@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.
- package/README.md +101 -1
- package/THIRD_PARTY_NOTICES.md +40 -0
- package/dist/agent/index.cjs +175 -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 +168 -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 +8588 -1857
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +1847 -9
- package/dist/canvas/index.d.ts +1847 -9
- package/dist/canvas/index.js +8577 -1846
- 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-4BVP64JJ.cjs +1406 -0
- package/dist/chunk-4BVP64JJ.cjs.map +1 -0
- package/dist/chunk-BVP3TSLH.cjs +69 -0
- package/dist/chunk-BVP3TSLH.cjs.map +1 -0
- package/dist/{chunk-OLZJXL4R.cjs → chunk-CS6NZWWA.cjs} +59 -25
- package/dist/chunk-CS6NZWWA.cjs.map +1 -0
- package/dist/{chunk-MCSJFWAO.cjs → chunk-EWCOFSCQ.cjs} +685 -100
- 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-HRMEDT2L.js +1406 -0
- package/dist/chunk-HRMEDT2L.js.map +1 -0
- package/dist/{chunk-D27YFC46.cjs → chunk-IFHKKVXH.cjs} +382 -63
- package/dist/chunk-IFHKKVXH.cjs.map +1 -0
- package/dist/{chunk-PGNZKFQS.js → chunk-JOIREKL7.js} +137 -58
- package/dist/chunk-JOIREKL7.js.map +1 -0
- package/dist/chunk-KRGXUQ2Y.js +1696 -0
- package/dist/chunk-KRGXUQ2Y.js.map +1 -0
- package/dist/{chunk-3LV6RRPH.js → chunk-MHEPLBFB.js} +2 -2
- package/dist/chunk-MR2764X2.js +831 -0
- package/dist/chunk-MR2764X2.js.map +1 -0
- package/dist/{chunk-XNORY7M6.cjs → chunk-NFVBT3UZ.cjs} +166 -87
- package/dist/chunk-NFVBT3UZ.cjs.map +1 -0
- package/dist/chunk-NQF32I6Z.cjs +6478 -0
- package/dist/chunk-NQF32I6Z.cjs.map +1 -0
- package/dist/chunk-O5RYH2PG.js +69 -0
- package/dist/chunk-O5RYH2PG.js.map +1 -0
- package/dist/{chunk-ITBSKI26.js → chunk-Q2OHWD2A.js} +1064 -360
- package/dist/chunk-Q2OHWD2A.js.map +1 -0
- package/dist/{chunk-FODNLX5N.js → chunk-QJSOZFCZ.js} +38 -4
- package/dist/chunk-QJSOZFCZ.js.map +1 -0
- package/dist/{chunk-SML64VJG.cjs → chunk-RRREAOVM.cjs} +4 -4
- package/dist/{chunk-SML64VJG.cjs.map → chunk-RRREAOVM.cjs.map} +1 -1
- package/dist/{chunk-5S3Z4PPF.js → chunk-SWE3NPOU.js} +347 -28
- 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-X7HXL2SB.js +6478 -0
- package/dist/chunk-X7HXL2SB.js.map +1 -0
- package/dist/{chunk-SBCZ6RN5.cjs → chunk-YOMYSFJU.cjs} +1163 -459
- package/dist/chunk-YOMYSFJU.cjs.map +1 -0
- package/dist/{chunk-3CN2WD3X.js → chunk-ZRNHGAQT.js} +661 -76
- package/dist/chunk-ZRNHGAQT.js.map +1 -0
- package/dist/commands/index.cjs +425 -4
- package/dist/commands/index.cjs.map +1 -1
- package/dist/commands/index.d.cts +39 -77
- package/dist/commands/index.d.ts +39 -77
- package/dist/commands/index.js +424 -3
- package/dist/commands/index.js.map +1 -1
- package/dist/compare/index.cjs +3 -3
- package/dist/compare/index.d.cts +1 -1
- package/dist/compare/index.d.ts +1 -1
- package/dist/compare/index.js +2 -2
- package/dist/controller-CxXGOEmy.d.cts +2038 -0
- package/dist/controller-CxXGOEmy.d.ts +2038 -0
- package/dist/{documents-BQjzJNe2.d.ts → documents-CHT1U5Vs.d.ts} +10 -0
- package/dist/{documents-KRTPhvst.d.cts → documents-Gp7wb0Me.d.cts} +10 -0
- 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 +101 -6
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.d.cts +18 -5
- package/dist/extensions/index.d.ts +18 -5
- package/dist/extensions/index.js +101 -6
- package/dist/generation/index.cjs +1013 -69
- package/dist/generation/index.cjs.map +1 -1
- package/dist/generation/index.d.cts +474 -13
- package/dist/generation/index.d.ts +474 -13
- package/dist/generation/index.js +976 -32
- package/dist/generation/index.js.map +1 -1
- package/dist/image-editor/index.cjs +3385 -1275
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +693 -128
- package/dist/image-editor/index.d.ts +693 -128
- package/dist/image-editor/index.js +3325 -1215
- package/dist/image-editor/index.js.map +1 -1
- package/dist/{index-fJrlkJCd.d.ts → index-B273Zllk.d.ts} +500 -7
- package/dist/{index-BhJBSm2d.d.cts → index-jcJwmBYt.d.cts} +500 -7
- package/dist/index.cjs +1603 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +154 -27
- package/dist/index.d.ts +154 -27
- package/dist/index.js +1584 -26
- package/dist/index.js.map +1 -1
- package/dist/mention-text-CDnCFd3c.d.cts +53 -0
- package/dist/mention-text-CDnCFd3c.d.ts +53 -0
- package/dist/model-C1zApQM8.d.cts +219 -0
- package/dist/model-C1zApQM8.d.ts +219 -0
- package/dist/persistence/index.d.cts +3 -120
- package/dist/persistence/index.d.ts +3 -120
- package/dist/registry-CED5C0lA.d.cts +204 -0
- package/dist/registry-CED5C0lA.d.ts +204 -0
- package/dist/{registry-GJI4gToU.d.cts → registry-CEgwXED1.d.cts} +12 -1
- package/dist/{registry-GJI4gToU.d.ts → registry-CEgwXED1.d.ts} +12 -1
- 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 +12 -4
- package/dist/serializers/index.cjs.map +1 -1
- package/dist/serializers/index.d.cts +41 -13
- package/dist/serializers/index.d.ts +41 -13
- package/dist/serializers/index.js +12 -4
- package/dist/spreadsheet/index.cjs +157 -3
- package/dist/spreadsheet/index.cjs.map +1 -1
- package/dist/spreadsheet/index.d.cts +534 -11
- package/dist/spreadsheet/index.d.ts +534 -11
- package/dist/spreadsheet/index.js +157 -3
- package/dist/storage-BpFfspHm.d.cts +120 -0
- package/dist/storage-BpFfspHm.d.ts +120 -0
- package/dist/tokens/index.cjs +115 -0
- package/dist/tokens/index.cjs.map +1 -0
- package/dist/tokens/index.d.cts +212 -0
- package/dist/tokens/index.d.ts +212 -0
- package/dist/tokens/index.js +115 -0
- package/dist/tokens/index.js.map +1 -0
- package/dist/{track-changes-BK5sVf4_.d.cts → track-changes-D_VAPELi.d.cts} +95 -11
- package/dist/{track-changes-CDjCrwKe.d.ts → track-changes-Db_fGEvx.d.ts} +95 -11
- package/package.json +15 -1
- package/dist/chunk-3CN2WD3X.js.map +0 -1
- package/dist/chunk-5S3Z4PPF.js.map +0 -1
- package/dist/chunk-D27YFC46.cjs.map +0 -1
- package/dist/chunk-FODNLX5N.js.map +0 -1
- package/dist/chunk-ITBSKI26.js.map +0 -1
- package/dist/chunk-MA2F5KHF.cjs +0 -3223
- package/dist/chunk-MA2F5KHF.cjs.map +0 -1
- package/dist/chunk-MCSJFWAO.cjs.map +0 -1
- package/dist/chunk-OLZJXL4R.cjs.map +0 -1
- package/dist/chunk-PGNZKFQS.js.map +0 -1
- package/dist/chunk-SBCZ6RN5.cjs.map +0 -1
- package/dist/chunk-U5KWZU4X.js +0 -3223
- package/dist/chunk-U5KWZU4X.js.map +0 -1
- package/dist/chunk-XNORY7M6.cjs.map +0 -1
- package/dist/controller-BhLLAoi8.d.cts +0 -1000
- package/dist/controller-BhLLAoi8.d.ts +0 -1000
- package/dist/types-DX4Mh4SL.d.cts +0 -217
- package/dist/types-DX4Mh4SL.d.ts +0 -217
- /package/dist/{chunk-3LV6RRPH.js.map → chunk-MHEPLBFB.js.map} +0 -0
package/dist/commands/index.cjs
CHANGED
|
@@ -239,10 +239,10 @@ var CommandRegistry = (_class = 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) {
|
|
@@ -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 = _nullishCoalesce(options.prefix, () => ( "canvas."));
|
|
813
|
+
const group = _nullishCoalesce(options.group, () => ( "Shape"));
|
|
814
|
+
const scope = options.scope === null ? void 0 : _nullishCoalesce(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(_optionalChain([params, 'optionalAccess', _40 => _40.ids])) ? true : "Select at least two unlocked shapes.",
|
|
825
|
+
run: (_ctx, params) => controller.combineShapes(op, _optionalChain([params, 'optionalAccess', _41 => _41.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 ${_nullishCoalesce(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(_optionalChain([params, 'optionalAccess', _42 => _42.ids])) ? true : "Select an unlocked shape.",
|
|
846
|
+
run: (_ctx, params) => controller.offsetShapes(_nullishCoalesce(_nullishCoalesce(_optionalChain([params, 'optionalAccess', _43 => _43.distance]), () => ( options.defaultOffset)), () => ( 10)), _optionalChain([params, 'optionalAccess', _44 => _44.ids]), {
|
|
847
|
+
..._optionalChain([params, 'optionalAccess', _45 => _45.join]) ? { join: params.join } : {},
|
|
848
|
+
..._optionalChain([params, 'optionalAccess', _46 => _46.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(_optionalChain([params, 'optionalAccess', _47 => _47.ids])) ? true : "Select an unlocked shape with a stroke.",
|
|
867
|
+
run: (_ctx, params) => controller.outlineStroke(_optionalChain([params, 'optionalAccess', _48 => _48.ids]), {
|
|
868
|
+
..._optionalChain([params, 'optionalAccess', _49 => _49.join]) ? { join: params.join } : {},
|
|
869
|
+
..._optionalChain([params, 'optionalAccess', _50 => _50.cap]) ? { cap: params.cap } : {},
|
|
870
|
+
..._optionalChain([params, 'optionalAccess', _51 => _51.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 = _nullishCoalesce(options.prefix, () => ( "canvas."));
|
|
882
|
+
const group = _nullishCoalesce(options.group, () => ( "Components"));
|
|
883
|
+
const scope = options.scope === null ? void 0 : _nullishCoalesce(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(_optionalChain([params, 'optionalAccess', _52 => _52.ids])),
|
|
896
|
+
run: (_ctx, params) => outcome(controller.createComponent(_optionalChain([params, 'optionalAccess', _53 => _53.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(_optionalChain([params, 'optionalAccess', _54 => _54.ids])),
|
|
906
|
+
run: (_ctx, params) => outcome(controller.combineAsVariants(_optionalChain([params, 'optionalAccess', _55 => _55.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) => _optionalChain([params, 'optionalAccess', _56 => _56.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: _nullishCoalesce(params.x, () => ( 0)), y: _nullishCoalesce(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(_optionalChain([params, 'optionalAccess', _57 => _57.ids])),
|
|
943
|
+
run: (_ctx, params) => outcome(controller.detachInstance(_optionalChain([params, 'optionalAccess', _58 => _58.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(_optionalChain([params, 'optionalAccess', _59 => _59.id])),
|
|
959
|
+
run: (_ctx, params) => outcome(controller.resetOverrides(_optionalChain([params, 'optionalAccess', _60 => _60.id]), _optionalChain([params, 'optionalAccess', _61 => _61.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(_optionalChain([params, 'optionalAccess', _62 => _62.id])),
|
|
969
|
+
run: (_ctx, params) => outcome(controller.pushOverrides(_optionalChain([params, 'optionalAccess', _63 => _63.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(_optionalChain([params, 'optionalAccess', _64 => _64.id])),
|
|
979
|
+
run: (_ctx, params) => {
|
|
980
|
+
const main = controller.goToMainComponent(_optionalChain([params, 'optionalAccess', _65 => _65.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(_optionalChain([params, 'optionalAccess', _66 => _66.componentId]), _optionalChain([params, 'optionalAccess', _67 => _67.ids])),
|
|
1000
|
+
run: (_ctx, params) => outcome(controller.swapInstance(params.componentId, _optionalChain([params, 'optionalAccess', _68 => _68.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(_optionalChain([params, 'optionalAccess', _69 => _69.ids])),
|
|
1017
|
+
run: (_ctx, params) => outcome(controller.setInstanceProperties(params.properties, _optionalChain([params, 'optionalAccess', _70 => _70.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(_optionalChain([params, 'optionalAccess', _71 => _71.id])),
|
|
1027
|
+
run: (_ctx, params) => outcome(controller.restoreMainComponent(_optionalChain([params, 'optionalAccess', _72 => _72.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(_optionalChain([params, 'optionalAccess', _73 => _73.id])) ? true : "Select an instance.",
|
|
1047
|
+
run: (_ctx, params) => _nullishCoalesce(controller.inspect(_optionalChain([params, 'optionalAccess', _74 => _74.id])), () => ( null))
|
|
1048
|
+
}
|
|
1049
|
+
];
|
|
1050
|
+
}
|
|
803
1051
|
function createSpreadsheetCommands(controller, options = {}) {
|
|
804
1052
|
const prefix = _nullishCoalesce(options.prefix, () => ( "spreadsheet."));
|
|
805
1053
|
const scope = options.scope === null ? void 0 : _nullishCoalesce(options.scope, () => ( "spreadsheet"));
|
|
@@ -822,6 +1070,179 @@ function createSpreadsheetCommands(controller, options = {}) {
|
|
|
822
1070
|
];
|
|
823
1071
|
}
|
|
824
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 = _nullishCoalesce(options.prefix, () => ( "canvas.animation."));
|
|
1082
|
+
const group = _nullishCoalesce(options.group, () => ( "Animation"));
|
|
1083
|
+
const scope = options.scope === null ? void 0 : _nullishCoalesce(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(_optionalChain([params, 'optionalAccess', _75 => _75.ids]), _optionalChain([params, 'optionalAccess', _76 => _76.properties]), _optionalChain([params, 'optionalAccess', _77 => _77.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
|
+
}
|
|
1242
|
+
|
|
1243
|
+
|
|
1244
|
+
|
|
1245
|
+
|
|
825
1246
|
|
|
826
1247
|
|
|
827
1248
|
|
|
@@ -856,5 +1277,5 @@ function createSpreadsheetCommands(controller, options = {}) {
|
|
|
856
1277
|
|
|
857
1278
|
|
|
858
1279
|
|
|
859
|
-
exports.CommandRegistry = CommandRegistry; exports.CommandRegistryError = CommandRegistryError; exports.DEFAULT_HISTORY_SHORTCUTS = DEFAULT_HISTORY_SHORTCUTS; exports.DEFAULT_RECENT_LIMIT = DEFAULT_RECENT_LIMIT; exports.PLATFORMS = _chunk26BVFKHUcjs.PLATFORMS; exports.ShortcutMap = _chunk26BVFKHUcjs.ShortcutMap; exports.chordToString = _chunk26BVFKHUcjs.chordToString; exports.codeFromKey = _chunk26BVFKHUcjs.codeFromKey; exports.codeToKeyText = _chunk26BVFKHUcjs.codeToKeyText; exports.createArrangeCommands = createArrangeCommands; exports.createCommandPaletteController = createCommandPaletteController; exports.createCommandRegistry = createCommandRegistry; exports.createCommandToolProvider = createCommandToolProvider; exports.createHistoryCommands = createHistoryCommands; exports.createSpreadsheetCommands = createSpreadsheetCommands; exports.defineCommand = defineCommand; exports.detectPlatform = _chunk26BVFKHUcjs.detectPlatform; exports.effectiveChord = _chunk26BVFKHUcjs.effectiveChord; exports.effectiveChordKey = _chunk26BVFKHUcjs.effectiveChordKey; exports.eventCode = _chunk26BVFKHUcjs.eventCode; exports.exactBonus = exactBonus; exports.formatShortcut = _chunk26BVFKHUcjs.formatShortcut; exports.fuzzyMatch = fuzzyMatch; exports.fuzzyScore = fuzzyScore; exports.isEditableEventTarget = _chunk26BVFKHUcjs.isEditableEventTarget; exports.keyToCode = _chunk26BVFKHUcjs.keyToCode; exports.matchHistoryShortcut = matchHistoryShortcut; exports.matchPaletteHotkey = matchPaletteHotkey; exports.normalizeChord = _chunk26BVFKHUcjs.normalizeChord; exports.parseChord = _chunk26BVFKHUcjs.parseChord; exports.pushRecent = pushRecent; exports.rankCommands = rankCommands; exports.shortcutCode = _chunk26BVFKHUcjs.shortcutCode; exports.toShortcutBindings = _chunk26BVFKHUcjs.toShortcutBindings;
|
|
1280
|
+
exports.CommandRegistry = CommandRegistry; exports.CommandRegistryError = CommandRegistryError; exports.DEFAULT_HISTORY_SHORTCUTS = DEFAULT_HISTORY_SHORTCUTS; exports.DEFAULT_RECENT_LIMIT = DEFAULT_RECENT_LIMIT; exports.PLATFORMS = _chunk26BVFKHUcjs.PLATFORMS; exports.ShortcutMap = _chunk26BVFKHUcjs.ShortcutMap; exports.chordToString = _chunk26BVFKHUcjs.chordToString; exports.codeFromKey = _chunk26BVFKHUcjs.codeFromKey; exports.codeToKeyText = _chunk26BVFKHUcjs.codeToKeyText; exports.createArrangeCommands = createArrangeCommands; exports.createCanvasAnimationCommands = createCanvasAnimationCommands; exports.createCommandPaletteController = createCommandPaletteController; exports.createCommandRegistry = createCommandRegistry; exports.createCommandToolProvider = createCommandToolProvider; exports.createComponentCommands = createComponentCommands; exports.createHistoryCommands = createHistoryCommands; exports.createShapeCommands = createShapeCommands; exports.createSpreadsheetCommands = createSpreadsheetCommands; exports.defineCommand = defineCommand; exports.detectPlatform = _chunk26BVFKHUcjs.detectPlatform; exports.effectiveChord = _chunk26BVFKHUcjs.effectiveChord; exports.effectiveChordKey = _chunk26BVFKHUcjs.effectiveChordKey; exports.eventCode = _chunk26BVFKHUcjs.eventCode; exports.exactBonus = exactBonus; exports.formatShortcut = _chunk26BVFKHUcjs.formatShortcut; exports.fuzzyMatch = fuzzyMatch; exports.fuzzyScore = fuzzyScore; exports.isEditableEventTarget = _chunk26BVFKHUcjs.isEditableEventTarget; exports.keyToCode = _chunk26BVFKHUcjs.keyToCode; exports.matchHistoryShortcut = matchHistoryShortcut; exports.matchPaletteHotkey = matchPaletteHotkey; exports.normalizeChord = _chunk26BVFKHUcjs.normalizeChord; exports.parseChord = _chunk26BVFKHUcjs.parseChord; exports.pushRecent = pushRecent; exports.rankCommands = rankCommands; exports.shortcutCode = _chunk26BVFKHUcjs.shortcutCode; exports.toShortcutBindings = _chunk26BVFKHUcjs.toShortcutBindings;
|
|
860
1281
|
//# sourceMappingURL=index.cjs.map
|