@pixerate/editor 0.160.0 → 0.162.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/agent/index.cjs +36 -35
- package/dist/agent/index.js +7 -6
- package/dist/animation/index.cjs +5 -4
- package/dist/animation/index.js +4 -3
- package/dist/animation-editor/index.cjs +62 -61
- package/dist/animation-editor/index.js +6 -5
- package/dist/canvas/index.cjs +33 -32
- package/dist/canvas/index.js +6 -5
- package/dist/chart/index.cjs +88 -87
- package/dist/chart/index.js +7 -6
- package/dist/{chunk-QMI5HZWA.cjs → chunk-236TKNUR.cjs} +3 -3
- package/dist/{chunk-6UPGM3JB.js → chunk-2TKHLX6H.js} +1 -1
- package/dist/{chunk-3YDQLQH2.cjs → chunk-32MMQYCQ.cjs} +81 -81
- package/dist/{chunk-MHEXLG3M.cjs → chunk-3GJH2MGH.cjs} +37 -37
- package/dist/{chunk-AKDWAWSY.cjs → chunk-3IHNXRUV.cjs} +45 -45
- package/dist/{chunk-VKF3PWKR.cjs → chunk-3OSXHLIT.cjs} +259 -28
- package/dist/{chunk-TVO6W2Q6.cjs → chunk-4NGVHHJB.cjs} +17 -17
- package/dist/chunk-4VU4CP7R.js +769 -0
- package/dist/chunk-6DM3PUQD.cjs +767 -0
- package/dist/{chunk-DBIVICAO.js → chunk-7CKPUUN4.js} +1 -1
- package/dist/{chunk-57JLBGJ5.cjs → chunk-7YBDRJXT.cjs} +8 -8
- package/dist/{chunk-KY3FYKP3.js → chunk-BQWGN5WH.js} +1 -1
- package/dist/{chunk-LEUZ4FRC.cjs → chunk-CIPIESX4.cjs} +3 -3
- package/dist/chunk-CJE5MOIS.js +347 -0
- package/dist/{chunk-5QBRAIVK.js → chunk-CX6JLDFC.js} +3 -3
- package/dist/{chunk-R3QY7PPL.js → chunk-DTSTNRPH.js} +1 -1
- package/dist/{chunk-6LUYFHHN.cjs → chunk-EQ46F75O.cjs} +51 -51
- package/dist/{chunk-UKCJ43YL.cjs → chunk-ES3UEVUT.cjs} +130 -898
- package/dist/{chunk-UM3RPYC5.js → chunk-EVPZ5IKN.js} +1 -1
- package/dist/{chunk-XNQ5EFB4.cjs → chunk-EY22AY6R.cjs} +16 -16
- package/dist/chunk-FKUKJ3XA.cjs +347 -0
- package/dist/{chunk-YABNLNY7.js → chunk-GLMP22FT.js} +3 -3
- package/dist/{chunk-SUF6WRXR.cjs → chunk-GTELFJRE.cjs} +2 -2
- package/dist/{chunk-72BGL3I2.js → chunk-GWV4T5NZ.js} +1 -1
- package/dist/{chunk-AY65VQSU.js → chunk-H3OEM3Q2.js} +1 -1
- package/dist/{chunk-4YWAEV4W.cjs → chunk-HDGBM7EA.cjs} +26 -26
- package/dist/{chunk-H5XX4KHB.js → chunk-HLOKB7WW.js} +5 -3
- package/dist/{chunk-WNAAWLZ5.js → chunk-KGTF55R3.js} +2 -2
- package/dist/{chunk-WPPJH6X4.cjs → chunk-LL3H5XUH.cjs} +6 -4
- package/dist/{chunk-4T44CJ5K.cjs → chunk-NA4UVVJ4.cjs} +15 -15
- package/dist/{chunk-Q6PA362P.js → chunk-NO5QQDHZ.js} +2 -2
- package/dist/{chunk-AA34BA7G.js → chunk-QYZGBVNC.js} +30 -798
- package/dist/chunk-S6X2QRVU.cjs +769 -0
- package/dist/{chunk-SSCL7QQ4.js → chunk-XDCFJEU7.js} +2 -2
- package/dist/{chunk-IQ6KKXOU.js → chunk-YN4AYYBJ.js} +243 -12
- package/dist/chunk-ZGOHKS3X.js +767 -0
- package/dist/color/index.cjs +6 -2
- package/dist/color/index.d.cts +1 -0
- package/dist/color/index.d.ts +1 -0
- package/dist/color/index.js +28 -24
- package/dist/color/suggest.d.cts +12 -0
- package/dist/color/suggest.d.ts +12 -0
- package/dist/effects/index.cjs +44 -771
- package/dist/effects/index.js +34 -761
- package/dist/effects/ui.d.cts +20 -3
- package/dist/effects/ui.d.ts +20 -3
- package/dist/export/index.cjs +6 -5
- package/dist/export/index.js +5 -4
- package/dist/extensions/index.cjs +9 -8
- package/dist/extensions/index.js +8 -7
- package/dist/gradient/index.cjs +28 -26
- package/dist/gradient/index.js +7 -5
- package/dist/image-editor/index.cjs +638 -637
- package/dist/image-editor/index.js +5 -4
- package/dist/index.cjs +15 -14
- package/dist/index.js +9 -8
- package/dist/paint-editor/index.cjs +17 -16
- package/dist/paint-editor/index.js +6 -5
- package/dist/typography/accessibility.d.cts +44 -0
- package/dist/typography/accessibility.d.ts +44 -0
- package/dist/typography/catalog.d.cts +98 -0
- package/dist/typography/catalog.d.ts +98 -0
- package/dist/typography/index.cjs +1099 -0
- package/dist/typography/index.d.cts +16 -0
- package/dist/typography/index.d.ts +16 -0
- package/dist/typography/index.js +1099 -0
- package/dist/typography/metrics.d.cts +31 -0
- package/dist/typography/metrics.d.ts +31 -0
- package/dist/typography/picker.d.cts +132 -0
- package/dist/typography/picker.d.ts +132 -0
- package/dist/typography/registry.d.cts +66 -0
- package/dist/typography/registry.d.ts +66 -0
- package/dist/typography/scale.d.cts +62 -0
- package/dist/typography/scale.d.ts +62 -0
- package/dist/typography/segment.d.cts +26 -0
- package/dist/typography/segment.d.ts +26 -0
- package/dist/typography/stack.d.cts +26 -0
- package/dist/typography/stack.d.ts +26 -0
- package/dist/typography/tools.d.cts +34 -0
- package/dist/typography/tools.d.ts +34 -0
- package/dist/typography/types.d.cts +96 -0
- package/dist/typography/types.d.ts +96 -0
- package/dist/typography/weight.d.cts +13 -0
- package/dist/typography/weight.d.ts +13 -0
- package/dist/vector/index.cjs +950 -949
- package/dist/vector/index.js +5 -4
- package/dist/video-editor/audio.d.cts +9 -0
- package/dist/video-editor/audio.d.ts +9 -0
- package/dist/video-editor/check.d.cts +1 -1
- package/dist/video-editor/check.d.ts +1 -1
- package/dist/video-editor/controller.d.cts +47 -0
- package/dist/video-editor/controller.d.ts +47 -0
- package/dist/video-editor/dialogue-tools.d.cts +19 -0
- package/dist/video-editor/dialogue-tools.d.ts +19 -0
- package/dist/video-editor/effect-authoring.d.cts +54 -0
- package/dist/video-editor/effect-authoring.d.ts +54 -0
- package/dist/video-editor/evaluate.d.cts +11 -0
- package/dist/video-editor/evaluate.d.ts +11 -0
- package/dist/video-editor/export.d.cts +7 -1
- package/dist/video-editor/export.d.ts +7 -1
- package/dist/video-editor/index.cjs +1857 -531
- package/dist/video-editor/index.d.cts +7 -0
- package/dist/video-editor/index.d.ts +7 -0
- package/dist/video-editor/index.js +1516 -190
- package/dist/video-editor/lut.d.cts +12 -2
- package/dist/video-editor/lut.d.ts +12 -2
- package/dist/video-editor/mask.d.cts +48 -0
- package/dist/video-editor/mask.d.ts +48 -0
- package/dist/video-editor/mix.d.cts +107 -0
- package/dist/video-editor/mix.d.ts +107 -0
- package/dist/video-editor/music-tools.d.cts +19 -0
- package/dist/video-editor/music-tools.d.ts +19 -0
- package/dist/video-editor/parse.d.cts +3 -1
- package/dist/video-editor/parse.d.ts +3 -1
- package/dist/video-editor/plan.d.cts +75 -0
- package/dist/video-editor/plan.d.ts +75 -0
- package/dist/video-editor/render.d.cts +1 -1
- package/dist/video-editor/render.d.ts +1 -1
- package/dist/video-editor/timeline.d.cts +2 -0
- package/dist/video-editor/timeline.d.ts +2 -0
- package/dist/video-editor/tools.d.cts +90 -0
- package/dist/video-editor/tools.d.ts +90 -0
- package/dist/video-editor/transcript-controller.d.cts +106 -0
- package/dist/video-editor/transcript-controller.d.ts +106 -0
- package/dist/video-editor/transcript.d.cts +40 -0
- package/dist/video-editor/transcript.d.ts +40 -0
- package/dist/video-editor/types.d.cts +62 -2
- package/dist/video-editor/types.d.ts +62 -2
- package/dist/video-editor/ui.d.cts +21 -1
- package/dist/video-editor/ui.d.ts +21 -1
- package/package.json +11 -1
- package/skills/README.md +3 -0
- package/skills/pixerate-bgm-alignment/SKILL.md +82 -0
- package/skills/pixerate-talking-head-edit/SKILL.md +80 -0
- package/skills/pixerate-typography/SKILL.md +91 -0
- package/skills/pixerate-video-editor/SKILL.md +40 -2
package/dist/effects/index.cjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkFKUKJ3XAcjs = require('../chunk-FKUKJ3XA.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
var _chunk6DM3PUQDcjs = require('../chunk-6DM3PUQD.cjs');
|
|
6
7
|
|
|
7
8
|
|
|
9
|
+
var _chunkPY4GWSE2cjs = require('../chunk-PY4GWSE2.cjs');
|
|
8
10
|
|
|
9
11
|
|
|
10
12
|
|
|
@@ -23,13 +25,13 @@ var _chunkPY4GWSE2cjs = require('../chunk-PY4GWSE2.cjs');
|
|
|
23
25
|
|
|
24
26
|
|
|
25
27
|
|
|
26
|
-
var _chunkRUZQMYXHcjs = require('../chunk-RUZQMYXH.cjs');
|
|
27
|
-
require('../chunk-WOFXZ3XU.cjs');
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
var _chunkFJ2MSI43cjs = require('../chunk-FJ2MSI43.cjs');
|
|
31
30
|
|
|
32
31
|
|
|
32
|
+
var _chunkRUZQMYXHcjs = require('../chunk-RUZQMYXH.cjs');
|
|
33
|
+
require('../chunk-WOFXZ3XU.cjs');
|
|
34
|
+
require('../chunk-FJ2MSI43.cjs');
|
|
33
35
|
|
|
34
36
|
|
|
35
37
|
var _chunkDWJJI6RTcjs = require('../chunk-DWJJI6RT.cjs');
|
|
@@ -213,756 +215,6 @@ async function checkEffectProvider(provider, options = {}) {
|
|
|
213
215
|
return issues;
|
|
214
216
|
}
|
|
215
217
|
|
|
216
|
-
// src/effects/authoring-session.ts
|
|
217
|
-
var HEX_RE = /^#([0-9a-f]{6}|[0-9a-f]{8})$/i;
|
|
218
|
-
function valueErrorMessage(errors) {
|
|
219
|
-
return errors.map((e) => {
|
|
220
|
-
const [control, ...rest] = e.path.replace(/^\//, "").split("/");
|
|
221
|
-
return `control "${control}"${rest.length ? ` (item ${rest.join("/")})` : ""}: ${e.message}`;
|
|
222
|
-
}).join("; ");
|
|
223
|
-
}
|
|
224
|
-
function documentErrors(doc, description) {
|
|
225
|
-
const errors = [];
|
|
226
|
-
const controls = Object.keys(description.controls.properties);
|
|
227
|
-
const isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
228
|
-
if (doc.values !== void 0) {
|
|
229
|
-
if (!isRecord(doc.values)) errors.push({ path: "/values", message: "must be an object of control values" });
|
|
230
|
-
else errors.push(..._chunkRUZQMYXHcjs.effectValueErrors.call(void 0, description, doc.values).map((e) => ({ ...e, path: `/values${e.path}` })));
|
|
231
|
-
}
|
|
232
|
-
if (doc.tracks !== void 0) {
|
|
233
|
-
if (!isRecord(doc.tracks)) errors.push({ path: "/tracks", message: "must be an object of keyframe lists" });
|
|
234
|
-
else
|
|
235
|
-
for (const [control, kfs] of Object.entries(doc.tracks)) {
|
|
236
|
-
const at = `/tracks/${control}`;
|
|
237
|
-
if (!controls.includes(control)) errors.push({ path: at, message: `there is no control "${control}"; the controls are ${controls.join(", ")}` });
|
|
238
|
-
else if (!Array.isArray(kfs)) errors.push({ path: at, message: "must be a list of keyframes" });
|
|
239
|
-
else
|
|
240
|
-
kfs.forEach((kf, i) => {
|
|
241
|
-
if (!isRecord(kf)) return errors.push({ path: `${at}/${i}`, message: "must be a keyframe object" });
|
|
242
|
-
if (typeof kf.time !== "number" || !Number.isFinite(kf.time) || kf.time < 0) errors.push({ path: `${at}/${i}/time`, message: "must be a finite number of ms >= 0" });
|
|
243
|
-
errors.push(..._chunkRUZQMYXHcjs.effectValueErrors.call(void 0, description, { [control]: kf.value }).map((e) => ({ ...e, path: `${at}/${i}/value` })));
|
|
244
|
-
if (kf.easing !== void 0 && !_chunkDWJJI6RTcjs.isAnimationEasing.call(void 0, kf.easing)) errors.push({ path: `${at}/${i}/easing`, message: "is not a valid easing" });
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
if (doc.presets !== void 0) {
|
|
249
|
-
if (!Array.isArray(doc.presets)) errors.push({ path: "/presets", message: "must be a list of presets" });
|
|
250
|
-
else
|
|
251
|
-
doc.presets.forEach((p, i) => {
|
|
252
|
-
if (!isRecord(p) || typeof p.name !== "string" || !p.name) return errors.push({ path: `/presets/${i}`, message: "must have a name" });
|
|
253
|
-
errors.push(..._chunkRUZQMYXHcjs.effectValueErrors.call(void 0, description, p.values).map((e) => ({ ...e, path: `/presets/${i}/values${e.path}` })));
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
if (doc.duration !== void 0 && (typeof doc.duration !== "number" || !Number.isFinite(doc.duration) || !(doc.duration > 0))) {
|
|
257
|
-
errors.push({ path: "/duration", message: "must be a finite number of ms > 0" });
|
|
258
|
-
}
|
|
259
|
-
if (doc.loop !== void 0 && typeof doc.loop !== "boolean") errors.push({ path: "/loop", message: "must be a boolean" });
|
|
260
|
-
return errors;
|
|
261
|
-
}
|
|
262
|
-
function parseHex(hex) {
|
|
263
|
-
if (!HEX_RE.test(hex)) return null;
|
|
264
|
-
const body = hex.slice(1);
|
|
265
|
-
const r = parseInt(body.slice(0, 2), 16);
|
|
266
|
-
const g = parseInt(body.slice(2, 4), 16);
|
|
267
|
-
const b = parseInt(body.slice(4, 6), 16);
|
|
268
|
-
const hasAlpha = body.length === 8;
|
|
269
|
-
const a = hasAlpha ? parseInt(body.slice(6, 8), 16) : 255;
|
|
270
|
-
return { r, g, b, a, hasAlpha };
|
|
271
|
-
}
|
|
272
|
-
function toHex2(n) {
|
|
273
|
-
const clamped = Math.round(Math.max(0, Math.min(255, n)));
|
|
274
|
-
return clamped.toString(16).padStart(2, "0");
|
|
275
|
-
}
|
|
276
|
-
function lerpHex(c1, c2, t) {
|
|
277
|
-
const p1 = parseHex(c1);
|
|
278
|
-
const p2 = parseHex(c2);
|
|
279
|
-
if (!p1 || !p2) return t >= 1 ? c2 : c1;
|
|
280
|
-
const r = p1.r + (p2.r - p1.r) * t;
|
|
281
|
-
const g = p1.g + (p2.g - p1.g) * t;
|
|
282
|
-
const b = p1.b + (p2.b - p1.b) * t;
|
|
283
|
-
const a = p1.a + (p2.a - p1.a) * t;
|
|
284
|
-
const withAlpha = p1.hasAlpha || p2.hasAlpha;
|
|
285
|
-
return `#${toHex2(r)}${toHex2(g)}${toHex2(b)}${withAlpha ? toHex2(a) : ""}`;
|
|
286
|
-
}
|
|
287
|
-
function interpolateValue(v1, v2, progress) {
|
|
288
|
-
if (typeof v1 === "number" && typeof v2 === "number") {
|
|
289
|
-
return v1 + (v2 - v1) * progress;
|
|
290
|
-
}
|
|
291
|
-
if (Array.isArray(v1) && Array.isArray(v2) && v1.length === v2.length) {
|
|
292
|
-
return v1.map((num, i) => {
|
|
293
|
-
const other = v2[i];
|
|
294
|
-
return typeof num === "number" && typeof other === "number" ? num + (other - num) * progress : num;
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
if (typeof v1 === "string" && typeof v2 === "string" && v1.startsWith("#") && v2.startsWith("#")) {
|
|
298
|
-
return lerpHex(v1, v2, progress);
|
|
299
|
-
}
|
|
300
|
-
return progress >= 1 ? v2 : v1;
|
|
301
|
-
}
|
|
302
|
-
function valuesAtTime(time, baseValues, tracks) {
|
|
303
|
-
const result = { ...baseValues };
|
|
304
|
-
for (const [control, kfs] of Object.entries(tracks)) {
|
|
305
|
-
if (!kfs || kfs.length === 0) continue;
|
|
306
|
-
if (kfs.length === 1) {
|
|
307
|
-
result[control] = kfs[0].value;
|
|
308
|
-
continue;
|
|
309
|
-
}
|
|
310
|
-
if (time <= kfs[0].time) {
|
|
311
|
-
result[control] = kfs[0].value;
|
|
312
|
-
continue;
|
|
313
|
-
}
|
|
314
|
-
const last = kfs[kfs.length - 1];
|
|
315
|
-
if (time >= last.time) {
|
|
316
|
-
result[control] = last.value;
|
|
317
|
-
continue;
|
|
318
|
-
}
|
|
319
|
-
let idx = 0;
|
|
320
|
-
while (idx < kfs.length - 1 && kfs[idx + 1].time <= time) {
|
|
321
|
-
idx++;
|
|
322
|
-
}
|
|
323
|
-
const kf1 = kfs[idx];
|
|
324
|
-
const kf2 = kfs[idx + 1];
|
|
325
|
-
const span = kf2.time - kf1.time;
|
|
326
|
-
const rawProgress = span > 0 ? (time - kf1.time) / span : 0;
|
|
327
|
-
const easing = _nullishCoalesce(kf1.easing, () => ( "linear"));
|
|
328
|
-
const eased = _chunkDWJJI6RTcjs.evaluateEasing.call(void 0, easing, rawProgress);
|
|
329
|
-
result[control] = interpolateValue(kf1.value, kf2.value, eased);
|
|
330
|
-
}
|
|
331
|
-
return result;
|
|
332
|
-
}
|
|
333
|
-
var defaultSchedule = (frame) => {
|
|
334
|
-
if (typeof requestAnimationFrame === "function") {
|
|
335
|
-
let handle2;
|
|
336
|
-
let running2 = true;
|
|
337
|
-
const tick2 = (now) => {
|
|
338
|
-
if (!running2) return;
|
|
339
|
-
frame(now);
|
|
340
|
-
if (running2) handle2 = requestAnimationFrame(tick2);
|
|
341
|
-
};
|
|
342
|
-
handle2 = requestAnimationFrame(tick2);
|
|
343
|
-
return () => {
|
|
344
|
-
running2 = false;
|
|
345
|
-
cancelAnimationFrame(handle2);
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
let handle;
|
|
349
|
-
let running = true;
|
|
350
|
-
const interval = 16;
|
|
351
|
-
const tick = () => {
|
|
352
|
-
if (!running) return;
|
|
353
|
-
frame(Date.now());
|
|
354
|
-
if (running) handle = setTimeout(tick, interval);
|
|
355
|
-
};
|
|
356
|
-
handle = setTimeout(tick, interval);
|
|
357
|
-
return () => {
|
|
358
|
-
running = false;
|
|
359
|
-
clearTimeout(handle);
|
|
360
|
-
};
|
|
361
|
-
};
|
|
362
|
-
function isDocumentSource(source) {
|
|
363
|
-
return "document" in source && typeof source.document === "object" && source.document !== null;
|
|
364
|
-
}
|
|
365
|
-
async function createEffectAuthoringSession(source, options) {
|
|
366
|
-
const { provider, history = new (0, _chunkFJ2MSI43cjs.HistoryManager)(), mergeWindowMs = 400 } = options;
|
|
367
|
-
const scheduleFn = _nullishCoalesce(options.schedule, () => ( defaultSchedule));
|
|
368
|
-
let effectId;
|
|
369
|
-
let requestedPreset;
|
|
370
|
-
let initialDoc = null;
|
|
371
|
-
if (isDocumentSource(source)) {
|
|
372
|
-
const doc = source.document;
|
|
373
|
-
if (doc.version !== 1 || !doc.effectId) {
|
|
374
|
-
throw new (0, _chunkRUZQMYXHcjs.EffectUnsupportedError)("Invalid effect authoring document: version 1 required");
|
|
375
|
-
}
|
|
376
|
-
effectId = doc.effectId;
|
|
377
|
-
initialDoc = doc;
|
|
378
|
-
} else if ("effectId" in source && typeof source.effectId === "string") {
|
|
379
|
-
effectId = source.effectId;
|
|
380
|
-
requestedPreset = source.preset;
|
|
381
|
-
} else {
|
|
382
|
-
throw new (0, _chunkRUZQMYXHcjs.EffectUnsupportedError)("Invalid effect authoring source");
|
|
383
|
-
}
|
|
384
|
-
const description = await provider.describe(effectId);
|
|
385
|
-
if (initialDoc) {
|
|
386
|
-
const problems = documentErrors(initialDoc, description);
|
|
387
|
-
if (problems.length) throw new (0, _chunkRUZQMYXHcjs.EffectControlError)(effectId, problems);
|
|
388
|
-
}
|
|
389
|
-
if (description.kind === "motion") {
|
|
390
|
-
throw new (0, _chunkRUZQMYXHcjs.EffectUnsupportedError)("Motion effects cannot be authored as pixel effects", effectId);
|
|
391
|
-
}
|
|
392
|
-
let disposed = false;
|
|
393
|
-
let playing = false;
|
|
394
|
-
let cancelSchedule = null;
|
|
395
|
-
let lastScheduleTime = null;
|
|
396
|
-
let playheadTime = 0;
|
|
397
|
-
let duration = _nullishCoalesce(_nullishCoalesce(_optionalChain([initialDoc, 'optionalAccess', _12 => _12.duration]), () => ( description.duration)), () => ( 1e3));
|
|
398
|
-
if (!(duration > 0)) duration = 1e3;
|
|
399
|
-
let loop = _nullishCoalesce(_nullishCoalesce(_optionalChain([initialDoc, 'optionalAccess', _13 => _13.loop]), () => ( description.loop)), () => ( false));
|
|
400
|
-
let compiled = null;
|
|
401
|
-
let savedPresets = initialDoc ? [..._nullishCoalesce(initialDoc.presets, () => ( []))] : [];
|
|
402
|
-
let baseValues = { ...description.defaults };
|
|
403
|
-
if (_optionalChain([initialDoc, 'optionalAccess', _14 => _14.values])) {
|
|
404
|
-
baseValues = { ...baseValues, ...initialDoc.values };
|
|
405
|
-
} else if (requestedPreset) {
|
|
406
|
-
const found = description.presets.find((p) => p.name === requestedPreset);
|
|
407
|
-
if (!found) {
|
|
408
|
-
const validNames = description.presets.map((p) => `"${p.name}"`).join(", ");
|
|
409
|
-
throw new (0, _chunkRUZQMYXHcjs.EffectUnsupportedError)(
|
|
410
|
-
`Unknown preset "${requestedPreset}" for effect "${effectId}". Valid presets are: ${validNames || "none"}`,
|
|
411
|
-
effectId
|
|
412
|
-
);
|
|
413
|
-
}
|
|
414
|
-
baseValues = { ...baseValues, ...found.values };
|
|
415
|
-
}
|
|
416
|
-
let tracks = {};
|
|
417
|
-
if (_optionalChain([initialDoc, 'optionalAccess', _15 => _15.tracks])) {
|
|
418
|
-
for (const [k, kfs] of Object.entries(initialDoc.tracks)) {
|
|
419
|
-
tracks[k] = [...kfs].sort((a, b) => a.time - b.time);
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
const livePreviews = /* @__PURE__ */ new Set();
|
|
423
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
424
|
-
let cachedState = null;
|
|
425
|
-
function mergePresets() {
|
|
426
|
-
const result = [];
|
|
427
|
-
const seen = /* @__PURE__ */ new Set();
|
|
428
|
-
for (const p of savedPresets) {
|
|
429
|
-
result.push(p);
|
|
430
|
-
seen.add(p.name);
|
|
431
|
-
}
|
|
432
|
-
for (const p of description.presets) {
|
|
433
|
-
if (!seen.has(p.name)) {
|
|
434
|
-
result.push(p);
|
|
435
|
-
seen.add(p.name);
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
return result;
|
|
439
|
-
}
|
|
440
|
-
function currentMergedDescription() {
|
|
441
|
-
return {
|
|
442
|
-
...description,
|
|
443
|
-
presets: mergePresets()
|
|
444
|
-
};
|
|
445
|
-
}
|
|
446
|
-
function buildState() {
|
|
447
|
-
const desc = currentMergedDescription();
|
|
448
|
-
const currentValues = valuesAtTime(playheadTime, baseValues, tracks);
|
|
449
|
-
const historyState = history.getState();
|
|
450
|
-
return {
|
|
451
|
-
providerId: provider.id,
|
|
452
|
-
effectId,
|
|
453
|
-
name: _nullishCoalesce(_optionalChain([initialDoc, 'optionalAccess', _16 => _16.name]), () => ( description.name)),
|
|
454
|
-
kind: description.kind,
|
|
455
|
-
description: desc,
|
|
456
|
-
source: null,
|
|
457
|
-
sourceLanguage: null,
|
|
458
|
-
values: currentValues,
|
|
459
|
-
tracks: { ...tracks },
|
|
460
|
-
issues: [],
|
|
461
|
-
compiled,
|
|
462
|
-
time: playheadTime,
|
|
463
|
-
duration,
|
|
464
|
-
loop,
|
|
465
|
-
playing,
|
|
466
|
-
canUndo: historyState.canUndo,
|
|
467
|
-
canRedo: historyState.canRedo
|
|
468
|
-
};
|
|
469
|
-
}
|
|
470
|
-
function getState() {
|
|
471
|
-
if (!cachedState) {
|
|
472
|
-
cachedState = buildState();
|
|
473
|
-
}
|
|
474
|
-
return cachedState;
|
|
475
|
-
}
|
|
476
|
-
function invalidateState() {
|
|
477
|
-
cachedState = null;
|
|
478
|
-
const next = getState();
|
|
479
|
-
listeners.forEach((l) => l(next));
|
|
480
|
-
}
|
|
481
|
-
function validControlNames() {
|
|
482
|
-
return Object.keys(description.controls.properties);
|
|
483
|
-
}
|
|
484
|
-
function checkDisposed() {
|
|
485
|
-
if (disposed) {
|
|
486
|
-
return { ok: false, message: "the session is closed" };
|
|
487
|
-
}
|
|
488
|
-
return null;
|
|
489
|
-
}
|
|
490
|
-
function pauseInternal() {
|
|
491
|
-
if (!playing) return;
|
|
492
|
-
playing = false;
|
|
493
|
-
if (cancelSchedule) {
|
|
494
|
-
cancelSchedule();
|
|
495
|
-
cancelSchedule = null;
|
|
496
|
-
}
|
|
497
|
-
lastScheduleTime = null;
|
|
498
|
-
invalidateState();
|
|
499
|
-
}
|
|
500
|
-
function seekInternal(t) {
|
|
501
|
-
const clamped = Math.max(0, Math.min(duration, t));
|
|
502
|
-
if (clamped !== playheadTime) {
|
|
503
|
-
playheadTime = clamped;
|
|
504
|
-
invalidateState();
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
const session = {
|
|
508
|
-
getState,
|
|
509
|
-
subscribe(listener) {
|
|
510
|
-
listeners.add(listener);
|
|
511
|
-
return () => {
|
|
512
|
-
listeners.delete(listener);
|
|
513
|
-
};
|
|
514
|
-
},
|
|
515
|
-
setValue(name, value, opts) {
|
|
516
|
-
const disp = checkDisposed();
|
|
517
|
-
if (disp) return disp;
|
|
518
|
-
const validNames = validControlNames();
|
|
519
|
-
if (!validNames.includes(name)) {
|
|
520
|
-
return { ok: false, message: `there is no control "${name}"; the controls are ${validNames.join(", ")}` };
|
|
521
|
-
}
|
|
522
|
-
const errors = _chunkRUZQMYXHcjs.effectValueErrors.call(void 0, description, { [name]: value });
|
|
523
|
-
if (errors.length > 0) {
|
|
524
|
-
return { ok: false, message: valueErrorMessage(errors) };
|
|
525
|
-
}
|
|
526
|
-
const isAnimated = (_nullishCoalesce(_optionalChain([tracks, 'access', _17 => _17[name], 'optionalAccess', _18 => _18.length]), () => ( 0))) > 0;
|
|
527
|
-
if (isAnimated) {
|
|
528
|
-
const oldTracks = { ...tracks };
|
|
529
|
-
const t = playheadTime;
|
|
530
|
-
const currentTrack = [..._nullishCoalesce(tracks[name], () => ( []))];
|
|
531
|
-
const existingIdx = currentTrack.findIndex((kf) => kf.time === t);
|
|
532
|
-
const prevKf = existingIdx >= 0 ? currentTrack[existingIdx] : void 0;
|
|
533
|
-
const execute2 = () => {
|
|
534
|
-
const track = [..._nullishCoalesce(tracks[name], () => ( []))];
|
|
535
|
-
const idx = track.findIndex((kf) => kf.time === t);
|
|
536
|
-
if (idx >= 0) {
|
|
537
|
-
track[idx] = { ...track[idx], value };
|
|
538
|
-
} else {
|
|
539
|
-
track.push({ time: t, value });
|
|
540
|
-
track.sort((a, b) => a.time - b.time);
|
|
541
|
-
}
|
|
542
|
-
tracks[name] = track;
|
|
543
|
-
invalidateState();
|
|
544
|
-
};
|
|
545
|
-
const undo2 = () => {
|
|
546
|
-
tracks = { ...oldTracks };
|
|
547
|
-
invalidateState();
|
|
548
|
-
};
|
|
549
|
-
const cmd2 = {
|
|
550
|
-
name: `Set ${name}`,
|
|
551
|
-
tag: name,
|
|
552
|
-
execute: execute2,
|
|
553
|
-
undo: undo2
|
|
554
|
-
};
|
|
555
|
-
if (_optionalChain([opts, 'optionalAccess', _19 => _19.gesture])) {
|
|
556
|
-
history.executeMerged(cmd2, { key: opts.gesture });
|
|
557
|
-
} else {
|
|
558
|
-
history.executeMerged(cmd2, { windowMs: mergeWindowMs });
|
|
559
|
-
}
|
|
560
|
-
invalidateState();
|
|
561
|
-
return { ok: true };
|
|
562
|
-
}
|
|
563
|
-
const prevVal = baseValues[name];
|
|
564
|
-
const execute = () => {
|
|
565
|
-
baseValues[name] = value;
|
|
566
|
-
};
|
|
567
|
-
const undo = () => {
|
|
568
|
-
baseValues[name] = prevVal;
|
|
569
|
-
};
|
|
570
|
-
const cmd = {
|
|
571
|
-
name: `Set ${name}`,
|
|
572
|
-
tag: name,
|
|
573
|
-
execute,
|
|
574
|
-
undo
|
|
575
|
-
};
|
|
576
|
-
if (_optionalChain([opts, 'optionalAccess', _20 => _20.gesture])) {
|
|
577
|
-
history.executeMerged(cmd, { key: opts.gesture });
|
|
578
|
-
} else {
|
|
579
|
-
history.executeMerged(cmd, { windowMs: mergeWindowMs });
|
|
580
|
-
}
|
|
581
|
-
invalidateState();
|
|
582
|
-
return { ok: true };
|
|
583
|
-
},
|
|
584
|
-
setValues(values, opts) {
|
|
585
|
-
const disp = checkDisposed();
|
|
586
|
-
if (disp) return disp;
|
|
587
|
-
const validNames = validControlNames();
|
|
588
|
-
for (const [k, v] of Object.entries(values)) {
|
|
589
|
-
if (!validNames.includes(k)) {
|
|
590
|
-
return { ok: false, message: `there is no control "${k}"; the controls are ${validNames.join(", ")}` };
|
|
591
|
-
}
|
|
592
|
-
const errors = _chunkRUZQMYXHcjs.effectValueErrors.call(void 0, description, { [k]: v });
|
|
593
|
-
if (errors.length > 0) {
|
|
594
|
-
return { ok: false, message: valueErrorMessage(errors) };
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
const prevBase = { ...baseValues };
|
|
598
|
-
const prevTracks = { ...tracks };
|
|
599
|
-
const t = playheadTime;
|
|
600
|
-
const execute = () => {
|
|
601
|
-
for (const [k, v] of Object.entries(values)) {
|
|
602
|
-
const isAnimated = (_nullishCoalesce(_optionalChain([tracks, 'access', _21 => _21[k], 'optionalAccess', _22 => _22.length]), () => ( 0))) > 0;
|
|
603
|
-
if (isAnimated) {
|
|
604
|
-
const track = [..._nullishCoalesce(tracks[k], () => ( []))];
|
|
605
|
-
const idx = track.findIndex((kf) => kf.time === t);
|
|
606
|
-
if (idx >= 0) {
|
|
607
|
-
track[idx] = { ...track[idx], value: v };
|
|
608
|
-
} else {
|
|
609
|
-
track.push({ time: t, value: v });
|
|
610
|
-
track.sort((a, b) => a.time - b.time);
|
|
611
|
-
}
|
|
612
|
-
tracks[k] = track;
|
|
613
|
-
} else {
|
|
614
|
-
baseValues[k] = v;
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
};
|
|
618
|
-
const undo = () => {
|
|
619
|
-
baseValues = { ...prevBase };
|
|
620
|
-
tracks = { ...prevTracks };
|
|
621
|
-
};
|
|
622
|
-
const cmd = {
|
|
623
|
-
name: "Set values",
|
|
624
|
-
execute,
|
|
625
|
-
undo
|
|
626
|
-
};
|
|
627
|
-
if (_optionalChain([opts, 'optionalAccess', _23 => _23.gesture])) {
|
|
628
|
-
history.executeMerged(cmd, { key: opts.gesture });
|
|
629
|
-
} else {
|
|
630
|
-
history.execute(cmd);
|
|
631
|
-
}
|
|
632
|
-
invalidateState();
|
|
633
|
-
return { ok: true };
|
|
634
|
-
},
|
|
635
|
-
resetValues(names) {
|
|
636
|
-
const disp = checkDisposed();
|
|
637
|
-
if (disp) return disp;
|
|
638
|
-
const targets = names ? [...names] : validControlNames();
|
|
639
|
-
const prevBase = { ...baseValues };
|
|
640
|
-
const prevTracks = { ...tracks };
|
|
641
|
-
const execute = () => {
|
|
642
|
-
for (const name of targets) {
|
|
643
|
-
if (name in description.defaults) {
|
|
644
|
-
baseValues[name] = description.defaults[name];
|
|
645
|
-
}
|
|
646
|
-
delete tracks[name];
|
|
647
|
-
}
|
|
648
|
-
};
|
|
649
|
-
const undo = () => {
|
|
650
|
-
baseValues = { ...prevBase };
|
|
651
|
-
tracks = { ...prevTracks };
|
|
652
|
-
};
|
|
653
|
-
history.execute({
|
|
654
|
-
name: "Reset values",
|
|
655
|
-
execute,
|
|
656
|
-
undo
|
|
657
|
-
});
|
|
658
|
-
invalidateState();
|
|
659
|
-
return { ok: true };
|
|
660
|
-
},
|
|
661
|
-
applyPreset(name) {
|
|
662
|
-
const disp = checkDisposed();
|
|
663
|
-
if (disp) return disp;
|
|
664
|
-
const allPresets = mergePresets();
|
|
665
|
-
const preset = allPresets.find((p) => p.name === name);
|
|
666
|
-
if (!preset) {
|
|
667
|
-
const available = allPresets.map((p) => `"${p.name}"`).join(", ");
|
|
668
|
-
return { ok: false, message: `unknown preset "${name}"; available presets are: ${available || "none"}` };
|
|
669
|
-
}
|
|
670
|
-
const prevBase = { ...baseValues };
|
|
671
|
-
const prevTracks = { ...tracks };
|
|
672
|
-
const execute = () => {
|
|
673
|
-
for (const [k, v] of Object.entries(preset.values)) {
|
|
674
|
-
baseValues[k] = v;
|
|
675
|
-
delete tracks[k];
|
|
676
|
-
}
|
|
677
|
-
};
|
|
678
|
-
const undo = () => {
|
|
679
|
-
baseValues = { ...prevBase };
|
|
680
|
-
tracks = { ...prevTracks };
|
|
681
|
-
};
|
|
682
|
-
history.execute({
|
|
683
|
-
name: `Apply preset "${name}"`,
|
|
684
|
-
execute,
|
|
685
|
-
undo
|
|
686
|
-
});
|
|
687
|
-
invalidateState();
|
|
688
|
-
return { ok: true };
|
|
689
|
-
},
|
|
690
|
-
savePreset(name) {
|
|
691
|
-
const disp = checkDisposed();
|
|
692
|
-
if (disp) return disp;
|
|
693
|
-
if (!name || !name.trim()) {
|
|
694
|
-
return { ok: false, message: "preset name cannot be empty" };
|
|
695
|
-
}
|
|
696
|
-
const trimmed = name.trim();
|
|
697
|
-
const currentValues = valuesAtTime(playheadTime, baseValues, tracks);
|
|
698
|
-
const prevSaved = [...savedPresets];
|
|
699
|
-
const execute = () => {
|
|
700
|
-
const next = savedPresets.filter((p) => p.name !== trimmed);
|
|
701
|
-
next.push({ name: trimmed, values: { ...currentValues } });
|
|
702
|
-
savedPresets = next;
|
|
703
|
-
};
|
|
704
|
-
const undo = () => {
|
|
705
|
-
savedPresets = [...prevSaved];
|
|
706
|
-
};
|
|
707
|
-
history.execute({
|
|
708
|
-
name: `Save preset "${trimmed}"`,
|
|
709
|
-
execute,
|
|
710
|
-
undo
|
|
711
|
-
});
|
|
712
|
-
invalidateState();
|
|
713
|
-
return { ok: true };
|
|
714
|
-
},
|
|
715
|
-
setKeyframe(name, time, value, easing) {
|
|
716
|
-
const disp = checkDisposed();
|
|
717
|
-
if (disp) return disp;
|
|
718
|
-
const validNames = validControlNames();
|
|
719
|
-
if (!validNames.includes(name)) {
|
|
720
|
-
return { ok: false, message: `there is no control "${name}"; the controls are ${validNames.join(", ")}` };
|
|
721
|
-
}
|
|
722
|
-
if (typeof time !== "number" || !Number.isFinite(time) || time < 0) {
|
|
723
|
-
return { ok: false, message: "keyframe time must be a finite number >= 0" };
|
|
724
|
-
}
|
|
725
|
-
if (easing !== void 0 && !_chunkDWJJI6RTcjs.isAnimationEasing.call(void 0, easing)) {
|
|
726
|
-
return { ok: false, message: `invalid easing: ${String(easing)}` };
|
|
727
|
-
}
|
|
728
|
-
const targetValue = value !== void 0 ? value : valuesAtTime(time, baseValues, tracks)[name];
|
|
729
|
-
const errors = _chunkRUZQMYXHcjs.effectValueErrors.call(void 0, description, { [name]: targetValue });
|
|
730
|
-
if (errors.length > 0) {
|
|
731
|
-
return { ok: false, message: valueErrorMessage(errors) };
|
|
732
|
-
}
|
|
733
|
-
const prevTrack = tracks[name] ? [...tracks[name]] : void 0;
|
|
734
|
-
const execute = () => {
|
|
735
|
-
const track = prevTrack ? [...prevTrack] : [];
|
|
736
|
-
const idx = track.findIndex((kf2) => kf2.time === time);
|
|
737
|
-
const kf = {
|
|
738
|
-
time,
|
|
739
|
-
value: targetValue,
|
|
740
|
-
...easing !== void 0 ? { easing } : {}
|
|
741
|
-
};
|
|
742
|
-
if (idx >= 0) {
|
|
743
|
-
track[idx] = kf;
|
|
744
|
-
} else {
|
|
745
|
-
track.push(kf);
|
|
746
|
-
track.sort((a, b) => a.time - b.time);
|
|
747
|
-
}
|
|
748
|
-
tracks[name] = track;
|
|
749
|
-
};
|
|
750
|
-
const undo = () => {
|
|
751
|
-
if (prevTrack === void 0) {
|
|
752
|
-
delete tracks[name];
|
|
753
|
-
} else {
|
|
754
|
-
tracks[name] = [...prevTrack];
|
|
755
|
-
}
|
|
756
|
-
};
|
|
757
|
-
history.execute({
|
|
758
|
-
name: `Set keyframe on ${name}`,
|
|
759
|
-
execute,
|
|
760
|
-
undo
|
|
761
|
-
});
|
|
762
|
-
invalidateState();
|
|
763
|
-
return { ok: true };
|
|
764
|
-
},
|
|
765
|
-
removeKeyframe(name, time) {
|
|
766
|
-
const disp = checkDisposed();
|
|
767
|
-
if (disp) return disp;
|
|
768
|
-
const validNames = validControlNames();
|
|
769
|
-
if (!validNames.includes(name)) {
|
|
770
|
-
return { ok: false, message: `there is no control "${name}"; the controls are ${validNames.join(", ")}` };
|
|
771
|
-
}
|
|
772
|
-
const track = tracks[name];
|
|
773
|
-
if (!track || !track.some((kf) => kf.time === time)) {
|
|
774
|
-
const times = _optionalChain([track, 'optionalAccess', _24 => _24.map, 'call', _25 => _25((kf) => `${kf.time}`), 'access', _26 => _26.join, 'call', _27 => _27(", ")]);
|
|
775
|
-
return {
|
|
776
|
-
ok: false,
|
|
777
|
-
message: times ? `no keyframe at ${time} ms on control "${name}"; its keyframes are at ${times} ms` : `control "${name}" has no keyframes`
|
|
778
|
-
};
|
|
779
|
-
}
|
|
780
|
-
const prevTrack = [...track];
|
|
781
|
-
const execute = () => {
|
|
782
|
-
const next = tracks[name].filter((kf) => kf.time !== time);
|
|
783
|
-
if (next.length === 0) {
|
|
784
|
-
delete tracks[name];
|
|
785
|
-
} else {
|
|
786
|
-
tracks[name] = next;
|
|
787
|
-
}
|
|
788
|
-
};
|
|
789
|
-
const undo = () => {
|
|
790
|
-
tracks[name] = [...prevTrack];
|
|
791
|
-
};
|
|
792
|
-
history.execute({
|
|
793
|
-
name: `Remove keyframe on ${name}`,
|
|
794
|
-
execute,
|
|
795
|
-
undo
|
|
796
|
-
});
|
|
797
|
-
invalidateState();
|
|
798
|
-
return { ok: true };
|
|
799
|
-
},
|
|
800
|
-
clearTrack(name) {
|
|
801
|
-
const disp = checkDisposed();
|
|
802
|
-
if (disp) return disp;
|
|
803
|
-
const validNames = validControlNames();
|
|
804
|
-
if (!validNames.includes(name)) {
|
|
805
|
-
return { ok: false, message: `there is no control "${name}"; the controls are ${validNames.join(", ")}` };
|
|
806
|
-
}
|
|
807
|
-
const prevTrack = tracks[name] ? [...tracks[name]] : void 0;
|
|
808
|
-
if (!prevTrack || prevTrack.length === 0) {
|
|
809
|
-
const animated = Object.keys(tracks).filter((k) => _optionalChain([tracks, 'access', _28 => _28[k], 'optionalAccess', _29 => _29.length]));
|
|
810
|
-
return {
|
|
811
|
-
ok: false,
|
|
812
|
-
message: `control "${name}" is not animated, so there is nothing to clear; ${animated.length ? `the animated controls are ${animated.join(", ")}` : "no control is animated"}`
|
|
813
|
-
};
|
|
814
|
-
}
|
|
815
|
-
const currentValue = valuesAtTime(playheadTime, baseValues, tracks)[name];
|
|
816
|
-
const prevBase = baseValues[name];
|
|
817
|
-
const execute = () => {
|
|
818
|
-
delete tracks[name];
|
|
819
|
-
baseValues[name] = currentValue;
|
|
820
|
-
};
|
|
821
|
-
const undo = () => {
|
|
822
|
-
tracks[name] = [...prevTrack];
|
|
823
|
-
baseValues[name] = prevBase;
|
|
824
|
-
};
|
|
825
|
-
history.execute({
|
|
826
|
-
name: `Clear animation on ${name}`,
|
|
827
|
-
execute,
|
|
828
|
-
undo
|
|
829
|
-
});
|
|
830
|
-
invalidateState();
|
|
831
|
-
return { ok: true };
|
|
832
|
-
},
|
|
833
|
-
setTiming(timing) {
|
|
834
|
-
const disp = checkDisposed();
|
|
835
|
-
if (disp) return disp;
|
|
836
|
-
if (timing.duration !== void 0 && (!(timing.duration > 0) || !Number.isFinite(timing.duration))) {
|
|
837
|
-
return { ok: false, message: "duration must be a finite number > 0" };
|
|
838
|
-
}
|
|
839
|
-
const prevDuration = duration;
|
|
840
|
-
const prevLoop = loop;
|
|
841
|
-
const prevTime = playheadTime;
|
|
842
|
-
const execute = () => {
|
|
843
|
-
if (timing.duration !== void 0) {
|
|
844
|
-
duration = timing.duration;
|
|
845
|
-
if (playheadTime > duration) playheadTime = duration;
|
|
846
|
-
}
|
|
847
|
-
if (timing.loop !== void 0) {
|
|
848
|
-
loop = timing.loop;
|
|
849
|
-
}
|
|
850
|
-
};
|
|
851
|
-
const undo = () => {
|
|
852
|
-
duration = prevDuration;
|
|
853
|
-
loop = prevLoop;
|
|
854
|
-
playheadTime = prevTime;
|
|
855
|
-
};
|
|
856
|
-
history.execute({
|
|
857
|
-
name: "Set timing",
|
|
858
|
-
execute,
|
|
859
|
-
undo
|
|
860
|
-
});
|
|
861
|
-
invalidateState();
|
|
862
|
-
return { ok: true };
|
|
863
|
-
},
|
|
864
|
-
play() {
|
|
865
|
-
if (disposed || playing) return;
|
|
866
|
-
playing = true;
|
|
867
|
-
lastScheduleTime = null;
|
|
868
|
-
cancelSchedule = scheduleFn((now) => {
|
|
869
|
-
if (!playing) return;
|
|
870
|
-
const delta = lastScheduleTime === null ? 0 : Math.max(0, now - lastScheduleTime);
|
|
871
|
-
lastScheduleTime = now;
|
|
872
|
-
let nextTime = playheadTime + delta;
|
|
873
|
-
if (nextTime >= duration) {
|
|
874
|
-
if (loop) {
|
|
875
|
-
nextTime = duration > 0 ? nextTime % duration : 0;
|
|
876
|
-
} else {
|
|
877
|
-
nextTime = duration;
|
|
878
|
-
pauseInternal();
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
seekInternal(nextTime);
|
|
882
|
-
});
|
|
883
|
-
invalidateState();
|
|
884
|
-
},
|
|
885
|
-
pause() {
|
|
886
|
-
pauseInternal();
|
|
887
|
-
},
|
|
888
|
-
seek(time) {
|
|
889
|
-
if (disposed) return;
|
|
890
|
-
seekInternal(time);
|
|
891
|
-
},
|
|
892
|
-
undo() {
|
|
893
|
-
if (disposed) return false;
|
|
894
|
-
const changed = history.undo();
|
|
895
|
-
if (changed) invalidateState();
|
|
896
|
-
return changed;
|
|
897
|
-
},
|
|
898
|
-
redo() {
|
|
899
|
-
if (disposed) return false;
|
|
900
|
-
const changed = history.redo();
|
|
901
|
-
if (changed) invalidateState();
|
|
902
|
-
return changed;
|
|
903
|
-
},
|
|
904
|
-
async createPreview(opts) {
|
|
905
|
-
if (disposed) {
|
|
906
|
-
throw new (0, _chunkRUZQMYXHcjs.EffectDisposedError)(effectId);
|
|
907
|
-
}
|
|
908
|
-
const renderer = await provider.createRenderer(effectId, opts);
|
|
909
|
-
livePreviews.add(renderer);
|
|
910
|
-
const preview = {
|
|
911
|
-
effectId: renderer.effectId,
|
|
912
|
-
width: renderer.width,
|
|
913
|
-
height: renderer.height,
|
|
914
|
-
depth: renderer.depth,
|
|
915
|
-
render: async (req) => {
|
|
916
|
-
if (disposed) throw new (0, _chunkRUZQMYXHcjs.EffectDisposedError)(effectId);
|
|
917
|
-
const effectiveValues = _nullishCoalesce(req.values, () => ( valuesAtTime(req.time, baseValues, tracks)));
|
|
918
|
-
const pixels = await renderer.render({
|
|
919
|
-
...req,
|
|
920
|
-
values: effectiveValues
|
|
921
|
-
});
|
|
922
|
-
if (compiled !== true) {
|
|
923
|
-
compiled = true;
|
|
924
|
-
invalidateState();
|
|
925
|
-
}
|
|
926
|
-
return pixels;
|
|
927
|
-
},
|
|
928
|
-
dispose: () => {
|
|
929
|
-
livePreviews.delete(renderer);
|
|
930
|
-
renderer.dispose();
|
|
931
|
-
}
|
|
932
|
-
};
|
|
933
|
-
return preview;
|
|
934
|
-
},
|
|
935
|
-
exportDocument() {
|
|
936
|
-
const currentValues = valuesAtTime(playheadTime, baseValues, tracks);
|
|
937
|
-
return {
|
|
938
|
-
version: 1,
|
|
939
|
-
providerId: provider.id,
|
|
940
|
-
effectId,
|
|
941
|
-
name: _nullishCoalesce(_optionalChain([initialDoc, 'optionalAccess', _30 => _30.name]), () => ( description.name)),
|
|
942
|
-
values: { ...currentValues },
|
|
943
|
-
tracks: JSON.parse(JSON.stringify(tracks)),
|
|
944
|
-
presets: JSON.parse(JSON.stringify(savedPresets)),
|
|
945
|
-
duration,
|
|
946
|
-
loop
|
|
947
|
-
};
|
|
948
|
-
},
|
|
949
|
-
dispose() {
|
|
950
|
-
if (disposed) return;
|
|
951
|
-
disposed = true;
|
|
952
|
-
pauseInternal();
|
|
953
|
-
listeners.clear();
|
|
954
|
-
for (const p of livePreviews) {
|
|
955
|
-
try {
|
|
956
|
-
p.dispose();
|
|
957
|
-
} catch (e2) {
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
livePreviews.clear();
|
|
961
|
-
}
|
|
962
|
-
};
|
|
963
|
-
return session;
|
|
964
|
-
}
|
|
965
|
-
|
|
966
218
|
// src/effects/fake.ts
|
|
967
219
|
var HEX = "^#[0-9a-fA-F]{6}$";
|
|
968
220
|
var colour = (description) => ({ type: "string", pattern: HEX, description });
|
|
@@ -1136,7 +388,7 @@ var hexToRgb = (hex) => [1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16));
|
|
|
1136
388
|
var smooth = (t) => t * t * (3 - 2 * t);
|
|
1137
389
|
var clamp01 = (v) => v < 0 ? 0 : v > 1 ? 1 : v;
|
|
1138
390
|
function input(request, name, id, width, height) {
|
|
1139
|
-
const src = _optionalChain([request, 'access',
|
|
391
|
+
const src = _optionalChain([request, 'access', _12 => _12.inputs, 'optionalAccess', _13 => _13[name]]);
|
|
1140
392
|
if (!src) throw new (0, _chunkRUZQMYXHcjs.EffectUnsupportedError)(`Effect "${id}" needs an input named "${name}".`, id);
|
|
1141
393
|
if (!_chunkRUZQMYXHcjs.isEffectPixels.call(void 0, src)) throw new (0, _chunkRUZQMYXHcjs.EffectUnsupportedError)(`The fake provider only takes EffectPixels inputs ("${name}").`, id);
|
|
1142
394
|
if (src.width !== width || src.height !== height) {
|
|
@@ -1283,11 +535,11 @@ function createFakeEffectProvider(options = {}) {
|
|
|
1283
535
|
throw new (0, _chunkRUZQMYXHcjs.EffectUnsupportedError)(`time must be a finite number of ms \u2265 0, got ${request.time}.`, id);
|
|
1284
536
|
}
|
|
1285
537
|
const values = _chunkRUZQMYXHcjs.resolveEffectValues.call(void 0, d, request.values);
|
|
1286
|
-
_optionalChain([options, 'access',
|
|
538
|
+
_optionalChain([options, 'access', _14 => _14.onRender, 'optionalCall', _15 => _15(id, request)]);
|
|
1287
539
|
const out = renderPixels(d, values, request, width, height);
|
|
1288
540
|
if (request.mask) {
|
|
1289
541
|
if (!capabilities.supportsMask) throw new (0, _chunkRUZQMYXHcjs.EffectUnsupportedError)("This provider does not take masks.", id);
|
|
1290
|
-
const source = d.uses.includes("filter") ? _optionalChain([request, 'access',
|
|
542
|
+
const source = d.uses.includes("filter") ? _optionalChain([request, 'access', _16 => _16.inputs, 'optionalAccess', _17 => _17.source]) : void 0;
|
|
1291
543
|
maskResult(out, request.mask, source, id);
|
|
1292
544
|
}
|
|
1293
545
|
return depth > 8 && capabilities.supportsFloat ? toFloat(out) : out;
|
|
@@ -1316,7 +568,7 @@ function createFakeEffectProvider(options = {}) {
|
|
|
1316
568
|
};
|
|
1317
569
|
},
|
|
1318
570
|
...supportsAuthoring ? {
|
|
1319
|
-
openAuthoring: (from) => createEffectAuthoringSession(from, { provider })
|
|
571
|
+
openAuthoring: (from) => _chunk6DM3PUQDcjs.createEffectAuthoringSession.call(void 0, from, { provider })
|
|
1320
572
|
} : {}
|
|
1321
573
|
};
|
|
1322
574
|
return provider;
|
|
@@ -1334,13 +586,16 @@ var EFFECT_USE_LABELS = {
|
|
|
1334
586
|
};
|
|
1335
587
|
var HEX2 = /^#[0-9a-f]{6}([0-9a-f]{2})?$/i;
|
|
1336
588
|
var typeOf = (s) => Array.isArray(s.type) ? s.type.find((t) => t !== "null") : s.type;
|
|
1337
|
-
function
|
|
589
|
+
function isEffectFontControl(schema) {
|
|
590
|
+
return typeOf(schema) === "string" && (schema.format === "font" || schema["x-pixerate-control"] === "font");
|
|
591
|
+
}
|
|
592
|
+
function effectControlField(name, schema, fallback, options = {}) {
|
|
1338
593
|
const base = { id: name, ...schema.title ? { label: schema.title } : {}, ...schema.description ? { description: schema.description } : {} };
|
|
1339
594
|
const def = _nullishCoalesce(schema.default, () => ( fallback));
|
|
1340
595
|
const type = typeOf(schema);
|
|
1341
596
|
if (Array.isArray(schema.enum) && schema.enum.length) {
|
|
1342
|
-
const
|
|
1343
|
-
return { ...base, type: "choice", options, default: typeof def === "string" || typeof def === "number" ? def :
|
|
597
|
+
const options2 = schema.enum.filter((v) => typeof v === "string" || typeof v === "number");
|
|
598
|
+
return { ...base, type: "choice", options: options2, default: typeof def === "string" || typeof def === "number" ? def : options2[0], control: options2.length <= 4 ? "segmented" : "select" };
|
|
1344
599
|
}
|
|
1345
600
|
if (type === "number" || type === "integer") {
|
|
1346
601
|
const min = _nullishCoalesce(schema.minimum, () => ( schema.exclusiveMinimum));
|
|
@@ -1348,6 +603,13 @@ function effectControlField(name, schema, fallback) {
|
|
|
1348
603
|
return { ...base, type: type === "integer" ? "int" : "number", default: typeof def === "number" ? def : _nullishCoalesce(min, () => ( 0)), ...min !== void 0 ? { min } : {}, ...max !== void 0 ? { max } : {}, ...schema.multipleOf ? { step: schema.multipleOf } : {} };
|
|
1349
604
|
}
|
|
1350
605
|
if (type === "boolean") return { ...base, type: "boolean", default: def === true };
|
|
606
|
+
if (isEffectFontControl(schema)) {
|
|
607
|
+
const fonts = _nullishCoalesce(options.fonts, () => ( _chunkFKUKJ3XAcjs.SYSTEM_FONT_CATALOG));
|
|
608
|
+
const opts = fonts.map((f) => ({ value: f.family, label: f.family, description: f.category }));
|
|
609
|
+
const current = typeof def === "string" && def ? def : _nullishCoalesce(_optionalChain([opts, 'access', _18 => _18[0], 'optionalAccess', _19 => _19.value]), () => ( "sans-serif"));
|
|
610
|
+
if (!opts.some((o) => o.value.toLowerCase() === current.toLowerCase())) opts.unshift({ value: current, label: current, description: "current" });
|
|
611
|
+
return { ...base, type: "choice", options: opts, default: opts.find((o) => o.value.toLowerCase() === current.toLowerCase()).value, control: "select" };
|
|
612
|
+
}
|
|
1351
613
|
if (type === "string") {
|
|
1352
614
|
if (typeof def === "string" && HEX2.test(def)) return { ...base, type: "color", alpha: def.length === 9, default: def };
|
|
1353
615
|
return { ...base, type: "text", default: typeof def === "string" ? def : "", ...schema.maxLength ? { maxLength: schema.maxLength } : {} };
|
|
@@ -1358,8 +620,17 @@ function effectControlField(name, schema, fallback) {
|
|
|
1358
620
|
}
|
|
1359
621
|
return null;
|
|
1360
622
|
}
|
|
1361
|
-
function effectParameterFields(description) {
|
|
1362
|
-
return Object.entries(description.controls.properties).map(([name, schema]) => effectControlField(name, schema, description.defaults[name])).filter((f) => !!f);
|
|
623
|
+
function effectParameterFields(description, options = {}) {
|
|
624
|
+
return Object.entries(description.controls.properties).map(([name, schema]) => effectControlField(name, schema, description.defaults[name], options)).filter((f) => !!f);
|
|
625
|
+
}
|
|
626
|
+
function effectFontFamilies(description, values = {}) {
|
|
627
|
+
const out = [];
|
|
628
|
+
for (const [name, schema] of Object.entries(description.controls.properties)) {
|
|
629
|
+
if (!isEffectFontControl(schema)) continue;
|
|
630
|
+
const v = _nullishCoalesce(_nullishCoalesce(values[name], () => ( description.defaults[name])), () => ( schema.default));
|
|
631
|
+
if (typeof v === "string" && v && !out.includes(v)) out.push(v);
|
|
632
|
+
}
|
|
633
|
+
return out;
|
|
1363
634
|
}
|
|
1364
635
|
var effectFieldValue = (field, value) => value === void 0 || value === null || typeof value === "object" && !Array.isArray(value) ? field.default : value;
|
|
1365
636
|
function effectSamplePicture(width, height, variant = 0) {
|
|
@@ -1454,11 +725,11 @@ var EASING_SCHEMA = {
|
|
|
1454
725
|
};
|
|
1455
726
|
var NO_SESSION = "No effect authoring session is currently open. Open an effect using EffectProvider.openAuthoring() or in an authoring editor before calling effect authoring tools.";
|
|
1456
727
|
function createEffectAuthoringToolProvider(host, options) {
|
|
1457
|
-
const id = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1458
|
-
const namespace = _optionalChain([options, 'optionalAccess',
|
|
1459
|
-
const title = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1460
|
-
const description = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1461
|
-
const skill = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
728
|
+
const id = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _20 => _20.id]), () => ( "effect-authoring"));
|
|
729
|
+
const namespace = _optionalChain([options, 'optionalAccess', _21 => _21.namespace]);
|
|
730
|
+
const title = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _22 => _22.title]), () => ( "Effect authoring"));
|
|
731
|
+
const description = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _23 => _23.description]), () => ( "Author shaders and procedural effects, inspect parameters, adjust values, and manage keyframe animations."));
|
|
732
|
+
const skill = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _24 => _24.skill]), () => ( "pixerate-effect-authoring"));
|
|
1462
733
|
const requireSession = () => {
|
|
1463
734
|
const s = host.session();
|
|
1464
735
|
if (!s) throw new Error(NO_SESSION);
|
|
@@ -1479,7 +750,7 @@ function createEffectAuthoringToolProvider(host, options) {
|
|
|
1479
750
|
sourceLanguage: state.sourceLanguage,
|
|
1480
751
|
controls: effectParameterFields(state.description),
|
|
1481
752
|
values: state.values,
|
|
1482
|
-
presets: _nullishCoalesce(_optionalChain([state, 'access',
|
|
753
|
+
presets: _nullishCoalesce(_optionalChain([state, 'access', _25 => _25.description, 'access', _26 => _26.presets, 'optionalAccess', _27 => _27.map, 'call', _28 => _28((p) => p.name)]), () => ( [])),
|
|
1483
754
|
tracks: Object.entries(state.tracks).map(([control, track]) => ({
|
|
1484
755
|
control,
|
|
1485
756
|
keyframes: track.length
|
|
@@ -1780,7 +1051,7 @@ function createEffectAuthoringToolProvider(host, options) {
|
|
|
1780
1051
|
const tools = [
|
|
1781
1052
|
describeTool,
|
|
1782
1053
|
getSourceTool,
|
|
1783
|
-
..._optionalChain([session, 'optionalAccess',
|
|
1054
|
+
..._optionalChain([session, 'optionalAccess', _29 => _29.setSource]) ? [setSourceTool] : [],
|
|
1784
1055
|
setValuesTool,
|
|
1785
1056
|
resetValuesTool,
|
|
1786
1057
|
applyPresetTool,
|
|
@@ -1834,4 +1105,6 @@ function createEffectAuthoringToolProvider(host, options) {
|
|
|
1834
1105
|
|
|
1835
1106
|
|
|
1836
1107
|
|
|
1837
|
-
|
|
1108
|
+
|
|
1109
|
+
|
|
1110
|
+
exports.EFFECT_ERROR_CODES = _chunkRUZQMYXHcjs.EFFECT_ERROR_CODES; exports.EFFECT_KINDS = _chunkRUZQMYXHcjs.EFFECT_KINDS; exports.EFFECT_USES = _chunkRUZQMYXHcjs.EFFECT_USES; exports.EFFECT_USE_LABELS = EFFECT_USE_LABELS; exports.EffectControlError = _chunkRUZQMYXHcjs.EffectControlError; exports.EffectDisposedError = _chunkRUZQMYXHcjs.EffectDisposedError; exports.EffectError = _chunkRUZQMYXHcjs.EffectError; exports.EffectRendererPool = _chunkPY4GWSE2cjs.EffectRendererPool; exports.EffectUnsupportedError = _chunkRUZQMYXHcjs.EffectUnsupportedError; exports.EffectsSlot = _chunkRUZQMYXHcjs.EffectsSlot; exports.NoEffectsProviderError = _chunkRUZQMYXHcjs.NoEffectsProviderError; exports.UnknownEffectError = _chunkRUZQMYXHcjs.UnknownEffectError; exports.applyEffectMask = _chunkRUZQMYXHcjs.applyEffectMask; exports.checkEffectProvider = checkEffectProvider; exports.createEffectAuthoringSession = _chunk6DM3PUQDcjs.createEffectAuthoringSession; exports.createEffectAuthoringToolProvider = createEffectAuthoringToolProvider; exports.createEffectPixels = _chunkRUZQMYXHcjs.createEffectPixels; exports.createEffectToolProvider = _chunkRUZQMYXHcjs.createEffectToolProvider; exports.createFakeEffectProvider = createFakeEffectProvider; exports.effectControlField = effectControlField; exports.effectFieldValue = effectFieldValue; exports.effectFontFamilies = effectFontFamilies; exports.effectParameterFields = effectParameterFields; exports.effectSampleInputs = effectSampleInputs; exports.effectSamplePicture = effectSamplePicture; exports.effectValueErrors = _chunkRUZQMYXHcjs.effectValueErrors; exports.encodeEffectFloat = _chunkRUZQMYXHcjs.encodeEffectFloat; exports.groupEffectsByCategory = groupEffectsByCategory; exports.isEffectError = _chunkRUZQMYXHcjs.isEffectError; exports.isEffectFontControl = isEffectFontControl; exports.isEffectPixels = _chunkRUZQMYXHcjs.isEffectPixels; exports.linearToSrgb = _chunkRUZQMYXHcjs.linearToSrgb; exports.renderEffectThumbnail = renderEffectThumbnail; exports.resolveEffectValues = _chunkRUZQMYXHcjs.resolveEffectValues; exports.searchEffectSummaries = _chunkRUZQMYXHcjs.searchEffectSummaries; exports.srgbToLinear = _chunkRUZQMYXHcjs.srgbToLinear;
|