@pixel-point/toolcraft 0.0.2
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/LICENSE.md +98 -0
- package/README.md +41 -0
- package/bin/create-toolcraft-app.mjs +8 -0
- package/bin/toolcraft.mjs +8 -0
- package/package.json +24 -0
- package/scripts/prepare-pack.mjs +29 -0
- package/src/cli.mjs +392 -0
- package/src/cli.test.mjs +284 -0
- package/src/copy-recursive.mjs +86 -0
- package/src/generate.mjs +212 -0
- package/src/generate.test.mjs +322 -0
- package/src/import-map.mjs +14 -0
- package/src/package-json.mjs +80 -0
- package/src/package-json.test.mjs +67 -0
- package/src/rewrite-imports.mjs +85 -0
- package/src/rewrite-imports.test.mjs +58 -0
- package/templates/runtime/contracts/component-contracts.test.ts +1165 -0
- package/templates/runtime/contracts/component-contracts.ts +1340 -0
- package/templates/runtime/contracts/decision-contracts.test.ts +206 -0
- package/templates/runtime/contracts/decision-contracts.ts +283 -0
- package/templates/runtime/contracts/index.test.ts +14 -0
- package/templates/runtime/contracts/index.ts +3 -0
- package/templates/runtime/contracts/types.ts +56 -0
- package/templates/runtime/export/export.test.ts +203 -0
- package/templates/runtime/export/export.ts +132 -0
- package/templates/runtime/export/index.ts +1 -0
- package/templates/runtime/index.ts +14 -0
- package/templates/runtime/react/canvas-shell.test.tsx +424 -0
- package/templates/runtime/react/canvas-shell.tsx +408 -0
- package/templates/runtime/react/control-renderers.ts +31 -0
- package/templates/runtime/react/controls-panel.test.tsx +3736 -0
- package/templates/runtime/react/controls-panel.tsx +2327 -0
- package/templates/runtime/react/curve-geometry.test.ts +70 -0
- package/templates/runtime/react/index.ts +15 -0
- package/templates/runtime/react/layer-tree.ts +96 -0
- package/templates/runtime/react/layers-panel.test.tsx +487 -0
- package/templates/runtime/react/layers-panel.tsx +1348 -0
- package/templates/runtime/react/media-file.ts +82 -0
- package/templates/runtime/react/panel-host-config.ts +80 -0
- package/templates/runtime/react/panel-host-geometry.test.ts +66 -0
- package/templates/runtime/react/panel-host-geometry.ts +109 -0
- package/templates/runtime/react/panel-host-types.ts +74 -0
- package/templates/runtime/react/panel-host.test.tsx +102 -0
- package/templates/runtime/react/panel-host.tsx +353 -0
- package/templates/runtime/react/runtime-public-api.test.tsx +132 -0
- package/templates/runtime/react/settings-transfer.test.ts +150 -0
- package/templates/runtime/react/settings-transfer.ts +279 -0
- package/templates/runtime/react/storage-key-migration.ts +48 -0
- package/templates/runtime/react/theme-runtime.tsx +177 -0
- package/templates/runtime/react/timeline-panel.test.tsx +668 -0
- package/templates/runtime/react/timeline-panel.tsx +2953 -0
- package/templates/runtime/react/toolbar-panel.test.tsx +212 -0
- package/templates/runtime/react/toolbar-panel.tsx +205 -0
- package/templates/runtime/react/toolcraft-app.integration.test.tsx +350 -0
- package/templates/runtime/react/toolcraft-app.test.tsx +339 -0
- package/templates/runtime/react/toolcraft-app.tsx +81 -0
- package/templates/runtime/react/toolcraft-root.test.tsx +347 -0
- package/templates/runtime/react/toolcraft-root.tsx +203 -0
- package/templates/runtime/react/use-toolcraft.ts +41 -0
- package/templates/runtime/schema/define-toolcraft.test.ts +1524 -0
- package/templates/runtime/schema/define-toolcraft.ts +1442 -0
- package/templates/runtime/schema/keyframe-capability.test.ts +90 -0
- package/templates/runtime/schema/keyframe-capability.ts +51 -0
- package/templates/runtime/schema/runtime-targets.ts +40 -0
- package/templates/runtime/schema/types.ts +370 -0
- package/templates/runtime/state/canvas-zoom.ts +8 -0
- package/templates/runtime/state/create-template-state.test.ts +242 -0
- package/templates/runtime/state/create-template-state.ts +95 -0
- package/templates/runtime/state/keyframe-evaluation.test.ts +141 -0
- package/templates/runtime/state/keyframe-evaluation.ts +203 -0
- package/templates/runtime/state/persistence.test.ts +217 -0
- package/templates/runtime/state/persistence.ts +511 -0
- package/templates/runtime/state/reducer.test.ts +937 -0
- package/templates/runtime/state/reducer.ts +1212 -0
- package/templates/runtime/state/timeline-readiness.ts +43 -0
- package/templates/runtime/state/types.ts +242 -0
- package/templates/runtime/styles.css +125 -0
- package/templates/runtime/testing/performance.test.ts +1058 -0
- package/templates/runtime/testing/performance.ts +1078 -0
- package/templates/starter/AGENTS.md +186 -0
- package/templates/starter/LICENSE.md +98 -0
- package/templates/starter/NOTICE.md +8 -0
- package/templates/starter/docs/toolcraft/README.md +41 -0
- package/templates/starter/docs/toolcraft/acceptance-testing.md +205 -0
- package/templates/starter/docs/toolcraft/agent-worklog.md +81 -0
- package/templates/starter/docs/toolcraft/assembly-workflow.md +206 -0
- package/templates/starter/docs/toolcraft/component-rules.md +299 -0
- package/templates/starter/docs/toolcraft/custom-controls.md +71 -0
- package/templates/starter/docs/toolcraft/decision-contract.md +71 -0
- package/templates/starter/docs/toolcraft/performance.md +112 -0
- package/templates/starter/docs/toolcraft/renderer-technique.md +48 -0
- package/templates/starter/docs/toolcraft/schema-reference.md +265 -0
- package/templates/starter/docs/toolcraft/workflow.md +87 -0
- package/templates/starter/e2e/app-browser-acceptance.spec.ts +785 -0
- package/templates/starter/e2e/app-controls.spec.ts +41 -0
- package/templates/starter/e2e/app-performance.spec.ts +326 -0
- package/templates/starter/e2e/canvas-handle-helpers.ts +244 -0
- package/templates/starter/e2e/performance-helpers.ts +612 -0
- package/templates/starter/e2e/product-observable-helpers.ts +170 -0
- package/templates/starter/index.html +12 -0
- package/templates/starter/package.json +52 -0
- package/templates/starter/playwright.config.ts +43 -0
- package/templates/starter/scripts/check-ai-skills.mjs +95 -0
- package/templates/starter/scripts/check-toolcraft-docs.mjs +159 -0
- package/templates/starter/scripts/check-toolcraft-integrity.mjs +232 -0
- package/templates/starter/scripts/run-vite-on-free-port.mjs +48 -0
- package/templates/starter/scripts/toolcraft-port.mjs +54 -0
- package/templates/starter/scripts/toolcraft-port.test.mjs +73 -0
- package/templates/starter/src/app/starter-acceptance.test.ts +5959 -0
- package/templates/starter/src/app/starter-acceptance.ts +2646 -0
- package/templates/starter/src/app/starter-performance.test.ts +1390 -0
- package/templates/starter/src/app/starter-performance.ts +12 -0
- package/templates/starter/src/app/starter-schema.test.ts +70 -0
- package/templates/starter/src/app/starter-schema.ts +15 -0
- package/templates/starter/src/main.tsx +18 -0
- package/templates/starter/src/router.tsx +16 -0
- package/templates/starter/src/routes/index.tsx +7 -0
- package/templates/starter/src/routes/root.tsx +19 -0
- package/templates/starter/src/styles.css +120 -0
- package/templates/starter/tsconfig.json +11 -0
- package/templates/starter/vite.config.ts +13 -0
- package/templates/ui/components/composites/accordion.tsx +73 -0
- package/templates/ui/components/composites/alert-dialog.tsx +190 -0
- package/templates/ui/components/composites/alert.tsx +74 -0
- package/templates/ui/components/composites/aspect-ratio.tsx +22 -0
- package/templates/ui/components/composites/avatar.tsx +98 -0
- package/templates/ui/components/composites/badge.tsx +69 -0
- package/templates/ui/components/composites/breadcrumb.tsx +106 -0
- package/templates/ui/components/composites/card.tsx +91 -0
- package/templates/ui/components/composites/combobox.tsx +486 -0
- package/templates/ui/components/composites/command.tsx +296 -0
- package/templates/ui/components/composites/context-menu.tsx +247 -0
- package/templates/ui/components/composites/dialog.tsx +282 -0
- package/templates/ui/components/composites/dropdown-menu.tsx +299 -0
- package/templates/ui/components/composites/empty.tsx +110 -0
- package/templates/ui/components/composites/hover-card.tsx +44 -0
- package/templates/ui/components/composites/index.ts +30 -0
- package/templates/ui/components/composites/menubar.tsx +214 -0
- package/templates/ui/components/composites/navigation-menu.tsx +167 -0
- package/templates/ui/components/composites/pagination.tsx +131 -0
- package/templates/ui/components/composites/progress.tsx +72 -0
- package/templates/ui/components/composites/radio-group.tsx +84 -0
- package/templates/ui/components/composites/resizable.tsx +42 -0
- package/templates/ui/components/composites/sheet.tsx +153 -0
- package/templates/ui/components/composites/sidebar-structural.tsx +310 -0
- package/templates/ui/components/composites/sidebar.tsx +431 -0
- package/templates/ui/components/composites/sonner.tsx +35 -0
- package/templates/ui/components/composites/spinner.tsx +43 -0
- package/templates/ui/components/composites/table.tsx +108 -0
- package/templates/ui/components/composites/tabs.tsx +83 -0
- package/templates/ui/components/control-layout/index.tsx +437 -0
- package/templates/ui/components/controls/actions/actions-control.tsx +139 -0
- package/templates/ui/components/controls/actions/index.ts +9 -0
- package/templates/ui/components/controls/anchor-grid/anchor-grid-control.tsx +107 -0
- package/templates/ui/components/controls/anchor-grid/index.ts +4 -0
- package/templates/ui/components/controls/boolean/boolean-controls.tsx +79 -0
- package/templates/ui/components/controls/boolean/index.ts +4 -0
- package/templates/ui/components/controls/channel-mixer/channel-mixer-control.tsx +95 -0
- package/templates/ui/components/controls/channel-mixer/index.ts +4 -0
- package/templates/ui/components/controls/channel-tabs/channel-tabs.tsx +42 -0
- package/templates/ui/components/controls/channel-tabs/index.ts +6 -0
- package/templates/ui/components/controls/code-textarea/code-textarea-control.tsx +90 -0
- package/templates/ui/components/controls/code-textarea/index.ts +4 -0
- package/templates/ui/components/controls/color/color-control.tsx +571 -0
- package/templates/ui/components/controls/color/color-picker-popover.tsx +104 -0
- package/templates/ui/components/controls/color/index.ts +41 -0
- package/templates/ui/components/controls/color/palette-control-data.ts +436 -0
- package/templates/ui/components/controls/color/palette-control.tsx +535 -0
- package/templates/ui/components/controls/color/style-guide-color-picker-channel-utils.ts +162 -0
- package/templates/ui/components/controls/color/style-guide-color-picker-interactions.ts +190 -0
- package/templates/ui/components/controls/color/style-guide-color-picker-logic.ts +485 -0
- package/templates/ui/components/controls/color/style-guide-color-picker-parts.tsx +710 -0
- package/templates/ui/components/controls/color/style-guide-color-picker.tsx +503 -0
- package/templates/ui/components/controls/control-types.ts +43 -0
- package/templates/ui/components/controls/curves/curve-geometry.ts +355 -0
- package/templates/ui/components/controls/curves/curve-graph.tsx +390 -0
- package/templates/ui/components/controls/curves/curves-control.tsx +445 -0
- package/templates/ui/components/controls/curves/index.ts +6 -0
- package/templates/ui/components/controls/file-drop/file-drop-control.tsx +191 -0
- package/templates/ui/components/controls/file-drop/index.ts +5 -0
- package/templates/ui/components/controls/font-picker/font-catalog.json +15360 -0
- package/templates/ui/components/controls/font-picker/font-catalog.ts +116 -0
- package/templates/ui/components/controls/font-picker/font-picker-control.tsx +1202 -0
- package/templates/ui/components/controls/font-picker/font-preview-loader.ts +336 -0
- package/templates/ui/components/controls/font-picker/index.ts +24 -0
- package/templates/ui/components/controls/font-picker/use-hover-intent.ts +46 -0
- package/templates/ui/components/controls/gradient/gradient-control-utils.ts +190 -0
- package/templates/ui/components/controls/gradient/gradient-control.tsx +612 -0
- package/templates/ui/components/controls/gradient/gradient-stop-list.tsx +400 -0
- package/templates/ui/components/controls/gradient/gradient-toolbar.tsx +152 -0
- package/templates/ui/components/controls/gradient/index.ts +4 -0
- package/templates/ui/components/controls/image-picker/image-picker-control.tsx +139 -0
- package/templates/ui/components/controls/image-picker/index.ts +7 -0
- package/templates/ui/components/controls/index.ts +192 -0
- package/templates/ui/components/controls/range-input/index.ts +4 -0
- package/templates/ui/components/controls/range-input/range-input-control.tsx +173 -0
- package/templates/ui/components/controls/range-slider/index.ts +4 -0
- package/templates/ui/components/controls/range-slider/range-slider-control.tsx +122 -0
- package/templates/ui/components/controls/range-slider/range-slider-value.ts +61 -0
- package/templates/ui/components/controls/segmented/index.ts +8 -0
- package/templates/ui/components/controls/segmented/segmented-control.tsx +94 -0
- package/templates/ui/components/controls/select/index.ts +4 -0
- package/templates/ui/components/controls/select/select-control.tsx +223 -0
- package/templates/ui/components/controls/slider/index.ts +4 -0
- package/templates/ui/components/controls/slider/slider-control.tsx +150 -0
- package/templates/ui/components/controls/slider/slider-value.ts +56 -0
- package/templates/ui/components/controls/text-input/index.ts +4 -0
- package/templates/ui/components/controls/text-input/text-input-control.tsx +158 -0
- package/templates/ui/components/controls/use-measured-element-width.ts +42 -0
- package/templates/ui/components/controls/vector/index.ts +8 -0
- package/templates/ui/components/controls/vector/vector-control.tsx +401 -0
- package/templates/ui/components/panel/index.ts +19 -0
- package/templates/ui/components/panel/panel-actions.tsx +165 -0
- package/templates/ui/components/panel/panel-header.tsx +61 -0
- package/templates/ui/components/panel/panel-icon-button.tsx +96 -0
- package/templates/ui/components/panel/panel-section.tsx +168 -0
- package/templates/ui/components/panel/panel-surface.tsx +206 -0
- package/templates/ui/components/panel/panel.tsx +210 -0
- package/templates/ui/components/primitives/animated-loader.tsx +61 -0
- package/templates/ui/components/primitives/button-group.tsx +134 -0
- package/templates/ui/components/primitives/button.tsx +429 -0
- package/templates/ui/components/primitives/checkbox.tsx +62 -0
- package/templates/ui/components/primitives/editable-slider-value-label.tsx +337 -0
- package/templates/ui/components/primitives/field.tsx +225 -0
- package/templates/ui/components/primitives/index.ts +82 -0
- package/templates/ui/components/primitives/input-group.tsx +298 -0
- package/templates/ui/components/primitives/input.tsx +61 -0
- package/templates/ui/components/primitives/internal/button-loading.tsx +178 -0
- package/templates/ui/components/primitives/label.tsx +16 -0
- package/templates/ui/components/primitives/popover.tsx +126 -0
- package/templates/ui/components/primitives/portal-layer-context.tsx +33 -0
- package/templates/ui/components/primitives/primitive-arrow-icon.tsx +38 -0
- package/templates/ui/components/primitives/scroll-fade-logic.ts +441 -0
- package/templates/ui/components/primitives/scroll-fade-render.tsx +75 -0
- package/templates/ui/components/primitives/scroll-fade-types.ts +41 -0
- package/templates/ui/components/primitives/scroll-fade.tsx +72 -0
- package/templates/ui/components/primitives/select.tsx +408 -0
- package/templates/ui/components/primitives/selection-state.ts +31 -0
- package/templates/ui/components/primitives/separator.tsx +21 -0
- package/templates/ui/components/primitives/slider/index.ts +4 -0
- package/templates/ui/components/primitives/slider/slider-interaction.tsx +96 -0
- package/templates/ui/components/primitives/slider/slider-parts.tsx +303 -0
- package/templates/ui/components/primitives/slider/slider-reset.ts +152 -0
- package/templates/ui/components/primitives/slider/slider-value.ts +114 -0
- package/templates/ui/components/primitives/slider/slider.tsx +511 -0
- package/templates/ui/components/primitives/switch.tsx +35 -0
- package/templates/ui/components/primitives/textarea.tsx +49 -0
- package/templates/ui/components/primitives/toggle-group.tsx +114 -0
- package/templates/ui/components/primitives/toggle.tsx +46 -0
- package/templates/ui/components/primitives/tooltip.tsx +100 -0
- package/templates/ui/hooks/use-mobile.ts +21 -0
- package/templates/ui/index.ts +31 -0
- package/templates/ui/lib/control-outline.ts +3 -0
- package/templates/ui/lib/input-control-style.ts +131 -0
- package/templates/ui/lib/style-guide-color-utils.ts +111 -0
- package/templates/ui/lib/utils.ts +6 -0
- package/templates/ui/styles.css +291 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { getToolcraftControlKeyframeCapability } from "./keyframe-capability";
|
|
4
|
+
import type { ToolcraftControlSchema } from "./types";
|
|
5
|
+
|
|
6
|
+
function control(
|
|
7
|
+
type: ToolcraftControlSchema["type"],
|
|
8
|
+
target: string,
|
|
9
|
+
extra: Partial<ToolcraftControlSchema> = {},
|
|
10
|
+
): ToolcraftControlSchema {
|
|
11
|
+
return {
|
|
12
|
+
defaultValue: 0,
|
|
13
|
+
label: "Control",
|
|
14
|
+
target,
|
|
15
|
+
type,
|
|
16
|
+
...extra,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
describe("getToolcraftControlKeyframeCapability", () => {
|
|
21
|
+
it("marks numeric and visual parameter controls as keyframe-capable by component type", () => {
|
|
22
|
+
for (const type of [
|
|
23
|
+
"slider",
|
|
24
|
+
"rangeSlider",
|
|
25
|
+
"rangeInput",
|
|
26
|
+
"vector",
|
|
27
|
+
"color",
|
|
28
|
+
"gradient",
|
|
29
|
+
"curves",
|
|
30
|
+
"anchorGrid",
|
|
31
|
+
"channelMixer",
|
|
32
|
+
]) {
|
|
33
|
+
expect(
|
|
34
|
+
getToolcraftControlKeyframeCapability(control(type, `effect.${type}`)),
|
|
35
|
+
).toEqual({
|
|
36
|
+
capable: true,
|
|
37
|
+
reason: "control-type",
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("does not let schema keyframeable false hide diamonds for capable control types", () => {
|
|
43
|
+
expect(
|
|
44
|
+
getToolcraftControlKeyframeCapability(
|
|
45
|
+
control("slider", "mesh.blur", { keyframeable: false }),
|
|
46
|
+
),
|
|
47
|
+
).toEqual({
|
|
48
|
+
capable: true,
|
|
49
|
+
reason: "control-type",
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("blocks runtime-owned canvas size targets even when the visual type could otherwise animate", () => {
|
|
54
|
+
expect(
|
|
55
|
+
getToolcraftControlKeyframeCapability(control("text", "canvas.size.width")),
|
|
56
|
+
).toEqual({
|
|
57
|
+
capable: false,
|
|
58
|
+
reason: "runtime-owned-target",
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
expect(
|
|
62
|
+
getToolcraftControlKeyframeCapability(control("slider", "canvas.size.height")),
|
|
63
|
+
).toEqual({
|
|
64
|
+
capable: false,
|
|
65
|
+
reason: "runtime-owned-target",
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("blocks command, source, mode, boolean, text, and choice controls", () => {
|
|
70
|
+
for (const type of [
|
|
71
|
+
"actions",
|
|
72
|
+
"checkbox",
|
|
73
|
+
"code",
|
|
74
|
+
"fileDrop",
|
|
75
|
+
"imagePicker",
|
|
76
|
+
"panelActions",
|
|
77
|
+
"select",
|
|
78
|
+
"segmented",
|
|
79
|
+
"switch",
|
|
80
|
+
"text",
|
|
81
|
+
]) {
|
|
82
|
+
expect(
|
|
83
|
+
getToolcraftControlKeyframeCapability(control(type, `effect.${type}`)),
|
|
84
|
+
).toEqual({
|
|
85
|
+
capable: false,
|
|
86
|
+
reason: "control-type",
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { getToolcraftCanvasSizeTargetDimension } from "./runtime-targets";
|
|
2
|
+
import type { ToolcraftControlSchema } from "./types";
|
|
3
|
+
|
|
4
|
+
export type ToolcraftControlKeyframeCapabilityReason =
|
|
5
|
+
| "control-type"
|
|
6
|
+
| "runtime-owned-target";
|
|
7
|
+
|
|
8
|
+
export type ToolcraftControlKeyframeCapability =
|
|
9
|
+
| {
|
|
10
|
+
capable: true;
|
|
11
|
+
reason: "control-type";
|
|
12
|
+
}
|
|
13
|
+
| {
|
|
14
|
+
capable: false;
|
|
15
|
+
reason: ToolcraftControlKeyframeCapabilityReason;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const keyframeCapableControlTypes = new Set([
|
|
19
|
+
"anchorGrid",
|
|
20
|
+
"channelMixer",
|
|
21
|
+
"color",
|
|
22
|
+
"curves",
|
|
23
|
+
"gradient",
|
|
24
|
+
"rangeInput",
|
|
25
|
+
"rangeSlider",
|
|
26
|
+
"slider",
|
|
27
|
+
"vector",
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
export function getToolcraftControlKeyframeCapability(
|
|
31
|
+
control: ToolcraftControlSchema,
|
|
32
|
+
): ToolcraftControlKeyframeCapability {
|
|
33
|
+
if (getToolcraftCanvasSizeTargetDimension(control.target)) {
|
|
34
|
+
return {
|
|
35
|
+
capable: false,
|
|
36
|
+
reason: "runtime-owned-target",
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (keyframeCapableControlTypes.has(control.type)) {
|
|
41
|
+
return {
|
|
42
|
+
capable: true,
|
|
43
|
+
reason: "control-type",
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
capable: false,
|
|
49
|
+
reason: "control-type",
|
|
50
|
+
};
|
|
51
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export const toolcraftRuntimeOwnedTargets = [
|
|
2
|
+
"canvas.size.width",
|
|
3
|
+
"canvas.size.height",
|
|
4
|
+
] as const;
|
|
5
|
+
|
|
6
|
+
export const toolcraftReservedTargets = [
|
|
7
|
+
...toolcraftRuntimeOwnedTargets,
|
|
8
|
+
"selectedLayer.opacity",
|
|
9
|
+
"selectedLayer.visible",
|
|
10
|
+
] as const;
|
|
11
|
+
|
|
12
|
+
export type ToolcraftRuntimeOwnedTarget =
|
|
13
|
+
(typeof toolcraftRuntimeOwnedTargets)[number];
|
|
14
|
+
|
|
15
|
+
export type ToolcraftReservedTarget = (typeof toolcraftReservedTargets)[number];
|
|
16
|
+
|
|
17
|
+
export function getToolcraftCanvasSizeTargetDimension(
|
|
18
|
+
target: string,
|
|
19
|
+
): "height" | "width" | null {
|
|
20
|
+
switch (target) {
|
|
21
|
+
case "canvas.size.height":
|
|
22
|
+
return "height";
|
|
23
|
+
case "canvas.size.width":
|
|
24
|
+
return "width";
|
|
25
|
+
default:
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function isToolcraftReservedTarget(
|
|
31
|
+
target: string,
|
|
32
|
+
): target is ToolcraftReservedTarget {
|
|
33
|
+
return toolcraftReservedTargets.includes(target as ToolcraftReservedTarget);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function isToolcraftRuntimeOwnedTarget(
|
|
37
|
+
target: string,
|
|
38
|
+
): target is ToolcraftRuntimeOwnedTarget {
|
|
39
|
+
return toolcraftRuntimeOwnedTargets.includes(target as ToolcraftRuntimeOwnedTarget);
|
|
40
|
+
}
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ToolcraftControlLayoutGroupColumns,
|
|
3
|
+
ToolcraftControlLayoutGroupLayout,
|
|
4
|
+
ToolcraftSectionLayout,
|
|
5
|
+
} from "../contracts/types";
|
|
6
|
+
|
|
7
|
+
export type ToolcraftCanvasSize = {
|
|
8
|
+
height: number;
|
|
9
|
+
unit: "px";
|
|
10
|
+
width: number;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type ToolcraftCanvasSizeSource = "app" | "runtime-default";
|
|
14
|
+
|
|
15
|
+
export type ToolcraftCanvasSizingMode =
|
|
16
|
+
| "editable-output"
|
|
17
|
+
| "fixed-output"
|
|
18
|
+
| "intrinsic-media";
|
|
19
|
+
|
|
20
|
+
export type ToolcraftCanvasSizingSchema = {
|
|
21
|
+
mode: ToolcraftCanvasSizingMode;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type ToolcraftPngExportBackground = "include" | "transparent";
|
|
25
|
+
|
|
26
|
+
export type ToolcraftPngExportSchema = {
|
|
27
|
+
background?: ToolcraftPngExportBackground;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type ToolcraftExportSchema = {
|
|
31
|
+
png?: ToolcraftPngExportSchema;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type ResolvedToolcraftExportSchema = {
|
|
35
|
+
png: Required<ToolcraftPngExportSchema>;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type ToolcraftAssemblyComponentId =
|
|
39
|
+
| "canvas"
|
|
40
|
+
| "controlsPanel"
|
|
41
|
+
| "layersPanel"
|
|
42
|
+
| "timelinePanel"
|
|
43
|
+
| "toolbar";
|
|
44
|
+
|
|
45
|
+
export type ToolcraftAssemblyCapability =
|
|
46
|
+
| "canvas.draggable"
|
|
47
|
+
| "canvas.editableSize"
|
|
48
|
+
| "canvas.upload"
|
|
49
|
+
| "controls.defaults"
|
|
50
|
+
| "controls.panel"
|
|
51
|
+
| "history.undoRedo"
|
|
52
|
+
| "layers.groups"
|
|
53
|
+
| "layers.panel"
|
|
54
|
+
| "layers.selection"
|
|
55
|
+
| "layers.visibility"
|
|
56
|
+
| "panels.doubleClickReset"
|
|
57
|
+
| "panels.draggable"
|
|
58
|
+
| "panels.snap"
|
|
59
|
+
| "timeline.duration"
|
|
60
|
+
| "timeline.keyframes"
|
|
61
|
+
| "timeline.panel"
|
|
62
|
+
| "timeline.playback"
|
|
63
|
+
| "toolbar.history"
|
|
64
|
+
| "toolbar.radar"
|
|
65
|
+
| "toolbar.theme"
|
|
66
|
+
| "toolbar.zoom";
|
|
67
|
+
|
|
68
|
+
export type ToolcraftAssemblyCommand =
|
|
69
|
+
| "canvas.center"
|
|
70
|
+
| "canvas.panBy"
|
|
71
|
+
| "canvas.setOffset"
|
|
72
|
+
| "canvas.setSize"
|
|
73
|
+
| "canvas.setViewport"
|
|
74
|
+
| "canvas.zoomIn"
|
|
75
|
+
| "canvas.zoomOut"
|
|
76
|
+
| "canvas.zoomReset"
|
|
77
|
+
| "controls.apply"
|
|
78
|
+
| "controls.reset"
|
|
79
|
+
| "controls.setValue"
|
|
80
|
+
| "history.redo"
|
|
81
|
+
| "history.undo"
|
|
82
|
+
| "layers.add"
|
|
83
|
+
| "layers.delete"
|
|
84
|
+
| "layers.moveToGroup"
|
|
85
|
+
| "layers.rename"
|
|
86
|
+
| "layers.reorder"
|
|
87
|
+
| "layers.select"
|
|
88
|
+
| "layers.toggleCollapsed"
|
|
89
|
+
| "layers.toggleVisibility"
|
|
90
|
+
| "media.delete"
|
|
91
|
+
| "media.import"
|
|
92
|
+
| "panels.resetOffset"
|
|
93
|
+
| "panels.setOffset"
|
|
94
|
+
| "timeline.changeKeyframeEasing"
|
|
95
|
+
| "timeline.deleteControlKeyframes"
|
|
96
|
+
| "timeline.deleteKeyframe"
|
|
97
|
+
| "timeline.moveKeyframe"
|
|
98
|
+
| "timeline.selectKeyframe"
|
|
99
|
+
| "timeline.setCurrentTime"
|
|
100
|
+
| "timeline.setDuration"
|
|
101
|
+
| "timeline.setExpanded"
|
|
102
|
+
| "timeline.setPlaying"
|
|
103
|
+
| "timeline.toggleControlKeyframes"
|
|
104
|
+
| "timeline.toggleExpanded"
|
|
105
|
+
| "timeline.toggleLoop"
|
|
106
|
+
| "timeline.togglePlayback";
|
|
107
|
+
|
|
108
|
+
export type ToolcraftAssemblyPanelContract = {
|
|
109
|
+
capabilities: readonly ToolcraftAssemblyCapability[];
|
|
110
|
+
commands: readonly ToolcraftAssemblyCommand[];
|
|
111
|
+
defaultPlacement: "bottom" | "left" | "right" | "top";
|
|
112
|
+
dragMode: "handle" | "panel";
|
|
113
|
+
enabled: boolean;
|
|
114
|
+
requiredWrapper: "PanelHost";
|
|
115
|
+
snapEdges: readonly ("bottom" | "left" | "right" | "top")[];
|
|
116
|
+
visualComponent: string;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export type ToolcraftAssemblyCanvasContract = {
|
|
120
|
+
capabilities: readonly ToolcraftAssemblyCapability[];
|
|
121
|
+
commands: readonly ToolcraftAssemblyCommand[];
|
|
122
|
+
enabled: boolean;
|
|
123
|
+
visualComponent: "CanvasShell";
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export type ToolcraftAssemblyContract = {
|
|
127
|
+
capabilities: readonly ToolcraftAssemblyCapability[];
|
|
128
|
+
commands: readonly ToolcraftAssemblyCommand[];
|
|
129
|
+
components: readonly ToolcraftAssemblyComponentId[];
|
|
130
|
+
surfaces: {
|
|
131
|
+
canvas: ToolcraftAssemblyCanvasContract;
|
|
132
|
+
panels: {
|
|
133
|
+
controls?: ToolcraftAssemblyPanelContract;
|
|
134
|
+
layers?: ToolcraftAssemblyPanelContract;
|
|
135
|
+
timeline?: ToolcraftAssemblyPanelContract;
|
|
136
|
+
toolbar: ToolcraftAssemblyPanelContract;
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export type ToolcraftCanvasSchema = {
|
|
142
|
+
draggable?: boolean;
|
|
143
|
+
enabled: boolean;
|
|
144
|
+
size?: ToolcraftCanvasSize;
|
|
145
|
+
sizing?: ToolcraftCanvasSizingSchema;
|
|
146
|
+
upload?: boolean;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export type ToolcraftToolbarSchema = {
|
|
150
|
+
history?: boolean;
|
|
151
|
+
radar?: boolean;
|
|
152
|
+
theme?: boolean;
|
|
153
|
+
zoom?: boolean;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
export type ToolcraftTimelineMode = "keyframes" | "playback";
|
|
157
|
+
|
|
158
|
+
export type ToolcraftTimelinePanelSchema =
|
|
159
|
+
| boolean
|
|
160
|
+
| {
|
|
161
|
+
enabled?: boolean;
|
|
162
|
+
mode?: ToolcraftTimelineMode;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export type ResolvedToolcraftTimelinePanelSchema = {
|
|
166
|
+
enabled: boolean;
|
|
167
|
+
mode: ToolcraftTimelineMode;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export type ToolcraftPersistableStateSlice =
|
|
171
|
+
| "canvas"
|
|
172
|
+
| "layers"
|
|
173
|
+
| "panels"
|
|
174
|
+
| "timeline"
|
|
175
|
+
| "values";
|
|
176
|
+
|
|
177
|
+
export type ToolcraftNoPersistenceSchema = {
|
|
178
|
+
storage?: "none";
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export type ToolcraftLocalStoragePersistenceSchema = {
|
|
182
|
+
include: readonly ToolcraftPersistableStateSlice[];
|
|
183
|
+
key: `toolcraft:${string}:state:v${number}`;
|
|
184
|
+
storage: "localStorage";
|
|
185
|
+
version: number;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
export type ToolcraftPersistenceSchema =
|
|
189
|
+
| ToolcraftNoPersistenceSchema
|
|
190
|
+
| ToolcraftLocalStoragePersistenceSchema;
|
|
191
|
+
|
|
192
|
+
export type ResolvedToolcraftPersistenceSchema =
|
|
193
|
+
| { storage: "none" }
|
|
194
|
+
| ToolcraftLocalStoragePersistenceSchema;
|
|
195
|
+
|
|
196
|
+
export type ToolcraftSettingsTransferMode = boolean | "auto";
|
|
197
|
+
|
|
198
|
+
export type ToolcraftSettingsTransferObjectSchema = {
|
|
199
|
+
appId?: string;
|
|
200
|
+
enabled?: ToolcraftSettingsTransferMode;
|
|
201
|
+
fileName?: string;
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
export type ToolcraftSettingsTransferSchema =
|
|
205
|
+
| ToolcraftSettingsTransferMode
|
|
206
|
+
| ToolcraftSettingsTransferObjectSchema;
|
|
207
|
+
|
|
208
|
+
export type ResolvedToolcraftSettingsTransferSchema = {
|
|
209
|
+
appId: string;
|
|
210
|
+
enabled: boolean;
|
|
211
|
+
fileName: string;
|
|
212
|
+
mode: ToolcraftSettingsTransferMode;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export type ToolcraftActionCommand = "controls.apply" | "controls.reset";
|
|
216
|
+
|
|
217
|
+
export type ToolcraftActionSchema = {
|
|
218
|
+
command?: ToolcraftActionCommand;
|
|
219
|
+
icon?:
|
|
220
|
+
| "check"
|
|
221
|
+
| "copy"
|
|
222
|
+
| "download"
|
|
223
|
+
| "download-simple"
|
|
224
|
+
| "eraser"
|
|
225
|
+
| "export"
|
|
226
|
+
| "rotate-ccw"
|
|
227
|
+
| "shuffle"
|
|
228
|
+
| "wand-sparkles";
|
|
229
|
+
label?: string;
|
|
230
|
+
value: string;
|
|
231
|
+
variant?: "default" | "destructive" | "ghost" | "link" | "outline" | "secondary";
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
export type ToolcraftImagePickerItemSchema = {
|
|
235
|
+
alt?: string;
|
|
236
|
+
src: string;
|
|
237
|
+
value: string;
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
export type ToolcraftControlOrderRole =
|
|
241
|
+
| "action"
|
|
242
|
+
| "advanced"
|
|
243
|
+
| "color"
|
|
244
|
+
| "detail"
|
|
245
|
+
| "input"
|
|
246
|
+
| "mode"
|
|
247
|
+
| "primary"
|
|
248
|
+
| "spatial"
|
|
249
|
+
| "strength";
|
|
250
|
+
|
|
251
|
+
export type ToolcraftControlPerformanceRole =
|
|
252
|
+
| "responsiveness"
|
|
253
|
+
| "workload";
|
|
254
|
+
|
|
255
|
+
export type ToolcraftControlConditionSchema = {
|
|
256
|
+
equals?: unknown;
|
|
257
|
+
greaterThan?: number;
|
|
258
|
+
greaterThanOrEqual?: number;
|
|
259
|
+
lessThan?: number;
|
|
260
|
+
lessThanOrEqual?: number;
|
|
261
|
+
notOneOf?: readonly unknown[];
|
|
262
|
+
notEquals?: unknown;
|
|
263
|
+
oneOf?: readonly unknown[];
|
|
264
|
+
target: string;
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
export type ToolcraftControlDisabledConditionSchema =
|
|
268
|
+
ToolcraftControlConditionSchema;
|
|
269
|
+
|
|
270
|
+
export type ToolcraftColorOpacityValueSchema = {
|
|
271
|
+
hex: string;
|
|
272
|
+
opacity?: number;
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
export type ToolcraftFontPickerValueSchema = {
|
|
276
|
+
color?: string;
|
|
277
|
+
fontId: string;
|
|
278
|
+
fontSize?: number;
|
|
279
|
+
fontWeight?: string;
|
|
280
|
+
letterSpacing?: "tight" | "tighter" | "normal" | "wide" | "wider" | "widest";
|
|
281
|
+
lineHeight?: "loose" | "none" | "normal" | "relaxed" | "snug" | "tight";
|
|
282
|
+
opacity?: number;
|
|
283
|
+
textCase?: "capitalize" | "lowercase" | "original" | "titleCase" | "uppercase";
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
export type ToolcraftCurveInterpolation = "monotone" | "smooth";
|
|
287
|
+
|
|
288
|
+
export type ToolcraftControlSchema = {
|
|
289
|
+
accept?: string;
|
|
290
|
+
actions?: readonly (ToolcraftActionSchema | string)[];
|
|
291
|
+
commitMode?: "content" | "setting";
|
|
292
|
+
defaultValue?: unknown;
|
|
293
|
+
description?: string;
|
|
294
|
+
disabled?: boolean;
|
|
295
|
+
disabledWhen?: ToolcraftControlDisabledConditionSchema;
|
|
296
|
+
interpolation?: ToolcraftCurveInterpolation;
|
|
297
|
+
items?: readonly ToolcraftImagePickerItemSchema[];
|
|
298
|
+
keyframeable?: boolean;
|
|
299
|
+
label?: boolean | string;
|
|
300
|
+
markerCount?: number;
|
|
301
|
+
max?: number;
|
|
302
|
+
min?: number;
|
|
303
|
+
orderRole?: ToolcraftControlOrderRole;
|
|
304
|
+
performanceReason?: string;
|
|
305
|
+
performanceRole?: ToolcraftControlPerformanceRole;
|
|
306
|
+
options?: readonly { label: string; value: string }[];
|
|
307
|
+
step?: number;
|
|
308
|
+
target: string;
|
|
309
|
+
type: string;
|
|
310
|
+
unit?: string;
|
|
311
|
+
valueLabel?: string;
|
|
312
|
+
variant?: string;
|
|
313
|
+
visibleWhen?: ToolcraftControlConditionSchema;
|
|
314
|
+
xLabel?: string;
|
|
315
|
+
yLabel?: string;
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
export type ToolcraftControlLayoutGroupSchema = {
|
|
319
|
+
columns?: ToolcraftControlLayoutGroupColumns;
|
|
320
|
+
controls: readonly string[];
|
|
321
|
+
layout: ToolcraftControlLayoutGroupLayout;
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
export type ToolcraftControlSectionSchema = {
|
|
325
|
+
actionGroup?: "primary" | "secondary";
|
|
326
|
+
controls: Record<string, ToolcraftControlSchema>;
|
|
327
|
+
layout?: ToolcraftSectionLayout;
|
|
328
|
+
layoutGroups?: readonly ToolcraftControlLayoutGroupSchema[];
|
|
329
|
+
title?: string;
|
|
330
|
+
visibleWhen?: ToolcraftControlConditionSchema;
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
export type ToolcraftControlsPanelSchema = {
|
|
334
|
+
sections: readonly ToolcraftControlSectionSchema[];
|
|
335
|
+
title: string;
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
export type ToolcraftPanelsSchema = {
|
|
339
|
+
controls?: ToolcraftControlsPanelSchema;
|
|
340
|
+
layers?: boolean;
|
|
341
|
+
timeline?: ToolcraftTimelinePanelSchema;
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
export type ResolvedToolcraftPanelsSchema = {
|
|
345
|
+
controls?: ToolcraftControlsPanelSchema;
|
|
346
|
+
layers?: boolean;
|
|
347
|
+
timeline?: ResolvedToolcraftTimelinePanelSchema;
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
export type ToolcraftAppSchema = {
|
|
351
|
+
canvas: ToolcraftCanvasSchema;
|
|
352
|
+
export?: ToolcraftExportSchema;
|
|
353
|
+
panels: ToolcraftPanelsSchema;
|
|
354
|
+
persistence?: ToolcraftPersistenceSchema;
|
|
355
|
+
settingsTransfer?: ToolcraftSettingsTransferSchema;
|
|
356
|
+
toolbar?: ToolcraftToolbarSchema;
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
export type ResolvedToolcraftAppSchema = {
|
|
360
|
+
assembly: ToolcraftAssemblyContract;
|
|
361
|
+
canvas: Required<ToolcraftCanvasSchema> & {
|
|
362
|
+
size: ToolcraftCanvasSize;
|
|
363
|
+
sizeSource: ToolcraftCanvasSizeSource;
|
|
364
|
+
};
|
|
365
|
+
export: ResolvedToolcraftExportSchema;
|
|
366
|
+
panels: ResolvedToolcraftPanelsSchema;
|
|
367
|
+
persistence: ResolvedToolcraftPersistenceSchema;
|
|
368
|
+
settingsTransfer: ResolvedToolcraftSettingsTransferSchema;
|
|
369
|
+
toolbar: Required<ToolcraftToolbarSchema>;
|
|
370
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const toolcraftCanvasZoomMin = 25;
|
|
2
|
+
export const toolcraftCanvasZoomMax = 400;
|
|
3
|
+
export const toolcraftCanvasZoomStep = 10;
|
|
4
|
+
export const toolcraftCanvasZoomDefault = 70;
|
|
5
|
+
|
|
6
|
+
export function clampToolcraftCanvasZoom(zoom: number): number {
|
|
7
|
+
return Math.min(toolcraftCanvasZoomMax, Math.max(toolcraftCanvasZoomMin, zoom));
|
|
8
|
+
}
|