mirror of
https://git.j0bot.ch/admin_j0bot/ploxion-infra.git
synced 2026-11-29 06:45:08 +00:00
synchro du labo (0bf0da65) : app.blade.php, README.md
This commit is contained in:
parent
42ae56aefd
commit
192a360d5b
22
README.md
22
README.md
@ -1,3 +1,21 @@
|
|||||||
# ploxion-infra
|
# 🕸 Infra
|
||||||
|
|
||||||
PLOXION · La carte de TOUTE l'infra, auto-générée (un n8n géant qui se dessine seul) : noeuds = ploxions actifs + bions (device/object/math) + le bus xion ; liens AUTO = sortie-type d'un ploxion → entrée-type d'un autre (/ploxion-io.json) + ploxion→catalogue de bions + tout → bus. Graphe force-directed, zoom/pan, clic = isoler un noeud. Montre l'infra actuelle et toutes les instances. · fournit: infra-map, graph, topology
|
La carte de TOUTE l'infra, auto-générée (un n8n géant qui se dessine seul) : noeuds = ploxions actifs + bions (device/object/math) + le bus xion ; liens AUTO = sortie-type d'un ploxion → entrée-type d'un autre (/ploxion-io.json) + ploxion→catalogue de bions + tout → bus. Graphe force-directed, zoom/pan, clic = isoler un noeud. Montre l'infra actuelle et toutes les instances.
|
||||||
|
|
||||||
|
| | |
|
||||||
|
| --- | --- |
|
||||||
|
| id | `infra` |
|
||||||
|
| fournit | `infra-map` `graph` `topology` |
|
||||||
|
| bions qu'il nomme | `jOSApps` |
|
||||||
|
| fichiers | `app.blade.php` |
|
||||||
|
| dans le labo | `resources/views/ploxions/infra/` (dépôt `my_website2`) |
|
||||||
|
|
||||||
|
## Contribuer
|
||||||
|
|
||||||
|
- **Dans le xer** : https://labo.j0bot.ch/px/atelier?ploxion=infra — prends-le, modifie-le, vois-le tourner, « ⧗ envoyer le tsoin ».
|
||||||
|
- **Dans VS Code** : `xb prendre infra` (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
|
||||||
|
|||||||
169
app.blade.php
Normal file
169
app.blade.php
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
{{-- PL0XI0N infra — la carte de TOUTE l'infra, auto-générée (RS-7 : « un n8n géant
|
||||||
|
mais généré automatiquement pour montrer l'infra actuelle + toutes les instances
|
||||||
|
de ploxions + les bions qu'on utilise »). Graphe force-directed en canvas :
|
||||||
|
- noeuds = ploxions actifs (window.__PLOXIONS__) + bions (device/object/math) + le bus xion.
|
||||||
|
- liens = AUTO : sortie-type T d'un ploxion → entrée-type T d'un autre (/ploxion-io.json),
|
||||||
|
+ ploxion→catalogue de bions (via config), + tout ploxion → bus xion.
|
||||||
|
Zoom molette, pan drag, clic = isole un noeud + ses voisins. Rien de codé en dur. --}}
|
||||||
|
<style>
|
||||||
|
.nf{height:100%;display:flex;flex-direction:column;background:var(--xr-bg,#06080d);color:var(--xr-text,#dfe9ff);font-family:var(--xr-font,ui-sans-serif,system-ui);font-size:.84rem;position:relative}
|
||||||
|
.nf__hd{flex:0 0 auto;display:flex;align-items:center;gap:10px;padding:7px 12px;border-bottom:1px solid var(--xr-border,rgba(110,170,255,.16));z-index:2}
|
||||||
|
.nf__hd b{color:var(--xr-accent,#5fa8ff)} .nf__hd .dim{color:var(--xr-muted,#7e8ba8);font-size:.72rem}
|
||||||
|
.nf__hd input{flex:1;max-width:200px;background:#04070d;border:1px solid var(--xr-border,rgba(110,170,255,.3));color:var(--xr-text,#dfe9ff);border-radius:7px;padding:4px 9px;font-size:.78rem;outline:none}
|
||||||
|
.nf__hd label{font-size:.7rem;color:var(--xr-muted,#7e8ba8);display:flex;align-items:center;gap:4px;cursor:pointer}
|
||||||
|
.nf__cv{flex:1;min-height:0;display:block;cursor:grab} .nf__cv:active{cursor:grabbing}
|
||||||
|
.nf__leg{position:absolute;left:10px;bottom:10px;display:flex;flex-direction:column;gap:3px;font-size:.68rem;background:rgba(6,8,13,.7);padding:6px 9px;border-radius:8px;border:1px solid var(--xr-border,rgba(110,170,255,.16))}
|
||||||
|
.nf__leg span{display:flex;align-items:center;gap:6px;color:var(--xr-muted,#9fb0cc)} .nf__leg i{width:9px;height:9px;border-radius:50%}
|
||||||
|
.nf__info{position:absolute;right:10px;top:48px;width:200px;background:rgba(6,8,13,.92);border:1px solid var(--xr-accent,#5fa8ff);border-radius:9px;padding:9px 11px;font-size:.74rem;display:none}
|
||||||
|
.nf__info.on{display:block} .nf__info b{color:var(--xr-accent,#5fa8ff)} .nf__info .k{color:var(--xr-muted,#7e8ba8);font-size:.66rem} .nf__info div{margin:2px 0;line-height:1.4}
|
||||||
|
@media (max-width:768px){
|
||||||
|
.nf{max-width:100%}
|
||||||
|
.nf__hd{flex-wrap:wrap;row-gap:4px;min-width:0}
|
||||||
|
.nf__hd input{flex:1 1 110px;min-width:0}
|
||||||
|
.nf__hd .dim{min-width:0;white-space:normal}
|
||||||
|
.nf__hd .dim:last-child{display:none} /* astuce souris (molette/glisser) inutile au tactile */
|
||||||
|
.nf__info{max-width:calc(100% - 20px)}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
(function(){
|
||||||
|
var ID='infra';
|
||||||
|
var COL={ploxion:'#5fa8ff',device:'#3fe07f',object:'#ffae5f',math:'#b89dff',bus:'#ff6a9a',group:'#9fb0cc',cubion:'#ffd27a'};
|
||||||
|
var LIVE=null; // posé au mount : { nodes, edges }
|
||||||
|
function describe(){
|
||||||
|
var nodes=LIVE?LIVE.nodes():[], edges=LIVE?LIVE.edges():[];
|
||||||
|
var px=nodes.filter(function(n){return n.kind==='ploxion';}).length;
|
||||||
|
return { v:1, id:ID, title:'Infra', icon:'🕸', items:[
|
||||||
|
{ p:1, kind:'stat', label:'ploxions branchés', value:px },
|
||||||
|
{ p:2, kind:'stat', label:'liens', value:edges.length }
|
||||||
|
] };
|
||||||
|
}
|
||||||
|
function mount(container){
|
||||||
|
var alive=true, nodes=[], edges=[], byId={}, seen={}, sel=null, hover=null, q='';
|
||||||
|
var view={x:0,y:0,k:0.6}, drag=null, alpha=1, raf=null;
|
||||||
|
container.innerHTML='<div class="nf"><div class="nf__hd"><b>🕸 Infra</b><span class="dim" data-stat>scan…</span><input data-q placeholder="filtrer…"><label><input type="checkbox" data-bus checked> bus</label><span class="dim">molette=zoom · glisser=pan · clic=isoler</span></div>'
|
||||||
|
+'<canvas class="nf__cv" data-cv></canvas>'
|
||||||
|
+'<div class="nf__leg" data-leg></div><div class="nf__info" data-info></div></div>';
|
||||||
|
var root=container.querySelector('.nf'), cv=root.querySelector('[data-cv]'), ctx=cv.getContext('2d'),
|
||||||
|
statEl=root.querySelector('[data-stat]'), info=root.querySelector('[data-info]'), leg=root.querySelector('[data-leg]'), qin=root.querySelector('[data-q]'), busChk=root.querySelector('[data-bus]');
|
||||||
|
leg.innerHTML=[['ploxion',COL.ploxion],['device-bion',COL.device],['object-bion',COL.object],['bion math',COL.math],['cubion',COL.cubion],['bus xion',COL.bus]].map(function(p){return '<span><i style="background:'+p[1]+'"></i>'+p[0]+'</span>';}).join('')+'<span style="margin-top:3px;color:#ffd27a">━ live (tes branchements)</span>';
|
||||||
|
|
||||||
|
function N(id,label,kind,icon){ if(byId[id])return byId[id]; var n={id:id,label:label,kind:kind,icon:icon||'',x:(Math.random()-0.5)*600,y:(Math.random()-0.5)*600,vx:0,vy:0,deg:0,r:kind==='bus'?11:(kind==='group'?9:6)}; nodes.push(n); byId[id]=n; return n; }
|
||||||
|
function E(a,b,kind){ if(a===b||!byId[a]||!byId[b])return; var k=a<b?a+'~'+b:b+'~'+a; if(seen[k])return; seen[k]=1; edges.push({a:a,b:b,kind:kind||'io'}); byId[a].deg++; byId[b].deg++; }
|
||||||
|
|
||||||
|
function build(io,dev,obj){
|
||||||
|
var PLX=window.__PLOXIONS__||[];
|
||||||
|
var bus=N('bus:xion','xion (bus)','bus','◆');
|
||||||
|
PLX.forEach(function(p){ N('px:'+p.id, p.name||p.id, 'ploxion', p.icon); });
|
||||||
|
// groupes de bions + individus
|
||||||
|
var gd=N('grp:device','device-bions','group','🧩'), go=N('grp:object','object-bions','group','▦'), gm=N('grp:math','bions math','group','ƒ');
|
||||||
|
(dev||[]).forEach(function(b){ N('dev:'+b.id, b.name, 'device', b.glyph); E('dev:'+b.id,'grp:device','grp'); });
|
||||||
|
(obj||[]).forEach(function(b){ N('obj:'+b.id, b.name, 'object', b.icon); E('obj:'+b.id,'grp:object','grp'); });
|
||||||
|
// liens AUTO : sortie-type -> entrée-type (le n8n). On exclut les types « bruit »
|
||||||
|
// (none/vide/any) qui relieraient tout à tout sans sens.
|
||||||
|
var STOP={'':1,'none':1,'-':1,'any':1,'*':1,'aucun':1};
|
||||||
|
var inByType={};
|
||||||
|
Object.keys(io).forEach(function(id){ if(!byId['px:'+id])return; (io[id].in||[]).forEach(function(p){ var t=(p.t||'').toLowerCase().trim(); if(STOP[t])return; (inByType[t]=inByType[t]||[]).push(id); }); });
|
||||||
|
Object.keys(io).forEach(function(id){ if(!byId['px:'+id])return; (io[id].out||[]).forEach(function(p){ var t=(p.t||'').toLowerCase().trim(); if(STOP[t])return; (inByType[t]||[]).forEach(function(tgt){ if(tgt!==id) E('px:'+id,'px:'+tgt,'io'); }); });
|
||||||
|
// tout ploxion qui émet -> bus
|
||||||
|
if((io[id].out||[]).length) E('px:'+id,'bus:xion','bus');
|
||||||
|
});
|
||||||
|
// ploxion -> catalogue de bions (via config) + curé
|
||||||
|
var usesDev=['iobions','connexions','bluetooth','boxion'], usesObj=['openscad','blocs','cubions'], usesMath=['xerlang','calculatrice','analyse'];
|
||||||
|
PLX.forEach(function(p){
|
||||||
|
var cfg=JSON.stringify(p.config||{});
|
||||||
|
if(cfg.indexOf('device-bions')>=0||usesDev.indexOf(p.id)>=0) E('px:'+p.id,'grp:device','use');
|
||||||
|
if(cfg.indexOf('object-bions')>=0||usesObj.indexOf(p.id)>=0) E('px:'+p.id,'grp:object','use');
|
||||||
|
if(cfg.indexOf('/bions.json')>=0||usesMath.indexOf(p.id)>=0) E('px:'+p.id,'grp:math','use');
|
||||||
|
if(cfg.indexOf('blocks.json')>=0){ E('px:'+p.id,'grp:device','use'); E('px:'+p.id,'grp:object','use'); }
|
||||||
|
});
|
||||||
|
E('grp:device','bus:xion','bus'); E('grp:object','bus:xion','bus'); E('grp:math','bus:xion','bus');
|
||||||
|
statEl.textContent=nodes.filter(function(n){return n.kind==='ploxion';}).length+' ploxions · '+(dev||[]).length+'+'+(obj||[]).length+' bions · '+edges.length+' liens';
|
||||||
|
}
|
||||||
|
|
||||||
|
function mapBion(id){ if(!id)return null; if(byId['dev:'+id])return 'dev:'+id; if(id.indexOf('io-')===0&&byId['dev:'+id.slice(3)])return 'dev:'+id.slice(3); if(id.indexOf('fn-')===0)return 'grp:math'; if(byId['obj:'+id])return 'obj:'+id; if(byId['px:'+id])return 'px:'+id; return N('bn:'+id,id,'math','◌').id; }
|
||||||
|
// (2) fusion : connexions live (jos:connexions) + cubions générés
|
||||||
|
function merge(cubs){
|
||||||
|
// branchements live faits dans le ploxion `connexions` : src(device-bion) -> connexions
|
||||||
|
try{ var conns=JSON.parse(localStorage.getItem('jos:connexions')||'[]'); conns.forEach(function(c){ if(byId['dev:'+c.src]&&byId['px:connexions']) E('dev:'+c.src,'px:connexions','live'); }); }catch(e){}
|
||||||
|
// cubions générés/enregistrés : noeud cubion + liens vers ses bions + ses wires internes
|
||||||
|
(cubs||[]).forEach(function(cu){ var cid='cub:'+(cu.slug||cu.name); N(cid, cu.name, 'cubion','⚡');
|
||||||
|
(cu.bions||[]).forEach(function(b){ var m=mapBion(b.id); if(m) E(cid,m,'cubion'); });
|
||||||
|
(cu.wires||[]).forEach(function(w){ var a=mapBion(String(w.from).split(':')[0]), b=mapBion(String(w.to).split(':')[0]); if(a&&b) E(a,b,'live'); });
|
||||||
|
});
|
||||||
|
statEl.textContent=nodes.filter(function(n){return n.kind==='ploxion';}).length+' ploxions · '+nodes.filter(function(n){return n.kind==='cubion';}).length+' cubions · '+edges.length+' liens';
|
||||||
|
}
|
||||||
|
|
||||||
|
Promise.all([
|
||||||
|
fetch('/ploxion-io.json').then(function(r){return r.json();}).catch(function(){return{};}),
|
||||||
|
fetch('/device-bions.json').then(function(r){return r.json();}).catch(function(){return{bions:[]};}),
|
||||||
|
fetch('/object-bions.json').then(function(r){return r.json();}).catch(function(){return{bions:[]};}),
|
||||||
|
fetch('/cubions-generated.json').then(function(r){return r.json();}).catch(function(){return{cubions:[]};})
|
||||||
|
]).then(function(a){ if(!alive)return;
|
||||||
|
var io=a[0].ploxions||a[0]; if(Array.isArray(io)){ var m={}; io.forEach(function(x){if(x.id)m[x.id]=x;}); io=m; }
|
||||||
|
build(io||{}, a[1].bions||[], a[2].bions||[]);
|
||||||
|
merge(a[3].cubions||[]);
|
||||||
|
resize(); loop();
|
||||||
|
});
|
||||||
|
|
||||||
|
// ---- physique force-directed ----
|
||||||
|
function step(){
|
||||||
|
var rep=2400, n=nodes.length;
|
||||||
|
for(var i=0;i<n;i++){ var a=nodes[i];
|
||||||
|
for(var j=i+1;j<n;j++){ var b=nodes[j]; var dx=a.x-b.x, dy=a.y-b.y, d2=dx*dx+dy*dy+0.01; var f=rep/d2; var d=Math.sqrt(d2); var fx=f*dx/d, fy=f*dy/d; a.vx+=fx;a.vy+=fy;b.vx-=fx;b.vy-=fy; }
|
||||||
|
a.vx-=a.x*0.002; a.vy-=a.y*0.002; // gravité centre
|
||||||
|
}
|
||||||
|
edges.forEach(function(e){ var a=byId[e.a],b=byId[e.b]; var dx=b.x-a.x,dy=b.y-a.y,d=Math.sqrt(dx*dx+dy*dy)||1; var L=e.kind==='io'?90:120; var f=(d-L)*0.02; var fx=f*dx/d,fy=f*dy/d; a.vx+=fx;a.vy+=fy;b.vx-=fx;b.vy-=fy; });
|
||||||
|
nodes.forEach(function(p){ p.x+=p.vx*alpha; p.y+=p.vy*alpha; p.vx*=0.85; p.vy*=0.85; });
|
||||||
|
alpha*=0.992; if(alpha<0.03) alpha=0.03;
|
||||||
|
}
|
||||||
|
function loop(){ if(!alive)return; if(alpha>0.031||drag) step(); draw(); raf=requestAnimationFrame(loop); }
|
||||||
|
|
||||||
|
function near(n){ if(!sel) return true; if(n.id===sel) return true; return edges.some(function(e){ return (e.a===sel&&e.b===n.id)||(e.b===sel&&e.a===n.id); }); }
|
||||||
|
function draw(){
|
||||||
|
var w=cv.width,h=cv.height; ctx.clearRect(0,0,w,h);
|
||||||
|
ctx.save(); ctx.translate(w/2+view.x,h/2+view.y); ctx.scale(view.k,view.k);
|
||||||
|
var showBus=busChk.checked;
|
||||||
|
edges.forEach(function(e){ if(!showBus&&e.kind==='bus')return; var a=byId[e.a],b=byId[e.b];
|
||||||
|
var live=(e.kind==='live'||e.kind==='cubion');
|
||||||
|
var dim = sel && !(e.a===sel||e.b===sel); ctx.globalAlpha=dim?0.04:(live?0.85:(e.kind==='io'?0.5:0.18));
|
||||||
|
ctx.strokeStyle=e.kind==='io'?'#5fa8ff':(e.kind==='use'?'#3fe07f':(e.kind==='live'?'#ffd27a':(e.kind==='cubion'?'#ffd27a':'#445')));
|
||||||
|
ctx.lineWidth=(live?1.6:(e.kind==='io'?1.1:0.7))/view.k;
|
||||||
|
if(e.kind==='cubion'){ ctx.setLineDash([4/view.k,3/view.k]); } else { ctx.setLineDash([]); }
|
||||||
|
ctx.beginPath(); ctx.moveTo(a.x,a.y); ctx.lineTo(b.x,b.y); ctx.stroke();
|
||||||
|
});
|
||||||
|
ctx.setLineDash([]);
|
||||||
|
ctx.globalAlpha=1;
|
||||||
|
nodes.forEach(function(p){ var on=near(p); var match=q&&p.label.toLowerCase().indexOf(q)>=0;
|
||||||
|
ctx.globalAlpha=on?1:0.15;
|
||||||
|
ctx.fillStyle=COL[p.kind]||'#888'; ctx.beginPath(); ctx.arc(p.x,p.y,(p.r+Math.min(p.deg,8)*0.6)/1,0,7); ctx.fill();
|
||||||
|
if(match){ ctx.strokeStyle='#fff'; ctx.lineWidth=2/view.k; ctx.stroke(); }
|
||||||
|
if(view.k>0.9||p===hover||p===byId[sel]||p.kind==='bus'||p.kind==='group'||match){ ctx.globalAlpha=on?1:0.3; ctx.fillStyle='#dfe9ff'; ctx.font=(11/view.k)+'px ui-sans-serif'; ctx.fillText((p.icon?p.icon+' ':'')+p.label, p.x+p.r+2, p.y+3); }
|
||||||
|
});
|
||||||
|
ctx.restore(); ctx.globalAlpha=1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- interactions ----
|
||||||
|
function pick(mx,my){ var w=cv.width,h=cv.height; var x=(mx-w/2-view.x)/view.k, y=(my-h/2-view.y)/view.k; var best=null,bd=1e9; nodes.forEach(function(p){ var d=(p.x-x)*(p.x-x)+(p.y-y)*(p.y-y); if(d<bd){bd=d;best=p;} }); return bd<(220/view.k)?best:null; }
|
||||||
|
function rel(e){ var r=cv.getBoundingClientRect(); var t=e.touches?e.touches[0]:e; return {x:t.clientX-r.left,y:t.clientY-r.top}; }
|
||||||
|
cv.addEventListener('mousedown',function(e){ var m=rel(e); var n=pick(m.x,m.y); drag={x:m.x,y:m.y,node:n,moved:false}; });
|
||||||
|
window.addEventListener('mousemove',function(e){ var m=rel(e); if(drag){ var dx=m.x-drag.x,dy=m.y-drag.y; if(Math.abs(dx)+Math.abs(dy)>3)drag.moved=true; if(drag.node){ drag.node.x+=dx/view.k; drag.node.y+=dy/view.k; drag.node.vx=0; alpha=Math.max(alpha,0.2);} else { view.x+=dx; view.y+=dy; } drag.x=m.x;drag.y=m.y; } else { hover=pick(m.x,m.y); } });
|
||||||
|
window.addEventListener('mouseup',function(){ if(drag&&!drag.moved){ var n=drag.node; sel=(n&&sel!==n.id)?n.id:(n?sel:null); if(n&&sel===n.id)showInfo(n); else info.classList.remove('on'); } drag=null; });
|
||||||
|
cv.addEventListener('wheel',function(e){ e.preventDefault(); var f=e.deltaY<0?1.12:0.89; view.k=Math.max(0.15,Math.min(3,view.k*f)); },{passive:false});
|
||||||
|
function showInfo(n){
|
||||||
|
var ins=edges.filter(function(e){return e.b===n.id&&e.kind==='io';}).length, outs=edges.filter(function(e){return e.a===n.id&&e.kind==='io';}).length;
|
||||||
|
info.innerHTML='<b>'+(n.icon?n.icon+' ':'')+esc(n.label)+'</b><div class="k">'+n.kind+'</div><div>degré : '+n.deg+'</div><div>flux io : '+ins+' entrants · '+outs+' sortants</div>'+(n.kind==='ploxion'?'<div class="k" style="margin-top:4px;cursor:pointer" data-open="'+n.id.slice(3)+'">→ ouvrir le ploxion</div>':'');
|
||||||
|
info.classList.add('on');
|
||||||
|
}
|
||||||
|
info.addEventListener('click',function(e){ var o=e.target.closest('[data-open]'); if(o&&window.jOS&&window.jOS.openPloxion){ try{window.jOS.openPloxion(o.getAttribute('data-open'));}catch(_){}}});
|
||||||
|
qin.addEventListener('input',function(){ q=qin.value.toLowerCase().trim(); });
|
||||||
|
function esc(s) { return window.jOSb.esc(s); }
|
||||||
|
function resize(){ var r=cv.getBoundingClientRect(); cv.width=r.width; cv.height=r.height; }
|
||||||
|
var ro=new ResizeObserver(resize); ro.observe(cv);
|
||||||
|
LIVE={ nodes:function(){return nodes;}, edges:function(){return edges;} };
|
||||||
|
return { unmount:function(){ LIVE=null; alive=false; cancelAnimationFrame(raf); try{ro.disconnect();}catch(e){} container.innerHTML=''; } };
|
||||||
|
}
|
||||||
|
window.jOSApps=window.jOSApps||{};
|
||||||
|
window.jOSApps[ID]={manifest:{id:ID,name:'Infra',icon:'🕸'},mount:mount,describe:describe};
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
Loading…
Reference in New Issue
Block a user