synchro du labo (9bfd7520) : app.blade.php, README.md

This commit is contained in:
cloudion 2026-11-11 00:05:54 +00:00
parent 892d7d075a
commit 1dff0123fb
2 changed files with 242 additions and 11 deletions

View File

@ -6,7 +6,7 @@ La porte de contribution : prends un ploxion, modifie-le dans le xer, vois-le to
| --- | --- |
| id | `atelier` |
| fournit | `contribution` `atelier` `dev` |
| bions qu'il nomme | `jOSApi` `jOSApiDriver` `jOSAppareil` `jOSApps` `jOSBoxion` `jOSCarte` `jOSCommandes` `jOSForge` `jOSGame` `jOSKion` `jOSMobile` `jOSPlug` `jOSPorts` `jOSQR` `jOSRepoverse` `jOSStore` `jOSSwipe` `jOSTsoin` |
| bions qu'il nomme | `jOSApi` `jOSApiDriver` `jOSAppareil` `jOSApps` `jOSBoxion` `jOSCarte` `jOSCommandes` `jOSForge` `jOSGame` `jOSKion` `jOSMobile` `jOSPlug` `jOSPorts` `jOSQR` `jOSRepoverse` `jOSStore` `jOSSwipe` `jOSTsoin` `jOSXerVues` `jOSXui` |
| fichiers | `app.blade.php` |
| dans le labo | `resources/views/ploxions/atelier/` (dépôt `my_website2`) |
@ -16,6 +16,6 @@ La porte de contribution : prends un ploxion, modifie-le dans le xer, vois-le to
- **Dans VS Code** : `xb prendre atelier` (ou l'extension xerboxion › ⇩ Prendre), puis ⧗ Envoyer.
- Le chemin complet : https://labo.j0bot.ch/px/contribuer
Ce dépôt est un **miroir** du labo (synchronisé par `bin/ploxions-forge.mjs`, depuis le commit `0bf0da65`) : une modif se propose par un tsoin ou une branche du labo, pas directement ici.
Ce dépôt est un **miroir** du labo (synchronisé par `bin/ploxions-forge.mjs`, depuis le commit `9bfd7520`) : une modif se propose par un tsoin ou une branche du labo, pas directement ici.
© 2026 chill-tekk · ne pas nuire

View File

@ -112,6 +112,31 @@
.atl__log .err{color:#ff9d9d}.atl__log .bus{color:#9df3c8}.atl__log .inf{opacity:.6}
.atl__frame{width:100%;height:280px;border:1px solid var(--xr-border,#22324f);border-radius:11px;background:#0a0f18;display:none}
.atl__frame.on{display:block}
.atl__modebar{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin:0 0 8px}
.atl__mode{padding:7px 11px;border:1px solid var(--xr-border,#22324f);border-radius:9px;background:transparent;color:inherit;font-size:.72rem;font-weight:700;cursor:pointer}
.atl__mode.on{border-color:var(--xr-accent,#3fe0d0);color:var(--xr-accent,#3fe0d0);background:rgba(63,224,208,.08)}
.atl__device{margin-left:auto;padding:7px 9px;border:1px solid var(--xr-border,#22324f);border-radius:9px;background:var(--xr-bg,#070b12);color:inherit;font:inherit;font-size:.72rem}
.atl__workbench{display:grid;grid-template-columns:minmax(0,1fr) minmax(320px,1fr);gap:10px;align-items:start}
.atl__pane{min-width:0}
.atl__pane-title{display:flex;align-items:center;justify-content:space-between;gap:8px;margin:0 0 6px;font-size:.68rem;text-transform:uppercase;letter-spacing:.07em;color:var(--xr-accent,#3fe0d0)}
.atl__viewport{display:flex;justify-content:center;align-items:flex-start;min-height:300px;padding:10px;background:rgba(255,255,255,.025);border:1px solid var(--xr-border,#22324f);border-radius:11px;overflow:auto}
.atl__viewport .atl__frame{flex:0 0 auto;min-width:0;margin:0}
.atl__viewport[data-device="phone"] .atl__frame{width:390px;height:690px}
.atl__viewport[data-device="tablet"] .atl__frame{width:768px;height:620px}
.atl__viewport[data-device="watch"] .atl__frame{width:240px;height:300px;border-radius:32px}
.atl__viewport[data-device="xer"] .atl__frame{width:520px;height:420px}
.atl__inspect{margin-top:7px;padding:9px;border:1px solid var(--xr-border,#22324f);border-radius:10px;background:rgba(255,255,255,.025);font:.7rem/1.45 var(--xr-font-mono,ui-monospace,monospace);min-height:48px}
.atl__inspect b{color:var(--xr-accent,#3fe0d0)}
.atl__inspect small{display:block;color:var(--xr-muted,#7f93c8);margin-top:3px}
.atl__inspecttools{display:flex;gap:6px;align-items:center;flex-wrap:wrap;margin-top:8px}
.atl__inspecttools input{width:76px;padding:5px 6px;border:1px solid var(--xr-border,#22324f);border-radius:7px;background:var(--xr-bg,#070b12);color:inherit;font:inherit}
.atl__inspecttools button{padding:5px 8px;border:1px solid var(--xr-accent,#3fe0d0);border-radius:7px;background:transparent;color:var(--xr-accent,#3fe0d0);font:inherit;cursor:pointer}
.atl__mode-test .atl__codepane{display:none}
.atl__mode-test .atl__previewpane{grid-column:1/-1}
.atl__mode-test .atl__viewport{min-height:520px}
.atl__mode-ui .atl__inspect{display:block}
.atl__mode-code .atl__inspect{opacity:.55}
@media (max-width:999px){.atl__workbench{grid-template-columns:1fr}.atl__mode-test .atl__previewpane{grid-column:auto}}
.atl__fw{position:relative}
.atl__fw.full{position:fixed;inset:0;z-index:9999;background:#0a0f18;padding:0;max-width:none}
.atl__fw.full .atl__frame{height:100%;border:0;border-radius:0}
@ -295,7 +320,8 @@
['jOSChart', 'jOSSound', 'jOSPlayer', 'jOSKion', 'jOSMobile', 'jOSMap', 'jOSSwipe', 'jOSApi', 'jOSApiDriver',
'jOSRepoverse', 'jOSPlug', 'jOSForge', 'jOSTsoin', 'jOSQR', 'jOSui', 'jOSSensor', 'jOSCarte', 'jOSSDK'].forEach(function (n) { window[n] = perm(); });
window.fetch = function () { return Promise.resolve({ ok: true, status: 200, headers: { get: function () { return null; } }, json: function () { return Promise.resolve({}); }, text: function () { return Promise.resolve(''); }, blob: function () { return Promise.resolve(new Blob()); }, clone: function () { return this; } }); };
window.requestAnimationFrame = function () { return 1; };
// (07.11) l'animation réelle : un ploxion qui dessine image par image (une fractale, un jeu) doit se voir tourner dans l'aperçu ;
// l'iframe est isolée (sandbox sans même-origine) et rendue invisible = le navigateur la ralentit lui-même
// --- exécute le code du brouillon (celui de l'utilisateur LUI-MÊME — self-XSS ok) ---
var okRun = true;
try { (0, eval)(window.__ATL_CODE__); }
@ -310,11 +336,29 @@
}
var root = document.getElementById('root'); var handle = null; var threw = null;
try { handle = app.mount(root, { id: id }); } catch (e) { threw = e; }
function inspect(el, eventName) {
if (!el || el === root || !root.contains(el)) return;
var r = el.getBoundingClientRect(), attrs = {};
Array.prototype.forEach.call(el.attributes || [], function (a) { attrs[a.name] = a.value; });
post({ xbAtl: 1, t: 'inspect', event: eventName, tag: el.tagName.toLowerCase(), id: el.id || '',
classes: el.className && typeof el.className === 'string' ? el.className : '',
attrs: attrs, text: (el.textContent || '').trim().slice(0, 120),
rect: { x: Math.round(r.x), y: Math.round(r.y), width: Math.round(r.width), height: Math.round(r.height) } });
}
root.addEventListener('mouseover', function (e) {
if (e.target && e.target.closest) inspect(e.target.closest('*'), 'survol');
}, true);
root.addEventListener('click', function (e) {
if (e.target && e.target.closest) inspect(e.target.closest('*'), 'sélection');
}, true);
setTimeout(function () {
var rendered = (root.innerHTML || '').replace(/\s+/g, '').length;
post({ xbAtl: 1, t: 'mounted', ok: !threw && rendered > 0 && !errors.length, id: id, rendered: rendered,
unmount: !!(handle && typeof handle.unmount === 'function'),
msg: threw ? ('mount() a levé : ' + threw.message) : (rendered ? '' : 'rien n\'est rendu') });
// (07.11) la vue xerploxion : le describe() part au parent (puis toutes les 2 s : l'état vivant), dessiné sur tous les écrans des xers
var envoyerXui = function () { var x = null, er = ''; try { x = typeof app.describe === 'function' ? app.describe() : null; } catch (e) { er = e.message; } try { post({ xbAtl: 1, t: 'xui', xui: x ? JSON.parse(JSON.stringify(x)) : null, err: er }); } catch (e2) { post({ xbAtl: 1, t: 'xui', xui: null, err: 'describe() pas sérialisable : ' + e2.message }); } };
envoyerXui(); setInterval(envoyerXui, 2000);
}, 150);
}
@ -356,7 +400,8 @@
ck('warn', /unmount\s*[:=]/.test(src), 'unmount présent (le droit au silence)', 'retourne { unmount } depuis mount()');
var inner = src.indexOf('innerHTML') >= 0;
ck('warn', !inner || /\besc\s*\(|jOSb\.esc|textContent/.test(src), 'esc() sur le HTML (la muraille XSS)', 'innerHTML sans esc() repéré — toute donnée passe par jOSb.esc()');
ck('warn', /describe\s*[:=]/.test(src), 'describe() XUI', 'décrit en p1–p5, le ploxion s\'affiche sur toutes les surfaces');
// (07.11) RS-7 : « la vue xerploxion, il faut l'implémenter tout le temps » : sans describe(), le ploxion n'existe sur aucun xer
ck('ko', /describe\s*[:=]/.test(src), 'describe() XUI (la vue xerploxion)', 'obligatoire : décrit en p1–p5, le ploxion s\'affiche sur tous les xers (32×32 d\'un cubion, montre, HUD, bureau)');
return out;
}
function checksLight(list) {
@ -401,7 +446,8 @@
// ================= le ploxion =================
function mount(container, ctx) {
var st = { view: 'pick', id: null, meta: null, src: '', orig: '', note: '', dirty: false, savedAt: '',
hist: [], q: '', queue: null, admin: false, detail: null, sent: null, dead: false, full: false };
hist: [], q: '', queue: null, admin: false, detail: null, sent: null, dead: false, full: false,
mode: 'code', device: 'desktop', inspect: null };
var busLog;
container.innerHTML =
@ -411,6 +457,7 @@
'<button class="atl__tab" data-tab="pick">🧩 prendre</button>' +
'<button class="atl__tab" data-tab="edit">✏️ l\'établi</button>' +
'<button class="atl__tab" data-tab="queue">⧗ la file</button>' +
'<button class="atl__tab" data-tab="recus">⇄ reçus</button>' +
'</div></div>' +
'<div class="atl__b" data-body></div></div>';
@ -430,8 +477,37 @@
}
// ---------- navigation ----------
// ---- ⇄ LA BOÎTE : ce qu'on m'a partagé (07.11 ; RS-7 : « partager mon atelier sur epsylaeu » ; AtelierPartageController) ----
function renderRecus() {
if (!st.recus) { jget('/atelier/recus').then(function (j) { st.recus = j.recus || []; if (!st.dead && st.view === 'recus') render(); }).catch(function () { st.recus = []; if (!st.dead && st.view === 'recus') render(); }); return '<div class="atl__msg">chargement de ta boîte…</div>'; }
var h = '<div class="atl__sec">⇄ reçus <small>les brouillons qu\'on t\'a partagés : vois-les tourner, prends-les dans ton établi, renvoie ton tsoin</small></div>';
if (!st.recus.length) return h + '<div class="atl__msg">rien encore. Dans l\'établi, « ⇄ partager » envoie ton brouillon à un ami.</div>';
st.recus.forEach(function (x) {
h += '<div class="atl__row" style="display:block;cursor:default"><b>' + esc(x.ploxion) + '</b> <span class="atl__chip">' + esc(x.nom_de) + '</span> <span class="atl__chip">' + esc(String(x.lignes || '')) + ' lignes</span> <span class="atl__chip">' + esc((x.at || '').slice(0, 16).replace('T', ' ')) + '</span>' +
(x.note ? '<div class="atl__note">« ' + esc(x.note) + ' »</div>' : '') +
'<div style="display:flex;gap:7px;flex-wrap:wrap;margin:6px 0"><button class="atl__btn" data-rapercu="' + esc(x.uid) + '">▶ aperçu</button><button class="atl__btn atl__btn--go" data-rprendre="' + esc(x.uid) + '">⇩ prendre dans mon établi</button><button class="atl__btn" data-roublier="' + esc(x.uid) + '">✕</button></div>' +
'<iframe class="atl__frame" data-rframe="' + esc(x.uid) + '" sandbox="allow-scripts" title="le brouillon partagé (bac à sable)"></iframe></div>';
});
return h;
}
function wireRecus() {
container.querySelectorAll('[data-rapercu]').forEach(function (b) { b.addEventListener('click', function () {
var u = b.getAttribute('data-rapercu'), fr = container.querySelector('[data-rframe="' + u + '"]');
jget('/atelier/recus/' + encodeURIComponent(u)).then(function (x) { fr.classList.add('on'); fr.srcdoc = frameHtml(x.source || '', { id: x.ploxion }); });
}); });
container.querySelectorAll('[data-rprendre]').forEach(function (b) { b.addEventListener('click', function () {
var u = b.getAttribute('data-rprendre'); b.disabled = true; b.textContent = '…';
jget('/atelier/recus/' + encodeURIComponent(u)).then(function (x) {
return jpost('/atelier/draft/' + encodeURIComponent(x.ploxion), { source: x.source, note: 'partagé par ' + x.nom_de }).then(function () { take(x.ploxion); });
}).catch(function (e) { b.disabled = false; b.textContent = '✕ ' + (e.message || e); });
}); });
container.querySelectorAll('[data-roublier]').forEach(function (b) { b.addEventListener('click', function () {
jpost('/atelier/recus/' + encodeURIComponent(b.getAttribute('data-roublier')) + '/oublier', {}).then(function () { st.recus = null; render(); });
}); });
}
function setTab(v) {
st.view = v; st.detail = null;
if (v === 'recus') st.recus = null;
if (v === 'queue' && !st.queue) refreshQueue();
render();
}
@ -568,16 +644,29 @@
'<button class="atl__tool" data-findtog title="chercher dans le code">🔍</button>' +
'<button class="atl__tool" data-reset title="recharger le source du repo">♻️</button>' +
'<button class="atl__btn atl__btn--go" data-run>▶ voir tourner</button>' +
'<button class="atl__btn" data-partager title="envoyer ce brouillon à un ami (sa boîte : atelier › ⇄ reçus)">⇄ partager</button>' +
'<button class="atl__tool" data-full title="plein écran">⛶</button>' +
'<span class="atl__status" data-status>' + (st.savedAt ? '💾 brouillon du ' + esc(st.savedAt.slice(0, 16).replace('T', ' ')) : 'pas encore de brouillon') + '</span>' +
'</div>';
h += '<div class="atl__find" data-find><input class="atl__in" data-findq placeholder="chercher… (entrée = suivant)"><button class="atl__btn" data-findgo>↓</button></div>';
h += '<div class="atl__ed" data-edwrap><pre class="atl__gut" data-gut></pre>' +
h += '<div class="atl__modebar">' +
'<button class="atl__mode' + (st.mode === 'ui' ? ' on' : '') + '" data-mode="ui">◇ mode UI</button>' +
'<button class="atl__mode' + (st.mode === 'code' ? ' on' : '') + '" data-mode="code">⌘ mode code</button>' +
'<button class="atl__mode' + (st.mode === 'test' ? ' on' : '') + '" data-mode="test">▶ mode test</button>' +
'<select class="atl__device" data-device aria-label="vue de sortie"><option value="desktop">bureau · 100%</option><option value="phone">téléphone · 390px</option><option value="tablet">iPad · 768px</option><option value="watch">montre · 240px</option><option value="xer">xer · 520px</option></select>' +
'</div>';
h += '<div class="atl__workbench atl__mode-' + esc(st.mode || 'code') + '" data-workbench>' +
'<section class="atl__pane atl__codepane"><div class="atl__pane-title"><span>code source</span><span class="atl__muted">édition directe</span></div>' +
'<div class="atl__ed" data-edwrap><pre class="atl__gut" data-gut></pre>' +
'<div class="atl__code"><pre class="atl__hl" data-hl aria-hidden="true"></pre>' +
'<textarea class="atl__ta" data-ta spellcheck="false" wrap="off" autocapitalize="off" autocomplete="off" autocorrect="off"></textarea></div></div>';
'<textarea class="atl__ta" data-ta spellcheck="false" wrap="off" autocapitalize="off" autocomplete="off" autocorrect="off"></textarea></div></div></section>' +
'<section class="atl__pane atl__previewpane"><div class="atl__pane-title"><span>aperçu vivant</span><span class="atl__muted" data-preview-status>en attente</span></div>' +
'<div class="atl__viewport" data-viewport data-device="desktop"><div class="atl__fw" data-fw><button class="atl__fx" data-unfull>✕ fermer</button><iframe class="atl__frame" data-frame sandbox="allow-scripts" title="ton ploxion qui tourne"></iframe></div></div>' +
'<div class="atl__inspect" data-inspect><b>Inspection</b><small>Survole ou clique un élément dans l’aperçu en mode UI pour retrouver son tag, ses attributs, sa taille et sa ligne probable.</small></div>' +
'<div class="atl__inspecttools" data-inspecttools style="display:none"><label>W <input data-ui-width type="number" min="1" max="2400"></label><label>H <input data-ui-height type="number" min="1" max="1600"></label><button data-apply-size>appliquer la taille</button></div></section></div>';
h += '<div class="atl__log" data-log></div>';
h += '<div class="atl__fw" data-fw><button class="atl__fx" data-unfull>✕ fermer</button>' +
'<iframe class="atl__frame" data-frame sandbox="allow-scripts" title="ton ploxion qui tourne"></iframe></div>';
// (07.11) RS-7 : « il faut pouvoir voir toutes les vues dans l'atelier, et surtout sur les xers qu'on va mettre dans les cubions »
h += '<div class="atl__sec">◫ les vues <small>le describe() sur les écrans des xers (jOSXerVues) ; ▶ voir tourner pour les remplir</small></div><div data-vues class="atl__note">▶ voir tourner : chaque écran montre ce que ton ploxion y dit</div>';
h += '<div class="atl__sec">✅ les checks (verify-lite)</div><div data-checks></div>';
h += '<div class="atl__send" data-send>' +
'<b style="font-size:.9rem">⧗ envoyer le tsoin</b>' +
@ -593,10 +682,51 @@
function wireEdit() {
var ta = $('[data-ta]'), pre = $('[data-hl]'), gut = $('[data-gut]'), frame = $('[data-frame]');
// ◫ les vues : le describe() que l'aperçu renvoie, dessiné sur chaque écran de xer
var vuesEl = $('[data-vues]'), vues = null;
if (st._onMsg) window.removeEventListener('message', st._onMsg);
st._onMsg = function (ev) {
if (!frame || ev.source !== frame.contentWindow) return;
var d = ev.data; if (!d || !d.xbAtl || d.t !== 'xui' || !vuesEl) return;
if (!d.xui) { vues = null; vuesEl.innerHTML = '<b style="color:#ff8a8a">✕ pas de vue xerploxion</b> : ' + esc(d.err || 'ce ploxion n\'a pas de describe()') + '. Sans lui, il n\'existe sur aucun xer (le 32×32 d\'un cubion, la montre, le HUD). Ajoute <code>describe: function () { return { v: 1, id, title, icon, items: [{ p: 1, kind: \'stat\', label, value }] }; }</code>'; return; }
if (!window.jOSXerVues) { vuesEl.textContent = 'le bion jOSXerVues manque ici'; return; }
st._xui = d.xui;
if (!vues) { vuesEl.innerHTML = '<div data-vg></div><div class="atl__sendrow" style="margin-top:8px"><button class="atl__btn" data-montre>⌚ sur ma montre</button><span class="atl__note" data-montre-etat style="margin:0"></span></div>'; vues = window.jOSXerVues.galerie(vuesEl.querySelector('[data-vg]'), d.xui); vuesEl.querySelector('[data-montre]').onclick = surMontre; }
else vues.maj(d.xui);
};
// ⌚ épingler ce ploxion sur la montre (XuiMontreController) : le XUI compact, que l'app Connect IQ lit avec la clé du compte
function compacter(x) {
try { if (window.jOSXui && window.jOSXui.compact) return window.jOSXui.compact(x); } catch (e) {}
return [x.id, x.title || x.id, (x.items || []).map(function (it) { return [it.p || 3, it.kind || 'stat', it.label || '', it.value == null ? '' : it.value, it.unit || '']; })];
}
function surMontre() {
var et = vuesEl.querySelector('[data-montre-etat]'); if (!st._xui) return;
var csrf = (document.querySelector('meta[name=csrf-token]') || {}).content || '';
fetch('/xui/montre', { method: 'POST', credentials: 'same-origin', headers: { 'Content-Type': 'application/json', Accept: 'application/json', 'X-CSRF-TOKEN': csrf }, body: JSON.stringify({ id: st.id, xuic: compacter(st._xui) }) })
.then(function (r) { return r.json().catch(function () { return { ok: false, erreur: 'HTTP ' + r.status }; }); })
.then(function (j) { if (et) et.innerHTML = j.ok ? '✓ sur ta montre (' + esc(j.epingles.join(', ')) + ') · clé de la montre : <b>' + esc(j.cle) + '</b> (à mettre dans Garmin Connect › l\'app xer › réglages)' : '✕ ' + esc(j.erreur || 'refusé'); })
.catch(function (e) { if (et) et.textContent = '✕ ' + e.message; });
}
window.addEventListener('message', st._onMsg);
var logEl = $('[data-log]'), statusEl = $('[data-status]');
if (!ta) return;
busLog = [];
ta.value = st.src;
var viewport = $('[data-viewport]'), device = $('[data-device]');
if (viewport) viewport.setAttribute('data-device', st.device || 'desktop');
if (device) {
device.value = st.device || 'desktop';
device.addEventListener('change', function () {
st.device = device.value;
if (viewport) viewport.setAttribute('data-device', st.device);
});
}
container.querySelectorAll('[data-mode]').forEach(function (b) {
b.addEventListener('click', function () {
st.mode = b.getAttribute('data-mode') || 'code';
render();
});
});
function paint() {
pre.innerHTML = hl(ta.value) + '\n';
@ -615,6 +745,59 @@
logEl.scrollTop = logEl.scrollHeight;
}
st._log = log;
function sourceLine(info) {
var lines = st.src.split('\n'), needles = [];
if (info.id) needles.push('id="' + info.id + '"', "id='" + info.id + "'");
(info.classes || '').split(/\s+/).filter(Boolean).slice(0, 3).forEach(function (c) {
needles.push('.' + c, 'class="' + c, 'class=\'' + c);
});
Object.keys(info.attrs || {}).forEach(function (k) {
if (k.indexOf('data-') === 0) needles.push(k);
});
needles.push('<' + info.tag);
var best = { line: 0, score: -1 };
lines.forEach(function (line, i) {
var score = needles.reduce(function (n, needle) { return n + (line.indexOf(needle) >= 0 ? 1 : 0); }, 0);
if (score > best.score) best = { line: i + 1, score: score };
});
return best.score > 0 ? best.line : null;
}
function renderInspect(info) {
var box = $('[data-inspect]'), tools = $('[data-inspecttools]');
if (!box || !info) return;
var attrs = Object.keys(info.attrs || {}).map(function (k) { return k + (info.attrs[k] ? '="' + info.attrs[k] + '"' : ''); }).join(' ');
var line = sourceLine(info);
box.innerHTML = '<b>' + esc((info.event === 'survol' ? 'Survol' : 'Sélection') + ' · <' + info.tag + '>') + '</b>' +
'<small>' + esc((info.classes ? '.' + info.classes : '') + (info.id ? ' #' + info.id : '') + ' · ' + (info.rect ? info.rect.width + ' × ' + info.rect.height + ' px' : 'taille inconnue')) +
(line ? ' · ligne probable ' + line : ' · ligne non déterminée') + '<br>' + esc(attrs || 'aucun attribut') + '</small>';
if (tools) tools.style.display = 'flex';
var wi = $('[data-ui-width]'), hi = $('[data-ui-height]');
if (wi) wi.value = info.rect && info.rect.width || '';
if (hi) hi.value = info.rect && info.rect.height || '';
st.inspect = info;
}
if (st.messageHandler) window.removeEventListener('message', st.messageHandler);
st.messageHandler = function (e) {
if (st.dead || !e.data || e.data.xbAtl !== 1 || e.data.t !== 'inspect') return;
if (frame.contentWindow && e.source !== frame.contentWindow) return;
renderInspect(e.data);
};
window.addEventListener('message', st.messageHandler);
function selectorFor(info) {
if (info.id) return '#' + info.id;
var first = (info.classes || '').split(/\s+/).filter(Boolean)[0];
return first ? '.' + first : info.tag;
}
var applySize = $('[data-apply-size]');
if (applySize) applySize.addEventListener('click', function () {
if (!st.inspect) return;
var w = parseInt(($('[data-ui-width]') || {}).value, 10), h = parseInt(($('[data-ui-height]') || {}).value, 10);
if (!w || !h || w > 2400 || h > 1600) { log('err', 'taille invalide (1–2400 × 1–1600 px)'); return; }
var css = '<style data-atelier-ui>\n' + selectorFor(st.inspect) + ' { width: ' + w + 'px; min-height: ' + h + 'px; }\n</style>';
st.src = st.src.replace(/<style data-atelier-ui>[\s\S]*?<\/style>\s*/gi, '').replace(/\s*$/, '\n') + css + '\n';
st.dirty = true; ta.value = st.src; paint(); refreshChecks(); runPreview();
log('ok', 'taille appliquée à ' + selectorFor(st.inspect) + ' — tu peux encore l’ajuster dans le code');
});
// un Ctrl+S dans VS Code : le texte, la coloration, les checks, puis l'aperçu (sans reconstruire l'établi)
st._recharger = function () {
if (!ta.isConnected) { st._recharger = null; render(); return; }
@ -687,6 +870,22 @@
frame.srcdoc = frameHtml(st.src, { id: st.id });
}
$('[data-run]').addEventListener('click', runPreview);
// ⇄ partager ce brouillon : choisir un ami, il le reçoit dans sa boîte (atelier › ⇄ reçus)
var bPart = $('[data-partager]');
if (bPart) bPart.addEventListener('click', function () {
var zone = $('[data-partage]');
if (!zone) { bPart.insertAdjacentHTML('afterend', '<span data-partage style="display:inline-flex;gap:6px;align-items:center;flex-wrap:wrap"></span>'); zone = $('[data-partage]'); }
zone.innerHTML = '…';
jget('/px/friends').then(function (j) {
var l = (j.friends || []).filter(function (f) { return f.status === 'accepted'; });
if (!l.length) { zone.textContent = 'pas encore d\'amis (ploxion amis)'; return; }
zone.innerHTML = '<select class="atl__in" data-partage-a style="width:auto;padding:7px 10px">' + l.map(function (f) { return '<option value="' + f.id + '">' + esc(f.name) + '</option>'; }).join('') + '</select><button class="atl__btn atl__btn--go" data-partage-go>⇄ envoyer</button>';
zone.querySelector('[data-partage-go]').addEventListener('click', function () {
var a = +zone.querySelector('[data-partage-a]').value;
jpost('/atelier/partager/' + encodeURIComponent(st.id), { a: a, source: st.src, note: (st.note || '') }).then(function (r) { zone.textContent = r.ok ? '✓ envoyé à ' + r.a + ' (sa boîte : atelier › ⇄ reçus)' : '✕ ' + (r.erreur || r._status); });
});
}).catch(function (e) { zone.textContent = '✕ ' + (e.message || e); });
});
var run2 = $('[data-run2]');
if (run2) run2.addEventListener('click', function () {
runPreview();
@ -714,6 +913,7 @@
});
paint(); refreshChecks();
runPreview();
if (st.sent) renderSent();
}
@ -862,17 +1062,43 @@
// du contributeur, marque appliqué), puis ⇪ déployer — les deux par le runner de l'hôte (jOSCommandes), deux temps chacun
var cmdOk = !!window.jOSCommandes;
h += '<div style="display:flex;gap:7px;flex-wrap:wrap;margin:8px 0">' +
// (07.11) ⇪ publier : appliquer + déployer d'un geste (RS-7 : « un bouton publier le ploxion »), même si le tsoin était marqué appliqué sans être dans le repo
(cmdOk && it.status !== 'refuse' ? '<button class="atl__btn atl__btn--go" data-publier>⇪ publier le ploxion</button>' : '') +
(cmdOk && it.status === 'envoye' ? '<button class="atl__btn atl__btn--go" data-repo>⇶ appliquer dans le repo</button>' : '') +
(cmdOk ? '<button class="atl__btn" data-deploy>⇪ déployer le labo</button>' : '') +
'<button class="atl__btn" data-st="applique">✓ marquer appliqué</button>' +
'<button class="atl__btn" data-st="refuse">✗ refuser</button>' +
'<button class="atl__btn" data-st="envoye">⧗ renvoyer en file</button></div>' +
'<pre class="atl__note" data-sortie style="white-space:pre-wrap;max-height:220px;overflow:auto;display:none"></pre>' +
'<div class="atl__note">⇶ écrit le ploxion dans le repo (et son entrée de registre s\'il est neuf), vérifie qu\'il se monte, committe au nom du contributeur ; ⇪ le met en ligne. « marquer appliqué » ne fait que tenir le statut.</div>';
'<div class="atl__note">⇪ publier = appliquer puis déployer, d\'un geste (le ploxion est en ligne à la fin). ⇶ écrit le ploxion dans le repo (et son entrée de registre s\'il est neuf), vérifie qu\'il se monte, committe au nom du contributeur ; ⇪ le met en ligne. « marquer appliqué » ne fait que tenir le statut.</div>';
}
// le diff TEXTE — jamais monté, jamais exécuté : le code des autres ne tourne pas ici
// (07.11) ▶ L'APERÇU d'un tsoin (RS-7 : « dans l'atelier j'ai même pas l'aperçu, c'est important ») : le code d'un autre tourne dans le
// BAC À SABLE de l'établi (iframe sandbox="allow-scripts", sans allow-same-origin : origine opaque, ni cookies ni session, bions stubbés),
// jamais dans la page ; ses vues sur les écrans des xers (jOSXerVues) à côté. Le diff texte reste en dessous.
if (it.source) {
h += '<div style="display:flex;gap:7px;flex-wrap:wrap;margin:8px 0"><button class="atl__btn atl__btn--go" data-apercu>▶ aperçu (bac à sable)</button><button class="atl__tool" data-apercu-full title="plein écran">⛶</button></div>' +
'<div class="atl__fw" data-qfw><button class="atl__fx" data-qunfull>✕ fermer</button><iframe class="atl__frame" data-qframe sandbox="allow-scripts" title="le tsoin qui tourne (bac à sable)"></iframe></div>' +
'<div data-qvues class="atl__note"></div>';
}
// le diff TEXTE, en dessous
h += renderDiff(it.current || '', it.source || '') + '</div>';
box.className = ''; box.innerHTML = h;
var qf = box.querySelector('[data-qframe]'), qv = box.querySelector('[data-qvues]'), qg = null;
if (qf) {
if (st._onQMsg) window.removeEventListener('message', st._onQMsg);
st._onQMsg = function (ev) {
if (ev.source !== qf.contentWindow) return; var d = ev.data; if (!d || !d.xbAtl) return;
if (d.t === 'err') { qv.insertAdjacentHTML('beforeend', '<div style="color:#ff8a8a">✕ ' + esc(d.msg) + '</div>'); return; }
if (d.t !== 'xui') return;
if (!d.xui) { qv.innerHTML = '<b style="color:#ff8a8a">✕ pas de vue xerploxion</b> : ' + esc(d.err || 'pas de describe()'); return; }
if (window.jOSXerVues) { if (!qg) qg = window.jOSXerVues.galerie(qv, d.xui); else qg.maj(d.xui); }
};
window.addEventListener('message', st._onQMsg);
var lancerApercu = function () { qf.classList.add('on'); qv.textContent = '… ça monte (bac à sable)'; qg = null; qf.srcdoc = frameHtml(it.source, { id: it.ploxion }); };
box.querySelector('[data-apercu]').addEventListener('click', lancerApercu);
box.querySelector('[data-apercu-full]').addEventListener('click', function () { box.querySelector('[data-qfw]').classList.add('full'); if (!qf.srcdoc) lancerApercu(); });
box.querySelector('[data-qunfull]').addEventListener('click', function () { box.querySelector('[data-qfw]').classList.remove('full'); });
}
if (st.admin) {
var sortie = box.querySelector('[data-sortie]');
function lancerCmd(btn, id, args) {
@ -888,6 +1114,7 @@
}
var bRepo = box.querySelector('[data-repo]'), bDep = box.querySelector('[data-deploy]');
if (bRepo) bRepo.addEventListener('click', function () { lancerCmd(bRepo, 'tsoin-appliquer', { id: it.id }); });
var bPub = box.querySelector('[data-publier]'); if (bPub) bPub.addEventListener('click', function () { lancerCmd(bPub, 'tsoin-publier', { id: it.id }); });
if (bDep) bDep.addEventListener('click', function () { lancerCmd(bDep, 'deploy', {}); });
box.querySelectorAll('[data-st]').forEach(function (b) {
b.addEventListener('click', function () {
@ -910,6 +1137,7 @@
});
if (st.view === 'pick') { body.innerHTML = renderPick(); wirePick(); }
else if (st.view === 'edit') { body.innerHTML = renderEdit(); wireEdit(); }
else if (st.view === 'recus') { body.innerHTML = renderRecus(); wireRecus(); }
else { body.innerHTML = renderQueue(); wireQueue(); if (st.detail) loadDetail(); }
}
function wirePick() {
@ -983,8 +1211,11 @@
return {
unmount: function () {
st.dead = true;
if (st._onMsg) { window.removeEventListener('message', st._onMsg); st._onMsg = null; }
if (st._onQMsg) { window.removeEventListener('message', st._onQMsg); st._onQMsg = null; }
clearInterval(saveTimer);
if (lieTimer) clearInterval(lieTimer);
if (st.messageHandler) window.removeEventListener('message', st.messageHandler);
saveDraft(true); // best effort — le brouillon ne se perd pas
if (offBus) { try { offBus(); } catch (e) {} }
container.innerHTML = '';