@pixel-point/toolcraft 0.0.16 → 0.0.18
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/package.json +1 -1
- package/src/generate-performance-iteration-execution.test.mjs +2 -2
- package/src/generate-test-demand-only-lifecycle.mjs +14 -3
- package/src/generate-test-dependency-sandbox.mjs +42 -5
- package/src/generate-test-doc-assertions.mjs +109 -69
- package/src/generate-test-doc-assertions.test.mjs +65 -0
- package/src/generate-test-doc-policy-assertions.mjs +92 -0
- package/src/generate-test-file-assertions.mjs +36 -118
- package/src/generate-test-output-assertions.mjs +95 -0
- package/src/generate-test-package-assertions.mjs +6 -0
- package/src/generate-test-performance-boundary-assertions.mjs +45 -0
- package/src/generate-test-product-fixture.mjs +1 -0
- package/src/generate-test-product-fixture.test.mjs +18 -0
- package/src/generate-test-product-iteration.mjs +1 -0
- package/src/generate-test-product-iteration.test.mjs +18 -0
- package/src/generate-test-runtime-boundary-assertions.mjs +158 -0
- package/src/generate-test-standalone-assertions.mjs +10 -0
- package/src/generate-test-standalone-delivery-stages.mjs +14 -6
- package/src/generate.test.mjs +14 -0
- package/templates/runtime/contracts/component-contracts.choices.test.ts +59 -12
- package/templates/runtime/contracts/component-contracts.choices.ts +58 -12
- package/templates/runtime/contracts/component-contracts.inputs.test.ts +6 -6
- package/templates/runtime/contracts/component-contracts.inputs.ts +6 -6
- package/templates/runtime/contracts/component-contracts.media-custom.test.ts +8 -2
- package/templates/runtime/contracts/component-contracts.media-custom.ts +8 -2
- package/templates/runtime/contracts/component-contracts.runtime-acceptance.test.ts +21 -6
- package/templates/runtime/contracts/component-contracts.runtime-labels.test.ts +7 -1
- package/templates/runtime/contracts/component-contracts.runtime-panels.test.ts +4 -1
- package/templates/runtime/contracts/component-contracts.runtime-shell.test.ts +4 -1
- package/templates/runtime/contracts/component-contracts.runtime.ts +15 -10
- package/templates/runtime/contracts/component-contracts.test.ts +2 -0
- package/templates/runtime/contracts/decision-contracts.test.ts +43 -4
- package/templates/runtime/contracts/decision-contracts.ts +10 -10
- package/templates/runtime/contracts/performance-verification-policy.test.ts +59 -6
- package/templates/runtime/contracts/performance-verification-policy.ts +5 -2
- package/templates/runtime/export/artifact-download.test.ts +71 -0
- package/templates/runtime/export/artifact-download.ts +80 -0
- package/templates/runtime/export/artifact-export-request.ts +23 -0
- package/templates/runtime/export/artifact-export-settings.test.ts +75 -0
- package/templates/runtime/export/artifact-export-settings.ts +96 -0
- package/templates/runtime/export/artifact-frame-renderer.test.ts +107 -0
- package/templates/runtime/export/artifact-frame-renderer.ts +96 -0
- package/templates/runtime/export/artifact-frame-state.test.ts +54 -0
- package/templates/runtime/export/artifact-frame-state.ts +44 -0
- package/templates/runtime/export/artifact-scene-frame.test.ts +84 -0
- package/templates/runtime/export/artifact-scene-frame.ts +118 -0
- package/templates/runtime/export/export-background.ts +46 -0
- package/templates/runtime/export/export-error.ts +43 -0
- package/templates/runtime/export/export.test.ts +49 -226
- package/templates/runtime/export/image-artifact-export.test.ts +111 -0
- package/templates/runtime/export/image-artifact-export.ts +145 -0
- package/templates/runtime/export/index.ts +44 -3
- package/templates/runtime/export/product-export-renderer.test.ts +77 -0
- package/templates/runtime/export/product-export-renderer.ts +63 -0
- package/templates/runtime/export/video-artifact-export.test.ts +166 -0
- package/templates/runtime/export/video-artifact-export.ts +164 -0
- package/templates/runtime/export/video-encoding-backend.ts +124 -0
- package/templates/runtime/export/video-encoding-policy.test.ts +68 -0
- package/templates/runtime/export/video-encoding-policy.ts +86 -0
- package/templates/runtime/export/video-frame-schedule.test.ts +58 -0
- package/templates/runtime/export/video-frame-schedule.ts +42 -0
- package/templates/runtime/index.ts +3 -0
- package/templates/runtime/model-import/model-import-limits.ts +15 -4
- package/templates/runtime/react/app-shell/runtime-public-api-runtime.test.tsx +291 -0
- package/templates/runtime/react/app-shell/runtime-public-api-test-support.ts +21 -0
- package/templates/runtime/react/app-shell/runtime-public-api.test.tsx +15 -304
- package/templates/runtime/react/app-shell/toolcraft-app.scene-export.test.tsx +41 -27
- package/templates/runtime/react/app-shell/toolcraft-app.tsx +39 -11
- package/templates/runtime/react/app-shell/toolcraft-source-asset-context.test.tsx +16 -57
- package/templates/runtime/react/app-shell/toolcraft-source-asset-context.tsx +75 -434
- package/templates/runtime/react/app-shell/toolcraft-source-asset-owner.test.ts +194 -0
- package/templates/runtime/react/app-shell/toolcraft-source-asset-owner.ts +227 -0
- package/templates/runtime/react/app-shell/toolcraft-source-asset-provider-ownership.test.tsx +243 -0
- package/templates/runtime/react/app-shell/toolcraft-source-asset-test-support.ts +51 -0
- package/templates/runtime/react/app-shell/toolcraft-unavailable-resource-proof.test.ts +138 -0
- package/templates/runtime/react/app-shell/toolcraft-unavailable-resource-proof.ts +378 -0
- package/templates/runtime/react/canvas/canvas-shell-rendering.test.tsx +76 -0
- package/templates/runtime/react/canvas/canvas-shell-test-utils.tsx +13 -1
- package/templates/runtime/react/canvas/canvas-shell.tsx +16 -1
- package/templates/runtime/react/canvas/product-scene-surface.test.tsx +195 -0
- package/templates/runtime/react/canvas/product-scene-surface.tsx +155 -0
- package/templates/runtime/react/canvas/runtime-scene-export.ts +1 -1
- package/templates/runtime/react/controls-panel/__tests__/control-conditions.test.ts +61 -0
- package/templates/runtime/react/controls-panel/__tests__/controls-panel.collection-actions.test.tsx +89 -0
- package/templates/runtime/react/controls-panel/__tests__/controls-panel.control-visibility.test.tsx +40 -19
- package/templates/runtime/react/controls-panel/__tests__/controls-panel.footer-actions.test.tsx +7 -12
- package/templates/runtime/react/controls-panel/__tests__/controls-panel.scene-export-actions.test.tsx +18 -84
- package/templates/runtime/react/controls-panel/__tests__/controls-panel.source-collection.test.tsx +62 -0
- package/templates/runtime/react/controls-panel/__tests__/controls-panel.source-color-bank.test.tsx +67 -0
- package/templates/runtime/react/controls-panel/actions/controls-panel-actions.ts +43 -87
- package/templates/runtime/react/controls-panel/actions/export-action-runner.ts +68 -0
- package/templates/runtime/react/controls-panel/conditions/control-conditions.ts +32 -119
- package/templates/runtime/react/controls-panel/layout/controls-panel-control-group.tsx +5 -2
- package/templates/runtime/react/controls-panel/layout/controls-panel-layout.tsx +10 -8
- package/templates/runtime/react/controls-panel/layout/controls-panel-section.tsx +3 -3
- package/templates/runtime/react/controls-panel/renderers/controls-panel-collection-item-fields.test.tsx +63 -0
- package/templates/runtime/react/controls-panel/renderers/controls-panel-collection-item-fields.tsx +138 -0
- package/templates/runtime/react/controls-panel/renderers/controls-panel-collection-items.tsx +104 -0
- package/templates/runtime/react/controls-panel/renderers/controls-panel-collection-renderer.tsx +115 -236
- package/templates/runtime/react/controls-panel/renderers/controls-panel-file-drop-item-controls.test.tsx +95 -0
- package/templates/runtime/react/controls-panel/renderers/controls-panel-file-drop-item-controls.tsx +82 -0
- package/templates/runtime/react/controls-panel/renderers/controls-panel-media-renderer.test.tsx +73 -1
- package/templates/runtime/react/controls-panel/renderers/controls-panel-media-renderer.tsx +50 -1
- package/templates/runtime/react/controls-panel/renderers/controls-panel-renderer-registry.test.ts +1 -1
- package/templates/runtime/react/controls-panel/renderers/controls-panel-renderer-registry.ts +2 -1
- package/templates/runtime/react/controls-panel/values/controls-panel-collection-values.ts +38 -6
- package/templates/runtime/react/controls-panel/values/controls-panel-value-labels.ts +1 -0
- package/templates/runtime/react/index.ts +4 -0
- package/templates/runtime/react/model-rendering/model-export.ts +1 -1
- package/templates/runtime/react/orientation-gizmo/orientation-gizmo-selection.ts +5 -5
- package/templates/runtime/react/orientation-gizmo/use-toolcraft-orientation-control-selection.ts +2 -2
- package/templates/runtime/react/panel-host/panel-host-runtime-placement.test.tsx +30 -0
- package/templates/runtime/react/panel-host/panel-host.tsx +4 -0
- package/templates/runtime/scene/scene-bounds.test.ts +23 -0
- package/templates/runtime/scene/scene-bounds.ts +32 -19
- package/templates/runtime/schema/app-capabilities.test.ts +4 -0
- package/templates/runtime/schema/canvas-render-scale.ts +62 -0
- package/templates/runtime/schema/collection-item-controls.ts +29 -0
- package/templates/runtime/schema/control-applicability.test.ts +127 -0
- package/templates/runtime/schema/control-applicability.ts +433 -0
- package/templates/runtime/schema/control-schema-normalization.ts +177 -11
- package/templates/runtime/schema/controls-panel-actions.ts +2 -2
- package/templates/runtime/schema/controls-panel-section-id.test.ts +1 -1
- package/templates/runtime/schema/controls-panel-section-layout.ts +14 -9
- package/templates/runtime/schema/controls-panel-section-roundtrip.test.ts +62 -3
- package/templates/runtime/schema/define-toolcraft.collection-actions-item-controls.test.ts +127 -0
- package/templates/runtime/schema/define-toolcraft.control-sections.test.ts +10 -4
- package/templates/runtime/schema/define-toolcraft.file-drop-item-controls.test.ts +98 -0
- package/templates/runtime/schema/define-toolcraft.file-drop-normalization.test.ts +27 -0
- package/templates/runtime/schema/define-toolcraft.segmented-control-fit.test.ts +20 -2
- package/templates/runtime/schema/define-toolcraft.setup-background.test.ts +1 -1
- package/templates/runtime/schema/define-toolcraft.setup-canvas.test.ts +16 -3
- package/templates/runtime/schema/define-toolcraft.setup-render-scale-timeline.test.ts +71 -3
- package/templates/runtime/schema/define-toolcraft.source-collection.test.ts +79 -0
- package/templates/runtime/schema/define-toolcraft.ts +1 -1
- package/templates/runtime/schema/runtime-setup-section.ts +24 -5
- package/templates/runtime/schema/schema-resolvers.ts +0 -56
- package/templates/runtime/schema/types.ts +72 -17
- package/templates/runtime/state/canvas-background-state.ts +6 -0
- package/templates/runtime/testing/performance-render-plan-integration.test.ts +64 -0
- package/templates/runtime/testing/performance-renderer-pipeline-validation.ts +18 -1
- package/templates/starter/AGENTS.md +18 -15
- package/templates/starter/NOTICE.md +6 -0
- package/templates/starter/docs/toolcraft/README.md +2 -1
- package/templates/starter/docs/toolcraft/acceptance-testing.md +23 -35
- package/templates/starter/docs/toolcraft/agent-worklog.md +18 -3
- package/templates/starter/docs/toolcraft/assembly-workflow.md +13 -5
- package/templates/starter/docs/toolcraft/component-rules.md +8 -6
- package/templates/starter/docs/toolcraft/core/control-selection.md +9 -3
- package/templates/starter/docs/toolcraft/core/layout.md +7 -7
- package/templates/starter/docs/toolcraft/core/media-upload.md +4 -2
- package/templates/starter/docs/toolcraft/core/performance.md +14 -3
- package/templates/starter/docs/toolcraft/core/runtime-boundary.md +16 -3
- package/templates/starter/docs/toolcraft/core/setup-export.md +49 -19
- package/templates/starter/docs/toolcraft/core/timeline-animation.md +4 -4
- package/templates/starter/docs/toolcraft/custom-controls.md +6 -4
- package/templates/starter/docs/toolcraft/decision-contract.md +3 -1
- package/templates/starter/docs/toolcraft/performance.md +20 -6
- package/templates/starter/docs/toolcraft/renderer-technique.md +5 -1
- package/templates/starter/docs/toolcraft/schema-reference.md +23 -25
- package/templates/starter/docs/toolcraft/workflow.md +7 -2
- package/templates/starter/e2e/app-browser-control-applicability-requirements.spec.ts +163 -0
- package/templates/starter/e2e/app-browser-control-coverage.spec.ts +33 -0
- package/templates/starter/e2e/app-browser-infinity-canvas-evidence.spec.ts +50 -3
- package/templates/starter/e2e/app-browser-orientation-evidence.spec.ts +174 -21
- package/templates/starter/e2e/app-browser-render-scale-evidence.spec.ts +60 -6
- package/templates/starter/e2e/app-browser-render-scale-requirements.spec.ts +77 -1
- package/templates/starter/e2e/app-browser-runtime-provenance.spec.ts +8 -0
- package/templates/starter/e2e/app-browser-runtime-reporter.spec.ts +35 -0
- package/templates/starter/e2e/app-browser-runtime-requirements.spec.ts +5 -34
- package/templates/starter/e2e/app-browser-semantic-evidence.spec.ts +61 -16
- package/templates/starter/e2e/app-browser-shell.spec.ts +13 -5
- package/templates/starter/e2e/app-performance-path-adapters.ts +8 -1
- package/templates/starter/e2e/app-performance.spec.ts +16 -9
- package/templates/starter/e2e/{browser-conditional-output-evidence-helpers.ts → browser-background-output-evidence.ts} +0 -68
- package/templates/starter/e2e/browser-control-applicability-evidence.ts +114 -0
- package/templates/starter/e2e/browser-infinity-canvas-evidence.ts +29 -341
- package/templates/starter/e2e/browser-infinity-canvas-unavailable-image-evidence.ts +370 -0
- package/templates/starter/e2e/browser-media-export-evidence.spec.ts +77 -0
- package/templates/starter/e2e/browser-media-export-evidence.ts +208 -0
- package/templates/starter/e2e/browser-orientation-gizmo-evidence-helpers.ts +4 -0
- package/templates/starter/e2e/browser-orientation-gizmo-live-preconditions.ts +86 -0
- package/templates/starter/e2e/browser-render-scale-evidence.ts +37 -29
- package/templates/starter/e2e/browser-runtime-applicability-requirements.ts +84 -0
- package/templates/starter/e2e/browser-runtime-evidence-reporter.ts +13 -3
- package/templates/starter/e2e/browser-runtime-evidence-requirements.ts +72 -35
- package/templates/starter/e2e/browser-semantic-evidence-test-helpers.ts +25 -0
- package/templates/starter/e2e/browser-standard-timeline-evidence.ts +106 -0
- package/templates/starter/e2e/decoded-pixel-observation.spec.ts +74 -0
- package/templates/starter/e2e/decoded-pixel-observation.ts +227 -0
- package/templates/starter/e2e/export-artifact-helpers.ts +206 -25
- package/templates/starter/e2e/image-artifact-inspection.spec.ts +41 -0
- package/templates/starter/e2e/image-artifact-inspection.ts +99 -0
- package/templates/starter/e2e/performance-canvas-helpers.ts +22 -21
- package/templates/starter/e2e/performance-canvas-quality-guard.spec.ts +312 -0
- package/templates/starter/e2e/performance-canvas-quality-guard.ts +196 -0
- package/templates/starter/e2e/performance-canvas-quality-observer.ts +351 -0
- package/templates/starter/e2e/performance-control-layout-helpers.ts +2 -2
- package/templates/starter/e2e/performance-path-adapter-contract.ts +4 -4
- package/templates/starter/e2e/performance-path-helpers.spec.ts +203 -70
- package/templates/starter/e2e/performance-path-helpers.ts +210 -91
- package/templates/starter/e2e/performance-pipeline-evidence-continuity.spec.ts +76 -0
- package/templates/starter/e2e/performance-pipeline-evidence-test-fixtures.ts +11 -2
- package/templates/starter/e2e/performance-pipeline-invariants.ts +47 -4
- package/templates/starter/e2e/performance-render-scale-runner.spec.ts +140 -38
- package/templates/starter/e2e/video-artifact-inspection.spec.ts +64 -0
- package/templates/starter/e2e/video-artifact-inspection.ts +281 -0
- package/templates/starter/gitignore +1 -0
- package/templates/starter/package.json +1 -0
- package/templates/starter/scripts/check-toolcraft-docs.mjs +17 -0
- package/templates/starter/scripts/toolcraft-contract-manifest.json +1 -0
- package/templates/starter/scripts/toolcraft-delivery-plan-authority.test.mjs +60 -0
- package/templates/starter/scripts/toolcraft-delivery-plan-errors.test.mjs +7 -2
- package/templates/starter/scripts/toolcraft-delivery-plan.mjs +7 -3
- package/templates/starter/scripts/toolcraft-product-boundary-ast.mjs +95 -103
- package/templates/starter/scripts/toolcraft-product-boundary-module-policy.mjs +101 -0
- package/templates/starter/scripts/toolcraft-product-boundary.mjs +12 -0
- package/templates/starter/scripts/toolcraft-product-boundary.test.mjs +0 -26
- package/templates/starter/scripts/toolcraft-product-control-bindings.mjs +182 -0
- package/templates/starter/scripts/toolcraft-product-control-boundary.mjs +146 -0
- package/templates/starter/scripts/toolcraft-product-control-boundary.test.mjs +186 -0
- package/templates/starter/scripts/toolcraft-product-evidence-boundary.test.mjs +85 -20
- package/templates/starter/scripts/toolcraft-product-evidence-import-policy.mjs +43 -0
- package/templates/starter/scripts/toolcraft-product-export-boundary.mjs +157 -0
- package/templates/starter/scripts/toolcraft-product-export-boundary.test.mjs +196 -0
- package/templates/starter/scripts/toolcraft-typescript-analysis.d.mts +73 -0
- package/templates/starter/scripts/toolcraft-typescript-source-evidence-structure.test.mjs +20 -0
- package/templates/starter/scripts/toolcraft-typescript-source-evidence.mjs +1 -0
- package/templates/starter/scripts/toolcraft-unavailable-resource-evidence-facade-test-helpers.mjs +318 -0
- package/templates/starter/scripts/toolcraft-unavailable-resource-evidence-facade.test.mjs +157 -206
- package/templates/starter/scripts/toolcraft-verification-inventory.mjs +1 -0
- package/templates/starter/scripts/toolcraft-verification-receipt.test.mjs +51 -0
- package/templates/starter/scripts/toolcraft-vite-env-activation.test.mjs +128 -59
- package/templates/starter/src/app/acceptance/artifact-export-intent.ts +130 -0
- package/templates/starter/src/app/acceptance/conditions.ts +1 -1
- package/templates/starter/src/app/acceptance/control-acceptance-context.ts +2 -2
- package/templates/starter/src/app/acceptance/control-acceptance-coverage.ts +6 -20
- package/templates/starter/src/app/acceptance/control-acceptance-kind-rules.ts +24 -5
- package/templates/starter/src/app/acceptance/control-acceptance-policy.ts +2 -13
- package/templates/starter/src/app/acceptance/control-applicability-cases.test.ts +321 -0
- package/templates/starter/src/app/acceptance/control-applicability-cases.ts +290 -0
- package/templates/starter/src/app/acceptance/control-applicability.ts +332 -0
- package/templates/starter/src/app/acceptance/control-layout-dependency-rules.ts +20 -9
- package/templates/starter/src/app/acceptance/control-layout-entity-rules.ts +4 -6
- package/templates/starter/src/app/acceptance/control-layout-model.ts +4 -4
- package/templates/starter/src/app/acceptance/control-layout-section-rules.ts +3 -10
- package/templates/starter/src/app/acceptance/control-parts.ts +8 -0
- package/templates/starter/src/app/acceptance/control-section-entity-cohesion.test.ts +215 -0
- package/templates/starter/src/app/acceptance/control-section-entity-cohesion.ts +132 -0
- package/templates/starter/src/app/acceptance/control-section-inventory.test.ts +87 -0
- package/templates/starter/src/app/acceptance/control-section-inventory.ts +74 -44
- package/templates/starter/src/app/acceptance/custom-controls.ts +11 -3
- package/templates/starter/src/app/acceptance/export-artifact-coverage.ts +113 -0
- package/templates/starter/src/app/acceptance/inline-layout.ts +64 -9
- package/templates/starter/src/app/acceptance/media-upload.ts +5 -1
- package/templates/starter/src/app/acceptance/orientation-gizmo.ts +18 -11
- package/templates/starter/src/app/acceptance/output-background-rules.ts +2 -2
- package/templates/starter/src/app/acceptance/output-export-layout-rules.ts +18 -10
- package/templates/starter/src/app/acceptance/output-export-model.ts +54 -11
- package/templates/starter/src/app/acceptance/output-export.ts +35 -12
- package/templates/starter/src/app/acceptance/output-video-export-rules.ts +99 -0
- package/templates/starter/src/app/acceptance/types.ts +30 -8
- package/templates/starter/src/app/acceptance/validate-coverage.ts +20 -2
- package/templates/starter/src/app/starter-acceptance.artifact-export-intent.test.ts +239 -0
- package/templates/starter/src/app/starter-acceptance.background-export.test.ts +33 -0
- package/templates/starter/src/app/starter-acceptance.canvas-sizing.test.ts +16 -1
- package/templates/starter/src/app/starter-acceptance.compound-part-coverage.test.ts +65 -0
- package/templates/starter/src/app/starter-acceptance.contract-fixtures.test.ts +41 -0
- package/templates/starter/src/app/starter-acceptance.contract-fixtures.ts +112 -16
- package/templates/starter/src/app/starter-acceptance.control-applicability.test.ts +224 -0
- package/templates/starter/src/app/starter-acceptance.control-order.test.ts +58 -3
- package/templates/starter/src/app/starter-acceptance.control-state.test.ts +0 -111
- package/templates/starter/src/app/starter-acceptance.custom-control-collections.test.ts +3 -1
- package/templates/starter/src/app/starter-acceptance.custom-control-valid.test.ts +1 -1
- package/templates/starter/src/app/starter-acceptance.export-artifact.test.ts +131 -0
- package/templates/starter/src/app/starter-acceptance.export-test-utils.ts +22 -0
- package/templates/starter/src/app/{starter-acceptance.image-video-export-settings.test.ts → starter-acceptance.image-export-settings.test.ts} +37 -9
- package/templates/starter/src/app/starter-acceptance.interaction-ownership.test.ts +12 -0
- package/templates/starter/src/app/starter-acceptance.keyframes.test.ts +14 -4
- package/templates/starter/src/app/starter-acceptance.media-upload.fixtures.ts +11 -1
- package/templates/starter/src/app/starter-acceptance.media-upload.test.ts +28 -0
- package/templates/starter/src/app/starter-acceptance.output-export-intent.test.ts +384 -0
- package/templates/starter/src/app/starter-acceptance.output-export-rules.test.ts +46 -1
- package/templates/starter/src/app/starter-acceptance.product-output-export.test.ts +112 -105
- package/templates/starter/src/app/starter-acceptance.product-readiness.test.ts +12 -0
- package/templates/starter/src/app/starter-acceptance.section-cohesion.test.ts +1 -1
- package/templates/starter/src/app/starter-acceptance.section-dependencies.test.ts +35 -24
- package/templates/starter/src/app/starter-acceptance.section-size.test.ts +72 -0
- package/templates/starter/src/app/starter-acceptance.ts +13 -2
- package/templates/starter/src/app/starter-acceptance.video-export-settings.test.ts +336 -0
- package/templates/starter/src/app/starter-acceptance.view-interaction.test.ts +8 -0
- package/templates/starter/src/app/starter-performance-test-utils.ts +103 -0
- package/templates/starter/src/app/starter-performance.gates.test.ts +231 -278
- package/templates/starter/src/app/starter-performance.lifecycle.test.ts +261 -0
- package/templates/starter/src/app/test-evidence/browser-runtime-contract.ts +4 -2
- package/templates/starter/src/routes/index.tsx +2 -0
- package/templates/ui/components/composites/tabs.tsx +2 -2
- package/templates/ui/components/controls/collection-actions/collection-item-groups.test.tsx +38 -0
- package/templates/ui/components/controls/collection-actions/collection-item-groups.tsx +36 -0
- package/templates/ui/components/controls/collection-actions/index.ts +2 -0
- package/templates/ui/components/controls/file-drop/file-drop-collection-control.tsx +137 -0
- package/templates/ui/components/controls/file-drop/file-drop-control.test.tsx +189 -0
- package/templates/ui/components/controls/file-drop/file-drop-control.tsx +81 -88
- package/templates/ui/components/controls/file-drop/file-drop-presentation.tsx +131 -9
- package/templates/ui/components/controls/file-drop/file-drop-types.ts +36 -22
- package/templates/ui/components/controls/file-drop/index.ts +1 -0
- package/templates/ui/components/controls/index.ts +3 -0
- package/templates/ui/components/controls/range-slider/range-slider-control.tsx +1 -1
- package/templates/ui/components/controls/range-slider/range-slider-value.test.ts +14 -0
- package/templates/ui/components/controls/range-slider/range-slider-value.ts +3 -2
- package/templates/runtime/export/export.ts +0 -166
- package/templates/starter/src/app/acceptance/condition-exclusivity.test.ts +0 -60
- package/templates/starter/src/app/acceptance/condition-exclusivity.ts +0 -221
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { defineToolcraft } from "../schema/define-toolcraft";
|
|
4
|
+
import { createToolcraftState } from "../state/create-template-state";
|
|
5
|
+
import {
|
|
6
|
+
resolveToolcraftImageExportSettings,
|
|
7
|
+
resolveToolcraftVideoExportSettings,
|
|
8
|
+
toolcraftImageExportFormatTarget,
|
|
9
|
+
toolcraftImageExportResolutionTarget,
|
|
10
|
+
toolcraftVideoExportFormatTarget,
|
|
11
|
+
toolcraftVideoExportResolutionTarget,
|
|
12
|
+
} from "./artifact-export-settings";
|
|
13
|
+
import { ToolcraftArtifactExportError } from "./export-error";
|
|
14
|
+
|
|
15
|
+
function createState() {
|
|
16
|
+
return createToolcraftState(
|
|
17
|
+
defineToolcraft({ canvas: { enabled: true }, panels: {} }),
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
describe("artifact export settings", () => {
|
|
22
|
+
it("uses canonical defaults when controls are absent", () => {
|
|
23
|
+
const state = createState();
|
|
24
|
+
|
|
25
|
+
expect(resolveToolcraftImageExportSettings(state)).toEqual({
|
|
26
|
+
format: "png",
|
|
27
|
+
resolution: "4k",
|
|
28
|
+
});
|
|
29
|
+
expect(resolveToolcraftVideoExportSettings(state)).toEqual({
|
|
30
|
+
format: "mp4",
|
|
31
|
+
resolution: "current",
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("prefers current values over normalized defaults", () => {
|
|
36
|
+
const state = createState();
|
|
37
|
+
Object.assign(state.defaults, {
|
|
38
|
+
[toolcraftImageExportFormatTarget]: "png",
|
|
39
|
+
[toolcraftImageExportResolutionTarget]: "4k",
|
|
40
|
+
[toolcraftVideoExportFormatTarget]: "mp4",
|
|
41
|
+
[toolcraftVideoExportResolutionTarget]: "current",
|
|
42
|
+
});
|
|
43
|
+
Object.assign(state.values, {
|
|
44
|
+
[toolcraftImageExportFormatTarget]: "jpg",
|
|
45
|
+
[toolcraftImageExportResolutionTarget]: "8k",
|
|
46
|
+
[toolcraftVideoExportFormatTarget]: "webm",
|
|
47
|
+
[toolcraftVideoExportResolutionTarget]: "4k",
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
expect(resolveToolcraftImageExportSettings(state)).toEqual({
|
|
51
|
+
format: "jpg",
|
|
52
|
+
resolution: "8k",
|
|
53
|
+
});
|
|
54
|
+
expect(resolveToolcraftVideoExportSettings(state)).toEqual({
|
|
55
|
+
format: "webm",
|
|
56
|
+
resolution: "4k",
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("rejects unsupported present values with the exact target", () => {
|
|
61
|
+
const state = createState();
|
|
62
|
+
state.values[toolcraftVideoExportFormatTarget] = "mov";
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
resolveToolcraftVideoExportSettings(state);
|
|
66
|
+
throw new Error("Expected invalid export setting.");
|
|
67
|
+
} catch (error) {
|
|
68
|
+
expect(error).toBeInstanceOf(ToolcraftArtifactExportError);
|
|
69
|
+
expect((error as ToolcraftArtifactExportError).feedback).toMatchObject({
|
|
70
|
+
code: "invalid-export-setting",
|
|
71
|
+
target: toolcraftVideoExportFormatTarget,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { ToolcraftState } from "../state/types";
|
|
2
|
+
import { ToolcraftArtifactExportError } from "./export-error";
|
|
3
|
+
|
|
4
|
+
export const toolcraftImageExportFormatTarget = "export.image.format";
|
|
5
|
+
export const toolcraftImageExportResolutionTarget = "export.image.resolution";
|
|
6
|
+
export const toolcraftVideoExportFormatTarget = "export.video.format";
|
|
7
|
+
export const toolcraftVideoExportResolutionTarget = "export.video.resolution";
|
|
8
|
+
|
|
9
|
+
export type ToolcraftImageExportFormat = "jpg" | "png";
|
|
10
|
+
export type ToolcraftImageExportPresetResolution = "2k" | "4k" | "8k";
|
|
11
|
+
export type ToolcraftVideoExportFormat = "mp4" | "webm";
|
|
12
|
+
export type ToolcraftVideoExportPresetResolution = "4k" | "current";
|
|
13
|
+
|
|
14
|
+
export type ToolcraftResolvedImageExportSettings = Readonly<{
|
|
15
|
+
format: ToolcraftImageExportFormat;
|
|
16
|
+
resolution: ToolcraftImageExportPresetResolution;
|
|
17
|
+
}>;
|
|
18
|
+
|
|
19
|
+
export type ToolcraftResolvedVideoExportSettings = Readonly<{
|
|
20
|
+
format: ToolcraftVideoExportFormat;
|
|
21
|
+
resolution: ToolcraftVideoExportPresetResolution;
|
|
22
|
+
}>;
|
|
23
|
+
|
|
24
|
+
function getSettingValue(
|
|
25
|
+
state: ToolcraftState,
|
|
26
|
+
target: string,
|
|
27
|
+
fallback: string,
|
|
28
|
+
): unknown {
|
|
29
|
+
return state.values[target] ?? state.defaults[target] ?? fallback;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function invalidSetting(target: string): never {
|
|
33
|
+
throw new ToolcraftArtifactExportError({
|
|
34
|
+
code: "invalid-export-setting",
|
|
35
|
+
message: `Toolcraft export setting ${target} is invalid.`,
|
|
36
|
+
target,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function resolveImageFormat(state: ToolcraftState): ToolcraftImageExportFormat {
|
|
41
|
+
const value = getSettingValue(state, toolcraftImageExportFormatTarget, "png");
|
|
42
|
+
return value === "jpg" || value === "png"
|
|
43
|
+
? value
|
|
44
|
+
: invalidSetting(toolcraftImageExportFormatTarget);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function resolveImageResolution(
|
|
48
|
+
state: ToolcraftState,
|
|
49
|
+
): ToolcraftImageExportPresetResolution {
|
|
50
|
+
const value = getSettingValue(
|
|
51
|
+
state,
|
|
52
|
+
toolcraftImageExportResolutionTarget,
|
|
53
|
+
"4k",
|
|
54
|
+
);
|
|
55
|
+
return value === "2k" || value === "4k" || value === "8k"
|
|
56
|
+
? value
|
|
57
|
+
: invalidSetting(toolcraftImageExportResolutionTarget);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function resolveVideoFormat(state: ToolcraftState): ToolcraftVideoExportFormat {
|
|
61
|
+
const value = getSettingValue(state, toolcraftVideoExportFormatTarget, "mp4");
|
|
62
|
+
return value === "mp4" || value === "webm"
|
|
63
|
+
? value
|
|
64
|
+
: invalidSetting(toolcraftVideoExportFormatTarget);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function resolveVideoResolution(
|
|
68
|
+
state: ToolcraftState,
|
|
69
|
+
): ToolcraftVideoExportPresetResolution {
|
|
70
|
+
const value = getSettingValue(
|
|
71
|
+
state,
|
|
72
|
+
toolcraftVideoExportResolutionTarget,
|
|
73
|
+
"current",
|
|
74
|
+
);
|
|
75
|
+
return value === "4k" || value === "current"
|
|
76
|
+
? value
|
|
77
|
+
: invalidSetting(toolcraftVideoExportResolutionTarget);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function resolveToolcraftImageExportSettings(
|
|
81
|
+
state: ToolcraftState,
|
|
82
|
+
): ToolcraftResolvedImageExportSettings {
|
|
83
|
+
return Object.freeze({
|
|
84
|
+
format: resolveImageFormat(state),
|
|
85
|
+
resolution: resolveImageResolution(state),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function resolveToolcraftVideoExportSettings(
|
|
90
|
+
state: ToolcraftState,
|
|
91
|
+
): ToolcraftResolvedVideoExportSettings {
|
|
92
|
+
return Object.freeze({
|
|
93
|
+
format: resolveVideoFormat(state),
|
|
94
|
+
resolution: resolveVideoResolution(state),
|
|
95
|
+
});
|
|
96
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { defineToolcraft } from "../schema/define-toolcraft";
|
|
4
|
+
import { createToolcraftState } from "../state/create-template-state";
|
|
5
|
+
import { renderToolcraftArtifactFrame } from "./artifact-frame-renderer";
|
|
6
|
+
|
|
7
|
+
function deferred() {
|
|
8
|
+
let resolve!: () => void;
|
|
9
|
+
const promise = new Promise<void>((done) => {
|
|
10
|
+
resolve = done;
|
|
11
|
+
});
|
|
12
|
+
return { promise, resolve };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function createContext(events: string[]) {
|
|
16
|
+
return {
|
|
17
|
+
clearRect: vi.fn(() => events.push("clear")),
|
|
18
|
+
fillRect: vi.fn(() => events.push("background")),
|
|
19
|
+
fillStyle: "",
|
|
20
|
+
restore: vi.fn(() => events.push("restore")),
|
|
21
|
+
save: vi.fn(() => events.push("save")),
|
|
22
|
+
scale: vi.fn(() => events.push("scale")),
|
|
23
|
+
setTransform: vi.fn(() => events.push("reset-transform")),
|
|
24
|
+
translate: vi.fn(() => events.push("translate")),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
describe("renderToolcraftArtifactFrame", () => {
|
|
29
|
+
it("keeps the scene transform active until async product rendering settles", async () => {
|
|
30
|
+
const events: string[] = [];
|
|
31
|
+
const pending = deferred();
|
|
32
|
+
const context = createContext(events);
|
|
33
|
+
const canvas = {
|
|
34
|
+
getContext: vi.fn(() => context),
|
|
35
|
+
height: 200,
|
|
36
|
+
width: 400,
|
|
37
|
+
} as unknown as HTMLCanvasElement;
|
|
38
|
+
const state = createToolcraftState(
|
|
39
|
+
defineToolcraft({ canvas: { enabled: true }, panels: {} }),
|
|
40
|
+
);
|
|
41
|
+
const rendering = renderToolcraftArtifactFrame({
|
|
42
|
+
backgroundColor: "#123456",
|
|
43
|
+
canvas,
|
|
44
|
+
frame: { height: 100, width: 200, x: -10, y: -20 },
|
|
45
|
+
includeBackground: true,
|
|
46
|
+
pixelRatio: 2,
|
|
47
|
+
renderProductFrame: async () => {
|
|
48
|
+
events.push("product-start");
|
|
49
|
+
await pending.promise;
|
|
50
|
+
events.push("product-end");
|
|
51
|
+
},
|
|
52
|
+
renderRuntimeScene: async () => {
|
|
53
|
+
events.push("runtime-scene");
|
|
54
|
+
},
|
|
55
|
+
rendererPipeline: null,
|
|
56
|
+
state,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
await Promise.resolve();
|
|
60
|
+
expect(events).toEqual([
|
|
61
|
+
"reset-transform",
|
|
62
|
+
"clear",
|
|
63
|
+
"background",
|
|
64
|
+
"runtime-scene",
|
|
65
|
+
"save",
|
|
66
|
+
"scale",
|
|
67
|
+
"translate",
|
|
68
|
+
"product-start",
|
|
69
|
+
]);
|
|
70
|
+
pending.resolve();
|
|
71
|
+
await rendering;
|
|
72
|
+
expect(events.at(-2)).toBe("product-end");
|
|
73
|
+
expect(events.at(-1)).toBe("restore");
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("restores the context and types an unknown renderer failure", async () => {
|
|
77
|
+
const events: string[] = [];
|
|
78
|
+
const context = createContext(events);
|
|
79
|
+
const canvas = {
|
|
80
|
+
getContext: vi.fn(() => context),
|
|
81
|
+
height: 100,
|
|
82
|
+
width: 100,
|
|
83
|
+
} as unknown as HTMLCanvasElement;
|
|
84
|
+
const state = createToolcraftState(
|
|
85
|
+
defineToolcraft({ canvas: { enabled: true }, panels: {} }),
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
await expect(
|
|
89
|
+
renderToolcraftArtifactFrame({
|
|
90
|
+
backgroundColor: "#000000",
|
|
91
|
+
canvas,
|
|
92
|
+
frame: { height: 100, width: 100, x: 0, y: 0 },
|
|
93
|
+
includeBackground: false,
|
|
94
|
+
pixelRatio: 1,
|
|
95
|
+
renderProductFrame: () => {
|
|
96
|
+
throw new Error("broken product");
|
|
97
|
+
},
|
|
98
|
+
renderRuntimeScene: async () => undefined,
|
|
99
|
+
rendererPipeline: null,
|
|
100
|
+
state,
|
|
101
|
+
}),
|
|
102
|
+
).rejects.toMatchObject({
|
|
103
|
+
feedback: { code: "product-frame-render-failed" },
|
|
104
|
+
});
|
|
105
|
+
expect(context.restore).toHaveBeenCalledOnce();
|
|
106
|
+
});
|
|
107
|
+
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { ToolcraftRendererPipelineClient } from "../rendering";
|
|
2
|
+
import type { ToolcraftState } from "../state/types";
|
|
3
|
+
import type { ToolcraftExportFrame } from "./export-frame";
|
|
4
|
+
import {
|
|
5
|
+
normalizeToolcraftExportError,
|
|
6
|
+
ToolcraftArtifactExportError,
|
|
7
|
+
} from "./export-error";
|
|
8
|
+
import type { ToolcraftProductExportFrameRenderer } from "./product-export-renderer";
|
|
9
|
+
|
|
10
|
+
export type ToolcraftArtifactFrameRenderRequest = Readonly<{
|
|
11
|
+
backgroundColor: string;
|
|
12
|
+
canvas: HTMLCanvasElement;
|
|
13
|
+
frame: ToolcraftExportFrame;
|
|
14
|
+
includeBackground: boolean;
|
|
15
|
+
pixelRatio: number;
|
|
16
|
+
renderProductFrame: ToolcraftProductExportFrameRenderer | null;
|
|
17
|
+
renderRuntimeScene: (
|
|
18
|
+
canvas: HTMLCanvasElement,
|
|
19
|
+
frame: ToolcraftExportFrame,
|
|
20
|
+
state: ToolcraftState,
|
|
21
|
+
) => Promise<unknown>;
|
|
22
|
+
rendererPipeline: ToolcraftRendererPipelineClient | null;
|
|
23
|
+
state: ToolcraftState;
|
|
24
|
+
}>;
|
|
25
|
+
|
|
26
|
+
function getTimelineProgress(state: ToolcraftState): number {
|
|
27
|
+
if (state.timeline.durationSeconds <= 0) {
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return Math.max(
|
|
32
|
+
0,
|
|
33
|
+
Math.min(
|
|
34
|
+
1,
|
|
35
|
+
state.timeline.currentTimeSeconds / state.timeline.durationSeconds,
|
|
36
|
+
),
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function renderToolcraftArtifactFrame(
|
|
41
|
+
request: ToolcraftArtifactFrameRenderRequest,
|
|
42
|
+
): Promise<void> {
|
|
43
|
+
const context = request.canvas.getContext("2d");
|
|
44
|
+
if (!context) {
|
|
45
|
+
throw new ToolcraftArtifactExportError({
|
|
46
|
+
code: "canvas-context-unavailable",
|
|
47
|
+
message: "Toolcraft export requires a 2D canvas context.",
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
context.setTransform(1, 0, 0, 1, 0, 0);
|
|
52
|
+
context.clearRect(0, 0, request.canvas.width, request.canvas.height);
|
|
53
|
+
if (request.includeBackground) {
|
|
54
|
+
context.fillStyle = request.backgroundColor;
|
|
55
|
+
context.fillRect(0, 0, request.canvas.width, request.canvas.height);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
await request.renderRuntimeScene(
|
|
60
|
+
request.canvas,
|
|
61
|
+
request.frame,
|
|
62
|
+
request.state,
|
|
63
|
+
);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
throw normalizeToolcraftExportError(error, {
|
|
66
|
+
code: "runtime-scene-render-failed",
|
|
67
|
+
message: "Toolcraft could not render runtime scene layers for export.",
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (!request.renderProductFrame) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
context.save();
|
|
76
|
+
context.scale(request.pixelRatio, request.pixelRatio);
|
|
77
|
+
context.translate(-request.frame.x, -request.frame.y);
|
|
78
|
+
try {
|
|
79
|
+
await request.renderProductFrame({
|
|
80
|
+
context,
|
|
81
|
+
frame: request.frame,
|
|
82
|
+
pixelRatio: request.pixelRatio,
|
|
83
|
+
rendererPipeline: request.rendererPipeline,
|
|
84
|
+
state: request.state,
|
|
85
|
+
timeSeconds: request.state.timeline.currentTimeSeconds,
|
|
86
|
+
timelineProgress: getTimelineProgress(request.state),
|
|
87
|
+
});
|
|
88
|
+
} catch (error) {
|
|
89
|
+
throw normalizeToolcraftExportError(error, {
|
|
90
|
+
code: "product-frame-render-failed",
|
|
91
|
+
message: "Toolcraft could not render product pixels for export.",
|
|
92
|
+
});
|
|
93
|
+
} finally {
|
|
94
|
+
context.restore();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { defineToolcraft } from "../schema/define-toolcraft";
|
|
4
|
+
import { createToolcraftState } from "../state/create-template-state";
|
|
5
|
+
import { createToolcraftArtifactFrameState } from "./artifact-frame-state";
|
|
6
|
+
|
|
7
|
+
describe("createToolcraftArtifactFrameState", () => {
|
|
8
|
+
it("evaluates keyframed values without mutating the base snapshot", () => {
|
|
9
|
+
const state = createToolcraftState(
|
|
10
|
+
defineToolcraft({ canvas: { enabled: true }, panels: {} }),
|
|
11
|
+
{
|
|
12
|
+
timeline: {
|
|
13
|
+
currentTimeSeconds: 0,
|
|
14
|
+
isPlaying: true,
|
|
15
|
+
keyframeGroups: [
|
|
16
|
+
{
|
|
17
|
+
controlId: "shape.opacity",
|
|
18
|
+
label: "Opacity",
|
|
19
|
+
keyframes: [
|
|
20
|
+
{
|
|
21
|
+
controlId: "shape.opacity",
|
|
22
|
+
controlLabel: "Opacity",
|
|
23
|
+
id: "a",
|
|
24
|
+
timeSeconds: 0,
|
|
25
|
+
value: 0,
|
|
26
|
+
valueLabel: "0",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
controlId: "shape.opacity",
|
|
30
|
+
controlLabel: "Opacity",
|
|
31
|
+
id: "b",
|
|
32
|
+
timeSeconds: 1,
|
|
33
|
+
value: 1,
|
|
34
|
+
valueLabel: "1",
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
values: { "shape.opacity": 0 },
|
|
41
|
+
},
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
const frameState = createToolcraftArtifactFrameState(state, 0.5);
|
|
45
|
+
|
|
46
|
+
expect(frameState).not.toBe(state);
|
|
47
|
+
expect(frameState.timeline.currentTimeSeconds).toBe(0.5);
|
|
48
|
+
expect(frameState.timeline.isPlaying).toBe(false);
|
|
49
|
+
expect(frameState.values["shape.opacity"]).toBeCloseTo(0.5, 5);
|
|
50
|
+
expect(state.timeline.currentTimeSeconds).toBe(0);
|
|
51
|
+
expect(state.timeline.isPlaying).toBe(true);
|
|
52
|
+
expect(state.values["shape.opacity"]).toBe(0);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { evaluateToolcraftTimelineValues } from "../state/keyframe-evaluation";
|
|
2
|
+
import type { ToolcraftState } from "../state/types";
|
|
3
|
+
import type { ToolcraftVideoFrameScheduleEntry } from "./video-frame-schedule";
|
|
4
|
+
|
|
5
|
+
export type ToolcraftArtifactFrameState = Readonly<ToolcraftState>;
|
|
6
|
+
|
|
7
|
+
export type ToolcraftVideoArtifactFramePlanEntry = Readonly<{
|
|
8
|
+
scheduleEntry: ToolcraftVideoFrameScheduleEntry;
|
|
9
|
+
state: ToolcraftArtifactFrameState;
|
|
10
|
+
}>;
|
|
11
|
+
|
|
12
|
+
export function createToolcraftArtifactFrameState(
|
|
13
|
+
baseState: ToolcraftState,
|
|
14
|
+
timeSeconds: number,
|
|
15
|
+
): ToolcraftArtifactFrameState {
|
|
16
|
+
return Object.freeze({
|
|
17
|
+
...baseState,
|
|
18
|
+
timeline: Object.freeze({
|
|
19
|
+
...baseState.timeline,
|
|
20
|
+
currentTimeSeconds: timeSeconds,
|
|
21
|
+
isPlaying: false,
|
|
22
|
+
}),
|
|
23
|
+
values: Object.freeze(
|
|
24
|
+
evaluateToolcraftTimelineValues(baseState, timeSeconds),
|
|
25
|
+
),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function createToolcraftVideoArtifactFramePlan(
|
|
30
|
+
baseState: ToolcraftState,
|
|
31
|
+
schedule: readonly ToolcraftVideoFrameScheduleEntry[],
|
|
32
|
+
): readonly ToolcraftVideoArtifactFramePlanEntry[] {
|
|
33
|
+
return Object.freeze(
|
|
34
|
+
schedule.map((scheduleEntry) =>
|
|
35
|
+
Object.freeze({
|
|
36
|
+
scheduleEntry,
|
|
37
|
+
state: createToolcraftArtifactFrameState(
|
|
38
|
+
baseState,
|
|
39
|
+
scheduleEntry.timeSeconds,
|
|
40
|
+
),
|
|
41
|
+
}),
|
|
42
|
+
),
|
|
43
|
+
);
|
|
44
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { defineToolcraft } from "../schema/define-toolcraft";
|
|
4
|
+
import { createToolcraftState } from "../state/create-template-state";
|
|
5
|
+
import { createToolcraftRuntimeSceneVisibility } from "../scene";
|
|
6
|
+
import { ToolcraftSceneExportError } from "./export-frame";
|
|
7
|
+
import {
|
|
8
|
+
resolveToolcraftImageArtifactFrame,
|
|
9
|
+
resolveToolcraftVideoArtifactFrame,
|
|
10
|
+
} from "./artifact-scene-frame";
|
|
11
|
+
import { createToolcraftVideoArtifactFramePlan } from "./artifact-frame-state";
|
|
12
|
+
import { createToolcraftVideoFrameSchedule } from "./video-frame-schedule";
|
|
13
|
+
|
|
14
|
+
const visibility = createToolcraftRuntimeSceneVisibility({
|
|
15
|
+
renderDefaultImages: true,
|
|
16
|
+
suppressedModelTargets: [],
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
function createState(mode: "finite" | "infinite") {
|
|
20
|
+
return createToolcraftState(
|
|
21
|
+
defineToolcraft({ canvas: { enabled: true }, panels: {} }),
|
|
22
|
+
{ canvas: { mode } },
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
describe("artifact scene frame", () => {
|
|
27
|
+
it("returns a finite frame without invoking product bounds", () => {
|
|
28
|
+
const state = createState("finite");
|
|
29
|
+
const boundsProvider = vi.fn(() => []);
|
|
30
|
+
|
|
31
|
+
expect(
|
|
32
|
+
resolveToolcraftImageArtifactFrame({
|
|
33
|
+
boundsProvider,
|
|
34
|
+
productSceneRequired: true,
|
|
35
|
+
state,
|
|
36
|
+
visibility,
|
|
37
|
+
}),
|
|
38
|
+
).toEqual({
|
|
39
|
+
height: state.canvas.size.height,
|
|
40
|
+
width: state.canvas.size.width,
|
|
41
|
+
x: 0,
|
|
42
|
+
y: 0,
|
|
43
|
+
});
|
|
44
|
+
expect(boundsProvider).not.toHaveBeenCalled();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("unions moving infinite-scene bounds across the exact frame plan", () => {
|
|
48
|
+
const state = createState("infinite");
|
|
49
|
+
const plan = createToolcraftVideoArtifactFramePlan(
|
|
50
|
+
state,
|
|
51
|
+
createToolcraftVideoFrameSchedule(0.1),
|
|
52
|
+
);
|
|
53
|
+
const boundsProvider = vi.fn(({ state: frameState }) => [
|
|
54
|
+
{
|
|
55
|
+
height: 10,
|
|
56
|
+
width: 20,
|
|
57
|
+
x: frameState.timeline.currentTimeSeconds * 300,
|
|
58
|
+
y: -5,
|
|
59
|
+
},
|
|
60
|
+
]);
|
|
61
|
+
|
|
62
|
+
expect(
|
|
63
|
+
resolveToolcraftVideoArtifactFrame({
|
|
64
|
+
boundsProvider,
|
|
65
|
+
framePlan: plan,
|
|
66
|
+
productSceneRequired: true,
|
|
67
|
+
visibility,
|
|
68
|
+
}),
|
|
69
|
+
).toEqual({ height: 10, width: 40, x: 0, y: -5 });
|
|
70
|
+
expect(boundsProvider).toHaveBeenCalledTimes(3);
|
|
71
|
+
expect(boundsProvider.mock.calls[1]?.[0].state).toBe(plan[1]?.state);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("fails visibly when an infinite product scene has no bounds provider", () => {
|
|
75
|
+
expect(() =>
|
|
76
|
+
resolveToolcraftImageArtifactFrame({
|
|
77
|
+
boundsProvider: undefined,
|
|
78
|
+
productSceneRequired: true,
|
|
79
|
+
state: createState("infinite"),
|
|
80
|
+
visibility,
|
|
81
|
+
}),
|
|
82
|
+
).toThrow(ToolcraftSceneExportError);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveToolcraftSceneBounds,
|
|
3
|
+
unionToolcraftSceneRects,
|
|
4
|
+
type ToolcraftProductSceneBoundsProvider,
|
|
5
|
+
type ToolcraftRuntimeSceneVisibility,
|
|
6
|
+
type ToolcraftSceneRect,
|
|
7
|
+
} from "../scene";
|
|
8
|
+
import { getToolcraftCanvasFrame } from "../state/canvas-frame";
|
|
9
|
+
import type { ToolcraftState } from "../state/types";
|
|
10
|
+
import type { ToolcraftVideoArtifactFramePlanEntry } from "./artifact-frame-state";
|
|
11
|
+
import {
|
|
12
|
+
resolveToolcraftExportFrame,
|
|
13
|
+
ToolcraftSceneExportError,
|
|
14
|
+
type ToolcraftExportFrame,
|
|
15
|
+
type ToolcraftExportFrameResult,
|
|
16
|
+
} from "./export-frame";
|
|
17
|
+
|
|
18
|
+
type ToolcraftArtifactSceneFrameBaseRequest = Readonly<{
|
|
19
|
+
boundsProvider: ToolcraftProductSceneBoundsProvider | undefined;
|
|
20
|
+
productSceneRequired: boolean;
|
|
21
|
+
visibility: ToolcraftRuntimeSceneVisibility;
|
|
22
|
+
}>;
|
|
23
|
+
|
|
24
|
+
export type ToolcraftImageArtifactSceneFrameRequest =
|
|
25
|
+
ToolcraftArtifactSceneFrameBaseRequest &
|
|
26
|
+
Readonly<{ state: ToolcraftState }>;
|
|
27
|
+
|
|
28
|
+
export type ToolcraftVideoArtifactSceneFrameRequest =
|
|
29
|
+
ToolcraftArtifactSceneFrameBaseRequest &
|
|
30
|
+
Readonly<{ framePlan: readonly ToolcraftVideoArtifactFramePlanEntry[] }>;
|
|
31
|
+
|
|
32
|
+
function requireFrame(result: ToolcraftExportFrameResult): ToolcraftExportFrame {
|
|
33
|
+
if (!result.ok) {
|
|
34
|
+
throw new ToolcraftSceneExportError(result);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return result.frame;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function requireProductRects(
|
|
41
|
+
state: ToolcraftState,
|
|
42
|
+
request: ToolcraftArtifactSceneFrameBaseRequest,
|
|
43
|
+
): readonly ToolcraftSceneRect[] {
|
|
44
|
+
if (!request.boundsProvider) {
|
|
45
|
+
if (request.productSceneRequired) {
|
|
46
|
+
throw new ToolcraftSceneExportError({
|
|
47
|
+
code: "scene-bounds-unavailable",
|
|
48
|
+
message: "This infinite product scene does not provide export bounds.",
|
|
49
|
+
ok: false,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
try {
|
|
57
|
+
return request.boundsProvider({ state });
|
|
58
|
+
} catch {
|
|
59
|
+
throw new ToolcraftSceneExportError({
|
|
60
|
+
code: "scene-bounds-unavailable",
|
|
61
|
+
message: "Product scene bounds could not be resolved.",
|
|
62
|
+
ok: false,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function isFiniteCanvas(state: ToolcraftState): boolean {
|
|
68
|
+
return getToolcraftCanvasFrame(state.canvas).kind === "finite";
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function resolveToolcraftImageArtifactFrame(
|
|
72
|
+
request: ToolcraftImageArtifactSceneFrameRequest,
|
|
73
|
+
): ToolcraftExportFrame {
|
|
74
|
+
if (isFiniteCanvas(request.state)) {
|
|
75
|
+
return requireFrame(resolveToolcraftExportFrame(request.state, null));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const bounds = resolveToolcraftSceneBounds(
|
|
79
|
+
request.state,
|
|
80
|
+
requireProductRects(request.state, request),
|
|
81
|
+
request.visibility,
|
|
82
|
+
);
|
|
83
|
+
return requireFrame(resolveToolcraftExportFrame(request.state, bounds));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function resolveToolcraftVideoArtifactFrame(
|
|
87
|
+
request: ToolcraftVideoArtifactSceneFrameRequest,
|
|
88
|
+
): ToolcraftExportFrame {
|
|
89
|
+
const firstState = request.framePlan[0]?.state;
|
|
90
|
+
if (!firstState) {
|
|
91
|
+
throw new ToolcraftSceneExportError({
|
|
92
|
+
code: "empty-scene",
|
|
93
|
+
message: "Video export has no scheduled frames.",
|
|
94
|
+
ok: false,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
if (isFiniteCanvas(firstState)) {
|
|
98
|
+
return requireFrame(resolveToolcraftExportFrame(firstState, null));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const frameBounds: ToolcraftSceneRect[] = [];
|
|
102
|
+
for (const entry of request.framePlan) {
|
|
103
|
+
const result = resolveToolcraftSceneBounds(
|
|
104
|
+
entry.state,
|
|
105
|
+
requireProductRects(entry.state, request),
|
|
106
|
+
request.visibility,
|
|
107
|
+
);
|
|
108
|
+
if (result.ok) {
|
|
109
|
+
frameBounds.push(result.bounds);
|
|
110
|
+
} else if (result.code !== "empty-scene") {
|
|
111
|
+
throw new ToolcraftSceneExportError(result);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return requireFrame(
|
|
116
|
+
resolveToolcraftExportFrame(firstState, unionToolcraftSceneRects(frameBounds)),
|
|
117
|
+
);
|
|
118
|
+
}
|