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

This commit is contained in:
cloudion
2026-11-03 22:42:30 +00:00
commit 0dfe30886f
2 changed files with 225 additions and 0 deletions

204
app.blade.php Normal file
View File

@@ -0,0 +1,204 @@
{{-- PL0XION cosmos — LA MAP ZOOMABLE de tes ploxions (RS-7 : « sur téléphone il faut
un vrai truc avec la map où on zoom et dezoome »). Tous les ploxions posés dans
un espace ; pinch/molette = zoom, drag = navigue, tap = ouvre. Le pendant mobile
du bureau, esprit zoom wormion/portion (navigation égocentrique). 100% DOM +
transform GPU. (Le `map` existant = carte du réel/transports, autre chose.)
window.jOSApps['cosmos']. mount(c, ctx) -> { unmount }. --}}
<style>
.mp { position:relative; height:100%; overflow:hidden; background:radial-gradient(circle at 50% 50%, rgba(18,24,40,.6), var(--xr-bg,#05060c) 80%);
font-family:ui-sans-serif,system-ui,sans-serif; touch-action:none; cursor:grab; }
.mp.drag { cursor:grabbing; }
.mp__world { position:absolute; left:0; top:0; transform-origin:0 0; will-change:transform; }
.mp__node { position:absolute; width:104px; margin-left:-52px; margin-top:-52px; display:flex; flex-direction:column; align-items:center; gap:6px; cursor:pointer; user-select:none; }
.mp__ic { width:62px; height:62px; border-radius:18px; display:flex; align-items:center; justify-content:center; font-size:30px;
background:rgba(22,28,46,.85); border:1px solid rgba(130,165,240,.35); box-shadow:0 6px 22px rgba(0,0,0,.45); transition:transform .1s, border-color .1s; }
.mp__node:hover .mp__ic, .mp__node:active .mp__ic { transform:scale(1.12); border-color:rgba(160,195,255,.85); }
.mp__nm { font-size:12px; color:rgba(210,222,245,.85); text-align:center; max-width:100px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.mp__hud { position:absolute; left:11px; top:10px; font-size:.7rem; color:rgba(170,200,255,.85); font-family:ui-monospace,monospace; background:rgba(8,12,22,.6); padding:3px 9px; border-radius:8px; pointer-events:none; }
.mp__tools { position:absolute; right:11px; top:10px; display:flex; gap:5px; }
.mp__b { cursor:pointer; width:30px; height:30px; border-radius:8px; border:1px solid rgba(130,165,240,.35); background:rgba(16,22,38,.8); color:#cfe; font-size:16px; }
.mp__b:hover { background:rgba(40,55,95,.8); color:#fff; }
.mp__f { position:absolute; left:11px; bottom:10px; right:11px; max-width:320px; }
.mp__f input { width:100%; box-sizing:border-box; padding:7px 11px; border-radius:9px; border:1px solid rgba(130,165,240,.3); background:rgba(12,16,28,.85); color:#fff; font-family:inherit; font-size:.82rem; outline:none; }
/* menu d'action (tap sur un ploxion -> choisir l'action) + sélection cubion */
.mp__node.pick .mp__ic { border-color:rgba(120,255,180,.9); box-shadow:0 0 0 2px rgba(120,255,180,.5), 0 6px 22px rgba(0,0,0,.45); }
.mp__menu { position:absolute; z-index:30; background:rgba(11,15,27,.98); border:1px solid rgba(130,165,240,.45); border-radius:13px; padding:6px; box-shadow:0 14px 48px rgba(0,0,0,.65); min-width:158px; max-width:240px; }
.mp__mh { display:flex; align-items:center; gap:8px; padding:5px 8px 8px; border-bottom:1px solid rgba(130,165,240,.18); margin-bottom:5px; }
.mp__mh .g { font-size:1.25rem; } .mp__mh .n { font-weight:700; color:#dce8ff; font-size:.83rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.mp__mi { display:flex; align-items:center; gap:9px; padding:8px 9px; border-radius:8px; cursor:pointer; color:#cdddf5; font-size:.81rem; }
.mp__mi:hover { background:rgba(60,90,160,.5); color:#fff; }
.mp__mi.on { background:rgba(35,120,85,.45); color:#dffded; }
.mp__io { font-size:.66rem; color:rgba(185,208,238,.8); padding:6px 9px 2px; line-height:1.5; }
.mp__io b { color:#86efc7; } .mp__io .k { color:rgba(150,180,230,.75); }
.mp__craft { position:absolute; left:50%; bottom:52px; transform:translateX(-50%); z-index:25; cursor:pointer; padding:9px 17px; border-radius:22px; border:0;
background:#5b8cff; color:#03122e; font-weight:800; font-size:.82rem; box-shadow:0 6px 24px rgba(0,0,0,.55); }
.mp__craft:hover { filter:brightness(1.08); }
/* VERSION MOBILE : menu d'action en bottom-sheet (ergonomie pouce) + cibles + grosses */
.mp__backdrop { position:absolute; inset:0; z-index:29; background:rgba(0,0,0,.45); }
.mp__menu.sheet { left:0 !important; right:0; bottom:0; top:auto !important; width:100%; max-width:none; min-width:0;
border-radius:18px 18px 0 0; padding:8px 12px calc(12px + env(safe-area-inset-bottom)); box-shadow:0 -12px 44px rgba(0,0,0,.72);
animation:mpsheet .18s ease-out; }
@keyframes mpsheet { from { transform:translateY(100%); } to { transform:translateY(0); } }
.mp__menu.sheet .mp__mh { padding:8px 10px 11px; }
.mp__menu.sheet .mp__mh .n { font-size:.95rem; }
.mp__menu.sheet .mp__mi { padding:14px 12px; font-size:.94rem; }
.mp__menu.sheet .mp__io { font-size:.8rem; padding:9px 12px; }
.mp__craft.sheeted { bottom:auto; top:10px; }
/* nœuds un peu plus gros au doigt */
html.uitier-mobile .mp__ic { width:66px; height:66px; font-size:32px; }
</style>
<script>
(function () {
function openPx(id, name) {
try {
if (window.jOS && window.jOS.openPloxion) return window.jOS.openPloxion(id);
if (window.jOSMobile && window.jOSMobile.open) return window.jOSMobile.open(id, name);
} catch (e) {}
}
function manifest() {
var list = window.__PLOXIONS__ || [];
if (!list.length && window.jOSApps) list = Object.keys(window.jOSApps).map(function (id) { var m = (window.jOSApps[id] || {}).manifest || {}; return { id: id, name: m.name || id, icon: m.icon || '◻' }; });
return list.filter(function (p) { return p && p.id && p.id !== 'cosmos'; });
}
function describe() {
var n = manifest().length;
return { v: 1, id: 'cosmos', title: 'Cosmos', icon: '🌌', items: [
{ p: 1, kind: 'stat', label: 'ploxions dans le cosmos', value: n }
] };
}
function mount(container, ctx) {
var nodes = manifest();
container.innerHTML = '<div class="mp"><div class="mp__world"></div>'
+ '<div class="mp__hud">🌌 cosmos · <b data-z>×1.0</b> · ' + nodes.length + ' ploxions</div>'
+ '<div class="mp__tools"><button class="mp__b" data-zin>+</button><button class="mp__b" data-zout>−</button><button class="mp__b" data-fit>⤢</button></div>'
+ '<div class="mp__f"><input data-find placeholder="cherche un ploxion…"></div></div>';
var root = container.querySelector('.mp'), world = container.querySelector('.mp__world');
var hud = container.querySelector('[data-z]');
var scale = 1, tx = 0, ty = 0;
var SP = 150, cols = Math.ceil(Math.sqrt(nodes.length)) || 1;
nodes.forEach(function (p, i) {
var c = i % cols, r = Math.floor(i / cols);
p._x = (c - (cols - 1) / 2) * SP; p._y = r * SP;
var el = document.createElement('div'); el.className = 'mp__node'; el.setAttribute('data-id', p.id);
el.style.left = p._x + 'px'; el.style.top = p._y + 'px';
el.innerHTML = '<div class="mp__ic">' + (p.icon || '◻') + '</div><div class="mp__nm"></div>';
el.querySelector('.mp__nm').textContent = p.name || p.id;
world.appendChild(el); p._el = el;
});
function apply() { world.style.transform = 'translate(' + tx + 'px,' + ty + 'px) scale(' + scale + ')'; hud.textContent = '×' + scale.toFixed(2); }
function zoomAt(cx, cy, factor) { closeMenu(); var ns = Math.max(0.15, Math.min(3, scale * factor)); tx = cx - (cx - tx) * (ns / scale); ty = cy - (cy - ty) * (ns / scale); scale = ns; apply(); }
function fit() {
var r = root.getBoundingClientRect();
var xs = nodes.map(function (p) { return p._x; }), ys = nodes.map(function (p) { return p._y; });
if (!xs.length) { apply(); return; }
var minx = Math.min.apply(null, xs) - 80, maxx = Math.max.apply(null, xs) + 80, miny = Math.min.apply(null, ys) - 80, maxy = Math.max.apply(null, ys) + 80;
var w = maxx - minx, h = maxy - miny;
scale = Math.max(0.2, Math.min(1.2, Math.min(r.width / w, r.height / h)));
tx = r.width / 2 - ((minx + maxx) / 2) * scale; ty = r.height / 2 - ((miny + maxy) / 2) * scale; apply();
}
root.addEventListener('wheel', function (e) { e.preventDefault(); closeMenu(); var r = root.getBoundingClientRect(); zoomAt(e.clientX - r.left, e.clientY - r.top, e.deltaY < 0 ? 1.12 : 0.89); }, { passive: false });
var dragging = false, sx = 0, sy = 0, moved = false, pinch = null;
root.addEventListener('pointerdown', function (e) {
if (e.target.closest('.mp__tools, .mp__f, .mp__menu, .mp__craft')) return;
dragging = true; moved = false; sx = e.clientX - tx; sy = e.clientY - ty; root.classList.add('drag');
try { root.setPointerCapture(e.pointerId); } catch (_) {}
});
root.addEventListener('pointermove', function (e) { if (!dragging) return; if (!moved) closeMenu(); moved = true; tx = e.clientX - sx; ty = e.clientY - ty; apply(); });
root.addEventListener('pointerup', function (e) {
dragging = false; root.classList.remove('drag');
if (!moved) {
var n = e.target.closest('[data-id]');
if (n) { var id = n.getAttribute('data-id'); var p = nodes.filter(function (x) { return x.id === id; })[0]; if (p) showMenu(p, e.clientX, e.clientY); }
else if (!e.target.closest('.mp__menu, .mp__craft')) closeMenu();
}
});
root.addEventListener('touchmove', function (e) {
if (e.touches.length === 2) { e.preventDefault(); dragging = false;
var dx = e.touches[0].clientX - e.touches[1].clientX, dy = e.touches[0].clientY - e.touches[1].clientY, d = Math.hypot(dx, dy);
var r = root.getBoundingClientRect(); var mx = (e.touches[0].clientX + e.touches[1].clientX) / 2 - r.left, my = (e.touches[0].clientY + e.touches[1].clientY) / 2 - r.top;
if (pinch != null) zoomAt(mx, my, d / pinch); pinch = d;
}
}, { passive: false });
root.addEventListener('touchend', function () { pinch = null; });
container.querySelector('[data-zin]').addEventListener('click', function () { var r = root.getBoundingClientRect(); zoomAt(r.width / 2, r.height / 2, 1.25); });
container.querySelector('[data-zout]').addEventListener('click', function () { var r = root.getBoundingClientRect(); zoomAt(r.width / 2, r.height / 2, 0.8); });
container.querySelector('[data-fit]').addEventListener('click', fit);
container.querySelector('[data-find]').addEventListener('input', function () {
var q = this.value.trim().toLowerCase();
nodes.forEach(function (p) { p._el.style.opacity = (!q || (p.name + ' ' + p.id).toLowerCase().indexOf(q) !== -1) ? '1' : '.18'; });
if (q) { var m = nodes.filter(function (p) { return (p.name + ' ' + p.id).toLowerCase().indexOf(q) !== -1; })[0];
if (m) { var r = root.getBoundingClientRect(); scale = 1; tx = r.width / 2 - m._x; ty = r.height / 2 - m._y; apply(); } }
});
// ---- MENU D'ACTION (RS-7 : « cliquer sur les ploxions et choisir l'action »)
// + composition CUBION (« fais un cubion de ça ») + I/O (/ploxion-io.json) ----
var menuEl = null, backdrop = null, selected = {}, ioCache = null;
function isMobile() { try { return (window.jOSui && window.jOSui.tier && window.jOSui.tier() === 'mobile') || document.documentElement.classList.contains('uitier-mobile'); } catch (e) { return false; } }
function closeMenu() { if (backdrop) { backdrop.remove(); backdrop = null; } if (menuEl) { menuEl.remove(); menuEl = null; } }
function updatePick() {
nodes.forEach(function (p) { p._el.classList.toggle('pick', !!selected[p.id]); });
var n = Object.keys(selected).length, btn = container.querySelector('.mp__craft');
if (n) { if (!btn) { btn = document.createElement('button'); btn.className = 'mp__craft' + (isMobile() ? ' sheeted' : ''); root.appendChild(btn); btn.addEventListener('click', craftCubion); } btn.textContent = '⚒ Crafter le cubion (' + n + ')'; }
else if (btn) btn.remove();
}
function craftCubion() {
var F = window.jOSForge, ids = Object.keys(selected);
if (!F || !ids.length) return;
var cells = ids.map(function (id, i) { return { x: i % 2, y: Math.floor(i / 2), ploxion: id }; });
var name = ids.map(function (id) { return selected[id].name || id; }).join('+').slice(0, 40);
var icon = ids.map(function (id) { return selected[id].icon || ''; }).join('').slice(0, 3) || '🧩';
var s = F.add({ name: name, icon: icon, template: 'cubion', params: { cols: 2, rows: Math.ceil(ids.length / 2) || 1, cells: cells, gap: 1 }, desc: 'cubion composé depuis le cosmos' });
selected = {}; updatePick(); closeMenu(); if (s) openPx(s.id, s.name);
}
function showIO(p) {
var box = menuEl && menuEl.querySelector('[data-io]'); if (!box) return;
box.hidden = false; box.innerHTML = '…';
function fmt(a) { return (a || []).map(function (x) { return x.t; }).join(', ') || '—'; }
function render(io) { var e = io && io[p.id];
box.innerHTML = e ? ('<b>in</b> <span class="k">' + fmt(e.in) + '</span><br><b>out</b> <span class="k">' + fmt(e.out) + '</span>') : '<span class="k">pas d\'I/O référencée</span>'; }
if (ioCache) return render(ioCache);
fetch('/ploxion-io.json').then(function (r) { return r.json(); }).then(function (d) { ioCache = d; if (menuEl) render(d); }).catch(function () { if (box) box.innerHTML = '<span class="k">I/O indisponible</span>'; });
}
function showMenu(p, clientX, clientY) {
closeMenu();
var rr = root.getBoundingClientRect(), picked = !!selected[p.id], hasForge = !!window.jOSForge;
menuEl = document.createElement('div'); menuEl.className = 'mp__menu';
menuEl.innerHTML = '<div class="mp__mh"><span class="g">' + (p.icon || '◻') + '</span><span class="n"></span></div>'
+ '<div class="mp__mi" data-a="open">▶ Ouvrir</div>'
+ (hasForge ? '<div class="mp__mi ' + (picked ? 'on' : '') + '" data-a="pick">⊞ ' + (picked ? 'Retirer du cubion' : 'Composer (cubion)') + '</div>' : '')
+ '<div class="mp__mi" data-a="io">ⓘ Entrées / Sorties</div>'
+ '<div class="mp__io" data-io hidden></div>';
menuEl.querySelector('.n').textContent = p.name || p.id;
root.appendChild(menuEl);
if (isMobile()) {
// bottom-sheet : backdrop tapable pour fermer, pas de positionnement x/y
menuEl.classList.add('sheet');
backdrop = document.createElement('div'); backdrop.className = 'mp__backdrop';
backdrop.addEventListener('pointerdown', function (e) { e.stopPropagation(); closeMenu(); });
root.insertBefore(backdrop, menuEl);
} else {
var mw = menuEl.offsetWidth, mh = menuEl.offsetHeight;
var x = Math.min(clientX - rr.left, rr.width - mw - 8), y = Math.min(clientY - rr.top, rr.height - mh - 8);
menuEl.style.left = Math.max(8, x) + 'px'; menuEl.style.top = Math.max(8, y) + 'px';
}
menuEl.addEventListener('pointerdown', function (e) { e.stopPropagation(); });
menuEl.querySelectorAll('[data-a]').forEach(function (mi) { mi.addEventListener('click', function () {
var a = mi.getAttribute('data-a');
if (a === 'open') { openPx(p.id, p.name); closeMenu(); }
else if (a === 'pick') { if (selected[p.id]) delete selected[p.id]; else selected[p.id] = { id: p.id, name: p.name, icon: p.icon }; updatePick(); showMenu(p, clientX, clientY); }
else if (a === 'io') { showIO(p); }
}); });
}
requestAnimationFrame(fit);
return { unmount: function () { closeMenu(); container.innerHTML = ''; } };
}
window.jOSApps = window.jOSApps || {};
window.jOSApps['cosmos'] = { manifest: { id: 'cosmos', name: 'Cosmos', icon: '🌌' }, mount: mount, describe: describe };
})();
</script>