synchro du labo (0bf0da65) : app.blade.php, README.md

This commit is contained in:
cloudion 2026-11-03 22:39:23 +00:00
parent ddb011b515
commit 5e12b84b0c
2 changed files with 379 additions and 2 deletions

View File

@ -1,3 +1,21 @@
# ploxion-machine
# ⧗ Machine à tsoins
PLOXION · La machine à tsoins dessinée : une console + deux entonnoirs-wormions + des flux RGB — capter un tsoin, le voir se former. · fournit: tsoin-machine, glyph-viz, wormion-io
La machine à tsoins dessinée : une console + deux entonnoirs-wormions + des flux RGB — capter un tsoin, le voir se former.
| | |
| --- | --- |
| id | `machine` |
| fournit | `tsoin-machine` `glyph-viz` `wormion-io` |
| bions qu'il nomme | `jOSApps` `jOSNexus` `jOSPorts` `jOSSession` `jOSStop` `jOSStore` `jOSTransport` `jOSTsoin` `jOSWire` `jOSWireshark` |
| fichiers | `app.blade.php` |
| dans le labo | `resources/views/ploxions/machine/` (dépôt `my_website2`) |
## Contribuer
- **Dans le xer** : https://labo.j0bot.ch/px/atelier?ploxion=machine — prends-le, modifie-le, vois-le tourner, « ⧗ envoyer le tsoin ».
- **Dans VS Code** : `xb prendre machine` (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.
© 2026 chill-tekk · ne pas nuire

359
app.blade.php Normal file
View File

@ -0,0 +1,359 @@
{{-- PL0XI0N machine ⧗ — LA MACHINE À TSOINS, dessinée par RS-7 (IMG_0208 / carnet) : une CONSOLE centrale
(l'état) + deux ENTONNOIRS-wormions (les I/O = tuyaux qui aspirent/crachent) + des flux RGB ondulés (les
tsoins multimodaux qui transitent) → un tsoin se forme au centre. Sous : un koin niché + une barre de
contrôle à mandala + une base trapèze. Rendu sur jGlyph.prim (contours imbriqués validés). Déterministe,
animé, zéro-dépendance. « Commencer à travailler avec le langage visuel. » --}}
<style>
.px-mach{position:relative;height:100%;background:#060810;overflow:hidden;font-family:var(--xr-font-ui,ui-sans-serif,system-ui);touch-action:manipulation}
.px-mach canvas{display:block;width:100%;height:100%}
.px-mach .kbp{position:absolute;bottom:8px;left:50%;transform:translateX(-50%);display:flex;align-items:center;gap:6px;z-index:3;
background:rgba(6,10,18,.74);border:1px solid rgba(90,110,160,.35);border-radius:12px;padding:5px 9px}
.px-mach .kbp__k{width:34px;height:30px;border-radius:8px;border:1px solid rgba(120,150,210,.35);background:rgba(16,24,42,.85);color:#cfe0f5;font-size:.9rem;cursor:pointer;display:flex;align-items:center;justify-content:center}
.px-mach .kbp__k:hover{border-color:rgba(120,180,255,.7)}
.px-mach .kbp__k.rec.on{background:#c0304a;border-color:#ff6a7a;color:#fff;animation:mach-rec 1.1s ease-in-out infinite}
@keyframes mach-rec{50%{opacity:.5}}
.px-mach .kbp__st{font-size:.66rem;color:#8aa0c8;font-family:ui-monospace,monospace;min-width:60px;max-width:230px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
.px-mach .lbl{position:absolute;top:8px;left:12px;font-size:.66rem;color:#5a6a90;pointer-events:none}
.px-mach .cnt{position:absolute;top:8px;right:12px;font-size:.62rem;color:#4a5a80;pointer-events:none;text-align:right}
.px-mach canvas{cursor:crosshair}
.px-mach .insp{position:absolute;top:44px;right:12px;width:min(230px,72%);background:rgba(9,14,28,.96);border:1px solid #3a4a8a;border-radius:12px;
padding:11px 12px;z-index:3;box-shadow:0 10px 34px #000b;font-size:.74rem;color:#dbe6ff}
.px-mach .insp[hidden]{display:none}
.px-mach .insp h5{margin:0 0 3px;font-size:.82rem;color:#8fd0ff;display:flex;align-items:center;gap:6px}
.px-mach .insp .meta{color:#7a8bb8;font-size:.66rem;font-family:ui-monospace,monospace;word-break:break-word;margin-bottom:8px}
.px-mach .insp .acts{display:flex;gap:6px;flex-wrap:wrap}
.px-mach .insp button{cursor:pointer;font:inherit;font-size:.72rem;padding:5px 9px;border-radius:8px;border:1px solid #4a5a9a;background:rgba(40,55,110,.5);color:#eaf0ff}
.px-mach .insp button:hover{border-color:#8fd0ff;color:#fff}
.px-mach .insp .x{position:absolute;top:6px;right:8px;border:0;background:none;color:#7a8bb8;font-size:.9rem;padding:2px}
.px-mach .toast{position:absolute;bottom:58px;left:50%;transform:translateX(-50%) translateY(8px);opacity:0;transition:.2s;
background:#12203e;border:1px solid #5a6ad0;color:#eaf0ff;border-radius:9px;padding:6px 13px;font-size:.74rem;z-index:4;pointer-events:none}
.px-mach .toast.on{opacity:1;transform:translateX(-50%) translateY(0)}
</style>
<script>
(function () {
'use strict';
function describe() {
var cs = []; try { cs = JSON.parse(localStorage.getItem('machine:cibles')) || []; } catch (e) {}
return { v: 1, id: 'machine', title: 'Machine à tsoins', icon: '⧗', items: [
{ p: 1, kind: 'stat', label: 'tsoins ciblés', value: cs.length }
] };
}
function mount(container, ctx) {
container.innerHTML = '<div class="px-mach"><canvas></canvas>' +
'<div class="lbl">⧗ machine à tsoins · clique un koin capté</div><div class="cnt" data-cnt></div>' +
'<div class="insp" data-insp hidden></div><div class="toast" data-toast></div>' +
'<div class="insp" data-gest hidden style="left:12px;right:auto;width:min(270px,80%)"></div>' +
'<button data-gestbtn style="position:absolute;right:12px;bottom:12px;z-index:3;cursor:pointer;background:rgba(16,24,42,.85);border:1px solid rgba(120,150,210,.4);color:#cfe0f5;border-radius:10px;padding:8px 13px;font:700 .76rem ui-sans-serif,system-ui" title="gestion des tsoins (mission /machine)">⚙ gérer</button>' +
'<div class="kbp" data-kbp>' +
'<button class="kbp__k rec" data-k="rec" title="enregistrer une session (⏺)">⏺</button>' +
'<button class="kbp__k" data-k="play" title="rejouer (étape 3)">▶</button>' +
'<button class="kbp__k" data-k="cut" title="couper (étape 4)">✂</button>' +
'<button class="kbp__k" data-k="del" title="supprimer (étape 4)">🗑</button>' +
'<button class="kbp__k" data-k="ff" title="accéléré = état final (étape 4)">⏭</button>' +
'<span class="kbp__st" data-kbpst>portion · clavier de montage</span>' +
'</div></div>';
var root = container.querySelector('.px-mach'), cv = root.querySelector('canvas'), g = cv.getContext('2d');
var cntEl = root.querySelector('[data-cnt]'), inspEl = root.querySelector('[data-insp]'), toastEl = root.querySelector('[data-toast]');
var hits = [], hitCenter = null, toastTimer = null, selIdx = -1;
function toast(m) { toastEl.textContent = m; toastEl.classList.add('on'); clearTimeout(toastTimer); toastTimer = setTimeout(function () { toastEl.classList.remove('on'); }, 1600); }
var DPR = Math.min(2, window.devicePixelRatio || 1), W = 0, H = 0, aborted = false, raf = null, t = 0;
var RGB = ['#ff3b52', '#39ff8a', '#4aa8ff'];
var frise = [], unwire = null, FRISE_WIN = 30000; // Étape 1 : les xerkions du bus qui défilent sur le temps (fenêtre 30 s)
var packets = []; // {funnel:-1|1, color, s:0..1, tsoin}
var captured = []; // tsoins formés dans la console
var GK = ['koin', 'wormion', 'portion', 'ploxion', 'trion'];
var TSOINS = [], tnext = 0, lastName = ''; // VRAIS tsoins (/bion-tsoins.json) — la machine les fait transiter
function nextTsoin() { if (!TSOINS.length) return { name: '', results: [], params: [] }; return TSOINS[tnext++ % TSOINS.length]; }
function glyphFor(ts) { var r = (ts.results || []).join(','), p = (ts.params || []).length;
if (r.indexOf('f64') >= 0) return 'wormion'; if (r.indexOf('i32') >= 0) return 'koin'; if (p > 1) return 'portion'; return 'ploxion'; }
// moteur de primitives : jGlyph si présent (labo), sinon fallback inline IDENTIQUE (autonome, marche partout)
var jg = window.jGlyph || (function () {
function shapePath(c, kind, cx, cy, r) { c.beginPath();
if (kind === 'wormion' || kind === 'spherion' || kind === 'rond') c.arc(cx, cy, r, 0, 7);
else if (kind === 'koin' || kind === 'triangle') { c.moveTo(cx, cy - r); c.lineTo(cx + r * 0.92, cy + r * 0.62); c.lineTo(cx - r * 0.92, cy + r * 0.62); c.closePath(); }
else if (kind === 'ploxion' || kind === 'losange') { c.moveTo(cx, cy - r); c.lineTo(cx + r, cy); c.lineTo(cx, cy + r); c.lineTo(cx - r, cy); c.closePath(); }
else if (kind === 'trion') { c.moveTo(cx - r, cy - r); c.lineTo(cx + r, cy - r); c.lineTo(cx - r, cy + r); c.closePath(); }
else c.rect(cx - r, cy - r, r * 2, r * 2);
}
return { shapePath: shapePath, prim: function (c, kind, cx, cy, r, color, rings) { rings = rings || 3; c.save(); c.strokeStyle = color || 'rgba(232,238,252,.92)'; c.lineWidth = Math.max(1.1, r * 0.085); c.lineJoin = 'round'; for (var i = 0; i < rings; i++) { var rr2 = r * (1 - i * (0.62 / rings)); if (rr2 < 2) break; shapePath(c, kind, cx, cy, rr2); c.stroke(); } c.restore(); } };
})();
function resize() { var r = root.getBoundingClientRect(); W = r.width; H = r.height; cv.width = W * DPR; cv.height = H * DPR; cv.style.width = W + 'px'; cv.style.height = H + 'px'; }
var ro = new ResizeObserver(resize); ro.observe(root); resize();
// VRAIS tsoins : le catalogue déterministe des bions=tsoins (dérivés du WASM du core). La machine
// les fait transiter par les entonnoirs → un tsoin RÉEL se forme dans la console (fusion avec l'existant).
fetch('/bion-tsoins.json', { cache: 'no-store' }).then(function (r) { return r.ok ? r.json() : null; })
.then(function (d) { if (!aborted && d && d.tsoins) TSOINS = d.tsoins; }).catch(function () {});
// ÉTAPE 1 — FRISE VIVANTE (plugion jOSWire→frise) : chaque event du bus = un xerkion qui défile sur le temps.
// RS-7 : « le vrai xerboxion, voir tous les xerkions défiler, voir le temps. » Rien à capturer : jOSWire voit déjà tout.
function glyphForWire(e) { var l = ((e && e.label) || '') + '';
if (e && e.kind === 'net') return 'wormion';
if (/son|sound|audio|music|spotif/i.test(l)) return 'wormion';
if (/tsoin|record|cast|seal/i.test(l)) return 'koin';
if (/win|window|open|close|nav|tab/i.test(l)) return 'portion';
if (/kion|xer|trion/i.test(l)) return 'trion';
return 'ploxion'; }
function friseCol(k) { return { koin: '#ff6b52', wormion: '#4aa8ff', portion: '#c14bff', ploxion: '#39ff8a', trion: '#ffc857' }[k] || '#8fb6ff'; }
function pushWire(e) { if (!e) return;
var _l = ((e.label || '') + ''); if (e.kind === 'net' && /boxion\/save|xion\/emit|\/rtc\/|enderchest|\/coord/.test(_l)) return; // ANTI-BOUCLE : ne pas se nourrir de son propre bruit réseau (sinon feedback loop → flood de /px/boxion/save)
var k = glyphForWire(e), col = friseCol(k);
frise.push({ ts: e.ts || Date.now(), k: k, col: col, label: ((e.label || '') + '') }); if (frise.length > 500) frise.shift();
if (packets.length < 8) packets.push({ funnel: ((e.id || 0) % 2 ? 1 : -1), color: col, s: 0, phase: t * 2, tsoin: { name: ((e.label || '') + '').slice(0, 24), results: [], params: [] }, wire: true }); }
try { if (window.jOSWireshark && window.jOSWireshark.subscribe) {
try { (window.jOSWireshark.list() || []).slice(-120).forEach(function (e) { frise.push({ ts: e.ts || Date.now(), k: glyphForWire(e), col: friseCol(glyphForWire(e)), label: ((e.label || '') + '') }); }); } catch (e) {}
unwire = window.jOSWireshark.subscribe(function (e) { if (!aborted) pushWire(e); });
} } catch (e) {}
// géométrie relative (s'adapte à la taille)
function consoleRect() { var w = Math.min(W * 0.34, 200), h = w * 0.62, x = W / 2 - w / 2, y = H * 0.30 - h / 2; return { x: x, y: y, w: w, h: h }; }
function funnelAxis(dir) { // dir=-1 gauche, +1 droite. mouth (haut, coin) -> throat (bord haut de la console)
var c = consoleRect();
var mouth = { x: W / 2 + dir * W * 0.34, y: H * 0.13 }, throat = { x: W / 2 + dir * c.w * 0.34, y: c.y + 4 };
return { mouth: mouth, throat: throat };
}
// ---- entonnoir-wormion (ellipses concentriques qui reculent = cône/vortex) ----
function drawFunnel(dir) {
var a = funnelAxis(dir), N = 7;
for (var i = 0; i < N; i++) {
var u = i / (N - 1);
var cx = a.mouth.x + (a.throat.x - a.mouth.x) * u, cy = a.mouth.y + (a.throat.y - a.mouth.y) * u;
var rx = (W * 0.14) * (1 - u * 0.82), ry = rx * 0.5;
var rot = dir * (0.5 + u * 0.4) + Math.sin(t * 0.6 + i) * 0.04;
g.save(); g.translate(cx, cy); g.rotate(rot);
g.beginPath(); g.ellipse(0, 0, Math.max(2, rx), Math.max(1.4, ry), 0, 0, 7);
g.strokeStyle = 'rgba(150,175,230,' + (0.13 + u * 0.22) + ')'; g.lineWidth = 1.1; g.stroke();
g.restore();
}
}
// ---- flux RGB ondulés le long de l'axe de l'entonnoir ----
function streamPoint(dir, u, wavePhase, amp) {
var a = funnelAxis(dir);
var bx = a.mouth.x + (a.throat.x - a.mouth.x) * u, by = a.mouth.y + (a.throat.y - a.mouth.y) * u;
var nx = -(a.throat.y - a.mouth.y), ny = (a.throat.x - a.mouth.x), nl = Math.hypot(nx, ny) || 1; nx /= nl; ny /= nl;
var off = Math.sin(u * 7 + wavePhase) * amp * (1 - u * 0.7);
return { x: bx + nx * off, y: by + ny * off };
}
function drawStreams(dir) {
for (var c = 0; c < 3; c++) {
g.beginPath();
for (var u = 0; u <= 1.001; u += 0.05) { var p = streamPoint(dir, u, t * 2 + c * 2.1, W * 0.03); u === 0 ? g.moveTo(p.x, p.y) : g.lineTo(p.x, p.y); }
g.strokeStyle = RGB[c]; g.globalAlpha = 0.5; g.lineWidth = 1.4; g.stroke(); g.globalAlpha = 1;
}
}
// ---- console centrale (l'état / le tsoin qui se forme) ----
function drawConsole() {
var c = consoleRect();
g.save(); g.strokeStyle = 'rgba(200,215,255,.85)'; g.lineWidth = 1.6;
rr(c.x, c.y, c.w, c.h, 8); g.stroke();
g.strokeStyle = 'rgba(120,145,210,.4)'; g.lineWidth = 1; g.beginPath(); g.moveTo(c.x + c.w * 0.1, c.y + c.h * 0.8); g.lineTo(c.x + c.w * 0.9, c.y + c.h * 0.2); g.stroke();
// les tsoins captés = mini-glyphes rangés dans la console
if (jg && jg.prim) {
var n = Math.min(captured.length, 8), gx = c.x + 14, gy = c.y + c.h - 16, r = Math.min(c.h * 0.16, 11);
hits.length = 0;
for (var i = 0; i < n; i++) {
var idx = captured.length - 1 - i, gxp = gx + i * (r * 2 + 4);
var seld = (selIdx === idx);
if (seld) { g.beginPath(); g.arc(gxp, gy, r + 5, 0, 7); g.strokeStyle = '#8fd0ff'; g.lineWidth = 1.6; g.stroke(); }
jg.prim(g, captured[idx].k, gxp, gy, r, captured[idx].col, 3);
hits.push({ x: gxp, y: gy, r: r + 5, idx: idx });
}
// glyphe « en cours de formation » au centre, qui pulse — CLIQUABLE = capter
var pr = r * (1.6 + Math.sin(t * 3) * 0.15);
jg.prim(g, 'wormion', c.x + c.w / 2, c.y + c.h * 0.42, pr, 'rgba(120,200,255,.9)', 3);
hitCenter = { x: c.x + c.w / 2, y: c.y + c.h * 0.42, r: pr + 6 };
}
if (lastName) { g.fillStyle = 'rgba(150,205,255,.95)'; g.font = '11px ui-monospace,monospace'; g.textAlign = 'center'; g.fillText('⧗ ' + lastName + '( )', c.x + c.w / 2, c.y - 9); }
g.restore();
}
// ---- koin niché + barre mandala + base (bas de IMG_0208) ----
function drawLower() {
if (!jg || !jg.prim) return;
var ky = H * 0.62, kr = Math.min(W * 0.16, H * 0.13);
jg.prim(g, 'koin', W / 2, ky, kr, 'rgba(210,220,255,.8)', 5);
// barre de contrôle
var by = H * 0.80, bh = H * 0.09, bx = W * 0.1, bw = W * 0.8;
g.strokeStyle = 'rgba(160,180,230,.55)'; g.lineWidth = 1.2; rr(bx, by, bw, bh, 6); g.stroke();
// mandala central (cadran)
var mx = W / 2, my = by + bh / 2, mr = bh * 0.42;
for (var i = 0; i < 4; i++) { g.beginPath(); g.arc(mx, my, mr * (1 - i * 0.22), 0, 7); g.strokeStyle = 'rgba(140,200,255,' + (0.7 - i * 0.13) + ')'; g.stroke(); }
for (var a2 = 0; a2 < 12; a2++) { var an = a2 / 12 * 6.283 + t * 0.3; g.beginPath(); g.moveTo(mx + Math.cos(an) * mr * 0.5, my + Math.sin(an) * mr * 0.5); g.lineTo(mx + Math.cos(an) * mr, my + Math.sin(an) * mr); g.strokeStyle = 'rgba(120,150,210,.4)'; g.stroke(); }
// rectangles latéraux
g.strokeStyle = 'rgba(150,170,220,.4)';
[0.16, 0.30, 0.66, 0.80].forEach(function (fx) { rr(bx + bw * fx - 14, my - 7, 26, 14, 3); g.stroke(); });
// base trapèze
g.beginPath(); g.moveTo(W * 0.14, H * 0.97); g.lineTo(W * 0.86, H * 0.97); g.lineTo(W * 0.78, H * 0.90); g.lineTo(W * 0.22, H * 0.90); g.closePath();
g.strokeStyle = 'rgba(150,170,220,.5)'; g.stroke();
}
function rr(x, y, w, h, r) { r = Math.min(r, w / 2, h / 2); g.beginPath(); g.moveTo(x + r, y); g.arcTo(x + w, y, x + w, y + h, r); g.arcTo(x + w, y + h, x, y + h, r); g.arcTo(x, y + h, x, y, r); g.arcTo(x, y, x + w, y, r); }
// ---- paquets RGB qui remontent l'entonnoir vers la console ----
function drawPackets() {
for (var i = packets.length - 1; i >= 0; i--) {
var pk = packets[i]; pk.s += 0.02;
if (pk.s >= 1) { // arrivé dans la console → un VRAI tsoin se forme
var ts = pk.tsoin || { name: '', results: [], params: [] };
captured.push({ k: glyphFor(ts), col: pk.color, name: ts.name, ts: ts }); if (captured.length > 40) captured.shift();
if (ts.name) lastName = ts.name;
try { if (!pk.wire && window.jOSPorts) window.jOSPorts.emit('machine', 'tsoin.formed', { name: ts.name, glyph: glyphFor(ts) }); } catch (e) {} // pas d'émission pour les paquets nourris par le bus (anti-boucle)
packets.splice(i, 1); continue;
}
var p = streamPoint(pk.funnel, pk.s, pk.phase, W * 0.03);
g.beginPath(); g.arc(p.x, p.y, 3.2, 0, 7); g.fillStyle = pk.color; g.shadowColor = pk.color; g.shadowBlur = 8; g.fill(); g.shadowBlur = 0;
}
}
function emitBurst() {
for (var k = 0; k < 6; k++) {
var dir = k % 2 ? 1 : -1, c = k % 3;
packets.push({ funnel: dir, color: RGB[c], s: -k * 0.06, phase: t * 2 + c * 2.1, tsoin: nextTsoin() });
}
}
// ---- ÉTAPE 1 : LA FRISE — les xerkions du bus qui défilent le long du TEMPS (bas), + scrubber-wormion « now » ----
function drawFrise() {
var fy = H - 48, x0 = 12, x1 = W - 12, span = Math.max(1, x1 - x0), now = Date.now(), vis = 0;
g.strokeStyle = 'rgba(120,150,210,.22)'; g.lineWidth = 1; g.beginPath(); g.moveTo(x0, fy); g.lineTo(x1, fy); g.stroke();
for (var i = 0; i < frise.length; i++) { var f = frise[i], age = now - f.ts; if (age < 0 || age > FRISE_WIN) continue;
var x = x1 - (age / FRISE_WIN) * span; if (x < x0) continue; vis++;
g.globalAlpha = 0.22 + 0.68 * (1 - age / FRISE_WIN);
try { jg.prim(g, f.k, x, fy, 4.6, f.col, 2); } catch (e) {} }
g.globalAlpha = 1;
for (var r = 0; r < 3; r++) { g.beginPath(); g.arc(x1, fy, 3 + r * 3, 0, 7); g.strokeStyle = 'rgba(120,220,240,' + (0.55 - r * 0.14) + ')'; g.lineWidth = 1.2; g.stroke(); }
g.fillStyle = 'rgba(150,175,230,.72)'; g.font = '10px ui-monospace,monospace';
g.fillText('frise · ' + vis + ' xerkions défilent · ' + (FRISE_WIN / 1000) + 's', x0, fy - 8);
}
function loop() {
if (aborted) return;
t += 0.016;
g.setTransform(DPR, 0, 0, DPR, 0, 0); g.clearRect(0, 0, W, H); g.fillStyle = '#060810'; g.fillRect(0, 0, W, H);
drawFunnel(-1); drawFunnel(1);
drawStreams(-1); drawStreams(1);
drawPackets();
drawConsole();
drawLower();
drawFrise();
cntEl.textContent = captured.length + ' captés · ' + frise.length + ' xerkions · ' + TSOINS.length + ' tsoins';
raf = requestAnimationFrame(loop);
}
// CLAVIER-PORTION (RS-7) : ⏺ = enregistrer une vraie SESSION via le plugion jOSSession (actions+xerkions, t0 partagé).
// play/cut/del/ff = étapes 3-4. Le format-session = le contrat que le core Rust produira nativement (capter tous les tsoins).
var kbpSt = root.querySelector('[data-kbpst]');
root.querySelector('[data-kbp]').addEventListener('click', function (e) {
var b = e.target.closest('[data-k]'); if (!b) return; var k = b.getAttribute('data-k');
if (k === 'rec') {
var S = window.jOSSession; if (!S) { toast('jOSSession indisponible'); return; }
if (S.isOn()) { var ses = S.stop(); b.classList.remove('on');
if (kbpSt) kbpSt.textContent = ses ? ('■ scellé — ' + ses.counts.actions + ' actions · ' + ses.counts.xerkions + ' xerkions') : '■ vide';
toast('■ session scellée'); emitBurst(); }
else { S.start('machine ' + new Date().toLocaleTimeString()); b.classList.add('on');
if (kbpSt) kbpSt.textContent = '● enregistrement — fais tes actions'; toast('● session lancée'); }
return;
}
toast('⧗ ' + k + ' — étape suivante (bientôt)');
});
// ---- USABLE : cliquer un koin capté = l'inspecter ; le centre = capter ----
function openInspect(idx) {
var it = captured[idx]; if (!it) { closeInspect(); return; }
selIdx = idx; var ts = it.ts || { name: it.name, params: [], results: [] };
inspEl.hidden = false;
inspEl.innerHTML = '<button class="x" data-close>✕</button>'
+ '<h5>' + gicon(it.k) + ' ' + esc(it.name || 'tsoin') + '</h5>'
+ '<div class="meta">glyphe : ' + it.k + '<br>params : ' + ((ts.params || []).join(', ') || '—') + '<br>résultat : ' + ((ts.results || []).join(', ') || '—') + '</div>'
+ '<div class="acts"><button data-act="replay">▶ rejouer</button><button data-act="seal">✦ sceller</button><button data-act="cast">→ bus</button></div>';
}
function closeInspect() { selIdx = -1; inspEl.hidden = true; }
function gicon(k) { return { koin: '△', wormion: '◎', portion: '▣', ploxion: '◇', trion: '◹' }[k] || '⧗'; }
function esc(s) { return window.jOSb.esc(s); }
function selTsoin() { var it = captured[selIdx]; return it ? (it.ts || { name: it.name, params: [], results: [] }) : null; }
inspEl.addEventListener('click', function (e) {
if (e.target.closest('[data-close]')) { closeInspect(); return; }
var b = e.target.closest('[data-act]'); if (!b) return; var it = captured[selIdx]; if (!it) return;
var ts = selTsoin(), a = b.getAttribute('data-act');
if (a === 'replay') {
try { window.jOSPorts && window.jOSPorts.emit('machine', 'tsoin.replay', { name: it.name }); } catch (er) {}
// MONTAGE LIVE : rejoue le pouvoir sous TRANSPORT (wormion-temps + accéléré + rewind)
if (window.jOSTransport && window.jOSTransport.play) {
var steps = Math.max(4, ((ts.params || []).length + (ts.results || []).length) || 6), evs = [];
for (var s = 0; s < steps; s++) evs.push({ t: s * 180, data: { i: s } });
var reel = {
dur: steps * 180 + 200, events: evs, title: '⧗ ' + (it.name || 'tsoin'),
// le xer CHANGE pendant le rejeu : le glyphe du pouvoir se forme au centre selon le curseur
render: function (pg, PW, PH, s2) {
pg.clearRect(0, 0, PW, PH); var cx2 = PW / 2, cy2 = PH / 2, rr2 = Math.min(PW, PH) * 0.30;
if (jg && jg.prim) { jg.prim(pg, it.k, cx2, cy2, rr2, it.col, Math.max(1, s2.fired || 1)); }
pg.strokeStyle = 'rgba(120,200,255,.4)'; pg.lineWidth = 1; pg.beginPath(); pg.arc(cx2, cy2, rr2 + 10, 0, 6.283 * (s2.frac || 0.001)); pg.stroke();
pg.fillStyle = '#eaf6ff'; pg.textAlign = 'center'; pg.font = '700 14px ui-sans-serif,system-ui';
pg.fillText((it.name || 'tsoin') + ' — ' + s2.fired + '/' + s2.events.length + (s2.frac >= 1 ? ' · état final' : ''), cx2, cy2 + rr2 + 40);
}
};
window.jOSTransport.play(reel, function () {
packets.push({ funnel: Math.random() < 0.5 ? 1 : -1, color: it.col, s: 0, phase: t * 2, tsoin: ts });
});
toast('▶ montage : ' + (it.name || 'tsoin') + ' (F = accéléré)');
} else {
for (var k = 0; k < 4; k++) packets.push({ funnel: k % 2 ? 1 : -1, color: it.col, s: -k * 0.08, phase: t * 2 + k, tsoin: ts }); toast('▶ rejoue ' + (it.name || 'tsoin'));
}
}
else if (a === 'seal') { try { window.jOSTsoin && window.jOSTsoin.mark && window.jOSTsoin.mark('machine', 'tsoin', { name: it.name, glyph: it.k }); } catch (er) {} try { window.jOSPorts && window.jOSPorts.emit('machine', 'tsoin.sealed', { name: it.name }); } catch (er) {} toast('✦ ' + (it.name || 'tsoin') + ' scellé'); }
else if (a === 'cast') { try { window.jOSPorts && window.jOSPorts.emit('machine', 'tsoin.cast', { name: it.name, glyph: it.k, params: ts.params, results: ts.results }); } catch (er) {} toast('→ ' + (it.name || 'tsoin') + ' envoyé au bus'); }
});
cv.addEventListener('click', function (e) {
var rect = cv.getBoundingClientRect(), mx = e.clientX - rect.left, my = e.clientY - rect.top;
for (var i = 0; i < hits.length; i++) { var hh = hits[i]; if (Math.hypot(mx - hh.x, my - hh.y) <= hh.r) { openInspect(hh.idx); return; } }
if (hitCenter && Math.hypot(mx - hitCenter.x, my - hitCenter.y) <= hitCenter.r) { emitBurst(); toast('⧗ capture…'); return; }
closeInspect();
});
// souffle : un léger flux continu même sans clic (la machine respire)
var breathe = setInterval(function () { if (!aborted && packets.length < 4) { var dir = Math.sin(t) > 0 ? 1 : -1, c = Math.floor(t) % 3; packets.push({ funnel: dir, color: RGB[c], s: 0, phase: t * 2 + c * 2.1, tsoin: nextTsoin() }); } }, 1400);
// ---- ⚙ GESTION (mission /machine rs-4) : Grand Tsoin + 24 sources + tsoin→cible + STOP TOUT ----
var gestEl = root.querySelector('[data-gest]'), SOURCES = [];
fetch('/px/tsoin-sources.json', { cache: 'no-store' }).then(function (r) { return r.ok ? r.json() : []; })
.then(function (d) { SOURCES = (Array.isArray(d) ? d : (d && d.sources)) || []; }).catch(function () {});
function cibles() { try { return JSON.parse(localStorage.getItem('machine:cibles')) || []; } catch (e) { return []; } }
function renderGest() {
var gtAll = []; try { var gt = window.jOSStore && window.jOSStore('grand-tsoin'); gtAll = (gt && gt.all) ? gt.all() : []; } catch (e) {}
var actif = false; try { actif = !!(window.jOSTsoin && window.jOSTsoin.isOn && window.jOSTsoin.isOn()); } catch (e) {}
var pl = (window.__PLOXIONS__ || []).slice(0, 200);
var last = captured.slice(-8), base = captured.length - last.length;
gestEl.innerHTML = '<button class="x" data-gclose>✕</button><h5>⚙ gestion des tsoins</h5>'
+ '<div class="meta">grand tsoin : ' + gtAll.length + ' entrées · sources : ' + SOURCES.length + '/24 · rec actif : ' + (actif ? 'OUI ⏺' : 'non') + '</div>'
+ '<div class="acts" style="margin-bottom:8px"><button data-gstop style="border-color:#ff6a7a;color:#ffb3ba;font-weight:800">■ STOP TOUT (Ctrl+.)</button>'
+ '<button data-gnexus title="pousser mes tsoins captés vers le nexus (rejeu décentralisé)">🛰 → nexus</button>'
+ '<button data-gnexpull title="tirer les tsoins du nexus (des autres)">⬇ nexus</button></div>'
+ '<div class="meta" data-nexus style="margin-bottom:6px;color:#8fd8ff"></div>'
+ '<div class="meta" style="margin-bottom:4px">câbler tsoin → cible (le casté déclenche la cible) :</div>'
+ '<div class="acts"><select data-gt style="max-width:44%;background:#0a1220;color:#dce7f7;border:1px solid #33507a;border-radius:7px;font-size:.7rem">'
+ (last.length ? last.map(function (c, i) { return '<option value="' + (base + i) + '">⧗ ' + (c.name || 'tsoin') + '</option>'; }).join('') : '<option value="-1">— capte d\'abord —</option>')
+ '</select><span>→</span><select data-gc style="max-width:40%;background:#0a1220;color:#dce7f7;border:1px solid #33507a;border-radius:7px;font-size:.7rem">'
+ pl.map(function (p) { return '<option value="' + p.id + '">' + (p.icon || '') + ' ' + (p.name || p.id) + '</option>'; }).join('') + '</select>'
+ '<button data-gwire>🔌 câbler</button></div>'
+ (cibles().length ? '<div class="meta" style="margin-top:6px">' + cibles().map(function (c) { return '⧗ ' + c.t + ' → ' + c.p; }).join('<br>') + '</div>' : '')
+ '<div class="meta" style="margin-top:6px">sources : ' + SOURCES.slice(0, 24).map(function (s) { return s.ploxion || s; }).join(' · ') + '</div>';
}
root.querySelector('[data-gestbtn]').onclick = function () { if (gestEl.hidden) { renderGest(); gestEl.hidden = false; } else gestEl.hidden = true; };
gestEl.addEventListener('click', function (e) {
if (e.target.closest('[data-gclose]')) { gestEl.hidden = true; return; }
if (e.target.closest('[data-gstop]')) { try { window.jOSStop && window.jOSStop.all('machine'); } catch (er) {} renderGest(); return; }
if (e.target.closest('[data-gnexus]')) { var nx = gestEl.querySelector('[data-nexus]'); if (!window.jOSNexus) { if (nx) nx.textContent = 'jOSNexus absent'; return; }
jOSNexus.push('tsoin', { tsoins: captured.slice(-20).map(function (c) { return { name: c.name, n: (c.events || []).length }; }), from: 'machine', ts: Date.now() }).then(function (ok) { if (nx) nx.textContent = ok ? '🛰 ' + Math.min(20, captured.length) + ' tsoins poussés au nexus (rejeu décentralisé)' : 'nexus hors ligne — gardé sur ton boxion, sync plus tard'; }); return; }
if (e.target.closest('[data-gnexpull]')) { var nx2 = gestEl.querySelector('[data-nexus]'); if (!window.jOSNexus) return;
jOSNexus.pull('tsoin').then(function (d) { var items = (d && d.items) || []; if (nx2) nx2.innerHTML = items.length ? '⬇ ' + items.length + ' tsoins du nexus : ' + items.slice(0, 8).map(function (it) { return (it.tsoins && it.tsoins[0] && it.tsoins[0].name) || 'tsoin'; }).join(' · ') : 'nexus vide ou hors ligne'; }); return; }
if (e.target.closest('[data-gwire]')) {
var ti = +gestEl.querySelector('[data-gt]').value, cid = gestEl.querySelector('[data-gc]').value;
var ts2 = captured[ti]; if (!ts2 || !cid) return;
try { window.jOSWire && window.jOSWire.add({ p: 'machine', port: 'tsoin' }, { p: cid, port: 'in' }); } catch (er) {}
var cs = cibles(); cs.push({ t: ts2.name || 'tsoin', p: cid }); try { localStorage.setItem('machine:cibles', JSON.stringify(cs.slice(-20))); } catch (er) {}
toast('🔌 ' + (ts2.name || 'tsoin') + ' → ' + cid + ' câblé'); renderGest(); return; }
});
loop();
return { unmount: function () { aborted = true; cancelAnimationFrame(raf); clearInterval(breathe); try { if (unwire) unwire(); } catch (e) {} try { ro.disconnect(); } catch (e) {} container.innerHTML = ''; } };
}
window.jOSApps = window.jOSApps || {};
window.jOSApps['machine'] = { manifest: { id: 'machine', name: 'Machine à tsoins', icon: '⧗' }, mount: mount, describe: describe };
})();
</script>