synchro du labo (0bf0da65) : app.blade.php, README.md
This commit is contained in:
356
app.blade.php
Normal file
356
app.blade.php
Normal file
@@ -0,0 +1,356 @@
|
||||
{{-- PL0XI0N flow ⚡ — LE COCKPIT DU FLOW (lot PULSE, 25.09.2026 ; plan docs/plans/son-flow-v0.md §7 ; doc docs/dev/30-son-et-flow.md).
|
||||
RS-7 : « le but de mon système c'est d'atteindre le flowstate […] un système pour extrapoler avec du son ».
|
||||
Compose, ne duplique rien : l'horloge = window.jOSPulse (sources, tap, analyse d'un fichier), la mesure = window.jOSFlowstate
|
||||
(jauge tetraplexion ↔ xerboxion, « je suis dedans », recette, « entrer en flow », sessions), les sources sonores = les ploxions
|
||||
spotify / music / beats / dj / mixer montés en direct (jOSApps.monter, à la demande ; iframe /px/<id> si la page n'a pas le
|
||||
manifeste). Langage dix-mille-ans : le vide, un trait fin, le présent (le temps fort) en ambre ; des instruments, pas des boutons.
|
||||
L'anneau ne bouge qu'AU TEMPS (jamais à chaque image), au plus 3 changements par seconde, sur une petite surface ; palier T0 ou
|
||||
prefers-reduced-motion : seulement la mesure. Le texte ne bouge jamais. Rien ne démarre au montage (ni son, ni micro) : tout
|
||||
part d'un geste. unmount = tout se désabonne, le fichier joué ici s'arrête. window.jOSApps['flow'] : mount(c, ctx) → {unmount}. --}}
|
||||
<style>
|
||||
.flw{--v:#010306;--t:rgba(225,247,255,.9);--t2:rgba(193,227,240,.5);--t3:rgba(193,227,240,.3);--g:#9edff5;--a:#f5b35e;--l:rgba(158,223,245,.16);
|
||||
position:relative;min-height:100%;box-sizing:border-box;padding:calc(env(safe-area-inset-top,0px) + 14px) 16px calc(env(safe-area-inset-bottom,0px) + 28px);
|
||||
background:radial-gradient(120% 70% at 50% 0%,rgba(158,223,245,.07),transparent 62%),var(--v);color:var(--t);
|
||||
font:14px/1.45 ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;overflow-x:hidden}
|
||||
.flw *{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
|
||||
.flw__col{max-width:560px;margin:0 auto;--fx-gap:18px;--fx-tuile:24rem}
|
||||
.flw__col:not([data-fx-noeud]),.flw__col[data-fx-noeud][data-taille="m"]{display:flex;flex-direction:column;gap:18px}
|
||||
.flw__lab{font-size:10px;letter-spacing:.24em;text-transform:uppercase;color:var(--t2);font-weight:500}
|
||||
.flw__sens{font-family:ui-serif,Georgia,"Times New Roman",serif;font-style:italic;color:var(--t2)}
|
||||
.flw__num{font-variant-numeric:tabular-nums;font-feature-settings:"tnum"}
|
||||
.flw__hd{display:flex;align-items:baseline;justify-content:space-between;gap:10px}
|
||||
.flw__hd b{font-weight:500;letter-spacing:.3em;font-size:12px;color:var(--t)}
|
||||
.flw__etat{font-family:ui-serif,Georgia,serif;font-style:italic;font-size:15px}
|
||||
.flw__etat.x{color:var(--a);font-style:normal;letter-spacing:.08em}
|
||||
.flw__ring{display:flex;justify-content:center}
|
||||
.flw__ring svg{width:min(250px,72vw);height:auto;display:block;overflow:visible}
|
||||
.flw__seg{fill:none;stroke:var(--l);stroke-width:3;stroke-linecap:round;transition:stroke .35s ease-out,opacity .35s ease-out}
|
||||
.flw__seg.on{stroke:var(--g);transition:stroke .1s ease-in,opacity .1s ease-in}
|
||||
.flw__seg.fort{stroke:rgba(245,179,94,.32)}
|
||||
.flw__seg.fort.on{stroke:var(--a)}
|
||||
.flw__dot{fill:var(--l);transition:fill .3s}
|
||||
.flw__dot.on{fill:var(--g)} .flw__dot.fort.on{fill:var(--a)}
|
||||
.flw__conf{fill:none;stroke:rgba(158,223,245,.55);stroke-width:1.2;transition:stroke-dasharray .6s}
|
||||
.flw__bpm{font-size:46px;font-weight:200;fill:var(--t);font-variant-numeric:tabular-nums;letter-spacing:.02em}
|
||||
.flw__bpml{font-size:9px;letter-spacing:.3em;fill:var(--t2)}
|
||||
.flw__src{font-size:12px;fill:var(--t2);font-family:ui-serif,Georgia,serif;font-style:italic}
|
||||
.flw__row{display:flex;gap:10px;flex-wrap:wrap;align-items:stretch}
|
||||
.flw__b{font:inherit;cursor:pointer;min-height:44px;padding:0 16px;border-radius:999px;border:1px solid rgba(158,223,245,.3);background:rgba(158,223,245,.05);color:var(--t);letter-spacing:.04em}
|
||||
.flw__b:active{background:rgba(158,223,245,.14)}
|
||||
.flw__b[aria-pressed="true"]{border-color:var(--a);color:var(--a)}
|
||||
.flw__b.am{border-color:rgba(245,179,94,.6);color:var(--a)}
|
||||
.flw__tap{flex:1;min-height:64px;font-size:13px;letter-spacing:.3em;text-transform:uppercase;border-radius:16px;touch-action:manipulation;user-select:none;-webkit-user-select:none}
|
||||
.flw__grow{flex:1}
|
||||
.flw__msg{min-height:1.4em;font-size:12px;color:var(--t2)}
|
||||
.flw__chips{display:flex;gap:8px;flex-wrap:wrap}
|
||||
.flw__chip{font:inherit;font-size:12px;cursor:pointer;min-height:36px;padding:4px 12px;border-radius:10px;border:1px solid rgba(158,223,245,.22);background:transparent;color:var(--t);display:inline-flex;gap:8px;align-items:center}
|
||||
.flw__chip small{font-size:9px;letter-spacing:.18em;text-transform:uppercase;color:var(--t3)}
|
||||
.flw__chip.off{opacity:.42}
|
||||
.flw__chip.ici{border-color:var(--a)} .flw__chip.ici small{color:var(--a)}
|
||||
.flw__jauge{position:relative;height:30px;margin:4px 6px 0}
|
||||
.flw__jauge i{position:absolute;left:0;right:0;top:14px;height:1px;background:linear-gradient(90deg,rgba(158,223,245,.18),rgba(158,223,245,.4) 55%,rgba(245,179,94,.55))}
|
||||
.flw__jauge u{position:absolute;top:9px;width:1px;height:11px;background:var(--t3)}
|
||||
.flw__jauge b{position:absolute;top:8px;width:13px;height:13px;margin-left:-6px;border-radius:50%;background:var(--v);border:1.5px solid var(--g);transition:left .8s ease,border-color .4s}
|
||||
.flw__jauge b.x{border-color:var(--a);background:var(--a)}
|
||||
.flw__jl{display:flex;justify-content:space-between}
|
||||
.flw__sig{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:10px 16px}
|
||||
.flw__sig div{display:flex;flex-direction:column;gap:3px}
|
||||
.flw__sig em{font-style:normal;font-size:15px;font-variant-numeric:tabular-nums}
|
||||
.flw__bar{height:2px;background:rgba(158,223,245,.12);position:relative}
|
||||
.flw__bar s{position:absolute;left:0;top:0;bottom:0;background:var(--g)}
|
||||
.flw__card{border-top:1px solid var(--l);padding-top:12px;display:flex;flex-direction:column;gap:8px}
|
||||
.flw__kv{display:grid;grid-template-columns:auto 1fr;gap:4px 14px;font-size:13px}
|
||||
.flw__kv span:nth-child(odd){color:var(--t2);font-size:11px;letter-spacing:.14em;text-transform:uppercase;padding-top:2px}
|
||||
.flw__ses{display:flex;flex-direction:column;gap:6px}
|
||||
.flw__ses div{display:grid;grid-template-columns:1fr auto 70px;gap:10px;align-items:center;font-size:12px}
|
||||
.flw__ses svg{width:70px;height:18px;display:block}
|
||||
.flw__host{border:1px solid var(--l);border-radius:12px;overflow:hidden;position:relative;height:min(62vh,520px);background:#05080c}
|
||||
.flw__host>iframe{border:0;width:100%;height:100%;display:block}
|
||||
.flw__x{position:absolute;right:6px;top:6px;z-index:5}
|
||||
.flw details summary{cursor:pointer;list-style:none;min-height:36px;display:flex;align-items:center}
|
||||
.flw details summary::-webkit-details-marker{display:none}
|
||||
.flw__opt{display:flex;flex-direction:column;gap:10px;padding-top:6px;font-size:13px}
|
||||
.flw__opt label{display:flex;gap:10px;align-items:center;justify-content:space-between}
|
||||
.flw__opt input[type=range]{flex:1;accent-color:var(--g)}
|
||||
.flw__opt input[type=checkbox]{accent-color:var(--a);width:18px;height:18px}
|
||||
.flw__prive{font-size:11px;color:var(--t3);line-height:1.5}
|
||||
.flw input[type=file]{font-size:12px;color:var(--t2);max-width:100%}
|
||||
@media (prefers-reduced-motion: reduce){ .flw__seg,.flw__dot,.flw__conf,.flw__jauge b{transition:none} }
|
||||
/* À N'IMPORTE QUELLE TAILLE, LES MÊMES FONCTIONS (RS-7 25.09). LE XER FRACTAL range .flw__col (jOSFractal, docs/dev/34-xer-fractal.md :
|
||||
ses pièces sont déclarées par data-piece, la bande de tête est une barre) selon SA taille : large (l, xl) = tuiles de 24rem (2 ou 3
|
||||
colonnes, les sources sur toute la ligne) · moyen (m) = la colonne de flow · étroit (s) = une bande qu'on fait glisser, un geste =
|
||||
la pièce suivante · tout petit (xs) = une pièce à la fois avec un fil d'index. Ce qui reste ici est propre à flow : sa largeur,
|
||||
ses respirations, la taille de l'anneau et des boutons (selon la taille de l'hôte ou du nœud le plus proche). */
|
||||
:is([data-taille="l"],[data-taille="xl"]) .flw__col[data-fx-noeud]{max-width:1180px}
|
||||
.flw__col[data-fx-noeud]:is([data-taille="l"],[data-taille="xl"])>.flw__plein{grid-column:1/-1}
|
||||
/* sans le bion (kill-switch xb:fractal=off, jOSTaille coupé) : exactement la mise en page d'avant — une colonne, deux quand c'est large */
|
||||
@media (min-width:900px){ .flw__col:not([data-fx-noeud]){max-width:880px;display:grid;grid-template-columns:1fr 1fr;align-items:start;gap:18px 34px} .flw__col:not([data-fx-noeud])>.flw__plein{grid-column:1/-1} }
|
||||
:is([data-taille="l"],[data-taille="xl"]) .flw__col:not([data-fx-noeud]){max-width:880px;display:grid;grid-template-columns:1fr 1fr;align-items:start;gap:18px 34px}
|
||||
:is([data-taille="xs"],[data-taille="s"],[data-taille="m"]) .flw__col:not([data-fx-noeud]){max-width:560px;display:flex;flex-direction:column;gap:16px}
|
||||
[data-taille="xs"] .flw__col:not([data-fx-noeud]){gap:12px}
|
||||
:is([data-taille="xs"],[data-taille="s"]) .flw{padding:12px 12px 22px}
|
||||
:is([data-taille="xs"],[data-taille="s"]) .flw__ring svg{width:min(210px,70%)}
|
||||
[data-taille="xs"] .flw{padding:10px 10px 18px;font-size:13px}
|
||||
[data-taille="xs"] .flw__ring svg{width:min(150px,62%)}
|
||||
[data-taille="xs"] .flw__tap{min-height:52px}
|
||||
[data-taille="xs"] .flw__b{min-height:40px;padding:0 12px}
|
||||
[data-taille="xs"] .flw__sig{grid-template-columns:1fr}
|
||||
[data-court] .flw__ring svg{width:min(150px,40%)}
|
||||
[data-court] .flw__tap{min-height:48px}
|
||||
.flw__host{height:min(520px,calc(var(--plx-h,88vh) * .7))}
|
||||
</style>
|
||||
<script>
|
||||
(function () {
|
||||
'use strict';
|
||||
var ID = 'flow';
|
||||
var MONTABLES = [['spotify', '🎧'], ['music', '🎵'], ['beats', '🥁'], ['dj', '🎚'], ['mixer', '🎛']];
|
||||
var PREC = { exacte: 'exacte', fichier: 'fichier', ecoute: 'écoute', midi: 'midi', tap: 'tap' };
|
||||
var LIVE = null;
|
||||
function esc(s) { return window.jOSb.esc(s); }
|
||||
function fr(x, d) { if (x == null || !isFinite(x)) return '—'; return (+x).toFixed(d == null ? 1 : d).replace('.', ','); }
|
||||
function lsGet(k) { try { return localStorage.getItem(k); } catch (e) { return null; } }
|
||||
function lsSet(k, v) { try { if (v == null) localStorage.removeItem(k); else localStorage.setItem(k, v); } catch (e) {} }
|
||||
// écrit « jOSPulse.etat » / « jOSFlowstate.etat » en toutes lettres : /px/flow en déduit les bions à inclure (routes/web.php)
|
||||
function Pu() { return (window.jOSPulse && window.jOSPulse.etat) ? window.jOSPulse : null; }
|
||||
function Fs() { return (window.jOSFlowstate && window.jOSFlowstate.etat) ? window.jOSFlowstate : null; }
|
||||
function duree(ms) { var m = Math.round((ms || 0) / 60000); return m < 60 ? m + ' min' : Math.floor(m / 60) + ' h ' + ('0' + (m % 60)).slice(-2); }
|
||||
|
||||
function describe() {
|
||||
var P = Pu(), F = Fs(), e = P ? P.etat() : null, st = F ? F.etat() : 'tetraplexion', nom = F ? F.nom() : '—';
|
||||
return { v: 1, id: ID, title: 'Flow', icon: '⚡', items: [
|
||||
{ p: 1, kind: 'stat', label: nom, value: e && e.bpm ? Math.round(e.bpm) + ' BPM' : '—' },
|
||||
{ p: 2, kind: 'action', label: F && F.dedans() ? 'je décroche' : 'je suis dedans', act: { port: 'ploxion.flowstate.cmd', payload: { cmd: 'declarer', v: !(F && F.dedans()) } } },
|
||||
{ p: 2, kind: 'action', label: 'tap', act: { port: 'ploxion.pulse.cmd', payload: { cmd: 'tap' } } },
|
||||
{ p: 3, kind: 'action', label: F && F.modeFlow() ? 'sortir du flow' : 'entrer en flow', act: { port: 'ploxion.flowstate.cmd', payload: { cmd: F && F.modeFlow() ? 'quitter' : 'entrer' } } },
|
||||
{ p: 4, kind: 'text', label: 'état', value: st }
|
||||
] };
|
||||
}
|
||||
|
||||
// l'anneau de phase : 4 temps (le temps fort en ambre) + 8 points de la phrase + l'arc de confiance
|
||||
function arc(cx, cy, r, a0, a1) { var p = function (a) { return [cx + r * Math.sin(a), cy - r * Math.cos(a)]; }, s = p(a0), e = p(a1); return 'M' + s[0].toFixed(2) + ' ' + s[1].toFixed(2) + ' A' + r + ' ' + r + ' 0 0 1 ' + e[0].toFixed(2) + ' ' + e[1].toFixed(2); }
|
||||
function anneau() {
|
||||
var h = '<svg viewBox="-110 -110 220 220" role="img" aria-label="anneau de phase">', i, g = 0.1;
|
||||
h += '<circle r="100" fill="none" stroke="rgba(158,223,245,.07)" stroke-width="1"/>';
|
||||
for (i = 0; i < 4; i++) h += '<path class="flw__seg' + (i === 0 ? ' fort' : '') + '" data-seg="' + i + '" d="' + arc(0, 0, 92, i * Math.PI / 2 + g, (i + 1) * Math.PI / 2 - g) + '"/>';
|
||||
for (i = 0; i < 8; i++) { var a = i * Math.PI / 4; h += '<circle class="flw__dot' + (i === 0 ? ' fort' : '') + '" data-dot="' + i + '" r="2.2" cx="' + (76 * Math.sin(a)).toFixed(2) + '" cy="' + (-76 * Math.cos(a)).toFixed(2) + '"/>'; }
|
||||
h += '<circle class="flw__conf" data-conf r="84" transform="rotate(-90)" stroke-dasharray="0 600"/>';
|
||||
h += '<text class="flw__bpm" data-bpm text-anchor="middle" y="12">—</text><text class="flw__bpml" text-anchor="middle" y="32">BPM</text>';
|
||||
h += '<text class="flw__src" data-src text-anchor="middle" y="54"></text></svg>';
|
||||
return h;
|
||||
}
|
||||
|
||||
function mount(container, ctx) {
|
||||
ctx = ctx || {};
|
||||
var alive = true, offs = [], enfant = null, enfantId = null, audio = null, audioUrl = null, dernierVisuel = 0, dernierEtatRendu = 0, minuteur = 0;
|
||||
container.innerHTML = '<div class="flw"><div class="flw__col">'
|
||||
+ '<div class="flw__hd flw__plein"><b>⚡ FLOW</b><span class="flw__etat" data-etat>—</span></div>'
|
||||
+ '<div data-piece="tempo" data-piece-nom="le tempo"><div class="flw__ring" data-ring>' + anneau() + '</div>'
|
||||
+ '<div class="flw__row" style="margin-top:14px"><button type="button" class="flw__b flw__tap" data-a="tap" aria-label="taper le tempo">tap</button></div>'
|
||||
+ '<div class="flw__row" style="margin-top:10px"><button type="button" class="flw__b flw__grow" data-a="synchro">▶ démarrer la synchro</button></div>'
|
||||
+ '<p class="flw__msg" data-msg aria-live="polite"></p>'
|
||||
+ '<div class="flw__lab" style="margin:6px 0 8px">sources</div><div class="flw__chips" data-sources></div></div>'
|
||||
+ '<div data-piece="flow" data-piece-nom="le flow"><div class="flw__lab">tetraplexion ↔ xerboxion</div>'
|
||||
+ '<div class="flw__jauge" data-jauge><i></i><u style="left:40%"></u><u style="left:70%"></u><b data-marq style="left:0%"></b></div>'
|
||||
+ '<div class="flw__jl flw__lab"><span>fragmenté</span><span class="flw__sens" data-score style="letter-spacing:0;text-transform:none"></span><span>fusionné</span></div>'
|
||||
+ '<div class="flw__row" style="margin-top:14px"><button type="button" class="flw__b flw__grow" data-a="dedans" aria-pressed="false">je suis dedans</button><button type="button" class="flw__b am flw__grow" data-a="entrer">entrer en flow</button></div>'
|
||||
+ '<div class="flw__card"><div class="flw__lab">signaux</div><div class="flw__sig" data-sig></div></div>'
|
||||
+ '<div class="flw__card"><div class="flw__lab">recette</div><div data-recette></div></div>'
|
||||
+ '<div class="flw__card"><div class="flw__lab">sessions</div><div class="flw__ses" data-sessions></div></div></div>'
|
||||
+ '<div class="flw__card flw__plein" data-piece="sources" data-piece-nom="sources sonores"><div class="flw__lab">sources sonores</div><div class="flw__row" data-montables>'
|
||||
+ MONTABLES.map(function (m) { return '<button type="button" class="flw__b" data-monter="' + m[0] + '">' + m[1] + ' ' + m[0] + '</button>'; }).join('') + '</div>'
|
||||
+ '<div data-hote hidden></div></div>'
|
||||
+ '<div class="flw__card" data-piece="fichier" data-piece-nom="un fichier"><div class="flw__lab">un fichier → une grille exacte</div><input type="file" accept="audio/*" data-fichier aria-label="analyser un fichier audio"><p class="flw__msg" data-fres></p>'
|
||||
+ '<div class="flw__row"><button type="button" class="flw__b" data-a="jouer" hidden>▶ jouer avec la grille</button><button type="button" class="flw__b" data-a="stopfichier" hidden>■</button></div></div>'
|
||||
+ '<div class="flw__card" data-piece="reglages" data-piece-nom="réglages"><details><summary class="flw__lab">réglages ⚙</summary><div class="flw__opt" data-opt></div></details>'
|
||||
+ '<p class="flw__prive">Le micro n\'enregistre rien : il mesure des énergies en mémoire, jamais un son gardé ni envoyé. Tes données de flow restent à toi (ton navigateur et ton boxion, espace « flow »).</p></div>'
|
||||
+ '</div></div>';
|
||||
var root = container.firstChild;
|
||||
function q(s) { return root.querySelector(s); }
|
||||
var elEtat = q('[data-etat]'), elMsg = q('[data-msg]'), elSrc = q('[data-sources]'), elMarq = q('[data-marq]'), elScore = q('[data-score]');
|
||||
var bpmT = q('[data-bpm]'), srcT = q('[data-src]'), conf = q('[data-conf]'), segs = root.querySelectorAll('[data-seg]'), dots = root.querySelectorAll('[data-dot]');
|
||||
|
||||
var dernierMsgPulse = '';
|
||||
function dire(t) { elMsg.textContent = t || ''; }
|
||||
// le souffle (lot SOUFFLE) : écrit en toutes lettres pour que /px/flow l'inclue aussi (il reste inerte tant qu'on ne l'allume pas)
|
||||
function souffleActif() { try { return !!(window.jOSSouffle && window.jOSSouffle.actif()); } catch (e) { return false; } }
|
||||
function calme() { var P = Pu(); var pal = P && P.palier ? P.palier() : 'T1'; var r = false; try { r = matchMedia('(prefers-reduced-motion: reduce)').matches; } catch (e) {} return r || pal === 'T0'; }
|
||||
|
||||
/* ── l'horloge ── */
|
||||
function rendrePulse() {
|
||||
var P = Pu(); if (!P) { bpmT.textContent = '—'; srcT.textContent = 'horloge absente'; return; }
|
||||
var e = P.etat();
|
||||
bpmT.textContent = e.bpm ? fr(e.bpm, 1) : '—';
|
||||
srcT.textContent = e.actif ? (e.nom || e.source || '') + (e.muet ? ' · en pause' : '') : (P.coupe && P.coupe() ? 'synchro coupée' : 'à l\'arrêt');
|
||||
conf.setAttribute('stroke-dasharray', (2 * Math.PI * 84 * (e.actif ? e.confiance : 0)).toFixed(1) + ' 600');
|
||||
var b = q('[data-a="synchro"]'); b.textContent = e.actif || e.ecoute ? '■ arrêter la synchro' : '▶ démarrer la synchro';
|
||||
// le message de l'horloge (démarrage, veille, refus…) s'efface quand elle n'a plus rien à dire ; un message du cockpit reste
|
||||
var m = e.piste ? '♪ ' + e.piste + (e.artiste ? ' — ' + e.artiste : '') + (e.message ? ' · ' + e.message : '') : (e.message || '');
|
||||
if (m) { dire(m); dernierMsgPulse = m; } else if (dernierMsgPulse && elMsg.textContent === dernierMsgPulse) { dire(''); dernierMsgPulse = ''; }
|
||||
rendreSources();
|
||||
if (!e.actif) { segs.forEach(function (s) { s.classList.remove('on'); }); dots.forEach(function (d) { d.classList.remove('on'); }); }
|
||||
}
|
||||
function rendreSources() {
|
||||
var P = Pu(); if (!P) { elSrc.innerHTML = ''; return; }
|
||||
elSrc.innerHTML = P.sources().map(function (s) {
|
||||
return '<button type="button" class="flw__chip' + (s.dispo ? '' : ' off') + (s.actif ? ' ici' : '') + '" data-src="' + esc(s.id) + '" title="' + esc(s.dispo ? s.nom : (s.raison || 'indisponible')) + '">'
|
||||
+ esc(s.nom) + (s.bpm ? ' <span class="flw__num">' + esc(fr(s.bpm, 1)) + '</span>' : '') + ' <small>' + esc(PREC[s.precision] || s.precision || '') + '</small></button>';
|
||||
}).join('');
|
||||
}
|
||||
// un temps : le segment du temps s'allume (≤ 3 changements / s ; palier T0 ou mouvement réduit : seulement la mesure)
|
||||
function surTemps(e) {
|
||||
if (!alive || !e) return;
|
||||
var t = Date.now(), leger = calme();
|
||||
if (leger && e.temps !== 1) return;
|
||||
if (!leger && t - dernierVisuel < 340) return;
|
||||
dernierVisuel = t;
|
||||
segs.forEach(function (s, i) { s.classList.toggle('on', !leger && i === e.temps - 1); });
|
||||
if (e.temps === 1) dots.forEach(function (d, i) { d.classList.toggle('on', i === (e.mesure - 1) % 8); });
|
||||
if (t - dernierEtatRendu > 5000) { dernierEtatRendu = t; rendrePulse(); }
|
||||
}
|
||||
|
||||
/* ── le flow ── */
|
||||
function rendreFlow() {
|
||||
var F = Fs(); if (!F) { elEtat.textContent = 'mesure absente'; return; }
|
||||
var st = F.etat(), sc = F.score(), nom = F.nom();
|
||||
elEtat.textContent = nom; elEtat.classList.toggle('x', st === 'xerboxion');
|
||||
elMarq.style.left = Math.round(sc * 100) + '%'; elMarq.classList.toggle('x', st === 'xerboxion');
|
||||
var ses = F.session(), jeune = ses && ses.duree < 120000 && !F.dedans();
|
||||
elScore.textContent = !F.mesure() ? 'la mesure démarre avec la synchro' : (jeune ? 'la mesure s\'installe…' : nom + ' · ' + Math.round(sc * 100));
|
||||
if (jeune) { elEtat.textContent = '…'; elEtat.classList.remove('x'); }
|
||||
var d = q('[data-a="dedans"]'), de = F.dedans(); d.setAttribute('aria-pressed', de ? 'true' : 'false'); d.textContent = de ? 'je suis dedans ✓' : 'je suis dedans';
|
||||
q('[data-a="entrer"]').textContent = F.modeFlow() ? 'sortir du flow' : 'entrer en flow';
|
||||
var sg = F.signaux(), noms = { continuite: 'continuité', fragmentation: 'fragmentation', cadence: 'cadence', synchronisation: 'synchro (PLV)', declaration: 'déclaration', humeur: 'humeur', xerax: 'xerax', cardio: 'cardio' };
|
||||
q('[data-sig]').innerHTML = Object.keys(sg).length ? Object.keys(sg).map(function (k) {
|
||||
var s = sg[k], brut = typeof s.brut === 'number' ? fr(s.brut, s.unite === 'min' ? 1 : 2) + (s.unite ? ' ' + s.unite : '') : String(s.brut == null ? '' : s.brut);
|
||||
return '<div><span class="flw__lab">' + esc(noms[k] || k) + '</span><em>' + esc(brut) + '</em><span class="flw__bar"><s style="width:' + Math.round((+s.v || 0) * 100) + '%"></s></span></div>';
|
||||
}).join('') : '<p class="flw__sens" style="margin:0">rien encore : la mesure commence quand la synchro tourne, ou quand tu te déclares dedans.</p>';
|
||||
var r = F.recette();
|
||||
q('[data-recette]').innerHTML = r ? '<div class="flw__kv">'
|
||||
+ (r.bpm ? '<span>tempo</span><span class="flw__num">' + esc(fr(r.bpm, 0)) + ' BPM</span>' : '')
|
||||
+ (r.source ? '<span>source</span><span>' + esc(r.source) + '</span>' : '')
|
||||
+ (r.playlist ? '<span>playlist</span><span>' + esc(r.playlist.nom || r.playlist.uri) + '</span>' : (r.piste ? '<span>piste</span><span>' + esc(r.piste) + '</span>' : ''))
|
||||
+ (r.zone ? '<span>zone</span><span>' + esc(r.zone.nom) + '</span>' : '')
|
||||
+ (r.mode ? '<span>mode</span><span>' + esc(r.mode) + '</span>' : '')
|
||||
+ (r.heure != null ? '<span>heure</span><span class="flw__num">' + esc(String(r.heure)) + ' h</span>' : '')
|
||||
+ (r.ploxions.length ? '<span>ploxions</span><span>' + esc(r.ploxions.join(' · ')) + '</span>' : '')
|
||||
+ '</div><p class="flw__sens" style="margin:4px 0 0">' + r.n + ' session' + (r.n > 1 ? 's' : '') + ' de flow · « entrer en flow » la rejoue en un geste</p>'
|
||||
: '<p class="flw__sens" style="margin:0">pas encore de recette : quand tu es dedans, dis-le (« je suis dedans ») ; la machine retient ce qui y menait.</p>';
|
||||
var H = F.historique().sessions.slice(-5).reverse();
|
||||
q('[data-sessions]').innerHTML = H.length ? H.map(function (s) {
|
||||
var c = s.courbe || [], pts = c.length > 1 ? c.map(function (v, i) { return (i / (c.length - 1) * 70).toFixed(1) + ',' + (17 - v * 16).toFixed(1); }).join(' ') : '';
|
||||
return '<div><span>' + esc(new Date(s.debut).toLocaleString('fr-CH', { weekday: 'short', hour: '2-digit', minute: '2-digit' })) + ' · ' + esc(duree(s.duree)) + '</span>'
|
||||
+ '<span class="' + (s.max === 'xerboxion' ? 'flw__etat x' : 'flw__sens') + '" style="font-size:12px">' + esc(F.NOMS[s.max] || s.max) + '</span>'
|
||||
+ '<svg viewBox="0 0 70 18" aria-hidden="true">' + (pts ? '<polyline fill="none" stroke="#9edff5" stroke-width="1" points="' + pts + '"/>' : '') + '</svg></div>';
|
||||
}).join('') : '<p class="flw__sens" style="margin:0">aucune session gardée.</p>';
|
||||
}
|
||||
|
||||
/* ── réglages : les kill-switches, le calage, la phrase, le cardio ── */
|
||||
function rendreOptions() {
|
||||
var P = Pu(), F = Fs(), opt = q('[data-opt]');
|
||||
var cle = function (k, lib, inv) { var off = lsGet(k) === 'off'; return '<label><span>' + esc(lib) + '</span><input type="checkbox" data-ks="' + esc(k) + '"' + (!off ? ' checked' : '') + '></label>'; };
|
||||
var cal = P && P.caler ? P.caler() : 0, ph = P && P.phrase ? P.phrase() : 8;
|
||||
opt.innerHTML = '<label><span>calage de l\'écoute <span class="flw__num" data-calv>' + cal + ' ms</span></span><input type="range" min="-200" max="200" step="5" value="' + cal + '" data-calage></label>'
|
||||
+ '<label><span>phrase</span><span><button type="button" class="flw__b" data-phrase="4"' + (ph === 4 ? ' aria-pressed="true"' : '') + '>4</button> <button type="button" class="flw__b" data-phrase="8"' + (ph === 8 ? ' aria-pressed="true"' : '') + '>8</button> <button type="button" class="flw__b" data-phrase="16"' + (ph === 16 ? ' aria-pressed="true"' : '') + '>16</button></span></label>'
|
||||
+ cle('xb:pulse', 'synchro musicale') + cle('xb:pulse.ecoute', 'écoute (micro, onglet, média)') + cle('xb:pulse.spotify', 'Spotify') + cle('xb:pulse.midi', 'MIDI clock')
|
||||
+ cle('xb:flow', 'mesure du flow') + cle('xb:flow.mode', 'mode flow') + cle('xb:flow.calme', 'le calme (HUD minimal, notifications en attente)')
|
||||
+ cle('xb:flow.apprendre', 'apprendre mes poids') + cle('xb:flow.adaptateurs', 'adaptateurs (xerax, cardio)') + cle('xb:flow.auto', 'mesurer quand la musique joue')
|
||||
+ '<label><span>mesurer à chaque ouverture</span><input type="checkbox" data-toujours' + (lsGet('xb:flow:mesure') === 'toujours' ? ' checked' : '') + '></label>'
|
||||
+ '<div class="flw__row"><button type="button" class="flw__b" data-a="cardio">❤ brancher un cardio</button>' + (window.jOSSouffle ? '<button type="button" class="flw__b" data-a="souffle" aria-pressed="' + (souffleActif() ? 'true' : 'false') + '">l\'UI respire</button>' : '') + '</div>';
|
||||
}
|
||||
|
||||
/* ── monter une source sonore en direct ── */
|
||||
function monter(id) {
|
||||
var hote = q('[data-hote]');
|
||||
if (enfant) { try { enfant.unmount && enfant.unmount(); } catch (e) {} enfant = null; }
|
||||
if (enfantId === id) { enfantId = null; hote.hidden = true; hote.innerHTML = ''; majMontables(); return; }
|
||||
enfantId = id; hote.hidden = false;
|
||||
hote.innerHTML = '<div class="flw__host"><button type="button" class="flw__b flw__x" data-a="demonter" aria-label="fermer">✕</button><div data-plx style="height:100%"></div></div>';
|
||||
var h = hote.querySelector('[data-plx]'), A = window.jOSApps || {};
|
||||
if (A.monter && (A[id] || (A.peut && A.peut(id)))) { try { enfant = A.monter(id, h, { win: null, close: function () { monter(id); }, depuis: ID }); } catch (e) { h.textContent = 'montage impossible : ' + (e && e.message || e); } }
|
||||
else { h.innerHTML = '<iframe src="/px/' + encodeURIComponent(id) + '" title="' + esc(id) + '" loading="lazy" allow="autoplay; encrypted-media; microphone"></iframe>'; enfant = null; }
|
||||
majMontables();
|
||||
}
|
||||
function majMontables() { root.querySelectorAll('[data-monter]').forEach(function (b) { b.setAttribute('aria-pressed', b.getAttribute('data-monter') === enfantId ? 'true' : 'false'); }); }
|
||||
|
||||
/* ── un fichier : analyse hors ligne → grille exacte → joué ici, suivi par l'horloge ── */
|
||||
var analyse = null, fichier = null;
|
||||
function stopFichier() { if (audio) { try { audio.pause(); } catch (e) {} audio.removeAttribute('src'); audio = null; } if (audioUrl) { try { URL.revokeObjectURL(audioUrl); } catch (e) {} audioUrl = null; } var P = Pu(); if (P && P.suivre) P.suivre(null); q('[data-a="stopfichier"]').hidden = true; }
|
||||
|
||||
/* ── les gestes ── */
|
||||
root.addEventListener('pointerdown', function (e) { // le tap au plus tôt (pointerdown, pas click : 0 latence d'écran)
|
||||
var b = e.target.closest && e.target.closest('[data-a="tap"]'); if (!b) return;
|
||||
var P = Pu(); if (!P) { dire('horloge absente'); return; }
|
||||
var r = P.tap(performance.now()); if (!r) dire('synchro coupée (réglages ⚙)'); else if (!r.bpm) dire('encore…'); else dire('');
|
||||
rendrePulse();
|
||||
});
|
||||
root.addEventListener('click', function (e) {
|
||||
var t = e.target, b = t.closest && t.closest('[data-a],[data-src],[data-monter],[data-phrase]'); if (!b) return;
|
||||
var P = Pu(), F = Fs(), a = b.getAttribute('data-a');
|
||||
if (b.hasAttribute('data-src')) {
|
||||
var id = b.getAttribute('data-src'), s = P ? P.sources().filter(function (x) { return x.id === id; })[0] : null;
|
||||
if (!s) return; if (!s.dispo) { dire(s.raison || 'indisponible'); return; }
|
||||
if (id === 'tap') { dire('tape le tempo sur ✋'); P.demarrer('tap'); rendrePulse(); return; }
|
||||
dire('…'); P.demarrer(id).then(function (r) { if (!alive) return; dire(r && r.ok ? (r.message || '') : ((r && r.message) || 'échec') + (r && r.repli === 'tap' ? ' — le tap ✋ marche toujours' : '')); rendrePulse(); });
|
||||
return;
|
||||
}
|
||||
if (b.hasAttribute('data-monter')) { monter(b.getAttribute('data-monter')); return; }
|
||||
if (b.hasAttribute('data-phrase')) { if (P && P.phrase) P.phrase(+b.getAttribute('data-phrase')); rendreOptions(); return; }
|
||||
if (a === 'synchro') {
|
||||
if (!P) return; var e0 = P.etat();
|
||||
if (e0.actif || e0.ecoute) { P.arreter(); dire('synchro arrêtée'); rendrePulse(); return; }
|
||||
dire('…'); P.demarrer().then(function (r) { if (!alive) return; dire(r && r.ok ? (r.message || '') : ((r && r.message) || 'échec') + ' — le tap ✋ marche toujours'); rendrePulse(); });
|
||||
} else if (a === 'dedans') { if (F) { F.declarer(!F.dedans()); rendreFlow(); } }
|
||||
else if (a === 'entrer') {
|
||||
if (!F) return;
|
||||
if (F.modeFlow()) { F.quitterModeFlow(); rendreFlow(); return; }
|
||||
F.entrer().then(function (r) { if (!alive) return; dire(r && r.fait && r.fait.length ? 'en flow : ' + r.fait.join(' · ') : ''); if (r && r.rate && r.rate.length) dire((elMsg.textContent ? elMsg.textContent + ' · ' : '') + r.rate.join(' · ')); rendreFlow(); rendrePulse(); });
|
||||
} else if (a === 'demonter') { if (enfantId) monter(enfantId); }
|
||||
else if (a === 'jouer') {
|
||||
if (!fichier || !analyse) return; stopFichier();
|
||||
audioUrl = URL.createObjectURL(fichier); audio = new Audio(audioUrl); audio.preload = 'auto';
|
||||
var pp = audio.play(); if (pp && pp.catch) pp.catch(function () { dire('lecture refusée par le navigateur'); });
|
||||
if (P && P.suivre) { P.suivre(audio, analyse); P.demarrer('fichier').then(function (r) { if (alive && r && !r.ok) dire(r.message); rendrePulse(); }); }
|
||||
q('[data-a="stopfichier"]').hidden = false;
|
||||
} else if (a === 'stopfichier') { stopFichier(); if (P && P.etat().source === 'fichier') P.arreter(); rendrePulse(); }
|
||||
else if (a === 'cardio') { if (!F) return; F.connecterCardio().then(function (r) { if (alive) dire(r.message || ''); rendreFlow(); }); }
|
||||
else if (a === 'souffle') { try { if (window.jOSSouffle.actif()) window.jOSSouffle.eteindre(); else window.jOSSouffle.allumer(); } catch (x) {} rendreOptions(); }
|
||||
});
|
||||
root.addEventListener('change', function (e) {
|
||||
var t = e.target;
|
||||
if (t.hasAttribute('data-ks')) { var k = t.getAttribute('data-ks'); lsSet(k, t.checked ? null : 'off'); if (k === 'xb:pulse' && !t.checked && Pu()) Pu().arreter(); if (k === 'xb:flow' && !t.checked && Fs()) { if (Fs().modeFlow()) Fs().quitterModeFlow(); Fs().mesurer(false); } rendrePulse(); rendreFlow(); return; }
|
||||
if (t.hasAttribute('data-toujours')) { lsSet('xb:flow:mesure', t.checked ? 'toujours' : null); return; }
|
||||
if (t.hasAttribute('data-fichier')) {
|
||||
var f = t.files && t.files[0], res = q('[data-fres]'); if (!f) return;
|
||||
var P = Pu(); if (!P || !P.analyserFichier) { res.textContent = 'horloge absente'; return; }
|
||||
fichier = f; analyse = null; q('[data-a="jouer"]').hidden = true; res.textContent = 'analyse de « ' + f.name.slice(0, 60) + ' »…';
|
||||
P.analyserFichier(f).then(function (a) { if (!alive || fichier !== f) return; analyse = a; a.titre = f.name.slice(0, 80);
|
||||
res.textContent = fr(a.bpm, 1) + ' BPM · confiance ' + fr(a.confiance, 2) + ' · ' + Math.floor(a.duree / 60) + ':' + ('0' + Math.floor(a.duree % 60)).slice(-2) + ' — la grille est exacte';
|
||||
q('[data-a="jouer"]').hidden = false;
|
||||
}, function (err) { if (alive) res.textContent = 'analyse impossible : ' + ((err && err.message) || err); });
|
||||
}
|
||||
});
|
||||
root.addEventListener('input', function (e) {
|
||||
var t = e.target; if (!t.hasAttribute('data-calage')) return;
|
||||
var P = Pu(); if (P && P.caler) { var v = P.caler(+t.value); var l = q('[data-calv]'); if (l) l.textContent = v + ' ms'; }
|
||||
});
|
||||
|
||||
/* ── abonnements (défaits à l'unmount) ── */
|
||||
var P0 = Pu(), F0 = Fs();
|
||||
if (P0) { offs.push(P0.on('temps', surTemps)); offs.push(P0.on('etat', function () { if (alive) rendrePulse(); })); }
|
||||
if (F0) { offs.push(F0.on('etat', function () { if (alive) rendreFlow(); })); offs.push(F0.on('mode', function () { if (alive) rendreFlow(); })); offs.push(F0.on('session', function () { if (alive) rendreFlow(); }));
|
||||
if (!F0.coupe()) F0.mesurer(true); } // ouvrir le cockpit = vouloir regarder son flow (écouteurs passifs + tick 15 s, rien d'autre)
|
||||
function rafraichir() { if (!alive) return; if (document.visibilityState !== 'hidden') { rendreFlow(); if (Pu()) rendreSources(); } minuteur = setTimeout(rafraichir, 15000); }
|
||||
rendrePulse(); rendreFlow(); rendreOptions(); rafraichir();
|
||||
|
||||
LIVE = { alive: function () { return alive; } };
|
||||
return { unmount: function () {
|
||||
alive = false; LIVE = null; if (minuteur) clearTimeout(minuteur);
|
||||
offs.forEach(function (f) { try { if (typeof f === 'function') f(); } catch (e) {} }); offs = [];
|
||||
if (enfant) { try { enfant.unmount && enfant.unmount(); } catch (e) {} enfant = null; }
|
||||
stopFichier(); container.innerHTML = '';
|
||||
} };
|
||||
}
|
||||
window.jOSApps = window.jOSApps || {};
|
||||
window.jOSApps[ID] = { manifest: { id: ID, name: 'Flow', icon: '⚡' }, mount: mount, describe: describe };
|
||||
})();
|
||||
</script>
|
||||
Reference in New Issue
Block a user