@pixerate/editor 0.24.0 → 0.26.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 (162) hide show
  1. package/README.md +101 -1
  2. package/THIRD_PARTY_NOTICES.md +40 -0
  3. package/dist/agent/index.cjs +175 -11
  4. package/dist/agent/index.cjs.map +1 -1
  5. package/dist/agent/index.d.cts +18 -4
  6. package/dist/agent/index.d.ts +18 -4
  7. package/dist/agent/index.js +168 -4
  8. package/dist/agent/index.js.map +1 -1
  9. package/dist/{arrangeShortcuts-B8O3f8-P.d.cts → arrange-BICutYPk.d.cts} +243 -29
  10. package/dist/{arrangeShortcuts-sLlD2rSX.d.ts → arrange-BICutYPk.d.ts} +243 -29
  11. package/dist/builtins-CdPcLwwF.d.cts +176 -0
  12. package/dist/builtins-Chj6zv_O.d.ts +176 -0
  13. package/dist/canvas/index.cjs +8588 -1857
  14. package/dist/canvas/index.cjs.map +1 -1
  15. package/dist/canvas/index.d.cts +1847 -9
  16. package/dist/canvas/index.d.ts +1847 -9
  17. package/dist/canvas/index.js +8577 -1846
  18. package/dist/canvas/index.js.map +1 -1
  19. package/dist/chunk-3CC7OPUQ.cjs +831 -0
  20. package/dist/chunk-3CC7OPUQ.cjs.map +1 -0
  21. package/dist/chunk-4BVP64JJ.cjs +1406 -0
  22. package/dist/chunk-4BVP64JJ.cjs.map +1 -0
  23. package/dist/chunk-BVP3TSLH.cjs +69 -0
  24. package/dist/chunk-BVP3TSLH.cjs.map +1 -0
  25. package/dist/{chunk-OLZJXL4R.cjs → chunk-CS6NZWWA.cjs} +59 -25
  26. package/dist/chunk-CS6NZWWA.cjs.map +1 -0
  27. package/dist/{chunk-MCSJFWAO.cjs → chunk-EWCOFSCQ.cjs} +685 -100
  28. package/dist/chunk-EWCOFSCQ.cjs.map +1 -0
  29. package/dist/chunk-HDYMLS3X.cjs +409 -0
  30. package/dist/chunk-HDYMLS3X.cjs.map +1 -0
  31. package/dist/chunk-HRMEDT2L.js +1406 -0
  32. package/dist/chunk-HRMEDT2L.js.map +1 -0
  33. package/dist/{chunk-D27YFC46.cjs → chunk-IFHKKVXH.cjs} +382 -63
  34. package/dist/chunk-IFHKKVXH.cjs.map +1 -0
  35. package/dist/{chunk-PGNZKFQS.js → chunk-JOIREKL7.js} +137 -58
  36. package/dist/chunk-JOIREKL7.js.map +1 -0
  37. package/dist/chunk-KRGXUQ2Y.js +1696 -0
  38. package/dist/chunk-KRGXUQ2Y.js.map +1 -0
  39. package/dist/{chunk-3LV6RRPH.js → chunk-MHEPLBFB.js} +2 -2
  40. package/dist/chunk-MR2764X2.js +831 -0
  41. package/dist/chunk-MR2764X2.js.map +1 -0
  42. package/dist/{chunk-XNORY7M6.cjs → chunk-NFVBT3UZ.cjs} +166 -87
  43. package/dist/chunk-NFVBT3UZ.cjs.map +1 -0
  44. package/dist/chunk-NQF32I6Z.cjs +6478 -0
  45. package/dist/chunk-NQF32I6Z.cjs.map +1 -0
  46. package/dist/chunk-O5RYH2PG.js +69 -0
  47. package/dist/chunk-O5RYH2PG.js.map +1 -0
  48. package/dist/{chunk-ITBSKI26.js → chunk-Q2OHWD2A.js} +1064 -360
  49. package/dist/chunk-Q2OHWD2A.js.map +1 -0
  50. package/dist/{chunk-FODNLX5N.js → chunk-QJSOZFCZ.js} +38 -4
  51. package/dist/chunk-QJSOZFCZ.js.map +1 -0
  52. package/dist/{chunk-SML64VJG.cjs → chunk-RRREAOVM.cjs} +4 -4
  53. package/dist/{chunk-SML64VJG.cjs.map → chunk-RRREAOVM.cjs.map} +1 -1
  54. package/dist/{chunk-5S3Z4PPF.js → chunk-SWE3NPOU.js} +347 -28
  55. package/dist/chunk-SWE3NPOU.js.map +1 -0
  56. package/dist/chunk-TXXNBDQX.cjs +1696 -0
  57. package/dist/chunk-TXXNBDQX.cjs.map +1 -0
  58. package/dist/chunk-UBCFIABU.js +409 -0
  59. package/dist/chunk-UBCFIABU.js.map +1 -0
  60. package/dist/chunk-X7HXL2SB.js +6478 -0
  61. package/dist/chunk-X7HXL2SB.js.map +1 -0
  62. package/dist/{chunk-SBCZ6RN5.cjs → chunk-YOMYSFJU.cjs} +1163 -459
  63. package/dist/chunk-YOMYSFJU.cjs.map +1 -0
  64. package/dist/{chunk-3CN2WD3X.js → chunk-ZRNHGAQT.js} +661 -76
  65. package/dist/chunk-ZRNHGAQT.js.map +1 -0
  66. package/dist/commands/index.cjs +425 -4
  67. package/dist/commands/index.cjs.map +1 -1
  68. package/dist/commands/index.d.cts +39 -77
  69. package/dist/commands/index.d.ts +39 -77
  70. package/dist/commands/index.js +424 -3
  71. package/dist/commands/index.js.map +1 -1
  72. package/dist/compare/index.cjs +3 -3
  73. package/dist/compare/index.d.cts +1 -1
  74. package/dist/compare/index.d.ts +1 -1
  75. package/dist/compare/index.js +2 -2
  76. package/dist/controller-CxXGOEmy.d.cts +2038 -0
  77. package/dist/controller-CxXGOEmy.d.ts +2038 -0
  78. package/dist/{documents-BQjzJNe2.d.ts → documents-CHT1U5Vs.d.ts} +10 -0
  79. package/dist/{documents-KRTPhvst.d.cts → documents-Gp7wb0Me.d.cts} +10 -0
  80. package/dist/export/index.cjs +36 -0
  81. package/dist/export/index.cjs.map +1 -0
  82. package/dist/export/index.d.cts +243 -0
  83. package/dist/export/index.d.ts +243 -0
  84. package/dist/export/index.js +36 -0
  85. package/dist/export/index.js.map +1 -0
  86. package/dist/extensions/index.cjs +101 -6
  87. package/dist/extensions/index.cjs.map +1 -1
  88. package/dist/extensions/index.d.cts +18 -5
  89. package/dist/extensions/index.d.ts +18 -5
  90. package/dist/extensions/index.js +101 -6
  91. package/dist/generation/index.cjs +1013 -69
  92. package/dist/generation/index.cjs.map +1 -1
  93. package/dist/generation/index.d.cts +474 -13
  94. package/dist/generation/index.d.ts +474 -13
  95. package/dist/generation/index.js +976 -32
  96. package/dist/generation/index.js.map +1 -1
  97. package/dist/image-editor/index.cjs +3385 -1275
  98. package/dist/image-editor/index.cjs.map +1 -1
  99. package/dist/image-editor/index.d.cts +693 -128
  100. package/dist/image-editor/index.d.ts +693 -128
  101. package/dist/image-editor/index.js +3325 -1215
  102. package/dist/image-editor/index.js.map +1 -1
  103. package/dist/{index-fJrlkJCd.d.ts → index-B273Zllk.d.ts} +500 -7
  104. package/dist/{index-BhJBSm2d.d.cts → index-jcJwmBYt.d.cts} +500 -7
  105. package/dist/index.cjs +1603 -45
  106. package/dist/index.cjs.map +1 -1
  107. package/dist/index.d.cts +154 -27
  108. package/dist/index.d.ts +154 -27
  109. package/dist/index.js +1584 -26
  110. package/dist/index.js.map +1 -1
  111. package/dist/mention-text-CDnCFd3c.d.cts +53 -0
  112. package/dist/mention-text-CDnCFd3c.d.ts +53 -0
  113. package/dist/model-C1zApQM8.d.cts +219 -0
  114. package/dist/model-C1zApQM8.d.ts +219 -0
  115. package/dist/persistence/index.d.cts +3 -120
  116. package/dist/persistence/index.d.ts +3 -120
  117. package/dist/registry-CED5C0lA.d.cts +204 -0
  118. package/dist/registry-CED5C0lA.d.ts +204 -0
  119. package/dist/{registry-GJI4gToU.d.cts → registry-CEgwXED1.d.cts} +12 -1
  120. package/dist/{registry-GJI4gToU.d.ts → registry-CEgwXED1.d.ts} +12 -1
  121. package/dist/{registry-D32LpIc4.d.cts → registry-D0GADKc7.d.cts} +1 -1
  122. package/dist/{registry-evKTP4ls.d.ts → registry-DhVUZioj.d.ts} +1 -1
  123. package/dist/serializers/index.cjs +12 -4
  124. package/dist/serializers/index.cjs.map +1 -1
  125. package/dist/serializers/index.d.cts +41 -13
  126. package/dist/serializers/index.d.ts +41 -13
  127. package/dist/serializers/index.js +12 -4
  128. package/dist/spreadsheet/index.cjs +157 -3
  129. package/dist/spreadsheet/index.cjs.map +1 -1
  130. package/dist/spreadsheet/index.d.cts +534 -11
  131. package/dist/spreadsheet/index.d.ts +534 -11
  132. package/dist/spreadsheet/index.js +157 -3
  133. package/dist/storage-BpFfspHm.d.cts +120 -0
  134. package/dist/storage-BpFfspHm.d.ts +120 -0
  135. package/dist/tokens/index.cjs +115 -0
  136. package/dist/tokens/index.cjs.map +1 -0
  137. package/dist/tokens/index.d.cts +212 -0
  138. package/dist/tokens/index.d.ts +212 -0
  139. package/dist/tokens/index.js +115 -0
  140. package/dist/tokens/index.js.map +1 -0
  141. package/dist/{track-changes-BK5sVf4_.d.cts → track-changes-D_VAPELi.d.cts} +95 -11
  142. package/dist/{track-changes-CDjCrwKe.d.ts → track-changes-Db_fGEvx.d.ts} +95 -11
  143. package/package.json +15 -1
  144. package/dist/chunk-3CN2WD3X.js.map +0 -1
  145. package/dist/chunk-5S3Z4PPF.js.map +0 -1
  146. package/dist/chunk-D27YFC46.cjs.map +0 -1
  147. package/dist/chunk-FODNLX5N.js.map +0 -1
  148. package/dist/chunk-ITBSKI26.js.map +0 -1
  149. package/dist/chunk-MA2F5KHF.cjs +0 -3223
  150. package/dist/chunk-MA2F5KHF.cjs.map +0 -1
  151. package/dist/chunk-MCSJFWAO.cjs.map +0 -1
  152. package/dist/chunk-OLZJXL4R.cjs.map +0 -1
  153. package/dist/chunk-PGNZKFQS.js.map +0 -1
  154. package/dist/chunk-SBCZ6RN5.cjs.map +0 -1
  155. package/dist/chunk-U5KWZU4X.js +0 -3223
  156. package/dist/chunk-U5KWZU4X.js.map +0 -1
  157. package/dist/chunk-XNORY7M6.cjs.map +0 -1
  158. package/dist/controller-BhLLAoi8.d.cts +0 -1000
  159. package/dist/controller-BhLLAoi8.d.ts +0 -1000
  160. package/dist/types-DX4Mh4SL.d.cts +0 -217
  161. package/dist/types-DX4Mh4SL.d.ts +0 -217
  162. /package/dist/{chunk-3LV6RRPH.js.map → chunk-MHEPLBFB.js.map} +0 -0
@@ -1,10 +1,10 @@
1
- import { C as CommandRegistry, P as Platform, a as CommandResult, b as CommandEntry, K as KeyboardEventLike, S as ShortcutBinding, c as CommandSpec } from '../registry-evKTP4ls.js';
2
- export { d as Chord, e as CommandErrorCode, f as CommandHistoryTarget, g as CommandListOptions, h as CommandParamsSchema, i as CommandRegistryError, j as CommandRegistryOptions, E as EffectiveChord, k as PLATFORMS, l as ShortcutConflict, m as ShortcutInput, n as ShortcutMap, o as ShortcutMapOptions, p as ShortcutMatch, q as ShortcutResolveOptions, r as chordToString, s as codeFromKey, t as codeToKeyText, u as createCommandRegistry, v as defineCommand, w as detectPlatform, x as effectiveChord, y as effectiveChordKey, z as eventCode, A as formatShortcut, B as isEditableEventTarget, D as keyToCode, F as normalizeChord, G as parseChord, H as shortcutCode, I as toShortcutBindings } from '../registry-evKTP4ls.js';
1
+ import { a as CommandRegistry, P as Platform, b as CommandResult, c as CommandEntry, K as KeyboardEventLike, C as CommandSpec } from '../registry-DhVUZioj.js';
2
+ export { d as Chord, e as CommandErrorCode, f as CommandHistoryTarget, g as CommandListOptions, h as CommandParamsSchema, i as CommandRegistryError, j as CommandRegistryOptions, E as EffectiveChord, k as PLATFORMS, S as ShortcutBinding, l as ShortcutConflict, m as ShortcutInput, n as ShortcutMap, o as ShortcutMapOptions, p as ShortcutMatch, q as ShortcutResolveOptions, r as chordToString, s as codeFromKey, t as codeToKeyText, u as createCommandRegistry, v as defineCommand, w as detectPlatform, x as effectiveChord, y as effectiveChordKey, z as eventCode, A as formatShortcut, B as isEditableEventTarget, D as keyToCode, F as normalizeChord, G as parseChord, H as shortcutCode, I as toShortcutBindings } from '../registry-DhVUZioj.js';
3
3
  import { A as AgentToolProvider } from '../registry-BDe-vlv3.js';
4
- import { H as HistoryState } from '../types-GT5a5YAX.js';
5
- import { C as CanvasArrangeAction, A as AlignEdge, D as DistributeAxis, a as DistributeMode, Z as ZOrderOperation } from '../arrangeShortcuts-sLlD2rSX.js';
4
+ export { A as ArrangeCommandOptions, a as ArrangeCommandTarget, C as ComponentCommandOptions, b as ComponentCommandTarget, D as DEFAULT_HISTORY_SHORTCUTS, H as HistoryCommandOptions, c as HistoryCommandTarget, S as ShapeCommandOptions, d as ShapeCommandTarget, e as SpreadsheetCommandOptions, f as SpreadsheetCommandTarget, g as createArrangeCommands, h as createComponentCommands, i as createHistoryCommands, j as createShapeCommands, k as createSpreadsheetCommands, m as matchHistoryShortcut } from '../builtins-Chj6zv_O.js';
6
5
  import '../schema-DYDGdYL9.js';
7
- import '../types-DX4Mh4SL.js';
6
+ import '../types-GT5a5YAX.js';
7
+ import '../arrange-BICutYPk.js';
8
8
 
9
9
  /** The fields `rankCommands` searches (a `CommandEntry` satisfies it). */
10
10
  interface RankableCommand {
@@ -160,85 +160,47 @@ interface CommandToolProviderOptions<TContext = any> {
160
160
  */
161
161
  declare function createCommandToolProvider<TContext = any>(registry: CommandRegistry<TContext>, options?: CommandToolProviderOptions<TContext>): AgentToolProvider;
162
162
 
163
- /** Minimal history surface (`HistoryManager` satisfies it). */
164
- interface HistoryCommandTarget {
165
- undo(): boolean | void;
166
- redo(): boolean | void;
167
- getState(): Pick<HistoryState, 'canUndo' | 'canRedo'> & Partial<Pick<HistoryState, 'undoName' | 'redoName'>>;
168
- }
169
- /** Default history bindings: `Mod+Z` undo; `Mod+Shift+Z` redo, plus `Mod+Y` off macOS. */
170
- declare const DEFAULT_HISTORY_SHORTCUTS: readonly ShortcutBinding[];
171
- interface HistoryCommandOptions {
172
- /** Id prefix (default `history.`). */
173
- prefix?: string;
174
- group?: string;
175
- scope?: string;
176
- }
177
- /** `history.undo` / `history.redo` commands for a `HistoryManager` (disabled with a reason when empty). */
178
- declare function createHistoryCommands(history: HistoryCommandTarget, options?: HistoryCommandOptions): CommandSpec[];
179
163
  /**
180
- * Resolves a keydown event to `undo` / `redo` with the default history bindings
181
- * (`Mod` is ⌘ on macOS and Ctrl elsewhere). Events from text inputs and
182
- * contenteditable elements are ignored unless `allowInEditable`.
164
+ * Animation controller surface used by `createCanvasAnimationCommands`
165
+ * (`createCanvasAnimationController`, `useCanvasAnimation` and `createCanvasAnimation` satisfy it).
183
166
  */
184
- declare function matchHistoryShortcut(event: KeyboardEventLike, options?: {
185
- platform?: Platform;
186
- allowInEditable?: boolean;
187
- }): 'undo' | 'redo' | null;
188
- /** Minimal arrange controller surface (`createCanvasArrangeController` satisfies it). */
189
- interface ArrangeCommandTarget {
190
- align(edge: AlignEdge, ids?: Iterable<string>): unknown;
191
- distribute(axis: DistributeAxis, mode?: DistributeMode, ids?: Iterable<string>): unknown;
192
- reorder(operation: ZOrderOperation, ids?: Iterable<string>): unknown;
193
- lock(ids?: Iterable<string>): unknown;
194
- unlock(ids?: Iterable<string>): unknown;
167
+ interface AnimationCommandTarget {
168
+ getState(): {
169
+ playing: boolean;
170
+ recording: boolean;
171
+ time: number;
172
+ duration: number;
173
+ selection: readonly unknown[];
174
+ };
175
+ play(): void;
176
+ pause(): void;
177
+ toggle(): void;
178
+ stop(): void;
179
+ seek(time: number): void;
180
+ toggleRecording(): void;
181
+ addKeyframe(ids?: Iterable<string>, keys?: readonly string[], time?: number): unknown;
182
+ deleteKeyframes(): unknown;
183
+ setEasing(easing: any, refs?: readonly any[]): unknown;
184
+ nextKeyframe(): unknown;
185
+ previousKeyframe(): unknown;
186
+ animateNode(nodeId: string, options: any): unknown;
187
+ exportCss(nodeId: string, options?: any): {
188
+ css: string;
189
+ exact: boolean;
190
+ };
195
191
  }
196
- interface ArrangeCommandOptions {
197
- /** Id prefix (default `canvas.`). */
192
+ interface AnimationCommandOptions {
193
+ /** Id prefix (default `canvas.animation.`). */
198
194
  prefix?: string;
199
195
  group?: string;
200
- /** Scope of the commands and their shortcuts (default `canvas`). Pass `null` for global. */
196
+ /** Scope (default `canvas`). Pass `null` for global. */
201
197
  scope?: string | null;
202
- /** Current selection, used for enablement ("Select at least two nodes"). */
203
- getSelectedIds?: () => string[];
204
- /** Scene navigation (`nextScene` / `previousScene`); those commands are only added when given. */
205
- scenes?: {
206
- next(): unknown;
207
- previous(): unknown;
208
- };
209
- /** Use these bindings instead of `DEFAULT_ARRANGE_SHORTCUTS`. */
210
- bindings?: readonly {
211
- action: CanvasArrangeAction;
212
- label: string;
213
- }[];
214
198
  }
215
199
  /**
216
- * Commands for the canvas arrange actions (`canvas.alignLeft`, `canvas.bringToFront`, …)
217
- * with the default arrange shortcuts. Each accepts `{ ids? }`; enablement checks the
218
- * named ids, or the selection when none are named.
200
+ * Palette / shortcut / agent commands for canvas animation: play / pause, seek, add keyframe at
201
+ * the playhead, delete keyframes, set easing, record toggle, keyframe navigation, "animate
202
+ * node from A to B over T" and CSS export. Edits are undoable when the controller has a history.
219
203
  */
220
- declare function createArrangeCommands(controller: ArrangeCommandTarget, options?: ArrangeCommandOptions): CommandSpec[];
221
- /** Spreadsheet controller surface used by `createSpreadsheetCommands`. */
222
- interface SpreadsheetCommandTarget {
223
- selectedRange: unknown;
224
- getFilterState(): {
225
- enabled: boolean;
226
- rules: readonly unknown[];
227
- };
228
- toggleFilters(): void;
229
- clearFilters(): void;
230
- unhideAll(): void;
231
- mergeCells(): boolean;
232
- unmergeCells(): boolean;
233
- transposeRange(): boolean;
234
- }
235
- interface SpreadsheetCommandOptions {
236
- /** Id prefix (default `spreadsheet.`). */
237
- prefix?: string;
238
- /** Scope (default `spreadsheet`). Pass `null` for global. */
239
- scope?: string | null;
240
- }
241
- /** Palette / agent commands for common spreadsheet table actions (no default shortcuts). */
242
- declare function createSpreadsheetCommands(controller: SpreadsheetCommandTarget, options?: SpreadsheetCommandOptions): CommandSpec[];
204
+ declare function createCanvasAnimationCommands(controller: AnimationCommandTarget, options?: AnimationCommandOptions): CommandSpec[];
243
205
 
244
- export { type ArrangeCommandOptions, type ArrangeCommandTarget, CommandEntry, type CommandPaletteController, type CommandPaletteItem, type CommandPaletteOptions, type CommandPaletteState, CommandRegistry, CommandResult, CommandSpec, type CommandToolProviderOptions, DEFAULT_HISTORY_SHORTCUTS, DEFAULT_RECENT_LIMIT, type FuzzyMatch, type HistoryCommandOptions, type HistoryCommandTarget, KeyboardEventLike, Platform, type RankCommandsOptions, type RankableCommand, type RankedCommand, ShortcutBinding, type SpreadsheetCommandOptions, type SpreadsheetCommandTarget, createArrangeCommands, createCommandPaletteController, createCommandToolProvider, createHistoryCommands, createSpreadsheetCommands, exactBonus, fuzzyMatch, fuzzyScore, matchHistoryShortcut, matchPaletteHotkey, pushRecent, rankCommands };
206
+ export { type AnimationCommandOptions, type AnimationCommandTarget, CommandEntry, type CommandPaletteController, type CommandPaletteItem, type CommandPaletteOptions, type CommandPaletteState, CommandRegistry, CommandResult, CommandSpec, type CommandToolProviderOptions, DEFAULT_RECENT_LIMIT, type FuzzyMatch, KeyboardEventLike, Platform, type RankCommandsOptions, type RankableCommand, type RankedCommand, createCanvasAnimationCommands, createCommandPaletteController, createCommandToolProvider, exactBonus, fuzzyMatch, fuzzyScore, matchPaletteHotkey, pushRecent, rankCommands };
@@ -239,10 +239,10 @@ var CommandRegistry = class {
239
239
  }
240
240
  /** Like `execute`, but awaits async commands (rejections become `failed` results). */
241
241
  async executeAsync(id, params, context = this.context) {
242
- const outcome = this.execute(id, params, context);
243
- if (!outcome.ok || !isThenable(outcome.result)) return outcome;
242
+ const outcome2 = this.execute(id, params, context);
243
+ if (!outcome2.ok || !isThenable(outcome2.result)) return outcome2;
244
244
  try {
245
- const result = await outcome.result;
245
+ const result = await outcome2.result;
246
246
  this.notify();
247
247
  return { ok: true, id, result };
248
248
  } catch (error) {
@@ -800,6 +800,254 @@ function createArrangeCommands(controller, options = {}) {
800
800
  };
801
801
  });
802
802
  }
803
+ var SHAPE_COMMANDS = [
804
+ { op: "unite", label: "Unite Shapes", keywords: ["union", "merge", "boolean", "combine"] },
805
+ { op: "intersect", label: "Intersect Shapes", keywords: ["intersection", "boolean", "combine"] },
806
+ { op: "subtract", label: "Subtract Shapes", keywords: ["difference", "minus front", "boolean", "combine"] },
807
+ { op: "exclude", label: "Exclude Shapes", keywords: ["xor", "boolean", "combine"] },
808
+ { op: "divide", label: "Divide Shapes", keywords: ["split", "pathfinder", "boolean"] }
809
+ ];
810
+ var JOIN_PARAM = { type: "string", enum: ["miter", "round", "bevel"], description: "Corner style (default miter)." };
811
+ function createShapeCommands(controller, options = {}) {
812
+ const prefix = options.prefix ?? "canvas.";
813
+ const group = options.group ?? "Shape";
814
+ const scope = options.scope === null ? void 0 : options.scope ?? "canvas";
815
+ const base = { group, ...scope ? { scope } : {} };
816
+ const combine = SHAPE_COMMANDS.map(
817
+ ({ op, label, keywords }) => ({
818
+ ...base,
819
+ id: `${prefix}${op}`,
820
+ label,
821
+ keywords: [...keywords],
822
+ description: `${label.split(" ")[0]}s the selected shapes into a new path (curves are kept).`,
823
+ params: IDS_PARAMS,
824
+ enabled: (_ctx, params) => controller.canCombineShapes(params?.ids) ? true : "Select at least two unlocked shapes.",
825
+ run: (_ctx, params) => controller.combineShapes(op, params?.ids)
826
+ })
827
+ );
828
+ return [
829
+ ...combine,
830
+ {
831
+ ...base,
832
+ id: `${prefix}offsetPath`,
833
+ label: "Offset Path\u2026",
834
+ keywords: ["inset", "outset", "grow", "shrink", "expand", "contract"],
835
+ description: "Grows (positive distance) or shrinks (negative) the selected shapes.",
836
+ params: {
837
+ type: "object",
838
+ properties: {
839
+ distance: { type: "number", description: `Offset in canvas units (default ${options.defaultOffset ?? 10}).` },
840
+ join: JOIN_PARAM,
841
+ miterLimit: { type: "number", description: "Miter limit (default 4)." },
842
+ ids: IDS_PARAMS.properties.ids
843
+ }
844
+ },
845
+ enabled: (_ctx, params) => controller.canOffsetShapes(params?.ids) ? true : "Select an unlocked shape.",
846
+ run: (_ctx, params) => controller.offsetShapes(params?.distance ?? options.defaultOffset ?? 10, params?.ids, {
847
+ ...params?.join ? { join: params.join } : {},
848
+ ...params?.miterLimit !== void 0 ? { miterLimit: params.miterLimit } : {}
849
+ })
850
+ },
851
+ {
852
+ ...base,
853
+ id: `${prefix}outlineStroke`,
854
+ label: "Outline Stroke",
855
+ keywords: ["expand stroke", "stroke to path", "convert stroke"],
856
+ description: "Converts the strokes of the selected shapes to filled shapes.",
857
+ params: {
858
+ type: "object",
859
+ properties: {
860
+ join: JOIN_PARAM,
861
+ cap: { type: "string", enum: ["butt", "round", "square"], description: "Line cap (default butt)." },
862
+ miterLimit: { type: "number", description: "Miter limit (default 4)." },
863
+ ids: IDS_PARAMS.properties.ids
864
+ }
865
+ },
866
+ enabled: (_ctx, params) => controller.canOutlineStroke(params?.ids) ? true : "Select an unlocked shape with a stroke.",
867
+ run: (_ctx, params) => controller.outlineStroke(params?.ids, {
868
+ ...params?.join ? { join: params.join } : {},
869
+ ...params?.cap ? { cap: params.cap } : {},
870
+ ...params?.miterLimit !== void 0 ? { miterLimit: params.miterLimit } : {}
871
+ })
872
+ }
873
+ ];
874
+ }
875
+ var outcome = (result) => {
876
+ if (!result.ok) throw new Error(result.reason);
877
+ return { ids: result.ids };
878
+ };
879
+ var ID_PARAM = { type: "string", description: "Instance (or layer inside one) to act on (default: the first selected node)." };
880
+ function createComponentCommands(controller, options = {}) {
881
+ const prefix = options.prefix ?? "canvas.";
882
+ const group = options.group ?? "Components";
883
+ const scope = options.scope === null ? void 0 : options.scope ?? "canvas";
884
+ const base = { group, ...scope ? { scope } : {} };
885
+ const idParams = { type: "object", properties: { id: ID_PARAM } };
886
+ return [
887
+ {
888
+ ...base,
889
+ id: `${prefix}createComponent`,
890
+ label: "Create Component",
891
+ keywords: ["component", "symbol", "main component", "reusable"],
892
+ description: "Turns the selected frame into a main component, or wraps the selection in one.",
893
+ params: IDS_PARAMS,
894
+ shortcut: "Mod+Alt+K",
895
+ enabled: (_ctx, params) => controller.canCreateComponent(params?.ids),
896
+ run: (_ctx, params) => outcome(controller.createComponent(params?.ids))
897
+ },
898
+ {
899
+ ...base,
900
+ id: `${prefix}combineAsVariants`,
901
+ label: "Combine as Variants",
902
+ keywords: ["component set", "variant", "variants"],
903
+ description: "Wraps the selected components in a component set.",
904
+ params: IDS_PARAMS,
905
+ enabled: (_ctx, params) => controller.canCombineAsVariants(params?.ids),
906
+ run: (_ctx, params) => outcome(controller.combineAsVariants(params?.ids))
907
+ },
908
+ {
909
+ ...base,
910
+ id: `${prefix}createInstance`,
911
+ label: "Create Instance",
912
+ keywords: ["instance", "insert component", "use component"],
913
+ description: "Places an instance of a component (or a component set\u2019s default variant).",
914
+ params: {
915
+ type: "object",
916
+ properties: {
917
+ componentId: { type: "string", description: "Component or component set id." },
918
+ parentId: { type: "string", description: "Frame to place it in (default: the canvas)." },
919
+ x: { type: "number", description: "X in the parent\u2019s space (default: next to the main)." },
920
+ y: { type: "number", description: "Y in the parent\u2019s space." },
921
+ properties: { type: "object", description: "Variant and component property values.", additionalProperties: true }
922
+ },
923
+ required: ["componentId"]
924
+ },
925
+ enabled: (_ctx, params) => params?.componentId === void 0 ? true : controller.canCreateInstance(params.componentId, params.parentId),
926
+ run: (_ctx, params) => outcome(
927
+ controller.createInstance(params.componentId, {
928
+ ...params.parentId !== void 0 ? { parentId: params.parentId } : {},
929
+ ...params.x !== void 0 || params.y !== void 0 ? { position: { x: params.x ?? 0, y: params.y ?? 0 } } : {},
930
+ ...params.properties ? { properties: params.properties } : {}
931
+ })
932
+ )
933
+ },
934
+ {
935
+ ...base,
936
+ id: `${prefix}detachInstance`,
937
+ label: "Detach Instance",
938
+ keywords: ["unlink", "break instance"],
939
+ description: "Turns the selected instances into plain frames that keep their look.",
940
+ params: IDS_PARAMS,
941
+ shortcut: "Mod+Alt+B",
942
+ enabled: (_ctx, params) => controller.canDetachInstance(params?.ids),
943
+ run: (_ctx, params) => outcome(controller.detachInstance(params?.ids))
944
+ },
945
+ {
946
+ ...base,
947
+ id: `${prefix}resetOverrides`,
948
+ label: "Reset All Changes",
949
+ keywords: ["reset instance", "reset overrides", "revert"],
950
+ description: "Resets the overrides of an instance (or of a layer, or one override group) to its main.",
951
+ params: {
952
+ type: "object",
953
+ properties: {
954
+ id: ID_PARAM,
955
+ group: { type: "string", description: 'One override group to reset, e.g. "data.label" or "shape.fill" (default: all).' }
956
+ }
957
+ },
958
+ enabled: (_ctx, params) => controller.canResetOverrides(params?.id),
959
+ run: (_ctx, params) => outcome(controller.resetOverrides(params?.id, params?.group))
960
+ },
961
+ {
962
+ ...base,
963
+ id: `${prefix}pushOverrides`,
964
+ label: "Push Changes to Main Component",
965
+ keywords: ["push overrides", "update main component"],
966
+ description: "Copies the instance\u2019s overrides to its main component and every other instance.",
967
+ params: idParams,
968
+ enabled: (_ctx, params) => controller.canPushOverrides(params?.id),
969
+ run: (_ctx, params) => outcome(controller.pushOverrides(params?.id))
970
+ },
971
+ {
972
+ ...base,
973
+ id: `${prefix}goToMainComponent`,
974
+ label: "Go to Main Component",
975
+ keywords: ["main component", "find main", "reveal"],
976
+ description: "Selects the main component of the selected instance.",
977
+ params: idParams,
978
+ enabled: (_ctx, params) => controller.canGoToMainComponent(params?.id),
979
+ run: (_ctx, params) => {
980
+ const main = controller.goToMainComponent(params?.id);
981
+ if (!main) throw new Error("The main component was not found.");
982
+ return { id: main };
983
+ }
984
+ },
985
+ {
986
+ ...base,
987
+ id: `${prefix}swapInstance`,
988
+ label: "Swap Instance\u2026",
989
+ keywords: ["replace instance", "swap component"],
990
+ description: "Makes the selected instances show another component, keeping matching overrides.",
991
+ params: {
992
+ type: "object",
993
+ properties: {
994
+ componentId: { type: "string", description: "Component or component set to swap to." },
995
+ ids: IDS_PARAMS.properties.ids
996
+ },
997
+ required: ["componentId"]
998
+ },
999
+ enabled: (_ctx, params) => controller.canSwapInstance(params?.componentId, params?.ids),
1000
+ run: (_ctx, params) => outcome(controller.swapInstance(params.componentId, params?.ids))
1001
+ },
1002
+ {
1003
+ ...base,
1004
+ id: `${prefix}setInstanceProperties`,
1005
+ label: "Set Instance Properties\u2026",
1006
+ keywords: ["variant", "switch variant", "component property", "toggle"],
1007
+ description: "Sets variant properties (switching variants) and component property values of the selected instances.",
1008
+ params: {
1009
+ type: "object",
1010
+ properties: {
1011
+ properties: { type: "object", description: "Property name \u2192 value (variant value, boolean, text or component id).", additionalProperties: true },
1012
+ ids: IDS_PARAMS.properties.ids
1013
+ },
1014
+ required: ["properties"]
1015
+ },
1016
+ enabled: (_ctx, params) => controller.canSetInstanceProperties(params?.ids),
1017
+ run: (_ctx, params) => outcome(controller.setInstanceProperties(params.properties, params?.ids))
1018
+ },
1019
+ {
1020
+ ...base,
1021
+ id: `${prefix}restoreMainComponent`,
1022
+ label: "Restore Main Component",
1023
+ keywords: ["missing main", "recover component"],
1024
+ description: "Turns an instance whose main was deleted back into the main component.",
1025
+ params: idParams,
1026
+ enabled: (_ctx, params) => controller.canRestoreMainComponent(params?.id),
1027
+ run: (_ctx, params) => outcome(controller.restoreMainComponent(params?.id))
1028
+ },
1029
+ {
1030
+ ...base,
1031
+ id: `${prefix}listComponents`,
1032
+ label: "List Components",
1033
+ keywords: ["components", "variants", "assets"],
1034
+ description: "Lists the components and component sets (with their variant options).",
1035
+ readOnly: true,
1036
+ run: () => controller.list()
1037
+ },
1038
+ {
1039
+ ...base,
1040
+ id: `${prefix}inspectInstance`,
1041
+ label: "Inspect Instance",
1042
+ keywords: ["instance", "overrides", "properties"],
1043
+ description: "Describes an instance: its main, variant, property values and overrides.",
1044
+ params: idParams,
1045
+ readOnly: true,
1046
+ enabled: (_ctx, params) => controller.inspect(params?.id) ? true : "Select an instance.",
1047
+ run: (_ctx, params) => controller.inspect(params?.id) ?? null
1048
+ }
1049
+ ];
1050
+ }
803
1051
  function createSpreadsheetCommands(controller, options = {}) {
804
1052
  const prefix = options.prefix ?? "spreadsheet.";
805
1053
  const scope = options.scope === null ? void 0 : options.scope ?? "spreadsheet";
@@ -821,6 +1069,176 @@ function createSpreadsheetCommands(controller, options = {}) {
821
1069
  { ...base, id: `${prefix}transposeRange`, label: "Transpose Range", keywords: ["rotate", "swap rows columns"], enabled: hasRange, run: () => controller.transposeRange() }
822
1070
  ];
823
1071
  }
1072
+
1073
+ // src/commands/animation.ts
1074
+ var EASING_DESCRIPTION = "Easing preset (linear, ease, ease-in, ease-out, ease-in-out, ease-in-back, ease-out-back, spring, hold) or a CSS cubic-bezier(x1, y1, x2, y2).";
1075
+ var VALUES = {
1076
+ type: "object",
1077
+ description: 'Property \u2192 value, e.g. {"x": 200, "opacity": 0.5, "fill": "#ff0000"}. Properties: x, y, width, height, rotation (degrees), scale, opacity (0\u20131), fill, stroke, strokeWidth, cornerRadius, motionPath (0\u20131).',
1078
+ additionalProperties: { type: ["number", "string"] }
1079
+ };
1080
+ function createCanvasAnimationCommands(controller, options = {}) {
1081
+ const prefix = options.prefix ?? "canvas.animation.";
1082
+ const group = options.group ?? "Animation";
1083
+ const scope = options.scope === null ? void 0 : options.scope ?? "canvas";
1084
+ const base = { group, ...scope ? { scope } : {} };
1085
+ const hasSelection = () => controller.getState().selection.length > 0 ? true : "Select keyframes first.";
1086
+ return [
1087
+ {
1088
+ ...base,
1089
+ id: `${prefix}togglePlay`,
1090
+ label: "Play / Pause Animation",
1091
+ keywords: ["play", "pause", "preview", "timeline"],
1092
+ description: "Plays or pauses the canvas animation from the playhead.",
1093
+ run: () => {
1094
+ controller.toggle();
1095
+ return { playing: controller.getState().playing, time: controller.getState().time };
1096
+ }
1097
+ },
1098
+ {
1099
+ ...base,
1100
+ id: `${prefix}play`,
1101
+ label: "Play Animation",
1102
+ keywords: ["preview", "timeline"],
1103
+ enabled: () => controller.getState().playing ? "Already playing." : true,
1104
+ run: () => controller.play()
1105
+ },
1106
+ {
1107
+ ...base,
1108
+ id: `${prefix}pause`,
1109
+ label: "Pause Animation",
1110
+ enabled: () => controller.getState().playing ? true : "Not playing.",
1111
+ run: () => controller.pause()
1112
+ },
1113
+ {
1114
+ ...base,
1115
+ id: `${prefix}stop`,
1116
+ label: "Stop Animation",
1117
+ keywords: ["rewind", "reset"],
1118
+ description: "Stops playback and returns to the start.",
1119
+ run: () => controller.stop()
1120
+ },
1121
+ {
1122
+ ...base,
1123
+ id: `${prefix}seek`,
1124
+ label: "Go to Time\u2026",
1125
+ keywords: ["playhead", "scrub", "time"],
1126
+ description: "Moves the playhead.",
1127
+ params: {
1128
+ type: "object",
1129
+ properties: { time: { type: "number", minimum: 0, description: "Time in milliseconds." } },
1130
+ required: ["time"]
1131
+ },
1132
+ run: (_ctx, params) => {
1133
+ controller.seek(params.time);
1134
+ return { time: controller.getState().time };
1135
+ }
1136
+ },
1137
+ {
1138
+ ...base,
1139
+ id: `${prefix}addKeyframe`,
1140
+ label: "Add Keyframe at Playhead",
1141
+ keywords: ["key", "animate", "record"],
1142
+ description: "Keys the selected nodes (or `ids`) at the playhead (or `time`): their animated properties, `properties`, or position.",
1143
+ params: {
1144
+ type: "object",
1145
+ properties: {
1146
+ ids: { type: "array", items: { type: "string" }, description: "Node ids (default: selected nodes)." },
1147
+ properties: { type: "array", items: { type: "string" }, description: "Properties to key (default: animated ones, or x and y)." },
1148
+ time: { type: "number", minimum: 0, description: "Time in ms (default: the playhead)." }
1149
+ }
1150
+ },
1151
+ run: (_ctx, params) => controller.addKeyframe(params?.ids, params?.properties, params?.time)
1152
+ },
1153
+ {
1154
+ ...base,
1155
+ id: `${prefix}deleteKeyframes`,
1156
+ label: "Delete Keyframes",
1157
+ keywords: ["remove", "clear"],
1158
+ enabled: hasSelection,
1159
+ run: () => controller.deleteKeyframes()
1160
+ },
1161
+ {
1162
+ ...base,
1163
+ id: `${prefix}setEasing`,
1164
+ label: "Set Keyframe Easing\u2026",
1165
+ keywords: ["interpolation", "ease", "bezier", "spring", "hold", "curve"],
1166
+ description: "Sets the easing of the segments leaving the selected keyframes.",
1167
+ params: {
1168
+ type: "object",
1169
+ properties: { easing: { type: "string", description: EASING_DESCRIPTION } },
1170
+ required: ["easing"]
1171
+ },
1172
+ enabled: hasSelection,
1173
+ run: (_ctx, params) => controller.setEasing(params.easing)
1174
+ },
1175
+ {
1176
+ ...base,
1177
+ id: `${prefix}toggleRecord`,
1178
+ label: "Toggle Record Mode",
1179
+ keywords: ["auto key", "record", "keyframe"],
1180
+ description: "In record mode, changing a property at the playhead keys it.",
1181
+ run: () => {
1182
+ controller.toggleRecording();
1183
+ return { recording: controller.getState().recording };
1184
+ }
1185
+ },
1186
+ {
1187
+ ...base,
1188
+ id: `${prefix}nextKeyframe`,
1189
+ label: "Next Keyframe",
1190
+ keywords: ["jump", "navigate"],
1191
+ run: () => controller.nextKeyframe()
1192
+ },
1193
+ {
1194
+ ...base,
1195
+ id: `${prefix}previousKeyframe`,
1196
+ label: "Previous Keyframe",
1197
+ keywords: ["jump", "navigate"],
1198
+ run: () => controller.previousKeyframe()
1199
+ },
1200
+ {
1201
+ ...base,
1202
+ id: `${prefix}animateNode`,
1203
+ label: "Animate Node\u2026",
1204
+ keywords: ["tween", "transition", "move", "fade"],
1205
+ description: "Animates a node from `from` (default: its current values) to `to` over `duration` ms, starting at `delay` ms.",
1206
+ params: {
1207
+ type: "object",
1208
+ properties: {
1209
+ nodeId: { type: "string", description: "Node to animate." },
1210
+ to: VALUES,
1211
+ from: VALUES,
1212
+ duration: { type: "number", exclusiveMinimum: 0, description: "Duration in ms (default 1000)." },
1213
+ delay: { type: "number", minimum: 0, description: "Start time in ms (default 0)." },
1214
+ easing: { type: "string", description: EASING_DESCRIPTION }
1215
+ },
1216
+ required: ["nodeId", "to"]
1217
+ },
1218
+ run: (_ctx, params) => controller.animateNode(params.nodeId, {
1219
+ to: params.to,
1220
+ ...params.from ? { from: params.from } : {},
1221
+ ...params.duration !== void 0 ? { duration: params.duration } : {},
1222
+ ...params.delay !== void 0 ? { delay: params.delay } : {},
1223
+ ...params.easing !== void 0 ? { easing: params.easing } : {}
1224
+ })
1225
+ },
1226
+ {
1227
+ ...base,
1228
+ id: `${prefix}exportCss`,
1229
+ label: "Export Animation as CSS",
1230
+ keywords: ["keyframes", "css", "web animations"],
1231
+ description: "Returns CSS @keyframes for a node's animation.",
1232
+ readOnly: true,
1233
+ params: {
1234
+ type: "object",
1235
+ properties: { nodeId: { type: "string" } },
1236
+ required: ["nodeId"]
1237
+ },
1238
+ run: (_ctx, params) => controller.exportCss(params.nodeId)
1239
+ }
1240
+ ];
1241
+ }
824
1242
  export {
825
1243
  CommandRegistry,
826
1244
  CommandRegistryError,
@@ -832,10 +1250,13 @@ export {
832
1250
  codeFromKey,
833
1251
  codeToKeyText,
834
1252
  createArrangeCommands,
1253
+ createCanvasAnimationCommands,
835
1254
  createCommandPaletteController,
836
1255
  createCommandRegistry,
837
1256
  createCommandToolProvider,
1257
+ createComponentCommands,
838
1258
  createHistoryCommands,
1259
+ createShapeCommands,
839
1260
  createSpreadsheetCommands,
840
1261
  defineCommand,
841
1262
  detectPlatform,