faustwave 0.94.0 → 0.95.2

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.
Files changed (100) hide show
  1. package/README.md +4 -8
  2. package/dist/npm/faustwave.mjs +17 -53
  3. package/dist/npm/page/assets/{index-BPO9trAg.css → index-D1USQuiC.css} +1 -1
  4. package/dist/npm/page/assets/{index-DyOBLoeh.js → index-idBrq71K.js} +1 -1
  5. package/dist/npm/page/files.json +1 -1
  6. package/dist/npm/page/index.html +2 -2
  7. package/package.json +57 -58
  8. package/dist/npm/pagekit/pagekit.js +0 -2347
  9. package/dist/npm/pagekit/parts/device-button.glb +0 -0
  10. package/dist/npm/pagekit/parts/device-fader.glb +0 -0
  11. package/dist/npm/pagekit/parts/device-knob.glb +0 -0
  12. package/dist/npm/pagekit/parts/device-meter.glb +0 -0
  13. package/dist/npm/pagekit/parts/device-panel.glb +0 -0
  14. package/dist/npm/pagekit/parts/models-provenance.json +0 -46
  15. package/dist/npm/pagekit/player/THIRD-PARTY-NOTICES.md +0 -12358
  16. package/dist/npm/pagekit/player/assets/AppView-BV9Obknn.js +0 -1
  17. package/dist/npm/pagekit/player/assets/AppView-CdET0bgZ.css +0 -1
  18. package/dist/npm/pagekit/player/assets/FontLoader-C8xh6Irz.js +0 -64
  19. package/dist/npm/pagekit/player/assets/StageView-CSu--ASd.css +0 -1
  20. package/dist/npm/pagekit/player/assets/StageView-_SwGWnwx.js +0 -1
  21. package/dist/npm/pagekit/player/assets/actionRegistry-DrQhww6a.js +0 -1
  22. package/dist/npm/pagekit/player/assets/actionRegistry-hOkUYNvI.js +0 -1
  23. package/dist/npm/pagekit/player/assets/ahead-BNQHG1e8.js +0 -1
  24. package/dist/npm/pagekit/player/assets/api-BrGhAVvb.js +0 -1
  25. package/dist/npm/pagekit/player/assets/autoLayout-C5ue2K3x.js +0 -1
  26. package/dist/npm/pagekit/player/assets/bundledSources-2GoXdU5z.js +0 -1
  27. package/dist/npm/pagekit/player/assets/clapModule-CB6_36hc.js +0 -1
  28. package/dist/npm/pagekit/player/assets/client-DksDHYQL.js +0 -1
  29. package/dist/npm/pagekit/player/assets/codeEditorBridge-Bl202hrO.js +0 -1
  30. package/dist/npm/pagekit/player/assets/disclose-version-BvIhFN19.js +0 -1
  31. package/dist/npm/pagekit/player/assets/dist-BvRk9kiK.js +0 -0
  32. package/dist/npm/pagekit/player/assets/dist-DfaMbR-1.js +0 -1
  33. package/dist/npm/pagekit/player/assets/engine.worklet-BTB8yjdk.js +0 -1865
  34. package/dist/npm/pagekit/player/assets/engineCost.worker-Cv0PY3S-.js +0 -2167
  35. package/dist/npm/pagekit/player/assets/errors-BdUU2zPt.js +0 -1
  36. package/dist/npm/pagekit/player/assets/faust-analysis.nodepack-Bg1ixSAB.js +0 -1
  37. package/dist/npm/pagekit/player/assets/faust-physical-models.nodepack-DxbqTZII.js +0 -1
  38. package/dist/npm/pagekit/player/assets/faust-reverbs.nodepack-c-ZIKLrJ.js +0 -1
  39. package/dist/npm/pagekit/player/assets/faust-spatial.nodepack-C6GwVzOM.js +0 -1
  40. package/dist/npm/pagekit/player/assets/faust-vintage.nodepack-D8g5LX-U.js +0 -1
  41. package/dist/npm/pagekit/player/assets/faust.nodepack-Do7P1z0H.js +0 -1
  42. package/dist/npm/pagekit/player/assets/faustSource-Blr9zzKL.js +0 -1
  43. package/dist/npm/pagekit/player/assets/faustwasm-webclap-double-BX3OrOpF.js +0 -1
  44. package/dist/npm/pagekit/player/assets/faustwasm-webclap-double-Drn3DiHA.wasm +0 -0
  45. package/dist/npm/pagekit/player/assets/faustwasm.js +0 -1
  46. package/dist/npm/pagekit/player/assets/faustwave-conventions.nodepack-D2jA38Q6.js +0 -1
  47. package/dist/npm/pagekit/player/assets/fileMirror-CkgB9zNS.js +0 -1
  48. package/dist/npm/pagekit/player/assets/fileRef-BmnWhXuY.js +0 -1
  49. package/dist/npm/pagekit/player/assets/host-DPIuYxlL.js +0 -1
  50. package/dist/npm/pagekit/player/assets/instantiate-Dh0T46aH.js +0 -1
  51. package/dist/npm/pagekit/player/assets/inter-500.typeface-B6jxeZL_.js +0 -21
  52. package/dist/npm/pagekit/player/assets/inter-700.typeface-COCE0d_R.js +0 -21
  53. package/dist/npm/pagekit/player/assets/kernel-BErAMnKr.js +0 -1
  54. package/dist/npm/pagekit/player/assets/kernel-D6spGIFh.js +0 -1
  55. package/dist/npm/pagekit/player/assets/kernel-DKiI3Wqx.js +0 -2
  56. package/dist/npm/pagekit/player/assets/kit--nsV_OZy.js +0 -1
  57. package/dist/npm/pagekit/player/assets/kit-vVQ5cDnW.css +0 -1
  58. package/dist/npm/pagekit/player/assets/lazy-BkjipY-3.css +0 -1
  59. package/dist/npm/pagekit/player/assets/lazy-ClEpU-Ev.js +0 -1
  60. package/dist/npm/pagekit/player/assets/libraryFacts-B_z-Kv6i.js +0 -1
  61. package/dist/npm/pagekit/player/assets/mono-500.typeface-CuX9Pbhu.js +0 -21
  62. package/dist/npm/pagekit/player/assets/mono-700.typeface-BpIQdJao.js +0 -21
  63. package/dist/npm/pagekit/player/assets/newId-DuoSrkVn.js +0 -1
  64. package/dist/npm/pagekit/player/assets/notes-D-zF5qJ1.js +0 -1
  65. package/dist/npm/pagekit/player/assets/opfsStore-CXd1Yz_2.js +0 -1
  66. package/dist/npm/pagekit/player/assets/panic-ckha9YOX.js +0 -1
  67. package/dist/npm/pagekit/player/assets/patchSnippets-Dsccmpj6.js +0 -1
  68. package/dist/npm/pagekit/player/assets/paths-DFjX1bFA.js +0 -1
  69. package/dist/npm/pagekit/player/assets/player-CgcvekqS.js +0 -2
  70. package/dist/npm/pagekit/player/assets/playerApp-BmyTSXxw.js +0 -2
  71. package/dist/npm/pagekit/player/assets/playerApp-DO80EIpx.css +0 -1
  72. package/dist/npm/pagekit/player/assets/preArm-ifXM2Buj.js +0 -1
  73. package/dist/npm/pagekit/player/assets/preload-helper-9MKZsTCd.js +0 -1
  74. package/dist/npm/pagekit/player/assets/projectFiles-BEdLy3nE.js +0 -1
  75. package/dist/npm/pagekit/player/assets/projectPicker-mteZ2tiI.js +0 -1
  76. package/dist/npm/pagekit/player/assets/rocket-CgRnlVoE.js +0 -1
  77. package/dist/npm/pagekit/player/assets/runtime-36oA_YiG.js +0 -1
  78. package/dist/npm/pagekit/player/assets/runtime-7lvdeERt.js +0 -1
  79. package/dist/npm/pagekit/player/assets/runtime-BNLxaYPi.js +0 -2
  80. package/dist/npm/pagekit/player/assets/runtime-CL1M0Epi.js +0 -1
  81. package/dist/npm/pagekit/player/assets/runtime-bQsuRbRM.js +0 -2
  82. package/dist/npm/pagekit/player/assets/runtime-vj8wKnnG.js +0 -1
  83. package/dist/npm/pagekit/player/assets/runtime-wuc1seO8.js +0 -1
  84. package/dist/npm/pagekit/player/assets/scale-D2nqiPek.js +0 -1
  85. package/dist/npm/pagekit/player/assets/sha256-B9lHpAF4.js +0 -1
  86. package/dist/npm/pagekit/player/assets/soundfiles-DMZ8HKDZ.js +0 -1
  87. package/dist/npm/pagekit/player/assets/src-BvHr5YSH.js +0 -2
  88. package/dist/npm/pagekit/player/assets/src-Co7ihhBK.js +0 -1
  89. package/dist/npm/pagekit/player/assets/src-DyDfRe65.js +0 -1
  90. package/dist/npm/pagekit/player/assets/src-LMfGAjlj.js +0 -1
  91. package/dist/npm/pagekit/player/assets/stageWorker-ggqqFf5m.js +0 -20869
  92. package/dist/npm/pagekit/player/assets/store-CJdayqZa.js +0 -1
  93. package/dist/npm/pagekit/player/assets/sun-Bi-OgPry.js +0 -1
  94. package/dist/npm/pagekit/player/assets/time-aboh42pX.js +0 -1
  95. package/dist/npm/pagekit/player/assets/toasts-BCcM1yGS.js +0 -1
  96. package/dist/npm/pagekit/player/assets/toasts-ChPacqdd.js +0 -1
  97. package/dist/npm/pagekit/player/assets/transportFollow-Ox91SKLF.js +0 -1
  98. package/dist/npm/pagekit/player/favicon.svg +0 -77
  99. package/dist/npm/pagekit/player/files.json +0 -1
  100. package/dist/npm/pagekit/player/player.html +0 -35
@@ -1,2347 +0,0 @@
1
- // \0rolldown/runtime.js
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
- key = keys[i];
12
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
- get: ((k) => from[k]).bind(null, key),
14
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
- });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
20
- value: mod,
21
- enumerable: true
22
- }) : target, mod));
23
- // ../../node_modules/fflate/esm/browser.js
24
- var u8 = Uint8Array;
25
- var u16 = Uint16Array;
26
- var i32 = Int32Array;
27
- var fleb = new u8([
28
- 0,
29
- 0,
30
- 0,
31
- 0,
32
- 0,
33
- 0,
34
- 0,
35
- 0,
36
- 1,
37
- 1,
38
- 1,
39
- 1,
40
- 2,
41
- 2,
42
- 2,
43
- 2,
44
- 3,
45
- 3,
46
- 3,
47
- 3,
48
- 4,
49
- 4,
50
- 4,
51
- 4,
52
- 5,
53
- 5,
54
- 5,
55
- 5,
56
- 0,
57
- 0,
58
- 0,
59
- 0
60
- ]);
61
- var fdeb = new u8([
62
- 0,
63
- 0,
64
- 0,
65
- 0,
66
- 1,
67
- 1,
68
- 2,
69
- 2,
70
- 3,
71
- 3,
72
- 4,
73
- 4,
74
- 5,
75
- 5,
76
- 6,
77
- 6,
78
- 7,
79
- 7,
80
- 8,
81
- 8,
82
- 9,
83
- 9,
84
- 10,
85
- 10,
86
- 11,
87
- 11,
88
- 12,
89
- 12,
90
- 13,
91
- 13,
92
- 0,
93
- 0
94
- ]);
95
- var clim = new u8([
96
- 16,
97
- 17,
98
- 18,
99
- 0,
100
- 8,
101
- 7,
102
- 9,
103
- 6,
104
- 10,
105
- 5,
106
- 11,
107
- 4,
108
- 12,
109
- 3,
110
- 13,
111
- 2,
112
- 14,
113
- 1,
114
- 15
115
- ]);
116
- var freb = function(eb, start) {
117
- var b = new u16(31);
118
- for (var i = 0; i < 31; ++i) b[i] = start += 1 << eb[i - 1];
119
- var r = new i32(b[30]);
120
- for (var i = 1; i < 30; ++i) for (var j = b[i]; j < b[i + 1]; ++j) r[j] = j - b[i] << 5 | i;
121
- return {
122
- b,
123
- r
124
- };
125
- };
126
- var _a = freb(fleb, 2);
127
- var fl = _a.b;
128
- var revfl = _a.r;
129
- fl[28] = 258, revfl[258] = 28;
130
- var _b = freb(fdeb, 0);
131
- _b.b;
132
- var revfd = _b.r;
133
- var rev = new u16(32768);
134
- for (var i = 0; i < 32768; ++i) {
135
- var x = (i & 43690) >> 1 | (i & 21845) << 1;
136
- x = (x & 52428) >> 2 | (x & 13107) << 2;
137
- x = (x & 61680) >> 4 | (x & 3855) << 4;
138
- rev[i] = ((x & 65280) >> 8 | (x & 255) << 8) >> 1;
139
- }
140
- var hMap = (function(cd, mb, r) {
141
- var s = cd.length;
142
- var i = 0;
143
- var l = new u16(mb);
144
- for (; i < s; ++i) if (cd[i]) ++l[cd[i] - 1];
145
- var le = new u16(mb);
146
- for (i = 1; i < mb; ++i) le[i] = le[i - 1] + l[i - 1] << 1;
147
- var co;
148
- if (r) {
149
- co = new u16(1 << mb);
150
- var rvb = 15 - mb;
151
- for (i = 0; i < s; ++i) if (cd[i]) {
152
- var sv = i << 4 | cd[i];
153
- var r_1 = mb - cd[i];
154
- var v = le[cd[i] - 1]++ << r_1;
155
- for (var m = v | (1 << r_1) - 1; v <= m; ++v) co[rev[v] >> rvb] = sv;
156
- }
157
- } else {
158
- co = new u16(s);
159
- for (i = 0; i < s; ++i) if (cd[i]) co[i] = rev[le[cd[i] - 1]++] >> 15 - cd[i];
160
- }
161
- return co;
162
- });
163
- var flt = new u8(288);
164
- for (var i = 0; i < 144; ++i) flt[i] = 8;
165
- for (var i = 144; i < 256; ++i) flt[i] = 9;
166
- for (var i = 256; i < 280; ++i) flt[i] = 7;
167
- for (var i = 280; i < 288; ++i) flt[i] = 8;
168
- var fdt = new u8(32);
169
- for (var i = 0; i < 32; ++i) fdt[i] = 5;
170
- var flm = /*#__PURE__*/ hMap(flt, 9, 0);
171
- var fdm = /*#__PURE__*/ hMap(fdt, 5, 0);
172
- var shft = function(p) {
173
- return (p + 7) / 8 | 0;
174
- };
175
- var slc = function(v, s, e) {
176
- if (s == null || s < 0) s = 0;
177
- if (e == null || e > v.length) e = v.length;
178
- return new u8(v.subarray(s, e));
179
- };
180
- var ec = [
181
- "unexpected EOF",
182
- "invalid block type",
183
- "invalid length/literal",
184
- "invalid distance",
185
- "stream finished",
186
- "no stream handler",
187
- ,
188
- "no callback",
189
- "invalid UTF-8 data",
190
- "extra field too long",
191
- "date not in range 1980-2099",
192
- "filename too long",
193
- "stream finishing",
194
- "invalid zip data"
195
- ];
196
- var err = function(ind, msg, nt) {
197
- var e = new Error(msg || ec[ind]);
198
- e.code = ind;
199
- if (Error.captureStackTrace) Error.captureStackTrace(e, err);
200
- if (!nt) throw e;
201
- return e;
202
- };
203
- var wbits = function(d, p, v) {
204
- v <<= p & 7;
205
- var o = p / 8 | 0;
206
- d[o] |= v;
207
- d[o + 1] |= v >> 8;
208
- };
209
- var wbits16 = function(d, p, v) {
210
- v <<= p & 7;
211
- var o = p / 8 | 0;
212
- d[o] |= v;
213
- d[o + 1] |= v >> 8;
214
- d[o + 2] |= v >> 16;
215
- };
216
- var hTree = function(d, mb) {
217
- var t = [];
218
- for (var i = 0; i < d.length; ++i) if (d[i]) t.push({
219
- s: i,
220
- f: d[i]
221
- });
222
- var s = t.length;
223
- var t2 = t.slice();
224
- if (!s) return {
225
- t: et,
226
- l: 0
227
- };
228
- if (s == 1) {
229
- var v = new u8(t[0].s + 1);
230
- v[t[0].s] = 1;
231
- return {
232
- t: v,
233
- l: 1
234
- };
235
- }
236
- t.sort(function(a, b) {
237
- return a.f - b.f;
238
- });
239
- t.push({
240
- s: -1,
241
- f: 25001
242
- });
243
- var l = t[0], r = t[1], i0 = 0, i1 = 1, i2 = 2;
244
- t[0] = {
245
- s: -1,
246
- f: l.f + r.f,
247
- l,
248
- r
249
- };
250
- while (i1 != s - 1) {
251
- l = t[t[i0].f < t[i2].f ? i0++ : i2++];
252
- r = t[i0 != i1 && t[i0].f < t[i2].f ? i0++ : i2++];
253
- t[i1++] = {
254
- s: -1,
255
- f: l.f + r.f,
256
- l,
257
- r
258
- };
259
- }
260
- var maxSym = t2[0].s;
261
- for (var i = 1; i < s; ++i) if (t2[i].s > maxSym) maxSym = t2[i].s;
262
- var tr = new u16(maxSym + 1);
263
- var mbt = ln$1(t[i1 - 1], tr, 0);
264
- if (mbt > mb) {
265
- var i = 0, dt = 0;
266
- var lft = mbt - mb, cst = 1 << lft;
267
- t2.sort(function(a, b) {
268
- return tr[b.s] - tr[a.s] || a.f - b.f;
269
- });
270
- for (; i < s; ++i) {
271
- var i2_1 = t2[i].s;
272
- if (tr[i2_1] > mb) {
273
- dt += cst - (1 << mbt - tr[i2_1]);
274
- tr[i2_1] = mb;
275
- } else break;
276
- }
277
- dt >>= lft;
278
- while (dt > 0) {
279
- var i2_2 = t2[i].s;
280
- if (tr[i2_2] < mb) dt -= 1 << mb - tr[i2_2]++ - 1;
281
- else ++i;
282
- }
283
- for (; i >= 0 && dt; --i) {
284
- var i2_3 = t2[i].s;
285
- if (tr[i2_3] == mb) {
286
- --tr[i2_3];
287
- ++dt;
288
- }
289
- }
290
- mbt = mb;
291
- }
292
- return {
293
- t: new u8(tr),
294
- l: mbt
295
- };
296
- };
297
- var ln$1 = function(n, l, d) {
298
- return n.s == -1 ? Math.max(ln$1(n.l, l, d + 1), ln$1(n.r, l, d + 1)) : l[n.s] = d;
299
- };
300
- var lc = function(c) {
301
- var s = c.length;
302
- while (s && !c[--s]);
303
- var cl = new u16(++s);
304
- var cli = 0, cln = c[0], cls = 1;
305
- var w = function(v) {
306
- cl[cli++] = v;
307
- };
308
- for (var i = 1; i <= s; ++i) if (c[i] == cln && i != s) ++cls;
309
- else {
310
- if (!cln && cls > 2) {
311
- for (; cls > 138; cls -= 138) w(32754);
312
- if (cls > 2) {
313
- w(cls > 10 ? cls - 11 << 5 | 28690 : cls - 3 << 5 | 12305);
314
- cls = 0;
315
- }
316
- } else if (cls > 3) {
317
- w(cln), --cls;
318
- for (; cls > 6; cls -= 6) w(8304);
319
- if (cls > 2) w(cls - 3 << 5 | 8208), cls = 0;
320
- }
321
- while (cls--) w(cln);
322
- cls = 1;
323
- cln = c[i];
324
- }
325
- return {
326
- c: cl.subarray(0, cli),
327
- n: s
328
- };
329
- };
330
- var clen = function(cf, cl) {
331
- var l = 0;
332
- for (var i = 0; i < cl.length; ++i) l += cf[i] * cl[i];
333
- return l;
334
- };
335
- var wfblk = function(out, pos, dat) {
336
- var s = dat.length;
337
- var o = shft(pos + 2);
338
- out[o] = s & 255;
339
- out[o + 1] = s >> 8;
340
- out[o + 2] = out[o] ^ 255;
341
- out[o + 3] = out[o + 1] ^ 255;
342
- for (var i = 0; i < s; ++i) out[o + i + 4] = dat[i];
343
- return (o + 4 + s) * 8;
344
- };
345
- var wblk = function(dat, out, final, syms, lf, df, eb, li, bs, bl, p) {
346
- wbits(out, p++, final);
347
- ++lf[256];
348
- var _a = hTree(lf, 15), dlt = _a.t, mlb = _a.l;
349
- var _b = hTree(df, 15), ddt = _b.t, mdb = _b.l;
350
- var _c = lc(dlt), lclt = _c.c, nlc = _c.n;
351
- var _d = lc(ddt), lcdt = _d.c, ndc = _d.n;
352
- var lcfreq = new u16(19);
353
- for (var i = 0; i < lclt.length; ++i) ++lcfreq[lclt[i] & 31];
354
- for (var i = 0; i < lcdt.length; ++i) ++lcfreq[lcdt[i] & 31];
355
- var _e = hTree(lcfreq, 7), lct = _e.t, mlcb = _e.l;
356
- var nlcc = 19;
357
- for (; nlcc > 4 && !lct[clim[nlcc - 1]]; --nlcc);
358
- var flen = bl + 5 << 3;
359
- var ftlen = clen(lf, flt) + clen(df, fdt) + eb;
360
- var dtlen = clen(lf, dlt) + clen(df, ddt) + eb + 14 + 3 * nlcc + clen(lcfreq, lct) + 2 * lcfreq[16] + 3 * lcfreq[17] + 7 * lcfreq[18];
361
- if (bs >= 0 && flen <= ftlen && flen <= dtlen) return wfblk(out, p, dat.subarray(bs, bs + bl));
362
- var lm, ll, dm, dl;
363
- wbits(out, p, 1 + (dtlen < ftlen)), p += 2;
364
- if (dtlen < ftlen) {
365
- lm = hMap(dlt, mlb, 0), ll = dlt, dm = hMap(ddt, mdb, 0), dl = ddt;
366
- var llm = hMap(lct, mlcb, 0);
367
- wbits(out, p, nlc - 257);
368
- wbits(out, p + 5, ndc - 1);
369
- wbits(out, p + 10, nlcc - 4);
370
- p += 14;
371
- for (var i = 0; i < nlcc; ++i) wbits(out, p + 3 * i, lct[clim[i]]);
372
- p += 3 * nlcc;
373
- var lcts = [lclt, lcdt];
374
- for (var it = 0; it < 2; ++it) {
375
- var clct = lcts[it];
376
- for (var i = 0; i < clct.length; ++i) {
377
- var len = clct[i] & 31;
378
- wbits(out, p, llm[len]), p += lct[len];
379
- if (len > 15) wbits(out, p, clct[i] >> 5 & 127), p += clct[i] >> 12;
380
- }
381
- }
382
- } else lm = flm, ll = flt, dm = fdm, dl = fdt;
383
- for (var i = 0; i < li; ++i) {
384
- var sym = syms[i];
385
- if (sym > 255) {
386
- var len = sym >> 18 & 31;
387
- wbits16(out, p, lm[len + 257]), p += ll[len + 257];
388
- if (len > 7) wbits(out, p, sym >> 23 & 31), p += fleb[len];
389
- var dst = sym & 31;
390
- wbits16(out, p, dm[dst]), p += dl[dst];
391
- if (dst > 3) wbits16(out, p, sym >> 5 & 8191), p += fdeb[dst];
392
- } else wbits16(out, p, lm[sym]), p += ll[sym];
393
- }
394
- wbits16(out, p, lm[256]);
395
- return p + ll[256];
396
- };
397
- var deo = /*#__PURE__*/ new i32([
398
- 65540,
399
- 131080,
400
- 131088,
401
- 131104,
402
- 262176,
403
- 1048704,
404
- 1048832,
405
- 2114560,
406
- 2117632
407
- ]);
408
- var et = /*#__PURE__*/ new u8(0);
409
- var dflt = function(dat, lvl, plvl, pre, post, st) {
410
- var s = st.z || dat.length;
411
- var o = new u8(pre + s + 5 * (1 + Math.ceil(s / 7e3)) + post);
412
- var w = o.subarray(pre, o.length - post);
413
- var lst = st.l;
414
- var pos = (st.r || 0) & 7;
415
- if (lvl) {
416
- if (pos) w[0] = st.r >> 3;
417
- var opt = deo[lvl - 1];
418
- var n = opt >> 13, c = opt & 8191;
419
- var msk_1 = (1 << plvl) - 1;
420
- var prev = st.p || new u16(32768), head = st.h || new u16(msk_1 + 1);
421
- var bs1_1 = Math.ceil(plvl / 3), bs2_1 = 2 * bs1_1;
422
- var hsh = function(i) {
423
- return (dat[i] ^ dat[i + 1] << bs1_1 ^ dat[i + 2] << bs2_1) & msk_1;
424
- };
425
- var syms = new i32(25e3);
426
- var lf = new u16(288), df = new u16(32);
427
- var lc_1 = 0, eb = 0, i = st.i || 0, li = 0, wi = st.w || 0, bs = 0;
428
- for (; i + 2 < s; ++i) {
429
- var hv = hsh(i);
430
- var imod = i & 32767, pimod = head[hv];
431
- prev[imod] = pimod;
432
- head[hv] = imod;
433
- if (wi <= i) {
434
- var rem = s - i;
435
- if ((lc_1 > 7e3 || li > 24576) && (rem > 423 || !lst)) {
436
- pos = wblk(dat, w, 0, syms, lf, df, eb, li, bs, i - bs, pos);
437
- li = lc_1 = eb = 0, bs = i;
438
- for (var j = 0; j < 286; ++j) lf[j] = 0;
439
- for (var j = 0; j < 30; ++j) df[j] = 0;
440
- }
441
- var l = 2, d = 0, ch_1 = c, dif = imod - pimod & 32767;
442
- if (rem > 2 && hv == hsh(i - dif)) {
443
- var maxn = Math.min(n, rem) - 1;
444
- var maxd = Math.min(32767, i);
445
- var ml = Math.min(258, rem);
446
- while (dif <= maxd && --ch_1 && imod != pimod) {
447
- if (dat[i + l] == dat[i + l - dif]) {
448
- var nl = 0;
449
- for (; nl < ml && dat[i + nl] == dat[i + nl - dif]; ++nl);
450
- if (nl > l) {
451
- l = nl, d = dif;
452
- if (nl > maxn) break;
453
- var mmd = Math.min(dif, nl - 2);
454
- var md = 0;
455
- for (var j = 0; j < mmd; ++j) {
456
- var ti = i - dif + j & 32767;
457
- var cd = ti - prev[ti] & 32767;
458
- if (cd > md) md = cd, pimod = ti;
459
- }
460
- }
461
- }
462
- imod = pimod, pimod = prev[imod];
463
- dif += imod - pimod & 32767;
464
- }
465
- }
466
- if (d) {
467
- syms[li++] = 268435456 | revfl[l] << 18 | revfd[d];
468
- var lin = revfl[l] & 31, din = revfd[d] & 31;
469
- eb += fleb[lin] + fdeb[din];
470
- ++lf[257 + lin];
471
- ++df[din];
472
- wi = i + l;
473
- ++lc_1;
474
- } else {
475
- syms[li++] = dat[i];
476
- ++lf[dat[i]];
477
- }
478
- }
479
- }
480
- for (i = Math.max(i, wi); i < s; ++i) {
481
- syms[li++] = dat[i];
482
- ++lf[dat[i]];
483
- }
484
- pos = wblk(dat, w, lst, syms, lf, df, eb, li, bs, i - bs, pos);
485
- if (!lst) {
486
- st.r = pos & 7 | w[pos / 8 | 0] << 3;
487
- pos -= 7;
488
- st.h = head, st.p = prev, st.i = i, st.w = wi;
489
- }
490
- } else {
491
- for (var i = st.w || 0; i < s + lst; i += 65535) {
492
- var e = i + 65535;
493
- if (e >= s) {
494
- w[pos / 8 | 0] = lst;
495
- e = s;
496
- }
497
- pos = wfblk(w, pos + 1, dat.subarray(i, e));
498
- }
499
- st.i = s;
500
- }
501
- return slc(o, 0, pre + shft(pos) + post);
502
- };
503
- var crct = /*#__PURE__*/ (function() {
504
- var t = /* @__PURE__ */ new Int32Array(256);
505
- for (var i = 0; i < 256; ++i) {
506
- var c = i, k = 9;
507
- while (--k) c = (c & 1 && -306674912) ^ c >>> 1;
508
- t[i] = c;
509
- }
510
- return t;
511
- })();
512
- var crc = function() {
513
- var c = -1;
514
- return {
515
- p: function(d) {
516
- var cr = c;
517
- for (var i = 0; i < d.length; ++i) cr = crct[cr & 255 ^ d[i]] ^ cr >>> 8;
518
- c = cr;
519
- },
520
- d: function() {
521
- return ~c;
522
- }
523
- };
524
- };
525
- var dopt = function(dat, opt, pre, post, st) {
526
- if (!st) {
527
- st = { l: 1 };
528
- if (opt.dictionary) {
529
- var dict = opt.dictionary.subarray(-32768);
530
- var newDat = new u8(dict.length + dat.length);
531
- newDat.set(dict);
532
- newDat.set(dat, dict.length);
533
- dat = newDat;
534
- st.w = dict.length;
535
- }
536
- }
537
- return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? st.l ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : 20 : 12 + opt.mem, pre, post, st);
538
- };
539
- var mrg = function(a, b) {
540
- var o = {};
541
- for (var k in a) o[k] = a[k];
542
- for (var k in b) o[k] = b[k];
543
- return o;
544
- };
545
- var wbytes = function(d, b, v) {
546
- for (; v; ++b) d[b] = v, v >>>= 8;
547
- };
548
- /**
549
- * Compresses data with DEFLATE without any wrapper
550
- * @param data The data to compress
551
- * @param opts The compression options
552
- * @returns The deflated version of the data
553
- */
554
- function deflateSync(data, opts) {
555
- return dopt(data, opts || {}, 0, 0);
556
- }
557
- var fltn = function(d, p, t, o) {
558
- for (var k in d) {
559
- var val = d[k], n = p + k, op = o;
560
- if (Array.isArray(val)) op = mrg(o, val[1]), val = val[0];
561
- if (ArrayBuffer.isView(val)) t[n] = [val, op];
562
- else {
563
- t[n += "/"] = [new u8(0), op];
564
- fltn(val, n, t, o);
565
- }
566
- }
567
- };
568
- var te = typeof TextEncoder != "undefined" && /*#__PURE__*/ new TextEncoder();
569
- var td = typeof TextDecoder != "undefined" && /*#__PURE__*/ new TextDecoder();
570
- try {
571
- td.decode(et, { stream: true });
572
- } catch (e) {}
573
- /**
574
- * Converts a string into a Uint8Array for use with compression/decompression methods
575
- * @param str The string to encode
576
- * @param latin1 Whether or not to interpret the data as Latin-1. This should
577
- * not need to be true unless decoding a binary string.
578
- * @returns The string encoded in UTF-8/Latin-1 binary
579
- */
580
- function strToU8(str, latin1) {
581
- if (latin1) {
582
- var ar_1 = new u8(str.length);
583
- for (var i = 0; i < str.length; ++i) ar_1[i] = str.charCodeAt(i);
584
- return ar_1;
585
- }
586
- if (te) return te.encode(str);
587
- var l = str.length;
588
- var ar = new u8(str.length + (str.length >> 1));
589
- var ai = 0;
590
- var w = function(v) {
591
- ar[ai++] = v;
592
- };
593
- for (var i = 0; i < l; ++i) {
594
- if (ai + 5 > ar.length) {
595
- var n = new u8(ai + 8 + (l - i << 1));
596
- n.set(ar);
597
- ar = n;
598
- }
599
- var c = str.charCodeAt(i);
600
- if (c < 128 || latin1) w(c);
601
- else if (c < 2048) w(192 | c >> 6), w(128 | c & 63);
602
- else if (c > 55295 && c < 57344) c = 65536 + (c & 1047552) | str.charCodeAt(++i) & 1023, w(240 | c >> 18), w(128 | c >> 12 & 63), w(128 | c >> 6 & 63), w(128 | c & 63);
603
- else w(224 | c >> 12), w(128 | c >> 6 & 63), w(128 | c & 63);
604
- }
605
- return slc(ar, 0, ai);
606
- }
607
- var exfl = function(ex) {
608
- var le = 0;
609
- if (ex) for (var k in ex) {
610
- var l = ex[k].length;
611
- if (l > 65535) err(9);
612
- le += l + 4;
613
- }
614
- return le;
615
- };
616
- var wzh = function(d, b, f, fn, u, c, ce, co) {
617
- var fl = fn.length, ex = f.extra, col = co && co.length;
618
- var exl = exfl(ex);
619
- wbytes(d, b, ce != null ? 33639248 : 67324752), b += 4;
620
- if (ce != null) d[b++] = 20, d[b++] = f.os;
621
- d[b] = 20, b += 2;
622
- d[b++] = f.flag << 1 | (c < 0 && 8), d[b++] = u && 8;
623
- d[b++] = f.compression & 255, d[b++] = f.compression >> 8;
624
- var dt = new Date(f.mtime == null ? Date.now() : f.mtime), y = dt.getFullYear() - 1980;
625
- if (y < 0 || y > 119) err(10);
626
- wbytes(d, b, y << 25 | dt.getMonth() + 1 << 21 | dt.getDate() << 16 | dt.getHours() << 11 | dt.getMinutes() << 5 | dt.getSeconds() >> 1), b += 4;
627
- if (c != -1) {
628
- wbytes(d, b, f.crc);
629
- wbytes(d, b + 4, c < 0 ? -c - 2 : c);
630
- wbytes(d, b + 8, f.size);
631
- }
632
- wbytes(d, b + 12, fl);
633
- wbytes(d, b + 14, exl), b += 16;
634
- if (ce != null) {
635
- wbytes(d, b, col);
636
- wbytes(d, b + 6, f.attrs);
637
- wbytes(d, b + 10, ce), b += 14;
638
- }
639
- d.set(fn, b);
640
- b += fl;
641
- if (exl) for (var k in ex) {
642
- var exf = ex[k], l = exf.length;
643
- wbytes(d, b, +k);
644
- wbytes(d, b + 2, l);
645
- d.set(exf, b + 4), b += 4 + l;
646
- }
647
- if (col) d.set(co, b), b += col;
648
- return b;
649
- };
650
- var wzf = function(o, b, c, d, e) {
651
- wbytes(o, b, 101010256);
652
- wbytes(o, b + 8, c);
653
- wbytes(o, b + 10, c);
654
- wbytes(o, b + 12, d);
655
- wbytes(o, b + 16, e);
656
- };
657
- /**
658
- * Synchronously creates a ZIP file. Prefer using `zip` for better performance
659
- * with more than one file.
660
- * @param data The directory structure for the ZIP archive
661
- * @param opts The main options, merged with per-file options
662
- * @returns The generated ZIP archive
663
- */
664
- function zipSync(data, opts) {
665
- if (!opts) opts = {};
666
- var r = {};
667
- var files = [];
668
- fltn(data, "", r, opts);
669
- var o = 0;
670
- var tot = 0;
671
- for (var fn in r) {
672
- var _a = r[fn], file = _a[0], p = _a[1];
673
- var compression = p.level == 0 ? 0 : 8;
674
- var f = strToU8(fn), s = f.length;
675
- var com = p.comment, m = com && strToU8(com), ms = m && m.length;
676
- var exl = exfl(p.extra);
677
- if (s > 65535) err(11);
678
- var d = compression ? deflateSync(file, p) : file, l = d.length;
679
- var c = crc();
680
- c.p(file);
681
- files.push(mrg(p, {
682
- size: file.length,
683
- crc: c.d(),
684
- c: d,
685
- f,
686
- m,
687
- u: s != fn.length || m && com.length != ms,
688
- o,
689
- compression
690
- }));
691
- o += 30 + s + exl + l;
692
- tot += 76 + 2 * (s + exl) + (ms || 0) + l;
693
- }
694
- var out = new u8(tot + 22), oe = o, cdl = tot - o;
695
- for (var i = 0; i < files.length; ++i) {
696
- var f = files[i];
697
- wzh(out, f.o, f, f.f, f.u, f.c.length);
698
- var badd = 30 + f.f.length + exfl(f.extra);
699
- out.set(f.c, f.o + badd);
700
- wzh(out, o, f, f.f, f.u, f.c.length, f.o, f.m), o += 16 + badd + (f.m ? f.m.length : 0);
701
- }
702
- wzf(out, o, files.length, cdl, oe);
703
- return out;
704
- }
705
- new TextDecoder();
706
- new TextEncoder();
707
- new TextEncoder();
708
- // ../faustwasm-webclap/dist/presets.js
709
- /** The presets file of a patch: beside it, its name with `.presets.json` for `.dsp`. */
710
- var presetsFileOf = (patch) => patch.replace(/\.dsp$/i, "") + ".presets.json";
711
- var NONE = 4294967295;
712
- var INPUTS = /* @__PURE__ */ new Set([
713
- "hslider",
714
- "vslider",
715
- "nentry",
716
- "button",
717
- "checkbox"
718
- ]);
719
- var BARGRAPHS = /* @__PURE__ */ new Set(["hbargraph", "vbargraph"]);
720
- /**
721
- * A module's items of these widgets, each with its path: its groups and its label, `filter/cutoff`. That is its Faust
722
- * address without the patch's own name — libfaust wraps a patch's controls in a root group of that name. A patch whose
723
- * controls all lie in one group of their own has no such wrapper (that group is its root): its paths are whole.
724
- */
725
- function itemsOf(json, widgets) {
726
- const wrapped = json.ui.length === 1 && json.ui[0].label === json.name;
727
- const out = [];
728
- const walk = (items) => {
729
- for (const it of items) if (it.items) walk(it.items);
730
- else if (widgets.has(it.type) && it.index !== void 0) out.push({
731
- ...it,
732
- path: (it.address ?? it.label ?? "").split("/").filter(Boolean).slice(wrapped ? 1 : 0).join("/")
733
- });
734
- };
735
- walk(json.ui);
736
- return out;
737
- }
738
- var inputsOf = (json) => itemsOf(json, INPUTS);
739
- /** A patch's bargraphs (its outputs beside the sound), told the plugin's page: the effect's, then the voice's
740
- * that the effect does not have (faustwasm reads a poly patch's output from its effect when it is there, else voice 0). */
741
- function bargraphsOf(faust, effect) {
742
- const fx = itemsOf(effect, BARGRAPHS);
743
- const fxAt = new Set(fx.map((it) => it.path));
744
- return [...fx.map((it) => ({
745
- target: 1,
746
- it
747
- })), ...itemsOf(faust, BARGRAPHS).filter((it) => !fxAt.has(it.path)).map((it) => ({
748
- target: 0,
749
- it
750
- }))];
751
- }
752
- /**
753
- * A control's CLAP id: a hash (FNV-1a, 32 bits) of its path (itemsOf: without the patch's own name — a renamed patch
754
- * keeps its ids), an effect's marked apart from a voice's. Stable while the control is where it is: automation and
755
- * saved states find it again after the patch changed (a DAW expects that).
756
- */
757
- function paramId(target, path) {
758
- path = (target ? "effect:" : "") + path;
759
- let h = 2166136261;
760
- for (const byte of new TextEncoder().encode(path)) h = Math.imul(h ^ byte, 16777619) >>> 0;
761
- return h;
762
- }
763
- var ends = (it, ...names) => names.some((n) => (it.address ?? "").endsWith("/" + n));
764
- /** What of a patch's controls the adapter plays itself (an instrument's voice) and what it offers the host
765
- * as its params — each with its id. */
766
- function controlsOf(faust, effect, instrument) {
767
- const own = inputsOf(faust);
768
- const find = (pred) => own.find(pred)?.index ?? NONE;
769
- const roles = instrument ? {
770
- freq: find((it) => ends(it, "freq")),
771
- gain: find((it) => ends(it, "gain")),
772
- gate: find((it) => ends(it, "gate")),
773
- key: find((it) => ends(it, "key")),
774
- vel: find((it) => ends(it, "vel", "velocity"))
775
- } : {
776
- freq: NONE,
777
- gain: NONE,
778
- gate: NONE,
779
- key: NONE,
780
- vel: NONE
781
- };
782
- const played = new Set(Object.values(roles));
783
- const params = [
784
- ...own.filter((it) => !played.has(it.index)).map((it) => ({
785
- target: 0,
786
- it
787
- })),
788
- ...inputsOf(effect).map((it) => ({
789
- target: 1,
790
- it
791
- })),
792
- ...bargraphsOf(faust, effect)
793
- ];
794
- if (params.length > 401) throw new Error(`${params.length} controls and bargraphs — a plugin carries at most 401`);
795
- const ids = params.map(({ target, it }) => paramId(target, it.path ?? ""));
796
- const twice = ids.findIndex((id, i) => ids.indexOf(id) !== i);
797
- if (twice >= 0) throw new Error(`two controls share a path — "${params[twice].it.address}"; name them apart`);
798
- return {
799
- roles,
800
- params,
801
- ids
802
- };
803
- }
804
- var pathOf = (it) => it.path ?? "";
805
- /** The groups a control lies in (`hgroup`, `vgroup`, `tgroup`), `a/b` — a host's module of the param. */
806
- var groupOf = (it) => pathOf(it).split("/").slice(0, -1).join("/");
807
- var metaOf = (it, key) => it.meta?.find((m) => key in m)?.[key] ?? "";
808
- /** A control's named values: `[style:menu{'Sine':0;'Saw':1}]` or `[style:radio{…}]` — none for any other. (libfaust's
809
- * wasm backend writes the quotes of its JSON as `-`, as in a soundfile's url.) */
810
- function menuOf(it) {
811
- const found = /^(?:menu|radio) *[{](.*)[}] *$/.exec(metaOf(it, "style").trim());
812
- if (!found) return [];
813
- return found[1].split(";").map((entry) => /^ *['-](.*)['-] *: *([-+0-9.eE]+) *$/.exec(entry)).filter((m) => m !== null).map((m) => ({
814
- label: m[1],
815
- value: Number(m[2])
816
- }));
817
- }
818
- var isToggle = (it) => it.type === "button" || it.type === "checkbox";
819
- var isOutput = (it) => BARGRAPHS.has(it.type ?? "");
820
- var isHidden = (it) => metaOf(it, "hidden").trim() === "1" || !isOutput(it) && (midiBits(it) & 92) !== 0;
821
- /**
822
- * What MIDI a control listens to, as faustwasm reads it (FaustBaseWebAudioDsp.parseUI): `[midi:ctrl N]` or
823
- * `[midi:ctrl N M]` (M a channel 1..16, none: any) — bits 8..15 N + 1, bits 16..23 M; `[midi:pitchwheel]` or
824
- * `[midi:pitchbend]`, with a channel M or not — bit 1, M in bits 16..23 (as the C++ MidiUI reads them; faustwasm dropped
825
- * "pitchwheel M" and did not know "pitchbend" — a fix proposed to faustwasm); `[midi:key N]`,
826
- * `[midi:keyon N]`, `[midi:keyoff N]` (each with a channel M or not) — N and M as a ctrl's, bits 24..25 1, 2, 3 (a patch
827
- * without voices only: faustwasm's poly dsp gives notes to its voices). The first such meta counts. Beside it Faust's
828
- * MIDI sync, played by the host's transport: `[midi:start]` bit 2, `[midi:stop]` bit 3, `[midi:clock]` bit 4,
829
- * `[midi:songpos]` bit 6 (MIDI's Song Position Pointer — proposed to Faust).
830
- */
831
- function midiBits(it) {
832
- let sync = 0;
833
- let bound = 0;
834
- for (const m of it.meta ?? []) {
835
- const midi = m.midi?.trim();
836
- if (midi === void 0) continue;
837
- if (midi === "start") sync |= 4;
838
- else if (midi === "stop") sync |= 8;
839
- else if (midi === "clock") sync |= 16;
840
- else if (midi === "songpos") sync |= 64;
841
- else if (bound) continue;
842
- else if (/^(pitchwheel|pitchbend)(\s+\d+)?(\s|$)/.test(midi)) bound = 2 | Number(/^\S+\s+(\d+)/.exec(midi)?.[1] ?? 0) << 16;
843
- else {
844
- const ctrl = /^ctrl\s(\d+)(?:\s(\d+))?/.exec(midi);
845
- const key = /^(key|keyon|keyoff)\s+(\d+)(?:\s+(\d+))?$/.exec(midi);
846
- if (ctrl) bound = Number(ctrl[1]) + 1 << 8 | Number(ctrl[2] ?? 0) << 16;
847
- else if (key) bound = Number(key[2]) + 1 << 8 | Number(key[3] ?? 0) << 16 | {
848
- key: 1,
849
- keyon: 2,
850
- keyoff: 3
851
- }[key[1]] << 24;
852
- }
853
- }
854
- return sync | bound;
855
- }
856
- /** What a plugin's page needs to know of it — `plugin.json` beside the page: its controls (its CLAP params, their ids
857
- * the host's) and its bargraphs (told the page only), each in the config block's order. */
858
- function pluginDescription(faust, effect, info) {
859
- const { params, ids } = controlsOf(faust, effect, info.voices !== void 0);
860
- return {
861
- id: info.id,
862
- name: info.name,
863
- vendor: info.vendor,
864
- version: info.version,
865
- instrument: info.voices !== void 0 || faust.inputs === 0,
866
- ...info.voices !== void 0 ? { voices: info.voices } : {},
867
- params: params.flatMap(({ it }, i) => isOutput(it) ? [] : [{
868
- id: ids[i],
869
- path: pathOf(it),
870
- group: groupOf(it),
871
- label: it.label ?? "",
872
- address: it.address ?? "",
873
- type: it.type,
874
- min: isToggle(it) ? 0 : it.min ?? 0,
875
- max: isToggle(it) ? 1 : it.max ?? 1,
876
- init: it.init ?? 0,
877
- step: isToggle(it) ? 1 : it.step ?? 0,
878
- unit: metaOf(it, "unit"),
879
- scale: metaOf(it, "scale") === "log" ? "log" : metaOf(it, "scale") === "exp" ? "exp" : "linear",
880
- style: metaOf(it, "style").replace(/[{].*$/, "").trim(),
881
- values: menuOf(it),
882
- hidden: isHidden(it)
883
- }]),
884
- bargraphs: params.flatMap(({ it }, i) => isOutput(it) ? [{
885
- id: ids[i],
886
- path: pathOf(it),
887
- group: groupOf(it),
888
- label: it.label ?? "",
889
- address: it.address ?? "",
890
- type: it.type,
891
- min: it.min ?? 0,
892
- max: it.max ?? 1,
893
- unit: metaOf(it, "unit"),
894
- hidden: isHidden(it)
895
- }] : [])
896
- };
897
- }
898
- // ../faustwasm-webclap/dist/scale.js
899
- var ln = (x) => Math.log(Math.max(Number.EPSILON, x));
900
- var within = (v, min, max) => Math.max(min, Math.min(max, v));
901
- /** The knob's position of a value — the inverse of valueAt. */
902
- function positionOf(value, min, max, scale) {
903
- if (scale === "log" && min > 0 && max > 0) return (ln(within(value, min, max)) - ln(min)) / (ln(max) - ln(min)) || 0;
904
- if (scale === "exp" && min > 0 && max > min) {
905
- const t = (value - min) / (max - min) || 0;
906
- return (within(Math.exp(ln(min) + (ln(max) - ln(min)) * t), min, max) - min) / (max - min) || 0;
907
- }
908
- return (value - min) / (max - min) || 0;
909
- }
910
- // ../faustwasm-webclap/dist/text.js
911
- /**
912
- * A control's value as text, as the plugin writes it (its clap.params value_to_text, adapter/src/params.rs) — for a host's
913
- * own widgets to show what a DAW shows: the step's decimal places, always written (0.710 for 0.71 under a step of 0.001,
914
- * the width steady while a knob turns), a space and the unit. The adapter's rule step by step: the decimals are the
915
- * places of the step (at most 4; no step: 2), the value rounded half away from zero. A menu's entries are named by the
916
- * menu, not here.
917
- */
918
- /** The decimal places a step has — 1 → 0, 0.25 → 2, 0.001 → 3, at most 4; no step (0) as 0.01. */
919
- function decimalsOf(step) {
920
- let d = 0;
921
- let scaled = step > 0 ? step : .01;
922
- while (d < 4 && Math.abs(scaled - Math.round(scaled)) > 1e-9) {
923
- scaled *= 10;
924
- d++;
925
- }
926
- return d;
927
- }
928
- // ../faustwasm-webclap/dist/compile.js
929
- /** Does the source define a top-level `effect` (Faust's poly convention: one effect over the voices' sum)? A look before
930
- * compiling it. A definition inside an environment matches too — then the effect fails to compile and the patch
931
- * plays without it, as in faustwasm. Not seen: an `effect` that only an imported library defines — such an instrument
932
- * plays without it (a known limit: asking the compiler instead aborts libfaust uncatchably on a patch without one). */
933
- function definesEffect(source) {
934
- return /^[ \t]*effect[ \t]*(\(|=)/m.test(source);
935
- }
936
- // ../faustwave-svelte/src/faust/device.ts
937
- var isBargraph = (it) => it.type === "hbargraph" || it.type === "vbargraph";
938
- /** The device's words in a UI tree (several trees: a voice's and an effect's). */
939
- function deviceMeta(...trees) {
940
- const big = /* @__PURE__ */ new Set();
941
- const faders = /* @__PURE__ */ new Set();
942
- const cols = /* @__PURE__ */ new Map();
943
- const monitors = [];
944
- const walk = (items) => {
945
- for (const it of items ?? []) {
946
- if (it.items) walk(it.items);
947
- if (!it.address) continue;
948
- const says = (it.meta ?? []).filter((m) => typeof m.device === "string").map((m) => m.device.trim());
949
- if (says.includes("big")) big.add(it.address);
950
- if (says.includes("fader") || it.type === "vslider") faders.add(it.address);
951
- const col = says.map((s) => /^col:([123])$/.exec(s)?.[1]).find(Boolean);
952
- if (col) cols.set(it.address, Number(col));
953
- const mon = says.map((s) => /^monitor(?::(.+))?$/.exec(s)).find(Boolean);
954
- if (mon && isBargraph(it)) {
955
- const name = (mon[1] ?? "monitor").trim();
956
- let m = monitors.find((x) => x.name === name);
957
- if (!m) monitors.push(m = {
958
- name,
959
- addresses: []
960
- });
961
- if (!m.addresses.includes(it.address)) m.addresses.push(it.address);
962
- if (col && !m.col) m.col = Number(col);
963
- }
964
- }
965
- };
966
- for (const t of trees) walk(t);
967
- return {
968
- big,
969
- faders,
970
- cols,
971
- monitors
972
- };
973
- }
974
- // ../plugin-page/src/index.ts
975
- /** A name as the last part of a plugin id — the IDE's rule (extension-core build.ts idPart: slugify, else "patch"). */
976
- var idPart = (name) => name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "patch";
977
- /** What a patch declares of itself (`declare name "…";` at its top), else null. */
978
- var declaredOf = (source, key) => new RegExp(`^\\s*declare\\s+${key}\\s+"((?:[^"\\\\]|\\\\.)*)"\\s*;`, "m").exec(source)?.[1].trim() || null;
979
- // ../extension-api/src/contentLicence.ts
980
- /**
981
- * The licence of a build's content (docs/EXPORT-FAKTEN-ZIEL.md @982cb10f E5, docs/BUILD-FAKTEN-ZIEL.md @982cb10f — Mani 17.11.: free, the user
982
- * chooses — from the Hub's list of licences, in the Build dialog; it covers the user's project only). What a build carries
983
- * as LICENSE.md: the project's own content (its music, patches, pictures, texts) under the licence chosen — and the
984
- * FaustWave player beside it, which stays proprietary but goes along with it freely.
985
- */
986
- var CONTENT_LICENCES = [
987
- "CC0-1.0",
988
- "CC-BY-4.0",
989
- "CC-BY-SA-4.0",
990
- "MIT",
991
- "Apache-2.0"
992
- ];
993
- var NAMES = {
994
- "CC0-1.0": "CC0 1.0 Universal (public domain dedication)",
995
- "CC-BY-4.0": "Creative Commons Attribution 4.0 International (CC BY 4.0)",
996
- "CC-BY-SA-4.0": "Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)",
997
- MIT: "the MIT License",
998
- "Apache-2.0": "the Apache License, Version 2.0"
999
- };
1000
- /** The licence's name as people read it. */
1001
- var licenceName = (l) => NAMES[l];
1002
- /** LICENSE.md of a build: its content under `licence`, then the player's own terms — or, for a plugin (`plugin`: the
1003
- * third-party notices of its adapter), the adapter's (docs/BUILD-PLUGIN-FAKTEN-ZIEL.md @d0036b98 D6: the player's wording, until
1004
- * Mani's). */
1005
- function licenceNotice(o) {
1006
- const who = o.author?.trim() || `the author of ${o.title}`;
1007
- const what = o.plugin ? "its patch, compiled into this plugin" : "its music, patches, pictures and texts, in `faustwave.project`";
1008
- const lines = [
1009
- `# ${o.title} — licence`,
1010
- "",
1011
- `The content of ${o.title} — ${what} — is licensed under ${NAMES[o.licence]}.`,
1012
- ""
1013
- ];
1014
- if (o.licence === "CC0-1.0") lines.push(`To the extent possible under law, ${who} has waived all copyright and related or neighbouring rights to it.`, "Legal code: https://creativecommons.org/publicdomain/zero/1.0/legalcode");
1015
- else if (o.licence === "CC-BY-4.0") lines.push(`© ${o.year} ${who}. You may share and adapt it for any purpose, even commercially, if you give appropriate credit, provide`, "a link to the licence, and indicate if changes were made.", "Legal code: https://creativecommons.org/licenses/by/4.0/legalcode");
1016
- else if (o.licence === "CC-BY-SA-4.0") lines.push(`© ${o.year} ${who}. You may share and adapt it for any purpose, even commercially, if you give appropriate credit, provide`, "a link to the licence, indicate if changes were made — and distribute what you make of it under the same licence.", "Legal code: https://creativecommons.org/licenses/by-sa/4.0/legalcode");
1017
- else if (o.licence === "Apache-2.0") lines.push(`Copyright ${o.year} ${who}`, "", "Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use these files except in compliance with", "the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 — unless required by", "applicable law or agreed to in writing, they are distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF", "ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations.");
1018
- else lines.push("```", `Copyright (c) ${o.year} ${who}`, "", "Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated", "documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the", "rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit", "persons to whom the Software is furnished to do so, subject to the following conditions:", "", "The above copyright notice and this permission notice shall be included in all copies or substantial portions of the", "Software.", "", "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE", "WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR", "COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR", "OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.", "```");
1019
- if (o.plugin) {
1020
- lines.push("", "## The FaustWave plugin adapter", "", "The rest of this plugin is the FaustWave adapter that plays the patch as a CLAP plugin. It is not covered by the licence", `above: © ${o.year} Mani Weber, all rights reserved. You may pass it on unchanged together with this content, free of`, "charge; you may not modify it or distribute it on its own. The open-source components inside it keep their own", "licences — they follow.", "", o.plugin.notices.trim(), "");
1021
- return lines.join("\n");
1022
- }
1023
- lines.push("", "## The FaustWave player", "", "The other files of this folder are the FaustWave player that plays it. They are not covered by the licence above:", `© ${o.year} Mani Weber, all rights reserved. You may pass them on unchanged together with this content, free of charge;`, "you may not modify them or distribute them on their own. The open-source components inside them keep their own", "licences — see THIRD-PARTY-NOTICES.md. What it uses of others, and their licences: CREDITS.md.", "");
1024
- return lines.join("\n");
1025
- }
1026
- // ../extension-stage/src/stage/share.ts
1027
- var shareOf = (p, value) => p.max === p.min ? 0 : Math.min(1, Math.max(0, positionOf(value, p.min, p.max, p.scale ?? "linear")));
1028
- // ../extension-stage/src/stage/device/name.ts
1029
- /** Where a patch's device stage lives — `<patch>-device.world` and `<patch>-device.stage` beside it. ONE place: the
1030
- * command that makes it (stage.device.create) and the kind that names it the page of the patch's plugin
1031
- * (DocumentKindDef.pluginPageFor) — the core used to spell the convention itself (review R7). */
1032
- function deviceStageOf(patchRef) {
1033
- const name = patchRef.replace(/^.*\//, "").replace(/\.[^.]+$/, "");
1034
- return {
1035
- world: `asset:assets/${name}-device.world`,
1036
- stage: `asset:assets/${name}-device.stage`
1037
- };
1038
- }
1039
- // ../extension-stage/src/stage/device/device.ts
1040
- /**
1041
- * A device stage made from a patch's knobs (docs/AUDIO-CLAP-FAKTEN-ZIEL.md §2.4, part 4): a dark panel seen from the
1042
- * front (the camera straight above it, as one looks at a hardware synth), laid out from the patch itself —
1043
- *
1044
- * - a bar along the top: the patch's name, the four meters (level and the three bands, scene quantities a cable from
1045
- * the analysis moves) and a lamp for each of its other bargraph outputs;
1046
- * - three columns: the plugin's pages (its groups — W5), each a section under its name, four knobs a row, and its
1047
- * monitors — lines through its bargraphs marked [device:monitor:<name>], in their order, on a screen under the name;
1048
- * a page or a monitor marked [device:col:1|2|3] stands in that column (left, middle, right), else the monitors in the
1049
- * middle and the pages left and right, each to the side less filled;
1050
- * - along the bottom the pages that hold a knob marked [device:big], their knobs large (macros).
1051
- *
1052
- * A knob has a ring that lights the way it has turned; a vslider (or a control marked [device:fader]) is a fader.
1053
- *
1054
- * Each knob is a model grabbed and turned (the world's "grab" and "follows"), the knob of one param of the patch (the
1055
- * stage's "knobs"). Only the world's and the stage's own words: nothing here draws.
1056
- */
1057
- /** The parts the device is made of (built by tools/props-build.mjs, in this folder). */
1058
- var DEVICE_PARTS = [
1059
- "device-panel.glb",
1060
- "device-knob.glb",
1061
- "device-meter.glb",
1062
- "device-fader.glb",
1063
- "device-button.glb"
1064
- ];
1065
- /** The meters: scene quantities, each moved by the analysis output of the same name. */
1066
- var DEVICE_METERS = [
1067
- "level",
1068
- "low",
1069
- "mid",
1070
- "high"
1071
- ];
1072
- /** A monitor's points as scene quantities: the n-th monitor's k-th point. */
1073
- var monitorPoint = (n, k) => `w${n + 1}-${k + 1}`;
1074
- /** The meters' names under them. */
1075
- var METER_NAMES = {
1076
- level: "LVL",
1077
- low: "LO",
1078
- mid: "MID",
1079
- high: "HI"
1080
- };
1081
- /** A knob's name as it reads: the param's last name, its underscores spaces, a dozen letters at most. */
1082
- var nameOf = (param) => param.replace(/^.*\//, "").replace(/_/g, " ").slice(0, 12);
1083
- /** A page's or a monitor's name as it reads: its underscores spaces. */
1084
- var headOf = (name) => name.replace(/_/g, " ").replace(/\//g, " › ").slice(0, 18);
1085
- /** Its value's digits: fewer the wider its range. */
1086
- var digitsOf = (k) => Math.abs(k.max - k.min) >= 100 ? 0 : Math.abs(k.max - k.min) >= 10 ? 1 : 2;
1087
- /** Places a page has: eight (a remote-controls page). */
1088
- var ROW = 8;
1089
- /** Knobs side by side in a section. */
1090
- var COLS = 4;
1091
- /** A panel tile (metres, as device-panel.glb). */
1092
- var TILE = [.12, .16];
1093
- /** A knob's place in a section, across and down; a large one's; a section's title; the room between sections. */
1094
- var CELL = [.12, .15];
1095
- var BIG = [.2, .2];
1096
- var BIG_SCALE = 1.6;
1097
- var TITLE = .05;
1098
- var GAP = .06;
1099
- var MARGIN = .06;
1100
- /** The bar along the top. */
1101
- var TOP = .11;
1102
- /** A monitor in the middle: its width, its screen's height. */
1103
- var MONITOR = [.84, .3];
1104
- /** The panel's surface (its tiles' top): what lies on it lies a hair above. */
1105
- var ON = .021;
1106
- /** The preset buttons: this far left and right of the name's middle (about 15 letters of it between them). */
1107
- var PRESET_HALF = .16;
1108
- /** The title's letters: their height, and about how wide a letter is of it (Inter, measured on the picture: 13 letters
1109
- * of 0.032 took 0.31 m). */
1110
- var TITLE_SIZE = .032;
1111
- var LETTER = .75;
1112
- var round = (v) => Math.round(v * 1e3) / 1e3;
1113
- /** The device's view across, degrees; the picture's shape it is laid out for (a plugin's window, 16:9). */
1114
- var ACROSS = 52;
1115
- var ASPECT = 16 / 9;
1116
- /** A page as a section: its places used, its rows, its size. */
1117
- function sectionOf(page, index) {
1118
- const used = page.knobs.slice(0, ROW).reduce((n, k, i) => k ? i + 1 : n, 0);
1119
- const big = page.knobs.some((k) => k?.big);
1120
- const [cw, ch] = big ? BIG : CELL;
1121
- const cols = Math.max(1, Math.min(COLS, used));
1122
- const rows = Math.max(1, Math.ceil(used / COLS));
1123
- const col = page.knobs.find((k) => k?.col)?.col;
1124
- return {
1125
- kind: "page",
1126
- page,
1127
- index,
1128
- used,
1129
- big,
1130
- cell: [cw, ch],
1131
- w: cols * cw,
1132
- h: TITLE + rows * ch,
1133
- ...col ? { col } : {}
1134
- };
1135
- }
1136
- /** The .world and the .stage of a device for `patch` (its file, asset:assets/<name>) — `world` its own file's ref; its
1137
- * pages a section each; `lamps` its other bargraph outputs, each a bar beside the meters (scene quantity m1, m2 …). */
1138
- function deviceStage(patch, world, pages, lamps = [], look = {}) {
1139
- const knobs = pages.flatMap((p) => [...p.knobs.slice(0, ROW), ...Array(ROW - Math.min(ROW, p.knobs.length)).fill(null)]);
1140
- const sections = pages.map(sectionOf).filter((s) => s.used > 0);
1141
- const bigs = sections.filter((s) => s.big);
1142
- const monitors = (look.monitors ?? []).filter((m) => m.points >= 2);
1143
- const cols = {
1144
- 1: [],
1145
- 2: [],
1146
- 3: []
1147
- };
1148
- const heightOf = (c) => c.reduce((h, s, i) => h + s.h + (i ? GAP : 0), 0);
1149
- const monitorItems = monitors.map((m, index) => ({
1150
- kind: "monitor",
1151
- monitor: m,
1152
- index,
1153
- w: m.col && m.col !== 2 ? COLS * CELL[0] : MONITOR[0],
1154
- h: TITLE + MONITOR[1],
1155
- ...m.col ? { col: m.col } : {}
1156
- }));
1157
- for (const it of [...monitorItems, ...sections.filter((s) => !s.big)].filter((it) => it.col)) cols[it.col].push(it);
1158
- for (const m of monitorItems.filter((m) => !m.col)) cols[2].push(m);
1159
- for (const s of sections.filter((s) => !s.big && !s.col)) cols[heightOf(cols[3]) < heightOf(cols[1]) ? 3 : 1].push(s);
1160
- const used = [
1161
- 1,
1162
- 2,
1163
- 3
1164
- ].filter((c) => cols[c].length);
1165
- const widthOf = (c) => Math.max(c === 2 ? 0 : COLS * CELL[0], ...cols[c].map((it) => it.w));
1166
- const middleW = used.reduce((w, c, i) => w + widthOf(c) + (i ? GAP : 0), 0);
1167
- const middleH = Math.max(0, ...used.map((c) => heightOf(cols[c])));
1168
- const bottomW = bigs.reduce((w, s, i) => w + s.w + (i ? GAP : 0), 0);
1169
- const bottomH = Math.max(0, ...bigs.map((s) => s.h));
1170
- const title = (look.title ?? patch.replace(/^.*\//, "").replace(/\.dsp$/, "")).slice(0, 24);
1171
- const titleW = title.length * TITLE_SIZE * LETTER;
1172
- const barsW = (DEVICE_METERS.length + lamps.length - 1) * .05 + .035;
1173
- const presetsW = look.presets ? .48 : 0;
1174
- const across = Math.ceil((Math.max(middleW, bottomW, .2 + lamps.length * .05 + .3, titleW + presetsW + barsW) + 2 * MARGIN) / TILE[0]);
1175
- const down = Math.ceil((.16999999999999998 + (middleH ? GAP + middleH : 0) + (bigs.length ? GAP + bottomH : 0) + MARGIN) / TILE[1]);
1176
- const [w, d] = [across * TILE[0], down * TILE[1]];
1177
- const models = [];
1178
- for (let row = 0; row < down; row++) for (let col = 0; col < across; col++) models.push({
1179
- name: `panel-${row * across + col + 1}`,
1180
- src: "asset:assets/device-panel.glb",
1181
- at: [
1182
- round(-w / 2 + (col + .5) * TILE[0]),
1183
- 0,
1184
- round(-d / 2 + (row + .5) * TILE[1])
1185
- ]
1186
- });
1187
- const texts = [];
1188
- const traces = [];
1189
- const rings = [];
1190
- const top = -d / 2 + MARGIN;
1191
- texts.push({
1192
- name: "title",
1193
- text: title,
1194
- at: [
1195
- round(-w / 2 + MARGIN),
1196
- ON,
1197
- round(top + TOP * .55)
1198
- ],
1199
- size: TITLE_SIZE,
1200
- align: "left",
1201
- lie: true
1202
- });
1203
- const bars = [...DEVICE_METERS.map((m) => ({
1204
- name: `meter-${m}`,
1205
- value: m,
1206
- label: METER_NAMES[m],
1207
- textName: `meter-name-${m}`,
1208
- color: void 0
1209
- })), ...lamps.map((l, k) => ({
1210
- name: `lamp-${k + 1}`,
1211
- value: `m${k + 1}`,
1212
- label: l.label.slice(0, 6),
1213
- textName: `lamp-name-${k + 1}`,
1214
- color: "#35d6ff"
1215
- }))];
1216
- if (look.presets) {
1217
- const z = round(top + TOP * .55);
1218
- const x = round((-w / 2 + MARGIN + titleW + (w / 2 - MARGIN - barsW)) / 2);
1219
- texts.push({
1220
- name: "preset",
1221
- says: "preset",
1222
- at: [
1223
- x,
1224
- ON,
1225
- z
1226
- ],
1227
- size: .022,
1228
- align: "center",
1229
- lie: true
1230
- });
1231
- models.push({
1232
- name: "preset-prev",
1233
- src: "asset:assets/device-button.glb",
1234
- at: [
1235
- round(x - PRESET_HALF),
1236
- .02,
1237
- z
1238
- ],
1239
- turn: 180,
1240
- press: "preset-prev"
1241
- });
1242
- models.push({
1243
- name: "preset-next",
1244
- src: "asset:assets/device-button.glb",
1245
- at: [
1246
- round(x + PRESET_HALF),
1247
- .02,
1248
- z
1249
- ],
1250
- press: "preset-next"
1251
- });
1252
- }
1253
- bars.forEach((b, k) => {
1254
- const bx = round(w / 2 - MARGIN - (bars.length - 1 - k) * .05 - .02);
1255
- models.push({
1256
- name: b.name,
1257
- src: "asset:assets/device-meter.glb",
1258
- at: [
1259
- bx,
1260
- .02,
1261
- round(top + TOP * .35)
1262
- ],
1263
- follows: [{
1264
- value: b.value,
1265
- moves: "grow",
1266
- part: "bar"
1267
- }]
1268
- });
1269
- texts.push({
1270
- name: b.textName,
1271
- text: b.label,
1272
- at: [
1273
- bx,
1274
- ON,
1275
- round(top + TOP * .35 + .045)
1276
- ],
1277
- size: .009,
1278
- ...b.color ? { color: b.color } : {},
1279
- lie: true
1280
- });
1281
- });
1282
- const place = (s, x0, z0) => {
1283
- texts.push({
1284
- name: `page-${s.index + 1}`,
1285
- text: headOf(s.page.name || ""),
1286
- at: [
1287
- round(x0),
1288
- ON,
1289
- round(z0 + TITLE * .6)
1290
- ],
1291
- size: .016,
1292
- color: "#8b93a7",
1293
- align: "left",
1294
- lie: true
1295
- });
1296
- s.page.knobs.slice(0, ROW).forEach((knob, slot) => {
1297
- if (!knob) return;
1298
- const k = s.index * ROW + slot;
1299
- const value = `k${k + 1}`;
1300
- const [cw, ch] = s.cell;
1301
- const kx = round(x0 + (slot % COLS + .5) * cw);
1302
- const kz = round(z0 + TITLE + (Math.floor(slot / COLS) + .5) * ch);
1303
- const scale = s.big ? BIG_SCALE : 1;
1304
- if (knob.fader) {
1305
- texts.push({
1306
- name: `name-${k + 1}`,
1307
- text: nameOf(knob.param),
1308
- at: [
1309
- kx,
1310
- ON,
1311
- round(kz - .066)
1312
- ],
1313
- size: .013,
1314
- lie: true
1315
- });
1316
- texts.push({
1317
- name: `value-${k + 1}`,
1318
- value: {
1319
- of: value,
1320
- from: knob.min,
1321
- to: knob.max,
1322
- digits: knob.step !== void 0 ? decimalsOf(knob.step) : digitsOf(knob),
1323
- ...knob.unit ? { unit: knob.unit } : {},
1324
- ...knob.scale ? { scale: knob.scale } : {}
1325
- },
1326
- at: [
1327
- kx,
1328
- ON,
1329
- round(kz + .07)
1330
- ],
1331
- size: .011,
1332
- color: "#35d6ff",
1333
- lie: true
1334
- });
1335
- models.push({
1336
- name: `knob-${k + 1}`,
1337
- src: "asset:assets/device-fader.glb",
1338
- at: [
1339
- kx,
1340
- .02,
1341
- kz
1342
- ],
1343
- grab: { value },
1344
- follows: [{
1345
- value,
1346
- moves: "slide",
1347
- part: "cap",
1348
- from: 0,
1349
- to: -.1
1350
- }]
1351
- });
1352
- return;
1353
- }
1354
- rings.push({
1355
- name: `ring-${k + 1}`,
1356
- value,
1357
- at: [
1358
- kx,
1359
- ON,
1360
- kz
1361
- ],
1362
- radius: round(.043 * scale),
1363
- lie: true
1364
- });
1365
- texts.push({
1366
- name: `name-${k + 1}`,
1367
- text: nameOf(knob.param),
1368
- at: [
1369
- kx,
1370
- ON,
1371
- round(kz - .055 * scale)
1372
- ],
1373
- size: .013 * (s.big ? 1.25 : 1),
1374
- lie: true
1375
- });
1376
- texts.push({
1377
- name: `value-${k + 1}`,
1378
- value: {
1379
- of: value,
1380
- from: knob.min,
1381
- to: knob.max,
1382
- digits: knob.step !== void 0 ? decimalsOf(knob.step) : digitsOf(knob),
1383
- ...knob.unit ? { unit: knob.unit } : {},
1384
- ...knob.scale ? { scale: knob.scale } : {}
1385
- },
1386
- at: [
1387
- kx,
1388
- ON,
1389
- round(kz + .05 * scale)
1390
- ],
1391
- size: .011 * (s.big ? 1.25 : 1),
1392
- color: "#35d6ff",
1393
- lie: true
1394
- });
1395
- models.push({
1396
- name: `knob-${k + 1}`,
1397
- src: "asset:assets/device-knob.glb",
1398
- at: [
1399
- kx,
1400
- .02,
1401
- kz
1402
- ],
1403
- ...s.big ? { scale: BIG_SCALE } : {},
1404
- grab: { value },
1405
- follows: [{
1406
- value,
1407
- moves: "turn",
1408
- from: 135,
1409
- to: -135
1410
- }]
1411
- });
1412
- });
1413
- };
1414
- const show = (m, x0, z0, width) => {
1415
- texts.push({
1416
- name: `monitor-name-${m.index + 1}`,
1417
- text: headOf(m.monitor.name),
1418
- at: [
1419
- round(x0),
1420
- ON,
1421
- round(z0 + TITLE * .6)
1422
- ],
1423
- size: .016,
1424
- color: "#8b93a7",
1425
- align: "left",
1426
- lie: true
1427
- });
1428
- traces.push({
1429
- name: `monitor-${m.index + 1}`,
1430
- values: Array.from({ length: m.monitor.points }, (_, k) => monitorPoint(m.index, k)),
1431
- at: [
1432
- round(x0 + width / 2),
1433
- ON,
1434
- round(z0 + TITLE + MONITOR[1] / 2)
1435
- ],
1436
- width: round(width * .94),
1437
- height: round(MONITOR[1] * .86),
1438
- screen: "#05070c",
1439
- lie: true
1440
- });
1441
- };
1442
- const middleZ = top + TOP + GAP;
1443
- let x = -middleW / 2;
1444
- for (const c of used) {
1445
- const cw = widthOf(c);
1446
- let z = middleZ;
1447
- for (const it of cols[c]) {
1448
- if (it.kind === "page") place(it, x, z);
1449
- else show(it, x, z, cw);
1450
- z += it.h + GAP;
1451
- }
1452
- x += cw + GAP;
1453
- }
1454
- let bx = -bottomW / 2;
1455
- for (const s of bigs) {
1456
- place(s, bx, middleZ + (middleH ? middleH + GAP : 0));
1457
- bx += s.w + GAP;
1458
- }
1459
- const half = Math.tan(ACROSS * Math.PI / 360);
1460
- return {
1461
- world: {
1462
- format: "world",
1463
- camera: {
1464
- at: [
1465
- 0,
1466
- round(Math.max(w * 1.06 / 2 / half, d * 1.06 / 2 / (half / ASPECT))),
1467
- .001
1468
- ],
1469
- look: [
1470
- 0,
1471
- 0,
1472
- 0
1473
- ],
1474
- fovAcross: ACROSS
1475
- },
1476
- look: {
1477
- sky: "#0b0c10",
1478
- ambient: {
1479
- sky: "#c8d2ff",
1480
- ground: "#202028",
1481
- strength: 2.5
1482
- },
1483
- sun: {
1484
- color: "#ffffff",
1485
- strength: 3,
1486
- from: [
1487
- -1,
1488
- 3,
1489
- 2
1490
- ]
1491
- },
1492
- bloom: {
1493
- strength: .45,
1494
- radius: .3,
1495
- threshold: .8
1496
- }
1497
- },
1498
- models,
1499
- texts,
1500
- ...traces.length ? { traces } : {},
1501
- ...rings.length ? { rings } : {}
1502
- },
1503
- stage: {
1504
- format: "stage",
1505
- follow: true,
1506
- fps: 60,
1507
- scene: {
1508
- ...Object.fromEntries(knobs.flatMap((k, i) => k ? [[`k${i + 1}`, round(k.start)]] : [])),
1509
- ...Object.fromEntries(DEVICE_METERS.map((m) => [m, 0])),
1510
- ...Object.fromEntries(lamps.map((_, i) => [`m${i + 1}`, 0])),
1511
- ...Object.fromEntries(monitors.flatMap((m, n) => Array.from({ length: m.points }, (_, k) => [monitorPoint(n, k), 0])))
1512
- },
1513
- knobs: Object.fromEntries(knobs.flatMap((k, i) => k ? [[`k${i + 1}`, {
1514
- doc: patch,
1515
- param: k.param
1516
- }]] : [])),
1517
- elements: [{
1518
- name: "device",
1519
- type: "world",
1520
- src: world
1521
- }]
1522
- }
1523
- };
1524
- }
1525
- /** What the patch says of its device in its controls' metadata — [device:big], [device:fader], [device:col:N],
1526
- * [device:monitor:<name>] — read by the one reader its 2D layout uses too (faustwave-svelte faust/device.ts,
1527
- * docs/PLUGIN-OBERFLAECHE-FAKTEN-ZIEL.md E1), from its compiled parts' JSON (the voice's and the effect's) — none when the
1528
- * kind has no parts. */
1529
- function deviceMetaOf(jsons) {
1530
- return deviceMeta(...jsons.flatMap((j) => {
1531
- try {
1532
- return [JSON.parse(j).ui ?? []];
1533
- } catch {
1534
- return [];
1535
- }
1536
- }));
1537
- }
1538
- /**
1539
- * The device of a patch (what stage.device.create makes, docs/AUDIO-CLAP-FAKTEN-ZIEL.md §2.4) from what is known of
1540
- * it — pure, for every maker (docs/PLUGIN-OBERFLAECHE-FAKTEN-ZIEL.md E5): the IDE's action, which asks the playing patch
1541
- * and plugs the cables itself, and the website's WebCLAP editor, which asks its plugin. `pages` its plugin's knob pages
1542
- * (clap.remote-controls — each a name and its params' paths, null an empty place), `params` its params, `meta` its
1543
- * controls' device words (deviceMetaOf), `outputs` its bargraph outputs (their ids as the -mod source names them, their
1544
- * labels), `presets` whether it has some. Its world and stage, their refs, and the cables they want.
1545
- */
1546
- function deviceOfPatch(i) {
1547
- const { world: worldRef, stage: stageRef } = deviceStageOf(i.patch);
1548
- const byPath = new Map(i.params.map((p) => [p.path, p]));
1549
- const pages = i.pages.map((pg) => ({
1550
- name: pg.name,
1551
- knobs: pg.params.map((path) => {
1552
- const p = path === null ? void 0 : byPath.get(path);
1553
- return p ? {
1554
- param: p.path,
1555
- start: shareOf(p, p.value),
1556
- min: p.min,
1557
- max: p.max,
1558
- ...p.scale ? { scale: p.scale } : {},
1559
- ...p.step !== void 0 ? { step: p.step } : {},
1560
- ...p.unit ? { unit: p.unit } : {},
1561
- ...i.meta.big.has(p.path) ? { big: true } : {},
1562
- ...i.meta.faders.has(p.path) ? { fader: true } : {},
1563
- ...i.meta.cols.has(p.path) ? { col: i.meta.cols.get(p.path) } : {}
1564
- } : null;
1565
- })
1566
- }));
1567
- const isAt = (o, a) => o.id === a || o.label === a;
1568
- const monitorOuts = i.meta.monitors.map((m) => ({
1569
- ...m,
1570
- outs: m.addresses.flatMap((a) => i.outputs.filter((o) => isAt(o, a)).slice(0, 1)).slice(0, 64)
1571
- })).filter((m) => m.outs.length >= 2);
1572
- const onMonitor = new Set(monitorOuts.flatMap((m) => m.outs));
1573
- const outs = i.outputs.filter((o) => !onMonitor.has(o)).slice(0, 8);
1574
- const lampName = (o) => o.label.replace(/^.*\//, "");
1575
- const title = i.patch.replace(/^.*\//, "").replace(/\.dsp$/, "");
1576
- const { world, stage } = deviceStage(i.patch, worldRef, pages, outs.map((o) => ({ label: lampName(o) })), {
1577
- title,
1578
- monitors: monitorOuts.map((m) => ({
1579
- name: m.name,
1580
- points: m.outs.length,
1581
- ...m.col ? { col: m.col } : {}
1582
- })),
1583
- presets: i.presets
1584
- });
1585
- return {
1586
- world,
1587
- stage,
1588
- worldRef,
1589
- stageRef,
1590
- cables: [
1591
- ...DEVICE_METERS.map((m) => ({
1592
- from: "analysis",
1593
- port: m,
1594
- to: `/stage/scene/${m}`
1595
- })),
1596
- ...outs.map((o, k) => ({
1597
- from: "patch",
1598
- port: o.id,
1599
- to: `/stage/scene/m${k + 1}`
1600
- })),
1601
- ...monitorOuts.flatMap((m, n) => m.outs.map((o, k) => ({
1602
- from: "patch",
1603
- port: o.id,
1604
- to: `/stage/scene/${monitorPoint(n, k)}`
1605
- })))
1606
- ],
1607
- knobs: pages.flatMap((pg) => pg.knobs.filter((k) => k !== null)),
1608
- lamps: outs.map((o) => ({
1609
- id: o.id,
1610
- label: lampName(o)
1611
- })),
1612
- monitors: monitorOuts.map((m) => ({
1613
- name: m.name,
1614
- points: m.outs.length
1615
- }))
1616
- };
1617
- }
1618
- // ../faust-clap/src/parts.ts
1619
- /**
1620
- * A patch's plugin parts as a host of the IDE hands them over (its kind's pluginParts: the two Faust modules, their JSON
1621
- * as text, the voices, the decoded samples by name) — checked, and made into the module the engine plays, by
1622
- * faustwasm-webclap (docs/AUDIO-WEBCLAP-UMSTIEG-FAKTEN-ZIEL.md). One way for the desktop (main) and the browser IDE (its
1623
- * electronAPI stand-in): the same parts, the same module. What FaustWave reads of a patch beside faustwasm-webclap's
1624
- * description is found here: its bargraphs — told the plugin's page, no params — as modulation sources (each but the hidden
1625
- * ones, Faust's `[hidden:1]`), and the controls the transport plays (`[midi:start]`/`[midi:stop]`/`[midi:clock]` — the
1626
- * plugin plays them itself) left out of what a hand turns.
1627
- */
1628
- /** The Faust addresses of the items of `json` `is` takes. */
1629
- function taggedIn(json, is) {
1630
- const found = /* @__PURE__ */ new Set();
1631
- const walk = (items) => {
1632
- if (!Array.isArray(items)) return;
1633
- for (const it of items) {
1634
- if (it.address && is(it)) found.add(it.address);
1635
- walk(it.items);
1636
- }
1637
- };
1638
- walk(json.ui);
1639
- return found;
1640
- }
1641
- /** The port a meter bargraph is (`fwmeter level` …: faust-runtime meters.ts names them so, hidden), by its label. */
1642
- var meterPortOf = (label) => /^fwmeter (\w+)$/.exec(label)?.[1] ?? null;
1643
- /** Played by the host's transport (`[midi:start]`, stop, clock, songpos) — as the plugin reads it (midiBits; a regex of
1644
- * its own here took "start 3" too, review R9#6). */
1645
- var transportPlayed = (it) => (midiBits(it) & 92) !== 0;
1646
- /** What FaustWave reads of a plugin made of `faust` and `effect`. */
1647
- function patchSides(faust, effect, voices) {
1648
- const d = pluginDescription(faust, effect, {
1649
- id: "x",
1650
- name: "x",
1651
- vendor: "x",
1652
- version: "0",
1653
- ...voices ? { voices } : {}
1654
- });
1655
- const tagged = (is) => /* @__PURE__ */ new Set([...taggedIn(faust, is), ...taggedIn(effect, is)]);
1656
- const played = tagged(transportPlayed);
1657
- const outputs = d.bargraphs;
1658
- return {
1659
- params: d.params.filter((p) => !played.has(p.address)).map((p) => ({
1660
- path: p.address,
1661
- id: p.id,
1662
- min: p.min,
1663
- max: p.max,
1664
- init: p.init,
1665
- ...p.scale !== "linear" ? { scale: p.scale } : {}
1666
- })),
1667
- modouts: outputs.filter((b) => !b.hidden).map((b) => ({
1668
- address: b.address,
1669
- label: b.label || b.address,
1670
- id: b.id
1671
- })),
1672
- meters: Object.fromEntries(outputs.flatMap((b) => meterPortOf(b.label) ? [[meterPortOf(b.label), b.id]] : []))
1673
- };
1674
- }
1675
- // \0pagekit-not-here
1676
- var require__pagekit_not_here = /* @__PURE__ */ __commonJSMin((() => {
1677
- throw new Error("An extension is not part of the page kit.");
1678
- }));
1679
- // ../extension-core/src/extension.ts
1680
- /**
1681
- * The core extension (docs/PLUGIN-STRUKTUR-FAKTEN-ZIEL.md @982cb10f) — its kernel: the transport and dsp.* actions.
1682
- * Its studio is `./studio`, apart: a player imports this file and must not see the studio's `import()`.
1683
- */
1684
- var extension$6 = {
1685
- id: "core",
1686
- kernel: () => Promise.resolve().then(() => /* @__PURE__ */ __toESM(require__pagekit_not_here(), 1)).then((m) => m.activateCoreRuntime)
1687
- };
1688
- // ../extension-dsp-builder/src/extension.ts
1689
- /**
1690
- * The dsp-builder plugin (docs/PLUGIN-STRUKTUR-FAKTEN-ZIEL.md @982cb10f) — its kernel: the .builder kind and its runtime, the node packs' kinds.
1691
- * Its studio is `./studio`, apart: a player imports this file and must not see the studio's `import()`.
1692
- */
1693
- var extension$5 = {
1694
- id: "dsp-builder",
1695
- kernel: () => Promise.resolve().then(() => /* @__PURE__ */ __toESM(require__pagekit_not_here(), 1)).then((m) => m.activateBuilderRuntime),
1696
- usedBy: builderUsedBy
1697
- };
1698
- /** A player whose documents are not all known (a game opens its levels as it plays) may open a patch of the Builder
1699
- * any time; a plugin's page only when one of its two documents is one (docs/PLAYER-PAKETE-FAKTEN-ZIEL.md S4). */
1700
- function builderUsedBy({ workspace, complete }) {
1701
- if (!complete) return true;
1702
- return (Array.isArray(workspace.documents) ? workspace.documents : []).some((d) => !!d && typeof d === "object" && d.type === "builder");
1703
- }
1704
- // ../extension-editors/src/extension.ts
1705
- /**
1706
- * The editors extension (docs/PLUGIN-STRUKTUR-FAKTEN-ZIEL.md @982cb10f) — its kernel: the .dsp kind and its runtime.
1707
- * Its studio is `./studio`, apart: a player imports this file and must not see the studio's `import()`.
1708
- */
1709
- var extension$4 = {
1710
- id: "editors",
1711
- kernel: () => Promise.resolve().then(() => /* @__PURE__ */ __toESM(require__pagekit_not_here(), 1)).then((m) => m.activateEditorsRuntime)
1712
- };
1713
- // ../extension-midi-sources/src/extension.ts
1714
- /**
1715
- * The midi-sources extension (docs/PLUGIN-STRUKTUR-FAKTEN-ZIEL.md @982cb10f) — its kernel: the .performer kind, the keyboard and performer sources, conducting.
1716
- * Its studio is `./studio`, apart: a player imports this file and must not see the studio's `import()`.
1717
- */
1718
- var extension$3 = {
1719
- id: "midi-sources",
1720
- kernel: () => Promise.resolve().then(() => /* @__PURE__ */ __toESM(require__pagekit_not_here(), 1)).then((m) => m.activateMidiSourcesRuntime),
1721
- usedBy: midiSourcesUsedBy
1722
- };
1723
- /** The sequencer plugin, apart from the rest of the package (docs/PLUGIN-STRUKTUR-FAKTEN-ZIEL.md @982cb10f E2): its kernel plays
1724
- * a project's sequencers. Its studio is `sequencerStudio` in ./studio. */
1725
- var sequencerExtension = {
1726
- id: "sequencer",
1727
- kernel: () => Promise.resolve().then(() => /* @__PURE__ */ __toESM(require__pagekit_not_here(), 1)).then((m) => m.activateSequencerKernel),
1728
- usedBy: sequencerUsedBy
1729
- };
1730
- /** The pads extension: its kernel plays what the pads send with no hand on them (modulation onto a knob). Its studio is
1731
- * `padsStudio` in ./studio. */
1732
- var padsExtension = {
1733
- id: "pads",
1734
- kernel: () => Promise.resolve().then(() => /* @__PURE__ */ __toESM(require__pagekit_not_here(), 1)).then((m) => m.activatePadsKernel),
1735
- usedBy: padsUsedBy
1736
- };
1737
- var arr = (v) => Array.isArray(v) ? v.filter((x) => !!x && typeof x === "object") : [];
1738
- /** A project plays its sequencer when one of its steps is more than a rest (a note, a chord, a param value). */
1739
- function sequencerUsedBy({ project }) {
1740
- return (project.sequencer && typeof project.sequencer === "object" ? Object.values(project.sequencer) : []).some((inst) => arr(inst?.tracks).some((t) => arr(t.patterns).some((p) => arr(p.steps).some((s) => !(s.type === "note" && s.kind === "rest")))));
1741
- }
1742
- /** A project plays its pads when an edge of its routing has them at an end (a modulator onto a knob, the pads onto an
1743
- * instrument). */
1744
- function padsUsedBy({ project }) {
1745
- return arr(project.routingOverrides).some((e) => [e.source, e.sink].some((end) => !!end && typeof end === "object" && end.id === "pads-default"));
1746
- }
1747
- /** A player whose documents are not all known (a game opens its levels as it plays — the keyboard plays an instrument
1748
- * over a cable) needs the keyboard and the Performer any time; a plugin's page only with a .performer among its two
1749
- * documents or a cable from them to its stage (docs/PLAYER-PAKETE-FAKTEN-ZIEL.md S4; the ids: keyboard/source.ts,
1750
- * performer/store.ts — not imported, this file stays light). */
1751
- function midiSourcesUsedBy({ project, workspace, complete }) {
1752
- if (!complete) return true;
1753
- if (arr(workspace.documents).some((d) => d.type === "performer")) return true;
1754
- return arr(project.routingOverrides).some((e) => [e.source, e.sink].some((end) => !!end && typeof end === "object" && ["keyboard-default", "performer"].includes(end.id)));
1755
- }
1756
- // ../extension-stage/src/extension.ts
1757
- /**
1758
- * The stage extension (docs/PLUGIN-STRUKTUR-FAKTEN-ZIEL.md @982cb10f) — its kernel: the .stage kind, which stage plays.
1759
- * Its studio is `./studio`, apart: a player imports this file and must not see the studio's `import()`.
1760
- */
1761
- var extension$2 = {
1762
- id: "stage",
1763
- kernel: () => Promise.resolve().then(() => /* @__PURE__ */ __toESM(require__pagekit_not_here(), 1)).then((m) => m.activateStageRuntime),
1764
- usedBy: stageUsedBy,
1765
- playerChunks: [{
1766
- chunk: "walk",
1767
- whenFiles: [".world"],
1768
- whenHas: "\"players\""
1769
- }]
1770
- };
1771
- /** A project plays a stage when one is open (a `stage` document in workspace.json) — a project without one loads no
1772
- * stage. (A game over stages opens them: its extension needs this one, the shell loads what a project names — G1.) */
1773
- function stageUsedBy({ workspace }) {
1774
- return (Array.isArray(workspace.documents) ? workspace.documents : []).some((d) => !!d && typeof d === "object" && d.type === "stage");
1775
- }
1776
- // ../extension-app/src/extension.ts
1777
- /**
1778
- * The app extension (docs/PLUGIN-GAME-FAKTEN-ZIEL.md): a .faustwave — the flow over a project's stages. Its own domain beside the
1779
- * stage's; FaustWave is no app platform — an app is one plugin's kind of document. Its studio is `./studio`, apart: a
1780
- * player imports this file and must not see the studio's `import()`.
1781
- */
1782
- var extension$1 = {
1783
- id: "app",
1784
- kernel: () => Promise.resolve().then(() => /* @__PURE__ */ __toESM(require__pagekit_not_here(), 1)).then((m) => m.activateAppRuntime),
1785
- usedBy: appUsedBy,
1786
- needs: ["stage"]
1787
- };
1788
- /** A project plays an app when one is open (a `app` document in workspace.json). */
1789
- function appUsedBy({ workspace }) {
1790
- return (Array.isArray(workspace.documents) ? workspace.documents : []).some((d) => !!d && typeof d === "object" && d.type === "app");
1791
- }
1792
- // ../shell/src/lib/extensionList.ts
1793
- var EXTENSIONS = [
1794
- extension$6,
1795
- extension$5,
1796
- extension$4,
1797
- extension$3,
1798
- sequencerExtension,
1799
- padsExtension,
1800
- extension$2,
1801
- extension$1,
1802
- { id: "modules-bundled" }
1803
- ];
1804
- /** The player build chunks the extensions need only with a kind of file (ExtensionDef.playerChunks) — the export decides. */
1805
- function playerChunks() {
1806
- return EXTENSIONS.flatMap((p) => p.playerChunks ?? []);
1807
- }
1808
- /** What a plugin's page carries of its project (electron/project-archive.ts playerFolder cuts it so: pageProject) — its
1809
- * two documents, the patch and its stage, and of the song only the cables to the stage: what its kernels are chosen by. */
1810
- function pageFiles(project, page) {
1811
- const touches = (end) => typeof end === "object" && end !== null && end.doc === page.stage;
1812
- return {
1813
- complete: true,
1814
- project: { routingOverrides: Array.isArray(project.routingOverrides) ? project.routingOverrides.filter((c) => touches(c.sink) || touches(c.source)) : [] },
1815
- workspace: { documents: [{
1816
- type: page.patchKind,
1817
- ref: page.patch
1818
- }, {
1819
- type: page.stageKind,
1820
- ref: page.stage
1821
- }] }
1822
- };
1823
- }
1824
- /** The extensions a player of this project activates: those with a kernel it uses (`usedBy`; none said: always). */
1825
- function extensionsUsedBy(files) {
1826
- const used = new Set(EXTENSIONS.filter((p) => p.kernel && (p.usedBy?.(files) ?? true)).map((p) => p.id));
1827
- for (let grew = true; grew;) {
1828
- grew = false;
1829
- for (const p of EXTENSIONS) if (used.has(p.id)) {
1830
- for (const n of p.needs ?? []) if (!used.has(n)) used.add(n), grew = true;
1831
- }
1832
- }
1833
- return EXTENSIONS.filter((p) => used.has(p.id)).map((p) => p.id);
1834
- }
1835
- // ../extension-api/src/playerPack.ts
1836
- /**
1837
- * A player's project packed (project.build { sources: false }): its archive scrambled — its file names and its
1838
- * data unreadable to a glance into the zip, or to an unzip tool. A hurdle, not encryption: what plays in a browser
1839
- * must be readable by the browser, so the way back travels with the player. The export packs (main process), the
1840
- * player's host unpacks (web-player unpackArchive) — one format, here, with no dependency of its own.
1841
- */
1842
- /** "FWP1" — the head of a packed project. */
1843
- var MAGIC = [
1844
- 70,
1845
- 87,
1846
- 80,
1847
- 49
1848
- ];
1849
- var SALT = 16;
1850
- /** The keystream over `bytes`, from the salt (xorshift32 — fast, and enough for a hurdle). In place. */
1851
- function scramble(bytes, salt) {
1852
- let s = 2654435769;
1853
- for (const b of salt) s = Math.imul(s ^ b, 16777619) >>> 0;
1854
- if (s === 0) s = 1;
1855
- for (let i = 0; i < bytes.length; i++) {
1856
- s ^= s << 13;
1857
- s ^= s >>> 17;
1858
- s ^= s << 5;
1859
- s >>>= 0;
1860
- bytes[i] ^= s & 255;
1861
- }
1862
- }
1863
- /** A project archive (zip bytes) packed: head, salt, scrambled archive. `salt`: 16 random bytes. */
1864
- function packProject(zip, salt) {
1865
- if (salt.length !== SALT) throw new Error(`packProject: the salt is ${SALT} bytes`);
1866
- const out = new Uint8Array(MAGIC.length + SALT + zip.length);
1867
- out.set(MAGIC, 0);
1868
- out.set(salt, MAGIC.length);
1869
- out.set(zip, MAGIC.length + SALT);
1870
- scramble(out.subarray(MAGIC.length + SALT), salt);
1871
- return out;
1872
- }
1873
- // ../extension-api/src/credits.ts
1874
- /** The packs of the models `shipped` (archive paths, `assets/<file>`), sorted — empty when none has a provenance.
1875
- * The provenance as its file's text (an archive), or read already (readModelsProvenance). */
1876
- function creditsOf(provenance, shipped) {
1877
- let entries;
1878
- try {
1879
- entries = typeof provenance === "string" ? JSON.parse(provenance) : provenance;
1880
- } catch {
1881
- return [];
1882
- }
1883
- const packs = /* @__PURE__ */ new Map();
1884
- for (const f of shipped) {
1885
- const model = f.startsWith("assets/") ? f.slice(7) : null;
1886
- const e = model ? entries[model] : void 0;
1887
- if (!e?.pack) continue;
1888
- const p = packs.get(e.pack) ?? {
1889
- pack: e.pack,
1890
- licence: e.licence ?? "",
1891
- models: []
1892
- };
1893
- p.models.push(model);
1894
- packs.set(e.pack, p);
1895
- }
1896
- return [...packs.values()].map((p) => ({
1897
- ...p,
1898
- models: p.models.sort()
1899
- })).sort((a, b) => a.pack.localeCompare(b.pack));
1900
- }
1901
- /** The credits as a Markdown page (CREDITS.md) — null when there are none. */
1902
- function creditsMarkdown(packs) {
1903
- if (!packs.length) return null;
1904
- const lines = [
1905
- "# Credits",
1906
- "",
1907
- "3D models:",
1908
- ""
1909
- ];
1910
- for (const p of packs) {
1911
- lines.push(`- **${p.pack}** — ${p.models.length} model${p.models.length === 1 ? "" : "s"}: ${p.models.join(", ")}`);
1912
- if (p.licence) lines.push(` ${p.licence}`);
1913
- }
1914
- lines.push("", "Made with FaustWave.", "");
1915
- return lines.join("\n");
1916
- }
1917
- // ../faustwave-player/src/lib/playerPackage.ts
1918
- /**
1919
- * A project as a player to share — the player's own format, made in one place for every maker of it
1920
- * (docs/PLUGIN-OBERFLAECHE-FAKTEN-ZIEL.md E5): the IDE (shell electron/project-archive.ts, its files from the disk) and
1921
- * the website's WebCLAP editor (a plugin's 3D page, its files made in the browser). Only what plays; a plugin's page its
1922
- * two documents; the credits, the licence, the player build as index.html. No disk, no Node: what it needs it is handed
1923
- * (PackageIo).
1924
- */
1925
- /** A compile-cache key: a SHA-256, hex — the cache's own IPC and the player export check it so (one test, review R1#21). */
1926
- var compileCacheKeyOk = (key) => typeof key === "string" && /^[a-f0-9]{64}$/.test(key);
1927
- /** Text, as git tells it: no NUL byte in its first 8000 — a text file can name others (`asset:…`); a picture, a sound or a
1928
- * model cannot. No list of kinds: the shell knows none (docs/BUILD-FAKTEN-ZIEL.md @982cb10f R1). */
1929
- var isText = (bytes) => !bytes.subarray(0, 8e3).includes(0);
1930
- /** Every `asset:assets/<name>` a text names. */
1931
- var assetRefs = (text) => [...text.matchAll(/asset:(assets\/[^"'\s)\]]+)/g)].map((m) => m[1]);
1932
- /**
1933
- * The files a glTF model names outside itself — its images' and buffers' `uri`s that are not data: URIs — from a .glb's
1934
- * JSON chunk (a 12-byte header, then [length, type, bytes]; the first chunk is JSON) or a .gltf's text. What the world
1935
- * loads beside it (extension-stage world.ts `externalImages`, `assetBeside`). Unreadable: none.
1936
- */
1937
- function modelFiles(bytes) {
1938
- let json;
1939
- try {
1940
- const v = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
1941
- const glb = bytes.byteLength >= 20 && v.getUint32(0, true) === 1179937895;
1942
- if (glb && v.getUint32(16, true) !== 1313821514) return [];
1943
- json = JSON.parse(new TextDecoder().decode(glb ? bytes.subarray(20, 20 + v.getUint32(12, true)) : bytes));
1944
- } catch {
1945
- return [];
1946
- }
1947
- return [...json.images ?? [], ...json.buffers ?? []].map((x) => x.uri).filter((u) => typeof u === "string" && !u.startsWith("data:"));
1948
- }
1949
- /**
1950
- * Only what the player plays (Mani 2026-11-12: "alles raus was wir nicht brauchen"): project.json, the documents that
1951
- * make the sound and those of the view — and every file they name (`asset:assets/…`), followed until nothing new
1952
- * comes; the workspace lists only the documents kept. Backups, sketches and files nothing names stay out.
1953
- */
1954
- function onlyWhatPlays(files, view, sounding, page = false) {
1955
- const td = new TextDecoder();
1956
- const workspace = JSON.parse(td.decode(files["workspace.json"]));
1957
- const shown = new Set(workspace.layout?.views?.find((v) => v.id === view)?.documents ?? []);
1958
- const docs = workspace.documents ?? [];
1959
- const keep = /* @__PURE__ */ new Set(["project.json"]);
1960
- const { routingOverrides, paramBases: _bases, ...song } = JSON.parse(td.decode(files["project.json"] ?? new TextEncoder().encode("{}")));
1961
- const cables = Array.isArray(routingOverrides) ? routingOverrides : [];
1962
- const fileOf = (ref) => ref?.startsWith("asset:") ? ref.slice(6) : null;
1963
- const namedIn = (f, text) => [...assetRefs(text), ...f.endsWith(".performer") ? [...text.matchAll(/"([^"/\\]+\.[A-Za-z0-9]+)"/g)].map((m) => `assets/${m[1]}`).filter((g) => files[g]) : []];
1964
- const wanted = page ? [] : [...assetRefs(JSON.stringify(song))];
1965
- for (const d of docs) if ((sounding.has(d.type) || shown.has(d.id)) && d.ref?.startsWith("asset:")) wanted.push(d.ref.slice(6));
1966
- while (wanted.length) {
1967
- while (wanted.length) {
1968
- const f = wanted.pop();
1969
- if (keep.has(f) || !files[f]) continue;
1970
- keep.add(f);
1971
- if (/\.(glb|gltf)$/i.test(f)) wanted.push(...modelFiles(files[f]).map((uri) => `assets/${decodeURIComponent(uri.split("/").pop() ?? uri)}`));
1972
- else if (isText(files[f])) wanted.push(...namedIn(f, td.decode(files[f])));
1973
- }
1974
- if (!page) for (const c of cables) {
1975
- const from = fileOf(c.source?.doc);
1976
- const to = fileOf(c.sink?.doc);
1977
- if (!from || !to) continue;
1978
- if (keep.has(to) && !keep.has(from)) wanted.push(from);
1979
- if (keep.has(from) && !keep.has(to) && (c.kind === "audio" || c.kind === "midi")) wanted.push(to);
1980
- }
1981
- }
1982
- for (const f of [...keep]) if (files[presetsFileOf(f)]) keep.add(presetsFileOf(f));
1983
- workspace.documents = docs.filter((d) => page ? shown.has(d.id) : !d.ref?.startsWith("asset:") || keep.has(d.ref.slice(6)));
1984
- const out = { "workspace.json": new TextEncoder().encode(JSON.stringify(workspace, null, 2)) };
1985
- for (const [f, bytes] of Object.entries(files)) if (keep.has(f) || f.startsWith("samples/")) out[f] = bytes;
1986
- return out;
1987
- }
1988
- /** A pack kind's id, when it has one. */
1989
- var kindId = (k) => k && typeof k === "object" && typeof k.kind === "string" ? k.kind : null;
1990
- /** HOW-TO-PLAY.txt at the top of a web build: a web player does not run from a double-click (file:// forbids its workers
1991
- * and its WebAssembly) — a local web server serves it, a browser plays it after a click. */
1992
- var howToPlay = (title) => [
1993
- `How to play ${title}`,
1994
- "",
1995
- "This folder is a web player. A double-click on index.html does not start it: browsers forbid what it needs",
1996
- "(its workers, its WebAssembly) on a page opened from the disk. Serve the folder from a local web server:",
1997
- "",
1998
- "1. Unzip it (done, if you are reading this).",
1999
- "2. Open a terminal in this folder and run: npx serve .",
2000
- " (Node.js from nodejs.org; \"npx http-server .\" works too, and so does any other static web server.)",
2001
- "3. Open the address it prints (such as http://localhost:3000) in Chrome or Edge, and click once:",
2002
- " browsers play sound only after a click.",
2003
- "",
2004
- "On a website: upload the contents of this folder as they are, index.html at the top (itch.io lists it as HTML5).",
2005
- "",
2006
- "Licence of its content: LICENSE.md. Credits: CREDITS.md. Open-source parts of the player: THIRD-PARTY-NOTICES.md.",
2007
- ""
2008
- ].join("\r\n");
2009
- /** An exported plugin's project.json: its version, its transport, the cables that touch its stage. */
2010
- function pageProject(project, stage) {
2011
- const touches = (end) => typeof end === "object" && end !== null && end.doc === stage;
2012
- const cables = Array.isArray(project.routingOverrides) ? project.routingOverrides.filter((c) => touches(c.sink) || touches(c.source)) : [];
2013
- return {
2014
- ...project.version !== void 0 ? { version: project.version } : {},
2015
- ...project.transport !== void 0 ? { transport: project.transport } : {},
2016
- routingOverrides: cables
2017
- };
2018
- }
2019
- /** The view an exported plugin's page opens on. */
2020
- var PLUGIN_VIEW = "plugin";
2021
- /** A player's files, as a web folder holds them: its page (index.html), its build, the project beside it — made of the
2022
- * project's files (`files`, changed in place) and what the caller hands in (`io`). */
2023
- async function playerPackage(name, files, o, io) {
2024
- const ws = files["workspace.json"];
2025
- if (!ws) throw new Error(`Project "${name}" has no workspace to open the player on.`);
2026
- const workspace = JSON.parse(new TextDecoder().decode(ws));
2027
- if (o.page) {
2028
- const docs = workspace.documents ??= [];
2029
- const stamp = Date.now().toString(36);
2030
- const docOf = (ref, type, tag) => {
2031
- const there = docs.find((d) => d.ref === ref);
2032
- if (there?.id) {
2033
- delete there.view;
2034
- return there.id;
2035
- }
2036
- const id = `${type}-${stamp}-${tag}`;
2037
- docs.push({
2038
- id,
2039
- type,
2040
- title: ref.slice(ref.lastIndexOf("/") + 1),
2041
- ref
2042
- });
2043
- return id;
2044
- };
2045
- const shown = [docOf(o.page.patch, o.page.patchKind, "ptch"), docOf(o.page.stage, o.page.stageKind, "page")];
2046
- if (files["project.json"]) files["project.json"] = new TextEncoder().encode(JSON.stringify(pageProject(JSON.parse(new TextDecoder().decode(files["project.json"])), o.page.stage)));
2047
- workspace.layout = {
2048
- ...workspace.layout,
2049
- views: [{
2050
- id: PLUGIN_VIEW,
2051
- name: "Plugin",
2052
- icon: "Box",
2053
- builtin: false,
2054
- panes: [{
2055
- surfaceId: "document",
2056
- instanceId: "document"
2057
- }],
2058
- documents: shown
2059
- }]
2060
- };
2061
- o = {
2062
- ...o,
2063
- view: PLUGIN_VIEW,
2064
- sounding: []
2065
- };
2066
- }
2067
- if (!workspace.layout?.views?.some((v) => v.id === o.view)) throw new Error(`Project "${name}" has no view "${o.view}".`);
2068
- workspace.layout.activeViewId = o.view;
2069
- for (const d of workspace.documents ?? []) if (d.id && o.views?.[d.id]) d.view = o.views[d.id];
2070
- files["workspace.json"] = new TextEncoder().encode(JSON.stringify(workspace, null, 2));
2071
- const provenance = files["assets/models-provenance.json"];
2072
- const plays = onlyWhatPlays(files, o.view, new Set(o.sounding ?? []), !!o.page);
2073
- for (const f of Object.keys(files)) delete files[f];
2074
- Object.assign(files, plays);
2075
- if (io.compressModel) {
2076
- for (const f of Object.keys(files)) if (f.toLowerCase().endsWith(".glb")) files[f] = await io.compressModel(files[f]);
2077
- }
2078
- if (provenance) {
2079
- const kept = Object.fromEntries(creditsOf(new TextDecoder().decode(provenance), Object.keys(files)).flatMap((p) => p.models).map((m) => [m, JSON.parse(new TextDecoder().decode(provenance))[m]]));
2080
- if (Object.keys(kept).length) files["assets/models-provenance.json"] = new TextEncoder().encode(JSON.stringify(kept, null, 2));
2081
- }
2082
- const te = new TextEncoder();
2083
- for (const [f, text] of Object.entries(o.replace ?? {})) if (files[f]) files[f] = te.encode(text);
2084
- files["sealed.json"] = te.encode(JSON.stringify(o.sealed ?? {}));
2085
- if (o.extensions) files["extensions.json"] = te.encode(JSON.stringify(o.extensions));
2086
- const licence = o.licence ?? "CC0-1.0";
2087
- files["player.json"] = te.encode(JSON.stringify({
2088
- name,
2089
- licence
2090
- }));
2091
- const tokens = /* @__PURE__ */ new Set();
2092
- const scan = (text) => {
2093
- for (const m of text.matchAll(/"([^"\\]{1,64})"/g)) tokens.add(m[1]);
2094
- };
2095
- const tdec = new TextDecoder();
2096
- for (const [f, bytes] of Object.entries(files)) if (!f.startsWith("compile-cache/")) scan(tdec.decode(bytes));
2097
- const packs = o.packs ?? [];
2098
- const taken = /* @__PURE__ */ new Set();
2099
- for (let grew = true; grew;) {
2100
- grew = false;
2101
- for (const p of packs) {
2102
- if (taken.has(p) || !p.kinds.some((k) => tokens.has(kindId(k) ?? ""))) continue;
2103
- taken.add(p);
2104
- scan(JSON.stringify(p));
2105
- grew = true;
2106
- }
2107
- }
2108
- for (const p of taken) files[`node-packs/${p.packId}.json`] = te.encode(JSON.stringify(p));
2109
- let compiled = 0;
2110
- let missing = 0;
2111
- for (const key of new Set(o.cacheKeys)) {
2112
- if (!compileCacheKeyOk(key)) continue;
2113
- const c = await io.cached(key);
2114
- if (c) {
2115
- files[`compile-cache/${key}.meta.json`] = c.meta;
2116
- files[`compile-cache/${key}.wasm`] = c.wasm;
2117
- compiled++;
2118
- } else missing++;
2119
- }
2120
- const built = io.build;
2121
- if (!built["player.html"]) throw new Error("The player is not built — npm run build:player.");
2122
- const player = {};
2123
- const unneeded = (o.chunks ?? []).filter((c) => !Object.keys(files).some((f) => c.whenFiles.some((end) => f.toLowerCase().endsWith(end.toLowerCase())) && (!c.whenHas || new TextDecoder().decode(files[f]).includes(c.whenHas)))).map((c) => new RegExp(`^assets/${c.chunk.replace(/[^A-Za-z0-9_-]/g, "")}-[A-Za-z0-9_-]{8}\\.js$`));
2124
- for (const [f, bytes] of Object.entries(built)) {
2125
- if (unneeded.some((re) => re.test(f))) continue;
2126
- player[f === "player.html" ? "index.html" : f] = bytes;
2127
- }
2128
- const credits = creditsMarkdown(provenance ? creditsOf(new TextDecoder().decode(provenance), Object.keys(files)) : []);
2129
- if (credits) player["CREDITS.md"] = new TextEncoder().encode(`${credits}
2130
- Its own content: ${licenceName(licence)} (LICENSE.md).
2131
- `);
2132
- player["LICENSE.md"] = new TextEncoder().encode(licenceNotice({
2133
- licence,
2134
- title: name,
2135
- ...o.author ? { author: o.author } : {},
2136
- year: (/* @__PURE__ */ new Date()).getFullYear()
2137
- }));
2138
- if (!player["THIRD-PARTY-NOTICES.md"]) throw new Error("The player build has no THIRD-PARTY-NOTICES.md at its top — build it again (npm run build:player).");
2139
- player["HOW-TO-PLAY.txt"] = new TextEncoder().encode(howToPlay(name));
2140
- if (o.manifest) player["faustwave.json"] = te.encode(JSON.stringify({
2141
- name,
2142
- version: o.manifest.version,
2143
- type: o.manifest.type,
2144
- capabilities: o.manifest.capabilities,
2145
- licence,
2146
- web: { entry: "index.html" }
2147
- }, null, 2));
2148
- if (o.packed) {
2149
- for (const [f, bytes] of Object.entries(files)) {
2150
- if (f.startsWith("compile-cache/") && !f.endsWith(".json")) continue;
2151
- try {
2152
- files[f] = te.encode(JSON.stringify(JSON.parse(tdec.decode(bytes))));
2153
- } catch {}
2154
- }
2155
- player["faustwave.project"] = packProject(await io.zip(files, 9), io.random(16));
2156
- } else player["faustwave.project"] = await io.zip(files, 6);
2157
- if (o.page) {
2158
- player["plugin.json"] = te.encode(JSON.stringify({
2159
- patch: o.page.patch,
2160
- params: o.page.params,
2161
- modouts: o.page.modouts ?? [],
2162
- meters: o.page.meters ?? {}
2163
- }));
2164
- delete player["HOW-TO-PLAY.txt"];
2165
- }
2166
- return {
2167
- player,
2168
- files: Object.keys(files).length,
2169
- compiled,
2170
- missing
2171
- };
2172
- }
2173
- // ../faust-runtime/src/meters.ts
2174
- /**
2175
- * The meters an exported plugin's page shows (docs/AUDIO-WEBCLAP-UMSTIEG-FAKTEN-ZIEL.md U4): a page gets no audio from its
2176
- * host, only what the plugin tells it — so a build with a page measures in the plugin, behind the patch's last stage
2177
- * (an instrument's effect, else the patch), as bargraphs named `fwmeter <port>` — told the plugin's page (no params), Faust's
2178
- * `[hidden:1]` (a host shows them to no one, a modulation offers them not) — the page reads. The measure is the
2179
- * IDE's master analysis (shell/src/assets/dsp/master-analysis.dsp): level, low, mid and high of the sum, and onset.
2180
- */
2181
- var METERS = `
2182
- fwm_db01(x) = x : ba.linear2db : max(-60) : +(60) : /(60);
2183
- fwm_env(x) = x : an.amp_follower_ar(0.005, 0.2);
2184
- fwm_level(x) = x : fwm_env : fwm_db01 : hbargraph("fwmeter level [hidden:1]", 0, 1);
2185
- fwm_low(x) = x : fi.lowpass(2, 200) : fwm_env : fwm_db01 : hbargraph("fwmeter low [hidden:1]", 0, 1);
2186
- fwm_mid(x) = x : fi.bandpass(2, 200, 2000) : fwm_env : fwm_db01 : hbargraph("fwmeter mid [hidden:1]", 0, 1);
2187
- fwm_high(x) = x : fi.highpass(2, 2000) : fwm_env : fwm_db01 : hbargraph("fwmeter high [hidden:1]", 0, 1);
2188
- fwm_onset(x) = (fast > slow * 1.6 + 0.005) : ba.peakholder(ma.SR * 0.08) : hbargraph("fwmeter onset [hidden:1]", 0, 1)
2189
- with {
2190
- fast = x : an.amp_follower_ar(0.001, 0.03);
2191
- slow = x : an.amp_follower_ar(0.05, 0.4);
2192
- };
2193
- fwm_tap(x, s) = attach(attach(attach(attach(attach(s, fwm_level(x)), fwm_low(x)), fwm_mid(x)), fwm_high(x)), fwm_onset(x));
2194
- fwm_on(1) = _ <: fwm_tap;
2195
- fwm_two(l, r) = fwm_tap((l + r) * 0.5, l), r;
2196
- fwm_on(n) = fwm_two, si.bus(n - 2);
2197
- `;
2198
- /** The patch `source` measured behind its last stage. `voices`: an instrument's (its effect is the last stage, or the
2199
- * meters become its effect). */
2200
- function withMeters(source, voices) {
2201
- const hasEffect = definesEffect(source);
2202
- const last = voices !== null ? hasEffect ? "fw_patch.effect" : null : "fw_patch.process";
2203
- const lines = [
2204
- "import(\"stdfaust.lib\");",
2205
- `fw_patch = environment {\n${source}\n};`,
2206
- METERS,
2207
- voices !== null ? "process = fw_patch.process;" : `process = ${last} : fwm_on(outputs(${last}));`
2208
- ];
2209
- if (voices !== null) lines.push(last ? `effect = ${last} : fwm_on(outputs(${last}));` : "effect = fwm_on(outputs(fw_patch.process));");
2210
- return lines.join("\n");
2211
- }
2212
- // src/pagekit.ts
2213
- /**
2214
- * What another maker of a plugin's 3D page needs of the IDE (docs/PLUGIN-OBERFLAECHE-FAKTEN-ZIEL.md E5, L5.3) — the
2215
- * website's WebCLAP editor: the same pure pieces the IDE makes it with, built into one module (vite.pagekit.config.mjs)
2216
- * beside the player build and the device's parts. No second way: each is the IDE's own.
2217
- *
2218
- * withMeters the patch measured behind its last stage (its page's meters) faust-runtime meters.ts
2219
- * patchSides its params, its outputs and its meters as the page reads them faust-clap parts.ts
2220
- * deviceMeta… its controls' device words; deviceOfPatch its device and cables extension-stage device.ts
2221
- * pageFiles, extensionsUsedBy the kernels its page activates shell extensionList.ts
2222
- * playerPackage the player's package of a project's files faustwave-player playerPackage.ts
2223
- */
2224
- /** A project's files zipped as a player reads them (fflate, which the player unzips with). */
2225
- var zipFiles = async (files, level) => zipSync(files, { level });
2226
- /**
2227
- * The project of a patch's 3D page, in the IDE's own files (project.json, workspace.json — their schema, the cables as
2228
- * routingOverrides): the patch's source, its device (deviceOfPatch) — its world, its stage, the cables to the stage —
2229
- * the device's parts and their provenance (`parts`, by file name), its presets file when it has one. What
2230
- * stage.device.create leaves in a project, made without one: for playerPackage with its `page` (the website's editor).
2231
- */
2232
- function devicePageProject(i) {
2233
- const enc = (v) => new TextEncoder().encode(typeof v === "string" ? v : JSON.stringify(v, null, 2));
2234
- const file = (ref) => ref.replace(/^asset:/, "");
2235
- const cables = i.made.cables.map((c) => ({
2236
- source: c.from === "analysis" ? { id: "analysis" } : {
2237
- doc: i.patch,
2238
- sub: "-mod"
2239
- },
2240
- sourcePort: c.port,
2241
- sink: { doc: i.made.stageRef },
2242
- sinkPort: c.to,
2243
- kind: "modulation",
2244
- override: {
2245
- present: true,
2246
- amount: 1
2247
- }
2248
- }));
2249
- const files = {
2250
- "project.json": enc({
2251
- version: 8,
2252
- transport: {
2253
- bpm: i.bpm ?? 120,
2254
- independent: []
2255
- },
2256
- routingOverrides: cables
2257
- }),
2258
- "workspace.json": enc({
2259
- version: 3,
2260
- documents: [],
2261
- layout: { views: [] }
2262
- }),
2263
- [file(i.patch)]: enc(i.source),
2264
- [file(i.made.worldRef)]: enc(i.made.world),
2265
- [file(i.made.stageRef)]: enc(i.made.stage)
2266
- };
2267
- for (const [name, bytes] of Object.entries(i.parts)) files[`assets/${name}`] = bytes;
2268
- if (i.presets) files[presetsFileOf(file(i.patch))] = enc(i.presets);
2269
- return files;
2270
- }
2271
- /** A 3D page's size — the plugin built for it says it (clap.gui). */
2272
- var PAGE_3D_SIZE = {
2273
- width: 800,
2274
- height: 450
2275
- };
2276
- /**
2277
- * A plugin's 3D page: its device played by FaustWave's player — the files beside its module (pluginPackage), its
2278
- * THIRD-PARTY-NOTICES.md the player's. The one way to make it outside the IDE (the website's WebCLAP editor,
2279
- * `faustwave convert --page 3d`):
2280
- * built the plugin compiled of withMeters(source) with ui PAGE_3D_SIZE (faustwasm-webclap's compilePlugin)
2281
- * pages its knob pages as the plugin names them (clap.remote-controls), each param by its address
2282
- * parts the device's parts by file name (parts/ beside this module); player — the player build by path
2283
- * (player/, its files.json)
2284
- * presets its presets file's text, when it has presets
2285
- */
2286
- async function devicePage(i) {
2287
- const { description, faust, effect } = i.built;
2288
- const sides = patchSides(faust, effect, i.built.voices ?? void 0);
2289
- const patch = `asset:assets/${idPart(description.name)}.dsp`;
2290
- const made = deviceOfPatch({
2291
- patch,
2292
- pages: i.pages,
2293
- params: description.params.filter((p) => !p.hidden && p.max > p.min).map((p) => ({
2294
- path: p.address,
2295
- value: p.init,
2296
- min: p.min,
2297
- max: p.max,
2298
- ...p.scale !== "linear" ? { scale: p.scale } : {},
2299
- ...p.step ? { step: p.step } : {},
2300
- ...p.unit ? { unit: p.unit } : {}
2301
- })),
2302
- meta: deviceMetaOf([JSON.stringify(faust), JSON.stringify(effect)]),
2303
- outputs: sides.modouts.map((o) => ({
2304
- id: o.address,
2305
- label: o.label
2306
- })),
2307
- presets: Boolean(i.presets)
2308
- });
2309
- const files = devicePageProject({
2310
- patch,
2311
- source: i.source,
2312
- made,
2313
- parts: i.parts,
2314
- ...i.presets ? { presets: i.presets } : {}
2315
- });
2316
- const page = {
2317
- stage: made.stageRef,
2318
- stageKind: "stage",
2319
- patch,
2320
- patchKind: "faust-dsp"
2321
- };
2322
- const project = JSON.parse(new TextDecoder().decode(files["project.json"]));
2323
- const said = declaredOf(i.source, "license");
2324
- const author = declaredOf(i.source, "author");
2325
- const { player } = await playerPackage(description.name, files, {
2326
- view: "",
2327
- cacheKeys: [],
2328
- sealed: {},
2329
- extensions: extensionsUsedBy(pageFiles(project, page)),
2330
- chunks: playerChunks(),
2331
- ...said && CONTENT_LICENCES.includes(said) ? { licence: said } : {},
2332
- ...author ? { author } : {},
2333
- page: {
2334
- ...page,
2335
- params: sides.params,
2336
- modouts: sides.modouts,
2337
- meters: sides.meters
2338
- }
2339
- }, {
2340
- zip: zipFiles,
2341
- random: (n) => crypto.getRandomValues(new Uint8Array(n)),
2342
- cached: async () => null,
2343
- build: i.player
2344
- });
2345
- return player;
2346
- }
2347
- export { CONTENT_LICENCES, DEVICE_PARTS, PAGE_3D_SIZE, PLUGIN_VIEW, deviceMetaOf, deviceOfPatch, devicePage, devicePageProject, extensionsUsedBy, pageFiles, patchSides, playerChunks, playerPackage, withMeters, zipFiles };