@kolkrabbi/design-editor 0.46.0 → 0.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{BindDot-B0VcuOag.js → BindDot-Cx-M0iQt.js} +9 -8
- package/dist/{BufferResource-BfLgK37S.js → BufferResource-Di5teicy.js} +2 -2
- package/dist/{CanvasPool-YNSF8hsR.js → CanvasPool-JdLj49b-.js} +1 -1
- package/dist/CanvasRenderer-fXDObOOi.js +2 -0
- package/dist/{FederatedEventTarget-BJgROaRQ.js → FederatedEventTarget-CH0bzxx1.js} +1 -1
- package/dist/{FilterSystem-BUrPNXx-.js → FilterSystem-C-ZoyuTO.js} +3 -3
- package/dist/{Geometry-C5s5KpWq.js → Geometry-D4tiuMOr.js} +1 -1
- package/dist/KolboxView-BjYfn_tl.js +21615 -0
- package/dist/{RenderTargetSystem-oFwWv5IW.js → RenderTargetSystem-Bom_vhlS.js} +1 -1
- package/dist/{Timeline-Ck1rBV8S.js → Timeline-CRr43b4B.js} +49 -53
- package/dist/TreePicker-DXsAlHK6.js +209 -0
- package/dist/WebGLRenderer-4hvrGmfW.js +2 -0
- package/dist/WebGPURenderer-BjzMV7Pg.js +2 -0
- package/dist/__vite-browser-external-y2xWjzgx.js +780 -0
- package/dist/browserAll-BFE0MRLW.js +6 -0
- package/dist/{canvasUtils-BoNfkAod.js → canvasUtils-DUNsu3ct.js} +1 -1
- package/dist/{core-BBb9Tk4Q.js → core-BbKj9Svq.js} +5877 -8206
- package/dist/core.js +6 -5
- package/dist/design-editor.css +2 -1
- package/dist/design-editor.js +7 -3644
- package/dist/{effectCategories-Ccye-8LP.js → effectCategories-wHY9ih8L.js} +8966 -4985
- package/dist/effects-D7J0e5xl.js +447 -0
- package/dist/effects.js +1 -1
- package/dist/{generators-BdVXv0jY.js → generators-BtRZ3Stj.js} +2473 -2538
- package/dist/generators.js +1 -1
- package/dist/{getTextureBatchBindGroup-CNWhZRbV.js → getTextureBatchBindGroup-ZMqkwiZS.js} +1 -1
- package/dist/{host-meUhieO9.js → host-0qv2SCjk.js} +1 -1
- package/dist/{host-9pJ7NvnR.js → host-II9SeVCH.js} +50 -50
- package/dist/init-DkGhdexn.js +4 -0
- package/dist/kolbox-sheet.js +0 -0
- package/dist/kolbox.css +3 -0
- package/dist/{morphStore-D6mkLJ-8.js → morphStore-s-rjCe-y.js} +1 -1
- package/dist/{motion-wsc6Qd7S.js → motion-CKtZAccJ.js} +765 -762
- package/dist/motion.js +1 -1
- package/dist/{pipeline-CMpuPUaX.js → pipeline-hZsOKbHd.js} +12 -12
- package/dist/{previewScale-SYKvfhUm.js → previewScale-C6EBx--U.js} +8 -8
- package/dist/{rolls-KpWCAeDv.js → rolls-Cnu6g8th.js} +10671 -4810
- package/dist/src-3UkpFoNW.js +3430 -0
- package/dist/{src-B5o6fGRJ.js → src-D-TQbBo2.js} +1 -2
- package/dist/{store-iBb0I6hk.js → store-YIW6P2zN.js} +289 -269
- package/dist/useLayerEdit-W_Tf3adq.js +455 -0
- package/dist/webworkerAll-0WBQ2FBr.js +2 -0
- package/package.json +16 -13
- package/dist/CanvasRenderer-Bl0rlqNq.js +0 -2
- package/dist/TreePicker-Dv0zpJwe.js +0 -166
- package/dist/WebGLRenderer-CXxpVIx3.js +0 -2
- package/dist/WebGPURenderer-BwLEUYBa.js +0 -2
- package/dist/browserAll-CAzdTUbR.js +0 -6
- package/dist/chunk-3b4jIN3o.js +0 -13
- package/dist/effects-B47bpwGh.js +0 -447
- package/dist/init-jApIMi04.js +0 -4
- package/dist/useLayerEdit-Ba7RA6qX.js +0 -454
- package/dist/webworkerAll-DEZhpG90.js +0 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as e, d as t, g as n, m as r, o as i, v as a } from "./__vite-browser-external-y2xWjzgx.js";
|
|
2
|
+
import { D as o, J as s, L as c, Mr as l, _ as u, b as ee, f as d, g as te, h as f, m as p, p as m, v as h, x as g, xn as ne, y as re } from "./rolls-Cnu6g8th.js";
|
|
2
3
|
import { Button as _, ButtonGroup as ie, CloseButton as v, ColorPickerPopover as ae, Dropdown as y, FullscreenOverlay as b, FunctionPlot as x, Input as S, LabeledControl as C, MenuDropdownItem as w, ModalShell as T, Section as E, Slider as D, Stepper as O, Tooltip as k } from "@kolkrabbi/kol-component";
|
|
3
4
|
import { createContext as oe, useCallback as A, useContext as se, useEffect as j, useMemo as ce, useRef as le, useState as M, useSyncExternalStore as N } from "react";
|
|
4
5
|
import { Fragment as ue, jsx as P, jsxs as F } from "react/jsx-runtime";
|
|
@@ -39,27 +40,27 @@ var fe = [
|
|
|
39
40
|
}
|
|
40
41
|
], I = 196, L = 64;
|
|
41
42
|
function pe({ expr: e }) {
|
|
42
|
-
let [
|
|
43
|
+
let [t, n] = M(0);
|
|
43
44
|
j(() => {
|
|
44
|
-
let e = 0,
|
|
45
|
-
|
|
45
|
+
let e = 0, t = () => {
|
|
46
|
+
n(i.getCtx().t ?? 0), e = requestAnimationFrame(t);
|
|
46
47
|
};
|
|
47
|
-
return e = requestAnimationFrame(
|
|
48
|
+
return e = requestAnimationFrame(t), () => cancelAnimationFrame(e);
|
|
48
49
|
}, []);
|
|
49
|
-
let
|
|
50
|
+
let a = r(e), o = i.getLoopSeconds(), s = I, c = Array.from({ length: 197 }, (e, t) => a.ok ? a.fn(t / s * o) : 0);
|
|
50
51
|
return /* @__PURE__ */ P(x, {
|
|
51
52
|
samples: c,
|
|
52
53
|
min: Math.min(0, ...c),
|
|
53
54
|
max: Math.max(1, ...c),
|
|
54
|
-
cursor:
|
|
55
|
+
cursor: t,
|
|
55
56
|
height: L,
|
|
56
57
|
ariaLabel: "Expression plot over one loop"
|
|
57
58
|
});
|
|
58
59
|
}
|
|
59
|
-
function
|
|
60
|
-
let l =
|
|
61
|
-
if (!
|
|
62
|
-
let h = u.source, g = u.transform ?? {}, ne = h.startsWith("lfo-"), re = h === "midi", v = n(h), ae = h === "expr", y = g.expr ?? "wave(t)", b = (e) => s(
|
|
60
|
+
function R({ layer: r, param: i, setProp: s }) {
|
|
61
|
+
let l = c(), u = r[i.key], [ee, d] = M(null), [te, f] = M(!1), [p, m] = M(!1);
|
|
62
|
+
if (!o(u) || u.bind !== "mod") return null;
|
|
63
|
+
let h = u.source, g = u.transform ?? {}, ne = h.startsWith("lfo-"), re = h === "midi", v = n(h), ae = h === "expr", y = g.expr ?? "wave(t)", b = (e) => s(i.key, {
|
|
63
64
|
...u,
|
|
64
65
|
transform: {
|
|
65
66
|
...g,
|
|
@@ -70,17 +71,17 @@ function me({ layer: t, param: r, setProp: s }) {
|
|
|
70
71
|
let t = String(e).trim();
|
|
71
72
|
t && t !== y && b({ expr: t });
|
|
72
73
|
}, T = async () => {
|
|
73
|
-
|
|
74
|
-
let e = await
|
|
75
|
-
|
|
74
|
+
f(!0);
|
|
75
|
+
let e = await a();
|
|
76
|
+
f(!1), e != null && b({ cc: e });
|
|
76
77
|
}, E = async () => {
|
|
77
78
|
m(!0);
|
|
78
|
-
let
|
|
79
|
-
m(!1),
|
|
79
|
+
let t = await e();
|
|
80
|
+
m(!1), t && s(i.key, {
|
|
80
81
|
...u,
|
|
81
|
-
source:
|
|
82
|
+
source: t
|
|
82
83
|
});
|
|
83
|
-
}, O = g.range ?? (
|
|
84
|
+
}, O = g.range ?? (i.min != null && i.max != null ? [i.min, i.max] : [0, 1]), k = (e, t) => {
|
|
84
85
|
let n = Number(e);
|
|
85
86
|
return Number.isFinite(n) ? n : t;
|
|
86
87
|
};
|
|
@@ -216,56 +217,56 @@ function me({ layer: t, param: r, setProp: s }) {
|
|
|
216
217
|
tone: "outline",
|
|
217
218
|
size: l,
|
|
218
219
|
onClick: T,
|
|
219
|
-
children:
|
|
220
|
+
children: te ? "Move a knob…" : "Learn"
|
|
220
221
|
})
|
|
221
222
|
}),
|
|
222
223
|
v && /* @__PURE__ */ P(C, {
|
|
223
|
-
label:
|
|
224
|
+
label: t(h)?.label ?? "Gamepad",
|
|
224
225
|
children: /* @__PURE__ */ P(_, {
|
|
225
226
|
tone: "outline",
|
|
226
227
|
size: l,
|
|
227
228
|
onClick: E,
|
|
228
|
-
children:
|
|
229
|
+
children: p ? "Move a control…" : "Learn"
|
|
229
230
|
})
|
|
230
231
|
})
|
|
231
232
|
]
|
|
232
233
|
});
|
|
233
234
|
}
|
|
234
|
-
function
|
|
235
|
-
let i = (n ?? []).filter((
|
|
236
|
-
let
|
|
237
|
-
return
|
|
235
|
+
function me({ layer: e, schema: n, setProp: r }) {
|
|
236
|
+
let i = (n ?? []).filter((t) => {
|
|
237
|
+
let n = e[t.key];
|
|
238
|
+
return o(n) && n.bind === "mod";
|
|
238
239
|
});
|
|
239
240
|
return i.length === 0 ? null : /* @__PURE__ */ F("div", {
|
|
240
241
|
className: "flex flex-col gap-4",
|
|
241
242
|
children: [/* @__PURE__ */ P("span", {
|
|
242
243
|
className: "kol-eyebrow text-fg-80",
|
|
243
244
|
children: "Modulation"
|
|
244
|
-
}), i.map((
|
|
245
|
-
let
|
|
245
|
+
}), i.map((n) => {
|
|
246
|
+
let i = t(e[n.key].source);
|
|
246
247
|
return /* @__PURE__ */ F("div", {
|
|
247
248
|
className: "flex flex-col gap-2 pt-3 border-t border-oq-08",
|
|
248
249
|
children: [/* @__PURE__ */ F("div", {
|
|
249
250
|
className: "flex items-center justify-between",
|
|
250
251
|
children: [/* @__PURE__ */ P("span", {
|
|
251
252
|
className: "kol-helper-12 text-emphasis",
|
|
252
|
-
children:
|
|
253
|
+
children: n.label ?? n.key
|
|
253
254
|
}), /* @__PURE__ */ P("span", {
|
|
254
255
|
className: "kol-helper-10 text-meta",
|
|
255
|
-
children:
|
|
256
|
+
children: i?.label ?? e[n.key].source
|
|
256
257
|
})]
|
|
257
|
-
}), /* @__PURE__ */ P(
|
|
258
|
-
layer:
|
|
259
|
-
param:
|
|
258
|
+
}), /* @__PURE__ */ P(R, {
|
|
259
|
+
layer: e,
|
|
260
|
+
param: n,
|
|
260
261
|
setProp: r
|
|
261
262
|
})]
|
|
262
|
-
},
|
|
263
|
+
}, n.key);
|
|
263
264
|
})]
|
|
264
265
|
});
|
|
265
266
|
}
|
|
266
267
|
//#endregion
|
|
267
268
|
//#region src/editor/modes/pattern/RuleRow.jsx
|
|
268
|
-
var
|
|
269
|
+
var z = [
|
|
269
270
|
{
|
|
270
271
|
value: "all",
|
|
271
272
|
label: "All cells"
|
|
@@ -294,7 +295,7 @@ var R = [
|
|
|
294
295
|
value: "expression",
|
|
295
296
|
label: "Expression…"
|
|
296
297
|
}
|
|
297
|
-
],
|
|
298
|
+
], B = [
|
|
298
299
|
{
|
|
299
300
|
value: 0,
|
|
300
301
|
label: "0°"
|
|
@@ -311,19 +312,19 @@ var R = [
|
|
|
311
312
|
value: 270,
|
|
312
313
|
label: "270°"
|
|
313
314
|
}
|
|
314
|
-
],
|
|
315
|
+
], he = [
|
|
315
316
|
"every-col",
|
|
316
317
|
"every-row",
|
|
317
318
|
"both",
|
|
318
319
|
"every-nth",
|
|
319
320
|
"checker"
|
|
320
|
-
],
|
|
321
|
+
], ge = [
|
|
321
322
|
0,
|
|
322
323
|
90,
|
|
323
324
|
180,
|
|
324
325
|
270
|
|
325
|
-
],
|
|
326
|
-
id:
|
|
326
|
+
], _e = 1, ve = () => `r${_e++}`, ye = () => ({
|
|
327
|
+
id: ve(),
|
|
327
328
|
selectKind: "every-col",
|
|
328
329
|
n: 2,
|
|
329
330
|
offset: 0,
|
|
@@ -337,9 +338,9 @@ var R = [
|
|
|
337
338
|
flipV: !1,
|
|
338
339
|
hide: !1,
|
|
339
340
|
opacity: 1
|
|
340
|
-
}),
|
|
341
|
-
id:
|
|
342
|
-
selectKind:
|
|
341
|
+
}), be = (e) => e[Math.floor(Math.random() * e.length)], xe = () => ({
|
|
342
|
+
id: ve(),
|
|
343
|
+
selectKind: be(he),
|
|
343
344
|
n: Math.floor(Math.random() * 5) + 2,
|
|
344
345
|
offset: Math.floor(Math.random() * 3),
|
|
345
346
|
n2: Math.floor(Math.random() * 5) + 2,
|
|
@@ -347,13 +348,13 @@ var R = [
|
|
|
347
348
|
expression: "sin(col * 0.6) + cos(row * 0.6)",
|
|
348
349
|
groupW: Math.random() > .6 ? Math.floor(Math.random() * 3) + 1 : 1,
|
|
349
350
|
groupH: Math.random() > .6 ? Math.floor(Math.random() * 3) + 1 : 1,
|
|
350
|
-
rotate:
|
|
351
|
+
rotate: be(ge),
|
|
351
352
|
flipH: Math.random() > .6,
|
|
352
353
|
flipV: Math.random() > .6,
|
|
353
354
|
hide: Math.random() > .85,
|
|
354
355
|
opacity: Math.random() > .7 ? .4 + Math.random() * .6 : 1
|
|
355
356
|
});
|
|
356
|
-
function
|
|
357
|
+
function V({ value: e, onChange: t, min: n = 0, max: r = 99 }) {
|
|
357
358
|
return /* @__PURE__ */ P(O, {
|
|
358
359
|
size: "sm",
|
|
359
360
|
value: e,
|
|
@@ -363,7 +364,7 @@ function B({ value: e, onChange: t, min: n = 0, max: r = 99 }) {
|
|
|
363
364
|
className: "w-full"
|
|
364
365
|
});
|
|
365
366
|
}
|
|
366
|
-
function
|
|
367
|
+
function Se({ active: e, onClick: t, children: n, title: r }) {
|
|
367
368
|
return /* @__PURE__ */ P(k, {
|
|
368
369
|
label: r,
|
|
369
370
|
children: /* @__PURE__ */ P(_, {
|
|
@@ -376,7 +377,7 @@ function Ce({ active: e, onClick: t, children: n, title: r }) {
|
|
|
376
377
|
})
|
|
377
378
|
});
|
|
378
379
|
}
|
|
379
|
-
function
|
|
380
|
+
function Ce({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
|
|
380
381
|
let i = (n) => t({
|
|
381
382
|
...e,
|
|
382
383
|
...n
|
|
@@ -393,7 +394,7 @@ function we({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
|
|
|
393
394
|
variant: "subtle",
|
|
394
395
|
size: "sm",
|
|
395
396
|
className: "w-full",
|
|
396
|
-
options:
|
|
397
|
+
options: z,
|
|
397
398
|
value: e.selectKind,
|
|
398
399
|
onChange: (e) => i({ selectKind: e })
|
|
399
400
|
})
|
|
@@ -430,14 +431,14 @@ function we({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
|
|
|
430
431
|
className: "grid grid-cols-2 gap-2",
|
|
431
432
|
children: [/* @__PURE__ */ P(E, {
|
|
432
433
|
label: "N",
|
|
433
|
-
children: /* @__PURE__ */ P(
|
|
434
|
+
children: /* @__PURE__ */ P(V, {
|
|
434
435
|
value: e.n,
|
|
435
436
|
onChange: (e) => i({ n: e }),
|
|
436
437
|
min: 1
|
|
437
438
|
})
|
|
438
439
|
}), /* @__PURE__ */ P(E, {
|
|
439
440
|
label: "Offset",
|
|
440
|
-
children: /* @__PURE__ */ P(
|
|
441
|
+
children: /* @__PURE__ */ P(V, {
|
|
441
442
|
value: e.offset,
|
|
442
443
|
onChange: (e) => i({ offset: e })
|
|
443
444
|
})
|
|
@@ -447,14 +448,14 @@ function we({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
|
|
|
447
448
|
className: "grid grid-cols-2 gap-2",
|
|
448
449
|
children: [/* @__PURE__ */ P(E, {
|
|
449
450
|
label: "Row N",
|
|
450
|
-
children: /* @__PURE__ */ P(
|
|
451
|
+
children: /* @__PURE__ */ P(V, {
|
|
451
452
|
value: e.n2,
|
|
452
453
|
onChange: (e) => i({ n2: e }),
|
|
453
454
|
min: 1
|
|
454
455
|
})
|
|
455
456
|
}), /* @__PURE__ */ P(E, {
|
|
456
457
|
label: "Row offset",
|
|
457
|
-
children: /* @__PURE__ */ P(
|
|
458
|
+
children: /* @__PURE__ */ P(V, {
|
|
458
459
|
value: e.offset2,
|
|
459
460
|
onChange: (e) => i({ offset2: e })
|
|
460
461
|
})
|
|
@@ -478,14 +479,14 @@ function we({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
|
|
|
478
479
|
className: "grid grid-cols-2 gap-2",
|
|
479
480
|
children: [/* @__PURE__ */ P(E, {
|
|
480
481
|
label: "Group W",
|
|
481
|
-
children: /* @__PURE__ */ P(
|
|
482
|
+
children: /* @__PURE__ */ P(V, {
|
|
482
483
|
value: e.groupW,
|
|
483
484
|
onChange: (e) => i({ groupW: Math.max(1, e) }),
|
|
484
485
|
min: 1
|
|
485
486
|
})
|
|
486
487
|
}), /* @__PURE__ */ P(E, {
|
|
487
488
|
label: "Group H",
|
|
488
|
-
children: /* @__PURE__ */ P(
|
|
489
|
+
children: /* @__PURE__ */ P(V, {
|
|
489
490
|
value: e.groupH,
|
|
490
491
|
onChange: (e) => i({ groupH: Math.max(1, e) }),
|
|
491
492
|
min: 1
|
|
@@ -498,23 +499,23 @@ function we({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
|
|
|
498
499
|
/* @__PURE__ */ P(y, {
|
|
499
500
|
variant: "subtle",
|
|
500
501
|
size: "sm",
|
|
501
|
-
options:
|
|
502
|
+
options: B,
|
|
502
503
|
value: e.rotate,
|
|
503
504
|
onChange: (e) => i({ rotate: Number(e) })
|
|
504
505
|
}),
|
|
505
|
-
/* @__PURE__ */ P(
|
|
506
|
+
/* @__PURE__ */ P(Se, {
|
|
506
507
|
active: e.flipH,
|
|
507
508
|
onClick: () => i({ flipH: !e.flipH }),
|
|
508
509
|
title: "Flip horizontal",
|
|
509
510
|
children: "⇋"
|
|
510
511
|
}),
|
|
511
|
-
/* @__PURE__ */ P(
|
|
512
|
+
/* @__PURE__ */ P(Se, {
|
|
512
513
|
active: e.flipV,
|
|
513
514
|
onClick: () => i({ flipV: !e.flipV }),
|
|
514
515
|
title: "Flip vertical",
|
|
515
516
|
children: "⇵"
|
|
516
517
|
}),
|
|
517
|
-
/* @__PURE__ */ P(
|
|
518
|
+
/* @__PURE__ */ P(Se, {
|
|
518
519
|
active: e.hide,
|
|
519
520
|
onClick: () => i({ hide: !e.hide }),
|
|
520
521
|
title: "Hide cell",
|
|
@@ -537,8 +538,8 @@ function we({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
|
|
|
537
538
|
}
|
|
538
539
|
//#endregion
|
|
539
540
|
//#region src/editor/library/mergeRemote.js
|
|
540
|
-
var
|
|
541
|
-
function
|
|
541
|
+
var we = (e) => e?.updatedAt ?? e?.savedAt ?? 0, Te = (e) => /^(Plan08 |Sync [A-Z] \d{13}|Morph [A-Z] \d{13})/.test(e?.name ?? "");
|
|
542
|
+
function Ee(e, t) {
|
|
542
543
|
let n = {}, r = [], i = /* @__PURE__ */ new Map();
|
|
543
544
|
for (let e of t || []) i.has(e.kind) || i.set(e.kind, /* @__PURE__ */ new Map()), i.get(e.kind).set(e.id, e);
|
|
544
545
|
let a = new Set([...Object.keys(e || {}), ...i.keys()]);
|
|
@@ -550,7 +551,7 @@ function De(e, t) {
|
|
|
550
551
|
o.push(n);
|
|
551
552
|
continue;
|
|
552
553
|
}
|
|
553
|
-
if (
|
|
554
|
+
if (Te(n)) {
|
|
554
555
|
s.add(n.id), e && !e.deleted && r.push({
|
|
555
556
|
op: "remove",
|
|
556
557
|
kind: t,
|
|
@@ -567,7 +568,7 @@ function De(e, t) {
|
|
|
567
568
|
continue;
|
|
568
569
|
}
|
|
569
570
|
if (e.deleted) {
|
|
570
|
-
if (e.updatedAt >
|
|
571
|
+
if (e.updatedAt > we(n)) continue;
|
|
571
572
|
o.push(n), r.push({
|
|
572
573
|
op: "put",
|
|
573
574
|
kind: t,
|
|
@@ -575,7 +576,7 @@ function De(e, t) {
|
|
|
575
576
|
});
|
|
576
577
|
continue;
|
|
577
578
|
}
|
|
578
|
-
e.updatedAt >
|
|
579
|
+
e.updatedAt > we(n) ? o.push(e.spec) : (o.push(n), e.updatedAt < we(n) && r.push({
|
|
579
580
|
op: "put",
|
|
580
581
|
kind: t,
|
|
581
582
|
item: n
|
|
@@ -583,7 +584,7 @@ function De(e, t) {
|
|
|
583
584
|
}
|
|
584
585
|
let c = new Set(o.map((e) => e.id));
|
|
585
586
|
for (let e of a.values()) if (!(e.deleted || c.has(e.id) || s.has(e.id))) {
|
|
586
|
-
if (
|
|
587
|
+
if (Te(e.spec)) {
|
|
587
588
|
r.push({
|
|
588
589
|
op: "remove",
|
|
589
590
|
kind: t,
|
|
@@ -602,19 +603,19 @@ function De(e, t) {
|
|
|
602
603
|
}
|
|
603
604
|
//#endregion
|
|
604
605
|
//#region src/editor/library/libraryApi.js
|
|
605
|
-
var
|
|
606
|
-
function
|
|
607
|
-
|
|
606
|
+
var H = null;
|
|
607
|
+
function De(e) {
|
|
608
|
+
H = typeof e == "string" && e.trim() ? e.trim().replace(/\/+$/, "") : null, Le();
|
|
608
609
|
}
|
|
609
|
-
function
|
|
610
|
-
return
|
|
610
|
+
function Oe() {
|
|
611
|
+
return H;
|
|
611
612
|
}
|
|
612
|
-
var
|
|
613
|
+
var U = class extends Error {
|
|
613
614
|
constructor() {
|
|
614
615
|
super("unauthorized"), this.name = "UnauthorizedError";
|
|
615
616
|
}
|
|
616
617
|
};
|
|
617
|
-
function
|
|
618
|
+
function ke(e, t) {
|
|
618
619
|
let n = `Bearer ${t}`, r = async (t, r = {}) => {
|
|
619
620
|
let i = await fetch(`${e}${t}`, {
|
|
620
621
|
...r,
|
|
@@ -624,7 +625,7 @@ function Ae(e, t) {
|
|
|
624
625
|
...r.headers || {}
|
|
625
626
|
}
|
|
626
627
|
});
|
|
627
|
-
if (i.status === 401) throw new
|
|
628
|
+
if (i.status === 401) throw new U();
|
|
628
629
|
if (!i.ok) throw Error(`library api ${i.status}`);
|
|
629
630
|
return i.json();
|
|
630
631
|
};
|
|
@@ -648,33 +649,33 @@ function Ae(e, t) {
|
|
|
648
649
|
}
|
|
649
650
|
};
|
|
650
651
|
}
|
|
651
|
-
var
|
|
652
|
-
function
|
|
653
|
-
return
|
|
652
|
+
var Ae = "kol.fxr.library-session", W = null, je = /* @__PURE__ */ new Set(), G = () => je.forEach((e) => e());
|
|
653
|
+
function Me() {
|
|
654
|
+
return W;
|
|
654
655
|
}
|
|
655
|
-
var
|
|
656
|
-
function
|
|
656
|
+
var Ne = () => N((e) => (je.add(e), () => je.delete(e)), Me, Me), Pe = () => Ne()?.user ?? null;
|
|
657
|
+
function K(e) {
|
|
657
658
|
try {
|
|
658
|
-
e ? localStorage.setItem(
|
|
659
|
+
e ? localStorage.setItem(Ae, JSON.stringify(e)) : localStorage.removeItem(Ae);
|
|
659
660
|
} catch {}
|
|
660
661
|
}
|
|
661
|
-
var
|
|
662
|
+
var Fe = () => {
|
|
662
663
|
try {
|
|
663
|
-
return JSON.parse(localStorage.getItem(
|
|
664
|
+
return JSON.parse(localStorage.getItem(Ae) || "null");
|
|
664
665
|
} catch {
|
|
665
666
|
return null;
|
|
666
667
|
}
|
|
667
668
|
};
|
|
668
|
-
function
|
|
669
|
-
let { next: n, pushes: r } =
|
|
670
|
-
|
|
671
|
-
...
|
|
669
|
+
function Ie(e, t) {
|
|
670
|
+
let { next: n, pushes: r } = Ee(Q(), t);
|
|
671
|
+
ct({
|
|
672
|
+
...Q(),
|
|
672
673
|
...n
|
|
673
674
|
});
|
|
674
675
|
for (let t of r) e.push(t).catch(() => {});
|
|
675
676
|
}
|
|
676
|
-
async function
|
|
677
|
-
let r = await fetch(`${
|
|
677
|
+
async function q(e, t = {}, n) {
|
|
678
|
+
let r = await fetch(`${H}${e}`, {
|
|
678
679
|
...t,
|
|
679
680
|
headers: {
|
|
680
681
|
"content-type": "application/json",
|
|
@@ -682,50 +683,50 @@ async function K(e, t = {}, n) {
|
|
|
682
683
|
...t.headers || {}
|
|
683
684
|
}
|
|
684
685
|
});
|
|
685
|
-
if (r.status === 401) throw new
|
|
686
|
+
if (r.status === 401) throw new U();
|
|
686
687
|
let i = await r.json().catch(() => ({}));
|
|
687
688
|
if (!r.ok) throw Error(i.error || `library api ${r.status}`);
|
|
688
689
|
return i;
|
|
689
690
|
}
|
|
690
|
-
function
|
|
691
|
-
if (
|
|
692
|
-
let e =
|
|
693
|
-
if (!e?.token || e.base !==
|
|
694
|
-
let t =
|
|
695
|
-
|
|
691
|
+
function Le() {
|
|
692
|
+
if (W || !H) return;
|
|
693
|
+
let e = Fe();
|
|
694
|
+
if (!e?.token || e.base !== H || !(e.expiresAt > Date.now()) || !e.user) return;
|
|
695
|
+
let t = ke(H, e.token);
|
|
696
|
+
W = {
|
|
696
697
|
backend: t,
|
|
697
698
|
user: e.user,
|
|
698
699
|
token: e.token
|
|
699
|
-
},
|
|
700
|
-
|
|
701
|
-
...
|
|
700
|
+
}, G(), q("/api/me", {}, e.token).then(({ user: t }) => {
|
|
701
|
+
W?.token === e.token && (W = {
|
|
702
|
+
...W,
|
|
702
703
|
user: t
|
|
703
|
-
},
|
|
704
|
+
}, K({
|
|
704
705
|
...e,
|
|
705
706
|
user: t
|
|
706
|
-
}),
|
|
707
|
+
}), G());
|
|
707
708
|
}).catch((e) => {
|
|
708
|
-
e instanceof
|
|
709
|
-
}), t.hydrate().then((e) =>
|
|
710
|
-
e instanceof
|
|
709
|
+
e instanceof U && J();
|
|
710
|
+
}), t.hydrate().then((e) => Ie(t, e)).catch((e) => {
|
|
711
|
+
e instanceof U ? J() : console.warn("library sync: hydrate failed —", e?.message || e);
|
|
711
712
|
});
|
|
712
713
|
}
|
|
713
|
-
async function
|
|
714
|
-
let r =
|
|
715
|
-
return
|
|
714
|
+
async function Re({ token: e, expiresAt: t, user: n }) {
|
|
715
|
+
let r = ke(H, e), i = await r.hydrate();
|
|
716
|
+
return Ie(r, i), W = {
|
|
716
717
|
backend: r,
|
|
717
718
|
user: n,
|
|
718
719
|
token: e
|
|
719
|
-
},
|
|
720
|
-
base:
|
|
720
|
+
}, K({
|
|
721
|
+
base: H,
|
|
721
722
|
token: e,
|
|
722
723
|
expiresAt: t,
|
|
723
724
|
user: n
|
|
724
|
-
}),
|
|
725
|
+
}), G(), i.filter((e) => !e.deleted).length;
|
|
725
726
|
}
|
|
726
|
-
async function
|
|
727
|
-
if (!
|
|
728
|
-
return
|
|
727
|
+
async function ze({ email: e, password: t } = {}) {
|
|
728
|
+
if (!H) throw Error("no library api");
|
|
729
|
+
return Re(await q("/api/auth/signin", {
|
|
729
730
|
method: "POST",
|
|
730
731
|
body: JSON.stringify({
|
|
731
732
|
email: e,
|
|
@@ -733,48 +734,48 @@ async function Be({ email: e, password: t } = {}) {
|
|
|
733
734
|
})
|
|
734
735
|
}));
|
|
735
736
|
}
|
|
736
|
-
async function
|
|
737
|
-
if (!
|
|
738
|
-
return
|
|
737
|
+
async function Be(e) {
|
|
738
|
+
if (!H) throw Error("no library api");
|
|
739
|
+
return Re(await q("/api/auth/signup", {
|
|
739
740
|
method: "POST",
|
|
740
741
|
body: JSON.stringify(e)
|
|
741
742
|
}));
|
|
742
743
|
}
|
|
743
|
-
function
|
|
744
|
-
let e =
|
|
745
|
-
|
|
744
|
+
function J() {
|
|
745
|
+
let e = W?.token ?? Fe()?.token;
|
|
746
|
+
K(null), e && H && q("/api/auth/signout", {
|
|
746
747
|
method: "POST",
|
|
747
748
|
body: "{}"
|
|
748
|
-
}, e).catch(() => {}),
|
|
749
|
+
}, e).catch(() => {}), W && (W = null, G());
|
|
749
750
|
}
|
|
750
|
-
async function
|
|
751
|
-
if (!
|
|
752
|
-
let { user: t } = await
|
|
751
|
+
async function Ve(e) {
|
|
752
|
+
if (!W) throw new U();
|
|
753
|
+
let { user: t } = await q("/api/me", {
|
|
753
754
|
method: "PATCH",
|
|
754
755
|
body: JSON.stringify(e)
|
|
755
|
-
},
|
|
756
|
-
return
|
|
757
|
-
...
|
|
756
|
+
}, W.token);
|
|
757
|
+
return W = {
|
|
758
|
+
...W,
|
|
758
759
|
user: t
|
|
759
|
-
},
|
|
760
|
-
...
|
|
760
|
+
}, K({
|
|
761
|
+
...Fe(),
|
|
761
762
|
user: t
|
|
762
|
-
}),
|
|
763
|
+
}), G(), t;
|
|
763
764
|
}
|
|
764
|
-
async function
|
|
765
|
-
if (!
|
|
766
|
-
let { token: e, expiresAt: t } = await
|
|
765
|
+
async function He() {
|
|
766
|
+
if (!W) throw new U();
|
|
767
|
+
let { token: e, expiresAt: t } = await q("/api/invites", {
|
|
767
768
|
method: "POST",
|
|
768
769
|
body: "{}"
|
|
769
|
-
},
|
|
770
|
+
}, W.token);
|
|
770
771
|
return {
|
|
771
772
|
url: `${window.location.origin}/join?invite=${encodeURIComponent(e)}`,
|
|
772
773
|
expiresAt: t
|
|
773
774
|
};
|
|
774
775
|
}
|
|
775
|
-
async function
|
|
776
|
-
if (!
|
|
777
|
-
return
|
|
776
|
+
async function Ue({ name: e, email: t }) {
|
|
777
|
+
if (!H) throw Error("no library api");
|
|
778
|
+
return q("/api/invite-requests", {
|
|
778
779
|
method: "POST",
|
|
779
780
|
body: JSON.stringify({
|
|
780
781
|
name: e,
|
|
@@ -782,16 +783,16 @@ async function We({ name: e, email: t }) {
|
|
|
782
783
|
})
|
|
783
784
|
});
|
|
784
785
|
}
|
|
785
|
-
async function
|
|
786
|
-
if (!
|
|
787
|
-
return (await
|
|
786
|
+
async function We() {
|
|
787
|
+
if (!W) throw new U();
|
|
788
|
+
return (await q("/api/invite-requests", {}, W.token)).requests;
|
|
788
789
|
}
|
|
789
|
-
async function
|
|
790
|
-
if (!
|
|
791
|
-
let { token: t, expiresAt: n, email: r, name: i } = await
|
|
790
|
+
async function Ge(e) {
|
|
791
|
+
if (!W) throw new U();
|
|
792
|
+
let { token: t, expiresAt: n, email: r, name: i } = await q(`/api/invite-requests/${encodeURIComponent(e)}/invite`, {
|
|
792
793
|
method: "POST",
|
|
793
794
|
body: "{}"
|
|
794
|
-
},
|
|
795
|
+
}, W.token);
|
|
795
796
|
return {
|
|
796
797
|
url: `${window.location.origin}/join?invite=${encodeURIComponent(t)}`,
|
|
797
798
|
expiresAt: n,
|
|
@@ -801,17 +802,17 @@ async function Ke(e) {
|
|
|
801
802
|
}
|
|
802
803
|
//#endregion
|
|
803
804
|
//#region src/editor/library/LibraryProvider.jsx
|
|
804
|
-
var
|
|
805
|
+
var Ke = "kol.editor.library.v3", Y = [
|
|
805
806
|
"palette",
|
|
806
807
|
"pattern",
|
|
807
808
|
"type",
|
|
808
809
|
"preset"
|
|
809
|
-
],
|
|
810
|
+
], X = Y.reduce((e, t) => (e[t] = [], e), {}), qe = 1, Je = () => `i${Date.now().toString(36)}-${qe++}`, Ye = (e) => ({
|
|
810
811
|
...e,
|
|
811
|
-
id: e.id ??
|
|
812
|
+
id: e.id ?? Je(),
|
|
812
813
|
savedAt: e.savedAt ?? Date.now()
|
|
813
|
-
}),
|
|
814
|
-
function
|
|
814
|
+
}), Z = (e) => typeof e == "number" && Number.isFinite(e);
|
|
815
|
+
function Xe(e) {
|
|
815
816
|
return !e || !Array.isArray(e.colors) || e.colors.length === 0 ? null : {
|
|
816
817
|
colors: e.colors,
|
|
817
818
|
bgEnabled: !!e.bgEnabled,
|
|
@@ -819,39 +820,39 @@ function Ze(e) {
|
|
|
819
820
|
modeId: e.modeId ?? "random"
|
|
820
821
|
};
|
|
821
822
|
}
|
|
822
|
-
function
|
|
823
|
+
function Ze(e) {
|
|
823
824
|
return !e || typeof e.shapeId != "string" || e.shapeId === "type-composition" ? null : {
|
|
824
825
|
shapeId: e.shapeId,
|
|
825
826
|
customSvg: typeof e.customSvg == "string" ? e.customSvg : "",
|
|
826
|
-
cols:
|
|
827
|
-
rows:
|
|
828
|
-
gap:
|
|
829
|
-
padding:
|
|
827
|
+
cols: Z(e.cols) ? e.cols : 4,
|
|
828
|
+
rows: Z(e.rows) ? e.rows : 4,
|
|
829
|
+
gap: Z(e.gap) ? e.gap : 0,
|
|
830
|
+
padding: Z(e.padding) ? e.padding : 0,
|
|
830
831
|
stretch: !!e.stretch,
|
|
831
832
|
overflow: !!e.overflow,
|
|
832
833
|
bg: e.bg ?? null,
|
|
833
834
|
color: e.color ?? "palette:secondary",
|
|
834
835
|
rules: Array.isArray(e.rules) ? e.rules : [],
|
|
835
|
-
scale:
|
|
836
|
+
scale: Z(e.scale) ? e.scale : 256
|
|
836
837
|
};
|
|
837
838
|
}
|
|
838
|
-
function
|
|
839
|
+
function Qe(e) {
|
|
839
840
|
if (!e || typeof e.text != "string") return null;
|
|
840
841
|
let t = {
|
|
841
842
|
text: e.text,
|
|
842
843
|
width: e.width ?? "Tight",
|
|
843
|
-
weight:
|
|
844
|
+
weight: Z(e.weight) ? e.weight : 600,
|
|
844
845
|
italic: !!e.italic,
|
|
845
|
-
size:
|
|
846
|
-
tracking:
|
|
847
|
-
lineHeight:
|
|
846
|
+
size: Z(e.size) ? e.size : 96,
|
|
847
|
+
tracking: Z(e.tracking) ? e.tracking : -.01,
|
|
848
|
+
lineHeight: Z(e.lineHeight) ? e.lineHeight : 1.05,
|
|
848
849
|
case: e.case ?? "original",
|
|
849
850
|
color: e.color ?? "palette:dark",
|
|
850
851
|
textAlign: e.textAlign ?? "center"
|
|
851
852
|
};
|
|
852
853
|
return e.axisOn !== void 0 && (t.axisOn = e.axisOn, t.width2 = e.width2, t.weight2 = e.weight2, t.blend = e.blend), t;
|
|
853
854
|
}
|
|
854
|
-
function
|
|
855
|
+
function $e(e) {
|
|
855
856
|
return !e || !Array.isArray(e.layers) ? null : {
|
|
856
857
|
intent: e.intent ?? "whole",
|
|
857
858
|
aspect: e.aspect ?? "1:1",
|
|
@@ -863,44 +864,52 @@ function et(e) {
|
|
|
863
864
|
} : {},
|
|
864
865
|
...typeof e.mode == "string" ? { mode: e.mode } : {},
|
|
865
866
|
...e.morph && typeof e.morph == "object" ? { morph: e.morph } : {},
|
|
867
|
+
...typeof e.canvasX == "number" && typeof e.canvasY == "number" ? {
|
|
868
|
+
canvasX: e.canvasX,
|
|
869
|
+
canvasY: e.canvasY
|
|
870
|
+
} : {},
|
|
871
|
+
...e.canvas && typeof e.canvas == "object" ? { canvas: e.canvas } : {},
|
|
872
|
+
...Array.isArray(e.pages) ? { pages: e.pages } : {},
|
|
873
|
+
...typeof e.frameModel == "number" ? { frameModel: e.frameModel } : {},
|
|
874
|
+
...typeof e.layerModel == "number" ? { layerModel: e.layerModel } : {},
|
|
866
875
|
...typeof e.thumb == "string" ? { thumb: e.thumb } : {},
|
|
867
876
|
...e.shipped === !0 ? { shipped: !0 } : {},
|
|
868
877
|
...typeof e.group == "string" ? { group: e.group } : {},
|
|
869
878
|
...typeof e.sub == "string" ? { sub: e.sub } : {}
|
|
870
879
|
};
|
|
871
880
|
}
|
|
872
|
-
var
|
|
873
|
-
palette:
|
|
874
|
-
pattern:
|
|
875
|
-
type:
|
|
876
|
-
preset:
|
|
877
|
-
},
|
|
881
|
+
var et = {
|
|
882
|
+
palette: Xe,
|
|
883
|
+
pattern: Ze,
|
|
884
|
+
type: Qe,
|
|
885
|
+
preset: $e
|
|
886
|
+
}, tt = [
|
|
878
887
|
"id",
|
|
879
888
|
"savedAt",
|
|
880
889
|
"updatedAt",
|
|
881
890
|
"name"
|
|
882
891
|
];
|
|
883
|
-
function
|
|
892
|
+
function nt(e) {
|
|
884
893
|
let t = {};
|
|
885
|
-
for (let n of
|
|
894
|
+
for (let n of tt) e?.[n] !== void 0 && (t[n] = e[n]);
|
|
886
895
|
return t;
|
|
887
896
|
}
|
|
888
|
-
function
|
|
889
|
-
let t =
|
|
890
|
-
for (let n of
|
|
891
|
-
let r =
|
|
897
|
+
function rt(e) {
|
|
898
|
+
let t = Y.reduce((e, t) => (e[t] = [], e), {});
|
|
899
|
+
for (let n of Y) {
|
|
900
|
+
let r = et[n];
|
|
892
901
|
t[n] = (Array.isArray(e?.[n]) ? e[n] : []).map((e) => {
|
|
893
902
|
let t = r ? r(e) : e;
|
|
894
903
|
return t ? {
|
|
895
904
|
v: 1,
|
|
896
|
-
...
|
|
905
|
+
...nt(e),
|
|
897
906
|
...t
|
|
898
907
|
} : null;
|
|
899
908
|
}).filter(Boolean);
|
|
900
909
|
}
|
|
901
910
|
return t;
|
|
902
911
|
}
|
|
903
|
-
function
|
|
912
|
+
function it(e) {
|
|
904
913
|
return Array.isArray(e) ? e.map((e) => e?.type ? e.type === "bg" ? {
|
|
905
914
|
...e,
|
|
906
915
|
type: "background"
|
|
@@ -913,7 +922,7 @@ function at(e) {
|
|
|
913
922
|
kind: "logo"
|
|
914
923
|
} : e : e) : e;
|
|
915
924
|
}
|
|
916
|
-
function
|
|
925
|
+
function at(e) {
|
|
917
926
|
let t = {};
|
|
918
927
|
for (let n of [
|
|
919
928
|
"palette",
|
|
@@ -924,37 +933,37 @@ function ot(e) {
|
|
|
924
933
|
"composition"
|
|
925
934
|
]) {
|
|
926
935
|
let r = e?.[n];
|
|
927
|
-
Array.isArray(r) ? t[n] = r : r && typeof r == "object" ? t[n] = [
|
|
936
|
+
Array.isArray(r) ? t[n] = r : r && typeof r == "object" ? t[n] = [Ye(r)] : t[n] = [];
|
|
928
937
|
}
|
|
929
938
|
return t;
|
|
930
939
|
}
|
|
931
|
-
function
|
|
932
|
-
let t =
|
|
940
|
+
function ot(e) {
|
|
941
|
+
let t = Y.reduce((e, t) => (e[t] = [], e), {}), n = (e) => Array.isArray(e) ? e : e && typeof e == "object" ? [Ye(e)] : [];
|
|
933
942
|
t.palette = n(e?.palette), t.pattern = n(e?.pattern), t.type = n(e?.type);
|
|
934
943
|
let r = n(e?.layout), i = n(e?.composition).map((e) => ({
|
|
935
944
|
...e,
|
|
936
|
-
layers:
|
|
945
|
+
layers: it(e.layers)
|
|
937
946
|
}));
|
|
938
947
|
return t.preset = [...r, ...i], t;
|
|
939
948
|
}
|
|
940
|
-
function
|
|
941
|
-
if (typeof window > "u") return
|
|
949
|
+
function Q() {
|
|
950
|
+
if (typeof window > "u") return X;
|
|
942
951
|
try {
|
|
943
|
-
let e = window.localStorage.getItem(
|
|
944
|
-
if (e) return
|
|
952
|
+
let e = window.localStorage.getItem(Ke);
|
|
953
|
+
if (e) return rt(JSON.parse(e));
|
|
945
954
|
let t = window.localStorage.getItem("kol.generator.library.v2");
|
|
946
|
-
if (t) return window.localStorage.setItem("kol.generator.library.v2._backup", t),
|
|
955
|
+
if (t) return window.localStorage.setItem("kol.generator.library.v2._backup", t), rt(ot(JSON.parse(t)));
|
|
947
956
|
let n = window.localStorage.getItem("kol.generator.library.v1");
|
|
948
|
-
return n ?
|
|
957
|
+
return n ? rt(ot(at(JSON.parse(n)))) : X;
|
|
949
958
|
} catch {
|
|
950
|
-
return
|
|
959
|
+
return X;
|
|
951
960
|
}
|
|
952
961
|
}
|
|
953
|
-
var
|
|
954
|
-
function
|
|
962
|
+
var st = (e) => e?.item?.shipped === !0 || String(e?.id ?? e?.item?.id ?? "").startsWith("ship:");
|
|
963
|
+
function ct(e) {
|
|
955
964
|
if (!(typeof window > "u")) {
|
|
956
965
|
try {
|
|
957
|
-
window.localStorage.setItem(
|
|
966
|
+
window.localStorage.setItem(Ke, JSON.stringify(e));
|
|
958
967
|
} catch (e) {
|
|
959
968
|
console.warn("library: could not save to this browser —", e?.message || e);
|
|
960
969
|
return;
|
|
@@ -962,23 +971,23 @@ function lt(e) {
|
|
|
962
971
|
window.dispatchEvent(new CustomEvent("kol:library"));
|
|
963
972
|
}
|
|
964
973
|
}
|
|
965
|
-
var
|
|
974
|
+
var lt = (e) => (window.addEventListener("kol:library", e), window.addEventListener("storage", e), () => {
|
|
966
975
|
window.removeEventListener("kol:library", e), window.removeEventListener("storage", e);
|
|
967
|
-
}),
|
|
976
|
+
}), ut = () => {
|
|
968
977
|
try {
|
|
969
|
-
return window.localStorage.getItem(
|
|
978
|
+
return window.localStorage.getItem(Ke);
|
|
970
979
|
} catch {
|
|
971
980
|
return null;
|
|
972
981
|
}
|
|
973
|
-
},
|
|
974
|
-
function
|
|
982
|
+
}, dt = oe(null);
|
|
983
|
+
function ft(e, t, n) {
|
|
975
984
|
return e.map((e) => e.id === t ? {
|
|
976
985
|
...e,
|
|
977
986
|
name: String(n ?? "").trim() || null,
|
|
978
987
|
updatedAt: Date.now()
|
|
979
988
|
} : e);
|
|
980
989
|
}
|
|
981
|
-
function
|
|
990
|
+
function pt(e, t, n) {
|
|
982
991
|
let r = e.findIndex((e) => e.id === t);
|
|
983
992
|
if (r === -1) return e;
|
|
984
993
|
let i = e[r], a = {
|
|
@@ -993,19 +1002,19 @@ function mt(e, t, n) {
|
|
|
993
1002
|
...e.slice(r + 1)
|
|
994
1003
|
];
|
|
995
1004
|
}
|
|
996
|
-
function
|
|
997
|
-
let [t, n] = M(
|
|
1005
|
+
function mt({ children: e }) {
|
|
1006
|
+
let [t, n] = M(Q);
|
|
998
1007
|
j(() => {
|
|
999
|
-
|
|
1008
|
+
ct(t);
|
|
1000
1009
|
}, [t]);
|
|
1001
1010
|
let r = le(t);
|
|
1002
1011
|
r.current = t;
|
|
1003
1012
|
let i = le(null), [a, o] = M("off"), s = A((e) => {
|
|
1004
1013
|
let t = i.current;
|
|
1005
|
-
!t ||
|
|
1006
|
-
e instanceof
|
|
1014
|
+
!t || st(e) || t.push(e).catch((e) => {
|
|
1015
|
+
e instanceof U && J(), typeof console < "u" && console.warn("library sync: push failed —", e?.message || e);
|
|
1007
1016
|
});
|
|
1008
|
-
}, []), c =
|
|
1017
|
+
}, []), c = Ne();
|
|
1009
1018
|
j(() => {
|
|
1010
1019
|
if (!c) {
|
|
1011
1020
|
i.current = null, o("off");
|
|
@@ -1014,23 +1023,23 @@ function ht({ children: e }) {
|
|
|
1014
1023
|
let e = !0;
|
|
1015
1024
|
return c.backend.hydrate().then((t) => {
|
|
1016
1025
|
if (!e) return;
|
|
1017
|
-
let { next: a, pushes: l } =
|
|
1026
|
+
let { next: a, pushes: l } = Ee(r.current, t);
|
|
1018
1027
|
i.current = c.backend, n({
|
|
1019
|
-
...
|
|
1028
|
+
...X,
|
|
1020
1029
|
...a
|
|
1021
1030
|
}), o("on");
|
|
1022
1031
|
for (let e of l) s(e);
|
|
1023
1032
|
}).catch((e) => {
|
|
1024
|
-
e instanceof
|
|
1033
|
+
e instanceof U && J(), typeof console < "u" && console.warn("library sync: hydrate failed —", e?.message || e);
|
|
1025
1034
|
}), () => {
|
|
1026
1035
|
e = !1;
|
|
1027
1036
|
};
|
|
1028
1037
|
}, [c, s]);
|
|
1029
1038
|
let l = A((e, t) => {
|
|
1030
|
-
if (!
|
|
1031
|
-
let r =
|
|
1039
|
+
if (!Y.includes(e) || !t) return null;
|
|
1040
|
+
let r = et[e], i = r ? r(t) : t;
|
|
1032
1041
|
if (!i) return null;
|
|
1033
|
-
let a =
|
|
1042
|
+
let a = Je(), o = {
|
|
1034
1043
|
v: 1,
|
|
1035
1044
|
id: a,
|
|
1036
1045
|
savedAt: Date.now(),
|
|
@@ -1055,8 +1064,8 @@ function ht({ children: e }) {
|
|
|
1055
1064
|
id: t
|
|
1056
1065
|
});
|
|
1057
1066
|
}, [s]), ee = A((e, t, i) => {
|
|
1058
|
-
if (!
|
|
1059
|
-
let a =
|
|
1067
|
+
if (!Y.includes(e) || !t || !i) return;
|
|
1068
|
+
let a = et[e], o = a ? a(i) : i;
|
|
1060
1069
|
if (!o) return;
|
|
1061
1070
|
let c = Date.now(), l = (e) => ({
|
|
1062
1071
|
...e,
|
|
@@ -1077,19 +1086,19 @@ function ht({ children: e }) {
|
|
|
1077
1086
|
item: l(u)
|
|
1078
1087
|
});
|
|
1079
1088
|
}, [s]), d = A((e, t, i) => {
|
|
1080
|
-
if (!
|
|
1089
|
+
if (!Y.includes(e) || !t) return;
|
|
1081
1090
|
n((n) => ({
|
|
1082
1091
|
...n,
|
|
1083
|
-
[e]:
|
|
1092
|
+
[e]: ft(n[e] ?? [], t, i)
|
|
1084
1093
|
}));
|
|
1085
|
-
let a =
|
|
1094
|
+
let a = ft(r.current[e] ?? [], t, i).find((e) => e.id === t);
|
|
1086
1095
|
a && s({
|
|
1087
1096
|
op: "put",
|
|
1088
1097
|
kind: e,
|
|
1089
1098
|
item: a
|
|
1090
1099
|
});
|
|
1091
|
-
}, [s]),
|
|
1092
|
-
if (!
|
|
1100
|
+
}, [s]), te = A((e, t, i) => {
|
|
1101
|
+
if (!Y.includes(e) || !t || typeof i != "string" || (r.current[e] ?? []).find((e) => e.id === t)?.shipped) return;
|
|
1093
1102
|
let a = (e) => e.map((e) => e.id === t ? {
|
|
1094
1103
|
...e,
|
|
1095
1104
|
thumb: i
|
|
@@ -1104,30 +1113,30 @@ function ht({ children: e }) {
|
|
|
1104
1113
|
kind: e,
|
|
1105
1114
|
item: o
|
|
1106
1115
|
});
|
|
1107
|
-
}, [s]),
|
|
1108
|
-
if (!
|
|
1109
|
-
let i =
|
|
1116
|
+
}, [s]), f = A((e, t) => {
|
|
1117
|
+
if (!Y.includes(e) || !t) return null;
|
|
1118
|
+
let i = Je();
|
|
1110
1119
|
n((n) => ({
|
|
1111
1120
|
...n,
|
|
1112
|
-
[e]:
|
|
1121
|
+
[e]: pt(n[e] ?? [], t, i)
|
|
1113
1122
|
}));
|
|
1114
|
-
let a =
|
|
1123
|
+
let a = pt(r.current[e] ?? [], t, i).find((e) => e.id === i);
|
|
1115
1124
|
return a && s({
|
|
1116
1125
|
op: "put",
|
|
1117
1126
|
kind: e,
|
|
1118
1127
|
item: a
|
|
1119
1128
|
}), i;
|
|
1120
|
-
}, [s]),
|
|
1129
|
+
}, [s]), p = A((e) => {
|
|
1121
1130
|
n((t) => ({
|
|
1122
1131
|
...t,
|
|
1123
1132
|
[e]: []
|
|
1124
1133
|
}));
|
|
1125
|
-
}, []), m = A(() => n(
|
|
1126
|
-
...
|
|
1134
|
+
}, []), m = A(() => n(X), []), h = A((e) => n({
|
|
1135
|
+
...X,
|
|
1127
1136
|
...e
|
|
1128
1137
|
}), []), g = {
|
|
1129
1138
|
library: t,
|
|
1130
|
-
selected: ce(() =>
|
|
1139
|
+
selected: ce(() => Y.reduce((e, n) => {
|
|
1131
1140
|
let r = t[n] ?? [];
|
|
1132
1141
|
return e[n] = r.length ? r[r.length - 1] : null, e;
|
|
1133
1142
|
}, {}), [t]),
|
|
@@ -1135,9 +1144,9 @@ function ht({ children: e }) {
|
|
|
1135
1144
|
removeItem: u,
|
|
1136
1145
|
updateItem: ee,
|
|
1137
1146
|
renameItem: d,
|
|
1138
|
-
setThumb:
|
|
1139
|
-
duplicateItem:
|
|
1140
|
-
clearSlot:
|
|
1147
|
+
setThumb: te,
|
|
1148
|
+
duplicateItem: f,
|
|
1149
|
+
clearSlot: p,
|
|
1141
1150
|
clearAll: m,
|
|
1142
1151
|
replaceAll: h,
|
|
1143
1152
|
syncState: a,
|
|
@@ -1146,15 +1155,15 @@ function ht({ children: e }) {
|
|
|
1146
1155
|
saveType: (e) => l("type", e),
|
|
1147
1156
|
savePreset: (e) => l("preset", e)
|
|
1148
1157
|
};
|
|
1149
|
-
return /* @__PURE__ */ P(
|
|
1158
|
+
return /* @__PURE__ */ P(dt.Provider, {
|
|
1150
1159
|
value: g,
|
|
1151
1160
|
children: e
|
|
1152
1161
|
});
|
|
1153
1162
|
}
|
|
1154
|
-
function
|
|
1155
|
-
return se(
|
|
1156
|
-
library:
|
|
1157
|
-
selected:
|
|
1163
|
+
function ht() {
|
|
1164
|
+
return se(dt) || {
|
|
1165
|
+
library: X,
|
|
1166
|
+
selected: Y.reduce((e, t) => (e[t] = null, e), {}),
|
|
1158
1167
|
addItem: () => null,
|
|
1159
1168
|
removeItem: () => {},
|
|
1160
1169
|
updateItem: () => {},
|
|
@@ -1168,29 +1177,29 @@ function gt() {
|
|
|
1168
1177
|
savePreset: () => null
|
|
1169
1178
|
};
|
|
1170
1179
|
}
|
|
1171
|
-
var
|
|
1180
|
+
var gt = Y, _t = (e) => l("generators")?.loopById(e) ?? null, vt = {
|
|
1172
1181
|
bg: "Background",
|
|
1173
1182
|
fg: "Ink",
|
|
1174
1183
|
accent: "Accent",
|
|
1175
1184
|
dim: "Dim",
|
|
1176
1185
|
warm: "Warm"
|
|
1177
|
-
},
|
|
1186
|
+
}, yt = {
|
|
1178
1187
|
0: "fg",
|
|
1179
1188
|
1: "warm",
|
|
1180
1189
|
3: "dim",
|
|
1181
1190
|
4: "accent",
|
|
1182
1191
|
5: "bg"
|
|
1183
|
-
},
|
|
1192
|
+
}, bt = (e) => e.slice(0, 7).toLowerCase();
|
|
1184
1193
|
function xt() {
|
|
1185
|
-
let e =
|
|
1194
|
+
let e = c(), { layers: t, selectedId: n, updateLayer: r, setColorAt: i } = s(), { library: a, addItem: o } = ht(), [l, ie] = M("analogous"), [v, b] = M(m), [x, S] = M(() => ee(.62, .14, Math.random() * 360)), [C, w] = M(() => re(d(v), {
|
|
1186
1195
|
base: x,
|
|
1187
|
-
relation:
|
|
1196
|
+
relation: l,
|
|
1188
1197
|
count: 5
|
|
1189
1198
|
}).map((e) => ({
|
|
1190
1199
|
hex: e,
|
|
1191
1200
|
locked: !1
|
|
1192
|
-
}))), [T, E] = M(null), D = ce(() =>
|
|
1193
|
-
let i = re(
|
|
1201
|
+
}))), [T, E] = M(null), D = ce(() => te(a), [a]), k = ({ b: e = x, rel: t = l, n = C.length, s: r = v } = {}) => {
|
|
1202
|
+
let i = re(d(r), {
|
|
1194
1203
|
base: e,
|
|
1195
1204
|
relation: t,
|
|
1196
1205
|
count: n
|
|
@@ -1200,10 +1209,10 @@ function xt() {
|
|
|
1200
1209
|
locked: !1
|
|
1201
1210
|
})), E(null);
|
|
1202
1211
|
}, oe = () => {
|
|
1203
|
-
let e =
|
|
1212
|
+
let e = m();
|
|
1204
1213
|
b(e), k({ s: e });
|
|
1205
1214
|
}, A = (e) => {
|
|
1206
|
-
let t =
|
|
1215
|
+
let t = bt(e);
|
|
1207
1216
|
S(t), k({ b: t });
|
|
1208
1217
|
}, se = (e) => {
|
|
1209
1218
|
ie(e), k({ rel: e });
|
|
@@ -1213,7 +1222,7 @@ function xt() {
|
|
|
1213
1222
|
}, le = (e, t) => {
|
|
1214
1223
|
w((n) => n.map((n, r) => r === e ? {
|
|
1215
1224
|
...n,
|
|
1216
|
-
hex:
|
|
1225
|
+
hex: bt(t)
|
|
1217
1226
|
} : n)), E(null);
|
|
1218
1227
|
}, N = (e) => w((t) => t.map((t, n) => n === e ? {
|
|
1219
1228
|
...t,
|
|
@@ -1225,22 +1234,22 @@ function xt() {
|
|
|
1225
1234
|
if (!t) return;
|
|
1226
1235
|
let n = t.colors.slice(0, 8);
|
|
1227
1236
|
w((n.length >= 2 ? n : [...n, ...n]).map((e) => ({
|
|
1228
|
-
hex:
|
|
1237
|
+
hex: bt(e),
|
|
1229
1238
|
locked: !1
|
|
1230
1239
|
}))), E({
|
|
1231
1240
|
name: t.name,
|
|
1232
1241
|
roles: t.colors.length <= 8 ? t.roles : null
|
|
1233
1242
|
});
|
|
1234
|
-
}, I = C.map((e) => e.hex), L = T?.roles ?? u(I), pe =
|
|
1243
|
+
}, I = C.map((e) => e.hex), L = T?.roles ?? u(I), pe = p.find((e) => e.id === l)?.label ?? "Palette", R = {
|
|
1235
1244
|
name: T?.name ?? pe,
|
|
1236
|
-
relation:
|
|
1245
|
+
relation: l,
|
|
1237
1246
|
colors: I,
|
|
1238
1247
|
roles: L
|
|
1239
|
-
},
|
|
1240
|
-
if (!
|
|
1241
|
-
let e =
|
|
1242
|
-
|
|
1243
|
-
},
|
|
1248
|
+
}, me = (e) => f.filter((t) => L[t]?.toLowerCase() === e).map((e) => vt[e]).join(", "), z = n && n !== "canvas" ? ne(t, n) : null, B = z?.type === "loop" ? _t(z.loopId)?.params : null, he = () => {
|
|
1249
|
+
if (!z || !B) return;
|
|
1250
|
+
let e = g(z, B, R, { rotate: !0 }), t = Object.fromEntries(B.filter((e) => e.type === "color").map((t) => [t.key, e[t.key]]));
|
|
1251
|
+
r(z.id, t);
|
|
1252
|
+
}, ge = () => Object.entries(yt).forEach(([e, t]) => i(Number(e), L[t]));
|
|
1244
1253
|
return /* @__PURE__ */ F("div", {
|
|
1245
1254
|
className: "p-4 flex flex-col gap-4",
|
|
1246
1255
|
children: [
|
|
@@ -1282,11 +1291,11 @@ function xt() {
|
|
|
1282
1291
|
className: "flex-1 min-w-0",
|
|
1283
1292
|
size: e,
|
|
1284
1293
|
"aria-label": "Relationship",
|
|
1285
|
-
options:
|
|
1294
|
+
options: p.map((e) => ({
|
|
1286
1295
|
value: e.id,
|
|
1287
1296
|
label: e.label
|
|
1288
1297
|
})),
|
|
1289
|
-
value:
|
|
1298
|
+
value: l,
|
|
1290
1299
|
onChange: se
|
|
1291
1300
|
}), /* @__PURE__ */ P(_, {
|
|
1292
1301
|
tone: "grey",
|
|
@@ -1308,7 +1317,7 @@ function xt() {
|
|
|
1308
1317
|
}),
|
|
1309
1318
|
/* @__PURE__ */ P("span", {
|
|
1310
1319
|
className: "kol-helper-10 uppercase text-meta flex-1 truncate",
|
|
1311
|
-
children:
|
|
1320
|
+
children: me(e.hex)
|
|
1312
1321
|
}),
|
|
1313
1322
|
/* @__PURE__ */ P("span", {
|
|
1314
1323
|
className: "kol-mono-10 text-meta",
|
|
@@ -1339,7 +1348,7 @@ function xt() {
|
|
|
1339
1348
|
]
|
|
1340
1349
|
}, t))
|
|
1341
1350
|
}),
|
|
1342
|
-
|
|
1351
|
+
h(L.bg, L.fg) < 4.5 && /* @__PURE__ */ F("span", {
|
|
1343
1352
|
className: "kol-helper-10 text-meta inline-flex items-center gap-1",
|
|
1344
1353
|
children: [/* @__PURE__ */ P(de, {
|
|
1345
1354
|
name: "info",
|
|
@@ -1362,25 +1371,25 @@ function xt() {
|
|
|
1362
1371
|
/* @__PURE__ */ P(_, {
|
|
1363
1372
|
tone: "grey",
|
|
1364
1373
|
size: e,
|
|
1365
|
-
onClick: () =>
|
|
1366
|
-
name:
|
|
1374
|
+
onClick: () => o("palette", {
|
|
1375
|
+
name: R.name,
|
|
1367
1376
|
colors: I
|
|
1368
1377
|
}),
|
|
1369
1378
|
children: "Save"
|
|
1370
1379
|
}),
|
|
1371
1380
|
/* @__PURE__ */ F("div", {
|
|
1372
1381
|
className: "flex gap-2",
|
|
1373
|
-
children: [
|
|
1382
|
+
children: [B && /* @__PURE__ */ P(_, {
|
|
1374
1383
|
tone: "grey",
|
|
1375
1384
|
size: e,
|
|
1376
1385
|
className: "flex-1",
|
|
1377
|
-
onClick:
|
|
1386
|
+
onClick: he,
|
|
1378
1387
|
children: "Apply to layer"
|
|
1379
1388
|
}), /* @__PURE__ */ P(_, {
|
|
1380
1389
|
tone: "grey",
|
|
1381
1390
|
size: e,
|
|
1382
1391
|
className: "flex-1",
|
|
1383
|
-
onClick:
|
|
1392
|
+
onClick: ge,
|
|
1384
1393
|
children: "Apply to document"
|
|
1385
1394
|
})]
|
|
1386
1395
|
})
|
|
@@ -1424,7 +1433,10 @@ function wt() {
|
|
|
1424
1433
|
//#endregion
|
|
1425
1434
|
//#region src/editor/generate/store.js
|
|
1426
1435
|
var $ = {}, Tt = /* @__PURE__ */ new Set(), Et = () => Tt.forEach((e) => e());
|
|
1427
|
-
function Dt(e
|
|
1436
|
+
function Dt(e) {
|
|
1437
|
+
return $[e];
|
|
1438
|
+
}
|
|
1439
|
+
function Ot(e, t) {
|
|
1428
1440
|
$[e] = {
|
|
1429
1441
|
live: !0,
|
|
1430
1442
|
layerId: null,
|
|
@@ -1432,7 +1444,7 @@ function Dt(e, t) {
|
|
|
1432
1444
|
...typeof t == "function" ? t($[e]) : t
|
|
1433
1445
|
}, Et();
|
|
1434
1446
|
}
|
|
1435
|
-
function
|
|
1447
|
+
function kt(e, t) {
|
|
1436
1448
|
return $[e]?.params || ($[e] = {
|
|
1437
1449
|
live: !0,
|
|
1438
1450
|
layerId: null,
|
|
@@ -1440,24 +1452,32 @@ function Ot(e, t) {
|
|
|
1440
1452
|
params: t()
|
|
1441
1453
|
}), N((e) => (Tt.add(e), () => Tt.delete(e)), () => $[e]);
|
|
1442
1454
|
}
|
|
1443
|
-
var
|
|
1444
|
-
function
|
|
1455
|
+
var At = (e, t = "rail") => Ft(t === "dialog" ? { dialog: e } : { rail: e });
|
|
1456
|
+
function jt(e, t, n = "rail") {
|
|
1445
1457
|
let { id: r, type: i, children: a, ...o } = t;
|
|
1446
|
-
|
|
1458
|
+
Ot(e, {
|
|
1447
1459
|
params: o,
|
|
1448
|
-
layerId: r
|
|
1449
|
-
|
|
1460
|
+
layerId: r,
|
|
1461
|
+
contentKey: null
|
|
1462
|
+
}), At(e, n);
|
|
1463
|
+
}
|
|
1464
|
+
function Mt(e, t, n, r = "rail") {
|
|
1465
|
+
Ot(e, {
|
|
1466
|
+
params: n.params,
|
|
1467
|
+
layerId: t.id,
|
|
1468
|
+
contentKey: n.key
|
|
1469
|
+
}), At(e, r);
|
|
1450
1470
|
}
|
|
1451
|
-
var
|
|
1471
|
+
var Nt = {
|
|
1452
1472
|
rail: null,
|
|
1453
1473
|
dialog: null
|
|
1454
|
-
},
|
|
1455
|
-
function
|
|
1456
|
-
|
|
1457
|
-
...
|
|
1474
|
+
}, Pt = /* @__PURE__ */ new Set();
|
|
1475
|
+
function Ft(e) {
|
|
1476
|
+
Nt = {
|
|
1477
|
+
...Nt,
|
|
1458
1478
|
...e
|
|
1459
|
-
},
|
|
1479
|
+
}, Pt.forEach((e) => e());
|
|
1460
1480
|
}
|
|
1461
|
-
var
|
|
1481
|
+
var It = () => N((e) => (Pt.add(e), () => Pt.delete(e)), () => Nt);
|
|
1462
1482
|
//#endregion
|
|
1463
|
-
export {
|
|
1483
|
+
export { J as A, me as B, Me as C, Ue as D, He as E, B as F, Ce as I, z as L, Ve as M, Pe as N, De as O, Ne as P, ye as R, Oe as S, We as T, ut as _, Ot as a, ht as b, It as c, mt as d, gt as f, Q as g, st as h, At as i, Be as j, ze as k, wt as l, ft as m, jt as n, Ft as o, pt as p, Dt as r, kt as s, Mt as t, Ct as u, ct as v, Ge as w, U as x, lt as y, xe as z };
|