@kolkrabbi/design-editor 0.24.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +2 -2
  2. package/dist/BindDot-CMUtpJPX.js +84 -0
  3. package/dist/BufferGeometryUtils-Cc8LNd5v.js +150 -0
  4. package/dist/ColorModesWindow-CWhL6nfm.js +1493 -0
  5. package/dist/GLTFLoader-BFir8PCc.js +1361 -0
  6. package/dist/OBJLoader-BgqC_-Jn.js +287 -0
  7. package/dist/{OrbitControls-Cql8Rn2i.js → OrbitControls-DVpLgmKv.js} +2755 -2202
  8. package/dist/STLLoader-C6DGLf6r.js +83 -0
  9. package/dist/Timeline-BObvcdXF.js +3014 -0
  10. package/dist/TreePicker-nMf17QGH.js +68 -0
  11. package/dist/core-EWu8GfXL.js +17504 -0
  12. package/dist/core.js +5 -3
  13. package/dist/design-editor.css +1 -1
  14. package/dist/design-editor.js +2114 -916
  15. package/dist/effects-DZEmfY7a.js +444 -0
  16. package/dist/effects.js +1 -1
  17. package/dist/generators-D1tFSZgG.js +2961 -0
  18. package/dist/generators.js +1 -1
  19. package/dist/{host-qtFVROOD.js → host-CRsCCafL.js} +429 -370
  20. package/dist/{host-be1CWhN1.js → host-ZLJKCZ54.js} +137 -136
  21. package/dist/motion-C_u7tsis.js +2295 -0
  22. package/dist/motion.js +1 -1
  23. package/dist/previewScale-BMkeLc6w.js +26 -0
  24. package/dist/{rolls-Bg1XHuvJ.js → rolls-BGtqxVYq.js} +2621 -1522
  25. package/dist/{src-B5fQgAVE.js → src-BpTckTDZ.js} +1 -1
  26. package/dist/{useLayerEdit-ieOjHx6x.js → useLayerEdit-BFcZhiNX.js} +20992 -12580
  27. package/package.json +9 -7
  28. package/dist/RuleRow-DIbuUt37.js +0 -650
  29. package/dist/TreePicker-DLmMl0aU.js +0 -68
  30. package/dist/core-CNI8b_83.js +0 -12314
  31. package/dist/effectCategories-0PnGZvjd.js +0 -4210
  32. package/dist/effects-BujxwoNY.js +0 -469
  33. package/dist/generators-SpRHQDMq.js +0 -2517
  34. package/dist/labels-B5qkocWy.js +0 -2007
  35. package/dist/motion-Bn3FVkCS.js +0 -2260
@@ -0,0 +1,444 @@
1
+ import { Et as e, F as t, J as n, L as r, Ln as i, a, d as o, et as s, n as c, o as l, rt as u, t as d, u as f } from "./rolls-BGtqxVYq.js";
2
+ import { $ as p, Q as m, X as h, Y as g, Z as _, c as v, et as y, f as b, g as x, h as S, l as C, n as w, nt as T, o as E, p as D, r as O, rt as k, s as A, t as ee, tt as j, u as M } from "./useLayerEdit-BFcZhiNX.js";
3
+ import { n as N, t as P } from "./TreePicker-nMf17QGH.js";
4
+ import { t as F } from "./BindDot-CMUtpJPX.js";
5
+ import { Button as I, Dropdown as L, LabeledControl as R, LabeledControlSection as z, SegmentedToggle as B, SettingsRow as te, ToggleSwitch as V, Tooltip as H, XYPad as U } from "@kolkrabbi/kol-component";
6
+ import { useEffect as ne, useRef as re, useState as W } from "react";
7
+ import { Fragment as G, jsx as K, jsxs as q } from "react/jsx-runtime";
8
+ //#region src/editor/compose/inspectors/EffectsPanel.jsx
9
+ var J = [{
10
+ value: "effect",
11
+ label: "Effect"
12
+ }, {
13
+ value: "anim",
14
+ label: "Animation"
15
+ }];
16
+ function Y() {
17
+ let { selectedId: t, layers: r } = n(), i = t && t !== "canvas" ? e(r, t) : null;
18
+ return /* @__PURE__ */ K("div", {
19
+ className: "kol-compose-rail kol-compose-rail--inspector",
20
+ children: /* @__PURE__ */ K("div", {
21
+ className: "kol-compose-inspector-body",
22
+ children: i ? /* @__PURE__ */ K(X, { layer: i }, i.id) : /* @__PURE__ */ K(O, {
23
+ always: !0,
24
+ children: "Select a layer to edit its effect."
25
+ })
26
+ })
27
+ });
28
+ }
29
+ function X({ layer: e }) {
30
+ let i = r(), { palette: a, addFilter: o, removeFilter: c, toggleFilter: l, moveFilter: d, replaceFilter: f } = n(), p = ee(e.id, { history: "coalesce" }), m = s(e), h = m.some((e) => e.def?.kind === "engine"), { effectable: g, engineHost: _, engineLoop: y } = A(e), [x, C] = W(m.length ? 0 : null), T = x == null ? null : m[x] ?? null, [E, O] = W("effect"), k = re(m.map((e) => e.key));
31
+ if (ne(() => {
32
+ let e = k.current, t = m.map((e) => e.key);
33
+ k.current = t;
34
+ let n = t.find((t) => !e.includes(t));
35
+ if (n != null) {
36
+ C(t.indexOf(n));
37
+ return;
38
+ }
39
+ x != null && x >= t.length && C(t.length ? t.length - 1 : null);
40
+ }, [m.length]), !g) return /* @__PURE__ */ K("p", {
41
+ className: "kol-mono-12 text-meta",
42
+ children: y ? "Engine loops can't host effects yet." : "This layer can't host an effect."
43
+ });
44
+ let j = (e) => {
45
+ let t = _ && (e == null ? !h : m[e]?.def?.kind === "engine" || !h && e === m.length - 1), n = S.filter((e) => e.kind !== "engine" || t), r = /* @__PURE__ */ new Set();
46
+ return v(n).flatMap((e) => {
47
+ let t = e.filters.filter((e) => !r.has(e.id) && r.add(e.id));
48
+ return t.length ? [{ heading: e.label }, ...t.map((e) => ({
49
+ value: e.id,
50
+ label: e.label
51
+ }))] : [];
52
+ });
53
+ }, M = m.map(({ def: e, ...t }) => t), P = T ? {
54
+ ...e,
55
+ ...T.params,
56
+ id: e.id
57
+ } : null, I = (e) => {
58
+ if (x == null) return;
59
+ let t = M.map((t, n) => n === x ? {
60
+ ...t,
61
+ params: {
62
+ ...t.params,
63
+ ...e
64
+ }
65
+ } : t);
66
+ p.patch({ filters: t });
67
+ }, R = (e, t) => {
68
+ if (e === "cameraDrag") {
69
+ p.setProp(e, t);
70
+ return;
71
+ }
72
+ I({ [e]: t });
73
+ }, z = (e) => R("sweeps", e), V = (e) => /* @__PURE__ */ K(F, {
74
+ layer: P,
75
+ param: e,
76
+ setProp: R
77
+ }), H = T?.def ? b(T.def.id) : null, U = H ? T.def.params.find((e) => e.key === H) : null, Y = T?.def ? T.def.params.filter((e) => u(e) !== "anim" && e !== U) : [];
78
+ return /* @__PURE__ */ q("div", {
79
+ className: "flex flex-col gap-4",
80
+ children: [m.map((n, r) => /* @__PURE__ */ q("div", {
81
+ className: "flex flex-col gap-3",
82
+ children: [/* @__PURE__ */ K(ie, {
83
+ stage: n,
84
+ selected: r === x,
85
+ options: j(r),
86
+ onSelect: () => C(r),
87
+ onPick: (t) => {
88
+ t && t !== n.id && f(e.id, r, t), C(r);
89
+ },
90
+ onToggle: () => l(e.id, r),
91
+ onRemove: () => c(e.id, r),
92
+ onUp: () => d(e.id, r, r - 1),
93
+ onDown: () => d(e.id, r, r + 1),
94
+ canUp: r > 0 && n.def?.kind !== "engine",
95
+ canDown: r < m.length - 1 && n.def?.kind !== "engine" && m[r + 1]?.def?.kind !== "engine"
96
+ }), r === x && T?.def && /* @__PURE__ */ q("div", {
97
+ className: "flex flex-col gap-3",
98
+ children: [
99
+ U && /* @__PURE__ */ K(N, {
100
+ label: "Preset",
101
+ options: U.options,
102
+ value: T.params[U.key] ?? U.default,
103
+ onChange: (e) => I(D(T.def, e)),
104
+ inline: !0
105
+ }),
106
+ e.imgW != null && /* @__PURE__ */ K("span", {
107
+ className: "kol-helper-12 text-meta",
108
+ children: "Filters don't apply to cropped photos."
109
+ }),
110
+ T.def.orbit && /* @__PURE__ */ K(te, {
111
+ label: "Camera drag",
112
+ align: "fill",
113
+ labelWidth: t,
114
+ children: /* @__PURE__ */ K(B, {
115
+ size: i,
116
+ className: "w-full",
117
+ options: [{
118
+ value: "off",
119
+ label: "Off"
120
+ }, {
121
+ value: "on",
122
+ label: "On"
123
+ }],
124
+ value: e.cameraDrag ? "on" : "off",
125
+ onChange: (e) => R("cameraDrag", e === "on")
126
+ })
127
+ }),
128
+ /* @__PURE__ */ K(B, {
129
+ size: i,
130
+ className: "w-full",
131
+ value: E,
132
+ onChange: O,
133
+ options: J
134
+ }),
135
+ E === "effect" && /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ K(w, {
136
+ schema: Y,
137
+ layer: P,
138
+ setProp: R,
139
+ palette: a,
140
+ renderAnimate: V
141
+ }), /* @__PURE__ */ K(Z, {
142
+ def: T.def,
143
+ view: P,
144
+ tab: "effect",
145
+ onPatch: I
146
+ })] }),
147
+ E === "anim" && /* @__PURE__ */ q(G, { children: [
148
+ /* @__PURE__ */ K(w, {
149
+ schema: T.def.params,
150
+ layer: P,
151
+ setProp: R,
152
+ palette: a,
153
+ renderAnimate: V,
154
+ tab: "anim"
155
+ }),
156
+ /* @__PURE__ */ K(Z, {
157
+ def: T.def,
158
+ view: P,
159
+ tab: "anim",
160
+ onPatch: I
161
+ }),
162
+ T.def.sweeps && /* @__PURE__ */ K(Q, {
163
+ sweeps: Array.isArray(T.params.sweeps) ? T.params.sweeps : [],
164
+ onChange: z
165
+ })
166
+ ] })
167
+ ]
168
+ })]
169
+ }, n.key)), m.length < 8 ? /* @__PURE__ */ K(L, {
170
+ variant: "subtle",
171
+ size: i,
172
+ className: "w-full",
173
+ options: [{
174
+ value: "",
175
+ label: "Add effect…"
176
+ }, ...j(null)],
177
+ value: "",
178
+ onChange: (t) => {
179
+ t && o(e.id, t);
180
+ }
181
+ }) : /* @__PURE__ */ K("span", {
182
+ className: "kol-helper-12 text-meta",
183
+ children: "Chain is full (8 effects)"
184
+ })]
185
+ });
186
+ }
187
+ function Z({ def: e, view: t, tab: n, onPatch: i, inline: s = !1, levels: p = null }) {
188
+ let m = r(), h = o(t), g = n === "anim", _ = e.params.filter((e) => u(e) === "anim" === g), v = g ? _.filter((e) => !e.noRandom) : c(_, t), y = f(l(_, t), v), b = (e, n) => {
189
+ e.length && i(a(t, e, h.take(), { stripNoRandom: !!n?.motion }));
190
+ }, x = (e) => {
191
+ let t = {};
192
+ for (let n of e) n.default !== void 0 && (t[n.key] = n.default);
193
+ Object.keys(t).length && i(t);
194
+ };
195
+ return !v.length && !y.length ? null : /* @__PURE__ */ q("div", {
196
+ className: "flex flex-col gap-2",
197
+ children: [
198
+ v.length >= 5 && /* @__PURE__ */ K(d, {
199
+ seed: h,
200
+ inline: s
201
+ }),
202
+ v.length > 0 && /* @__PURE__ */ q("div", {
203
+ className: "flex gap-2",
204
+ children: [p ?? /* @__PURE__ */ K(I, {
205
+ tone: "primary",
206
+ size: m,
207
+ className: "flex-1 min-w-0",
208
+ onClick: (e) => e.altKey ? x(v) : b(v),
209
+ children: g ? "Randomize motion" : "Randomize all"
210
+ }), /* @__PURE__ */ K(H, {
211
+ label: "Reset to defaults",
212
+ shortcut: "R",
213
+ children: /* @__PURE__ */ K(I, {
214
+ tone: "primary",
215
+ size: m,
216
+ iconOnly: "refresh",
217
+ "aria-label": "Reset to defaults",
218
+ onClick: () => x(v),
219
+ className: "shrink-0"
220
+ })
221
+ })]
222
+ }),
223
+ y.length > 0 && /* @__PURE__ */ K("div", {
224
+ className: `grid ${s ? "grid-cols-3" : "grid-cols-2"} gap-2`,
225
+ children: y.map((e) => /* @__PURE__ */ K(I, {
226
+ tone: "primary",
227
+ size: m,
228
+ onClick: (t) => t.altKey ? x(e.params) : b(e.params, e),
229
+ children: e.label
230
+ }, e.id))
231
+ })
232
+ ]
233
+ });
234
+ }
235
+ function ie({ stage: e, selected: t, options: n, onSelect: i, onPick: a, onToggle: o, onRemove: s, onUp: c, onDown: l, canUp: u, canDown: d }) {
236
+ let f = r(), p = e.enabled !== !1, m = (e, t, n, r, i = "") => {
237
+ let a = /* @__PURE__ */ K(H, {
238
+ label: e,
239
+ children: /* @__PURE__ */ K(I, {
240
+ tone: "ghost",
241
+ quiet: !0,
242
+ size: f,
243
+ iconOnly: r,
244
+ "aria-label": e,
245
+ tabIndex: n ? -1 : void 0,
246
+ onClick: (e) => {
247
+ e.stopPropagation(), n || t();
248
+ },
249
+ className: `shrink-0 ${i}`
250
+ })
251
+ });
252
+ return n ? /* @__PURE__ */ K("span", {
253
+ "aria-hidden": "true",
254
+ className: "invisible pointer-events-none shrink-0",
255
+ children: a
256
+ }) : a;
257
+ };
258
+ return /* @__PURE__ */ q("div", {
259
+ onClick: i,
260
+ className: `flex items-center gap-1 rounded ${t ? "bg-oq-08" : ""}`,
261
+ children: [
262
+ m(p ? "Disable effect" : "Enable effect", o, !1, p ? "eye-on" : "eye-off"),
263
+ /* @__PURE__ */ K("div", {
264
+ className: `flex-1 min-w-0 ${p ? "" : "opacity-60"}`,
265
+ children: /* @__PURE__ */ K(L, {
266
+ variant: "subtle",
267
+ size: f,
268
+ className: "w-full",
269
+ options: n,
270
+ value: e.id,
271
+ onChange: a
272
+ })
273
+ }),
274
+ m("Move up", c, !u, "chevron-down", "rotate-180"),
275
+ m("Move down", l, !d, "chevron-down"),
276
+ m("Delete effect", s, !1, "x")
277
+ ]
278
+ });
279
+ }
280
+ var ae = (e) => [
281
+ {
282
+ key: "shape",
283
+ label: "Shape",
284
+ type: "select",
285
+ options: _,
286
+ default: "linear"
287
+ },
288
+ {
289
+ key: "target",
290
+ label: "Target",
291
+ type: "select",
292
+ options: m,
293
+ default: "brightness"
294
+ },
295
+ {
296
+ key: "travel",
297
+ label: "Travel",
298
+ type: "select",
299
+ options: p,
300
+ default: "forward"
301
+ },
302
+ ...e.target === "reveal" ? [] : [{
303
+ key: "amount",
304
+ label: "Amount",
305
+ type: "range",
306
+ min: -1,
307
+ max: 1,
308
+ step: .01,
309
+ default: .6
310
+ }],
311
+ {
312
+ key: "speed",
313
+ label: "Speed",
314
+ type: "range",
315
+ min: -8,
316
+ max: 8,
317
+ step: 1,
318
+ default: 1
319
+ },
320
+ {
321
+ key: "width",
322
+ label: "Width",
323
+ type: "range",
324
+ min: .05,
325
+ max: 1,
326
+ step: .01,
327
+ default: .35
328
+ },
329
+ ...g.has(e.shape ?? "linear") ? [{
330
+ key: "angle",
331
+ label: "Angle",
332
+ type: "range",
333
+ min: 0,
334
+ max: 360,
335
+ step: 1,
336
+ default: 0
337
+ }] : []
338
+ ];
339
+ function Q({ sweeps: e, onChange: n, inline: i = !1 }) {
340
+ let a = r(), o = (e) => _.find((t) => t.value === e)?.label ?? e, s = (t) => n([...e, t ? y(t.shape, t) : y()]), c = (t) => n(e.filter((e, n) => n !== t)), l = (t, r) => n(e.map((e, n) => n === t ? {
341
+ ...e,
342
+ ...r
343
+ } : e));
344
+ return /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ q(z, {
345
+ label: "Motion",
346
+ divided: !0,
347
+ children: [/* @__PURE__ */ K(P, {
348
+ options: [{
349
+ value: "",
350
+ label: "Add motion…"
351
+ }, ...h.map((e) => ({
352
+ value: e.name,
353
+ label: e.name
354
+ }))],
355
+ value: "",
356
+ onChange: (e) => {
357
+ let t = h.find((t) => t.name === e);
358
+ t && s(t);
359
+ }
360
+ }), /* @__PURE__ */ K(I, {
361
+ tone: "primary",
362
+ size: a,
363
+ className: "w-full",
364
+ iconLeft: "plus",
365
+ iconSize: 12,
366
+ onClick: () => s(),
367
+ children: "Add custom sweep"
368
+ })]
369
+ }), e.map((e, n) => {
370
+ let r = e.enabled !== !1;
371
+ return /* @__PURE__ */ q(z, {
372
+ divided: !0,
373
+ children: [/* @__PURE__ */ q("div", {
374
+ className: "flex items-center gap-2",
375
+ children: [
376
+ /* @__PURE__ */ K("span", {
377
+ className: `kol-eyebrow flex-1 truncate ${r ? "text-fg-80" : "text-meta"}`,
378
+ children: o(e.shape ?? "linear")
379
+ }),
380
+ /* @__PURE__ */ K(V, {
381
+ size: a,
382
+ checked: r,
383
+ onChange: (e) => l(n, { enabled: e })
384
+ }),
385
+ /* @__PURE__ */ K(H, {
386
+ label: "Delete sweep",
387
+ children: /* @__PURE__ */ K(I, {
388
+ tone: "ghost",
389
+ quiet: !0,
390
+ size: a,
391
+ iconOnly: "x",
392
+ "aria-label": "Delete sweep",
393
+ className: "shrink-0",
394
+ onClick: () => c(n)
395
+ })
396
+ })
397
+ ]
398
+ }), r && /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ K(w, {
399
+ schema: ae(e),
400
+ layer: e,
401
+ setProp: (e, t) => l(n, { [e]: t }),
402
+ inline: i
403
+ }), (e.shape ?? "linear") !== "noise" && /* @__PURE__ */ K(R, {
404
+ inline: !0,
405
+ label: "ORIGIN",
406
+ labelWidth: t,
407
+ children: /* @__PURE__ */ K("div", {
408
+ className: "w-full min-w-0",
409
+ children: /* @__PURE__ */ K(U, {
410
+ xValue: e.cx ?? .5,
411
+ yValue: e.cy ?? .5,
412
+ xMin: 0,
413
+ xMax: 1,
414
+ yMin: 1,
415
+ yMax: 0,
416
+ onChange: (e, t) => l(n, {
417
+ cx: Math.round(e * 100) / 100,
418
+ cy: Math.round(t * 100) / 100
419
+ })
420
+ })
421
+ })
422
+ })] })]
423
+ }, n);
424
+ })] });
425
+ }
426
+ //#endregion
427
+ //#region src/packs/effects.js
428
+ var $ = {
429
+ FILTERS: S,
430
+ filterById: x,
431
+ makeSweep: y,
432
+ runChain: T,
433
+ invalidateSource: j,
434
+ stillOf: k,
435
+ effectCategories: E,
436
+ liveFilterGroups: C,
437
+ liveFilterLabel: M,
438
+ EffectsPanel: Y,
439
+ loadPixiPipeline: () => import("./pipeline-CMpuPUaX.js"),
440
+ loadGlHost: () => import("./host-ZLJKCZ54.js")
441
+ };
442
+ i("effects", $);
443
+ //#endregion
444
+ export { Z as n, Q as r, $ as t };
package/dist/effects.js CHANGED
@@ -1,2 +1,2 @@
1
- import { t as e } from "./effects-BujxwoNY.js";
1
+ import { t as e } from "./effects-DZEmfY7a.js";
2
2
  export { e as effects };