@pixel-point/toolcraft 0.0.9 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +42 -9
  2. package/package.json +1 -1
  3. package/src/generate.mjs +14 -6
  4. package/src/generate.test.mjs +28 -0
  5. package/templates/runtime/contracts/component-contracts.test.ts +148 -34
  6. package/templates/runtime/contracts/component-contracts.ts +79 -38
  7. package/templates/runtime/contracts/decision-contracts.test.ts +33 -1
  8. package/templates/runtime/contracts/decision-contracts.ts +19 -6
  9. package/templates/runtime/export/export.test.ts +63 -0
  10. package/templates/runtime/export/export.ts +55 -0
  11. package/templates/runtime/index.ts +1 -0
  12. package/templates/runtime/react/canvas-shell.test.tsx +58 -4
  13. package/templates/runtime/react/canvas-shell.tsx +31 -9
  14. package/templates/runtime/react/controls-panel.test.tsx +474 -27
  15. package/templates/runtime/react/controls-panel.tsx +71 -26
  16. package/templates/runtime/react/runtime-public-api.test.tsx +1 -1
  17. package/templates/runtime/react/settings-transfer.test.ts +4 -0
  18. package/templates/runtime/react/settings-transfer.ts +6 -1
  19. package/templates/runtime/react/timeline-panel.test.tsx +14 -0
  20. package/templates/runtime/react/timeline-panel.tsx +44 -7
  21. package/templates/runtime/react/toolcraft-app.integration.test.tsx +9 -1
  22. package/templates/runtime/react/toolcraft-app.test.tsx +112 -3
  23. package/templates/runtime/react/toolcraft-app.tsx +56 -37
  24. package/templates/runtime/schema/define-toolcraft.test.ts +225 -173
  25. package/templates/runtime/schema/define-toolcraft.ts +117 -247
  26. package/templates/runtime/schema/runtime-targets.ts +21 -0
  27. package/templates/runtime/schema/types.ts +41 -0
  28. package/templates/runtime/state/create-template-state.test.ts +156 -0
  29. package/templates/runtime/state/create-template-state.ts +38 -8
  30. package/templates/runtime/state/media-defaults.ts +105 -0
  31. package/templates/runtime/state/persistence.test.ts +58 -0
  32. package/templates/runtime/state/persistence.ts +105 -1
  33. package/templates/runtime/state/reducer.test.ts +280 -4
  34. package/templates/runtime/state/reducer.ts +195 -9
  35. package/templates/runtime/state/timeline-loop.test.ts +71 -0
  36. package/templates/runtime/state/timeline-loop.ts +35 -0
  37. package/templates/runtime/state/types.ts +27 -0
  38. package/templates/runtime/testing/performance.test.ts +657 -2
  39. package/templates/runtime/testing/performance.ts +789 -49
  40. package/templates/starter/AGENTS.md +22 -16
  41. package/templates/starter/docs/toolcraft/README.md +8 -4
  42. package/templates/starter/docs/toolcraft/acceptance-testing.md +38 -7
  43. package/templates/starter/docs/toolcraft/agent-worklog.md +1 -0
  44. package/templates/starter/docs/toolcraft/assembly-workflow.md +51 -20
  45. package/templates/starter/docs/toolcraft/component-rules.md +49 -37
  46. package/templates/starter/docs/toolcraft/decision-contract.md +2 -0
  47. package/templates/starter/docs/toolcraft/performance.md +30 -10
  48. package/templates/starter/docs/toolcraft/schema-reference.md +134 -33
  49. package/templates/starter/docs/toolcraft/workflow.md +5 -2
  50. package/templates/starter/e2e/app-browser-acceptance.spec.ts +3 -3
  51. package/templates/starter/e2e/app-performance.spec.ts +55 -2
  52. package/templates/starter/e2e/performance-helpers.ts +45 -0
  53. package/templates/starter/index.html +1 -0
  54. package/templates/starter/package.json +1 -0
  55. package/templates/starter/playwright.config.ts +1 -1
  56. package/templates/starter/scripts/check-toolcraft-docs.mjs +1 -0
  57. package/templates/starter/scripts/run-vite-on-free-port.mjs +82 -16
  58. package/templates/starter/scripts/toolcraft-port.mjs +178 -0
  59. package/templates/starter/scripts/toolcraft-port.test.mjs +147 -0
  60. package/templates/starter/src/app/starter-acceptance.test.ts +2573 -313
  61. package/templates/starter/src/app/starter-acceptance.ts +978 -81
  62. package/templates/starter/src/app/starter-performance.test.ts +111 -7
  63. package/templates/starter/src/app/starter-performance.ts +5 -0
  64. package/templates/starter/src/app/starter-schema.test.ts +32 -7
  65. package/templates/starter/src/app/starter-schema.ts +6 -2
  66. package/templates/starter/vite.config.ts +58 -2
  67. package/templates/ui/components/controls/actions/actions-control.tsx +46 -3
  68. package/templates/ui/components/controls/color/palette-control.tsx +34 -4
  69. package/templates/ui/components/controls/file-drop/file-drop-control.tsx +186 -14
  70. package/templates/ui/components/controls/file-drop/index.ts +6 -1
  71. package/templates/ui/components/controls/index.ts +2 -0
  72. package/templates/ui/components/controls/range-slider/range-slider-value.ts +3 -1
  73. package/templates/ui/components/controls/select/select-control.tsx +4 -26
  74. package/templates/ui/components/controls/vector/vector-control.tsx +25 -4
  75. package/templates/ui/components/panel/panel-actions.tsx +1 -1
@@ -0,0 +1,35 @@
1
+ import type { ToolcraftTimelineState } from "./types";
2
+
3
+ export type ToolcraftTimelineLoopOptions = Pick<
4
+ ToolcraftTimelineState,
5
+ "currentTimeSeconds" | "durationSeconds"
6
+ >;
7
+
8
+ function getPositiveModulo(value: number, modulo: number): number {
9
+ return ((value % modulo) + modulo) % modulo;
10
+ }
11
+
12
+ export function getToolcraftTimelineLoopTime({
13
+ currentTimeSeconds,
14
+ durationSeconds,
15
+ }: ToolcraftTimelineLoopOptions): number {
16
+ if (
17
+ !Number.isFinite(currentTimeSeconds) ||
18
+ !Number.isFinite(durationSeconds) ||
19
+ durationSeconds <= 0
20
+ ) {
21
+ return 0;
22
+ }
23
+
24
+ return getPositiveModulo(currentTimeSeconds, durationSeconds);
25
+ }
26
+
27
+ export function getToolcraftTimelineLoopProgress(
28
+ options: ToolcraftTimelineLoopOptions,
29
+ ): number {
30
+ if (!Number.isFinite(options.durationSeconds) || options.durationSeconds <= 0) {
31
+ return 0;
32
+ }
33
+
34
+ return getToolcraftTimelineLoopTime(options) / options.durationSeconds;
35
+ }
@@ -37,6 +37,11 @@ export type ToolcraftCommand =
37
37
  panelId: ToolcraftPanelId;
38
38
  type: "panels.setOffset";
39
39
  }
40
+ | {
41
+ hidden: boolean;
42
+ panelId: ToolcraftPanelId;
43
+ type: "panels.setHidden";
44
+ }
40
45
  | { panelId: ToolcraftPanelId; type: "panels.resetOffset" }
41
46
  | {
42
47
  asset: Omit<ToolcraftMediaAsset, "id" | "layerId"> & {
@@ -49,6 +54,11 @@ export type ToolcraftCommand =
49
54
  }
50
55
  | { mediaId: string; type: "media.delete" }
51
56
  | { mediaIds: string[]; type: "media.reorder" }
57
+ | {
58
+ mediaId: string;
59
+ operation: ToolcraftMediaTransformOperation;
60
+ type: "media.transform";
61
+ }
52
62
  | { currentTimeSeconds: number; type: "timeline.setCurrentTime" }
53
63
  | { durationSeconds: number; type: "timeline.setDuration" }
54
64
  | { expanded: boolean; type: "timeline.setExpanded" }
@@ -106,10 +116,12 @@ export const toolcraftRuntimeCommandTypes = [
106
116
  "canvas.zoomReset",
107
117
  "canvas.setViewport",
108
118
  "panels.setOffset",
119
+ "panels.setHidden",
109
120
  "panels.resetOffset",
110
121
  "media.import",
111
122
  "media.delete",
112
123
  "media.reorder",
124
+ "media.transform",
113
125
  "timeline.setCurrentTime",
114
126
  "timeline.setDuration",
115
127
  "timeline.setExpanded",
@@ -171,8 +183,21 @@ export type ToolcraftMediaAsset = {
171
183
  position: ToolcraftPoint;
172
184
  size?: ToolcraftCanvasSize;
173
185
  sourceTarget?: string;
186
+ transform?: ToolcraftMediaTransform;
187
+ };
188
+
189
+ export type ToolcraftMediaTransform = {
190
+ flipHorizontal?: boolean;
191
+ flipVertical?: boolean;
192
+ rotationDeg?: 0 | 90 | 180 | 270;
174
193
  };
175
194
 
195
+ export type ToolcraftMediaTransformOperation =
196
+ | "flip-horizontal"
197
+ | "flip-vertical"
198
+ | "rotate-left"
199
+ | "rotate-right";
200
+
176
201
  export type ToolcraftHistoryPatch = {
177
202
  after: Record<string, unknown>;
178
203
  before: Record<string, unknown>;
@@ -223,6 +248,8 @@ export type ToolcraftPanelId = "controls" | "layers" | "timeline" | "toolbar";
223
248
 
224
249
  export type ToolcraftPanelState = {
225
250
  collapsed?: boolean;
251
+ extended?: boolean;
252
+ hidden?: boolean;
226
253
  offset: { x: number; y: number };
227
254
  };
228
255