@pixerate/editor 0.224.1 → 0.226.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 (33) hide show
  1. package/dist/animation-editor/index.cjs +9 -9
  2. package/dist/animation-editor/index.js +1 -1
  3. package/dist/canvas/index.cjs +7 -7
  4. package/dist/canvas/index.js +1 -1
  5. package/dist/{chunk-WA4IS2EY.js → chunk-4MDWEX44.js} +1 -1
  6. package/dist/{chunk-7AAS3JO6.cjs → chunk-4PA6YS6W.cjs} +14 -14
  7. package/dist/{chunk-RDTCG5MS.js → chunk-56RFHF7O.js} +1 -1
  8. package/dist/{chunk-S6KKLFZO.js → chunk-5YLOU7VF.js} +18 -3
  9. package/dist/{chunk-HKPLKISO.js → chunk-7DZ55AIE.js} +10 -5
  10. package/dist/{chunk-NTWR5TQB.cjs → chunk-ABQ2VGUB.cjs} +10 -5
  11. package/dist/{chunk-MDNYYOBZ.cjs → chunk-C6CMQXMI.cjs} +7 -7
  12. package/dist/{chunk-R35YOUP2.cjs → chunk-IWMDW7LB.cjs} +18 -3
  13. package/dist/effects/index.cjs +44 -44
  14. package/dist/effects/index.js +2 -2
  15. package/dist/effects/tools.d.cts +6 -0
  16. package/dist/effects/tools.d.ts +6 -0
  17. package/dist/image-editor/controller.d.cts +12 -4
  18. package/dist/image-editor/controller.d.ts +12 -4
  19. package/dist/image-editor/index.cjs +882 -860
  20. package/dist/image-editor/index.js +46 -24
  21. package/dist/image-editor/layers/model.d.cts +6 -0
  22. package/dist/image-editor/layers/model.d.ts +6 -0
  23. package/dist/paint-editor/index.cjs +13 -13
  24. package/dist/paint-editor/index.js +3 -3
  25. package/dist/vector/index.cjs +19 -6
  26. package/dist/vector/index.js +14 -1
  27. package/dist/video-editor/index.cjs +309 -309
  28. package/dist/video-editor/index.js +3 -3
  29. package/package.json +1 -1
  30. package/skills/pixerate-image-editor/SKILL.md +14 -7
  31. package/skills/pixerate-image-editor/references/provider-effects.md +11 -0
  32. package/skills/pixerate-image-selection-masking/SKILL.md +3 -3
  33. package/skills/pixerate-vector/SKILL.md +1 -0
@@ -48,7 +48,7 @@ require('../chunk-NM3G4VQT.cjs');
48
48
 
49
49
 
50
50
 
51
- var _chunkNTWR5TQBcjs = require('../chunk-NTWR5TQB.cjs');
51
+ var _chunkABQ2VGUBcjs = require('../chunk-ABQ2VGUB.cjs');
52
52
  require('../chunk-WOFXZ3XU.cjs');
53
53
  require('../chunk-PQ3H2AAN.cjs');
54
54
  require('../chunk-YQGCPL5X.cjs');
@@ -3828,7 +3828,7 @@ var AnimationEditorController = (_class = class {
3828
3828
 
3829
3829
 
3830
3830
  /** The effects provider slot (see `setEffectsProvider`). */
3831
- __init() {this.effects = new (0, _chunkNTWR5TQBcjs.EffectsSlot)()}
3831
+ __init() {this.effects = new (0, _chunkABQ2VGUBcjs.EffectsSlot)()}
3832
3832
 
3833
3833
 
3834
3834
  __init2() {this.selection = null}
@@ -4013,7 +4013,7 @@ var AnimationEditorController = (_class = class {
4013
4013
  try {
4014
4014
  plan = await work();
4015
4015
  } catch (error) {
4016
- if (_chunkNTWR5TQBcjs.isEffectError.call(void 0, error) || error instanceof Error) return this.refuse(error.message);
4016
+ if (_chunkABQ2VGUBcjs.isEffectError.call(void 0, error) || error instanceof Error) return this.refuse(error.message);
4017
4017
  throw error;
4018
4018
  }
4019
4019
  const r = this.apply({ op: "replace_scene", scene: plan.scene }, plan.label, { merge });
@@ -4024,11 +4024,11 @@ var AnimationEditorController = (_class = class {
4024
4024
  }
4025
4025
  async describeFor(effect, kinds) {
4026
4026
  const provider = this.effects.require();
4027
- if (!provider.applyVectorEffect) throw new (0, _chunkNTWR5TQBcjs.EffectUnsupportedError)(`${provider.name} has no vector or motion effects.`);
4027
+ if (!provider.applyVectorEffect) throw new (0, _chunkABQ2VGUBcjs.EffectUnsupportedError)(`${provider.name} has no vector or motion effects.`);
4028
4028
  const d = await provider.describe(effect);
4029
4029
  if (!kinds.includes(d.kind)) {
4030
4030
  const hint = d.kind === "motion" ? "apply it to nodes with apply_effect" : d.kind === "vector" ? "add it with add_vector_effect" : "it draws pixels, which scenes cannot hold";
4031
- throw new (0, _chunkNTWR5TQBcjs.EffectUnsupportedError)(`"${d.id}" (${d.name}) is a ${d.kind} effect: ${hint}.`, d.id);
4031
+ throw new (0, _chunkABQ2VGUBcjs.EffectUnsupportedError)(`"${d.id}" (${d.name}) is a ${d.kind} effect: ${hint}.`, d.id);
4032
4032
  }
4033
4033
  return d;
4034
4034
  }
@@ -4049,7 +4049,7 @@ var AnimationEditorController = (_class = class {
4049
4049
  return this.effectEdit(async () => {
4050
4050
  this.knownNodes(targets);
4051
4051
  const d = await this.describeFor(effect, ["motion"]);
4052
- const values = _chunkNTWR5TQBcjs.resolveEffectValues.call(void 0, d, options.values);
4052
+ const values = _chunkABQ2VGUBcjs.resolveEffectValues.call(void 0, d, options.values);
4053
4053
  const instance = _nullishCoalesce(options.instance, () => ( nextMotionEffectInstance(this.scene)));
4054
4054
  const motion = await this.effects.require().applyVectorEffect(d.id, { svg: motionArtworkSvg(this.scene.artwork), nodeIds: [...targets] }, values);
4055
4055
  const source = { instance, effect: d.id, provider: this.effects.require().id, name: d.name, values };
@@ -4071,7 +4071,7 @@ var AnimationEditorController = (_class = class {
4071
4071
  addVectorEffect(effect, options = {}) {
4072
4072
  return this.effectEdit(async () => {
4073
4073
  const d = await this.describeFor(effect, ["vector"]);
4074
- const values = _chunkNTWR5TQBcjs.resolveEffectValues.call(void 0, d, options.values);
4074
+ const values = _chunkABQ2VGUBcjs.resolveEffectValues.call(void 0, d, options.values);
4075
4075
  const instance = _nullishCoalesce(options.instance, () => ( nextMotionEffectInstance(this.scene)));
4076
4076
  const motion = await this.effects.require().applyVectorEffect(d.id, motionArtworkSvg(this.scene.artwork), values);
4077
4077
  const source = { instance, effect: d.id, provider: this.effects.require().id, name: d.name, values };
@@ -4095,7 +4095,7 @@ var AnimationEditorController = (_class = class {
4095
4095
  else if (k in d.controls.properties) base[k] = d.defaults[k];
4096
4096
  else throw new Error(`"${k}" is not a control of "${d.id}"; its controls are ${Object.keys(d.controls.properties).join(", ")}.`);
4097
4097
  }
4098
- const merged = { ...base, ..._chunkNTWR5TQBcjs.resolveEffectValues.call(void 0, { ...d, defaults: base }, given) };
4098
+ const merged = { ...base, ..._chunkABQ2VGUBcjs.resolveEffectValues.call(void 0, { ...d, defaults: base }, given) };
4099
4099
  const { scene: bare, place } = withoutMotionEffect(this.scene, instance);
4100
4100
  const provider = this.effects.require();
4101
4101
  const source = { instance, effect: d.id, provider: provider.id, name: d.name, values: merged };
@@ -5868,7 +5868,7 @@ function createAnimationEffectsToolProvider(controller, options = {}) {
5868
5868
  if (!r.ok) throw new Error(r.error);
5869
5869
  return { target, effect: info(r.effect), effects: controller.appliedEffects().filter((e) => e.targets.includes(target)).map(info), ...r.notes.length ? { notes: r.notes } : {} };
5870
5870
  };
5871
- return withAnimationPlayback(_chunkNTWR5TQBcjs.createEffectToolProvider.call(void 0, {
5871
+ return withAnimationPlayback(_chunkABQ2VGUBcjs.createEffectToolProvider.call(void 0, {
5872
5872
  id: _nullishCoalesce(options.id, () => ( "animation-effects")),
5873
5873
  namespace: options.namespace,
5874
5874
  title: "Animation effects",
@@ -48,7 +48,7 @@ import {
48
48
  createEffectToolProvider,
49
49
  isEffectError,
50
50
  resolveEffectValues
51
- } from "../chunk-HKPLKISO.js";
51
+ } from "../chunk-7DZ55AIE.js";
52
52
  import "../chunk-V2ZCJRDM.js";
53
53
  import "../chunk-2PBZBRP5.js";
54
54
  import "../chunk-ODBT55Q7.js";
@@ -209,7 +209,7 @@ var _chunkNM3G4VQTcjs = require('../chunk-NM3G4VQT.cjs');
209
209
 
210
210
 
211
211
 
212
- var _chunkNTWR5TQBcjs = require('../chunk-NTWR5TQB.cjs');
212
+ var _chunkABQ2VGUBcjs = require('../chunk-ABQ2VGUB.cjs');
213
213
  require('../chunk-WOFXZ3XU.cjs');
214
214
 
215
215
 
@@ -11396,14 +11396,14 @@ function canvasNodeEffect(node) {
11396
11396
  return _chunkNM3G4VQTcjs.isShapeDescription.call(void 0, shape) ? shape.effect : void 0;
11397
11397
  }
11398
11398
  function createCanvasEffectsController(options) {
11399
- const slot = new (0, _chunkNTWR5TQBcjs.EffectsSlot)();
11399
+ const slot = new (0, _chunkABQ2VGUBcjs.EffectsSlot)();
11400
11400
  if (options.effects) slot.set(options.effects);
11401
11401
  const describe = async (effect, place2) => {
11402
11402
  const d = await slot.require().describe(effect);
11403
11403
  const allowed = CANVAS_EFFECT_PLACES[place2];
11404
11404
  if (d.kind === "motion" || !d.uses.some((u) => allowed.includes(u))) {
11405
11405
  const where = place2 === "transition" ? "a scene transition" : place2 === "fill" ? "a fill" : "an overlay";
11406
- throw new (0, _chunkNTWR5TQBcjs.EffectUnsupportedError)(`"${d.id}" (${d.name}) is a ${d.uses.join(" / ")} effect and cannot be ${where}, which takes ${allowed.join(" or ")} effects; search_effects with use "${allowed[0]}" lists ones that fit.`, d.id);
11406
+ throw new (0, _chunkABQ2VGUBcjs.EffectUnsupportedError)(`"${d.id}" (${d.name}) is a ${d.uses.join(" / ")} effect and cannot be ${where}, which takes ${allowed.join(" or ")} effects; search_effects with use "${allowed[0]}" lists ones that fit.`, d.id);
11407
11407
  }
11408
11408
  return d;
11409
11409
  };
@@ -11434,7 +11434,7 @@ function createCanvasEffectsController(options) {
11434
11434
  else if (k in d.controls.properties) base[k] = d.defaults[k];
11435
11435
  else throw new Error(`"${k}" is not a control of "${d.id}"; its controls are ${Object.keys(d.controls.properties).join(", ")}.`);
11436
11436
  }
11437
- return { ...base, ..._chunkNTWR5TQBcjs.resolveEffectValues.call(void 0, { ...d, defaults: base }, given) };
11437
+ return { ...base, ..._chunkABQ2VGUBcjs.resolveEffectValues.call(void 0, { ...d, defaults: base }, given) };
11438
11438
  };
11439
11439
  return {
11440
11440
  /** The provider slot. */
@@ -11464,7 +11464,7 @@ function createCanvasEffectsController(options) {
11464
11464
  const mode = _nullishCoalesce(opts.mode, () => ( "fill"));
11465
11465
  const d = await describe(effect, mode);
11466
11466
  if (opts.opacity !== void 0 && !(opts.opacity >= 0 && opts.opacity <= 1)) throw new Error("opacity must be from 0 to 1.");
11467
- const next = { effect: d.id, provider: slot.require().id, name: d.name, values: _chunkNTWR5TQBcjs.resolveEffectValues.call(void 0, d, opts.values), mode, ...opts.opacity !== void 0 && opts.opacity !== 1 ? { opacity: opts.opacity } : {} };
11467
+ const next = { effect: d.id, provider: slot.require().id, name: d.name, values: _chunkABQ2VGUBcjs.resolveEffectValues.call(void 0, d, opts.values), mode, ...opts.opacity !== void 0 && opts.opacity !== 1 ? { opacity: opts.opacity } : {} };
11468
11468
  commit(`Add effect ${d.name}`, withEffect(nodeId, next));
11469
11469
  return next;
11470
11470
  },
@@ -11521,7 +11521,7 @@ function createCanvasEffectsController(options) {
11521
11521
  const d = await describe(effect, "transition");
11522
11522
  const duration = _nullishCoalesce(_nullishCoalesce(opts.duration, () => ( d.duration)), () => ( 600));
11523
11523
  if (!(duration > 0)) throw new Error("duration must be a number of ms above 0.");
11524
- const transition = { effect: d.id, provider: slot.require().id, name: d.name, values: _chunkNTWR5TQBcjs.resolveEffectValues.call(void 0, d, opts.values), duration };
11524
+ const transition = { effect: d.id, provider: slot.require().id, name: d.name, values: _chunkABQ2VGUBcjs.resolveEffectValues.call(void 0, d, opts.values), duration };
11525
11525
  scenes2.update(sceneId, { transition });
11526
11526
  return transition;
11527
11527
  }
@@ -11665,7 +11665,7 @@ function createCanvasEffectsToolProvider(controller, options = {}) {
11665
11665
  const once = (instance) => {
11666
11666
  if (instance !== "effect") throw new Error('A shape node has one effect, "effect".');
11667
11667
  };
11668
- return _chunkNTWR5TQBcjs.createEffectToolProvider.call(void 0, {
11668
+ return _chunkABQ2VGUBcjs.createEffectToolProvider.call(void 0, {
11669
11669
  id: _nullishCoalesce(options.id, () => ( "canvas-effects")),
11670
11670
  namespace: options.namespace,
11671
11671
  title: "Canvas effects",
@@ -209,7 +209,7 @@ import {
209
209
  EffectsSlot,
210
210
  createEffectToolProvider,
211
211
  resolveEffectValues
212
- } from "../chunk-HKPLKISO.js";
212
+ } from "../chunk-7DZ55AIE.js";
213
213
  import "../chunk-V2ZCJRDM.js";
214
214
  import {
215
215
  brushstrokeScaleBucket
@@ -3,7 +3,7 @@ import {
3
3
  EffectDisposedError,
4
4
  EffectUnsupportedError,
5
5
  effectValueErrors
6
- } from "./chunk-HKPLKISO.js";
6
+ } from "./chunk-7DZ55AIE.js";
7
7
  import {
8
8
  HistoryManager
9
9
  } from "./chunk-RNSANXPT.js";
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkNTWR5TQBcjs = require('./chunk-NTWR5TQB.cjs');
6
+ var _chunkABQ2VGUBcjs = require('./chunk-ABQ2VGUB.cjs');
7
7
 
8
8
 
9
9
  var _chunkFJ2MSI43cjs = require('./chunk-FJ2MSI43.cjs');
@@ -26,7 +26,7 @@ function documentErrors(doc, description) {
26
26
  const isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
27
27
  if (doc.values !== void 0) {
28
28
  if (!isRecord(doc.values)) errors.push({ path: "/values", message: "must be an object of control values" });
29
- else errors.push(..._chunkNTWR5TQBcjs.effectValueErrors.call(void 0, description, doc.values).map((e) => ({ ...e, path: `/values${e.path}` })));
29
+ else errors.push(..._chunkABQ2VGUBcjs.effectValueErrors.call(void 0, description, doc.values).map((e) => ({ ...e, path: `/values${e.path}` })));
30
30
  }
31
31
  if (doc.tracks !== void 0) {
32
32
  if (!isRecord(doc.tracks)) errors.push({ path: "/tracks", message: "must be an object of keyframe lists" });
@@ -39,7 +39,7 @@ function documentErrors(doc, description) {
39
39
  kfs.forEach((kf, i) => {
40
40
  if (!isRecord(kf)) return errors.push({ path: `${at}/${i}`, message: "must be a keyframe object" });
41
41
  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" });
42
- errors.push(..._chunkNTWR5TQBcjs.effectValueErrors.call(void 0, description, { [control]: kf.value }).map((e) => ({ ...e, path: `${at}/${i}/value` })));
42
+ errors.push(..._chunkABQ2VGUBcjs.effectValueErrors.call(void 0, description, { [control]: kf.value }).map((e) => ({ ...e, path: `${at}/${i}/value` })));
43
43
  if (kf.easing !== void 0 && !_chunkDWJJI6RTcjs.isAnimationEasing.call(void 0, kf.easing)) errors.push({ path: `${at}/${i}/easing`, message: "is not a valid easing" });
44
44
  });
45
45
  }
@@ -49,7 +49,7 @@ function documentErrors(doc, description) {
49
49
  else
50
50
  doc.presets.forEach((p, i) => {
51
51
  if (!isRecord(p) || typeof p.name !== "string" || !p.name) return errors.push({ path: `/presets/${i}`, message: "must have a name" });
52
- errors.push(..._chunkNTWR5TQBcjs.effectValueErrors.call(void 0, description, p.values).map((e) => ({ ...e, path: `/presets/${i}/values${e.path}` })));
52
+ errors.push(..._chunkABQ2VGUBcjs.effectValueErrors.call(void 0, description, p.values).map((e) => ({ ...e, path: `/presets/${i}/values${e.path}` })));
53
53
  });
54
54
  }
55
55
  if (doc.duration !== void 0 && (typeof doc.duration !== "number" || !Number.isFinite(doc.duration) || !(doc.duration > 0))) {
@@ -170,7 +170,7 @@ async function createEffectAuthoringSession(source, options) {
170
170
  if (isDocumentSource(source)) {
171
171
  const doc = source.document;
172
172
  if (doc.version !== 1 || !doc.effectId) {
173
- throw new (0, _chunkNTWR5TQBcjs.EffectUnsupportedError)("Invalid effect authoring document: version 1 required");
173
+ throw new (0, _chunkABQ2VGUBcjs.EffectUnsupportedError)("Invalid effect authoring document: version 1 required");
174
174
  }
175
175
  effectId = doc.effectId;
176
176
  initialDoc = doc;
@@ -178,15 +178,15 @@ async function createEffectAuthoringSession(source, options) {
178
178
  effectId = source.effectId;
179
179
  requestedPreset = source.preset;
180
180
  } else {
181
- throw new (0, _chunkNTWR5TQBcjs.EffectUnsupportedError)("Invalid effect authoring source");
181
+ throw new (0, _chunkABQ2VGUBcjs.EffectUnsupportedError)("Invalid effect authoring source");
182
182
  }
183
183
  const description = await provider.describe(effectId);
184
184
  if (initialDoc) {
185
185
  const problems = documentErrors(initialDoc, description);
186
- if (problems.length) throw new (0, _chunkNTWR5TQBcjs.EffectControlError)(effectId, problems);
186
+ if (problems.length) throw new (0, _chunkABQ2VGUBcjs.EffectControlError)(effectId, problems);
187
187
  }
188
188
  if (description.kind === "motion") {
189
- throw new (0, _chunkNTWR5TQBcjs.EffectUnsupportedError)("Motion effects cannot be authored as pixel effects", effectId);
189
+ throw new (0, _chunkABQ2VGUBcjs.EffectUnsupportedError)("Motion effects cannot be authored as pixel effects", effectId);
190
190
  }
191
191
  let disposed = false;
192
192
  let playing = false;
@@ -207,7 +207,7 @@ async function createEffectAuthoringSession(source, options) {
207
207
  const found = description.presets.find((p) => p.name === requestedPreset);
208
208
  if (!found) {
209
209
  const validNames = description.presets.map((p) => `"${p.name}"`).join(", ");
210
- throw new (0, _chunkNTWR5TQBcjs.EffectUnsupportedError)(
210
+ throw new (0, _chunkABQ2VGUBcjs.EffectUnsupportedError)(
211
211
  `Unknown preset "${requestedPreset}" for effect "${effectId}". Valid presets are: ${validNames || "none"}`,
212
212
  effectId
213
213
  );
@@ -321,7 +321,7 @@ async function createEffectAuthoringSession(source, options) {
321
321
  if (!validNames.includes(name)) {
322
322
  return { ok: false, message: `there is no control "${name}"; the controls are ${validNames.join(", ")}` };
323
323
  }
324
- const errors = _chunkNTWR5TQBcjs.effectValueErrors.call(void 0, description, { [name]: value });
324
+ const errors = _chunkABQ2VGUBcjs.effectValueErrors.call(void 0, description, { [name]: value });
325
325
  if (errors.length > 0) {
326
326
  return { ok: false, message: valueErrorMessage(errors) };
327
327
  }
@@ -391,7 +391,7 @@ async function createEffectAuthoringSession(source, options) {
391
391
  if (!validNames.includes(k)) {
392
392
  return { ok: false, message: `there is no control "${k}"; the controls are ${validNames.join(", ")}` };
393
393
  }
394
- const errors = _chunkNTWR5TQBcjs.effectValueErrors.call(void 0, description, { [k]: v });
394
+ const errors = _chunkABQ2VGUBcjs.effectValueErrors.call(void 0, description, { [k]: v });
395
395
  if (errors.length > 0) {
396
396
  return { ok: false, message: valueErrorMessage(errors) };
397
397
  }
@@ -528,7 +528,7 @@ async function createEffectAuthoringSession(source, options) {
528
528
  return { ok: false, message: `invalid easing: ${String(easing)}` };
529
529
  }
530
530
  const targetValue = value !== void 0 ? value : valuesAtTime(time, baseValues, tracks)[name];
531
- const errors = _chunkNTWR5TQBcjs.effectValueErrors.call(void 0, description, { [name]: targetValue });
531
+ const errors = _chunkABQ2VGUBcjs.effectValueErrors.call(void 0, description, { [name]: targetValue });
532
532
  if (errors.length > 0) {
533
533
  return { ok: false, message: valueErrorMessage(errors) };
534
534
  }
@@ -705,7 +705,7 @@ async function createEffectAuthoringSession(source, options) {
705
705
  },
706
706
  async createPreview(opts) {
707
707
  if (disposed) {
708
- throw new (0, _chunkNTWR5TQBcjs.EffectDisposedError)(effectId);
708
+ throw new (0, _chunkABQ2VGUBcjs.EffectDisposedError)(effectId);
709
709
  }
710
710
  let renderer;
711
711
  try {
@@ -730,7 +730,7 @@ async function createEffectAuthoringSession(source, options) {
730
730
  height: renderer.height,
731
731
  depth: renderer.depth,
732
732
  render: async (req) => {
733
- if (disposed) throw new (0, _chunkNTWR5TQBcjs.EffectDisposedError)(effectId);
733
+ if (disposed) throw new (0, _chunkABQ2VGUBcjs.EffectDisposedError)(effectId);
734
734
  const effectiveValues = _nullishCoalesce(req.values, () => ( valuesAtTime(req.time, baseValues, tracks)));
735
735
  const pixels = await renderer.render({
736
736
  ...req,
@@ -7,7 +7,7 @@ import {
7
7
  EffectsSlot,
8
8
  createEffectPixels,
9
9
  effectValueErrors
10
- } from "./chunk-HKPLKISO.js";
10
+ } from "./chunk-7DZ55AIE.js";
11
11
  import {
12
12
  validateJsonSchema
13
13
  } from "./chunk-V2ZCJRDM.js";
@@ -4894,13 +4894,14 @@ function applySmartFilters(placed, stack, canvas) {
4894
4894
  let out2;
4895
4895
  if (f.kind === "effect") {
4896
4896
  if (incomplete) continue;
4897
- const inputKey = JSON.stringify([surfaceId(placed), W, H, active.slice(0, i + 1).map((x) => ({ ...x, id: void 0, blend: x === f ? void 0 : x.blend, opacity: x === f ? void 0 : x.opacity }))]);
4897
+ const inputKey = JSON.stringify([surfaceId(placed), W, H, active.slice(0, i + 1).map((x) => x === f ? { ...x, id: void 0, blend: void 0, opacity: void 0, preserveTransparency: void 0 } : { ...x, id: void 0 })]);
4898
4898
  const r = canvas.effects?.resolve(f, acc, W, H, inputKey);
4899
4899
  if (!r?.result) {
4900
4900
  if (r?.pending) incomplete = true;
4901
4901
  continue;
4902
4902
  }
4903
4903
  out2 = new Uint8ClampedArray(r.result);
4904
+ if (f.preserveTransparency) keepAlphaOf(out2, acc);
4904
4905
  } else {
4905
4906
  out2 = new Uint8ClampedArray(acc);
4906
4907
  runLayerFilters(out2, W, H, [f]);
@@ -4925,6 +4926,18 @@ function applySmartFilters(placed, stack, canvas) {
4925
4926
  if (incomplete) incompleteSurfaces.add(out);
4926
4927
  return out;
4927
4928
  }
4929
+ function keepAlphaOf(result, input) {
4930
+ for (let i = 0; i < result.length; i += 4) {
4931
+ const ia = input[i + 3];
4932
+ const ta = result[i + 3] / 255;
4933
+ if (ta < 1) {
4934
+ const ba = ia / 255;
4935
+ const a = ta + ba * (1 - ta);
4936
+ for (let c = 0; c < 3; c++) result[i + c] = a > 0 ? (result[i + c] * ta + input[i + c] * ba * (1 - ta)) / a : 0;
4937
+ }
4938
+ result[i + 3] = ia;
4939
+ }
4940
+ }
4928
4941
  function lerpInto(dst, src, k, coverage) {
4929
4942
  for (let i = 0, p = 0; i < dst.length; i += 4, p++) {
4930
4943
  const t = coverage ? k * coverage[p] : k;
@@ -5269,6 +5282,7 @@ function normalizeEffectSmartFilter(raw, id) {
5269
5282
  if (typeof raw.effect !== "string" || !raw.effect) fail4('An effect smart filter needs an "effect" id from search_effects.');
5270
5283
  const values = raw.values ?? {};
5271
5284
  if (typeof values !== "object" || values === null || Array.isArray(values)) fail4('"values" must be an object of control values.');
5285
+ if (raw.preserveTransparency !== void 0 && typeof raw.preserveTransparency !== "boolean") fail4('"preserveTransparency" must be true or false.');
5272
5286
  return {
5273
5287
  id,
5274
5288
  kind: "effect",
@@ -5276,7 +5290,8 @@ function normalizeEffectSmartFilter(raw, id) {
5276
5290
  effect: raw.effect,
5277
5291
  ...typeof raw.provider === "string" ? { provider: raw.provider } : {},
5278
5292
  ...typeof raw.name === "string" ? { name: raw.name } : {},
5279
- values: { ...values }
5293
+ values: { ...values },
5294
+ ...typeof raw.preserveTransparency === "boolean" ? { preserveTransparency: raw.preserveTransparency } : {}
5280
5295
  };
5281
5296
  }
5282
5297
  function withStack(layer, stack, canvas) {
@@ -6097,7 +6112,7 @@ function readSmartFilters(raw, ctx, what) {
6097
6112
  if (base) filters.push({ ...base, blend, opacity });
6098
6113
  } else if (f.kind === "effect") {
6099
6114
  const ref = readEffectRef(f);
6100
- if (ref) filters.push({ id: typeof f.id === "string" ? f.id : newLayerId("flt"), kind: "effect", enabled: f.enabled !== false, ...ref, blend, opacity });
6115
+ if (ref) filters.push({ id: typeof f.id === "string" ? f.id : newLayerId("flt"), kind: "effect", enabled: f.enabled !== false, ...ref, ...typeof f.preserveTransparency === "boolean" ? { preserveTransparency: f.preserveTransparency } : {}, blend, opacity });
6101
6116
  else ctx.problems.push(`${what}: an effect smart filter without an effect id was left out`);
6102
6117
  }
6103
6118
  }
@@ -358,6 +358,7 @@ function createEffectToolProvider(host) {
358
358
  }
359
359
  }
360
360
  ];
361
+ const hostOptions = (schemas, args) => Object.fromEntries(Object.keys(schemas ?? {}).filter((k) => args[k] !== void 0).map((k) => [k, args[k]]));
361
362
  const writeTools = () => [
362
363
  {
363
364
  name: "apply_effect",
@@ -370,14 +371,15 @@ function createEffectToolProvider(host) {
370
371
  values: valuesSchema("Control values over the effect's defaults", true),
371
372
  index: INDEX,
372
373
  enabled: ENABLED,
373
- opacity: OPACITY
374
+ opacity: OPACITY,
375
+ ...host.applyOptions
374
376
  },
375
377
  ["target", "effect"]
376
378
  ),
377
379
  annotations: { title: "Apply an effect", ...ANNOTATIONS.write },
378
380
  handler: async (args) => {
379
381
  writable();
380
- return explain(() => host.apply(args.target, args.effect, { values: args.values, index: args.index, enabled: args.enabled, opacity: args.opacity }));
382
+ return explain(() => host.apply(args.target, args.effect, { ...hostOptions(host.applyOptions, args), values: args.values, index: args.index, enabled: args.enabled, opacity: args.opacity }));
381
383
  }
382
384
  },
383
385
  {
@@ -391,15 +393,18 @@ function createEffectToolProvider(host) {
391
393
  values: { ...valuesSchema("Control values to change", true), description: `${valuesSchema("Control values to change", true).description} null resets a control to its default.` },
392
394
  enabled: ENABLED,
393
395
  opacity: OPACITY,
394
- index: { ...INDEX, description: `Move it to this place in the ${host.target.noun}'s stack (0 = applied first).` }
396
+ index: { ...INDEX, description: `Move it to this place in the ${host.target.noun}'s stack (0 = applied first).` },
397
+ ...host.updateOptions
395
398
  },
396
399
  ["target", "effect"]
397
400
  ),
398
401
  annotations: { title: "Change an applied effect", ...ANNOTATIONS.writeIdempotent },
399
402
  handler: async (args) => {
400
403
  writable();
401
- if (args.values === void 0 && args.enabled === void 0 && args.opacity === void 0 && args.index === void 0) throw new Error("Give at least one of values, enabled, opacity or index to change.");
402
- return explain(() => host.update(args.target, args.effect, { values: args.values, enabled: args.enabled, opacity: args.opacity, index: args.index }));
404
+ const options = hostOptions(host.updateOptions, args);
405
+ if (args.values === void 0 && args.enabled === void 0 && args.opacity === void 0 && args.index === void 0 && !Object.keys(options).length)
406
+ throw new Error(`Give at least one of ${["values", "enabled", "opacity", "index", ...Object.keys(host.updateOptions ?? {})].join(", ")} to change.`);
407
+ return explain(() => host.update(args.target, args.effect, { ...options, values: args.values, enabled: args.enabled, opacity: args.opacity, index: args.index }));
403
408
  }
404
409
  },
405
410
  {
@@ -358,6 +358,7 @@ function createEffectToolProvider(host) {
358
358
  }
359
359
  }
360
360
  ];
361
+ const hostOptions = (schemas, args) => Object.fromEntries(Object.keys(_nullishCoalesce(schemas, () => ( {}))).filter((k) => args[k] !== void 0).map((k) => [k, args[k]]));
361
362
  const writeTools = () => [
362
363
  {
363
364
  name: "apply_effect",
@@ -370,14 +371,15 @@ function createEffectToolProvider(host) {
370
371
  values: valuesSchema("Control values over the effect's defaults", true),
371
372
  index: INDEX,
372
373
  enabled: ENABLED,
373
- opacity: OPACITY
374
+ opacity: OPACITY,
375
+ ...host.applyOptions
374
376
  },
375
377
  ["target", "effect"]
376
378
  ),
377
379
  annotations: { title: "Apply an effect", ...ANNOTATIONS.write },
378
380
  handler: async (args) => {
379
381
  writable();
380
- return explain(() => host.apply(args.target, args.effect, { values: args.values, index: args.index, enabled: args.enabled, opacity: args.opacity }));
382
+ return explain(() => host.apply(args.target, args.effect, { ...hostOptions(host.applyOptions, args), values: args.values, index: args.index, enabled: args.enabled, opacity: args.opacity }));
381
383
  }
382
384
  },
383
385
  {
@@ -391,15 +393,18 @@ function createEffectToolProvider(host) {
391
393
  values: { ...valuesSchema("Control values to change", true), description: `${valuesSchema("Control values to change", true).description} null resets a control to its default.` },
392
394
  enabled: ENABLED,
393
395
  opacity: OPACITY,
394
- index: { ...INDEX, description: `Move it to this place in the ${host.target.noun}'s stack (0 = applied first).` }
396
+ index: { ...INDEX, description: `Move it to this place in the ${host.target.noun}'s stack (0 = applied first).` },
397
+ ...host.updateOptions
395
398
  },
396
399
  ["target", "effect"]
397
400
  ),
398
401
  annotations: { title: "Change an applied effect", ...ANNOTATIONS.writeIdempotent },
399
402
  handler: async (args) => {
400
403
  writable();
401
- if (args.values === void 0 && args.enabled === void 0 && args.opacity === void 0 && args.index === void 0) throw new Error("Give at least one of values, enabled, opacity or index to change.");
402
- return explain(() => host.update(args.target, args.effect, { values: args.values, enabled: args.enabled, opacity: args.opacity, index: args.index }));
404
+ const options = hostOptions(host.updateOptions, args);
405
+ if (args.values === void 0 && args.enabled === void 0 && args.opacity === void 0 && args.index === void 0 && !Object.keys(options).length)
406
+ throw new Error(`Give at least one of ${["values", "enabled", "opacity", "index", ...Object.keys(_nullishCoalesce(host.updateOptions, () => ( {})))].join(", ")} to change.`);
407
+ return explain(() => host.update(args.target, args.effect, { ...options, values: args.values, enabled: args.enabled, opacity: args.opacity, index: args.index }));
403
408
  }
404
409
  },
405
410
  {
@@ -7,7 +7,7 @@ var _chunkPY4GWSE2cjs = require('./chunk-PY4GWSE2.cjs');
7
7
 
8
8
 
9
9
 
10
- var _chunkNTWR5TQBcjs = require('./chunk-NTWR5TQB.cjs');
10
+ var _chunkABQ2VGUBcjs = require('./chunk-ABQ2VGUB.cjs');
11
11
 
12
12
 
13
13
  var _chunkWOFXZ3XUcjs = require('./chunk-WOFXZ3XU.cjs');
@@ -1307,12 +1307,12 @@ function videoEffectLayerKey(layer, width, height) {
1307
1307
  }
1308
1308
  function mixEffectPixels(a, b, k) {
1309
1309
  if (k >= 1) return b;
1310
- const out = _chunkNTWR5TQBcjs.createEffectPixels.call(void 0, a.width, a.height);
1310
+ const out = _chunkABQ2VGUBcjs.createEffectPixels.call(void 0, a.width, a.height);
1311
1311
  for (let i = 0; i < out.data.length; i++) out.data[i] = a.data[i] + (b.data[i] - a.data[i]) * k;
1312
1312
  return out;
1313
1313
  }
1314
1314
  function overEffectPixels(base, top, opacity = 1) {
1315
- const out = _chunkNTWR5TQBcjs.createEffectPixels.call(void 0, base.width, base.height);
1315
+ const out = _chunkABQ2VGUBcjs.createEffectPixels.call(void 0, base.width, base.height);
1316
1316
  const o = out.data;
1317
1317
  const b = base.data;
1318
1318
  const t = top.data;
@@ -1357,7 +1357,7 @@ var VideoEffectsEngine = (_class2 = class {
1357
1357
  __init10() {this.generation = 0}
1358
1358
 
1359
1359
  constructor(options = {}) {;_class2.prototype.__init5.call(this);_class2.prototype.__init6.call(this);_class2.prototype.__init7.call(this);_class2.prototype.__init8.call(this);_class2.prototype.__init9.call(this);_class2.prototype.__init10.call(this);
1360
- this.slot = _nullishCoalesce(options.slot, () => ( new (0, _chunkNTWR5TQBcjs.EffectsSlot)()));
1360
+ this.slot = _nullishCoalesce(options.slot, () => ( new (0, _chunkABQ2VGUBcjs.EffectsSlot)()));
1361
1361
  this.maxEntries = _nullishCoalesce(options.maxEntries, () => ( 120));
1362
1362
  this.toImage = _nullishCoalesce(options.toImage, () => ( defaultToImage));
1363
1363
  this.pool = new (0, _chunkPY4GWSE2cjs.EffectRendererPool)({ maxRenderers: options.maxRenderers });
@@ -1499,7 +1499,7 @@ function checkVideoEffectPlace(d, place) {
1499
1499
  if (d.kind === "motion" || !d.uses.some((u) => allowed.includes(u))) {
1500
1500
  const where = place === "clip" ? "on a clip" : place === "transition" ? "as a transition" : "as an effect clip";
1501
1501
  const instead = d.uses.includes("transition") ? "set_video_effect_transition" : d.uses.some((u) => VIDEO_EFFECT_PLACES.generator.includes(u)) ? "add_video_effect_clip" : d.uses.some((u) => u === "filter") ? "apply_effect" : null;
1502
- throw new (0, _chunkNTWR5TQBcjs.EffectUnsupportedError)(
1502
+ throw new (0, _chunkABQ2VGUBcjs.EffectUnsupportedError)(
1503
1503
  `"${d.id}" (${d.name}) is a ${d.uses.join(" / ")} effect and cannot be used ${where}, which takes ${allowed.join(" or ")} effects${instead ? `; use ${instead} instead` : ""}. search_effects with use "${allowed[0]}" lists ones that fit.`,
1504
1504
  d.id
1505
1505
  );
@@ -1520,12 +1520,12 @@ function checkVideoEffectValues(d, values, options = {}) {
1520
1520
  else if (type !== "number" && type !== "integer") errors.push({ path: `/${k}`, message: "only number controls can be keyframed." });
1521
1521
  else for (const [i, key] of v.keys.entries()) for (const e of _chunkWOFXZ3XUcjs.validateJsonSchema.call(void 0, key.v, schema)) errors.push({ path: `/${k}/keys/${i}/v`, message: e.message });
1522
1522
  }
1523
- for (const e of _chunkNTWR5TQBcjs.effectValueErrors.call(void 0, d, plain)) {
1523
+ for (const e of _chunkABQ2VGUBcjs.effectValueErrors.call(void 0, d, plain)) {
1524
1524
  const name = e.path.split("/")[1];
1525
1525
  const about = name && _optionalChain([d, 'access', _46 => _46.controls, 'access', _47 => _47.properties, 'access', _48 => _48[name], 'optionalAccess', _49 => _49.description]);
1526
1526
  errors.push(about ? { path: e.path, message: `${e.message} (${about})` } : e);
1527
1527
  }
1528
- if (errors.length) throw new (0, _chunkNTWR5TQBcjs.EffectControlError)(d.id, errors);
1528
+ if (errors.length) throw new (0, _chunkABQ2VGUBcjs.EffectControlError)(d.id, errors);
1529
1529
  return { ..._nullishCoalesce(options.base, () => ( d.defaults)), ..._nullishCoalesce(values, () => ( {})) };
1530
1530
  }
1531
1531
 
@@ -4894,13 +4894,14 @@ function applySmartFilters(placed, stack, canvas) {
4894
4894
  let out2;
4895
4895
  if (f.kind === "effect") {
4896
4896
  if (incomplete) continue;
4897
- const inputKey = JSON.stringify([surfaceId(placed), W, H, active.slice(0, i + 1).map((x) => ({ ...x, id: void 0, blend: x === f ? void 0 : x.blend, opacity: x === f ? void 0 : x.opacity }))]);
4897
+ const inputKey = JSON.stringify([surfaceId(placed), W, H, active.slice(0, i + 1).map((x) => x === f ? { ...x, id: void 0, blend: void 0, opacity: void 0, preserveTransparency: void 0 } : { ...x, id: void 0 })]);
4898
4898
  const r = _optionalChain([canvas, 'access', _112 => _112.effects, 'optionalAccess', _113 => _113.resolve, 'call', _114 => _114(f, acc, W, H, inputKey)]);
4899
4899
  if (!_optionalChain([r, 'optionalAccess', _115 => _115.result])) {
4900
4900
  if (_optionalChain([r, 'optionalAccess', _116 => _116.pending])) incomplete = true;
4901
4901
  continue;
4902
4902
  }
4903
4903
  out2 = new Uint8ClampedArray(r.result);
4904
+ if (f.preserveTransparency) keepAlphaOf(out2, acc);
4904
4905
  } else {
4905
4906
  out2 = new Uint8ClampedArray(acc);
4906
4907
  runLayerFilters(out2, W, H, [f]);
@@ -4925,6 +4926,18 @@ function applySmartFilters(placed, stack, canvas) {
4925
4926
  if (incomplete) incompleteSurfaces.add(out);
4926
4927
  return out;
4927
4928
  }
4929
+ function keepAlphaOf(result, input) {
4930
+ for (let i = 0; i < result.length; i += 4) {
4931
+ const ia = input[i + 3];
4932
+ const ta = result[i + 3] / 255;
4933
+ if (ta < 1) {
4934
+ const ba = ia / 255;
4935
+ const a = ta + ba * (1 - ta);
4936
+ for (let c = 0; c < 3; c++) result[i + c] = a > 0 ? (result[i + c] * ta + input[i + c] * ba * (1 - ta)) / a : 0;
4937
+ }
4938
+ result[i + 3] = ia;
4939
+ }
4940
+ }
4928
4941
  function lerpInto(dst, src, k, coverage) {
4929
4942
  for (let i = 0, p = 0; i < dst.length; i += 4, p++) {
4930
4943
  const t = coverage ? k * coverage[p] : k;
@@ -5269,6 +5282,7 @@ function normalizeEffectSmartFilter(raw, id) {
5269
5282
  if (typeof raw.effect !== "string" || !raw.effect) fail4('An effect smart filter needs an "effect" id from search_effects.');
5270
5283
  const values = _nullishCoalesce(raw.values, () => ( {}));
5271
5284
  if (typeof values !== "object" || values === null || Array.isArray(values)) fail4('"values" must be an object of control values.');
5285
+ if (raw.preserveTransparency !== void 0 && typeof raw.preserveTransparency !== "boolean") fail4('"preserveTransparency" must be true or false.');
5272
5286
  return {
5273
5287
  id,
5274
5288
  kind: "effect",
@@ -5276,7 +5290,8 @@ function normalizeEffectSmartFilter(raw, id) {
5276
5290
  effect: raw.effect,
5277
5291
  ...typeof raw.provider === "string" ? { provider: raw.provider } : {},
5278
5292
  ...typeof raw.name === "string" ? { name: raw.name } : {},
5279
- values: { ...values }
5293
+ values: { ...values },
5294
+ ...typeof raw.preserveTransparency === "boolean" ? { preserveTransparency: raw.preserveTransparency } : {}
5280
5295
  };
5281
5296
  }
5282
5297
  function withStack(layer, stack, canvas) {
@@ -6097,7 +6112,7 @@ function readSmartFilters(raw, ctx, what) {
6097
6112
  if (base) filters.push({ ...base, blend, opacity });
6098
6113
  } else if (f.kind === "effect") {
6099
6114
  const ref = readEffectRef(f);
6100
- if (ref) filters.push({ id: typeof f.id === "string" ? f.id : newLayerId("flt"), kind: "effect", enabled: f.enabled !== false, ...ref, blend, opacity });
6115
+ if (ref) filters.push({ id: typeof f.id === "string" ? f.id : newLayerId("flt"), kind: "effect", enabled: f.enabled !== false, ...ref, ...typeof f.preserveTransparency === "boolean" ? { preserveTransparency: f.preserveTransparency } : {}, blend, opacity });
6101
6116
  else ctx.problems.push(`${what}: an effect smart filter without an effect id was left out`);
6102
6117
  }
6103
6118
  }