@pixerate/editor 0.25.0 → 0.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -0
- package/THIRD_PARTY_NOTICES.md +11 -0
- package/dist/agent/index.cjs +174 -11
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +18 -4
- package/dist/agent/index.d.ts +18 -4
- package/dist/agent/index.js +167 -4
- package/dist/agent/index.js.map +1 -1
- package/dist/{arrangeShortcuts-B8O3f8-P.d.cts → arrange-BICutYPk.d.cts} +243 -29
- package/dist/{arrangeShortcuts-sLlD2rSX.d.ts → arrange-BICutYPk.d.ts} +243 -29
- package/dist/builtins-CdPcLwwF.d.cts +176 -0
- package/dist/builtins-Chj6zv_O.d.ts +176 -0
- package/dist/canvas/index.cjs +3917 -19
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +1232 -7
- package/dist/canvas/index.d.ts +1232 -7
- package/dist/canvas/index.js +3916 -18
- package/dist/canvas/index.js.map +1 -1
- package/dist/chunk-3CC7OPUQ.cjs +831 -0
- package/dist/chunk-3CC7OPUQ.cjs.map +1 -0
- package/dist/{chunk-7WISYZFO.cjs → chunk-66IMF6OD.cjs} +174 -67
- package/dist/chunk-66IMF6OD.cjs.map +1 -0
- package/dist/{chunk-AL6JMGWW.cjs → chunk-CS6NZWWA.cjs} +24 -24
- package/dist/{chunk-AL6JMGWW.cjs.map → chunk-CS6NZWWA.cjs.map} +1 -1
- package/dist/{chunk-C7P22VIP.cjs → chunk-EWCOFSCQ.cjs} +17 -6
- package/dist/chunk-EWCOFSCQ.cjs.map +1 -0
- package/dist/chunk-HDYMLS3X.cjs +409 -0
- package/dist/chunk-HDYMLS3X.cjs.map +1 -0
- package/dist/{chunk-V3CHHWOE.cjs → chunk-HNDSPZ5T.cjs} +4 -4
- package/dist/{chunk-V3CHHWOE.cjs.map → chunk-HNDSPZ5T.cjs.map} +1 -1
- package/dist/{chunk-X4N4WUKB.cjs → chunk-IFHKKVXH.cjs} +150 -38
- package/dist/chunk-IFHKKVXH.cjs.map +1 -0
- package/dist/chunk-KRGXUQ2Y.js +1696 -0
- package/dist/chunk-KRGXUQ2Y.js.map +1 -0
- package/dist/{chunk-PO6A6QQH.cjs → chunk-LN2POBHT.cjs} +742 -970
- package/dist/chunk-LN2POBHT.cjs.map +1 -0
- package/dist/chunk-MR2764X2.js +831 -0
- package/dist/chunk-MR2764X2.js.map +1 -0
- package/dist/{chunk-WSQKHXW7.cjs → chunk-NQF32I6Z.cjs} +1209 -457
- package/dist/chunk-NQF32I6Z.cjs.map +1 -0
- package/dist/{chunk-NAXVVS5I.js → chunk-QJSOZFCZ.js} +2 -2
- package/dist/{chunk-UAKDG62Z.js → chunk-SWE3NPOU.js} +116 -4
- package/dist/chunk-SWE3NPOU.js.map +1 -0
- package/dist/chunk-TXXNBDQX.cjs +1696 -0
- package/dist/chunk-TXXNBDQX.cjs.map +1 -0
- package/dist/chunk-UBCFIABU.js +409 -0
- package/dist/chunk-UBCFIABU.js.map +1 -0
- package/dist/{chunk-ECCCYKGL.js → chunk-UKI64KUD.js} +147 -40
- package/dist/chunk-UKI64KUD.js.map +1 -0
- package/dist/{chunk-QGYDWPRM.js → chunk-WON34HKM.js} +2 -2
- package/dist/{chunk-RR7F5GUM.js → chunk-X7HXL2SB.js} +941 -189
- package/dist/chunk-X7HXL2SB.js.map +1 -0
- package/dist/{chunk-IXHSYOVY.js → chunk-XQFHLT53.js} +638 -866
- package/dist/chunk-XQFHLT53.js.map +1 -0
- package/dist/{chunk-FH6F67DN.js → chunk-ZRNHGAQT.js} +17 -6
- package/dist/{chunk-FH6F67DN.js.map → chunk-ZRNHGAQT.js.map} +1 -1
- package/dist/commands/index.cjs +352 -4
- package/dist/commands/index.cjs.map +1 -1
- package/dist/commands/index.d.cts +37 -108
- package/dist/commands/index.d.ts +37 -108
- package/dist/commands/index.js +351 -3
- package/dist/commands/index.js.map +1 -1
- package/dist/compare/index.cjs +3 -3
- package/dist/compare/index.js +2 -2
- package/dist/{controller-BIJiNoVs.d.cts → controller-CxXGOEmy.d.cts} +209 -13
- package/dist/{controller-BIJiNoVs.d.ts → controller-CxXGOEmy.d.ts} +209 -13
- package/dist/export/index.cjs +36 -0
- package/dist/export/index.cjs.map +1 -0
- package/dist/export/index.d.cts +243 -0
- package/dist/export/index.d.ts +243 -0
- package/dist/export/index.js +36 -0
- package/dist/export/index.js.map +1 -0
- package/dist/extensions/index.cjs +54 -6
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.d.cts +7 -2
- package/dist/extensions/index.d.ts +7 -2
- package/dist/extensions/index.js +59 -11
- package/dist/{index-7a6bHTLy.d.ts → index-B273Zllk.d.ts} +211 -207
- package/dist/{index-Csd5qI8u.d.cts → index-jcJwmBYt.d.cts} +211 -207
- package/dist/index.cjs +146 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +50 -14
- package/dist/index.d.ts +50 -14
- package/dist/index.js +138 -24
- package/dist/index.js.map +1 -1
- package/dist/registry-CED5C0lA.d.cts +204 -0
- package/dist/registry-CED5C0lA.d.ts +204 -0
- package/dist/{registry-D32LpIc4.d.cts → registry-D0GADKc7.d.cts} +1 -1
- package/dist/{registry-evKTP4ls.d.ts → registry-DhVUZioj.d.ts} +1 -1
- package/dist/serializers/index.cjs +6 -4
- package/dist/serializers/index.cjs.map +1 -1
- package/dist/serializers/index.d.cts +15 -4
- package/dist/serializers/index.d.ts +15 -4
- package/dist/serializers/index.js +5 -3
- package/dist/spreadsheet/index.cjs +33 -3
- package/dist/spreadsheet/index.cjs.map +1 -1
- package/dist/spreadsheet/index.d.cts +106 -3
- package/dist/spreadsheet/index.d.ts +106 -3
- package/dist/spreadsheet/index.js +32 -2
- package/package.json +10 -1
- package/dist/chunk-7WISYZFO.cjs.map +0 -1
- package/dist/chunk-C7P22VIP.cjs.map +0 -1
- package/dist/chunk-ECCCYKGL.js.map +0 -1
- package/dist/chunk-IXHSYOVY.js.map +0 -1
- package/dist/chunk-PO6A6QQH.cjs.map +0 -1
- package/dist/chunk-RR7F5GUM.js.map +0 -1
- package/dist/chunk-UAKDG62Z.js.map +0 -1
- package/dist/chunk-WSQKHXW7.cjs.map +0 -1
- package/dist/chunk-X4N4WUKB.cjs.map +0 -1
- package/dist/types-DX4Mh4SL.d.cts +0 -217
- package/dist/types-DX4Mh4SL.d.ts +0 -217
- /package/dist/{chunk-NAXVVS5I.js.map → chunk-QJSOZFCZ.js.map} +0 -0
- /package/dist/{chunk-QGYDWPRM.js.map → chunk-WON34HKM.js.map} +0 -0
package/dist/commands/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
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-
|
|
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
|
-
|
|
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-
|
|
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,118 +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
|
-
*
|
|
181
|
-
* (`
|
|
182
|
-
* contenteditable elements are ignored unless `allowInEditable`.
|
|
164
|
+
* Animation controller surface used by `createCanvasAnimationCommands`
|
|
165
|
+
* (`createCanvasAnimationController`, `useCanvasAnimation` and `createCanvasAnimation` satisfy it).
|
|
183
166
|
*/
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
previous(): 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;
|
|
208
190
|
};
|
|
209
|
-
/** Use these bindings instead of `DEFAULT_ARRANGE_SHORTCUTS`. */
|
|
210
|
-
bindings?: readonly {
|
|
211
|
-
action: CanvasArrangeAction;
|
|
212
|
-
label: string;
|
|
213
|
-
}[];
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
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.
|
|
219
|
-
*/
|
|
220
|
-
declare function createArrangeCommands(controller: ArrangeCommandTarget, options?: ArrangeCommandOptions): CommandSpec[];
|
|
221
|
-
/** Shape operations surface of the arrange controller (`createCanvasArrangeController` satisfies it). */
|
|
222
|
-
interface ShapeCommandTarget {
|
|
223
|
-
combineShapes(operation: 'unite' | 'intersect' | 'subtract' | 'exclude' | 'divide', ids?: Iterable<string>): unknown;
|
|
224
|
-
canCombineShapes(ids?: Iterable<string>): boolean;
|
|
225
|
-
offsetShapes(distance: number, ids?: Iterable<string>, options?: {
|
|
226
|
-
join?: 'miter' | 'round' | 'bevel';
|
|
227
|
-
miterLimit?: number;
|
|
228
|
-
}): unknown;
|
|
229
|
-
canOffsetShapes(ids?: Iterable<string>): boolean;
|
|
230
|
-
outlineStroke(ids?: Iterable<string>, options?: {
|
|
231
|
-
join?: 'miter' | 'round' | 'bevel';
|
|
232
|
-
cap?: 'butt' | 'round' | 'square';
|
|
233
|
-
miterLimit?: number;
|
|
234
|
-
}): unknown;
|
|
235
|
-
canOutlineStroke(ids?: Iterable<string>): boolean;
|
|
236
191
|
}
|
|
237
|
-
interface
|
|
238
|
-
/** Id prefix (default `canvas.`). */
|
|
192
|
+
interface AnimationCommandOptions {
|
|
193
|
+
/** Id prefix (default `canvas.animation.`). */
|
|
239
194
|
prefix?: string;
|
|
240
195
|
group?: string;
|
|
241
196
|
/** Scope (default `canvas`). Pass `null` for global. */
|
|
242
197
|
scope?: string | null;
|
|
243
|
-
/** Offset distance used when `canvas.offsetPath` is run without one (default 10). */
|
|
244
|
-
defaultOffset?: number;
|
|
245
198
|
}
|
|
246
199
|
/**
|
|
247
|
-
* Palette /
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
* (`{ join?, cap?, miterLimit?, ids? }`). Each is one undoable step when the controller has a
|
|
251
|
-
* history; enablement explains why a command cannot run.
|
|
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.
|
|
252
203
|
*/
|
|
253
|
-
declare function
|
|
254
|
-
/** Spreadsheet controller surface used by `createSpreadsheetCommands`. */
|
|
255
|
-
interface SpreadsheetCommandTarget {
|
|
256
|
-
selectedRange: unknown;
|
|
257
|
-
getFilterState(): {
|
|
258
|
-
enabled: boolean;
|
|
259
|
-
rules: readonly unknown[];
|
|
260
|
-
};
|
|
261
|
-
toggleFilters(): void;
|
|
262
|
-
clearFilters(): void;
|
|
263
|
-
unhideAll(): void;
|
|
264
|
-
mergeCells(): boolean;
|
|
265
|
-
unmergeCells(): boolean;
|
|
266
|
-
transposeRange(): boolean;
|
|
267
|
-
}
|
|
268
|
-
interface SpreadsheetCommandOptions {
|
|
269
|
-
/** Id prefix (default `spreadsheet.`). */
|
|
270
|
-
prefix?: string;
|
|
271
|
-
/** Scope (default `spreadsheet`). Pass `null` for global. */
|
|
272
|
-
scope?: string | null;
|
|
273
|
-
}
|
|
274
|
-
/** Palette / agent commands for common spreadsheet table actions (no default shortcuts). */
|
|
275
|
-
declare function createSpreadsheetCommands(controller: SpreadsheetCommandTarget, options?: SpreadsheetCommandOptions): CommandSpec[];
|
|
204
|
+
declare function createCanvasAnimationCommands(controller: AnimationCommandTarget, options?: AnimationCommandOptions): CommandSpec[];
|
|
276
205
|
|
|
277
|
-
export { type
|
|
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 };
|
package/dist/commands/index.js
CHANGED
|
@@ -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
|
|
243
|
-
if (!
|
|
242
|
+
const outcome2 = this.execute(id, params, context);
|
|
243
|
+
if (!outcome2.ok || !isThenable(outcome2.result)) return outcome2;
|
|
244
244
|
try {
|
|
245
|
-
const result = await
|
|
245
|
+
const result = await outcome2.result;
|
|
246
246
|
this.notify();
|
|
247
247
|
return { ok: true, id, result };
|
|
248
248
|
} catch (error) {
|
|
@@ -872,6 +872,182 @@ function createShapeCommands(controller, options = {}) {
|
|
|
872
872
|
}
|
|
873
873
|
];
|
|
874
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
|
+
}
|
|
875
1051
|
function createSpreadsheetCommands(controller, options = {}) {
|
|
876
1052
|
const prefix = options.prefix ?? "spreadsheet.";
|
|
877
1053
|
const scope = options.scope === null ? void 0 : options.scope ?? "spreadsheet";
|
|
@@ -893,6 +1069,176 @@ function createSpreadsheetCommands(controller, options = {}) {
|
|
|
893
1069
|
{ ...base, id: `${prefix}transposeRange`, label: "Transpose Range", keywords: ["rotate", "swap rows columns"], enabled: hasRange, run: () => controller.transposeRange() }
|
|
894
1070
|
];
|
|
895
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
|
+
}
|
|
896
1242
|
export {
|
|
897
1243
|
CommandRegistry,
|
|
898
1244
|
CommandRegistryError,
|
|
@@ -904,9 +1250,11 @@ export {
|
|
|
904
1250
|
codeFromKey,
|
|
905
1251
|
codeToKeyText,
|
|
906
1252
|
createArrangeCommands,
|
|
1253
|
+
createCanvasAnimationCommands,
|
|
907
1254
|
createCommandPaletteController,
|
|
908
1255
|
createCommandRegistry,
|
|
909
1256
|
createCommandToolProvider,
|
|
1257
|
+
createComponentCommands,
|
|
910
1258
|
createHistoryCommands,
|
|
911
1259
|
createShapeCommands,
|
|
912
1260
|
createSpreadsheetCommands,
|