@pixerate/editor 0.160.0 → 0.161.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 (57) hide show
  1. package/dist/{chunk-VKF3PWKR.cjs → chunk-3OSXHLIT.cjs} +259 -28
  2. package/dist/chunk-6DM3PUQD.cjs +767 -0
  3. package/dist/{chunk-IQ6KKXOU.js → chunk-YN4AYYBJ.js} +243 -12
  4. package/dist/chunk-ZGOHKS3X.js +767 -0
  5. package/dist/effects/index.cjs +16 -767
  6. package/dist/effects/index.js +5 -756
  7. package/dist/paint-editor/index.cjs +2 -2
  8. package/dist/paint-editor/index.js +1 -1
  9. package/dist/video-editor/audio.d.cts +9 -0
  10. package/dist/video-editor/audio.d.ts +9 -0
  11. package/dist/video-editor/check.d.cts +1 -1
  12. package/dist/video-editor/check.d.ts +1 -1
  13. package/dist/video-editor/controller.d.cts +47 -0
  14. package/dist/video-editor/controller.d.ts +47 -0
  15. package/dist/video-editor/dialogue-tools.d.cts +19 -0
  16. package/dist/video-editor/dialogue-tools.d.ts +19 -0
  17. package/dist/video-editor/effect-authoring.d.cts +54 -0
  18. package/dist/video-editor/effect-authoring.d.ts +54 -0
  19. package/dist/video-editor/evaluate.d.cts +11 -0
  20. package/dist/video-editor/evaluate.d.ts +11 -0
  21. package/dist/video-editor/export.d.cts +7 -1
  22. package/dist/video-editor/export.d.ts +7 -1
  23. package/dist/video-editor/index.cjs +1853 -528
  24. package/dist/video-editor/index.d.cts +7 -0
  25. package/dist/video-editor/index.d.ts +7 -0
  26. package/dist/video-editor/index.js +1512 -187
  27. package/dist/video-editor/lut.d.cts +12 -2
  28. package/dist/video-editor/lut.d.ts +12 -2
  29. package/dist/video-editor/mask.d.cts +48 -0
  30. package/dist/video-editor/mask.d.ts +48 -0
  31. package/dist/video-editor/mix.d.cts +107 -0
  32. package/dist/video-editor/mix.d.ts +107 -0
  33. package/dist/video-editor/music-tools.d.cts +19 -0
  34. package/dist/video-editor/music-tools.d.ts +19 -0
  35. package/dist/video-editor/parse.d.cts +3 -1
  36. package/dist/video-editor/parse.d.ts +3 -1
  37. package/dist/video-editor/plan.d.cts +75 -0
  38. package/dist/video-editor/plan.d.ts +75 -0
  39. package/dist/video-editor/render.d.cts +1 -1
  40. package/dist/video-editor/render.d.ts +1 -1
  41. package/dist/video-editor/timeline.d.cts +2 -0
  42. package/dist/video-editor/timeline.d.ts +2 -0
  43. package/dist/video-editor/tools.d.cts +90 -0
  44. package/dist/video-editor/tools.d.ts +90 -0
  45. package/dist/video-editor/transcript-controller.d.cts +106 -0
  46. package/dist/video-editor/transcript-controller.d.ts +106 -0
  47. package/dist/video-editor/transcript.d.cts +40 -0
  48. package/dist/video-editor/transcript.d.ts +40 -0
  49. package/dist/video-editor/types.d.cts +62 -2
  50. package/dist/video-editor/types.d.ts +62 -2
  51. package/dist/video-editor/ui.d.cts +21 -1
  52. package/dist/video-editor/ui.d.ts +21 -1
  53. package/package.json +1 -1
  54. package/skills/README.md +2 -0
  55. package/skills/pixerate-bgm-alignment/SKILL.md +82 -0
  56. package/skills/pixerate-talking-head-edit/SKILL.md +80 -0
  57. package/skills/pixerate-video-editor/SKILL.md +40 -2
@@ -1,5 +1,8 @@
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 _chunk6DM3PUQDcjs = require('../chunk-6DM3PUQD.cjs');
4
+
5
+
3
6
  var _chunkPY4GWSE2cjs = require('../chunk-PY4GWSE2.cjs');
4
7
 
5
8
 
@@ -25,11 +28,7 @@ var _chunkPY4GWSE2cjs = require('../chunk-PY4GWSE2.cjs');
25
28
 
26
29
  var _chunkRUZQMYXHcjs = require('../chunk-RUZQMYXH.cjs');
27
30
  require('../chunk-WOFXZ3XU.cjs');
28
-
29
-
30
- var _chunkFJ2MSI43cjs = require('../chunk-FJ2MSI43.cjs');
31
-
32
-
31
+ require('../chunk-FJ2MSI43.cjs');
33
32
 
34
33
 
35
34
  var _chunkDWJJI6RTcjs = require('../chunk-DWJJI6RT.cjs');
@@ -213,756 +212,6 @@ async function checkEffectProvider(provider, options = {}) {
213
212
  return issues;
214
213
  }
215
214
 
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
215
  // src/effects/fake.ts
967
216
  var HEX = "^#[0-9a-fA-F]{6}$";
968
217
  var colour = (description) => ({ type: "string", pattern: HEX, description });
@@ -1136,7 +385,7 @@ var hexToRgb = (hex) => [1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16));
1136
385
  var smooth = (t) => t * t * (3 - 2 * t);
1137
386
  var clamp01 = (v) => v < 0 ? 0 : v > 1 ? 1 : v;
1138
387
  function input(request, name, id, width, height) {
1139
- const src = _optionalChain([request, 'access', _31 => _31.inputs, 'optionalAccess', _32 => _32[name]]);
388
+ const src = _optionalChain([request, 'access', _12 => _12.inputs, 'optionalAccess', _13 => _13[name]]);
1140
389
  if (!src) throw new (0, _chunkRUZQMYXHcjs.EffectUnsupportedError)(`Effect "${id}" needs an input named "${name}".`, id);
1141
390
  if (!_chunkRUZQMYXHcjs.isEffectPixels.call(void 0, src)) throw new (0, _chunkRUZQMYXHcjs.EffectUnsupportedError)(`The fake provider only takes EffectPixels inputs ("${name}").`, id);
1142
391
  if (src.width !== width || src.height !== height) {
@@ -1283,11 +532,11 @@ function createFakeEffectProvider(options = {}) {
1283
532
  throw new (0, _chunkRUZQMYXHcjs.EffectUnsupportedError)(`time must be a finite number of ms \u2265 0, got ${request.time}.`, id);
1284
533
  }
1285
534
  const values = _chunkRUZQMYXHcjs.resolveEffectValues.call(void 0, d, request.values);
1286
- _optionalChain([options, 'access', _33 => _33.onRender, 'optionalCall', _34 => _34(id, request)]);
535
+ _optionalChain([options, 'access', _14 => _14.onRender, 'optionalCall', _15 => _15(id, request)]);
1287
536
  const out = renderPixels(d, values, request, width, height);
1288
537
  if (request.mask) {
1289
538
  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', _35 => _35.inputs, 'optionalAccess', _36 => _36.source]) : void 0;
539
+ const source = d.uses.includes("filter") ? _optionalChain([request, 'access', _16 => _16.inputs, 'optionalAccess', _17 => _17.source]) : void 0;
1291
540
  maskResult(out, request.mask, source, id);
1292
541
  }
1293
542
  return depth > 8 && capabilities.supportsFloat ? toFloat(out) : out;
@@ -1316,7 +565,7 @@ function createFakeEffectProvider(options = {}) {
1316
565
  };
1317
566
  },
1318
567
  ...supportsAuthoring ? {
1319
- openAuthoring: (from) => createEffectAuthoringSession(from, { provider })
568
+ openAuthoring: (from) => _chunk6DM3PUQDcjs.createEffectAuthoringSession.call(void 0, from, { provider })
1320
569
  } : {}
1321
570
  };
1322
571
  return provider;
@@ -1454,11 +703,11 @@ var EASING_SCHEMA = {
1454
703
  };
1455
704
  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
705
  function createEffectAuthoringToolProvider(host, options) {
1457
- const id = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _37 => _37.id]), () => ( "effect-authoring"));
1458
- const namespace = _optionalChain([options, 'optionalAccess', _38 => _38.namespace]);
1459
- const title = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _39 => _39.title]), () => ( "Effect authoring"));
1460
- const description = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _40 => _40.description]), () => ( "Author shaders and procedural effects, inspect parameters, adjust values, and manage keyframe animations."));
1461
- const skill = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _41 => _41.skill]), () => ( "pixerate-effect-authoring"));
706
+ const id = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _18 => _18.id]), () => ( "effect-authoring"));
707
+ const namespace = _optionalChain([options, 'optionalAccess', _19 => _19.namespace]);
708
+ const title = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _20 => _20.title]), () => ( "Effect authoring"));
709
+ const description = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _21 => _21.description]), () => ( "Author shaders and procedural effects, inspect parameters, adjust values, and manage keyframe animations."));
710
+ const skill = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _22 => _22.skill]), () => ( "pixerate-effect-authoring"));
1462
711
  const requireSession = () => {
1463
712
  const s = host.session();
1464
713
  if (!s) throw new Error(NO_SESSION);
@@ -1479,7 +728,7 @@ function createEffectAuthoringToolProvider(host, options) {
1479
728
  sourceLanguage: state.sourceLanguage,
1480
729
  controls: effectParameterFields(state.description),
1481
730
  values: state.values,
1482
- presets: _nullishCoalesce(_optionalChain([state, 'access', _42 => _42.description, 'access', _43 => _43.presets, 'optionalAccess', _44 => _44.map, 'call', _45 => _45((p) => p.name)]), () => ( [])),
731
+ presets: _nullishCoalesce(_optionalChain([state, 'access', _23 => _23.description, 'access', _24 => _24.presets, 'optionalAccess', _25 => _25.map, 'call', _26 => _26((p) => p.name)]), () => ( [])),
1483
732
  tracks: Object.entries(state.tracks).map(([control, track]) => ({
1484
733
  control,
1485
734
  keyframes: track.length
@@ -1780,7 +1029,7 @@ function createEffectAuthoringToolProvider(host, options) {
1780
1029
  const tools = [
1781
1030
  describeTool,
1782
1031
  getSourceTool,
1783
- ..._optionalChain([session, 'optionalAccess', _46 => _46.setSource]) ? [setSourceTool] : [],
1032
+ ..._optionalChain([session, 'optionalAccess', _27 => _27.setSource]) ? [setSourceTool] : [],
1784
1033
  setValuesTool,
1785
1034
  resetValuesTool,
1786
1035
  applyPresetTool,
@@ -1834,4 +1083,4 @@ function createEffectAuthoringToolProvider(host, options) {
1834
1083
 
1835
1084
 
1836
1085
 
1837
- 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 = createEffectAuthoringSession; exports.createEffectAuthoringToolProvider = createEffectAuthoringToolProvider; exports.createEffectPixels = _chunkRUZQMYXHcjs.createEffectPixels; exports.createEffectToolProvider = _chunkRUZQMYXHcjs.createEffectToolProvider; exports.createFakeEffectProvider = createFakeEffectProvider; exports.effectControlField = effectControlField; exports.effectFieldValue = effectFieldValue; 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.isEffectPixels = _chunkRUZQMYXHcjs.isEffectPixels; exports.linearToSrgb = _chunkRUZQMYXHcjs.linearToSrgb; exports.renderEffectThumbnail = renderEffectThumbnail; exports.resolveEffectValues = _chunkRUZQMYXHcjs.resolveEffectValues; exports.searchEffectSummaries = _chunkRUZQMYXHcjs.searchEffectSummaries; exports.srgbToLinear = _chunkRUZQMYXHcjs.srgbToLinear;
1086
+ 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.effectParameterFields = effectParameterFields; exports.effectSampleInputs = effectSampleInputs; exports.effectSamplePicture = effectSamplePicture; exports.effectValueErrors = _chunkRUZQMYXHcjs.effectValueErrors; exports.encodeEffectFloat = _chunkRUZQMYXHcjs.encodeEffectFloat; exports.groupEffectsByCategory = groupEffectsByCategory; exports.isEffectError = _chunkRUZQMYXHcjs.isEffectError; exports.isEffectPixels = _chunkRUZQMYXHcjs.isEffectPixels; exports.linearToSrgb = _chunkRUZQMYXHcjs.linearToSrgb; exports.renderEffectThumbnail = renderEffectThumbnail; exports.resolveEffectValues = _chunkRUZQMYXHcjs.resolveEffectValues; exports.searchEffectSummaries = _chunkRUZQMYXHcjs.searchEffectSummaries; exports.srgbToLinear = _chunkRUZQMYXHcjs.srgbToLinear;