@kolkrabbi/design-editor 0.34.0 → 0.35.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/{core-BeMuE9nC.js → core-DJet1D7E.js} +7 -5
- package/dist/core.js +2 -2
- package/dist/design-editor.css +1 -1
- package/dist/design-editor.js +3 -3
- package/dist/{generators-XBzHN_kX.js → generators-Bf08F0NV.js} +873 -872
- package/dist/generators.js +1 -1
- package/dist/{host-B4QQewPr.js → host-CRRiwlrB.js} +1 -1
- package/dist/{store-CF9s1Pb2.js → store-DZUWPE2s.js} +212 -211
- package/package.json +3 -3
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Bn as e, Cn as t, D as n, J as r, L as i, Rt as a, Sn as o, _ as s, b as c, bn as l, f as u, g as ee, h as d, m as f, p, pn as m, v as h, vn as g, wn as _, x as te, y as ne } from "./rolls-CEQmdcp3.js";
|
|
2
|
-
import { Button as v, ButtonGroup as re, CloseButton as y, ColorPickerPopover as ie, Dropdown as b, FullscreenOverlay as x, FunctionPlot as S, Input as C, LabeledControl as w, MenuDropdownItem as T,
|
|
3
|
-
import { createContext as
|
|
4
|
-
import { Fragment as
|
|
5
|
-
import { IconLoader as
|
|
2
|
+
import { Button as v, ButtonGroup as re, CloseButton as y, ColorPickerPopover as ie, Dropdown as b, FullscreenOverlay as x, FunctionPlot as S, Input as C, LabeledControl as w, MenuDropdownItem as T, ModalShell as E, Section as D, Slider as O, Stepper as k, Tooltip as A } from "@kolkrabbi/kol-component";
|
|
3
|
+
import { createContext as ae, useCallback as j, useContext as oe, useEffect as M, useMemo as se, useRef as ce, useState as N, useSyncExternalStore as P } from "react";
|
|
4
|
+
import { Fragment as le, jsx as F, jsxs as I } from "react/jsx-runtime";
|
|
5
|
+
import { IconLoader as ue } from "@kolkrabbi/kol-icons";
|
|
6
6
|
//#region src/editor/params/ModulationEditor.jsx
|
|
7
|
-
var
|
|
7
|
+
var de = [
|
|
8
8
|
{
|
|
9
9
|
code: "wave(t*2)",
|
|
10
10
|
desc: "Fast sine"
|
|
@@ -37,26 +37,26 @@ var ue = [
|
|
|
37
37
|
code: "rand()",
|
|
38
38
|
desc: "Noise"
|
|
39
39
|
}
|
|
40
|
-
],
|
|
41
|
-
function
|
|
40
|
+
], L = 196, R = 64;
|
|
41
|
+
function fe({ expr: e }) {
|
|
42
42
|
let [t, n] = N(0);
|
|
43
|
-
|
|
43
|
+
M(() => {
|
|
44
44
|
let e = 0, t = () => {
|
|
45
45
|
n(m.getCtx().t ?? 0), e = requestAnimationFrame(t);
|
|
46
46
|
};
|
|
47
47
|
return e = requestAnimationFrame(t), () => cancelAnimationFrame(e);
|
|
48
48
|
}, []);
|
|
49
|
-
let r = l(e), i = m.getLoopSeconds(), a =
|
|
49
|
+
let r = l(e), i = m.getLoopSeconds(), a = L, o = Array.from({ length: 197 }, (e, t) => r.ok ? r.fn(t / a * i) : 0);
|
|
50
50
|
return /* @__PURE__ */ F(S, {
|
|
51
51
|
samples: o,
|
|
52
52
|
min: Math.min(0, ...o),
|
|
53
53
|
max: Math.max(1, ...o),
|
|
54
54
|
cursor: t,
|
|
55
|
-
height:
|
|
55
|
+
height: R,
|
|
56
56
|
ariaLabel: "Expression plot over one loop"
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function pe({ layer: e, param: r, setProp: a }) {
|
|
60
60
|
let s = i(), c = e[r.key], [l, u] = N(null), [ee, d] = N(!1), [f, p] = N(!1);
|
|
61
61
|
if (!n(c) || c.bind !== "mod") return null;
|
|
62
62
|
let m = c.source, h = c.transform ?? {}, te = m.startsWith("lfo-"), ne = m === "midi", y = o(m), ie = m === "expr", b = h.expr ?? "wave(t)", x = (e) => a(r.key, {
|
|
@@ -73,14 +73,14 @@ function fe({ layer: e, param: r, setProp: a }) {
|
|
|
73
73
|
d(!0);
|
|
74
74
|
let e = await _();
|
|
75
75
|
d(!1), e != null && x({ cc: e });
|
|
76
|
-
},
|
|
76
|
+
}, D = async () => {
|
|
77
77
|
p(!0);
|
|
78
78
|
let e = await t();
|
|
79
79
|
p(!1), e && a(r.key, {
|
|
80
80
|
...c,
|
|
81
81
|
source: e
|
|
82
82
|
});
|
|
83
|
-
},
|
|
83
|
+
}, k = h.range ?? (r.min != null && r.max != null ? [r.min, r.max] : [0, 1]), A = (e, t) => {
|
|
84
84
|
let n = Number(e);
|
|
85
85
|
return Number.isFinite(n) ? n : t;
|
|
86
86
|
};
|
|
@@ -99,8 +99,8 @@ function fe({ layer: e, param: r, setProp: a }) {
|
|
|
99
99
|
size: s,
|
|
100
100
|
type: "number",
|
|
101
101
|
width: "100%",
|
|
102
|
-
value:
|
|
103
|
-
onChange: (e) => x({ range: [
|
|
102
|
+
value: k[0],
|
|
103
|
+
onChange: (e) => x({ range: [A(e.target.value, k[0]), k[1]] })
|
|
104
104
|
})
|
|
105
105
|
}),
|
|
106
106
|
/* @__PURE__ */ F("span", {
|
|
@@ -114,8 +114,8 @@ function fe({ layer: e, param: r, setProp: a }) {
|
|
|
114
114
|
size: s,
|
|
115
115
|
type: "number",
|
|
116
116
|
width: "100%",
|
|
117
|
-
value:
|
|
118
|
-
onChange: (e) => x({ range: [
|
|
117
|
+
value: k[1],
|
|
118
|
+
onChange: (e) => x({ range: [k[0], A(e.target.value, k[1])] })
|
|
119
119
|
})
|
|
120
120
|
})
|
|
121
121
|
]
|
|
@@ -141,7 +141,7 @@ function fe({ layer: e, param: r, setProp: a }) {
|
|
|
141
141
|
})
|
|
142
142
|
}), /* @__PURE__ */ F(w, {
|
|
143
143
|
label: "Smooth",
|
|
144
|
-
children: /* @__PURE__ */ F(
|
|
144
|
+
children: /* @__PURE__ */ F(O, {
|
|
145
145
|
min: 0,
|
|
146
146
|
max: .95,
|
|
147
147
|
step: .05,
|
|
@@ -152,7 +152,7 @@ function fe({ layer: e, param: r, setProp: a }) {
|
|
|
152
152
|
}),
|
|
153
153
|
/* @__PURE__ */ F(w, {
|
|
154
154
|
label: "Curve",
|
|
155
|
-
children: /* @__PURE__ */ F(
|
|
155
|
+
children: /* @__PURE__ */ F(O, {
|
|
156
156
|
min: .25,
|
|
157
157
|
max: 4,
|
|
158
158
|
step: .05,
|
|
@@ -164,7 +164,7 @@ function fe({ layer: e, param: r, setProp: a }) {
|
|
|
164
164
|
className: "grid grid-cols-2 gap-2",
|
|
165
165
|
children: [/* @__PURE__ */ F(w, {
|
|
166
166
|
label: "Rate",
|
|
167
|
-
children: /* @__PURE__ */ F(
|
|
167
|
+
children: /* @__PURE__ */ F(O, {
|
|
168
168
|
min: .25,
|
|
169
169
|
max: 16,
|
|
170
170
|
step: .25,
|
|
@@ -173,7 +173,7 @@ function fe({ layer: e, param: r, setProp: a }) {
|
|
|
173
173
|
})
|
|
174
174
|
}), /* @__PURE__ */ F(w, {
|
|
175
175
|
label: "Phase",
|
|
176
|
-
children: /* @__PURE__ */ F(
|
|
176
|
+
children: /* @__PURE__ */ F(O, {
|
|
177
177
|
min: 0,
|
|
178
178
|
max: 1,
|
|
179
179
|
step: .01,
|
|
@@ -182,7 +182,7 @@ function fe({ layer: e, param: r, setProp: a }) {
|
|
|
182
182
|
})
|
|
183
183
|
})]
|
|
184
184
|
}),
|
|
185
|
-
ie && /* @__PURE__ */ I(
|
|
185
|
+
ie && /* @__PURE__ */ I(le, { children: [
|
|
186
186
|
/* @__PURE__ */ F(w, {
|
|
187
187
|
label: "Expression",
|
|
188
188
|
children: /* @__PURE__ */ F(C, {
|
|
@@ -196,10 +196,10 @@ function fe({ layer: e, param: r, setProp: a }) {
|
|
|
196
196
|
}
|
|
197
197
|
})
|
|
198
198
|
}),
|
|
199
|
-
/* @__PURE__ */ F(
|
|
199
|
+
/* @__PURE__ */ F(fe, { expr: b }),
|
|
200
200
|
/* @__PURE__ */ F("div", {
|
|
201
201
|
className: "flex flex-col",
|
|
202
|
-
children:
|
|
202
|
+
children: de.map((e) => /* @__PURE__ */ F(T, {
|
|
203
203
|
onClick: () => x({ expr: e.code }),
|
|
204
204
|
rowClass: "kol-mono-10 h-6",
|
|
205
205
|
shortcut: /* @__PURE__ */ F("span", {
|
|
@@ -224,14 +224,14 @@ function fe({ layer: e, param: r, setProp: a }) {
|
|
|
224
224
|
children: /* @__PURE__ */ F(v, {
|
|
225
225
|
tone: "outline",
|
|
226
226
|
size: s,
|
|
227
|
-
onClick:
|
|
227
|
+
onClick: D,
|
|
228
228
|
children: f ? "Move a control…" : "Learn"
|
|
229
229
|
})
|
|
230
230
|
})
|
|
231
231
|
]
|
|
232
232
|
});
|
|
233
233
|
}
|
|
234
|
-
function
|
|
234
|
+
function me({ layer: e, schema: t, setProp: r }) {
|
|
235
235
|
let i = (t ?? []).filter((t) => {
|
|
236
236
|
let r = e[t.key];
|
|
237
237
|
return n(r) && r.bind === "mod";
|
|
@@ -254,7 +254,7 @@ function pe({ layer: e, schema: t, setProp: r }) {
|
|
|
254
254
|
className: "kol-helper-10 text-meta",
|
|
255
255
|
children: n?.label ?? e[t.key].source
|
|
256
256
|
})]
|
|
257
|
-
}), /* @__PURE__ */ F(
|
|
257
|
+
}), /* @__PURE__ */ F(pe, {
|
|
258
258
|
layer: e,
|
|
259
259
|
param: t,
|
|
260
260
|
setProp: r
|
|
@@ -265,7 +265,7 @@ function pe({ layer: e, schema: t, setProp: r }) {
|
|
|
265
265
|
}
|
|
266
266
|
//#endregion
|
|
267
267
|
//#region src/editor/modes/pattern/RuleRow.jsx
|
|
268
|
-
var
|
|
268
|
+
var z = [
|
|
269
269
|
{
|
|
270
270
|
value: "all",
|
|
271
271
|
label: "All cells"
|
|
@@ -294,7 +294,7 @@ var me = [
|
|
|
294
294
|
value: "expression",
|
|
295
295
|
label: "Expression…"
|
|
296
296
|
}
|
|
297
|
-
],
|
|
297
|
+
], B = [
|
|
298
298
|
{
|
|
299
299
|
value: 0,
|
|
300
300
|
label: "0°"
|
|
@@ -311,19 +311,19 @@ var me = [
|
|
|
311
311
|
value: 270,
|
|
312
312
|
label: "270°"
|
|
313
313
|
}
|
|
314
|
-
],
|
|
314
|
+
], he = [
|
|
315
315
|
"every-col",
|
|
316
316
|
"every-row",
|
|
317
317
|
"both",
|
|
318
318
|
"every-nth",
|
|
319
319
|
"checker"
|
|
320
|
-
],
|
|
320
|
+
], ge = [
|
|
321
321
|
0,
|
|
322
322
|
90,
|
|
323
323
|
180,
|
|
324
324
|
270
|
|
325
|
-
],
|
|
326
|
-
id:
|
|
325
|
+
], _e = 1, ve = () => `r${_e++}`, ye = () => ({
|
|
326
|
+
id: ve(),
|
|
327
327
|
selectKind: "every-col",
|
|
328
328
|
n: 2,
|
|
329
329
|
offset: 0,
|
|
@@ -337,9 +337,9 @@ var me = [
|
|
|
337
337
|
flipV: !1,
|
|
338
338
|
hide: !1,
|
|
339
339
|
opacity: 1
|
|
340
|
-
}),
|
|
341
|
-
id:
|
|
342
|
-
selectKind:
|
|
340
|
+
}), be = (e) => e[Math.floor(Math.random() * e.length)], xe = () => ({
|
|
341
|
+
id: ve(),
|
|
342
|
+
selectKind: be(he),
|
|
343
343
|
n: Math.floor(Math.random() * 5) + 2,
|
|
344
344
|
offset: Math.floor(Math.random() * 3),
|
|
345
345
|
n2: Math.floor(Math.random() * 5) + 2,
|
|
@@ -347,14 +347,14 @@ var me = [
|
|
|
347
347
|
expression: "sin(col * 0.6) + cos(row * 0.6)",
|
|
348
348
|
groupW: Math.random() > .6 ? Math.floor(Math.random() * 3) + 1 : 1,
|
|
349
349
|
groupH: Math.random() > .6 ? Math.floor(Math.random() * 3) + 1 : 1,
|
|
350
|
-
rotate:
|
|
350
|
+
rotate: be(ge),
|
|
351
351
|
flipH: Math.random() > .6,
|
|
352
352
|
flipV: Math.random() > .6,
|
|
353
353
|
hide: Math.random() > .85,
|
|
354
354
|
opacity: Math.random() > .7 ? .4 + Math.random() * .6 : 1
|
|
355
355
|
});
|
|
356
356
|
function V({ value: e, onChange: t, min: n = 0, max: r = 99 }) {
|
|
357
|
-
return /* @__PURE__ */ F(
|
|
357
|
+
return /* @__PURE__ */ F(k, {
|
|
358
358
|
size: "sm",
|
|
359
359
|
value: e,
|
|
360
360
|
min: n,
|
|
@@ -363,8 +363,8 @@ function V({ value: e, onChange: t, min: n = 0, max: r = 99 }) {
|
|
|
363
363
|
className: "w-full"
|
|
364
364
|
});
|
|
365
365
|
}
|
|
366
|
-
function
|
|
367
|
-
return /* @__PURE__ */ F(
|
|
366
|
+
function Se({ active: e, onClick: t, children: n, title: r }) {
|
|
367
|
+
return /* @__PURE__ */ F(A, {
|
|
368
368
|
label: r,
|
|
369
369
|
children: /* @__PURE__ */ F(v, {
|
|
370
370
|
"aria-label": r,
|
|
@@ -376,7 +376,7 @@ function xe({ active: e, onClick: t, children: n, title: r }) {
|
|
|
376
376
|
})
|
|
377
377
|
});
|
|
378
378
|
}
|
|
379
|
-
function
|
|
379
|
+
function Ce({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
|
|
380
380
|
let i = (n) => t({
|
|
381
381
|
...e,
|
|
382
382
|
...n
|
|
@@ -393,12 +393,12 @@ function Se({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
|
|
|
393
393
|
variant: "subtle",
|
|
394
394
|
size: "sm",
|
|
395
395
|
className: "w-full",
|
|
396
|
-
options:
|
|
396
|
+
options: z,
|
|
397
397
|
value: e.selectKind,
|
|
398
398
|
onChange: (e) => i({ selectKind: e })
|
|
399
399
|
})
|
|
400
400
|
}),
|
|
401
|
-
/* @__PURE__ */ F(
|
|
401
|
+
/* @__PURE__ */ F(A, {
|
|
402
402
|
label: "Re-randomize this rule",
|
|
403
403
|
children: /* @__PURE__ */ F(v, {
|
|
404
404
|
tone: "ghost",
|
|
@@ -411,7 +411,7 @@ function Se({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
|
|
|
411
411
|
style: { padding: 6 }
|
|
412
412
|
})
|
|
413
413
|
}),
|
|
414
|
-
/* @__PURE__ */ F(
|
|
414
|
+
/* @__PURE__ */ F(A, {
|
|
415
415
|
label: "Delete rule",
|
|
416
416
|
children: /* @__PURE__ */ F(v, {
|
|
417
417
|
tone: "ghost",
|
|
@@ -428,14 +428,14 @@ function Se({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
|
|
|
428
428
|
}),
|
|
429
429
|
a && /* @__PURE__ */ I("div", {
|
|
430
430
|
className: "grid grid-cols-2 gap-2",
|
|
431
|
-
children: [/* @__PURE__ */ F(
|
|
431
|
+
children: [/* @__PURE__ */ F(D, {
|
|
432
432
|
label: "N",
|
|
433
433
|
children: /* @__PURE__ */ F(V, {
|
|
434
434
|
value: e.n,
|
|
435
435
|
onChange: (e) => i({ n: e }),
|
|
436
436
|
min: 1
|
|
437
437
|
})
|
|
438
|
-
}), /* @__PURE__ */ F(
|
|
438
|
+
}), /* @__PURE__ */ F(D, {
|
|
439
439
|
label: "Offset",
|
|
440
440
|
children: /* @__PURE__ */ F(V, {
|
|
441
441
|
value: e.offset,
|
|
@@ -445,14 +445,14 @@ function Se({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
|
|
|
445
445
|
}),
|
|
446
446
|
o && /* @__PURE__ */ I("div", {
|
|
447
447
|
className: "grid grid-cols-2 gap-2",
|
|
448
|
-
children: [/* @__PURE__ */ F(
|
|
448
|
+
children: [/* @__PURE__ */ F(D, {
|
|
449
449
|
label: "Row N",
|
|
450
450
|
children: /* @__PURE__ */ F(V, {
|
|
451
451
|
value: e.n2,
|
|
452
452
|
onChange: (e) => i({ n2: e }),
|
|
453
453
|
min: 1
|
|
454
454
|
})
|
|
455
|
-
}), /* @__PURE__ */ F(
|
|
455
|
+
}), /* @__PURE__ */ F(D, {
|
|
456
456
|
label: "Row offset",
|
|
457
457
|
children: /* @__PURE__ */ F(V, {
|
|
458
458
|
value: e.offset2,
|
|
@@ -460,7 +460,7 @@ function Se({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
|
|
|
460
460
|
})
|
|
461
461
|
})]
|
|
462
462
|
}),
|
|
463
|
-
s && /* @__PURE__ */ I(
|
|
463
|
+
s && /* @__PURE__ */ I(D, {
|
|
464
464
|
label: "Expression",
|
|
465
465
|
hint: "matches when > 0",
|
|
466
466
|
children: [/* @__PURE__ */ F(C, {
|
|
@@ -476,14 +476,14 @@ function Se({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
|
|
|
476
476
|
}),
|
|
477
477
|
/* @__PURE__ */ I("div", {
|
|
478
478
|
className: "grid grid-cols-2 gap-2",
|
|
479
|
-
children: [/* @__PURE__ */ F(
|
|
479
|
+
children: [/* @__PURE__ */ F(D, {
|
|
480
480
|
label: "Group W",
|
|
481
481
|
children: /* @__PURE__ */ F(V, {
|
|
482
482
|
value: e.groupW,
|
|
483
483
|
onChange: (e) => i({ groupW: Math.max(1, e) }),
|
|
484
484
|
min: 1
|
|
485
485
|
})
|
|
486
|
-
}), /* @__PURE__ */ F(
|
|
486
|
+
}), /* @__PURE__ */ F(D, {
|
|
487
487
|
label: "Group H",
|
|
488
488
|
children: /* @__PURE__ */ F(V, {
|
|
489
489
|
value: e.groupH,
|
|
@@ -498,23 +498,23 @@ function Se({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
|
|
|
498
498
|
/* @__PURE__ */ F(b, {
|
|
499
499
|
variant: "subtle",
|
|
500
500
|
size: "sm",
|
|
501
|
-
options:
|
|
501
|
+
options: B,
|
|
502
502
|
value: e.rotate,
|
|
503
503
|
onChange: (e) => i({ rotate: Number(e) })
|
|
504
504
|
}),
|
|
505
|
-
/* @__PURE__ */ F(
|
|
505
|
+
/* @__PURE__ */ F(Se, {
|
|
506
506
|
active: e.flipH,
|
|
507
507
|
onClick: () => i({ flipH: !e.flipH }),
|
|
508
508
|
title: "Flip horizontal",
|
|
509
509
|
children: "⇋"
|
|
510
510
|
}),
|
|
511
|
-
/* @__PURE__ */ F(
|
|
511
|
+
/* @__PURE__ */ F(Se, {
|
|
512
512
|
active: e.flipV,
|
|
513
513
|
onClick: () => i({ flipV: !e.flipV }),
|
|
514
514
|
title: "Flip vertical",
|
|
515
515
|
children: "⇵"
|
|
516
516
|
}),
|
|
517
|
-
/* @__PURE__ */ F(
|
|
517
|
+
/* @__PURE__ */ F(Se, {
|
|
518
518
|
active: e.hide,
|
|
519
519
|
onClick: () => i({ hide: !e.hide }),
|
|
520
520
|
title: "Hide cell",
|
|
@@ -522,10 +522,10 @@ function Se({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
|
|
|
522
522
|
})
|
|
523
523
|
]
|
|
524
524
|
}),
|
|
525
|
-
/* @__PURE__ */ F(
|
|
525
|
+
/* @__PURE__ */ F(D, {
|
|
526
526
|
label: "Opacity",
|
|
527
527
|
hint: `${Math.round(e.opacity * 100)}%`,
|
|
528
|
-
children: /* @__PURE__ */ F(
|
|
528
|
+
children: /* @__PURE__ */ F(O, {
|
|
529
529
|
min: 0,
|
|
530
530
|
max: 100,
|
|
531
531
|
value: Math.round(e.opacity * 100),
|
|
@@ -537,8 +537,8 @@ function Se({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
|
|
|
537
537
|
}
|
|
538
538
|
//#endregion
|
|
539
539
|
//#region src/editor/library/mergeRemote.js
|
|
540
|
-
var
|
|
541
|
-
function
|
|
540
|
+
var we = (e) => e?.updatedAt ?? e?.savedAt ?? 0, Te = (e) => /^(Plan08 |Sync [A-Z] \d{13}|Morph [A-Z] \d{13})/.test(e?.name ?? "");
|
|
541
|
+
function Ee(e, t) {
|
|
542
542
|
let n = {}, r = [], i = /* @__PURE__ */ new Map();
|
|
543
543
|
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
544
|
let a = new Set([...Object.keys(e || {}), ...i.keys()]);
|
|
@@ -550,7 +550,7 @@ function Te(e, t) {
|
|
|
550
550
|
o.push(n);
|
|
551
551
|
continue;
|
|
552
552
|
}
|
|
553
|
-
if (
|
|
553
|
+
if (Te(n)) {
|
|
554
554
|
s.add(n.id), e && !e.deleted && r.push({
|
|
555
555
|
op: "remove",
|
|
556
556
|
kind: t,
|
|
@@ -567,7 +567,7 @@ function Te(e, t) {
|
|
|
567
567
|
continue;
|
|
568
568
|
}
|
|
569
569
|
if (e.deleted) {
|
|
570
|
-
if (e.updatedAt >
|
|
570
|
+
if (e.updatedAt > we(n)) continue;
|
|
571
571
|
o.push(n), r.push({
|
|
572
572
|
op: "put",
|
|
573
573
|
kind: t,
|
|
@@ -575,7 +575,7 @@ function Te(e, t) {
|
|
|
575
575
|
});
|
|
576
576
|
continue;
|
|
577
577
|
}
|
|
578
|
-
e.updatedAt >
|
|
578
|
+
e.updatedAt > we(n) ? o.push(e.spec) : (o.push(n), e.updatedAt < we(n) && r.push({
|
|
579
579
|
op: "put",
|
|
580
580
|
kind: t,
|
|
581
581
|
item: n
|
|
@@ -583,7 +583,7 @@ function Te(e, t) {
|
|
|
583
583
|
}
|
|
584
584
|
let c = new Set(o.map((e) => e.id));
|
|
585
585
|
for (let e of a.values()) if (!(e.deleted || c.has(e.id) || s.has(e.id))) {
|
|
586
|
-
if (
|
|
586
|
+
if (Te(e.spec)) {
|
|
587
587
|
r.push({
|
|
588
588
|
op: "remove",
|
|
589
589
|
kind: t,
|
|
@@ -603,10 +603,10 @@ function Te(e, t) {
|
|
|
603
603
|
//#endregion
|
|
604
604
|
//#region src/editor/library/libraryApi.js
|
|
605
605
|
var H = null;
|
|
606
|
-
function
|
|
607
|
-
H = typeof e == "string" && e.trim() ? e.trim().replace(/\/+$/, "") : null,
|
|
606
|
+
function De(e) {
|
|
607
|
+
H = typeof e == "string" && e.trim() ? e.trim().replace(/\/+$/, "") : null, Le();
|
|
608
608
|
}
|
|
609
|
-
function
|
|
609
|
+
function Oe() {
|
|
610
610
|
return H;
|
|
611
611
|
}
|
|
612
612
|
var U = class extends Error {
|
|
@@ -614,7 +614,7 @@ var U = class extends Error {
|
|
|
614
614
|
super("unauthorized"), this.name = "UnauthorizedError";
|
|
615
615
|
}
|
|
616
616
|
};
|
|
617
|
-
function
|
|
617
|
+
function ke(e, t) {
|
|
618
618
|
let n = `Bearer ${t}`, r = async (t, r = {}) => {
|
|
619
619
|
let i = await fetch(`${e}${t}`, {
|
|
620
620
|
...r,
|
|
@@ -648,26 +648,26 @@ function Oe(e, t) {
|
|
|
648
648
|
}
|
|
649
649
|
};
|
|
650
650
|
}
|
|
651
|
-
var
|
|
652
|
-
function
|
|
651
|
+
var Ae = "kol.fxr.library-session", W = null, je = /* @__PURE__ */ new Set(), G = () => je.forEach((e) => e());
|
|
652
|
+
function Me() {
|
|
653
653
|
return W;
|
|
654
654
|
}
|
|
655
|
-
var
|
|
655
|
+
var Ne = () => P((e) => (je.add(e), () => je.delete(e)), Me, Me), Pe = () => Ne()?.user ?? null;
|
|
656
656
|
function K(e) {
|
|
657
657
|
try {
|
|
658
|
-
e ? localStorage.setItem(
|
|
658
|
+
e ? localStorage.setItem(Ae, JSON.stringify(e)) : localStorage.removeItem(Ae);
|
|
659
659
|
} catch {}
|
|
660
660
|
}
|
|
661
|
-
var
|
|
661
|
+
var Fe = () => {
|
|
662
662
|
try {
|
|
663
|
-
return JSON.parse(localStorage.getItem(
|
|
663
|
+
return JSON.parse(localStorage.getItem(Ae) || "null");
|
|
664
664
|
} catch {
|
|
665
665
|
return null;
|
|
666
666
|
}
|
|
667
667
|
};
|
|
668
|
-
function
|
|
669
|
-
let { next: n, pushes: r } =
|
|
670
|
-
|
|
668
|
+
function Ie(e, t) {
|
|
669
|
+
let { next: n, pushes: r } = Ee(Q(), t);
|
|
670
|
+
ct({
|
|
671
671
|
...Q(),
|
|
672
672
|
...n
|
|
673
673
|
});
|
|
@@ -687,11 +687,11 @@ async function q(e, t = {}, n) {
|
|
|
687
687
|
if (!r.ok) throw Error(i.error || `library api ${r.status}`);
|
|
688
688
|
return i;
|
|
689
689
|
}
|
|
690
|
-
function
|
|
690
|
+
function Le() {
|
|
691
691
|
if (W || !H) return;
|
|
692
|
-
let e =
|
|
692
|
+
let e = Fe();
|
|
693
693
|
if (!e?.token || e.base !== H || !(e.expiresAt > Date.now()) || !e.user) return;
|
|
694
|
-
let t =
|
|
694
|
+
let t = ke(H, e.token);
|
|
695
695
|
W = {
|
|
696
696
|
backend: t,
|
|
697
697
|
user: e.user,
|
|
@@ -706,13 +706,13 @@ function Ie() {
|
|
|
706
706
|
}), G());
|
|
707
707
|
}).catch((e) => {
|
|
708
708
|
e instanceof U && J();
|
|
709
|
-
}), t.hydrate().then((e) =>
|
|
709
|
+
}), t.hydrate().then((e) => Ie(t, e)).catch((e) => {
|
|
710
710
|
e instanceof U ? J() : console.warn("library sync: hydrate failed —", e?.message || e);
|
|
711
711
|
});
|
|
712
712
|
}
|
|
713
|
-
async function
|
|
714
|
-
let r =
|
|
715
|
-
return
|
|
713
|
+
async function Re({ token: e, expiresAt: t, user: n }) {
|
|
714
|
+
let r = ke(H, e), i = await r.hydrate();
|
|
715
|
+
return Ie(r, i), W = {
|
|
716
716
|
backend: r,
|
|
717
717
|
user: n,
|
|
718
718
|
token: e
|
|
@@ -723,9 +723,9 @@ async function Le({ token: e, expiresAt: t, user: n }) {
|
|
|
723
723
|
user: n
|
|
724
724
|
}), G(), i.filter((e) => !e.deleted).length;
|
|
725
725
|
}
|
|
726
|
-
async function
|
|
726
|
+
async function ze({ email: e, password: t } = {}) {
|
|
727
727
|
if (!H) throw Error("no library api");
|
|
728
|
-
return
|
|
728
|
+
return Re(await q("/api/auth/signin", {
|
|
729
729
|
method: "POST",
|
|
730
730
|
body: JSON.stringify({
|
|
731
731
|
email: e,
|
|
@@ -733,21 +733,21 @@ async function Re({ email: e, password: t } = {}) {
|
|
|
733
733
|
})
|
|
734
734
|
}));
|
|
735
735
|
}
|
|
736
|
-
async function
|
|
736
|
+
async function Be(e) {
|
|
737
737
|
if (!H) throw Error("no library api");
|
|
738
|
-
return
|
|
738
|
+
return Re(await q("/api/auth/signup", {
|
|
739
739
|
method: "POST",
|
|
740
740
|
body: JSON.stringify(e)
|
|
741
741
|
}));
|
|
742
742
|
}
|
|
743
743
|
function J() {
|
|
744
|
-
let e = W?.token ??
|
|
744
|
+
let e = W?.token ?? Fe()?.token;
|
|
745
745
|
K(null), e && H && q("/api/auth/signout", {
|
|
746
746
|
method: "POST",
|
|
747
747
|
body: "{}"
|
|
748
748
|
}, e).catch(() => {}), W && (W = null, G());
|
|
749
749
|
}
|
|
750
|
-
async function
|
|
750
|
+
async function Ve(e) {
|
|
751
751
|
if (!W) throw new U();
|
|
752
752
|
let { user: t } = await q("/api/me", {
|
|
753
753
|
method: "PATCH",
|
|
@@ -757,11 +757,11 @@ async function Be(e) {
|
|
|
757
757
|
...W,
|
|
758
758
|
user: t
|
|
759
759
|
}, K({
|
|
760
|
-
...
|
|
760
|
+
...Fe(),
|
|
761
761
|
user: t
|
|
762
762
|
}), G(), t;
|
|
763
763
|
}
|
|
764
|
-
async function
|
|
764
|
+
async function He() {
|
|
765
765
|
if (!W) throw new U();
|
|
766
766
|
let { token: e, expiresAt: t } = await q("/api/invites", {
|
|
767
767
|
method: "POST",
|
|
@@ -772,7 +772,7 @@ async function Ve() {
|
|
|
772
772
|
expiresAt: t
|
|
773
773
|
};
|
|
774
774
|
}
|
|
775
|
-
async function
|
|
775
|
+
async function Ue({ name: e, email: t }) {
|
|
776
776
|
if (!H) throw Error("no library api");
|
|
777
777
|
return q("/api/invite-requests", {
|
|
778
778
|
method: "POST",
|
|
@@ -782,11 +782,11 @@ async function He({ name: e, email: t }) {
|
|
|
782
782
|
})
|
|
783
783
|
});
|
|
784
784
|
}
|
|
785
|
-
async function
|
|
785
|
+
async function We() {
|
|
786
786
|
if (!W) throw new U();
|
|
787
787
|
return (await q("/api/invite-requests", {}, W.token)).requests;
|
|
788
788
|
}
|
|
789
|
-
async function
|
|
789
|
+
async function Ge(e) {
|
|
790
790
|
if (!W) throw new U();
|
|
791
791
|
let { token: t, expiresAt: n, email: r, name: i } = await q(`/api/invite-requests/${encodeURIComponent(e)}/invite`, {
|
|
792
792
|
method: "POST",
|
|
@@ -801,17 +801,17 @@ async function We(e) {
|
|
|
801
801
|
}
|
|
802
802
|
//#endregion
|
|
803
803
|
//#region src/editor/library/LibraryProvider.jsx
|
|
804
|
-
var
|
|
804
|
+
var Ke = "kol.editor.library.v3", Y = [
|
|
805
805
|
"palette",
|
|
806
806
|
"pattern",
|
|
807
807
|
"type",
|
|
808
808
|
"preset"
|
|
809
|
-
], X = Y.reduce((e, t) => (e[t] = [], e), {}),
|
|
809
|
+
], X = Y.reduce((e, t) => (e[t] = [], e), {}), qe = 1, Je = () => `i${Date.now().toString(36)}-${qe++}`, Ye = (e) => ({
|
|
810
810
|
...e,
|
|
811
|
-
id: e.id ??
|
|
811
|
+
id: e.id ?? Je(),
|
|
812
812
|
savedAt: e.savedAt ?? Date.now()
|
|
813
813
|
}), Z = (e) => typeof e == "number" && Number.isFinite(e);
|
|
814
|
-
function
|
|
814
|
+
function Xe(e) {
|
|
815
815
|
return !e || !Array.isArray(e.colors) || e.colors.length === 0 ? null : {
|
|
816
816
|
colors: e.colors,
|
|
817
817
|
bgEnabled: !!e.bgEnabled,
|
|
@@ -819,7 +819,7 @@ function Ye(e) {
|
|
|
819
819
|
modeId: e.modeId ?? "random"
|
|
820
820
|
};
|
|
821
821
|
}
|
|
822
|
-
function
|
|
822
|
+
function Ze(e) {
|
|
823
823
|
return !e || typeof e.shapeId != "string" || e.shapeId === "type-composition" ? null : {
|
|
824
824
|
shapeId: e.shapeId,
|
|
825
825
|
customSvg: typeof e.customSvg == "string" ? e.customSvg : "",
|
|
@@ -835,7 +835,7 @@ function Xe(e) {
|
|
|
835
835
|
scale: Z(e.scale) ? e.scale : 256
|
|
836
836
|
};
|
|
837
837
|
}
|
|
838
|
-
function
|
|
838
|
+
function Qe(e) {
|
|
839
839
|
if (!e || typeof e.text != "string") return null;
|
|
840
840
|
let t = {
|
|
841
841
|
text: e.text,
|
|
@@ -851,7 +851,7 @@ function Ze(e) {
|
|
|
851
851
|
};
|
|
852
852
|
return e.axisOn !== void 0 && (t.axisOn = e.axisOn, t.width2 = e.width2, t.weight2 = e.weight2, t.blend = e.blend), t;
|
|
853
853
|
}
|
|
854
|
-
function
|
|
854
|
+
function $e(e) {
|
|
855
855
|
return !e || !Array.isArray(e.layers) ? null : {
|
|
856
856
|
intent: e.intent ?? "whole",
|
|
857
857
|
aspect: e.aspect ?? "1:1",
|
|
@@ -869,38 +869,38 @@ function Qe(e) {
|
|
|
869
869
|
...typeof e.sub == "string" ? { sub: e.sub } : {}
|
|
870
870
|
};
|
|
871
871
|
}
|
|
872
|
-
var
|
|
873
|
-
palette:
|
|
874
|
-
pattern:
|
|
875
|
-
type:
|
|
876
|
-
preset:
|
|
877
|
-
},
|
|
872
|
+
var et = {
|
|
873
|
+
palette: Xe,
|
|
874
|
+
pattern: Ze,
|
|
875
|
+
type: Qe,
|
|
876
|
+
preset: $e
|
|
877
|
+
}, tt = [
|
|
878
878
|
"id",
|
|
879
879
|
"savedAt",
|
|
880
880
|
"updatedAt",
|
|
881
881
|
"name"
|
|
882
882
|
];
|
|
883
|
-
function
|
|
883
|
+
function nt(e) {
|
|
884
884
|
let t = {};
|
|
885
|
-
for (let n of
|
|
885
|
+
for (let n of tt) e?.[n] !== void 0 && (t[n] = e[n]);
|
|
886
886
|
return t;
|
|
887
887
|
}
|
|
888
|
-
function
|
|
888
|
+
function rt(e) {
|
|
889
889
|
let t = Y.reduce((e, t) => (e[t] = [], e), {});
|
|
890
890
|
for (let n of Y) {
|
|
891
|
-
let r =
|
|
891
|
+
let r = et[n];
|
|
892
892
|
t[n] = (Array.isArray(e?.[n]) ? e[n] : []).map((e) => {
|
|
893
893
|
let t = r ? r(e) : e;
|
|
894
894
|
return t ? {
|
|
895
895
|
v: 1,
|
|
896
|
-
...
|
|
896
|
+
...nt(e),
|
|
897
897
|
...t
|
|
898
898
|
} : null;
|
|
899
899
|
}).filter(Boolean);
|
|
900
900
|
}
|
|
901
901
|
return t;
|
|
902
902
|
}
|
|
903
|
-
function
|
|
903
|
+
function it(e) {
|
|
904
904
|
return Array.isArray(e) ? e.map((e) => e?.type ? e.type === "bg" ? {
|
|
905
905
|
...e,
|
|
906
906
|
type: "background"
|
|
@@ -913,7 +913,7 @@ function rt(e) {
|
|
|
913
913
|
kind: "logo"
|
|
914
914
|
} : e : e) : e;
|
|
915
915
|
}
|
|
916
|
-
function
|
|
916
|
+
function at(e) {
|
|
917
917
|
let t = {};
|
|
918
918
|
for (let n of [
|
|
919
919
|
"palette",
|
|
@@ -924,37 +924,37 @@ function it(e) {
|
|
|
924
924
|
"composition"
|
|
925
925
|
]) {
|
|
926
926
|
let r = e?.[n];
|
|
927
|
-
Array.isArray(r) ? t[n] = r : r && typeof r == "object" ? t[n] = [
|
|
927
|
+
Array.isArray(r) ? t[n] = r : r && typeof r == "object" ? t[n] = [Ye(r)] : t[n] = [];
|
|
928
928
|
}
|
|
929
929
|
return t;
|
|
930
930
|
}
|
|
931
|
-
function
|
|
932
|
-
let t = Y.reduce((e, t) => (e[t] = [], e), {}), n = (e) => Array.isArray(e) ? e : e && typeof e == "object" ? [
|
|
931
|
+
function ot(e) {
|
|
932
|
+
let t = Y.reduce((e, t) => (e[t] = [], e), {}), n = (e) => Array.isArray(e) ? e : e && typeof e == "object" ? [Ye(e)] : [];
|
|
933
933
|
t.palette = n(e?.palette), t.pattern = n(e?.pattern), t.type = n(e?.type);
|
|
934
934
|
let r = n(e?.layout), i = n(e?.composition).map((e) => ({
|
|
935
935
|
...e,
|
|
936
|
-
layers:
|
|
936
|
+
layers: it(e.layers)
|
|
937
937
|
}));
|
|
938
938
|
return t.preset = [...r, ...i], t;
|
|
939
939
|
}
|
|
940
940
|
function Q() {
|
|
941
941
|
if (typeof window > "u") return X;
|
|
942
942
|
try {
|
|
943
|
-
let e = window.localStorage.getItem(
|
|
944
|
-
if (e) return
|
|
943
|
+
let e = window.localStorage.getItem(Ke);
|
|
944
|
+
if (e) return rt(JSON.parse(e));
|
|
945
945
|
let t = window.localStorage.getItem("kol.generator.library.v2");
|
|
946
|
-
if (t) return window.localStorage.setItem("kol.generator.library.v2._backup", t),
|
|
946
|
+
if (t) return window.localStorage.setItem("kol.generator.library.v2._backup", t), rt(ot(JSON.parse(t)));
|
|
947
947
|
let n = window.localStorage.getItem("kol.generator.library.v1");
|
|
948
|
-
return n ?
|
|
948
|
+
return n ? rt(ot(at(JSON.parse(n)))) : X;
|
|
949
949
|
} catch {
|
|
950
950
|
return X;
|
|
951
951
|
}
|
|
952
952
|
}
|
|
953
|
-
var
|
|
954
|
-
function
|
|
953
|
+
var st = (e) => e?.item?.shipped === !0 || String(e?.id ?? e?.item?.id ?? "").startsWith("ship:");
|
|
954
|
+
function ct(e) {
|
|
955
955
|
if (!(typeof window > "u")) {
|
|
956
956
|
try {
|
|
957
|
-
window.localStorage.setItem(
|
|
957
|
+
window.localStorage.setItem(Ke, JSON.stringify(e));
|
|
958
958
|
} catch (e) {
|
|
959
959
|
console.warn("library: could not save to this browser —", e?.message || e);
|
|
960
960
|
return;
|
|
@@ -962,23 +962,23 @@ function st(e) {
|
|
|
962
962
|
window.dispatchEvent(new CustomEvent("kol:library"));
|
|
963
963
|
}
|
|
964
964
|
}
|
|
965
|
-
var
|
|
965
|
+
var lt = (e) => (window.addEventListener("kol:library", e), window.addEventListener("storage", e), () => {
|
|
966
966
|
window.removeEventListener("kol:library", e), window.removeEventListener("storage", e);
|
|
967
|
-
}),
|
|
967
|
+
}), ut = () => {
|
|
968
968
|
try {
|
|
969
|
-
return window.localStorage.getItem(
|
|
969
|
+
return window.localStorage.getItem(Ke);
|
|
970
970
|
} catch {
|
|
971
971
|
return null;
|
|
972
972
|
}
|
|
973
|
-
},
|
|
974
|
-
function
|
|
973
|
+
}, dt = ae(null);
|
|
974
|
+
function ft(e, t, n) {
|
|
975
975
|
return e.map((e) => e.id === t ? {
|
|
976
976
|
...e,
|
|
977
977
|
name: String(n ?? "").trim() || null,
|
|
978
978
|
updatedAt: Date.now()
|
|
979
979
|
} : e);
|
|
980
980
|
}
|
|
981
|
-
function
|
|
981
|
+
function pt(e, t, n) {
|
|
982
982
|
let r = e.findIndex((e) => e.id === t);
|
|
983
983
|
if (r === -1) return e;
|
|
984
984
|
let i = e[r], a = {
|
|
@@ -993,20 +993,20 @@ function ft(e, t, n) {
|
|
|
993
993
|
...e.slice(r + 1)
|
|
994
994
|
];
|
|
995
995
|
}
|
|
996
|
-
function
|
|
996
|
+
function mt({ children: e }) {
|
|
997
997
|
let [t, n] = N(Q);
|
|
998
|
-
|
|
999
|
-
|
|
998
|
+
M(() => {
|
|
999
|
+
ct(t);
|
|
1000
1000
|
}, [t]);
|
|
1001
|
-
let r =
|
|
1001
|
+
let r = ce(t);
|
|
1002
1002
|
r.current = t;
|
|
1003
|
-
let i =
|
|
1003
|
+
let i = ce(null), [a, o] = N("off"), s = j((e) => {
|
|
1004
1004
|
let t = i.current;
|
|
1005
|
-
!t ||
|
|
1005
|
+
!t || st(e) || t.push(e).catch((e) => {
|
|
1006
1006
|
e instanceof U && J(), typeof console < "u" && console.warn("library sync: push failed —", e?.message || e);
|
|
1007
1007
|
});
|
|
1008
|
-
}, []), c =
|
|
1009
|
-
|
|
1008
|
+
}, []), c = Ne();
|
|
1009
|
+
M(() => {
|
|
1010
1010
|
if (!c) {
|
|
1011
1011
|
i.current = null, o("off");
|
|
1012
1012
|
return;
|
|
@@ -1014,7 +1014,7 @@ function pt({ children: e }) {
|
|
|
1014
1014
|
let e = !0;
|
|
1015
1015
|
return c.backend.hydrate().then((t) => {
|
|
1016
1016
|
if (!e) return;
|
|
1017
|
-
let { next: a, pushes: l } =
|
|
1017
|
+
let { next: a, pushes: l } = Ee(r.current, t);
|
|
1018
1018
|
i.current = c.backend, n({
|
|
1019
1019
|
...X,
|
|
1020
1020
|
...a
|
|
@@ -1026,11 +1026,11 @@ function pt({ children: e }) {
|
|
|
1026
1026
|
e = !1;
|
|
1027
1027
|
};
|
|
1028
1028
|
}, [c, s]);
|
|
1029
|
-
let l =
|
|
1029
|
+
let l = j((e, t) => {
|
|
1030
1030
|
if (!Y.includes(e) || !t) return null;
|
|
1031
|
-
let r =
|
|
1031
|
+
let r = et[e], i = r ? r(t) : t;
|
|
1032
1032
|
if (!i) return null;
|
|
1033
|
-
let a =
|
|
1033
|
+
let a = Je(), o = {
|
|
1034
1034
|
v: 1,
|
|
1035
1035
|
id: a,
|
|
1036
1036
|
savedAt: Date.now(),
|
|
@@ -1045,7 +1045,7 @@ function pt({ children: e }) {
|
|
|
1045
1045
|
kind: e,
|
|
1046
1046
|
item: o
|
|
1047
1047
|
}), a;
|
|
1048
|
-
}, [s]), u =
|
|
1048
|
+
}, [s]), u = j((e, t) => {
|
|
1049
1049
|
n((n) => ({
|
|
1050
1050
|
...n,
|
|
1051
1051
|
[e]: (n[e] ?? []).filter((e) => e.id !== t)
|
|
@@ -1054,9 +1054,9 @@ function pt({ children: e }) {
|
|
|
1054
1054
|
kind: e,
|
|
1055
1055
|
id: t
|
|
1056
1056
|
});
|
|
1057
|
-
}, [s]), ee =
|
|
1057
|
+
}, [s]), ee = j((e, t, i) => {
|
|
1058
1058
|
if (!Y.includes(e) || !t || !i) return;
|
|
1059
|
-
let a =
|
|
1059
|
+
let a = et[e], o = a ? a(i) : i;
|
|
1060
1060
|
if (!o) return;
|
|
1061
1061
|
let c = Date.now(), l = (e) => ({
|
|
1062
1062
|
...e,
|
|
@@ -1076,19 +1076,19 @@ function pt({ children: e }) {
|
|
|
1076
1076
|
kind: e,
|
|
1077
1077
|
item: l(u)
|
|
1078
1078
|
});
|
|
1079
|
-
}, [s]), d =
|
|
1079
|
+
}, [s]), d = j((e, t, i) => {
|
|
1080
1080
|
if (!Y.includes(e) || !t) return;
|
|
1081
1081
|
n((n) => ({
|
|
1082
1082
|
...n,
|
|
1083
|
-
[e]:
|
|
1083
|
+
[e]: ft(n[e] ?? [], t, i)
|
|
1084
1084
|
}));
|
|
1085
|
-
let a =
|
|
1085
|
+
let a = ft(r.current[e] ?? [], t, i).find((e) => e.id === t);
|
|
1086
1086
|
a && s({
|
|
1087
1087
|
op: "put",
|
|
1088
1088
|
kind: e,
|
|
1089
1089
|
item: a
|
|
1090
1090
|
});
|
|
1091
|
-
}, [s]), f =
|
|
1091
|
+
}, [s]), f = j((e, t, i) => {
|
|
1092
1092
|
if (!Y.includes(e) || !t || typeof i != "string" || (r.current[e] ?? []).find((e) => e.id === t)?.shipped) return;
|
|
1093
1093
|
let a = (e) => e.map((e) => e.id === t ? {
|
|
1094
1094
|
...e,
|
|
@@ -1104,25 +1104,25 @@ function pt({ children: e }) {
|
|
|
1104
1104
|
kind: e,
|
|
1105
1105
|
item: o
|
|
1106
1106
|
});
|
|
1107
|
-
}, [s]), p =
|
|
1107
|
+
}, [s]), p = j((e, t) => {
|
|
1108
1108
|
if (!Y.includes(e) || !t) return null;
|
|
1109
|
-
let i =
|
|
1109
|
+
let i = Je();
|
|
1110
1110
|
n((n) => ({
|
|
1111
1111
|
...n,
|
|
1112
|
-
[e]:
|
|
1112
|
+
[e]: pt(n[e] ?? [], t, i)
|
|
1113
1113
|
}));
|
|
1114
|
-
let a =
|
|
1114
|
+
let a = pt(r.current[e] ?? [], t, i).find((e) => e.id === i);
|
|
1115
1115
|
return a && s({
|
|
1116
1116
|
op: "put",
|
|
1117
1117
|
kind: e,
|
|
1118
1118
|
item: a
|
|
1119
1119
|
}), i;
|
|
1120
|
-
}, [s]), m =
|
|
1120
|
+
}, [s]), m = j((e) => {
|
|
1121
1121
|
n((t) => ({
|
|
1122
1122
|
...t,
|
|
1123
1123
|
[e]: []
|
|
1124
1124
|
}));
|
|
1125
|
-
}, []), h =
|
|
1125
|
+
}, []), h = j(() => n(X), []), g = j((e) => n({
|
|
1126
1126
|
...X,
|
|
1127
1127
|
...e
|
|
1128
1128
|
}), []), _ = {
|
|
@@ -1146,13 +1146,13 @@ function pt({ children: e }) {
|
|
|
1146
1146
|
saveType: (e) => l("type", e),
|
|
1147
1147
|
savePreset: (e) => l("preset", e)
|
|
1148
1148
|
};
|
|
1149
|
-
return /* @__PURE__ */ F(
|
|
1149
|
+
return /* @__PURE__ */ F(dt.Provider, {
|
|
1150
1150
|
value: _,
|
|
1151
1151
|
children: e
|
|
1152
1152
|
});
|
|
1153
1153
|
}
|
|
1154
|
-
function
|
|
1155
|
-
return oe(
|
|
1154
|
+
function ht() {
|
|
1155
|
+
return oe(dt) || {
|
|
1156
1156
|
library: X,
|
|
1157
1157
|
selected: Y.reduce((e, t) => (e[t] = null, e), {}),
|
|
1158
1158
|
addItem: () => null,
|
|
@@ -1168,28 +1168,28 @@ function mt() {
|
|
|
1168
1168
|
savePreset: () => null
|
|
1169
1169
|
};
|
|
1170
1170
|
}
|
|
1171
|
-
var
|
|
1171
|
+
var gt = Y, _t = (t) => e("generators")?.loopById(t) ?? null, vt = {
|
|
1172
1172
|
bg: "Background",
|
|
1173
1173
|
fg: "Ink",
|
|
1174
1174
|
accent: "Accent",
|
|
1175
1175
|
dim: "Dim",
|
|
1176
1176
|
warm: "Warm"
|
|
1177
|
-
},
|
|
1177
|
+
}, yt = {
|
|
1178
1178
|
0: "fg",
|
|
1179
1179
|
1: "warm",
|
|
1180
1180
|
3: "dim",
|
|
1181
1181
|
4: "accent",
|
|
1182
1182
|
5: "bg"
|
|
1183
|
-
},
|
|
1184
|
-
function
|
|
1185
|
-
let e = i(), { layers: t, selectedId: n, updateLayer: o, setColorAt: l } = r(), { library: m, addItem: g } =
|
|
1183
|
+
}, bt = (e) => e.slice(0, 7).toLowerCase();
|
|
1184
|
+
function xt() {
|
|
1185
|
+
let e = i(), { layers: t, selectedId: n, updateLayer: o, setColorAt: l } = r(), { library: m, addItem: g } = ht(), [_, re] = N("analogous"), [y, x] = N(p), [S, C] = N(() => c(.62, .14, Math.random() * 360)), [w, T] = N(() => ne(u(y), {
|
|
1186
1186
|
base: S,
|
|
1187
1187
|
relation: _,
|
|
1188
1188
|
count: 5
|
|
1189
1189
|
}).map((e) => ({
|
|
1190
1190
|
hex: e,
|
|
1191
1191
|
locked: !1
|
|
1192
|
-
}))), [E, D] = N(null), O = se(() => ee(m), [m]),
|
|
1192
|
+
}))), [E, D] = N(null), O = se(() => ee(m), [m]), A = ({ b: e = S, rel: t = _, n = w.length, s: r = y } = {}) => {
|
|
1193
1193
|
let i = ne(u(r), {
|
|
1194
1194
|
base: e,
|
|
1195
1195
|
relation: t,
|
|
@@ -1199,33 +1199,33 @@ function bt() {
|
|
|
1199
1199
|
hex: t,
|
|
1200
1200
|
locked: !1
|
|
1201
1201
|
})), D(null);
|
|
1202
|
-
},
|
|
1202
|
+
}, ae = () => {
|
|
1203
1203
|
let e = p();
|
|
1204
|
-
x(e),
|
|
1205
|
-
}, oe = (e) => {
|
|
1206
|
-
let t = yt(e);
|
|
1207
|
-
C(t), k({ b: t });
|
|
1204
|
+
x(e), A({ s: e });
|
|
1208
1205
|
}, j = (e) => {
|
|
1209
|
-
|
|
1206
|
+
let t = bt(e);
|
|
1207
|
+
C(t), A({ b: t });
|
|
1208
|
+
}, oe = (e) => {
|
|
1209
|
+
re(e), A({ rel: e });
|
|
1210
1210
|
}, M = (e) => {
|
|
1211
1211
|
let t = Number(e);
|
|
1212
|
-
Number.isInteger(t) && t >= 2 && t <= 8 &&
|
|
1213
|
-
},
|
|
1212
|
+
Number.isInteger(t) && t >= 2 && t <= 8 && A({ n: t });
|
|
1213
|
+
}, ce = (e, t) => {
|
|
1214
1214
|
T((n) => n.map((n, r) => r === e ? {
|
|
1215
1215
|
...n,
|
|
1216
|
-
hex:
|
|
1216
|
+
hex: bt(t)
|
|
1217
1217
|
} : n)), D(null);
|
|
1218
|
-
},
|
|
1218
|
+
}, P = (e) => T((t) => t.map((t, n) => n === e ? {
|
|
1219
1219
|
...t,
|
|
1220
1220
|
locked: !t.locked
|
|
1221
|
-
} : t)),
|
|
1221
|
+
} : t)), le = (e) => {
|
|
1222
1222
|
T((t) => t.filter((t, n) => n !== e)), D(null);
|
|
1223
1223
|
}, de = (e) => {
|
|
1224
1224
|
let t = O.find((t) => t.id === e);
|
|
1225
1225
|
if (!t) return;
|
|
1226
1226
|
let n = t.colors.slice(0, 8);
|
|
1227
1227
|
T((n.length >= 2 ? n : [...n, ...n]).map((e) => ({
|
|
1228
|
-
hex:
|
|
1228
|
+
hex: bt(e),
|
|
1229
1229
|
locked: !1
|
|
1230
1230
|
}))), D({
|
|
1231
1231
|
name: t.name,
|
|
@@ -1236,11 +1236,11 @@ function bt() {
|
|
|
1236
1236
|
relation: _,
|
|
1237
1237
|
colors: L,
|
|
1238
1238
|
roles: R
|
|
1239
|
-
}, me = (e) => d.filter((t) => R[t]?.toLowerCase() === e).map((e) =>
|
|
1239
|
+
}, me = (e) => d.filter((t) => R[t]?.toLowerCase() === e).map((e) => vt[e]).join(", "), z = n && n !== "canvas" ? a(t, n) : null, B = z?.type === "loop" ? _t(z.loopId)?.params : null, he = () => {
|
|
1240
1240
|
if (!z || !B) return;
|
|
1241
1241
|
let e = te(z, B, pe, { rotate: !0 }), t = Object.fromEntries(B.filter((e) => e.type === "color").map((t) => [t.key, e[t.key]]));
|
|
1242
1242
|
o(z.id, t);
|
|
1243
|
-
}, ge = () => Object.entries(
|
|
1243
|
+
}, ge = () => Object.entries(yt).forEach(([e, t]) => l(Number(e), R[t]));
|
|
1244
1244
|
return /* @__PURE__ */ I("div", {
|
|
1245
1245
|
className: "p-4 flex flex-col gap-4",
|
|
1246
1246
|
children: [
|
|
@@ -1249,7 +1249,7 @@ function bt() {
|
|
|
1249
1249
|
children: [
|
|
1250
1250
|
/* @__PURE__ */ F(ie, {
|
|
1251
1251
|
color: S.toUpperCase(),
|
|
1252
|
-
onChange:
|
|
1252
|
+
onChange: j,
|
|
1253
1253
|
size: "sm",
|
|
1254
1254
|
label: "Base"
|
|
1255
1255
|
}),
|
|
@@ -1265,7 +1265,7 @@ function bt() {
|
|
|
1265
1265
|
className: "kol-helper-10 uppercase text-meta",
|
|
1266
1266
|
children: "Colors"
|
|
1267
1267
|
}),
|
|
1268
|
-
/* @__PURE__ */ F(
|
|
1268
|
+
/* @__PURE__ */ F(k, {
|
|
1269
1269
|
size: e,
|
|
1270
1270
|
min: 2,
|
|
1271
1271
|
max: 8,
|
|
@@ -1287,11 +1287,11 @@ function bt() {
|
|
|
1287
1287
|
label: e.label
|
|
1288
1288
|
})),
|
|
1289
1289
|
value: _,
|
|
1290
|
-
onChange:
|
|
1290
|
+
onChange: oe
|
|
1291
1291
|
}), /* @__PURE__ */ F(v, {
|
|
1292
1292
|
tone: "grey",
|
|
1293
1293
|
size: e,
|
|
1294
|
-
onClick:
|
|
1294
|
+
onClick: ae,
|
|
1295
1295
|
children: "Roll"
|
|
1296
1296
|
})]
|
|
1297
1297
|
}),
|
|
@@ -1302,7 +1302,7 @@ function bt() {
|
|
|
1302
1302
|
children: [
|
|
1303
1303
|
/* @__PURE__ */ F(ie, {
|
|
1304
1304
|
color: e.hex.toUpperCase(),
|
|
1305
|
-
onChange: (e) =>
|
|
1305
|
+
onChange: (e) => ce(t, e),
|
|
1306
1306
|
size: "sm",
|
|
1307
1307
|
label: `Color ${t + 1}`
|
|
1308
1308
|
}),
|
|
@@ -1321,7 +1321,7 @@ function bt() {
|
|
|
1321
1321
|
iconOnly: e.locked ? "lock" : "unlock",
|
|
1322
1322
|
"aria-label": `${e.locked ? "Unlock" : "Lock"} color ${t + 1}`,
|
|
1323
1323
|
pressed: e.locked,
|
|
1324
|
-
onClick: () =>
|
|
1324
|
+
onClick: () => P(t)
|
|
1325
1325
|
}),
|
|
1326
1326
|
/* @__PURE__ */ F("span", {
|
|
1327
1327
|
className: w.length <= 2 ? "invisible pointer-events-none" : "contents",
|
|
@@ -1333,7 +1333,7 @@ function bt() {
|
|
|
1333
1333
|
iconOnly: "trash",
|
|
1334
1334
|
"aria-label": `Delete color ${t + 1}`,
|
|
1335
1335
|
tabIndex: w.length <= 2 ? -1 : void 0,
|
|
1336
|
-
onClick: () =>
|
|
1336
|
+
onClick: () => le(t)
|
|
1337
1337
|
})
|
|
1338
1338
|
})
|
|
1339
1339
|
]
|
|
@@ -1341,7 +1341,7 @@ function bt() {
|
|
|
1341
1341
|
}),
|
|
1342
1342
|
h(R.bg, R.fg) < 4.5 && /* @__PURE__ */ I("span", {
|
|
1343
1343
|
className: "kol-helper-10 text-meta inline-flex items-center gap-1",
|
|
1344
|
-
children: [/* @__PURE__ */ F(
|
|
1344
|
+
children: [/* @__PURE__ */ F(ue, {
|
|
1345
1345
|
name: "info",
|
|
1346
1346
|
size: 12
|
|
1347
1347
|
}), "Ink on background is under 4.5:1"]
|
|
@@ -1389,12 +1389,12 @@ function bt() {
|
|
|
1389
1389
|
}
|
|
1390
1390
|
//#endregion
|
|
1391
1391
|
//#region src/editor/color/ColorModesWindow.jsx
|
|
1392
|
-
var
|
|
1393
|
-
function
|
|
1392
|
+
var St = "kol:open-color-modes", Ct = () => window.dispatchEvent(new CustomEvent(St));
|
|
1393
|
+
function wt() {
|
|
1394
1394
|
let [e, t] = N(!1);
|
|
1395
|
-
if (
|
|
1395
|
+
if (M(() => {
|
|
1396
1396
|
let e = () => t(!0);
|
|
1397
|
-
return window.addEventListener(
|
|
1397
|
+
return window.addEventListener(St, e), () => window.removeEventListener(St, e);
|
|
1398
1398
|
}, []), !e) return null;
|
|
1399
1399
|
let n = () => t(!1);
|
|
1400
1400
|
return /* @__PURE__ */ F(x, {
|
|
@@ -1402,10 +1402,11 @@ function Ct() {
|
|
|
1402
1402
|
onClose: n,
|
|
1403
1403
|
closeButton: !1,
|
|
1404
1404
|
scrim: !0,
|
|
1405
|
-
children: /* @__PURE__ */ I(
|
|
1405
|
+
children: /* @__PURE__ */ I(E, {
|
|
1406
|
+
variant: "bordered",
|
|
1406
1407
|
"aria-label": "Color Modes",
|
|
1407
1408
|
"data-editor-keep-selection": !0,
|
|
1408
|
-
className: "kol-design-editor
|
|
1409
|
+
className: "kol-design-editor w-[360px] max-w-full shadow-[0_8px_24px_-8px_rgba(0,0,0,0.4),0_2px_6px_-2px_rgba(0,0,0,0.3)]",
|
|
1409
1410
|
children: [/* @__PURE__ */ I("div", {
|
|
1410
1411
|
className: "relative flex h-10 items-center justify-center border-b border-oq-08 px-4",
|
|
1411
1412
|
children: [/* @__PURE__ */ F("span", {
|
|
@@ -1416,47 +1417,47 @@ function Ct() {
|
|
|
1416
1417
|
size: "sm",
|
|
1417
1418
|
className: "!absolute right-3"
|
|
1418
1419
|
})]
|
|
1419
|
-
}), /* @__PURE__ */ F(
|
|
1420
|
+
}), /* @__PURE__ */ F(xt, {})]
|
|
1420
1421
|
})
|
|
1421
1422
|
});
|
|
1422
1423
|
}
|
|
1423
1424
|
//#endregion
|
|
1424
1425
|
//#region src/editor/generate/store.js
|
|
1425
|
-
var $ = {},
|
|
1426
|
-
function
|
|
1426
|
+
var $ = {}, Tt = /* @__PURE__ */ new Set(), Et = () => Tt.forEach((e) => e());
|
|
1427
|
+
function Dt(e, t) {
|
|
1427
1428
|
$[e] = {
|
|
1428
1429
|
live: !0,
|
|
1429
1430
|
layerId: null,
|
|
1430
1431
|
...$[e],
|
|
1431
1432
|
...typeof t == "function" ? t($[e]) : t
|
|
1432
|
-
},
|
|
1433
|
+
}, Et();
|
|
1433
1434
|
}
|
|
1434
|
-
function
|
|
1435
|
+
function Ot(e, t) {
|
|
1435
1436
|
return $[e]?.params || ($[e] = {
|
|
1436
1437
|
live: !0,
|
|
1437
1438
|
layerId: null,
|
|
1438
1439
|
...$[e],
|
|
1439
1440
|
params: t()
|
|
1440
|
-
}), P((e) => (
|
|
1441
|
+
}), P((e) => (Tt.add(e), () => Tt.delete(e)), () => $[e]);
|
|
1441
1442
|
}
|
|
1442
|
-
var
|
|
1443
|
-
function
|
|
1443
|
+
var kt = (e, t = "rail") => Nt(t === "dialog" ? { dialog: e } : { rail: e });
|
|
1444
|
+
function At(e, t, n = "rail") {
|
|
1444
1445
|
let { id: r, type: i, children: a, ...o } = t;
|
|
1445
|
-
|
|
1446
|
+
Dt(e, {
|
|
1446
1447
|
params: o,
|
|
1447
1448
|
layerId: r
|
|
1448
|
-
}),
|
|
1449
|
+
}), kt(e, n);
|
|
1449
1450
|
}
|
|
1450
|
-
var
|
|
1451
|
+
var jt = {
|
|
1451
1452
|
rail: null,
|
|
1452
1453
|
dialog: null
|
|
1453
|
-
},
|
|
1454
|
-
function
|
|
1455
|
-
|
|
1456
|
-
...
|
|
1454
|
+
}, Mt = /* @__PURE__ */ new Set();
|
|
1455
|
+
function Nt(e) {
|
|
1456
|
+
jt = {
|
|
1457
|
+
...jt,
|
|
1457
1458
|
...e
|
|
1458
|
-
},
|
|
1459
|
+
}, Mt.forEach((e) => e());
|
|
1459
1460
|
}
|
|
1460
|
-
var
|
|
1461
|
+
var Pt = () => P((e) => (Mt.add(e), () => Mt.delete(e)), () => jt);
|
|
1461
1462
|
//#endregion
|
|
1462
|
-
export {
|
|
1463
|
+
export { Ve as A, We as C, ze as D, De as E, xe as F, me as I, Ne as M, Ce as N, J as O, ye as P, Ge as S, Ue as T, lt as _, Ot as a, Oe as b, Ct as c, pt as d, ft as f, ct as g, ut as h, Nt as i, Pe as j, Be as k, mt as l, Q as m, kt as n, Pt as o, st as p, Dt as r, wt as s, At as t, gt as u, ht as v, He as w, Me as x, U as y };
|