@kolkrabbi/design-editor 0.46.0 → 0.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/{BindDot-B0VcuOag.js → BindDot-B85UV79g.js} +9 -8
  2. package/dist/{BufferResource-BfLgK37S.js → BufferResource-Di5teicy.js} +2 -2
  3. package/dist/{CanvasPool-YNSF8hsR.js → CanvasPool-JdLj49b-.js} +1 -1
  4. package/dist/CanvasRenderer-fXDObOOi.js +2 -0
  5. package/dist/{FederatedEventTarget-BJgROaRQ.js → FederatedEventTarget-CH0bzxx1.js} +1 -1
  6. package/dist/{FilterSystem-BUrPNXx-.js → FilterSystem-C-ZoyuTO.js} +3 -3
  7. package/dist/{Geometry-C5s5KpWq.js → Geometry-D4tiuMOr.js} +1 -1
  8. package/dist/KolboxView-n6kEPJtV.js +21615 -0
  9. package/dist/{RenderTargetSystem-oFwWv5IW.js → RenderTargetSystem-Bom_vhlS.js} +1 -1
  10. package/dist/{Timeline-Ck1rBV8S.js → Timeline-EbecYeGh.js} +49 -47
  11. package/dist/TreePicker-2RUSyGl4.js +209 -0
  12. package/dist/WebGLRenderer-4hvrGmfW.js +2 -0
  13. package/dist/WebGPURenderer-BjzMV7Pg.js +2 -0
  14. package/dist/__vite-browser-external-y2xWjzgx.js +780 -0
  15. package/dist/browserAll-BFE0MRLW.js +6 -0
  16. package/dist/{canvasUtils-BoNfkAod.js → canvasUtils-DUNsu3ct.js} +1 -1
  17. package/dist/{core-BBb9Tk4Q.js → core-9UlJPBwX.js} +6272 -6239
  18. package/dist/core.js +6 -5
  19. package/dist/design-editor.css +2 -1
  20. package/dist/design-editor.js +7 -3644
  21. package/dist/{effectCategories-Ccye-8LP.js → effectCategories-CCpYmxS0.js} +8965 -4984
  22. package/dist/effects-DspYFJAM.js +447 -0
  23. package/dist/effects.js +1 -1
  24. package/dist/{generators-BdVXv0jY.js → generators-DY4_ymWh.js} +2386 -2416
  25. package/dist/generators.js +1 -1
  26. package/dist/{getTextureBatchBindGroup-CNWhZRbV.js → getTextureBatchBindGroup-ZMqkwiZS.js} +1 -1
  27. package/dist/{host-meUhieO9.js → host-0qv2SCjk.js} +1 -1
  28. package/dist/{host-9pJ7NvnR.js → host-Bo6itV50.js} +50 -50
  29. package/dist/init-DkGhdexn.js +4 -0
  30. package/dist/{morphStore-D6mkLJ-8.js → morphStore-Bm30Ekce.js} +1 -1
  31. package/dist/{motion-wsc6Qd7S.js → motion-BOWE4m3Q.js} +762 -759
  32. package/dist/motion.js +1 -1
  33. package/dist/{pipeline-CMpuPUaX.js → pipeline-hZsOKbHd.js} +12 -12
  34. package/dist/{previewScale-SYKvfhUm.js → previewScale-C6EBx--U.js} +8 -8
  35. package/dist/{rolls-KpWCAeDv.js → rolls-DugKaHUw.js} +10549 -4517
  36. package/dist/src-BlvCHYVY.js +3672 -0
  37. package/dist/{src-B5o6fGRJ.js → src-D-TQbBo2.js} +1 -2
  38. package/dist/{store-iBb0I6hk.js → store-BMGP1qou.js} +295 -275
  39. package/dist/{useLayerEdit-Ba7RA6qX.js → useLayerEdit-B5nF5I9b.js} +103 -102
  40. package/dist/webworkerAll-0WBQ2FBr.js +2 -0
  41. package/package.json +12 -9
  42. package/dist/CanvasRenderer-Bl0rlqNq.js +0 -2
  43. package/dist/TreePicker-Dv0zpJwe.js +0 -166
  44. package/dist/WebGLRenderer-CXxpVIx3.js +0 -2
  45. package/dist/WebGPURenderer-BwLEUYBa.js +0 -2
  46. package/dist/browserAll-CAzdTUbR.js +0 -6
  47. package/dist/chunk-3b4jIN3o.js +0 -13
  48. package/dist/effects-B47bpwGh.js +0 -447
  49. package/dist/init-jApIMi04.js +0 -4
  50. package/dist/webworkerAll-DEZhpG90.js +0 -2
@@ -0,0 +1,780 @@
1
+ import { useEffect as e, useState as t, useSyncExternalStore as n } from "react";
2
+ import { createTransport as r } from "@kolkrabbi/kol-hardware/signal";
3
+ //#region \0rolldown/runtime.js
4
+ var i = Object.create, a = Object.defineProperty, o = Object.getOwnPropertyDescriptor, s = Object.getOwnPropertyNames, c = Object.getPrototypeOf, ee = Object.prototype.hasOwnProperty, l = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), u = (e, t) => {
5
+ let n = {};
6
+ for (var r in e) a(n, r, {
7
+ get: e[r],
8
+ enumerable: !0
9
+ });
10
+ return t || a(n, Symbol.toStringTag, { value: "Module" }), n;
11
+ }, te = (e, t, n, r) => {
12
+ if (t && typeof t == "object" || typeof t == "function") for (var i = s(t), c = 0, l = i.length, u; c < l; c++) u = i[c], !ee.call(e, u) && u !== n && a(e, u, {
13
+ get: ((e) => t[e]).bind(null, u),
14
+ enumerable: !(r = o(t, u)) || r.enumerable
15
+ });
16
+ return e;
17
+ }, ne = (e, t, n) => (n = e == null ? {} : i(c(e)), te(t || !e || !e.__esModule ? a(n, "default", {
18
+ value: e,
19
+ enumerable: !0
20
+ }) : n, e)), re = Math.PI * 2, ie = (e) => Math.max(0, Math.min(1, e)), ae = (e, t = 0, n = 1) => e < t ? t : e > n ? n : e, d = (e, t, n) => e + (t - e) * n, f = (e) => parseInt(e, 16);
21
+ function p(e) {
22
+ let t = String(e || "").replace("#", ""), n = t.length === 3 ? t.split("").map((e) => e + e).join("") : t;
23
+ return n.length < 6 ? [
24
+ 0,
25
+ 0,
26
+ 0
27
+ ] : [
28
+ f(n.slice(0, 2)),
29
+ f(n.slice(2, 4)),
30
+ f(n.slice(4, 6))
31
+ ];
32
+ }
33
+ function oe(e, t, n) {
34
+ let r = p(e), i = p(t);
35
+ return `rgb(${Math.round(d(r[0], i[0], n))}, ${Math.round(d(r[1], i[1], n))}, ${Math.round(d(r[2], i[2], n))})`;
36
+ }
37
+ //#endregion
38
+ //#region src/editor/lib/appSettings.js
39
+ var m = "kol-editor-settings", h = 1, g = {
40
+ version: h,
41
+ defaultAspect: "4:5",
42
+ defaultTheme: "kol",
43
+ autoplay: !1,
44
+ clipToFrame: !0,
45
+ labsModDots: !1,
46
+ rollScopes: {},
47
+ rollEffects: !0,
48
+ defaultLoopSeconds: 4,
49
+ previewRes: "full",
50
+ grab: !1,
51
+ interactions: !0,
52
+ zoomLock: !1,
53
+ style: "default"
54
+ };
55
+ function se() {
56
+ try {
57
+ let e = JSON.parse(localStorage.getItem(m) || "{}");
58
+ return e.version === h ? {
59
+ ...g,
60
+ ...e
61
+ } : { ...g };
62
+ } catch {
63
+ return { ...g };
64
+ }
65
+ }
66
+ var _ = se(), v = /* @__PURE__ */ new Set();
67
+ function ce() {
68
+ return _;
69
+ }
70
+ function le(e, t) {
71
+ _ = {
72
+ ..._,
73
+ [e]: t
74
+ };
75
+ try {
76
+ localStorage.setItem(m, JSON.stringify(_));
77
+ } catch {}
78
+ y?.save(_), v.forEach((e) => e(_));
79
+ }
80
+ var y = null;
81
+ function ue(e) {
82
+ y = e ?? null, y?.load().then((t) => {
83
+ if (!(y !== e || !t || t.version !== h)) {
84
+ _ = {
85
+ ...g,
86
+ ...t
87
+ };
88
+ try {
89
+ localStorage.setItem(m, JSON.stringify(_));
90
+ } catch {}
91
+ v.forEach((e) => e(_));
92
+ }
93
+ }).catch(() => {});
94
+ }
95
+ function de(e) {
96
+ return v.add(e), () => v.delete(e);
97
+ }
98
+ function fe() {
99
+ let [n, r] = t(_);
100
+ return e(() => de(r), []), n;
101
+ }
102
+ //#endregion
103
+ //#region src/editor/params/audioBands.js
104
+ var b = {
105
+ level: 0,
106
+ bass: 0,
107
+ mid: 0,
108
+ high: 0
109
+ }, x = null, S = null, C = null, w = null, T = null, E = 0, D = null, O = null, k = !1, A = null, pe = .5, me = .12, j = (e, t) => e + (t - e) * (t > e ? pe : me);
110
+ function he() {
111
+ if (!k || !S) return;
112
+ S.getFloatTimeDomainData(D);
113
+ let e = 0;
114
+ for (let t = 0; t < D.length; t++) e += D[t] * D[t];
115
+ let t = Math.min(1, Math.sqrt(e / D.length) * 4);
116
+ S.getByteFrequencyData(O);
117
+ let n = O.length, r = Math.floor(n * .04), i = Math.floor(n * .25), a = 0, o = 0, s = 0;
118
+ for (let e = 0; e < r; e++) a += O[e];
119
+ for (let e = r; e < i; e++) o += O[e];
120
+ for (let e = i; e < n; e++) s += O[e];
121
+ b.level = j(b.level, t), b.bass = j(b.bass, Math.min(1, a / r / 200)), b.mid = j(b.mid, Math.min(1, o / (i - r) / 160)), b.high = j(b.high, Math.min(1, s / (n - i) / 120)), E = requestAnimationFrame(he);
122
+ }
123
+ async function ge({ file: e } = {}) {
124
+ let t = e ? "file" : "mic";
125
+ if (k && A === t && !e) return !0;
126
+ if (_e(), typeof window > "u") return !1;
127
+ try {
128
+ x = new (window.AudioContext || window.webkitAudioContext)(), x.state === "suspended" && await x.resume();
129
+ let n;
130
+ if (e) T = URL.createObjectURL(e), w = new Audio(T), w.loop = !0, w.crossOrigin = "anonymous", n = x.createMediaElementSource(w), n.connect(x.destination), await w.play();
131
+ else {
132
+ if (!navigator.mediaDevices?.getUserMedia) return !1;
133
+ C = await navigator.mediaDevices.getUserMedia({
134
+ audio: !0,
135
+ video: !1
136
+ }), n = x.createMediaStreamSource(C);
137
+ }
138
+ return S = x.createAnalyser(), S.fftSize = 512, n.connect(S), D = new Float32Array(S.fftSize), O = new Uint8Array(S.frequencyBinCount), k = !0, A = t, E = requestAnimationFrame(he), !0;
139
+ } catch (e) {
140
+ return console.info("[audio] not available:", e?.message ?? e), _e(), !1;
141
+ }
142
+ }
143
+ function _e() {
144
+ if (k = !1, A = null, E &&= (cancelAnimationFrame(E), 0), C &&= (C.getTracks().forEach((e) => e.stop()), null), w &&= (w.pause(), null), T &&= (URL.revokeObjectURL(T), null), x) {
145
+ try {
146
+ x.close();
147
+ } catch {}
148
+ x = null;
149
+ }
150
+ S = null, D = O = null, b.level = b.bass = b.mid = b.high = 0;
151
+ }
152
+ function M() {
153
+ return b;
154
+ }
155
+ function ve() {
156
+ return k;
157
+ }
158
+ function ye() {
159
+ return A;
160
+ }
161
+ //#endregion
162
+ //#region src/editor/params/midi.js
163
+ var N = /* @__PURE__ */ new Map(), P = null, F = !1, I = null;
164
+ function be(e) {
165
+ let [t, n, r] = e.data;
166
+ if ((t & 240) == 176 && (N.set(n, r / 127), I)) {
167
+ let e = I;
168
+ I = null, e(n);
169
+ }
170
+ }
171
+ function xe() {
172
+ for (let e of P.inputs.values()) e.onmidimessage = be;
173
+ }
174
+ async function Se() {
175
+ if (F) return !0;
176
+ if (typeof navigator > "u" || !navigator.requestMIDIAccess) return !1;
177
+ try {
178
+ return P = await navigator.requestMIDIAccess(), xe(), P.onstatechange = xe, F = !0, !0;
179
+ } catch (e) {
180
+ return console.info("[midi] not available:", e?.message ?? e), !1;
181
+ }
182
+ }
183
+ function Ce() {
184
+ return F;
185
+ }
186
+ function we(e) {
187
+ return N.get(e) ?? 0;
188
+ }
189
+ function Te() {
190
+ return N.size > 0;
191
+ }
192
+ function Ee() {
193
+ return new Promise((e) => {
194
+ let t = setTimeout(() => {
195
+ I = null, e(null);
196
+ }, 1e4);
197
+ I = (n) => {
198
+ clearTimeout(t), e(n);
199
+ };
200
+ });
201
+ }
202
+ //#endregion
203
+ //#region src/editor/params/gamepad.js
204
+ function L() {
205
+ if (typeof navigator > "u" || !navigator.getGamepads) return null;
206
+ let e = navigator.getGamepads();
207
+ for (let t of e) if (t) return t;
208
+ return null;
209
+ }
210
+ function R() {
211
+ return !!L();
212
+ }
213
+ function z(e) {
214
+ let t = L();
215
+ if (!t) return 0;
216
+ let n = t.axes[e];
217
+ return Number.isFinite(n) ? (n + 1) / 2 : 0;
218
+ }
219
+ function De(e) {
220
+ let t = L();
221
+ return t ? t.buttons[e]?.value ?? 0 : 0;
222
+ }
223
+ function B(e) {
224
+ let t = L();
225
+ return t ? +!!t.buttons[e]?.pressed : 0;
226
+ }
227
+ function Oe(e, t) {
228
+ let n = L();
229
+ if (!n) return 0;
230
+ let r = n.axes[e] ?? 0, i = n.axes[t] ?? 0, a = Math.atan2(i, r) / (Math.PI * 2);
231
+ return a - Math.floor(a);
232
+ }
233
+ function ke(e, t) {
234
+ let n = L();
235
+ if (!n) return 0;
236
+ let r = n.axes[e] ?? 0, i = n.axes[t] ?? 0;
237
+ return Math.min(1, Math.hypot(r, i));
238
+ }
239
+ var V = [
240
+ {
241
+ id: "pad-leftX",
242
+ label: "Pad · Left stick X",
243
+ axis: 0,
244
+ read: () => z(0)
245
+ },
246
+ {
247
+ id: "pad-leftY",
248
+ label: "Pad · Left stick Y",
249
+ axis: 1,
250
+ read: () => z(1)
251
+ },
252
+ {
253
+ id: "pad-rightX",
254
+ label: "Pad · Right stick X",
255
+ axis: 2,
256
+ read: () => z(2)
257
+ },
258
+ {
259
+ id: "pad-rightY",
260
+ label: "Pad · Right stick Y",
261
+ axis: 3,
262
+ read: () => z(3)
263
+ },
264
+ {
265
+ id: "pad-LT",
266
+ label: "Pad · L2 (trigger)",
267
+ button: 6,
268
+ read: () => De(6)
269
+ },
270
+ {
271
+ id: "pad-RT",
272
+ label: "Pad · R2 (trigger)",
273
+ button: 7,
274
+ read: () => De(7)
275
+ },
276
+ {
277
+ id: "pad-a",
278
+ label: "Pad · A (south)",
279
+ button: 0,
280
+ read: () => B(0)
281
+ },
282
+ {
283
+ id: "pad-b",
284
+ label: "Pad · B (east)",
285
+ button: 1,
286
+ read: () => B(1)
287
+ },
288
+ {
289
+ id: "pad-x",
290
+ label: "Pad · X (west)",
291
+ button: 2,
292
+ read: () => B(2)
293
+ },
294
+ {
295
+ id: "pad-y",
296
+ label: "Pad · Y (north)",
297
+ button: 3,
298
+ read: () => B(3)
299
+ },
300
+ {
301
+ id: "pad-L1",
302
+ label: "Pad · L1 (bumper)",
303
+ button: 4,
304
+ read: () => B(4)
305
+ },
306
+ {
307
+ id: "pad-R1",
308
+ label: "Pad · R1 (bumper)",
309
+ button: 5,
310
+ read: () => B(5)
311
+ },
312
+ {
313
+ id: "pad-leftAngle",
314
+ label: "Pad · Left stick ∠ (circle)",
315
+ read: () => Oe(0, 1)
316
+ },
317
+ {
318
+ id: "pad-leftForce",
319
+ label: "Pad · Left stick ⊙ (push)",
320
+ read: () => ke(0, 1)
321
+ },
322
+ {
323
+ id: "pad-rightAngle",
324
+ label: "Pad · Right stick ∠ (circle)",
325
+ read: () => Oe(2, 3)
326
+ },
327
+ {
328
+ id: "pad-rightForce",
329
+ label: "Pad · Right stick ⊙ (push)",
330
+ read: () => ke(2, 3)
331
+ }
332
+ ];
333
+ function Ae(e) {
334
+ return typeof e == "string" && (e.startsWith("pad-") || e === "padX" || e === "padY");
335
+ }
336
+ var je = new Map(V.filter((e) => e.axis != null).map((e) => [e.axis, e.id])), Me = new Map(V.filter((e) => e.button != null).map((e) => [e.button, e.id])), Ne = .5;
337
+ function Pe() {
338
+ return new Promise((e) => {
339
+ if (typeof requestAnimationFrame > "u") return e(null);
340
+ let t = L(), n = t ? [...t.axes] : [], r = typeof performance < "u" ? performance.now() : Date.now(), i = 0, a = (t) => {
341
+ cancelAnimationFrame(i), e(t);
342
+ }, o = () => {
343
+ let e = L();
344
+ if (e) {
345
+ for (let [t, n] of Me) if (e.buttons[t]?.pressed) return a(n);
346
+ for (let t = 0; t < e.axes.length; t++) {
347
+ let r = je.get(t);
348
+ if (r && Math.abs((e.axes[t] ?? 0) - (n[t] ?? 0)) > Ne) return a(r);
349
+ }
350
+ }
351
+ if ((typeof performance < "u" ? performance.now() : Date.now()) - r > 1e4) return a(null);
352
+ i = requestAnimationFrame(o);
353
+ };
354
+ i = requestAnimationFrame(o);
355
+ });
356
+ }
357
+ //#endregion
358
+ //#region src/editor/lib/sandbox.js
359
+ var Fe = [
360
+ "globalThis",
361
+ "window",
362
+ "self",
363
+ "document",
364
+ "fetch",
365
+ "XMLHttpRequest",
366
+ "localStorage",
367
+ "sessionStorage",
368
+ "indexedDB",
369
+ "navigator",
370
+ "location",
371
+ "top",
372
+ "parent",
373
+ "frames",
374
+ "opener",
375
+ "Function",
376
+ "WebSocket",
377
+ "Worker",
378
+ "importScripts"
379
+ ], Ie = {
380
+ level: 0,
381
+ bass: 0,
382
+ mid: 0,
383
+ high: 0
384
+ }, Le = "\n \"use strict\";\n var s=t, time=t;\n var level=+a.level||0, bass=+a.bass||0, mid=+a.mid||0, high=+a.high||0;\n var min=0, max=1;\n var PI=Math.PI, TAU=6.283185307179586, PHI=1.618033988749895, E=Math.E,\n SQRT2=Math.SQRT2, SQRT3=1.7320508075688772, SQRT5=2.23606797749979,\n LN2=Math.LN2, LN10=Math.LN10, DEG=0.017453292519943295;\n var sin=Math.sin, cos=Math.cos, tan=Math.tan,\n asin=Math.asin, acos=Math.acos, atan=Math.atan, atan2=Math.atan2,\n sinh=Math.sinh, cosh=Math.cosh, tanh=Math.tanh,\n abs=Math.abs, sign=Math.sign, floor=Math.floor, ceil=Math.ceil,\n round=Math.round, trunc=Math.trunc, sqrt=Math.sqrt, cbrt=Math.cbrt,\n exp=Math.exp, log=Math.log, log2=Math.log2, log10=Math.log10,\n pow=Math.pow, hypot=Math.hypot;\n function frac(x){return x-floor(x);}\n function mod(a,b){return ((a%b)+b)%b;}\n function clamp(x,a,b){return x<a?a:(x>b?b:x);}\n function lerp(a,b,u){return a+(b-a)*u;}\n function smooth(u){u=clamp(u,0,1);return u*u*(3-2*u);}\n function wave(x){return sin(x*TAU)*0.5+0.5;}\n function saw(x){return frac(x);}\n function tri(x){var p=frac(x);return p<0.5?p*2:(1-p)*2;}\n function pulse(x,w){w=(w===undefined?0.5:w);return frac(x)<w?1:0;}\n function ease(x,c){c=(c===undefined?2:c);var p=frac(x);var v=p<0.5?p*2:(1-p)*2;return pow(v,c);}\n function bell(x){var p=frac(x);return exp(-pow((p-0.5)*6,2));}\n function step(x,k){k=(k===undefined?4:k);return floor(frac(x)*k)/k;}\n function rand(){return Math.random();}\n", Re = /* @__PURE__ */ new Map(), ze = /\b(level|bass|mid|high|rand)\b/;
385
+ function Be(e) {
386
+ let t = String(e), n = Re.get(t);
387
+ if (n) return n;
388
+ let r;
389
+ try {
390
+ let e = Function("t", "a", ...Fe, `${Le}return (${t});`);
391
+ if (typeof e(1, Ie) != "number") throw Error("not numeric");
392
+ let n = 0;
393
+ r = {
394
+ ok: !0,
395
+ usesLive: ze.test(t),
396
+ fn: (t, r = M()) => {
397
+ try {
398
+ let i = e(t, r);
399
+ return typeof i == "number" && Number.isFinite(i) ? (n = i, i) : n;
400
+ } catch {
401
+ return n;
402
+ }
403
+ }
404
+ };
405
+ } catch {
406
+ r = {
407
+ ok: !1,
408
+ usesLive: !1,
409
+ fn: () => 0
410
+ };
411
+ }
412
+ return Re.set(t, r), r;
413
+ }
414
+ //#endregion
415
+ //#region src/editor/params/sources.js
416
+ var H = /* @__PURE__ */ new Map();
417
+ function U(e) {
418
+ if (!e?.id) throw Error("modulation source needs an id");
419
+ return H.set(e.id, e), e;
420
+ }
421
+ function Ve(e) {
422
+ return H.get(e);
423
+ }
424
+ function He() {
425
+ return [...H.values()];
426
+ }
427
+ function Ue(e, t, n) {
428
+ let r = H.get(e);
429
+ if (!r) return 0;
430
+ let i = r.sample(t, n);
431
+ return Number.isFinite(i) ? Math.min(1, Math.max(0, i)) : 0;
432
+ }
433
+ function We() {
434
+ for (let e of H.values()) if (e.live && e.active?.()) return !0;
435
+ return !1;
436
+ }
437
+ U({
438
+ id: "time",
439
+ label: "Time",
440
+ sample: (e) => e?.t ?? 0
441
+ }), U({
442
+ id: "mouseX",
443
+ label: "Mouse X",
444
+ sample: (e) => e?.mouse?.x ?? 0
445
+ }), U({
446
+ id: "mouseY",
447
+ label: "Mouse Y",
448
+ sample: (e) => e?.mouse?.y ?? 0
449
+ });
450
+ var Ge = (e) => (t, n) => {
451
+ let r = t?.stage, i = n?.layer;
452
+ return !r || !i || i.w == null || i.h == null ? .5 : e === "x" ? (r.x - i.x) / Math.max(1, i.w) : (r.y - i.y) / Math.max(1, i.h);
453
+ };
454
+ U({
455
+ id: "layerX",
456
+ label: "Pointer over layer X",
457
+ sample: Ge("x")
458
+ }), U({
459
+ id: "layerY",
460
+ label: "Pointer over layer Y",
461
+ sample: Ge("y")
462
+ });
463
+ var W = (e, t) => {
464
+ let n = t?.transform?.rate ?? 1, r = t?.transform?.phase ?? 0;
465
+ return ((e?.t ?? 0) * n + r) % 1;
466
+ };
467
+ U({
468
+ id: "lfo-sine",
469
+ label: "LFO · sine",
470
+ sample: (e, t) => .5 - .5 * Math.cos(W(e, t) * Math.PI * 2)
471
+ }), U({
472
+ id: "lfo-triangle",
473
+ label: "LFO · triangle",
474
+ sample: (e, t) => {
475
+ let n = W(e, t);
476
+ return n < .5 ? n * 2 : 2 - n * 2;
477
+ }
478
+ }), U({
479
+ id: "lfo-square",
480
+ label: "LFO · square",
481
+ sample: (e, t) => +(W(e, t) < .5)
482
+ });
483
+ var Ke = 0;
484
+ U({
485
+ id: "expr",
486
+ label: "Expression",
487
+ live: !0,
488
+ active: () => performance.now() < Ke,
489
+ sample: (e, t) => {
490
+ let n = Be(t?.transform?.expr ?? "wave(t)");
491
+ return n.usesLive && (Ke = performance.now() + 500), n.fn((e?.t ?? 0) * X.getLoopSeconds());
492
+ }
493
+ });
494
+ var G = (e) => ({
495
+ id: `audio-${e}`,
496
+ label: `Audio · ${e}`,
497
+ live: !0,
498
+ active: ve,
499
+ ensure: () => ge(),
500
+ sample: () => M()[e]
501
+ });
502
+ U(G("level")), U(G("bass")), U(G("mid")), U(G("high")), U({
503
+ ...G("level"),
504
+ id: "audio",
505
+ hidden: !0
506
+ }), U({
507
+ id: "midi",
508
+ label: "MIDI CC",
509
+ live: !0,
510
+ active: () => Ce() && Te(),
511
+ ensure: () => Se(),
512
+ sample: (e, t) => {
513
+ let n = t?.transform?.cc;
514
+ return n == null ? 0 : we(n);
515
+ }
516
+ });
517
+ for (let e of V) U({
518
+ id: e.id,
519
+ label: e.label,
520
+ live: !0,
521
+ active: R,
522
+ sample: e.read
523
+ });
524
+ U({
525
+ id: "padX",
526
+ label: "Joystick X",
527
+ hidden: !0,
528
+ live: !0,
529
+ active: R,
530
+ sample: V[0].read
531
+ }), U({
532
+ id: "padY",
533
+ label: "Joystick Y",
534
+ hidden: !0,
535
+ live: !0,
536
+ active: R,
537
+ sample: V[1].read
538
+ });
539
+ //#endregion
540
+ //#region src/editor/params/transport.js
541
+ var K = r({
542
+ loopIn: 0,
543
+ loopOut: 4,
544
+ looping: !0
545
+ }), qe = {
546
+ x: .5,
547
+ y: .5
548
+ }, Je = null, Ye = 0, q = /* @__PURE__ */ new Set(), Xe = null, J = !1;
549
+ function Y() {
550
+ Ye++, q.forEach((e) => e());
551
+ }
552
+ K.subscribe(Y);
553
+ function Ze() {
554
+ (K.playing || q.size > 0 && We()) && Y(), Xe = K.playing || q.size > 0 ? requestAnimationFrame(Ze) : null;
555
+ }
556
+ function Qe() {
557
+ Xe ??= requestAnimationFrame(Ze);
558
+ }
559
+ if (typeof window < "u") {
560
+ let e = (e) => {
561
+ qe = {
562
+ x: e.clientX / window.innerWidth,
563
+ y: e.clientY / window.innerHeight
564
+ }, J && q.size > 0 && Y();
565
+ };
566
+ window.addEventListener("pointermove", e), window.addEventListener("pointerdown", e);
567
+ }
568
+ var X = {
569
+ play() {
570
+ K.play(), Qe();
571
+ },
572
+ pause() {
573
+ K.pause();
574
+ },
575
+ toggle() {
576
+ K.playing ? X.pause() : X.play();
577
+ },
578
+ seek(e) {
579
+ K.seekPhase(e);
580
+ },
581
+ stop() {
582
+ K.stop();
583
+ },
584
+ rewind() {
585
+ K.home();
586
+ },
587
+ setLoopSeconds(e) {
588
+ let t = K.phase();
589
+ K.setLoopSeconds(e), K.seekPhase(t);
590
+ },
591
+ isPlaying() {
592
+ return K.playing;
593
+ },
594
+ getLoopSeconds() {
595
+ return K.loopSeconds;
596
+ },
597
+ getT() {
598
+ return K.phase();
599
+ },
600
+ getEpoch() {
601
+ return K.epoch;
602
+ },
603
+ getCtx() {
604
+ return {
605
+ t: K.phase(),
606
+ mouse: qe,
607
+ stage: Je,
608
+ epoch: K.epoch
609
+ };
610
+ },
611
+ clock: K,
612
+ setStagePointer(e, t, n = !1) {
613
+ Je = e == null || ce().interactions === !1 ? null : {
614
+ x: e,
615
+ y: t,
616
+ down: !!n
617
+ }, J && q.size > 0 && Y();
618
+ },
619
+ setPointerInterest(e) {
620
+ J = !!e;
621
+ }
622
+ };
623
+ function Z(e) {
624
+ return q.add(e), Qe(), () => q.delete(e);
625
+ }
626
+ function $e() {
627
+ return () => {};
628
+ }
629
+ function Q() {
630
+ return Ye;
631
+ }
632
+ function et(e) {
633
+ return n(e ? Z : $e, Q, Q), X.getCtx();
634
+ }
635
+ function tt() {
636
+ return n(Z, Q, Q), {
637
+ playing: K.playing,
638
+ loopSeconds: K.loopSeconds,
639
+ t: K.phase(),
640
+ play: X.play,
641
+ pause: X.pause,
642
+ toggle: X.toggle,
643
+ seek: X.seek,
644
+ stop: X.stop,
645
+ rewind: X.rewind,
646
+ setLoopSeconds: X.setLoopSeconds
647
+ };
648
+ }
649
+ var nt = () => K.playing, rt = () => K.epoch;
650
+ function it() {
651
+ return n(Z, nt, nt);
652
+ }
653
+ function at() {
654
+ return n(Z, rt, rt);
655
+ }
656
+ //#endregion
657
+ //#region src/editor/lib/themes.js
658
+ var $ = [
659
+ {
660
+ id: "dark",
661
+ label: "Dark",
662
+ bg: "#050506",
663
+ fg: "#9ec1ff",
664
+ accent: "#9ec1ff",
665
+ dim: "#4a4d60",
666
+ warm: "#f3c9c4",
667
+ grid: "#ffffff",
668
+ gridOpacity: .1
669
+ },
670
+ {
671
+ id: "paper",
672
+ label: "Paper",
673
+ bg: "#f4f1ea",
674
+ fg: "#16202e",
675
+ accent: "#3b5b8a",
676
+ dim: "#6b7280",
677
+ warm: "#b0623a",
678
+ grid: "#16202e",
679
+ gridOpacity: .14
680
+ },
681
+ {
682
+ id: "blueprint",
683
+ label: "Blueprint",
684
+ bg: "#0b1d3a",
685
+ fg: "#8fd3ff",
686
+ accent: "#8fd3ff",
687
+ dim: "#3f5a78",
688
+ warm: "#e3a054",
689
+ grid: "#8fd3ff",
690
+ gridOpacity: .2
691
+ },
692
+ {
693
+ id: "mono",
694
+ label: "Mono",
695
+ bg: "#0a0a0a",
696
+ fg: "#ededed",
697
+ accent: "#ededed",
698
+ dim: "#8a8a8a",
699
+ warm: "#d8c4a0",
700
+ grid: "#ffffff",
701
+ gridOpacity: .08
702
+ },
703
+ {
704
+ id: "amber",
705
+ label: "Amber",
706
+ bg: "#0c0a06",
707
+ fg: "#ffb35c",
708
+ accent: "#ffcf8a",
709
+ dim: "#8a6a3a",
710
+ warm: "#ffd8a0",
711
+ grid: "#ffcf8a",
712
+ gridOpacity: .12
713
+ },
714
+ {
715
+ id: "ink",
716
+ label: "Ink",
717
+ bg: "#0a0b14",
718
+ fg: "#f0ead8",
719
+ accent: "#8b8fd6",
720
+ dim: "#4a4d60",
721
+ warm: "#f3c9c4",
722
+ grid: "#f0ead8",
723
+ gridOpacity: .07
724
+ },
725
+ {
726
+ id: "slate",
727
+ label: "Slate",
728
+ bg: "#12161d",
729
+ fg: "#e7eef5",
730
+ accent: "#7fb0d8",
731
+ dim: "#566273",
732
+ warm: "#cfe0ee",
733
+ grid: "#e7eef5",
734
+ gridOpacity: .07
735
+ },
736
+ {
737
+ id: "plum",
738
+ label: "Plum",
739
+ bg: "#120a17",
740
+ fg: "#f0e6f3",
741
+ accent: "#c08bd6",
742
+ dim: "#5e4a66",
743
+ warm: "#f3c9e8",
744
+ grid: "#f0e6f3",
745
+ gridOpacity: .07
746
+ },
747
+ {
748
+ id: "kol",
749
+ label: "KOL",
750
+ bg: "#121215",
751
+ fg: "#FAF7F0",
752
+ accent: "#FFCF33",
753
+ dim: "#3F6485",
754
+ warm: "#E3A054",
755
+ grid: "#FAF7F0",
756
+ gridOpacity: .1
757
+ }
758
+ ], ot = $.map((e) => ({
759
+ value: e.id,
760
+ label: e.label
761
+ }));
762
+ function st(e) {
763
+ return $.find((t) => t.id === e) || $[0];
764
+ }
765
+ function ct(e, t = !1) {
766
+ let n = st(e);
767
+ return t ? {
768
+ ...n,
769
+ bg: n.fg,
770
+ fg: n.bg,
771
+ grid: n.bg
772
+ } : { ...n };
773
+ }
774
+ //#endregion
775
+ //#region __vite-browser-external
776
+ var lt = /* @__PURE__ */ l(((e, t) => {
777
+ t.exports = {};
778
+ }));
779
+ //#endregion
780
+ export { p as A, ce as C, re as D, fe as E, ne as F, oe as M, l as N, ae as O, u as P, M as S, ue as T, Pe as _, st as a, _e as b, et as c, Ve as d, He as f, Ae as g, Fe as h, ct as i, d as j, ie as k, at as l, Be as m, $ as n, X as o, Ue as p, ot as r, tt as s, lt as t, it as u, Ee as v, le as w, ge as x, ye as y };