faustwave 0.0.1 → 0.94.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +48 -5
- package/dist/npm/faustwave.mjs +31372 -0
- package/dist/npm/page/assets/index-BPO9trAg.css +1 -0
- package/dist/npm/page/assets/index-DyOBLoeh.js +2 -0
- package/dist/npm/page/files.json +1 -0
- package/dist/npm/page/index.html +17 -0
- package/dist/npm/pagekit/pagekit.js +2347 -0
- package/dist/npm/pagekit/parts/device-button.glb +0 -0
- package/dist/npm/pagekit/parts/device-fader.glb +0 -0
- package/dist/npm/pagekit/parts/device-knob.glb +0 -0
- package/dist/npm/pagekit/parts/device-meter.glb +0 -0
- package/dist/npm/pagekit/parts/device-panel.glb +0 -0
- package/dist/npm/pagekit/parts/models-provenance.json +46 -0
- package/dist/npm/pagekit/player/THIRD-PARTY-NOTICES.md +12358 -0
- package/dist/npm/pagekit/player/assets/AppView-BV9Obknn.js +1 -0
- package/dist/npm/pagekit/player/assets/AppView-CdET0bgZ.css +1 -0
- package/dist/npm/pagekit/player/assets/FontLoader-C8xh6Irz.js +64 -0
- package/dist/npm/pagekit/player/assets/StageView-CSu--ASd.css +1 -0
- package/dist/npm/pagekit/player/assets/StageView-_SwGWnwx.js +1 -0
- package/dist/npm/pagekit/player/assets/actionRegistry-DrQhww6a.js +1 -0
- package/dist/npm/pagekit/player/assets/actionRegistry-hOkUYNvI.js +1 -0
- package/dist/npm/pagekit/player/assets/ahead-BNQHG1e8.js +1 -0
- package/dist/npm/pagekit/player/assets/api-BrGhAVvb.js +1 -0
- package/dist/npm/pagekit/player/assets/autoLayout-C5ue2K3x.js +1 -0
- package/dist/npm/pagekit/player/assets/bundledSources-2GoXdU5z.js +1 -0
- package/dist/npm/pagekit/player/assets/clapModule-CB6_36hc.js +1 -0
- package/dist/npm/pagekit/player/assets/client-DksDHYQL.js +1 -0
- package/dist/npm/pagekit/player/assets/codeEditorBridge-Bl202hrO.js +1 -0
- package/dist/npm/pagekit/player/assets/disclose-version-BvIhFN19.js +1 -0
- package/dist/npm/pagekit/player/assets/dist-BvRk9kiK.js +0 -0
- package/dist/npm/pagekit/player/assets/dist-DfaMbR-1.js +1 -0
- package/dist/npm/pagekit/player/assets/engine.worklet-BTB8yjdk.js +1865 -0
- package/dist/npm/pagekit/player/assets/engineCost.worker-Cv0PY3S-.js +2167 -0
- package/dist/npm/pagekit/player/assets/errors-BdUU2zPt.js +1 -0
- package/dist/npm/pagekit/player/assets/faust-analysis.nodepack-Bg1ixSAB.js +1 -0
- package/dist/npm/pagekit/player/assets/faust-physical-models.nodepack-DxbqTZII.js +1 -0
- package/dist/npm/pagekit/player/assets/faust-reverbs.nodepack-c-ZIKLrJ.js +1 -0
- package/dist/npm/pagekit/player/assets/faust-spatial.nodepack-C6GwVzOM.js +1 -0
- package/dist/npm/pagekit/player/assets/faust-vintage.nodepack-D8g5LX-U.js +1 -0
- package/dist/npm/pagekit/player/assets/faust.nodepack-Do7P1z0H.js +1 -0
- package/dist/npm/pagekit/player/assets/faustSource-Blr9zzKL.js +1 -0
- package/dist/npm/pagekit/player/assets/faustwasm-webclap-double-BX3OrOpF.js +1 -0
- package/dist/npm/pagekit/player/assets/faustwasm-webclap-double-Drn3DiHA.wasm +0 -0
- package/dist/npm/pagekit/player/assets/faustwasm.js +1 -0
- package/dist/npm/pagekit/player/assets/faustwave-conventions.nodepack-D2jA38Q6.js +1 -0
- package/dist/npm/pagekit/player/assets/fileMirror-CkgB9zNS.js +1 -0
- package/dist/npm/pagekit/player/assets/fileRef-BmnWhXuY.js +1 -0
- package/dist/npm/pagekit/player/assets/host-DPIuYxlL.js +1 -0
- package/dist/npm/pagekit/player/assets/instantiate-Dh0T46aH.js +1 -0
- package/dist/npm/pagekit/player/assets/inter-500.typeface-B6jxeZL_.js +21 -0
- package/dist/npm/pagekit/player/assets/inter-700.typeface-COCE0d_R.js +21 -0
- package/dist/npm/pagekit/player/assets/kernel-BErAMnKr.js +1 -0
- package/dist/npm/pagekit/player/assets/kernel-D6spGIFh.js +1 -0
- package/dist/npm/pagekit/player/assets/kernel-DKiI3Wqx.js +2 -0
- package/dist/npm/pagekit/player/assets/kit--nsV_OZy.js +1 -0
- package/dist/npm/pagekit/player/assets/kit-vVQ5cDnW.css +1 -0
- package/dist/npm/pagekit/player/assets/lazy-BkjipY-3.css +1 -0
- package/dist/npm/pagekit/player/assets/lazy-ClEpU-Ev.js +1 -0
- package/dist/npm/pagekit/player/assets/libraryFacts-B_z-Kv6i.js +1 -0
- package/dist/npm/pagekit/player/assets/mono-500.typeface-CuX9Pbhu.js +21 -0
- package/dist/npm/pagekit/player/assets/mono-700.typeface-BpIQdJao.js +21 -0
- package/dist/npm/pagekit/player/assets/newId-DuoSrkVn.js +1 -0
- package/dist/npm/pagekit/player/assets/notes-D-zF5qJ1.js +1 -0
- package/dist/npm/pagekit/player/assets/opfsStore-CXd1Yz_2.js +1 -0
- package/dist/npm/pagekit/player/assets/panic-ckha9YOX.js +1 -0
- package/dist/npm/pagekit/player/assets/patchSnippets-Dsccmpj6.js +1 -0
- package/dist/npm/pagekit/player/assets/paths-DFjX1bFA.js +1 -0
- package/dist/npm/pagekit/player/assets/player-CgcvekqS.js +2 -0
- package/dist/npm/pagekit/player/assets/playerApp-BmyTSXxw.js +2 -0
- package/dist/npm/pagekit/player/assets/playerApp-DO80EIpx.css +1 -0
- package/dist/npm/pagekit/player/assets/preArm-ifXM2Buj.js +1 -0
- package/dist/npm/pagekit/player/assets/preload-helper-9MKZsTCd.js +1 -0
- package/dist/npm/pagekit/player/assets/projectFiles-BEdLy3nE.js +1 -0
- package/dist/npm/pagekit/player/assets/projectPicker-mteZ2tiI.js +1 -0
- package/dist/npm/pagekit/player/assets/rocket-CgRnlVoE.js +1 -0
- package/dist/npm/pagekit/player/assets/runtime-36oA_YiG.js +1 -0
- package/dist/npm/pagekit/player/assets/runtime-7lvdeERt.js +1 -0
- package/dist/npm/pagekit/player/assets/runtime-BNLxaYPi.js +2 -0
- package/dist/npm/pagekit/player/assets/runtime-CL1M0Epi.js +1 -0
- package/dist/npm/pagekit/player/assets/runtime-bQsuRbRM.js +2 -0
- package/dist/npm/pagekit/player/assets/runtime-vj8wKnnG.js +1 -0
- package/dist/npm/pagekit/player/assets/runtime-wuc1seO8.js +1 -0
- package/dist/npm/pagekit/player/assets/scale-D2nqiPek.js +1 -0
- package/dist/npm/pagekit/player/assets/sha256-B9lHpAF4.js +1 -0
- package/dist/npm/pagekit/player/assets/soundfiles-DMZ8HKDZ.js +1 -0
- package/dist/npm/pagekit/player/assets/src-BvHr5YSH.js +2 -0
- package/dist/npm/pagekit/player/assets/src-Co7ihhBK.js +1 -0
- package/dist/npm/pagekit/player/assets/src-DyDfRe65.js +1 -0
- package/dist/npm/pagekit/player/assets/src-LMfGAjlj.js +1 -0
- package/dist/npm/pagekit/player/assets/stageWorker-ggqqFf5m.js +20869 -0
- package/dist/npm/pagekit/player/assets/store-CJdayqZa.js +1 -0
- package/dist/npm/pagekit/player/assets/sun-Bi-OgPry.js +1 -0
- package/dist/npm/pagekit/player/assets/time-aboh42pX.js +1 -0
- package/dist/npm/pagekit/player/assets/toasts-BCcM1yGS.js +1 -0
- package/dist/npm/pagekit/player/assets/toasts-ChPacqdd.js +1 -0
- package/dist/npm/pagekit/player/assets/transportFollow-Ox91SKLF.js +1 -0
- package/dist/npm/pagekit/player/favicon.svg +77 -0
- package/dist/npm/pagekit/player/files.json +1 -0
- package/dist/npm/pagekit/player/player.html +35 -0
- package/package.json +58 -17
- package/faustwave.mjs +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./errors-BdUU2zPt.js";import{r as t}from"./fileRef-BmnWhXuY.js";import{a as s,s as n}from"./src-DyDfRe65.js";import{o as a}from"./projectFiles-BEdLy3nE.js";var o="asset:assets/models-provenance.json";async function l(e){try{if(!(await e.project.listAssets(".json")).some(e=>"asset:assets/models-provenance.json"===e.ref))return{models:{},problem:null};const t=JSON.parse(await e.files.readText(o));return!t||"object"!=typeof t||Array.isArray(t)?{models:{},problem:`${o} is no listing of models`}:{models:t,problem:null}}catch(t){return{models:{},problem:`${o} could not be read: ${t instanceof Error?t.message:String(t)}`}}}var i=null;function r(e){i=e}function u(){if(!i)throw new Error("[extension-app] IDEAPI not initialized. Did the factory run?");return i}var p=new Map;function c(e){const t=p.get(e);if(t)return t;const s=u().log.create(e);return p.set(e,s),s}var d=/^[a-z0-9-]+$/,m=e=>"object"==typeof e&&null!==e&&!Array.isArray(e);var v=(e,t)=>`${e}:${t}`;function f(e,t,s){const n=t.unlock;if(!n||s.includes(v(n.level,n.won)))return null;const a=e.levels.find(e=>e.name===n.level);return`win the mission "${n.won}" in ${a?.title??n.level} first`}var h=(e,t)=>e.levels.find(e=>e.stage===t);function g(e){if(e<60)return`${e.toFixed(1)} s`;const t=Math.floor(e/60);return`${t}:${(e-60*t).toFixed(1).padStart(4,"0")}`}var b={won:[],best:{},last:null},w=/^[a-z0-9-]+:.+$/,$=e=>"object"==typeof e&&null!==e&&!Array.isArray(e);function y(e){let t;try{t=JSON.parse(e)}catch(s){return{save:null,problem:`not JSON — ${s.message}`}}return $(t)&&"app-save"===t.format?1!==t.version?{save:null,problem:`a save of version ${JSON.stringify(t.version)} — this build reads version 1`}:Array.isArray(t.won)&&t.won.every(e=>"string"==typeof e&&w.test(e))?$(t.best)&&Object.entries(t.best).every(([e,t])=>w.test(e)&&"number"==typeof t&&Number.isFinite(t)&&t>=0)?null!==t.last&&"string"!=typeof t.last?{save:null,problem:'"last" is a level\'s name or null'}:{save:{won:[...new Set(t.won)],best:{...t.best},last:t.last},problem:null}:{save:null,problem:'"best" is { "<level>:<mission>": seconds }'}:{save:null,problem:'"won" is a list of "<level>:<mission>"'}:{save:null,problem:'not an app\'s save (no "format": "app-save")'}}function k(e){const t=Object.fromEntries(Object.entries(e.best).sort(([e],[t])=>e.localeCompare(t)));return JSON.stringify({format:"app-save",version:1,won:e.won,best:t,last:e.last})}function A(e){const t=(e??"").replace(/^.*[/:]/,"").replace(/\.faustwave$/i,"");return a(t)?t:null}function j(e,t,s){const n=e.best[t];return{...e,won:e.won.includes(t)?e.won:[...e.won,t],best:void 0===n||s<n?{...e.best,[t]:s}:e.best}}var O=e=>({won:e.won,best:e.best,last:e.last}),T=new Map,M=n(new Map),S=null;function N(e){return T.get(e)?.state??null}function _(e){if(e)return T.has(e)?e:null;const t=S;if(t&&T.has(t))return t;const n=t?function(e,t){for(const[s,n]of e)if(n.stage===t&&"menu"!==n.phase)return{id:s,state:n};return null}(s(M),t):null;return n?n.id:[...T.keys()][0]??null}function x(e){if(T.has(e))return{dispose:()=>{}};const t=u().documents.listModules().find(t=>t.id===e)?.filePath??null,a=n({doc:null,problems:[],phase:"menu",level:null,stage:null,spawn:null,won:[],best:{},last:null,save:{key:A(t),read:!1,problem:null},result:null,notice:null,loads:0,loaded:null,editing:!1,credits:null}),o=a.subscribe(t=>((e,t)=>M.update(s=>new Map(s).set(e,t)))(e,t));let l=null,i="";const r=a.subscribe(t=>{const s=t.stage&&"menu"!==t.phase?t.stage:null,n=s?function(e,t){const s=t.result,n={label:"Restart level",testid:"app.menu.again",action:"app.level.again",input:{module_id:e},playsOn:!0};return{cover:"loading"===t.phase?t.doc?.levels.find(e=>e.name===t.level)?.title??"":null,notice:t.notice,panel:"results"===t.phase&&s?{title:s.won?"Mission passed":"Mission failed",testid:"app.results",lines:[s.title,`Time ${g(s.took)}`,...s.record?["A new best time"]:null!==s.best?[`Best ${g(s.best)}`]:[],...s.why?[s.why[0].toUpperCase()+s.why.slice(1)]:[]],entries:[{label:"Play again",testid:"app.results.again",action:"app.level.again",input:{module_id:e},playsOn:!0},{label:"Back to the menu",testid:"app.results.menu",action:"app.menu",input:{module_id:e}}]}:null,menu:[n,{label:"Leave to the menu",testid:"app.menu.leave",action:"app.menu",input:{module_id:e}}]}}(e,t):null,a=JSON.stringify([s,n]);if(a===i)return;i=a;const o=u();l&&l!==s&&R("the overlay could not be taken off",o.actions.run("stage.overlay.set",{module_id:l,overlay:null})),s&&R("the overlay could not be laid on",o.actions.run("stage.overlay.set",{module_id:s,overlay:n})),l=s}),p={state:a,since:0,kept:null,saving:Promise.resolve(),musicOn:null,music:Promise.resolve()};T.set(e,p);const d=a.subscribe(e=>{var t,n;e.save.read&&e.save.key&&(t=p,n=e.save.key,t.saving=t.saving.then(async()=>{const e=k(O(s(t.state)));if(e!==t.kept&&(null!==t.kept||e!==k(b)))try{await u().saves.set(n,e),t.kept=e,s(t.state).save.problem&&t.state.update(e=>({...e,save:{...e.save,problem:null}}))}catch(a){const e=`the progress could not be saved — ${a.message}`;c("App").warn(`${n}: ${e}`),t.state.update(t=>({...t,save:{...t.save,problem:e}}))}}))});return(async()=>{if(t)try{P(e,await u().files.readText(t))}catch(s){a.update(e=>({...e,problems:[`${t} could not be read — ${s.message}`]}))}})(),p.saving=async function(e,t){const n=s(e.state).save.key;if(!n)return void c("App").warn(`${t}: no save — the app's file name is none a save can take (letters, digits, spaces, dashes, underscores)`);let a;try{a=await u().saves.get(n)}catch(p){const s=`the save could not be read — ${p.message} — the progress is not saved this session`;return c("App").warn(`${t} (${n}): ${s}`),void e.state.update(e=>({...e,save:{key:n,read:!1,problem:s}}))}const{save:o,problem:l}=null===a?{save:null,problem:null}:y(a),i=l?`the save does not read (${l}) — the app starts without it`:null,r=o??b;e.state.update(e=>({...e,won:[...new Set([...r.won,...e.won])],best:{...r.best,...e.best},last:e.last??r.last,save:{key:n,read:!0,problem:i}})),e.kept=null===a?null:o?a:k(O(s(e.state))),i?c("App").warn(`${t} (${n}): ${i}`):o&&c("App").info(`${t} (${n}): its save read — ${r.won.length} won, last played ${r.last??"none"}`)}(p,e),{dispose:()=>{o(),d(),r(),l&&R("the overlay could not be taken off",u().actions.run("stage.overlay.set",{module_id:l,overlay:null})),L(p,s(p.state).doc,null),T.delete(e),M.update(t=>{const s=new Map(t);return s.delete(e),s})}}}async function J(t){const n=T.get(t);n||e("That app is not open.");const a=s(n.state).save.key;if(await n.saving,n.kept=null,n.state.update(e=>({...e,won:[],best:{},last:null})),!a)return"Its progress is forgotten — the app had no save (its file name is none a save can take).";const o=n.saving.then(()=>u().saves.remove(a));n.saving=o.catch(()=>{});try{await o}catch(l){const e=`the save could not be removed — ${l.message}`;return n.state.update(t=>({...t,save:{...t.save,problem:e}})),`Its progress is forgotten for the session, but ${e}.`}return n.state.update(e=>({...e,save:{key:a,read:!0,problem:null}})),c("App").info(`${t} (${a}): its save removed — a new app`),`Its progress is forgotten and its save "${a}" removed: every locked level locked again, no best time, nothing to continue.`}async function C(e){const t=T.get(e);if(!t)return{problem:"That app is not open."};const{key:n,problem:a}=s(t.state).save;if(!n)return{key:null,said:"The app keeps no save — its file name is none a save can take (letters, digits, spaces, dashes, underscores)."};let o;await t.saving;try{o=await u().saves.get(n)}catch(r){return{key:n,said:`The save "${n}" could not be read — ${r.message}.`}}if(null===o)return{key:n,saved:null,said:`Nothing is saved for "${n}" yet — a mission won or a level loaded saves the progress.`,...a?{problem:a}:{}};const{save:l,problem:i}=y(o);return l?{key:n,saved:l,said:`"${n}": ${l.won.length} mission(s) won, last played ${l.last??"none"}.`,...a?{problem:a}:{}}:{key:n,saved:null,said:`The save "${n}" does not read (${i}) — it is ignored, the next progress writes over it.`}}function P(e,s){const n=T.get(e);if(!n)return["That app is not open."];const{app:a,problems:o}=function(e){let s;try{s=JSON.parse(e)}catch(o){return{app:null,problems:[`not JSON — ${o.message}`]}}if(!m(s)||"app"!==s.format)return{app:null,problems:['an app is { "format": "app", "title", "levels": [{ "name", "title"?, "stage", "unlock"?, "menu"?, "music"? }] }']};const n=[];"string"==typeof s.title&&s.title.trim()||n.push('"title" is what the menu says over its levels');const a=[];if(Array.isArray(s.levels)&&s.levels.length)for(const[l,i]of s.levels.entries()){const e=`level ${m(i)&&"string"==typeof i.name?`"${i.name}"`:l+1}`,s=n.length;if(!m(i)){n.push(`${e}: { "name", "title"?, "stage", "unlock"? }`);continue}"string"==typeof i.name&&d.test(i.name)?a.some(e=>e.name===i.name)&&n.push(`${e}: a name only once`):n.push(`${e}: "name" of lower-case letters, digits and dashes`),void 0===i.title||"string"==typeof i.title&&i.title.trim()||n.push(`${e}: "title" is what the menu calls it`),t(i.stage,".stage")||n.push(`${e}: "stage" is its .stage — "asset:assets/<name>.stage"`);const o=i.unlock;void 0===o||m(o)&&"string"==typeof o.level&&"string"==typeof o.won&&o.won||n.push(`${e}: "unlock" is { "level": a level of the app, "won": a mission of its stage } — locked until that mission is won`),void 0!==i.menu&&"boolean"!=typeof i.menu&&n.push(`${e}: "menu": false keeps it out of the menu (a door leads to it)`),void 0!==i.music&&"boolean"!=typeof i.music&&n.push(`${e}: "music": true — the music plays in it`),n.length>s||a.push({name:i.name,title:i.title??i.name,stage:i.stage,unlock:o?{level:o.level,won:o.won}:null,menu:!1!==i.menu,music:!0===i.music})}else n.push('"levels" lists its levels — each { "name", "title"?, "stage": "asset:assets/<name>.stage", "unlock"?, "menu"?, "music"? }');for(const t of a)t.unlock&&(a.some(e=>e.name===t.unlock.level)?t.unlock.level===t.name&&n.push(`level "${t.name}": it cannot be unlocked by its own mission — it would never be played`):n.push(`level "${t.name}": "unlock" names the level "${t.unlock.level}" — the app has ${a.map(e=>e.name).join(", ")}`));return a.length&&!a.some(e=>e.menu)&&n.push("every level is out of the menu — the menu would offer none to begin with"),n.length?{app:null,problems:n}:{app:{title:s.title.trim(),levels:a},problems:[]}}(s);return n.state.update(e=>a?{...e,doc:a,problems:[]}:{...e,problems:o}),a||c("App").warn(`${e}: ${o.join("; ")}`),o}async function E(e,t){const s=T.get(e);if(!s)return null;if(!t)return s.state.update(e=>({...e,credits:null})),null;const{models:n,problem:a}=await l(u());a&&c("App").warn(`the credits: ${a}`);const o=Object.keys(n).map(e=>`assets/${e}`),i=(r=function(e,t){let s;try{s="string"==typeof e?JSON.parse(e):e}catch{return[]}const n=new Map;for(const a of t){const e=a.startsWith("assets/")?a.slice(7):null,t=e?s[e]:void 0;if(!t?.pack)continue;const o=n.get(t.pack)??{pack:t.pack,licence:t.licence??"",models:[]};o.models.push(e),n.set(t.pack,o)}return[...n.values()].map(e=>({...e,models:e.models.sort()})).sort((e,t)=>e.pack.localeCompare(t.pack))}(n,o),[...r.length?["3D models"]:[],...r.map(e=>`${e.pack} — ${e.models.length} model${1===e.models.length?"":"s"}${e.licence.includes("CC0")?" (CC0)":""}`),"Made with FaustWave."]);var r;return s.state.update(e=>({...e,credits:i})),i}function F(e,t){T.get(e)?.state.update(e=>({...e,editing:t}))}function D(t,n,a){const o=T.get(t);o||e("That app is not open.");const l=s(o.state);l.doc||e(`The app does not read: ${l.problems.join("; ")||"not loaded yet"}.`);const i=l.doc.levels.find(e=>e.name===n);i||e(`No level "${n}" — the app has ${l.doc.levels.map(e=>e.name).join(", ")}.`);const r=f(l.doc,i,l.won);r&&e(`${i.title} is locked — ${r}.`);const p=u(),d=p.documents.listModules().find(e=>"stage"===e.type&&e.filePath===i.stage);let m;return o.since=performance.now(),o.state.update(e=>({...e,phase:"loading",level:n,last:n,spawn:a,result:null,notice:null,loads:e.loads+1,editing:!1})),d?(m=d.id,o.state.update(e=>({...e,stage:m})),W(t,o,m,a),p.documents.showDocument(m)):(m=p.documents.addModule("stage",void 0,{filePath:i.stage}),o.state.update(e=>({...e,stage:m})),W(t,o,m,a)),L(o,l.doc,i),c("App").info(`${l.doc.title}: level ${n} loads${a?` at the mark ${a}`:""}`),`Level ${n} (${i.title}) loads${a?` — the player at the mark ${a}`:""}: its stage is shown, its world made anew; app.state says when it plays.`}function I(t){const n=T.get(t)?s(T.get(t).state):null;return n||e("That app is not open."),n.level||e("No level has been played yet — app.level.load { level } loads one."),D(t,n.level,null)}function z(t,n=!1){const a=T.get(t);a||e("That app is not open.");const o=s(a.state);return o.stage&&R("its world could not play on",u().actions.run("stage.pause",{module_id:o.stage,on:!1})),a.state.update(e=>({...e,phase:"menu",result:null,notice:null,editing:!1,...n?{level:null}:{}})),u().documents.showDocument(t),L(a,o.doc,null),`${o.doc?.title??"The app"}: its menu${n?" — a new app":""}.`}function B(){const e=u().events.on("stage.made",({stage:e,failed:t})=>{for(const[n,a]of T){const o=s(a.state);if("loading"!==o.phase||o.stage!==e)continue;if(t.length){c("App").error(`level ${o.level} could not load: ${t.join("; ")}`),z(n),U(a,`The level could not load: ${t.join("; ")}`);continue}const l=Math.round(performance.now()-a.since);a.state.update(e=>({...e,phase:"playing",loaded:{level:o.level,ms:l}})),c("App").info(`${o.doc?.title??n}: level ${o.level} plays (its world was there after ${l} ms)`)}}),t=u().events.on("stage.world.event",({stage:e,events:t})=>{for(const[n,a]of T){const o=s(a.state);if("playing"===o.phase&&o.stage===e&&o.doc)for(const s of t){if("mark"in s){if("door"!==s.kind||!s.into||!s.to||s.mark===o.spawn)continue;const e=h(o.doc,s.to.stage),t=e?f(o.doc,e,o.won):null;return void(e?t?U(a,`${e.title} is locked — ${t}`):R("the door's level could not load",u().actions.run("app.level.load",{module_id:n,level:e.name,...s.to.mark?{spawn:s.to.mark}:{}})):U(a,`This door leads to ${s.to.stage} — no level of the app`))}if("win"!==s.moment&&"lose"!==s.moment)continue;const t="win"===s.moment,l=v(o.level,s.mission),i=s.took??0,r=o.best[l],p=t?j(O(o),l,i):O(o),d=p.best[l]??null,m={level:o.level,mission:s.mission,title:s.title??s.mission,won:t,took:i,why:t?null:"the time is up",best:d,record:t&&void 0!==r&&i<r};return R("its world could not pause",u().actions.run("stage.pause",{module_id:e,on:!0})),a.state.update(e=>({...e,phase:"results",result:m,won:p.won,best:p.best})),void c("App").info(`${o.doc.title}: ${o.level} — mission ${s.mission} ${t?"won":"lost"} in ${m.took.toFixed(1)} s`)}}}),n=u().documents.subscribeModules((e,t)=>S=t);return()=>{e(),t(),n()}}function L(e,t,s){if(!t?.levels.some(e=>e.music))return;const n=s?.music??!1;(n||e.musicOn)&&(e.musicOn=n,e.music=e.music.then(async()=>{const t=u(),s=!!(await t.actions.run("performer.state",{}))?.playing;n&&!s?t.actions.run("performer.start",{minutes:null}).catch(t=>{e.musicOn=!1,c("App").warn(`the band does not play — ${t.message}`),U(e,`The band does not play — ${t.message}`)}):n||await t.actions.run("performer.stop",{})}).catch(e=>c("App").warn(`the band could not be ${n?"started":"stopped"} — ${e.message}`)))}function R(e,t){t.catch(t=>c("App").error(`${e}: ${t instanceof Error?t.message:String(t)}`))}function W(e,t,s,n){u().actions.run("stage.restart",{module_id:s,...n?{spawn:n}:{}}).catch(s=>{const n=s instanceof Error?s.message:String(s);c("App").error(`the level could not start: ${n}`),z(e),U(t,`The level could not start: ${n}`)})}function U(e,t){e.state.update(e=>({...e,notice:{id:(e.notice?.id??0)+1,text:t}}))}export{o as _,I as a,C as c,z as d,B as f,r as g,u as h,x as i,F as l,g as m,N as n,D as o,f as p,P as r,J as s,_ as t,E as u,l as v};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as t}from"./fileRef-BmnWhXuY.js";import{n as e,o as i,s}from"./paths-DFjX1bFA.js";import"./client-DksDHYQL.js";import{a as n,c as r,i as o,n as a,o as l,s as u}from"./faustSource-Blr9zzKL.js";import{t as h}from"./transportFollow-Ox91SKLF.js";import{t as d}from"./fileMirror-CkgB9zNS.js";import{n as c}from"./preArm-ifXM2Buj.js";import{n as m,t as p}from"./panic-ckha9YOX.js";import{D as g,K as f,L as y,t as b,z as w}from"./src-DyDfRe65.js";import{i as I,s as S,t as P}from"./src-BvHr5YSH.js";import{n as k,t as M}from"./soundfiles-DMZ8HKDZ.js";var v=null;function $(){if(!v)throw new Error("[extension-editors] IDEAPI not initialized. Did the factory run?");return v}var C=new Map;function A(t){const e=C.get(t);if(e)return e;const i=$().log.create(t);return C.set(t,i),i}var E=class extends P{async start(t,e,i,s){await this.startOn(t,{getInput:i,pluginParts:e,...s?{partsKey:s}:{}})}setOutputHandler(t){this.listenToOutputs(t)}setParamValue(t,e,i){this.worklet?.set(t,e,i)}getParamValue(t){return this.valueAt(t)??null}};function O(t){return"armed"===t?"idle":t}function U(t){if(!t)return[];const e=[],i=t=>{for(const s of t)s.address&&e.push(s.address),s.items&&i(s.items)};return i(t),e}function D(t){return!!Array.isArray(t)&&t.some(t=>{const e=t;return void 0!==e.items?D(e.items):(e.meta??[]).some(t=>/^key(on|off)?\b/.test(t.midi??""))})}var N=class{moduleId;dspName;modSourceId;#t=w("");#e=w("");get savedSource(){return g(this.#e)}set savedSource(t){y(this.#e,t,!0)}#i=w(null);get filePath(){return g(this.#i)}set filePath(t){y(this.#i,t,!0)}#s=w("untitled.dsp");get title(){return g(this.#s)}set title(t){y(this.#s,t,!0)}#n=w(!1);get dirty(){return g(this.#n)}set dirty(t){y(this.#n,t,!0)}#r=w(null);get engine(){return g(this.#r)}set engine(t){y(this.#r,t,!0)}#o=w(null);get descriptor(){return g(this.#o)}set descriptor(t){y(this.#o,t,!0)}#a=w(!1);get running(){return g(this.#a)}set running(t){y(this.#a,t,!0)}#l=w("idle");get status(){return g(this.#l)}set status(t){y(this.#l,t,!0)}#u=w(null);get cost(){return g(this.#u)}set cost(t){y(this.#u,t,!0)}#h=w("");get compileError(){return g(this.#h)}set compileError(t){y(this.#h,t,!0)}#d=w("");get compileWarning(){return g(this.#d)}set compileWarning(t){y(this.#d,t,!0)}#c=w(null);get modValues(){return g(this.#c)}set modValues(t){y(this.#c,t,!0)}#m=w(!1);get midiRoutedIn(){return g(this.#m)}set midiRoutedIn(t){y(this.#m,t,!0)}#p=f(()=>o(g(this.#t))||null);get detectedVoices(){return g(this.#p)}set detectedVoices(t){y(this.#p,t)}get followsTransport(){return $().transport.followsTransport(this.moduleId)}#g=f(()=>a(g(this.#t)));get midiChannel(){return g(this.#g)}set midiChannel(t){y(this.#g,t)}#f=f(()=>this.running&&this.midiRoutedIn&&null!==this.engine&&!this.engine.isPolyphonic);get monoMidiHint(){return g(this.#f)}set monoMidiHint(t){y(this.#f,t)}#y=null;#b=null;#w=null;#I=null;#S=null;#P;#k=null;#M=null;#v=null;#$=new Set;#C=null;#A=null;#E=!1;#O=A("FaustDsp");constructor(t){this.moduleId=t,this.dspName=`fwdsp_${t.replace(/[^a-zA-Z0-9_]/g,"_")}`,this.modSourceId=`${t}-mod`;const e=$(),i=e.documents.listModules().find(e=>e.id===t);this.filePath=i?.filePath??null,this.title=e.documents.resolveModuleTitle(t,{defaultExt:".dsp"});const r=e.pluginHost;if(this.#U=!!r&&!!this.filePath&&s(this.filePath,r.patch),!this.#U){const i=e.audio.registerModuleOutput(t,{label:`Faust DSP: ${this.title}`,meta:{kind:"faust-dsp"}});this.#y=i.node,this.#b=i.unregister}if(this.engine=new E(()=>this.moduleId,()=>this.title),this.#S=e.routing.subscribe(e=>{this.midiRoutedIn=e.connections.some(e=>"midi"===e.kind&&!1!==e.enabled&&e.to.sinkId===`${t}:midi-in`)}),this.#P=new m(e,{moduleId:t,sourceKey:()=>g(this.#t),runnable:()=>!this.#U&&n(g(this.#t)),eager:()=>0===o(g(this.#t)),idleOnPlay:()=>l(g(this.#t))&&!h($().routing.getTable().connections,this.moduleId),listenChannel:()=>this.midiChannel,armedLabel:()=>`Faust DSP MIDI: ${this.title} (armed)`,prewarm:()=>{this.#D()},start:t=>this.#N(t),release:async()=>{this.engine&&await this.#V(this.engine)},handleMidi:t=>this.handleMidiMessage(t),stateChanged:t=>this.#T(t)}),this.#w=e.documents.register(t,this.#F()),r&&this.#U&&(this.#M=e.modulation.registerParamSink(t,{setParam:(t,e)=>r.set(t,e),getDescriptor:t=>{const e=r.params.find(e=>e.path===t);return e?{min:e.min,max:e.max,init:e.init,...e.scale?{scale:e.scale}:{}}:null},getValue:t=>r.value(t),listPaths:()=>r.params.map(t=>t.path),subscribeValues:t=>r.subscribe(t),hold:(t,e)=>r.gesture(t,e),restorable:()=>!1}),r.modouts.length)){this.#v=e.routing.registerSource({id:this.modSourceId,kind:"modulation",label:`Faust DSP: ${this.title} (mod)`,document:this.moduleId,outputs:r.modouts.map(t=>({id:t.address,label:t.label}))});const t=new Set(r.modouts.map(t=>t.address));this.#x=r.subscribe(i=>{for(const[s,n]of i)t.has(s)&&e.modulation.setSourceValue(this.modSourceId,s,n)})}}#U=!1;#x=null;get source(){return g(this.#t)}set source(t){t!==g(this.#t)&&(y(this.#t,t,!0),this.#j())}#j(){const t=g(this.#t)!==this.savedSource;t!==this.dirty&&(this.dirty=t,$().documents.updateModuleMeta(this.moduleId,{dirty:t})),t&&this.#W()}#_(t){this.status=t,t!==this.#A&&(this.#A=t,$().documents.updateModuleMeta(this.moduleId,{runStatus:O(t)}))}async load(){if(this.#E)return;this.#E=!0;const t=$();let e;try{e=await t.documents.loadDocumentSource(this.moduleId)}catch(i){throw this.#E=!1,i}if(y(this.#t,e??'declare name "My Patch";\ndeclare author "me";\ndeclare version "0.1";\n\nimport("stdfaust.lib");\n\nfreq = hslider("freq [scale:log][unit:Hz]", 440, 50, 5000, 0.1);\nlevel = hslider("level", 0.3, 0, 1, 0.001);\n\nprocess = os.osc(freq) * level;\n',!0),this.savedSource=g(this.#t),!this.filePath)try{await this.saveTo()}catch(i){this.#O.error("initial auto-place failed",i)}this.#U||(this.#P.wakeCheck(),this.#D())}#L(){return{label:`Faust DSP: ${this.title}`,meta:{kind:"faust-dsp"}}}#T(t){this.running="running"===t,"running"===t?this.#_("running"):"armed"===t?this.#_("armed"):"error"!==this.status&&this.#_("idle")}async compileOnly(){const t=this.engine;if(!t)return{ok:!1,error:"Engine not ready."};if(this.running)return await this.#P.renew(),"error"===this.status?{ok:!1,error:this.compileError}:{ok:!0};this.#_("compiling"),this.compileError="",this.compileWarning="";const e=await this.#R(t);return e.ok?(this.#K(t),this.compileWarning=e.warning??"",e.warning&&this.#O.warn(e.warning),$().audio.registerModuleInput(this.moduleId,t.getInputChannelCount(),this.#L()),this.#_("armed"===this.#P.state?"armed":"idle"),{ok:!0}):(this.#_("error"),this.compileError=e.error,this.#O.warn(`compile failed: ${e.error}`),{ok:!1,error:e.error})}#H=null;#z=null;#R(t){const e=g(this.#t);if(this.#H?.source===e)return this.#H.done;const i=o(e),s=t.compile(e,this.dspName,i>0?{voices:i}:void 0).then(t=>(t.ok&&(this.#z=e),t)),n={source:e,done:s};return this.#H=n,s.finally(()=>{this.#H===n&&(this.#H=null)}),s}async#D(){const t=this.engine,e=g(this.#t);if(!t||this.running||this.#P.starting||!n(e))return;if(e===this.#z||this.#P.blocks(e))return;const i=await this.#R(t);this.running||e!==g(this.#t)||(i.ok?this.#K(t):this.compileError=i.error)}#K(t){this.#B(t),this.descriptor=t.getUI()}async run(){this.#U||(this.running&&await this.#P.stop(),await this.#P.run())}async stop(){await this.#P.stop()}async#N(t){const e=this.engine;if(!e)return!1;const i=e.hasCompiled&&g(this.#t)===this.#z;i||(this.#_("compiling"),this.compileError="",this.compileWarning="");const s=i?{ok:!0,warning:this.compileWarning||null}:await this.#R(e);if(!t.current())return!1;if(!s.ok)return this.#_("error"),this.compileError=s.error,this.#O.warn(`compile failed: ${s.error}`),!1;if(this.compileWarning=s.warning??"",s.warning&&this.#O.warn(s.warning),$().audio.registerModuleInput(this.moduleId,e.getInputChannelCount(),this.#L()),!this.#y)return this.compileError="Module output not registered — reload the tab.",this.#_("error"),!1;try{if(await e.start(this.#y,()=>this.#q(),async t=>$().audio.registerModuleInput(this.moduleId,t,this.#L()),()=>M(g(this.#t),()=>$().project.listAssets())),!t.current()){try{await e.stop()}catch{}return!1}return this.descriptor=e.getUI(),this.cost=e.cost,this.#J(e),t.live()?(this.#I?.(),this.#I=$().midi.onMessage(t=>this.handleMidiMessage(t),{sinkId:`${this.moduleId}:midi-in`,label:`Faust DSP MIDI: ${this.title}`,...e.isPolyphonic?{isAudible:!0,priority:"user-loaded"}:{},allNotesOff:()=>this.allNotesOff()}),!0):(await this.#V(e),!1)}catch(n){return this.#_("error"),this.compileError=n instanceof Error?n.message:String(n),this.#O.error("start failed",n),await this.#V(e),!1}}async#V(t){this.#I?.(),this.#I=null,t.allNotesOff();try{await t.stop()}catch(e){this.#O.warn("engine stop failed",e)}t.onValueUpdate(null),this.#Z(),this.modValues=null,this.descriptor=t.getUI()}setMidiChannel(t){if(!Number.isInteger(t)||t<0||t>16)return{ok:!1,error:`MIDI channel must be an integer 0–16, got ${t}.`};const e=this.source;if(a(e)===t)return{ok:!0,message:t>0?`Already filtering on MIDI channel ${t}.`:"Already Omni (no channel filter)."};this.source=r(e,"midichannel",t>0?String(t):null);const i=this.running;i&&this.run();const s=i?" — recompiling":"";return{ok:!0,message:t>0?`Now accepting MIDI channel ${t} only ([midichannel:${t}] set${s} — save to persist).`:`Now Omni — accepting every MIDI channel ([midichannel] removed${s} — save to persist).`}}setFollowTransport(t){return $().transport.setFollowsTransport(this.moduleId,t)?(this.#P.followChanged(),{ok:!0,message:t?"Now following the global transport (the project keeps it).":"Now independent of the global transport (the project keeps it)."}):{ok:!0,message:t?"Already following the global transport.":"Already independent of the global transport."}}#q(t={}){return I(this.dspName,g(this.#t),o(g(this.#t))||null,k($().audio.getContext(),t=>$().files.readBinary(t),(t,e)=>this.#O.warn(`soundfile ${t} could not be read: ${e}`)),t)}#J(t){const e=$();this.#B(t),t.onValueUpdate(t=>{const e=new Map(t);this.modValues=e;for(const i of this.#$)i(e)}),this.#G(t,e)}#B(t){const e=$();this.#k?.(),this.#M?.(),this.#M=e.modulation.registerParamSink(this.moduleId,S(t,{subscribeValues:t=>(this.#$.add(t),()=>this.#$.delete(t))})),this.#k=e.routing.registerSink({id:this.moduleId,kind:"modulation",label:`Faust DSP: ${this.title} (params)`,document:this.moduleId,inputs:t.getModulatableParams().map(t=>({id:t,label:t}))}),this.#Q(t,e)}#Q(t,e){const i=t.getModulationOutputs();0!==i.length&&(this.#v=e.routing.registerSource({id:this.modSourceId,kind:"modulation",label:`Faust DSP: ${this.title} (mod)`,document:this.moduleId,outputs:i.map(t=>({id:t.address,label:t.label}))}))}#G(t,e){const i=t.getModulationOutputs();if(0===i.length)return;const s=new Set(i.map(t=>t.address));t.setOutputHandler((t,i)=>{s.has(t)&&e.modulation.setSourceValue(this.modSourceId,t,i)})}#Z(){this.engine?.setOutputHandler(null),$().modulation.clearSourceValues(this.modSourceId)}#X(){this.#Z(),this.#v?.(),this.#v=null}onParamChange(t,e){this.engine?.setParamValue(t,e),$().actions.run("modulation.base.set",{sink_id:this.moduleId,path:t,value:e})}handleMidiMessage(t){const e=this.engine;e&&this.running&&0!==t.data.length&&c(this.midiChannel,t)&&e.sendMidi(t.data,t.time)}allNotesOff(){const t=this.engine;t&&this.running&&p(t,{holdsKeys:()=>D(t.getUI()),listen:this.midiChannel})}#W(){this.#C&&clearTimeout(this.#C),this.#C=setTimeout(()=>{this.#C=null,this.saveTo().catch(t=>this.#O.error("autosave failed",t))},800)}async saveTo(t){const s=$(),n=g(this.#t);let r;return r=null!=t?e(t,".dsp"):this.filePath?this.filePath:await i(s.project,this.title,".dsp"),await s.files.writeText(r,n),this.filePath=r,this.title=r.replace(/^.*[\\/]/,""),this.savedSource=n,this.dirty&&g(this.#t)===n&&(this.dirty=!1,s.documents.updateModuleMeta(this.moduleId,{dirty:!1})),s.documents.updateModuleMeta(this.moduleId,{filePath:r,title:this.title}),r}#F(){return{getSource:()=>g(this.#t),setSource:t=>{this.source=t},reloadFromDisk:t=>(y(this.#t,t,!0),this.savedSource=t,this.#j(),!0),getEngineState:()=>({running:this.running,compiled:this.engine?.hasCompiled??!1,status:O(this.status),compile_error:this.compileError,compile_warning:this.compileWarning||null,params:U(this.engine?.getUI()??null),polyphonic:this.running&&null!==this.engine?this.engine.isPolyphonic:o(g(this.#t))>0,midi_channel:this.midiChannel,cost:this.running&&this.cost?{ms_per_block:this.cost.msPerBlock,share:this.cost.share}:null,transport_follow:this.followsTransport}),setMidiChannel:t=>this.setMidiChannel(t),setFollowTransport:t=>this.setFollowTransport(t),compile:async()=>this.compileOnly(),pluginParts:async t=>{try{return{ok:!0,parts:await this.#q(t)}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}},run:async()=>(await this.run(),"error"===this.status?{ok:!1,error:this.compileError}:this.running?{ok:!0,params:U(this.engine?.getUI()??null)}:{ok:!1,error:this.compileError||"not started — dsp.state says why"}),stop:async()=>{await this.stop()},setParam:(t,e)=>!(!this.engine||!this.running)&&(this.engine.setParamValue(t,e),!0),getParam:t=>this.engine&&this.running?this.engine.getParamValue(t):null,save:async t=>{try{const e=await this.saveTo(t);return e?{ok:!0,filePath:e}:{ok:!1,error:"No path provided and the module has no filePath yet — pass `path` to documents.save."}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}},getState:()=>({title:this.title,filePath:this.filePath,dirty:this.dirty,running:this.running,status:this.status,compileError:this.compileError,params:U(this.engine?.getUI()??null),polyphonic:this.running&&null!==this.engine?this.engine.isPolyphonic:o(g(this.#t))>0})}}async dispose(){if(this.#C&&(clearTimeout(this.#C),this.#C=null),this.dirty)try{await this.saveTo()}catch(t){this.#O.error("close-flush save failed",t),$().messages.notify({kind:"error",title:`${this.title} was closed with unsaved edits`,description:t?.message??String(t),durationMs:0})}try{await this.stop()}catch(t){this.#O.warn("stop during teardown failed",t)}this.#P.dispose();try{this.#w?.()}catch{}this.#w=null,this.#S?.(),this.#S=null;try{await(this.engine?.dispose())}catch(t){this.#O.warn("engine dispose failed",t)}this.engine=null,this.descriptor=null,this.running=!1;try{this.#b?.()}catch{}this.#b=null,this.#y=null,this.#k?.(),this.#k=null,this.#M?.(),this.#M=null,this.#x?.(),this.#x=null,this.#X()}},V=new Map;var T={id:"faust-dsp",label:"Faust DSP",icon:"FileCode",description:"Author a Faust .dsp with live audio output.",fileExtensions:[".dsp"],sounds:!0,compiles:!0,createRuntime:t=>(function(t){let e=V.get(t);return e||(e=new N(t),V.set(t,e)),e}(t).load().catch(e=>A("Faust DSP").error(`load "${t}" failed:`,e)),{dispose:()=>{!function(t){const e=V.get(t);!!e&&(e.dispose(),V.delete(t))}(t)}}),sealForPlayer:u,fxSource:t=>n(t)?t:null,patchOf:function(t){return n(t)?{source:t,takesInput:l(t),nodes:null}:null},instrumentOf:function(t){const e=a(t);return e?{channel:e,notes:null}:"declares no MIDI channel ([midichannel:N] in its options, 1..16) — it would hear every part"}},F=`${JSON.stringify({bundle:"asset:assets/<module>.wclap.tar.gz"},null,2)}\n`;function x(e){let i;try{i=JSON.parse(e)}catch(r){return`not JSON (${r instanceof Error?r.message:String(r)})`}if(!i||"object"!=typeof i||Array.isArray(i))return'not an object { "bundle": …, "plugin"?: … }';const s=i,n=Object.keys(s).filter(t=>"bundle"!==t&&"plugin"!==t&&"channel"!==t);return n.length?`${n.map(t=>`"${t}"`).join(", ")}: not a field of a plugin document (it has "bundle", "plugin" and "channel")`:"string"==typeof s.bundle&&t(s.bundle)?void 0===s.plugin||"string"==typeof s.plugin&&s.plugin?void 0!==s.channel&&("number"!=typeof s.channel||!Number.isInteger(s.channel)||s.channel<1||s.channel>16)?'"channel" is the MIDI channel it hears, 1..16 (or left out: every one)':{bundle:s.bundle,..."string"==typeof s.plugin?{plugin:s.plugin}:{},..."number"==typeof s.channel?{channel:s.channel}:{}}:'"plugin" is a plugin id of its factory (or left out: the first)':'"bundle" names the module or bundle, a project asset (asset:assets/<name>.wclap.tar.gz or .wasm)'}function j(t,e){const i={type:"vgroup",label:t,items:[]},s=new Map;return e.forEach((t,e)=>{if(t.hidden||t.readonly)return;const n=function(t,e){const i=b(t.id),s={label:t.name,address:i,shortname:t.name,index:e,min:t.min,max:t.max,url:i,init:t.init};return t.values?{...s,type:"hslider",step:1,meta:[{style:`menu{${t.values.map(t=>`'${t.text.replaceAll(";",",")}':${t.value}`).join(";")}}`}]}:t.stepped&&0===t.min&&1===t.max?{...s,type:"checkbox",step:1}:{...s,type:"hslider",step:t.stepped?1:0,meta:[{style:"knob"}]}}(t,e);if(!t.module)return void i.items.push(n);let r=s.get(t.module);r||(r={type:"vgroup",label:t.module,items:[]},s.set(t.module,r),i.items.push(r)),r.items.push(n)}),[i]}var W=class{moduleId;#t=w("");#s=w("");get title(){return g(this.#s)}set title(t){y(this.#s,t,!0)}#Y=w(null);get ref(){return g(this.#Y)}set ref(t){y(this.#Y,t,!0)}#n=w(!1);get dirty(){return g(this.#n)}set dirty(t){y(this.#n,t,!0)}mirror;constructor(t,e,i,s){this.moduleId=t;const n=$();if(this.mirror=d({api:n,moduleId:t,ext:e,get:()=>g(this.#t),set:t=>this.#tt(t),scaffold:i,onFile:({title:t,ref:e})=>{this.title=t,this.ref=e,this.fileChanged(e)},onText:()=>this.dirty=this.mirror.dirty()}),this.title=this.mirror.title(),this.ref=this.mirror.ref(),s){const t=this.mirror.runtime.getState;this.mirror.runtime.getState=()=>({...t(),...s()})}this.mirror.load().catch(e=>A("Editors").error(`${t} did not load`,e))}get source(){return g(this.#t)}set source(t){this.#tt(t)}#tt(t){y(this.#t,t,!0),this.mirror?.changed(),this.mirror&&(this.dirty=this.mirror.dirty()),this.textChanged()}fileChanged(t){}textChanged(){}dispose(){return this.mirror.dispose()}},_=new Map;var L,R=class extends W{#et=w(null);get description(){return g(this.#et)}set description(t){y(this.#et,t,!0)}#it=w("");get problem(){return g(this.#it)}set problem(t){y(this.#it,t,!0)}#st=w("stopped");get state(){return g(this.#st)}set state(t){y(this.#st,t,!0)}#o=f(()=>this.description?j(this.description.name,this.description.params):null);get descriptor(){return g(this.#o)}set descriptor(t){y(this.#o,t)}#c=w(null);get modValues(){return g(this.#c)}set modValues(t){y(this.#c,t,!0)}#$=new Set;#nt=null;#rt=null;#ot="";#at=0;#lt=null;#ut=null;#I=null;#b=null;#ht=null;#P;#O=A("Plugin");constructor(t){super(t,".plugin",F,()=>({plugin:this.description?.id??null,problem:this.problem||null,state:this.state}));const e=$(),i=e.audio.registerModuleOutput(t,{label:`Plugin: ${this.title}`,meta:{kind:"wclap-plugin"}});this.#ht=i.node,this.#b=i.unregister,this.#P=new m(e,{moduleId:t,sourceKey:()=>this.#ot,runnable:()=>null!==this.description,eager:()=>!(this.description?.notes&&0===this.description.audioIn),idleOnPlay:()=>(this.description?.audioIn??0)>0&&!h($().routing.getTable().connections,this.moduleId),listenChannel:()=>this.#dt(),armedLabel:()=>`Plugin MIDI: ${this.title} (armed)`,prewarm:()=>{},start:t=>this.#N(t),release:()=>this.#ct(),handleMidi:t=>this.#mt(t),stateChanged:t=>{this.state=t,$().documents.updateModuleMeta(this.moduleId,{runStatus:"running"===t?"running":this.problem?"error":"idle"})}}),Object.assign(this.mirror.runtime,this.#F())}textChanged(){queueMicrotask(()=>{this.#pt()})}async#pt(){const t=this.source.trim()===F.trim()?"it names no plugin yet — plugin.document.create writes one that does":x(this.source);if("string"==typeof t)return this.#rt=null,this.#ot="",this.description=null,void(this.problem=t);const e=`${t.bundle}|${t.plugin??""}`;if(e===this.#ot&&(this.description||this.#lt))return this.#lt??void 0;this.#rt=t,this.#ot=e;const i=++this.#at,s=(async()=>{try{const e=new Uint8Array(await $().files.readBinary(t.bundle)),s=await $().audio.describePlugin(e,t.plugin);if(i!==this.#at)return;this.description=s,this.problem="",this.#B(),this.#P.wakeCheck()}catch(e){if(i!==this.#at)return;this.description=null,this.problem=`${t.bundle}${t.plugin?` (${t.plugin})`:""}: ${e instanceof Error?e.message:String(e)}`,this.#O.warn(this.problem)}finally{i===this.#at&&(this.#lt=null)}})();return this.#lt=s,s}async#N(t){const e=this.#rt,i=this.#ht;if(!e||!i||!this.description)return!1;const s=$();let n;try{const i=new Uint8Array(await s.files.readBinary(e.bundle));if(!t.current())return!1;n=await s.audio.playPlugin(this.moduleId,i,{label:()=>this.title,...e.plugin?{pluginId:e.plugin}:{}})}catch(r){return this.problem=r instanceof Error?r.message:String(r),this.#O.error(`${this.title} did not start: ${this.problem}`),!1}return t.current()?(this.#ut=n,n.output.connect(i),n.onValues(t=>{const e=new Map(t);this.modValues=e;for(const i of this.#$)i(e)}),this.#B(),n.input&&s.audio.registerModuleInput(this.moduleId,n.inputChannels,{label:`Plugin in: ${this.title}`})?.connect(n.input),t.live()?(this.problem="",this.#I?.(),this.#I=s.midi.onMessage(t=>this.#mt(t),{sinkId:`${this.moduleId}:midi-in`,label:`Plugin MIDI: ${this.title}`,...this.description.notes&&0===this.description.audioIn?{isAudible:!0,priority:"user-loaded"}:{},allNotesOff:()=>this.#ut?.allNotesOff()}),!0):(await this.#ct(),!1)):(n.dispose(),!1)}#mt(t){this.#ut&&t.data.length&&c(this.#dt(),t)&&this.#ut.midi(t.data,t.time)}#dt(){const t=x(this.source);return"string"==typeof t?0:t.channel??0}#gt(t){if(!Number.isInteger(t)||t<0||t>16)return{ok:!1,error:`MIDI channel must be an integer 0–16, got ${t}.`};const e=x(this.source);return"string"==typeof e?{ok:!1,error:`${this.title} cannot be read: ${e}`}:(e.channel??0)===t?{ok:!0,message:t?`Already hearing MIDI channel ${t}.`:"Already Omni (every channel)."}:(this.source=function(t){return`${JSON.stringify({bundle:t.bundle,...t.plugin?{plugin:t.plugin}:{},...t.channel?{channel:t.channel}:{}},null,2)}\n`}({bundle:e.bundle,...e.plugin?{plugin:e.plugin}:{},...t?{channel:t}:{}}),{ok:!0,message:t?`Now hearing MIDI channel ${t} only (written into ${this.title}).`:`Now Omni — every channel (written into ${this.title}).`})}async#ct(){this.#I?.(),this.#I=null;const t=this.#ut;this.#ut=null,this.modValues=null,t&&(t.allNotesOff(),t.dispose(),$().audio.registerModuleInput(this.moduleId,0))}#ft(){return(this.description?.params??[]).filter(t=>!t.readonly)}#B(){const t=$();this.#nt?.();const e=new Map(this.#ft().map(t=>[b(t.id),t])),i=t.modulation.registerParamSink(this.moduleId,{setParam:(t,e,i)=>this.#ut?.set(t,e,i),getDescriptor:t=>{const i=e.get(t);return i?{min:i.min,max:i.max,init:i.init,...i.values?{options:Object.fromEntries(i.values.map(t=>[t.text,t.value]))}:{}}:null},getValue:t=>this.#ut?.get(t)??null,listPaths:()=>[...e.keys()],subscribeValues:t=>(this.#$.add(t),()=>this.#$.delete(t))}),s=t.routing.registerSink({id:this.moduleId,kind:"modulation",label:`Plugin: ${this.title} (params)`,document:this.moduleId,inputs:[...e].map(([t,e])=>({id:t,label:e.name}))});this.#nt=()=>{i(),s()}}onParamChange(t,e){this.#ut?.set(t,e),$().actions.run("modulation.base.set",{sink_id:this.moduleId,path:t,value:e})}#F(){const t=()=>this.#ft().map(t=>b(t.id));return{compile:async()=>(await this.#pt(),this.description?{ok:!0,note:" A plugin is not compiled — its asset is the plugin; it was read."}:{ok:!1,error:this.problem}),run:async()=>(await this.#pt(),this.description?(await this.#P.run(),"running"===this.state?{ok:!0,params:t()}:{ok:!1,error:this.problem||"not started — dsp.state says why"}):{ok:!1,error:this.problem}),stop:()=>this.#P.stop(),setMidiChannel:t=>this.#gt(t),setFollowTransport:t=>$().transport.setFollowsTransport(this.moduleId,t)?(this.#P.followChanged(),{ok:!0,message:t?"Now following the global transport (the project keeps it).":"Now independent of the global transport (the project keeps it)."}):{ok:!0,message:t?"Already following the global transport.":"Already independent of the global transport."},getEngineState:()=>({running:"running"===this.state,compiled:null!==this.description,status:"running"===this.state?"running":this.problem?"error":"idle",compile_error:this.problem,params:t(),midi_channel:this.#dt(),transport_follow:$().transport.followsTransport(this.moduleId)}),pluginParts:async()=>({ok:!1,error:"A plugin of another toolchain has no Faust parts — it is built already."})}}async dispose(){this.#at++;try{await this.#P.stop()}catch(t){this.#O.warn("stop during teardown failed",t)}this.#P.dispose(),this.#nt?.(),this.#nt=null,this.#b?.(),this.#b=null,this.#ht=null,await super.dispose()}},K={id:"wclap-plugin",label:"Plugin",icon:"Plug",description:"A WebCLAP plugin of another toolchain (a .wasm or .wclap.tar.gz asset), played as it is.",fileExtensions:[".plugin"],sounds:!0,createRuntime:(L=t=>new R(t),t=>(function(t,e){let i=_.get(t);i||_.set(t,i=e(t))}(t,L),{dispose:async()=>{const e=_.get(t);_.delete(t),await(e?.dispose())}})),refusesExport:"a plugin of another toolchain goes with a project only where its licence allows it; that is decided when it is needed (docs/AUDIO-WCLAP-FREMD-FAKTEN-ZIEL.md FZ6) — remove the .plugin documents, and the bundles they name, for a player",instrumentOf:function(t){const e=x(t);return"string"==typeof e?`is no plugin document: ${e}`:e.channel?{channel:e.channel,notes:null}:'names no MIDI channel ("channel": 1..16 in it, or dsp.midi.channel.set) — it would hear every part'},promptFragment:'## Plugin documents (.plugin) — WebCLAP plugins of other toolchains\nA `.plugin` document names a WebCLAP plugin that is a project asset as it came — a module (`.wasm`) or a bundle\n(`.wclap.tar.gz`): `{ "bundle": "asset:assets/<name>.wclap.tar.gz", "plugin": "<its CLAP id>", "channel": 1..16 }`\n("plugin" left out: the factory\'s first; "channel" left out: it hears every MIDI channel). Nothing is compiled: the\nasset is the plugin.\n- Make one with `plugin.document.create { bundle, path, plugin?, channel? }` (palette.run) — it reads the bundle and\n refuses an ambiguous one, naming its plugins; then `documents.add { ref: path }` opens it.\n- It plays as a .dsp does: `dsp.run` / `dsp.stop` / `dsp.state` with its module_id; an instrument waits armed for\n its first note — cable `keyboard-default:out` to `<module_id>:midi-in`; an effect takes audio from a cable into it.\n Its notes reach it in its note port\'s dialect (CLAP notes or MIDI). `dsp.midi.channel.set` writes its channel into it.\n- A Performer part plays it only when it names a channel (as a .dsp\'s [midichannel:N]).\n- Its params are its own, by CLAP id: `dsp.params.list` gives each `path` (the id in decimal, e.g. "1") with its name;\n `dsp.param.set`, `modulation.base.set` and modulation cables take that path. A project with a .plugin is not\n exported as a player (its plugin\'s licence decides — refused, said).'};function H(t){!function(t){v=t}(t);const e=t.extensions.registerDocumentKind(T),i=t.extensions.registerDocumentKind(K);return()=>{e(),i()}}export{H as activateEditorsRuntime};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t=t=>Math.log(Math.max(Number.EPSILON,t)),n=(t,n,r)=>Math.max(n,Math.min(r,t));function r(r,e,u,a){if(r<=0)return e;if(r>=1)return u;if("log"===a&&e>0&&u>0)return n(Math.exp(t(e)+(t(u)-t(e))*r),e,u);if("exp"===a&&e>0&&u>e){const a=n(e+r*(u-e),e,u);return e+(u-e)*((t(a)-t(e))/(t(u)-t(e)))}return e+r*(u-e)}function e(r,e,u,a){if("log"===a&&e>0&&u>0)return(t(n(r,e,u))-t(e))/(t(u)-t(e))||0;if("exp"===a&&e>0&&u>e){const a=(r-e)/(u-e)||0;return(n(Math.exp(t(e)+(t(u)-t(e))*a),e,u)-e)/(u-e)||0}return(r-e)/(u-e)||0}function u(t,n,u,a,o){const i=e(t,u,a,o)+n;return r(i<0?0:i>1?1:i,u,a,o)}function a(t,n,u,a,o,i){const f=e(n,a,o,i);return r(f+t*(e(u,a,o,i)-f),a,o,i)}function o(t,n,r,u,a,o){const i=e(n,u,a,o),f=e(r,u,a,o);return f===i?0:(e(t,u,a,o)-i)/(f-i)}export{u as a,a as i,e as n,r,o as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
async function t(t){const e="string"==typeof t?(new TextEncoder).encode(t):t instanceof Uint8Array?t:new Uint8Array(t),n=0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e:e.slice(),r=await crypto.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(r),t=>t.toString(16).padStart(2,"0")).join("")}export{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
async function t(t,a){const n=[...new Set(t.match(/asset:[^\s"'{}[\];,)]+/g)??[])].sort();if(!n.length)return"";const e=new Map((await a()).map(t=>[t.ref,t]));return n.map(t=>`${t}:${e.get(t)?.size??"-"}:${e.get(t)?.mtimeMs??"-"}`).join("|")}function a(t,a,n){return async e=>{const s={};for(const o of e)if(o.startsWith("asset:"))try{s[o]=await t.decodeAudioData(await a(o))}catch(r){n(o,r instanceof Error?r.message:String(r))}return s}}export{a as n,t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./bundledSources-2GoXdU5z.js","./libraryFacts-B_z-Kv6i.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as t}from"./paths-DFjX1bFA.js";import{a as e,d as n,i as o,o as r,r as s,s as i,t as a,u as l}from"./dist-DfaMbR-1.js";import{c}from"./faustSource-Blr9zzKL.js";import{t as u}from"./sha256-B9lHpAF4.js";import"./src-DyDfRe65.js";import{t as p}from"./faustwasm.js";import{t as f}from"./preload-helper-9MKZsTCd.js";import{n as d}from"./libraryFacts-B_z-Kv6i.js";var h=new Set(["hslider","vslider","nentry","button","checkbox"]);function m(t){const n=new Map,s=[],a=[],c=t=>{for(const u of t){if(u.address&&u.type&&h.has(u.type)){const t={min:u.min??0,max:u.max??1,init:u.init??0},o=e(u);o.length&&(t.options=Object.fromEntries(o.map(t=>[t.label,t.value])));const s=i(u);void 0!==s&&(t.cc=s);const c=l(u);"linear"!==c&&(t.scale=c),n.set(u.address,t),92&r(u)&&a.push(u.address)}!u.address||"hbargraph"!==u.type&&"vbargraph"!==u.type||o(u)||s.push({address:u.address,label:u.label??u.address}),u.items&&c(u.items)}};return c(t??[]),{paramMeta:n,modOutputs:s,transportFed:a}}var w=null,y=new Set,g=null;function v(t){w=t}var b="fwcc5",k=p;async function _(t){if(null===w)return null;try{const e=await w.get(t);return e&&e.code instanceof Uint8Array&&0!==e.code.length?"string"!=typeof e.json||0===e.json.length?null:(y.add(t),e):null}catch{return null}}var j=new Set;function $(){if(L>=2)return"wedged";for(const t of P.values())if("processing"===t.state&&void 0!==t.processingStartedAt&&Date.now()-t.processingStartedAt>15e3)return"suspect";return K>0&&Date.now()-D<12e4?"suspect":"ok"}var E=0,x=0,S=0,F=0,M=[],P=new Map,N=new Set;function A(){if(0===N.size)return;const t={totalCompiles:E,pending:x,lastCompileMs:S,recycles:K,health:$(),cacheHits:F};for(const e of N)try{e(t)}catch{}}var C=null,O=1,K=0,D=0,L=0,T=[],I=null,V=null,J=null,U=new Set(["compile","compilePoly"]),G=[];function W(){null!==V&&(clearTimeout(V),V=null),null!==J&&(clearTimeout(J),J=null)}function q(t,e){K+=1,"manual"!==t&&(L+=1),"manual"===t&&null===I||(D=Date.now()),W();const n=I;if(I=null,C){try{C.terminate()}catch{}C=null}if(n){!function(t,e){const n=t.payload,o={phase:e,type:t.type,name:"string"==typeof n.name?n.name:void 0,source:t.isCompile&&"string"==typeof n.source?n.source:void 0,args:"string"==typeof n.args?n.args:void 0,dispatchedAt:t.dispatchedAt??Date.now(),wallclockMs:void 0!==t.dispatchedAt?Date.now()-t.dispatchedAt:0,recycles:K};console.warn(`[compiler] watchdog killed "${o.name??o.type}" after ${Math.round(o.wallclockMs/1e3)}s (${e}); worker recycled (#${K}).`)}(n,t);const o=new Error(e);o.watchdogKill=!0,n.reject(o)}const o=T.splice(0,T.length);for(const r of G)try{r()}catch{}T.push(...o),A(),B()}function B(){if(null!==I)return;const t=T.shift();if(!t)return;I=t,t.dispatchedAt=Date.now();const e=t.isCompile?2e4:3e4;V=setTimeout(()=>{q("dispatch",`compiler worker did not ${"begin"==(t.isCompile?"begin":"reply")?"accept":"answer"} "${t.type}" within ${e/1e3}s — worker restarted automatically; queued jobs continue.`)},e),function(){if(!C)throw new Error("No Faust compiler here — a player plays the modules the IDE compiled and compiles nothing.");return C}().postMessage({id:t.id,type:t.type,payload:t.payload})}function R(t,e={},n){const o=n??O++;return new Promise((n,r)=>{T.push({id:o,type:t,payload:e,isCompile:U.has(t),resolve:n,reject:r}),B()})}function z(t){const e=new ArrayBuffer(t.byteLength);return new Uint8Array(e).set(t),e}var H=new WeakMap;function Q(t){return H.get(t)}async function X(t,e,n,o=!1){x+=1;const r=Date.now(),s=O++;P.set(s,{id:s,startedAt:r,name:`${e} (poly)`,sourceBytes:t.length,state:"queued"}),A();const i=performance.now();let a,l=!1,c=!1,p=!1;try{const r=null!==w?await async function(t,e,n,o){if(null===w)return null;const r=g?g():"",{bundledLibrariesMaterial:s}=await f(async()=>{const{bundledLibrariesMaterial:t}=await(import("./bundledSources-2GoXdU5z.js"));return{bundledLibrariesMaterial:t}},__vite__mapDeps([0,1]),import.meta.url),i=[b,k,t,n,o,r,s(),e].join("\0");return u(i)}("poly",t,e,n):null;if(r){const t=await _(r);if(t)try{const e=await async function(t){return{cfactory:0,module:await WebAssembly.compile(z(t.code)),code:new Uint8Array(0),json:t.json,shaKey:t.shaKey,poly:t.poly,soundfiles:{}}}(t);return o&&(e.code=t.code),l=!0,p=!0,E+=1,F+=1,H.set(e,r),{voiceFactory:e}}catch(h){console.warn(`[compiler] corrupt poly cache entry for "${e}" — recompiling.`,h)}}const i=await R("compilePoly",{source:t,name:e,args:n},s);if(!i)return l=!1,null;l=!0,E+=1,r&&i.voiceFactory.code instanceof Uint8Array&&i.voiceFactory.code.length>0&&function(t,e){if(null!==w){y.add(t);try{const n=w.put(t,e);if(n instanceof Promise){const t=n.catch(()=>{}).finally(()=>j.delete(t));j.add(t)}}catch{}}}(r,{code:i.voiceFactory.code,json:i.voiceFactory.json,shaKey:i.voiceFactory.shaKey,poly:i.voiceFactory.poly});const a={cfactory:0,module:i.voiceFactory.module,code:o?i.voiceFactory.code:new Uint8Array(0),json:i.voiceFactory.json,shaKey:i.voiceFactory.shaKey,poly:i.voiceFactory.poly,soundfiles:{}};return r&&H.set(a,r),{voiceFactory:a}}catch(m){throw a=m instanceof Error?m.message:String(m),c=!0===m?.watchdogKill,m}finally{x-=1;const n=P.get(s);P.delete(s),S=performance.now()-i;const o=void 0!==n?.processingStartedAt?Date.now()-n.processingStartedAt:void 0;l||c||function(t,e,n,o,r){if(o<1e4)return;Date.now(),console.warn(`[compiler] slow compile FAILURE "${t}" after ${Math.round(o/1e3)}s: ${r??"null factory"} — diagnostic dump captured.`)}(`${e} (poly)`,0,0,S,a),d={id:s,startedAt:r,durationMs:S,processingDurationMs:o,ok:l,error:a,sourceBytes:t.length,name:`${e} (poly)`,cached:p||void 0},M.push(d),M.length>50&&M.shift(),A()}var d}async function Y(t,e){await R("fsWrite",{path:t,content:e})}var Z,tt=new Map;Z=()=>{for(const[t,e]of tt)Y(`${d}/${t}`,e)},G.push(Z),g=()=>JSON.stringify([...tt.entries()].sort(([t],[e])=>t<e?-1:t>e?1:0));var et=new Set;async function nt(t,e){if(!t.endsWith(".lib"))throw new Error(`mountLibrary: name must end with .lib (got "${t}")`);if(t.includes("/")||t.includes("\\"))throw new Error(`mountLibrary: name must not contain path separators (got "${t}")`);tt.set(t,e),await Y(function(t){return`${d}/${t}`}(t),e),function(t){for(const e of et)try{e(t)}catch{}}({type:"mounted",name:t})}var ot=0,rt=null;function st(){ot+=1;let t=!1;return()=>{t||(t=!0,ot-=1,function(){if(null!==rt)return;rt=setTimeout(()=>{rt=null,ot>0||async function(){try{await async function(){await R("prune")}()}catch{}}()},1500)}())}}function it(e,n){const o=n=>e.isPolyphonic&&t(n);return{setParam:(t,n,o)=>e.setParamValue(t,n,o),getDescriptor:t=>e.getParamMeta(t)??null,...n,restorable:t=>!o(t),voiceControlled:o,transportFed:t=>e.getTransportFed().includes(t),getValue:t=>{const n=e.getParamValue(t);return null===n||Number.isNaN(n)?null:n},listPaths:()=>e.getModulatableParams()}}function at(t,e,n,o=!1){return u(`fwseal1\0${o?"parts\0":""}${t}\0${e??""}\0${n}`)}var lt=new Map;var ct=null;function ut(t){ct=new Map(Object.entries(t))}function pt(){return null!==ct}var ft=t=>`fw_patch = environment {\n${t}\n};\n`;function dt(t){return`${ft(t)}process = fw_patch.process;`}var ht=(t,e)=>t instanceof Error?t.message:t?String(t):e;async function mt(t,e,n,o=!1){let r,s;try{const o=await X(function(t){return`${ft(t)}process = fw_patch.effect;`}(e),t,n);if(!o)return{effectError:"libfaust returned null"};({inputs:r,outputs:s}=JSON.parse(o.voiceFactory.json))}catch(c){return{effectError:ht(c,"libfaust returned null")}}const i=function(t,e){const n=t=>1===t||2===t;return n(t)&&n(e)?null:`an effect takes and gives 1 or 2 channels — this one takes ${t} and gives ${e}`}(r,s);if(i)return{effectError:i};const a=function(t,e,n){const o=2===e||2===n,r=2===e?"_ <: _, _":o?"_, 0":"_",s=t=>1===t?"_":1===e?"+":"_, _";return{voice:`${ft(t)}toEffect(1) = ${r};\ntoEffect(2) = _, _;\nprocess = fw_patch.process : toEffect(outputs(fw_patch.process));\n`,effect:`${ft(t)}fromVoice(1) = ${s(o?2:1)};\nfromVoice(2) = ${s(2)};\nprocess = fromVoice(outputs(fw_patch.process)) : fw_patch.effect : ${1===n?"_, 0":"_, _"};\n`}}(e,r,s);let l;try{l=await X(a.voice,t,n,o)}catch(c){return{voiceError:(/pattern matching failed/.test(ht(c,""))?await X(dt(e),t,n).then(t=>t?function(t){return 1===t||2===t?null:`a voice with an effect has 1 or 2 outputs — this one has ${t} (its process)`}(JSON.parse(t.voiceFactory.json).outputs):null).catch(()=>null):null)??ht(c,"Polyphonic compilation failed (libfaust returned null)")}}if(!l)return{voiceError:"Polyphonic compilation failed (libfaust returned null)"};try{const e=await X(a.effect,t,`${n} -inpl`,o);return e?{voice:l,effect:e.voiceFactory}:{effectError:"libfaust returned null"}}catch(c){return{effectError:ht(c,"libfaust returned null")}}}var wt="-ftz 2 -double";async function yt(t,e){const n=await X(e,t,wt,!0);if(!n)throw new Error("Compilation failed (libfaust returned null)");return{code:n.voiceFactory.code,json:n.voiceFactory.json,key:Q(n.voiceFactory)}}var gt=t=>[...new Set(n(JSON.parse(t)).flatMap(t=>t.names))];async function vt(t,e,o,r=async()=>({}),i={}){i.anyChannel&&(e=(t=>c(t,"midichannel",null))(e)),i.meters&&(e=function(t,e){const n=a(t),o=null!==e?n?"fw_patch.effect":null:"fw_patch.process",r=['import("stdfaust.lib");',`fw_patch = environment {\n${t}\n};`,'\nfwm_db01(x) = x : ba.linear2db : max(-60) : +(60) : /(60);\nfwm_env(x) = x : an.amp_follower_ar(0.005, 0.2);\nfwm_level(x) = x : fwm_env : fwm_db01 : hbargraph("fwmeter level [hidden:1]", 0, 1);\nfwm_low(x) = x : fi.lowpass(2, 200) : fwm_env : fwm_db01 : hbargraph("fwmeter low [hidden:1]", 0, 1);\nfwm_mid(x) = x : fi.bandpass(2, 200, 2000) : fwm_env : fwm_db01 : hbargraph("fwmeter mid [hidden:1]", 0, 1);\nfwm_high(x) = x : fi.highpass(2, 2000) : fwm_env : fwm_db01 : hbargraph("fwmeter high [hidden:1]", 0, 1);\nfwm_onset(x) = (fast > slow * 1.6 + 0.005) : ba.peakholder(ma.SR * 0.08) : hbargraph("fwmeter onset [hidden:1]", 0, 1)\nwith {\n fast = x : an.amp_follower_ar(0.001, 0.03);\n slow = x : an.amp_follower_ar(0.05, 0.4);\n};\nfwm_tap(x, s) = attach(attach(attach(attach(attach(s, fwm_level(x)), fwm_low(x)), fwm_mid(x)), fwm_high(x)), fwm_onset(x));\nfwm_on(1) = _ <: fwm_tap;\nfwm_two(l, r) = fwm_tap((l + r) * 0.5, l), r;\nfwm_on(n) = fwm_two, si.bus(n - 2);\n',null!==e?"process = fw_patch.process;":`process = ${o} : fwm_on(outputs(${o}));`];return null!==e&&r.push(o?`effect = ${o} : fwm_on(outputs(${o}));`:"effect = fwm_on(outputs(fw_patch.process));"),r.join("\n")}(e,o));const l=[];let p=null,f=null;if(pt())({faust:p,effect:f}=await async function(t,e,n){const o=ct?.get(await at(t,n,await u(e),!0));if(!o||"parts"!==o.kind)throw new Error(`"${t}" is not in this player as it stands — export the project again.`);const r=async e=>{const n=await _(e);if(!n)throw new Error(`"${t}": a compiled module is missing from this player — export the project again.`);return{code:n.code,json:n.json}},[s,i]=await Promise.all([r(o.faust),r(o.effect)]);return{faust:s,effect:i}}(t,e,o));else if(null!==o&&a(e)){const n=await mt(t,e,wt,!0);if("voiceError"in n)throw new Error(n.voiceError);"effectError"in n?l.push(`its effect did not compile — the plugin plays without it, as the IDE does: ${n.effectError}`):(p={code:n.voice.voiceFactory.code,json:n.voice.voiceFactory.json,key:Q(n.voice.voiceFactory)},f={code:n.effect.code,json:n.effect.json,key:Q(n.effect)})}if(p??=await yt(t,e),!f){const t=JSON.parse(p.json).outputs;f=await yt("through",`process = ${Array(Math.max(t,1)).fill("_").join(",")};`)}for(const n of[p,f])if(!n.code.length)throw new Error("the compiler kept no module bytes");pt()||i.meters||i.anyChannel||!p.key||!f.key||async function(t,e,n,o){const r=await u(e);lt.set(await at(t,n,r,"parts"===o.kind),{name:t,voices:n,sourceSha:r,source:e,patch:o})}(t,e,o,{kind:"parts",faust:p.key,effect:f.key});const d=[],h={},m=gt(p.json);if(m.length){const t=await r(m),e=m.filter(e=>!t[e]);e.length&&d.push(`its samples ${e.join(", ")} do not read`);for(const n of m)t[n]&&(h[n]=s(t[n]))}const w=n(JSON.parse(f.json)).map(t=>t.label);return w.length&&d.push(`its effect plays samples (${w.join(", ")}) — faustwasm writes every soundfile into the voices' DSP alone (initSoundfileMemory), the effect's stays empty, in the IDE as in a plugin`),{faust:{code:p.code,json:p.json},effect:{code:f.code,json:f.json},voices:o,sounds:h,problems:d,hints:l}}async function bt(t){const e=pt()?()=>{}:st();try{const e=await vt(t.name,t.source,t.voices??null),n=JSON.parse(e.faust.json),o=e.hints.find(t=>t.startsWith("its effect did not compile"))??null,r=a(t.source)&&null===o,s=function(t,e,n,o){const r=JSON.parse(t).ui;return null===n?r:o?[{type:"tgroup",label:"Sequencer",items:[{type:"vgroup",label:"Instrument",items:r},{type:"vgroup",label:"Effect",items:JSON.parse(e).ui}]}]:[{type:"tgroup",label:"Polyphonic",items:[{type:"vgroup",label:"Voices",items:r}]}]}(e.faust.json,e.effect.json,e.voices,r);return{poly:null!==e.voices,warning:o,soundfileUrls:gt(e.faust.json),inputs:"number"==typeof n.inputs&&n.inputs>0?n.inputs:0,ui:m(s),descriptor:s}}finally{e()}}var kt=null;function _t(t){kt=t}async function jt(t,e){const n=kt;if(!n)throw new Error("No engine plays the project.");const o=await bt({name:e.name,source:e.source}),r=await vt(e.name,e.source,null,e.soundfiles);if(r.problems.length)throw new Error(r.problems.join("; "));return n({ctx:t,owner:e.owner,label:e.label,parts:r,ui:o.ui,descriptor:o.descriptor,poly:o.poly})}var $t=class{owner;label;constructor(t,e){this.owner=t,this.label=e}compiled=null;named=null;worklet=null;compiledKey=null;parked=null;connectedTo=null;runningKey=null;runningCompiled=null;poly=!1;params=new Set;inputNode=null;outputListener=null;valueListener=null;generation=0;latest=null;async compile(t,e,n){const o=++this.generation;this.compiled=null,this.poly=!1;const r=(async()=>{try{const r=await bt({name:e,source:t,voices:n?.voices});return o!==this.generation||(this.compiled=r,this.compiledKey=`${e}\n${n?.voices??0}\n${t}`,this.parked&&this.parked.compiled!==this.compiledKey&&this.letParkedGo(),this.poly=r.poly,this.named={ui:r.ui,descriptor:r.descriptor}),{ok:!0,warning:r.warning}}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}})();this.latest=r;const s=await r;return o===this.generation?s:this.latest}get hasCompiled(){return null!==this.compiled}get running(){return null!==this.worklet}get cost(){return this.worklet?.cost??null}get isPolyphonic(){return this.poly}async startOn(t,e){if(this.worklet)return!1;if(!this.compiled)throw new Error("No compiled patch — call compile() first");const n=t.context;let o;const r=await(e.partsKey?.())??"";if(this.worklet)return!1;const s=this.compiled;if(!s)throw new Error("No compiled patch — call compile() first");const i=this.compiledKey,a=`${i}\n${r}`,l=this.parked;if(l&&l.key===a&&l.worklet.output.context===n)this.parked=null,o=l.worklet,o.reset(),o.processing(!0);else{this.letParkedGo();const t=kt;if(!t)throw new Error("No engine plays the project.");const r=await e.pluginParts();if(r.problems.length)throw new Error(r.problems.join("; "));if(this.worklet)return!1;if(o=await t({ctx:n,owner:this.owner(),label:this.label,parts:r,ui:s.ui,descriptor:s.descriptor,poly:s.poly}),this.worklet)return o.dispose(),!1}if(this.worklet=o,this.connectedTo=t,this.runningKey=a,this.runningCompiled=i,this.params=new Set(o.params),this.started(),e.beforeConnect?.(),o.output.connect(t),o.onOutput((t,e)=>this.outputListener?.(t,e)),o.onValues(t=>this.valueListener?.(t)),o.input&&e.getInput)try{const t=await e.getInput(o.inputChannels);if(this.worklet!==o)return!1;t.connect(o.input),this.inputNode=t}catch(c){e.warn?.("Patch expects audio input but getInput() rejected:",c,"— running with silent input.")}return"suspended"===n.state&&await n.resume(),!0}started(){}async stop(){if(this.inputNode&&this.worklet)try{this.worklet.input&&this.inputNode.disconnect(this.worklet.input)}catch{}if(this.inputNode=null,!this.worklet)return;const t=this.worklet;t.processing(!1);try{this.connectedTo&&t.output.disconnect(this.connectedTo)}catch{}t.onOutput(null),t.onValues(null),this.letParkedGo(),this.runningKey&&this.runningCompiled&&this.runningCompiled===this.compiledKey?this.parked={worklet:t,key:this.runningKey,compiled:this.runningCompiled}:t.dispose(),this.worklet=null,this.connectedTo=null,this.runningKey=null,this.runningCompiled=null,this.params.clear(),this.started(),this.valueListener?.(new Map)}letParkedGo(){this.parked?.worklet.dispose(),this.parked=null}listenToOutputs(t){this.outputListener=t}onValueUpdate(t){this.valueListener=t}get walked(){return this.worklet?.ui??this.named?.ui??null}getModulationOutputs(){return this.walked?.modOutputs??[]}getTransportFed(){return this.walked?.transportFed??[]}getModulatableParams(){return[...this.walked?.paramMeta.keys()??[]]}getParamMeta(t){return this.walked?.paramMeta.get(t)??null}valueAt(t){return this.worklet?.get(t)??void 0}sendMidi(t,e){this.worklet?.midi(t,e)}allNotesOff(){this.worklet&&this.poly&&this.worklet.allNotesOff()}getUI(){return this.worklet?.descriptor??this.named?.descriptor??null}getInputChannelCount(){return this.compiled?.inputs??0}async dispose(){await this.stop(),this.letParkedGo(),this.named=null,this.compiled=null,this.compiledKey=null}};export{ut as a,nt as c,vt as i,v as l,jt as n,pt as o,_t as r,it as s,$t as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as s,r as a,t as r}from"./errors-BdUU2zPt.js";import{a as o,i as t,n as m,r as i,t as p}from"./fileRef-BmnWhXuY.js";import{a as f,c as n,i as j,l as e,n as c,o as l,r as u,s as w,t as d}from"./paths-DFjX1bFA.js";import{Nn as h,n as y,t as A}from"./src-DyDfRe65.js";import{f as F,p as R}from"./actionRegistry-hOkUYNvI.js";import{a as b,c as g,i as v,n as x,o as I,r as M,s as N,t as S}from"./faustSource-Blr9zzKL.js";import{n as _,t as k}from"./transportFollow-Ox91SKLF.js";import{a as q,i as z,n as B,o as C,r as D,s as E,t as G}from"./notes-D-zF5qJ1.js";import{t as H}from"./newId-DuoSrkVn.js";import{t as J}from"./sha256-B9lHpAF4.js";import{_ as K,v as L}from"./runtime-vj8wKnnG.js";import{t as O}from"./fileMirror-CkgB9zNS.js";import{a as P,i as Q,n as T,o as U,r as V,s as W,t as X}from"./projectFiles-BEdLy3nE.js";import{n as Y}from"./preArm-ifXM2Buj.js";import{n as Z}from"./panic-ckha9YOX.js";import{t as $}from"./runtime-36oA_YiG.js";import{n as ss,t as as}from"./playerApp-BmyTSXxw.js";export{h as kbPatchUri};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e,t){return`${e}/${t}`}var t=Array.isArray,n=Array.prototype.indexOf,r=Array.prototype.includes,s=Array.from,l=Object.keys,i=Object.defineProperty,o=Object.getOwnPropertyDescriptor,f=Object.getOwnPropertyDescriptors,u=Object.prototype,a=Array.prototype,c=Object.getPrototypeOf,d=Object.isExtensible;function v(e){return"function"==typeof e}var h=()=>{};function p(e){return e()}function y(e){for(var t=0;t<e.length;t++)e[t]()}function _(){var e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function g(e,t){if(Array.isArray(e))return e;if(void 0===t||!(Symbol.iterator in e))return Array.from(e);const n=[];for(const r of e)if(n.push(r),n.length===t)break;return n}var w=1024,b=2048,m=4096,k=8192,x=16384,S=32768,E=1<<25,j=65536,O=1<<19,P=1<<25,T=1<<21,A=1<<23,M=Symbol("$state"),q=Symbol("component"),N=Symbol("legacy props"),D=Symbol(""),C=Symbol("proxy path"),R=Symbol("attributes"),z=Symbol("class"),$=Symbol("style"),I=Symbol("text"),V=Symbol("form reset"),J=Symbol("hmr anchor"),K=new class extends Error{name="StaleReactionError";message="The reaction that called `getAbortSignal()` was re-run or destroyed"},B=!!globalThis.document?.contentType&&globalThis.document.contentType.includes("xml");function F(e){return e===this.v}function L(e,t){return e!=e?t==t:e!==t||null!==e&&"object"==typeof e||"function"==typeof e}function G(e){return!L(e,this.v)}function H(e){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function Q(e,t,n){throw new Error("https://svelte.dev/e/each_key_duplicate")}function U(e,t,n){throw new Error("https://svelte.dev/e/each_key_volatile")}function W(){throw new Error("https://svelte.dev/e/hydration_failed")}function X(){throw new Error("https://svelte.dev/e/invalid_snippet")}function Y(e){throw new Error("https://svelte.dev/e/props_invalid_value")}function Z(e){throw new Error("https://svelte.dev/e/props_rest_readonly")}function ee(e){throw new Error("https://svelte.dev/e/rune_outside_svelte")}function te(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}var ne=!1,re=!1;function se(){re=!0}var le={},ie=Symbol("uninitialized"),oe=Symbol("filename"),fe="http://www.w3.org/1999/xhtml",ue="http://www.w3.org/2000/svg",ae="@attach";var ce=[];function de(e,t=!1,n=!1){return ve(e,new Map,"",ce,null,n)}function ve(e,n,r,s,l=null,i=!1){if("object"==typeof e&&null!==e){var o=n.get(e);if(void 0!==o)return o;if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);if(t(e)){var f=Array(e.length);n.set(e,f),null!==l&&n.set(l,f);for(var a=0;a<e.length;a+=1){var d=e[a];a in e&&(f[a]=ve(d,n,r,s,null,i))}return f}if(c(e)===u){for(var v of(f={},n.set(e,f),null!==l&&n.set(l,f),Object.keys(e)))f[v]=ve(e[v],n,r,s,null,i);return f}if(e instanceof Date)return e.getTime(),structuredClone(e);if("function"==typeof e.toJSON&&!i)return ve(e.toJSON(),n,r,s,e)}if(e instanceof EventTarget)return e;try{return structuredClone(e)}catch(h){return e}}function he(e,t){return e.label=t,pe(e.v,t),e}function pe(e,t){return e?.[C]?.(t),e}function ye(e){return"symbol"==typeof e?`Symbol(${e.description})`:"function"==typeof e?"<function>":"object"==typeof e&&e?"<object>":String(e)}var _e=null;function ge(e){_e=e}var we=null;function be(e){return(t=_e,null===t&&H(),t.c??=new Map(function(e){let t=e.p;for(;null!==t&&null===t.c;)t=t.p;return t?.c??null}(t)||void 0)).get(e);var t}function me(e,t=!1,n){_e={p:_e,i:!1,c:null,e:null,s:e,x:null,r:wn,l:re&&!t?{s:null,u:null,$:[]}:null}}function ke(e){var t=_e,n=t.e;if(null!==n)for(var r of(t.e=null,n))Wn(r);return void 0!==e&&(t.x=e),t.i=!0,_e=t.p,xe(e)}function xe(e={}){return i(e,q,{value:!0}),e}function Se(){return!re||null!==_e&&null===_e.l}var Ee=[];function je(){var e=Ee;Ee=[],y(e)}function Oe(e){if(0===Ee.length&&!Rt){var t=Ee;queueMicrotask(()=>{t===Ee&&je()})}Ee.push(e)}function Pe(){for(;Ee.length>0;)je()}function Te(e,t,n){console.warn("https://svelte.dev/e/hydration_attribute_changed")}function Ae(e){console.warn("https://svelte.dev/e/hydration_mismatch")}function Me(){console.warn("https://svelte.dev/e/lifecycle_double_unmount")}function qe(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function Ne(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}var De,Ce=!1;function Re(e){Ce=e}function ze(e){if(null===e)throw Ae(),le;return De=e}function $e(){return ze(Ze(De))}function Ie(e){if(Ce){if(null!==Ze(De))throw Ae(),le;De=e}}function Ve(e=1){if(Ce){for(var t=e,n=De;t--;)n=Ze(n);De=n}}function Je(e=!0){for(var t=0,n=De;;){if(8===n.nodeType){var r=n.data;if("]"===r){if(0===t)return n;t-=1}else("["===r||"[!"===r||"["===r[0]&&!isNaN(Number(r.slice(1))))&&(t+=1)}var s=Ze(n);e&&n.remove(),n=s}}function Ke(e){if(!e||8!==e.nodeType)throw Ae(),le;return e.data}function Be(e){if("object"!=typeof e||null===e||M in e||q in e)return e;const n=c(e);if(n!==u&&n!==a)return e;var r=new Map,s=t(e),l=nn(0),i=null,f=Pn,d=e=>{if(Pn===f)return e();var t=yn,n=Pn;gn(null),Tn(f);var r=e();return gn(t),Tn(n),r};s&&r.set("length",nn(e.length,i));return new Proxy(e,{defineProperty(e,t,n){"value"in n&&!1!==n.configurable&&!1!==n.enumerable&&!1!==n.writable||function(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}();var s=r.get(t);return void 0===s?d(()=>{var e=nn(n.value,i);return r.set(t,e),e}):sn(s,n.value,!0),!0},deleteProperty(e,t){var n=r.get(t);if(void 0===n){if(t in e){const e=d(()=>nn(ie,i));r.set(t,e),cn(l)}}else sn(n,ie),cn(l);return!0},get(t,n,s){if(n===M)return e;var l=r.get(n),f=n in t;if(void 0!==l||f&&!o(t,n)?.writable||(l=d(()=>{var e=nn(Be(f?t[n]:ie),i);return e}),r.set(n,l)),void 0!==l){var u=In(l);return u===ie?void 0:u}return Reflect.get(t,n,s)},getOwnPropertyDescriptor(e,t){this.has?.(e,t);var n=Reflect.getOwnPropertyDescriptor(e,t),s=r.get(t);if(void 0!==s){var l=In(s);if(l===ie)return;if(!n||!("value"in n))return{enumerable:!0,configurable:!0,value:l,writable:!0};n.value=l}return n},has(e,t){if(t===M)return!0;var n=r.get(t),s=void 0!==n&&n.v!==ie||Reflect.has(e,t);return!!(void 0===n&&(null===wn&&null===yn||s&&!o(e,t)?.writable)||(void 0===n&&(n=d(()=>{var n=nn(s?Be(e[t]):ie,i);return n}),r.set(t,n)),In(n)!==ie))&&s},set(e,t,n,f){var u=r.get(t),a=t in e;if(s&&"length"===t)for(var c=n;c<u.v;c+=1){var v=r.get(c+"");void 0!==v?sn(v,ie):c in e&&(v=d(()=>nn(ie,i)),r.set(c+"",v))}void 0===u?a&&!o(e,t)?.writable||(sn(u=d(()=>nn(void 0,i)),Be(n)),r.set(t,u)):(a=u.v!==ie,sn(u,d(()=>Be(n))));var h=Reflect.getOwnPropertyDescriptor(e,t);if(h?.set&&h.set.call(f,n),!a){if(s&&"string"==typeof t){var p=r.get("length"),y=Number(t);Number.isInteger(y)&&y>=p.v&&sn(p,y+1)}cn(l)}return!0},ownKeys(e){In(l);var t=Reflect.ownKeys(e).filter(e=>{var t=r.get(e);return void 0===t||t.v!==ie});for(var[n,s]of r)s.v===ie||n in e||t.push(n);return t},setPrototypeOf(){!function(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}()}})}function Fe(e){try{if(null!==e&&"object"==typeof e&&M in e)return e[M]}catch{}return e}function Le(e,t){return Object.is(Fe(e),Fe(t))}var Ge,He,Qe,Ue;function We(){if(void 0===Ge){Ge=window,document,He=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;Qe=o(t,"firstChild").get,Ue=o(t,"nextSibling").get,d(e)&&(e[z]=void 0,e[R]=null,e[$]=void 0,e.__e=void 0),d(n)&&(n[I]=void 0)}}function Xe(e=""){return document.createTextNode(e)}function Ye(e){return Qe.call(e)}function Ze(e){return Ue.call(e)}function et(e,t){if(!Ce)return Ye(e);var n=Ye(De);if(null===n)n=De.appendChild(Xe());else if(t&&3!==n.nodeType){var r=Xe();return n?.before(r),ze(r),r}return t&&ot(n),ze(n),n}function tt(e,t=!1){if(!Ce){var n=Ye(e);return n instanceof Comment&&""===n.data?Ze(n):n}if(t){if(3!==De?.nodeType){var r=Xe();return De?.before(r),ze(r),r}ot(De)}return De}function nt(e,t=!1){if(!Ce)return Ye(e);var n=et(e,t);return Ie(e),n}function rt(e,t=1,n=!1){let r=Ce?De:e;for(var s;t--;)s=r,r=Ze(r);if(!Ce)return r;if(n){if(3!==r?.nodeType){var l=Xe();return null===r?s?.after(l):r.before(l),ze(l),l}ot(r)}return ze(r),r}function st(e){e.textContent=""}function lt(){return!1}function it(e,t,n){return null==t||"http://www.w3.org/1999/xhtml"===t?n?document.createElement(e,{is:n}):document.createElement(e):n?document.createElementNS(t,e,{is:n}):document.createElementNS(t,e)}function ot(e){if(e.nodeValue.length<65536)return;let t=e.nextSibling;for(;null!==t&&3===t.nodeType;)t.remove(),e.nodeValue+=t.nodeValue,t=e.nextSibling}function ft(e){var t=wn;if(null===t)return yn.f|=A,e;if(!(32768&t.f||4&t.f))throw e;ut(e,t)}function ut(e,t){if(e===le)throw e;if(!(null!==t&&16384&t.f)){for(;null!==t;){if(128&t.f&&!(33570816&t.f)){if(!(32768&t.f))throw e;try{return void t.b.error(e)}catch(n){e=n}}t=t.parent}throw e}}var at=-7169;function ct(e,t){e.f=e.f&at|t}function dt(e){512&e.f||null===e.deps?ct(e,w):ct(e,m)}function vt(e,t){2048&e.f?t.set(e,b):4096&e.f&&2048!==t.get(e)&&t.set(e,m),ct(e,w)}function ht(e,t){if(t){const t=document.body;e.autofocus=!0,Oe(()=>{document.activeElement===t&&e.focus()})}}var pt=!1;function yt(){pt||(pt=!0,document.addEventListener("reset",e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(const t of e.target.elements)t[V]?.()})},{capture:!0}))}function _t(e){var t=yn,n=wn;gn(null),bn(null);try{return e()}finally{gn(t),bn(n)}}function gt(e,t,n,r){const s=Se()?mt:Et;var l=e.filter(e=>!e.settled),i=t.map(s);if(0!==n.length||0!==l.length){var o=wn,f=function(){var e=wn,t=yn,n=_e,r=qt;return function(s=!0){bn(e),gn(t),ge(n),!s||16384&e.f||(r?.activate(),r?.apply())}}(),u=1===l.length?l[0].promise:l.length>1?Promise.all(l.map(e=>e.promise)):null,a=bt();0!==n.length?u?u.then(()=>{16384&o.f?a():(f(),d(),wt())}):d():u.then(()=>c([])).finally(a)}else r(i);function c(e){if(!(16384&o.f)){f();try{r([...i,...e])}catch(t){ut(t,o)}wt()}}function d(){Promise.all(n.map(e=>xt(e))).then(c).catch(e=>ut(e,o)).finally(a)}}function wt(e=!0){bn(null),gn(null),ge(null),e&&qt?.deactivate()}function bt(){var e=wn,t=e.b,n=qt,r=!!t?.is_rendered();return t?.update_pending_count(1,n),n.increment(r,e),()=>{t?.update_pending_count(-1,n),n.decrement(r,e)}}function mt(e){null!==wn&&(wn.f|=O);const t={ctx:_e,deps:null,effects:null,equals:F,f:2050,fn:e,reactions:null,rv:0,v:ie,wv:0,parent:wn,ac:null};return t}var kt=Symbol("obsolete");function xt(e,t,n){let r=wn;null===r&&function(){throw new Error("https://svelte.dev/e/async_derived_orphan")}();var s=void 0,l=tn(ie);var i=!yn,o=new Set;return function(e){Gn(4718592,e)}(()=>{var t=wn;var n=_();s=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==K&&n.reject(e)}).finally(wt)}catch(c){n.reject(c),wt()}var f=qt;if(i){if(32768&t.f)var u=bt();if(r.b?.is_rendered())f.async_deriveds.get(t)?.reject(kt);else for(const e of o.values())e.reject(kt);o.add(n),f.async_deriveds.set(t,n)}const a=(e,t=void 0)=>{u?.(),o.delete(n),t!==kt&&(f.activate(),t?(l.f|=A,fn(l,t)):(8388608&l.f&&(l.f^=A),fn(l,e)),f.deactivate())};n.promise.then(a,e=>a(null,e||"unknown"))}),Qn(()=>{for(const e of o)e.reject(kt)}),new Promise(e=>{!function t(n){function r(){n===s?e(l):t(s)}n.then(r,r)}(s)})}function St(e){const t=mt(e);return kn(t),t}function Et(e){const t=mt(e);return t.equals=G,t}function jt(e){var t=e.effects;if(null!==t){e.effects=null;for(var n=0;n<t.length;n+=1)fr(t[n])}}function Ot(e){var t,n=wn,r=e.parent;if(!hn&&null!==r&&e.v!==ie&&24576&r.f)return console.warn("https://svelte.dev/e/derived_inert"),e.v;bn(r);try{jt(e),t=Nn(e)}finally{bn(n)}return t}function Pt(e){var t=Ot(e);e.equals(t)||(e.wv=An(),qt?.is_fork&&null!==e.deps||(null!==qt?(qt.capture(e,t,!0),Nt?.capture(e,t,!0)):e.v=t,null!==e.deps))?hn||(null!==Dt?(Hn()||qt?.is_fork)&&Dt.set(e,t):dt(e)):ct(e,w)}function Tt(e){if(null!==e.effects)for(const t of e.effects)t.teardown&&null!==t.fn&&zn(t)}var At=null,Mt=null,qt=null,Nt=null,Dt=null,Ct=null,Rt=!1,zt=!1,$t=null,It=null,Vt=0,Jt=1,Kt=class e{id=Jt++;started=!1;linked=!0;prev=null;next=null;async_deriveds=new Map;current=new Map;previous=new Map;#e=new Set;#t=new Set;#n=0;#r=new Map;#s=null;#l=[];#i=[];#o=new Map;#f=new Map;#u=new Set;is_fork=!1;#a=!1;constructor(){null===Mt?At=Mt=this:(Mt.next=this,this.prev=Mt),Mt=this}#c(){if(this.is_fork)return!0;for(const e of this.#r.keys())if(!this.#d(e))return!0;return!1}#d(e){for(var t=e;null!==t;t=t.parent)if(this.#f.has(t))return!0;return!1}skip_effect(e){this.#f.has(e)||this.#f.set(e,{d:[],m:[]}),this.#u.delete(e)}unskip_effect(e,t=e=>this.schedule(e)){var n=this.#f.get(e);if(n){for(var r of(this.#f.delete(e),n.d))ct(r,b),t(r);for(r of n.m)ct(r,m),t(r)}this.#u.add(e)}#v(){var e=[];for(const s of this.#l)if(!(16384&s.f)&&6144&s.f){for(var t=s,n=!1;null!==t.parent;){var r=(t=t.parent).f;if(96&r){if(!(1024&r)){n=!0;break}t.f^=w}}n||e.push(t)}return this.#l=[],e}#h(){this.started=!0;for(const[e,f]of this.#o)ct(e,f),this.schedule(e);this.apply();for(var t=$t=[],n=[],r=It=[];this.#l.length>0;){Vt++>1e3&&(this.#p(),Ft());for(const e of this.#v())try{this.#y(e,t,n)}catch(o){throw Xt(e),this.#c()||this.discard(),o}}if(qt=null,r.length>0){var s=e.ensure();for(const e of r)s.schedule(e)}if($t=null,It=null,this.#c()){this.#_(n),this.#_(t);for(const[e,t]of this.#f)Wt(e,t);return void(r.length>0&&qt.#h())}const l=this.#g();if(l)return this.#_(n),this.#_(t),void l.#w(this);this.#o.clear();for(const e of this.#e)e(this);this.#e.clear(),Nt=this,Gt(n),Gt(t),Nt=null,this.#s?.resolve();var i=qt;0!==this.#n||0!==this.#l.length&&null===i||this.#p(),null!==i&&(Zt.clear(),i.#h())}#y(e,t,n){e.f^=w;for(var r=e.first;null!==r;){var s=r.f,l=!!(96&s);if(!(l&&1024&s||8192&s||this.#f.has(r))&&null!==r.fn){l?r.f^=w:4&s?t.push(r):Mn(r)&&(16&s&&this.add_dirty_reaction(r,m),zn(r));var i=r.first;if(null!==i){r=i;continue}}for(;null!==r;){var o=r.next;if(null!==o){r=o;break}r=r.parent}}}#g(){for(var e=this.prev;null!==e;e=e.prev)if(!e.is_fork&&this.#b(e))return e;return null}#b(e){for(const[t,[,n]]of this.current)if(!n&&e.current.has(t))return!0;return!1}#w(e){for(const[n,r]of e.current)!this.previous.has(n)&&e.previous.has(n)&&this.previous.set(n,e.previous.get(n)),this.current.set(n,r);for(const[n,r]of e.async_deriveds){const e=this.async_deriveds.get(n);e&&r.promise.then(e.resolve).catch(e.reject)}e.async_deriveds.clear(),this.transfer_reactions(e.#o);const t=e=>{var n=e.reactions;if(null!==n&&(!(2&e.f)||6144&e.f))for(const l of n){var r=l.f;if(2&r)t(l);else{var s=l;4194320&r&&!this.async_deriveds.has(s)&&(this.#o.delete(s),ct(s,b),this.schedule(s))}}};for(const n of this.current.keys())t(n);this.oncommit(()=>e.discard()),e.#p(),qt=this,this.#h()}#_(e){for(var t=0;t<e.length;t+=1)vt(e[t],this.#o)}capture(e,t,n=!1){e.v===ie||this.previous.has(e)||this.previous.set(e,e.v),8388608&e.f||(this.current.set(e,[t,n]),Dt?.set(e,t)),this.is_fork||(e.v=t)}activate(){qt=this}deactivate(){qt=null,Dt=null}flush(){try{0,zt=!0,qt=this,this.#h()}finally{Vt=0,Ct=null,$t=null,It=null,zt=!1,qt=null,Dt=null,Zt.clear()}}discard(){for(const e of this.#t)e(this);this.#t.clear();for(const e of this.async_deriveds.values())e.reject(kt);this.#p(),this.#s?.resolve()}register_created_effect(e){this.#i.push(e)}#m(){for(let a=At;null!==a;a=a.next){var e=a.id<this.id,t=[];for(const[r,[s,l]]of this.current){if(a.current.has(r)){var n=a.current.get(r)[0];if(!e||s===n)continue;a.current.set(r,[s,l])}t.push(r)}if(e)for(const[e,t]of this.async_deriveds){const n=a.async_deriveds.get(e);n&&t.promise.then(n.resolve).catch(n.reject)}var r=[...a.current.keys()].filter(e=>!a.current.get(e)[1]);if(a.started&&0!==r.length){var s=r.filter(e=>!this.current.has(e));if(0===s.length)e&&a.discard();else if(t.length>0){if(e)for(const e of this.#u)a.unskip_effect(e,e=>{4194320&e.f?a.schedule(e):a.#_([e])});a.activate();var l=new Set,i=new Map;for(var o of t)Ht(o,s,l,i);i=new Map;var f=[...a.current].filter(([e,t])=>{const n=this.current.get(e);return!n||(n[0]!==t[0]||n[1]!==t[1])}).map(([e])=>e);if(f.length>0)for(const e of this.#i)155648&e.f||!Qt(e,f,i)||(4194320&e.f?(ct(e,b),a.schedule(e)):a.add_dirty_reaction(e,b));if(a.#l.length>0&&!a.#a)for(var u of(a.apply(),a.#v()))a.#y(u,[],[]);a.deactivate()}}}}increment(e,t){if(this.#n+=1,e){let e=this.#r.get(t)??0;this.#r.set(t,e+1)}}decrement(e,t){if(this.#n-=1,e){let e=this.#r.get(t)??0;1===e?this.#r.delete(t):this.#r.set(t,e-1)}this.#a||(this.#a=!0,Oe(()=>{this.#a=!1,this.linked&&this.flush()}))}transfer_reactions(e){for(const[t,n]of e)this.add_dirty_reaction(t,n);e.clear()}add_dirty_reaction(e,t){2048!==t&&2048===this.#o.get(e)||this.#o.set(e,t)}oncommit(e){this.#e.add(e)}ondiscard(e){this.#t.add(e)}settled(){return(this.#s??=_()).promise}static ensure(){if(null===qt){const t=qt=new e;zt||Rt||Oe(()=>{t.started||t.flush()})}return qt}apply(){Dt=null}schedule(e){Ct=e,!(e.b?.is_pending&&16777228&e.f)||32768&e.f?this.#l.push(e):e.b.defer_effect(e)}#p(){if(this.linked){var e=this.prev,t=this.next;null===e?At=t:e.next=t,null===t?Mt=e:t.prev=e,this.linked=!1}}};function Bt(e){var t=Rt,n=Nt;Nt=null,Rt=!0;try{var r;for(e&&(Bt(),r=e());;){if(Pe(),null===qt)return r;qt.flush()}}finally{Rt=t,Nt=n}}function Ft(){try{!function(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}()}catch(e){0,ut(e,Ct)}}var Lt=null;function Gt(e){var t=e.length;if(0!==t){for(var n=0;n<t;){var r=e[n++];if(!(24576&r.f)&&Mn(r)&&(Lt=new Set,zn(r),null===r.deps&&null===r.first&&null===r.nodes&&null===r.teardown&&null===r.ac&&ur(r),Lt?.size>0)){Zt.clear();for(const e of Lt){if(24576&e.f)continue;const t=[e];let n=e.parent;for(;null!==n;)Lt.has(n)&&(Lt.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){const n=t[e];24576&n.f||zn(n)}}Lt.clear()}}Lt=null}}function Ht(e,t,n,r){if(!n.has(e)&&(n.add(e),null!==e.reactions))for(const s of e.reactions){const e=s.f;2&e?Ht(s,t,n,r):4194320&e&&!(2048&e)&&Qt(s,t,r)&&(ct(s,b),Ut(s))}}function Qt(e,t,n){const s=n.get(e);if(void 0!==s)return s;if(null!==e.deps)for(const l of e.deps){if(r.call(t,l))return!0;if(2&l.f&&Qt(l,t,n))return n.set(l,!0),!0}return n.set(e,!1),!1}function Ut(e){qt.schedule(e)}function Wt(e,t){if(!(32&e.f&&1024&e.f)){2048&e.f?t.d.push(e):4096&e.f&&t.m.push(e),ct(e,w);for(var n=e.first;null!==n;)Wt(n,t),n=n.next}}function Xt(e){ct(e,w);for(var t=e.first;null!==t;)Xt(t),t=t.next}var Yt=new Set,Zt=new Map;var en=!1;function tn(e,t){var n={f:0,v:e,reactions:null,equals:F,rv:0,wv:0};return n}function nn(e,t){const n=tn(e);return kn(n),n}function rn(e,t=!1,n=!0){const r=tn(e);return t||(r.equals=G),re&&n&&null!==_e&&null!==_e.l&&(_e.l.s??=[]).push(r),r}function sn(e,t,n=!1){null!==yn&&(!_n||131072&yn.f)&&Se()&&4325394&yn.f&&(null===mn||!mn.has(e))&&function(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}();let r=n?Be(t):t;return fn(e,r,It)}var ln=null,on=0;function fn(e,t,n=null){if(!e.equals(t)){hn?Zt.set(e,t):Zt.has(e)||Zt.set(e,e.v);var r=Kt.ensure();if(r.capture(e,t),2&e.f){const t=e;2048&e.f&&Ot(t),null===Dt&&dt(t)}e.wv=An(),ln=null,on=0,dn(e,b,n),ln=null,Se()&&null!==wn&&1024&wn.f&&!(96&wn.f)&&(null===En?function(e){En=e}([e]):En.push(e)),!r.is_fork&&Yt.size>0&&!en&&un()}return t}function un(){en=!1;for(const e of Yt){let t;1024&e.f&&ct(e,m);try{t=Mn(e)}catch{t=!0}t&&zn(e)}Yt.clear()}function an(e,t=1){var n=In(e),r=1===t?n++:n--;return sn(e,n),r}function cn(e){sn(e,e.v+1)}function dn(e,t,n){var r=e.reactions;if(null!==r){var s=Se(),l=r.length;if((on+=l)>1e5&&null===ln&&(ln=new Set),null!==ln){if(ln.has(e))return;ln.add(e)}for(var i=0;i<l;i++){var o=r[i],f=o.f;if(s||o!==wn){var u=0===(f&b);if(u&&ct(o,t),131072&f)Yt.add(o);else if(2&f){var a=o;Dt?.delete(a),dn(a,m,n)}else if(u){var c=o;16&f&&null!==Lt&&Lt.add(c),null!==n?n.push(c):Ut(c)}}}}}var vn=null,hn=!1;function pn(e){hn=e}var yn=null,_n=!1;function gn(e){yn=e}var wn=null;function bn(e){wn=e}var mn=null;function kn(e){null!==yn&&(2097152&yn.f||2&yn.f)&&(mn??=new Set).add(e)}var xn=null,Sn=0,En=null;var jn=1,On=0,Pn=On;function Tn(e){Pn=e}function An(){return++jn}function Mn(e){var t=e.f;if(2048&t)return!0;if(4096&t){for(var n=e.deps,r=n.length,s=0;s<r;s++){var l=n[s];if(Mn(l)&&Pt(l),l.wv>e.wv)return!0}512&t&&null===Dt&&ct(e,w)}return!1}function qn(e,t,n=!0){var r=e.reactions;if(null!==r&&(null===mn||!mn.has(e)))for(var s=0;s<r.length;s++){var l=r[s];2&l.f?qn(l,t,!1):t===l&&(n?ct(l,b):1024&l.f&&ct(l,m),Ut(l))}}function Nn(e){var t=xn,n=Sn,r=En,s=yn,l=mn,i=_e,o=_n,f=Pn,u=e.f;xn=null,Sn=0,En=null,yn=96&u?null:e,mn=null,ge(e.ctx),_n=!1,Pn=++On,null!==e.ac&&(_t(()=>{e.ac.abort(K)}),e.ac=null);try{e.f|=T;var a=(0,e.fn)();e.f|=S;var c=Dn(e);if(Se()&&null!==En&&!_n&&null!==c&&!(6146&e.f))for(var d=0;d<En.length;d++)qn(En[d],e);if(null!==s&&s!==e){if(On++,null!==s.deps)for(let e=0;e<n;e+=1)s.deps[e].rv=On;if(null!==t)for(const e of t)e.rv=On;null!==En&&(null===r?r=En:r.push(...En))}return 8388608&e.f&&(e.f^=A),a}catch(v){return Dn(e),ft(v)}finally{e.f^=T,xn=t,Sn=n,En=r,yn=s,mn=l,ge(i),_n=o,Pn=f}}function Dn(e){var t=e.deps,n=qt?.is_fork;if(null!==xn){var r;if(n||Rn(e,Sn),null!==t&&Sn>0)for(t.length=Sn+xn.length,r=0;r<xn.length;r++)t[Sn+r]=xn[r];else e.deps=t=xn;if(Hn()&&512&e.f)for(r=Sn;r<t.length;r++)(t[r].reactions??=[]).push(e)}else!n&&null!==t&&Sn<t.length&&(Rn(e,Sn),t.length=Sn);return t}function Cn(e,t){let s=t.reactions;if(null!==s){var l=n.call(s,e);if(-1!==l){var i=s.length-1;0===i?s=t.reactions=null:(s[l]=s[i],s.pop())}}if(null===s&&2&t.f&&(null===xn||!r.call(xn,t))){var o=t;512&o.f&&(o.f^=512),o.v!==ie&&dt(o),null!==o.ac&&_t(()=>{o.ac.abort(K),o.ac=null,ct(o,b)}),function(e){if(null!==e.effects)for(const t of e.effects)(t.teardown||t.ac)&&(t.teardown?.(),null!==t.ac&&_t(()=>{t.ac.abort(K),t.ac=null}),null!==t.fn&&(t.teardown=h),Rn(t,0),or(t))}(o),Rn(o,0)}}function Rn(e,t){var n=e.deps;if(null!==n)for(var r=t;r<n.length;r++)Cn(e,n[r])}function zn(e){var t=e.f;if(!(16384&t)){ct(e,w);var n=wn;wn=e;try{16777232&t?function(e){var t=e.first;for(;null!==t;){var n=t.next;32&t.f||fr(t),t=n}}(e):or(e),ir(e);var r=Nn(e);e.teardown="function"==typeof r?r:null,e.wv=jn}finally{wn=n}}}async function $n(){await Promise.resolve(),Bt()}function In(e){var t=!!(2&e.f);if(vn?.add(e),null!==yn&&!_n&&!(null!==wn&&16384&wn.f||null!==mn&&mn.has(e))){var n=yn.deps;if(2097152&yn.f)e.rv<On&&(e.rv=On,null===xn&&null!==n&&n[Sn]===e?Sn++:null===xn?xn=[e]:xn.push(e));else{yn.deps??=[],r.call(yn.deps,e)||yn.deps.push(e);var s=e.reactions;null===s?e.reactions=[yn]:r.call(s,yn)||s.push(yn)}}if(hn&&Zt.has(e))return Zt.get(e);if(t){var l=e;if(hn){var i=l.v;return(1024&l.f||null===l.reactions)&&!Jn(l)||(i=Ot(l)),Zt.set(l,i),i}var o=!(512&l.f||_n||null===yn||!(512&yn.f)),f=0===(l.f&S);Mn(l)&&(o&&(l.f|=512),Pt(l)),o&&!f&&(Tt(l),Vn(l))}if(Dt?.has(e))return Dt.get(e);if(8388608&e.f)throw e.v;return e.v}function Vn(e){if(e.f|=512,null!==e.deps)for(const n of e.deps){var t=n.reactions;null===t?n.reactions=[e]:r.call(t,e)||t.push(e),2&n.f&&!(512&n.f)&&(Tt(n),Vn(n))}}function Jn(e){if(e.v===ie)return!0;if(null===e.deps)return!1;for(const t of e.deps){if(Zt.has(t))return!0;if(2&t.f&&Jn(t))return!0}return!1}function Kn(e){var t=_n;try{return _n=!0,e()}finally{_n=t}}function Bn(e){if("object"==typeof e&&e&&!(e instanceof EventTarget))if(M in e)Fn(e);else if(!Array.isArray(e))for(let t in e){const n=e[t];"object"==typeof n&&n&&M in n&&Fn(n)}}function Fn(e,t=new Set){if(!("object"!=typeof e||null===e||e instanceof EventTarget||t.has(e))){t.add(e),e instanceof Date&&e.getTime();for(let s in e)try{Fn(e[s],t)}catch(n){}const r=c(e);if(r!==Object.prototype&&r!==Array.prototype&&r!==Map.prototype&&r!==Set.prototype&&r!==Date.prototype){const t=f(r);for(let r in t){const s=t[r].get;if(s)try{s.call(e)}catch(n){}}}}}function Ln(e){null===wn&&(null===yn&&function(){throw new Error("https://svelte.dev/e/effect_orphan")}(),function(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}()),hn&&function(){throw new Error("https://svelte.dev/e/effect_in_teardown")}()}function Gn(e,t){var n=wn;null!==n&&8192&n.f&&(e|=k);var r={ctx:_e,deps:null,nodes:null,f:e|b|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};qt?.register_created_effect(r);var s=r;if(4&e)null!==$t?$t.push(r):Kt.ensure().schedule(r);else if(null!==t){try{zn(r)}catch(s){throw fr(r),s}null!==s.deps||null!==s.teardown||null!==s.nodes||s.first!==s.last||524288&s.f||(s=s.first,16&e&&65536&e&&null!==s&&(s.f|=65536))}if(null!==s&&(s.parent=n,null!==n&&function(e,t){var n=t.last;null===n?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}(s,n),null!==yn&&2&yn.f&&!(64&e))){var l=yn;(l.effects??=[]).push(s)}return r}function Hn(){return null!==yn&&!_n}function Qn(e){const t=Gn(8,null);return ct(t,w),t.teardown=e,t}function Un(e){Ln();var t=wn.f;if(yn||!(32&t)||null===_e||_e.i)return Wn(e);var n=_e;(n.e??=[]).push(e)}function Wn(e){return Gn(1048580,e)}function Xn(e){return Ln(),Gn(1048584,e)}function Yn(e){Kt.ensure();const t=Gn(524352,e);return()=>{fr(t)}}function Zn(e){Kt.ensure();const t=Gn(524352,e);return(e={})=>new Promise(n=>{e.outro?ar(t,()=>{fr(t),n(void 0)}):(fr(t),n(void 0))})}function er(e){return Gn(4,e)}function tr(e,t=0){return Gn(8|t,e)}function nr(e,t=[],n=[],r=[]){gt(r,t,n,t=>{Gn(8,()=>{e(...t.map(In))})})}function rr(e,t=0){var n=Gn(16|t,e);return n}function sr(e,t=0){var n=Gn(16777216|t,e);return n}function lr(e){return Gn(524320,e)}function ir(e){var t=e.teardown;if(null!==t){const r=hn,s=yn;pn(!0),gn(null);try{t.call(null)}catch(n){ut(n,e.parent)}finally{pn(r),gn(s)}}}function or(e,t=!1){var n=e.first;for(e.first=e.last=null;null!==n;){const e=n.ac;null!==e&&_t(()=>{e.abort(K)});var r=n.next;64&n.f?n.parent=null:fr(n,t),n=r}}function fr(e,t=!0){var n=!1;(t||262144&e.f)&&null!==e.nodes&&null!==e.nodes.end&&(!function(e,t){for(;null!==e;){var n=e===t?null:Ze(e);e.remove(),e=n}}(e.nodes.start,e.nodes.end),n=!0),e.f|=E,or(e,t&&!n),Rn(e,0);var r=e.nodes&&e.nodes.t;if(null!==r)for(const l of r)l.stop();ir(e),e.f^=E,e.f|=16384;var s=e.parent;null!==s&&null!==s.first&&ur(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function ur(e){var t=e.parent,n=e.prev,r=e.next;null!==n&&(n.next=r),null!==r&&(r.prev=n),null!==t&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function ar(e,t,n=!0){var r=[];e.f|=256,cr(e,r,!0);var s=()=>{n&&fr(e),t&&t()},l=r.length;if(l>0){var i=()=>--l||s();for(var o of r)o.out(i)}else s()}function cr(e,t,n){if(!(8192&e.f)){e.f^=k;var r=e.nodes&&e.nodes.t;if(null!==r)for(const e of r)(e.is_global||n)&&t.push(e);for(var s=e.first;null!==s;){var l=s.next;if(!(64&s.f))cr(s,t,!!(!!(65536&s.f)||!!(32&s.f)&&!!(16&e.f))&&n);s=l}}}function dr(e){e.f&=-257,vr(e,!0)}function vr(e,t){if(!(256&e.f)&&8192&e.f){e.f^=k,1024&e.f||(ct(e,b),Kt.ensure().schedule(e));for(var n=e.first;null!==n;){var r=n.next;vr(n,!!(!!(65536&n.f)||!!(32&n.f))&&t),n=r}var s=e.nodes&&e.nodes.t;if(null!==s)for(const e of s)(e.is_global||t)&&e.in()}}function hr(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;null!==n;){var s=n===r?null:Ze(n);t.append(n),n=s}}function pr(e,t,n){if(null==e)return t(void 0),n&&n(void 0),h;const r=Kn(()=>e.subscribe(t,n));return r.unsubscribe?()=>r.unsubscribe():r}var yr=[];function _r(e,t){return{subscribe:gr(e,t).subscribe}}function gr(e,t=h){let n=null;const r=new Set;function s(t){if(L(e,t)&&(e=t,n)){const t=!yr.length;for(const n of r)n[1](),yr.push(n,e);if(t){for(let e=0;e<yr.length;e+=2)yr[e][0](yr[e+1]);yr.length=0}}}function l(t){s(t(e))}return{set:s,update:l,subscribe:function(i,o=h){const f=[i,o];return r.add(f),1===r.size&&(n=t(s,l)||h),i(e),()=>{r.delete(f),0===r.size&&n&&(n(),n=null)}}}}function wr(e,t,n){const r=!Array.isArray(e),s=r?[e]:e;if(!s.every(Boolean))throw new Error("derived() expects stores as input, got a falsy value");const l=t.length<2;return _r(n,(e,n)=>{let i=!1;const o=[];let f=0,u=h;const a=()=>{if(f)return;u();const s=t(r?o[0]:o,e,n);l?e(s):u="function"==typeof s?s:h},c=s.map((e,t)=>pr(e,e=>{o[t]=e,f&=~(1<<t),i&&a()},()=>{f|=1<<t}));return i=!0,a(),function(){y(c),u(),i=!1}})}function br(e){let t;return pr(e,e=>t=e)(),t}function mr(e){let t,n=0,r=tn(0);return()=>{Hn()&&(In(r),tr(()=>(0===n&&(t=Kn(()=>e(()=>cn(r)))),n+=1,()=>{Oe(()=>{n-=1,0===n&&(t?.(),t=void 0,cn(r))})})))}}function kr(){const{subscribe:e,set:t}=gr(!0);return{subscribe:e,observe:e=>{if("undefined"==typeof IntersectionObserver)return()=>{};const n=new IntersectionObserver(([e])=>t(e.isIntersecting));return n.observe(e),()=>n.disconnect()}}}function xr(e){return String(e)}export{et as $,Y as $t,gn as A,p as An,we as At,an as B,ae as Bt,Xn as C,o as Cn,Te as Ct,In as D,v as Dn,Ne as Dt,Bn as E,t as En,qe as Et,fn as F,me as Ft,Et as G,ie as Gt,qt as H,le as Ht,rn as I,ge as It,_t as J,re as Jt,St as K,ne as Kt,sn as L,ye as Lt,Kn as M,g as Mn,Se as Mt,Pn as N,e as Nn,xe as Nt,hn as O,h as On,Oe as Ot,cn as P,ke as Pt,ut as Q,X as Qt,tn as R,he as Rt,Un as S,i as Sn,Je as St,yn as T,c as Tn,Me as Tt,Bt as U,fe as Ut,Kt as V,oe as Vt,mt as W,ue as Wt,ht as X,U as Xt,yt as Y,Q as Yt,vt as Z,W as Zt,ar as _,S as _n,Ve as _t,br as a,z as an,Ze as at,Qn as b,I as bn,ze as bt,pr as c,P as cn,ot as ct,Zn as d,V as dn,rt as dt,Z as en,st as et,fr as f,J as fn,Le as ft,hr as g,D as gn,Ce as gt,sr as h,N as hn,De as ht,wr as i,R as in,Ye as it,$n as j,y as jn,be as jt,bn as k,l as kn,_e as kt,rr as l,O as ln,nt as lt,Yn as m,B as mn,$e as mt,kr as n,te as nn,Xe as nt,_r as o,x as on,We as ot,er as p,k as pn,Be as pt,gt as q,se as qt,mr as r,H as rn,tt as rt,gr as s,E as sn,He as st,xr as t,ee as tn,it as tt,lr as u,j as un,lt as ut,tr as v,M as vn,Ke as vt,wn as w,f as wn,Ae as wt,nr as x,s as xn,Re as xt,dr as y,$ as yn,Ie as yt,nn as z,de as zt};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as t,l as e,n as s,o}from"./dist-DfaMbR-1.js";import{a as n,i,t as r}from"./host-DPIuYxlL.js";import"./dist-BvRk9kiK.js";import{n as a,t as l}from"./time-aboh42pX.js";function c(t){const e=(t,e)=>{const s=t;if(!(s?.code instanceof Uint8Array&&s.code.length&&"string"==typeof s.json))throw new Error(`The plugin's ${e} module is missing.`);return{code:s.code,json:JSON.parse(s.json)}},o=e(t?.faust,"faust"),n=e(t?.effect,"effect"),i=t?.sounds&&"object"==typeof t.sounds?t.sounds:{},r={};for(const[s,a]of Object.entries(i))"number"==typeof a?.sampleRate&&Array.isArray(a.channels)&&a.channels.every(t=>t instanceof Float32Array)&&(r[s]={sampleRate:a.sampleRate,channels:a.channels});return{faust:o,effect:n,samples:s(o.json,r),voices:"number"==typeof t?.voices&&Number.isInteger(t.voices)&&t.voices>0?t.voices:void 0}}function h(t,e){const s=new Set,o=t=>{if(Array.isArray(t))for(const n of t)n.address&&e(n)&&s.add(n.address),o(n.items)};return o(t.ui),s}var d=t=>/^fwmeter (\w+)$/.exec(t)?.[1]??null,f=t=>!!(92&o(t));function u(e,s,o){const n=t(e,s,{id:"x",name:"x",vendor:"x",version:"0",...o?{voices:o}:{}}),i=(r=f,new Set([...h(e,r),...h(s,r)]));var r;const a=n.bargraphs;return{params:n.params.filter(t=>!i.has(t.address)).map(t=>({path:t.address,id:t.id,min:t.min,max:t.max,init:t.init,..."linear"!==t.scale?{scale:t.scale}:{}})),modouts:a.filter(t=>!t.hidden).map(t=>({address:t.address,label:t.label||t.address,id:t.id})),meters:Object.fromEntries(a.flatMap(t=>d(t.label)?[[d(t.label),t.id]]:[]))}}var m={width:1,height:1};function p(t,s){const{faust:o,effect:n,samples:i,voices:r}=c(s),a="string"==typeof s.name&&s.name.trim()?s.name.trim().slice(0,63):"Patch";return{module:e(t,o,n,{id:"io.faustwave.engine.patch",name:a,vendor:"FaustWave",version:"0",ui:m,...r?{voices:r}:{}},i),...u(o.json,n.json,r)}}var g=()=>({ms:0,peak:[0,0],notes:0,params:0}),v=class{sampleRate;block;clock;nodes=new Map;order=null;timeline=[{frame:0,playing:!1,bpm:120,beat:0}];step;blocks=0;renderMs=0;statsFrom;constructor(t,e=128,s=Date.now){this.sampleRate=t,this.block=e,this.clock=s,this.step=1-Math.exp(-1/(l*t)),this.statsFrom=s()}takeStats(){const t=this.clock(),e={};for(const[o,n]of this.nodes)n.host&&(e[o]=n.stats,n.stats=g());const s={blocks:this.blocks,ms:this.renderMs,wallMs:t-this.statsFrom,plugins:e};return this.blocks=0,this.renderMs=0,this.statsFrom=t,s}node(t,e,s,o=1){const n=t=>Array.from({length:t},()=>new Float32Array(this.block)),i=t=>({target:t,now:t});return{host:t,curve:null,out:n(e),in:n(s),sources:new Map,fader:[i(o),i(o)],peak:[0,0],due:[],dialect:null,fault:0,active:!0,stats:{ms:0,peak:[0,0],notes:0,params:0}}}active(t,e){const s=this.nodes.get(t);if(s?.host&&(s.active=e,!e)){s.host.stopProcessing(),s.due.length=0;for(const t of s.out)t.fill(0)}}reset(t){const e=this.nodes.get(t);if(e?.host){e.host.reset(),e.due.length=0;for(const t of e.out)t.fill(0)}}add(t,e,s={}){this.remove(t);const o=r.of(e,s.id,s.memory??null);o.activate(this.sampleRate,this.block,this.timeline[0].bpm);const n=this.node(o,o.audioOut,o.audioIn);return n.dialect=o.notePorts[0]?i(o.notePorts[0]):null,this.nodes.set(t,n),this.order=null,o}bus(t){this.nodes.has(t)||(this.nodes.set(t,this.node(null,2,2)),this.order=null)}shaper(t,e){this.nodes.has(t)||(this.nodes.set(t,this.node(null,2,2)),this.order=null),this.nodes.get(t).curve=e}remove(t){const e=this.nodes.get(t);if(e){this.nodes.delete(t),e.host?.destroy();for(const e of this.nodes.values())e.sources.delete(t);this.order=null}}has(t){return this.nodes.has(t)}host(t){return this.nodes.get(t)?.host??null}isActive(t){return this.nodes.get(t)?.active??!1}cable(t,e,s){const o=this.nodes.get(e);if(null===s)return void(o?.sources.delete(t)&&(this.order=null));if(!o)throw new Error(`a cable into "${e}", which the engine does not hold`);if(!this.nodes.has(t))throw new Error(`a cable from "${t}", which the engine does not hold`);const n=o.sources.get(t);n?n.target=s:(o.sources.set(t,{target:s,now:s}),this.order=null)}fader(t,e,s){const o=this.nodes.get(t);o&&!o.host&&(o.fader[0].target=e,o.fader[1].target=s)}takePeak(t){const e=this.nodes.get(t);if(!e)return[0,0];const s=[e.peak[0],e.peak[1]];return e.peak[0]=e.peak[1]=0,s}takeFault(t){const e=this.nodes.get(t);return 1===e?.fault&&(e.fault=2,!0)}event(t,e,s){const o=this.nodes.get(t);if(!o?.host)return;if(!o.active){if("param"!==s.type)return;const t=o.due.findIndex(t=>"param"===t.event.type&&t.event.id===s.id);t>=0&&o.due.splice(t,1)}if("midi"===s.type&&176==(240&s.data[0])&&(120===s.data[1]||123===s.data[1])){const t=15&s.data[0];o.due=o.due.filter(e=>!("midi"===e.event.type&&(15&e.event.data[0])===t||("on"===e.event.type||"off"===e.event.type)&&(e.event.channel??0)===t))}let n=o.due.length;for(;n>0&&o.due[n-1].frame>e;)n--;o.due.splice(n,0,{frame:e,event:s})}transport(t){const e=this.timeline.at(-1);if(t.playing&&e&&!e.playing&&e.frame>=t.frame){const s=e.frame+1;t={...t,frame:s,beat:a(t,s,this.sampleRate)}}this.timeline=this.timeline.filter(e=>e.frame<t.frame),this.timeline.push(t)}transportAt(t){let e=this.timeline[0];for(const s of this.timeline)s.frame<=t&&(e=s);return{playing:e.playing,bpm:e.bpm,beat:a(e,t,this.sampleRate)}}ordered(){if(this.order)return this.order;const t=new Set,e=new Set,s=[],o=n=>{if(!t.has(n)&&!e.has(n)&&this.nodes.has(n)){e.add(n);for(const t of this.nodes.get(n).sources.keys())o(t);e.delete(n),t.add(n),s.push(n)}};for(const n of this.nodes.keys())o(n);return this.order=s}addInto(t,e,s){const o=this.step;let n=s.now;const i=s.target,r=n===i;for(let a=0;a<this.block;a++){r||(n+=(i-n)*o);for(let s=0;s<t.length;s++){const o=e.length===t.length?e[s][a]:1===e.length?e[0][a]:1===t.length?.5*(e[0][a]+e[1][a]):e[s]?.[a]??0;t[s][a]+=o*n}}s.now=Math.abs(i-n)<1e-7?i:n}render(t,e,s){const o=t+this.block,i=this.clock(),r=[t,...this.timeline.filter(e=>e.frame>t&&e.frame<o).map(t=>t.frame),o],a={target:1,now:1};for(const c of this.ordered()){const o=this.nodes.get(c);for(const t of o.in)t.fill(0);const i=s?.get(c);i&&i.length&&o.in.length&&this.addInto(o.in,i,a);for(const[t,e]of o.sources){const s=this.nodes.get(t);s&&o.in.length&&this.addInto(o.in,s.out,e)}if(o.host&&!o.active);else if(o.host){const e=this.clock();for(let i=0;i+1<r.length;i++){const[e,s]=[r[i],r[i+1]],a=this.transportAt(e);o.host.setTransport(a.playing,a.bpm,a.beat);let l=0;for(;l<o.due.length&&o.due[l].frame<s;)l++;const c=o.due.splice(0,l).map(({frame:t,event:s})=>({...s,time:Math.max(0,t-e)})),h=o.dialect?n(c,o.dialect):c;for(const t of h)"param"===t.type?o.stats.params++:("on"===t.type||"midi"===t.type&&144==(240&t.data[0])&&t.data[2]>0)&&o.stats.notes++;o.host.render(o.out,e-t,s-e,h,o.in)}o.stats.ms+=this.clock()-e;let s=!1;for(let t=0;t<o.out.length&&!s;t++){const e=o.out[t];let n=o.stats.peak[t>0?1:0];for(let t=0;t<e.length;t++){const o=e[t];Number.isFinite(o)?(o<0?-o:o)>n&&(n=o<0?-o:o):s=!0}o.stats.peak[t>0?1:0]=n}if(s){for(const t of o.out)t.fill(0);0===o.fault&&(o.fault=1)}1===o.out.length&&(o.stats.peak[1]=o.stats.peak[0])}else if(o.curve){const t=o.curve,e=t.length-1;for(let s=0;s<2;s++){const[n,i]=[o.in[s],o.out[s]];for(let s=0;s<this.block;s++){const o=e/2*(n[s]+1);if(o<=0)i[s]=t[0];else if(o>=e)i[s]=t[e];else{const e=Math.floor(o),n=o-e;i[s]=(1-n)*t[e]+n*t[e+1]}}}}else for(let t=0;t<2;t++){const e=o.fader[t],[s,n]=[o.in[t],o.out[t]];let i=e.now,r=o.peak[t];for(let t=0;t<this.block;t++){i!==e.target&&(i+=(e.target-i)*this.step);const o=s[t]*i;n[t]=o;const a=o<0?-o:o;a>r&&(r=a)}e.now=Math.abs(e.target-i)<1e-7?e.target:i,o.peak[t]=r}const l=e.get(c);if(l)for(let t=0;t<l.length;t++)l[t].set(o.out[t]??(1===o.out.length?o.out[0]:new Float32Array(this.block)))}const l=this.timeline.filter(t=>t.frame<o);this.timeline=[...l.slice(-1),...this.timeline.filter(t=>t.frame>=o)],this.blocks++,this.renderMs+=this.clock()-i}};export{v as EngineCore,p as enginePluginModule,u as patchSides,c as pluginPartsOf};
|