@playcraft/cli 0.1.54 → 0.1.55-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -15
- package/SKILLS_REGISTRY.md +149 -0
- package/dist/agent/local-backend.js +1 -1
- package/dist/assets/client.js +157 -0
- package/dist/assets/messages.js +48 -0
- package/dist/auth/account-activation.js +157 -0
- package/dist/auth/messages.js +30 -0
- package/dist/cli-root-help.js +4 -0
- package/dist/commands/assets.js +123 -0
- package/dist/commands/build-all.js +5 -19
- package/dist/commands/build-temp.js +26 -0
- package/dist/commands/build.js +15 -28
- package/dist/commands/create.js +26 -33
- package/dist/commands/image-layer-messages.js +37 -0
- package/dist/commands/image-layer-tools.js +185 -0
- package/dist/commands/image.js +2 -73
- package/dist/commands/library-messages.js +46 -0
- package/dist/commands/library.js +130 -0
- package/dist/commands/login.js +84 -42
- package/dist/commands/platform-skills.generated.js +19 -0
- package/dist/commands/playable.js +53 -0
- package/dist/commands/preview-runtime.js +21 -0
- package/dist/commands/skills.js +4 -0
- package/dist/commands/tools-3d.js +11 -0
- package/dist/commands/tools-batch.js +113 -0
- package/dist/commands/tools-generation.js +6 -0
- package/dist/commands/tools.js +2 -0
- package/dist/commands/video.js +122 -0
- package/dist/commands/workspace-runtime.js +54 -0
- package/dist/commands/workspace.js +40 -0
- package/dist/config.js +59 -4
- package/dist/index.js +47 -3
- package/dist/preview-runtime/distribution.js +77 -0
- package/dist/project-skills/builtin-import.js +225 -0
- package/dist/project-skills/commands.js +77 -0
- package/dist/project-skills/lifecycle.js +28 -0
- package/dist/project-skills/local-run.js +112 -0
- package/dist/project-skills/local-store.js +221 -0
- package/dist/project-skills/messages.js +80 -0
- package/dist/project-skills/reconcile.js +62 -0
- package/dist/project-skills/remote-cache.js +51 -0
- package/dist/project-skills/validation.js +19 -0
- package/dist/recording/messages.js +40 -0
- package/dist/recording/project-digest.js +85 -0
- package/dist/recording/recorder.js +293 -0
- package/dist/recording/scenario.js +50 -0
- package/dist/remix/clone.js +2 -0
- package/dist/remix/init-template.js +2 -0
- package/dist/remix/pull.js +2 -0
- package/dist/remix/push.js +21 -1
- package/dist/skill-registry/client.js +345 -0
- package/dist/skill-registry/commands.js +180 -0
- package/dist/skill-registry/evaluation-client.js +156 -0
- package/dist/skill-registry/evaluation-commands.js +174 -0
- package/dist/skill-registry/messages.js +177 -0
- package/dist/skill-registry/package.js +275 -0
- package/dist/skill-registry/platform-package.js +100 -0
- package/dist/utils/agent-api-client.js +245 -30
- package/dist/utils/environment-endpoints.js +17 -0
- package/dist/utils/error-diagnostics.js +20 -0
- package/dist/utils/playcraft-http-client.js +6 -4
- package/dist/utils/tool-operation-journal.js +124 -0
- package/dist/utils/video-evidence-git.js +81 -0
- package/dist/video-replication/client.js +234 -0
- package/dist/video-replication/comparison-evidence.js +149 -0
- package/dist/video-replication/comparison-files.js +57 -0
- package/dist/video-replication/comparison-log.js +72 -0
- package/dist/video-replication/comparison-messages.js +104 -0
- package/dist/video-replication/comparison-output.js +63 -0
- package/dist/video-replication/comparison-preflight.js +66 -0
- package/dist/video-replication/comparison.js +230 -0
- package/dist/video-replication/diagnostics.js +41 -0
- package/dist/video-replication/evidence.js +165 -0
- package/dist/video-replication/media.js +112 -0
- package/dist/video-replication/messages.js +97 -0
- package/dist/workspace/messages.js +67 -0
- package/dist/workspace/transfer-client.js +237 -0
- package/dist/workspace/transfer-errors.js +48 -0
- package/dist/workspace-runtime/batch/content-changes.js +30 -0
- package/dist/workspace-runtime/batch/control.js +86 -0
- package/dist/workspace-runtime/batch/deliver.js +173 -0
- package/dist/workspace-runtime/batch/freeze.js +101 -0
- package/dist/workspace-runtime/batch/generate.js +249 -0
- package/dist/workspace-runtime/batch/git.js +40 -0
- package/dist/workspace-runtime/batch/occupancy.js +8 -0
- package/dist/workspace-runtime/batch/policy.js +70 -0
- package/dist/workspace-runtime/batch/prepare.js +317 -0
- package/dist/workspace-runtime/batch/processes.js +72 -0
- package/dist/workspace-runtime/batch/records.js +113 -0
- package/dist/workspace-runtime/batch/routes.js +61 -0
- package/dist/workspace-runtime/batch/source-candidate.js +86 -0
- package/dist/workspace-runtime/batch/source-capture.js +146 -0
- package/dist/workspace-runtime/batch/source-failure.js +43 -0
- package/dist/workspace-runtime/batch/source-publish.js +130 -0
- package/dist/workspace-runtime/codex/app-server.js +1065 -0
- package/dist/workspace-runtime/codex/compact.js +46 -0
- package/dist/workspace-runtime/codex/config-toml.js +107 -0
- package/dist/workspace-runtime/codex/delivery-tools.js +144 -0
- package/dist/workspace-runtime/codex/jsonrpc-stdio.js +145 -0
- package/dist/workspace-runtime/codex/launcher-client.js +177 -0
- package/dist/workspace-runtime/codex/loopback.js +146 -0
- package/dist/workspace-runtime/codex/mcp-config.js +39 -0
- package/dist/workspace-runtime/codex/model-broker.js +263 -0
- package/dist/workspace-runtime/codex/native-adapter.js +9 -0
- package/dist/workspace-runtime/codex/permissions.js +79 -0
- package/dist/workspace-runtime/codex/thread-image.js +38 -0
- package/dist/workspace-runtime/codex/tool-response.js +10 -0
- package/dist/workspace-runtime/codex/ui-instructions.js +4 -0
- package/dist/workspace-runtime/codex/ui-tools.js +203 -0
- package/dist/workspace-runtime/codex/work-mode.js +15 -0
- package/dist/workspace-runtime/main.js +10 -0
- package/dist/workspace-runtime/persistence/journal.js +365 -0
- package/dist/workspace-runtime/persistence/native-subagents.js +162 -0
- package/dist/workspace-runtime/persistence/sqlite-client.js +77 -0
- package/dist/workspace-runtime/persistence/sqlite-worker.js +1161 -0
- package/dist/workspace-runtime/persistence/stopped-execution.js +77 -0
- package/dist/workspace-runtime/previews/diagnostics.js +44 -0
- package/dist/workspace-runtime/previews/output.js +36 -0
- package/dist/workspace-runtime/previews/publish.js +283 -0
- package/dist/workspace-runtime/previews/runtime-preview.js +251 -0
- package/dist/workspace-runtime/previews/single-file.js +43 -0
- package/dist/workspace-runtime/processes/managed-writes.js +69 -0
- package/dist/workspace-runtime/serve.js +441 -0
- package/dist/workspace-runtime/server/accept-operation.js +61 -0
- package/dist/workspace-runtime/server/asset-transfers.js +63 -0
- package/dist/workspace-runtime/server/auth.js +21 -0
- package/dist/workspace-runtime/server/connectivity.js +211 -0
- package/dist/workspace-runtime/server/desktop-host.js +429 -0
- package/dist/workspace-runtime/server/desktop-preview-config.js +81 -0
- package/dist/workspace-runtime/server/desktop-preview-service.js +157 -0
- package/dist/workspace-runtime/server/desktop-preview-static.js +53 -0
- package/dist/workspace-runtime/server/desktop-preview.js +189 -0
- package/dist/workspace-runtime/server/dispatch.js +1655 -0
- package/dist/workspace-runtime/server/endpoints.js +21 -0
- package/dist/workspace-runtime/server/execution-group.js +90 -0
- package/dist/workspace-runtime/server/http.js +1363 -0
- package/dist/workspace-runtime/server/lock.js +53 -0
- package/dist/workspace-runtime/server/operation-record.js +33 -0
- package/dist/workspace-runtime/server/rfb-watch-gate.js +168 -0
- package/dist/workspace-runtime/server/session-restore.js +84 -0
- package/dist/workspace-runtime/server/source-uploader.js +138 -0
- package/dist/workspace-runtime/server/submit-operation.js +41 -0
- package/dist/workspace-runtime/server/terminal-host.js +366 -0
- package/dist/workspace-runtime/server/types.js +1 -0
- package/dist/workspace-runtime/server/workspace-transfer.js +168 -0
- package/dist/workspace-runtime/verify-artifact.js +59 -0
- package/dist/workspace-runtime/workspaces/append-only-log.js +62 -0
- package/dist/workspace-runtime/workspaces/archive.js +207 -0
- package/dist/workspace-runtime/workspaces/artifact-events.js +55 -0
- package/dist/workspace-runtime/workspaces/artifact-files.js +199 -0
- package/dist/workspace-runtime/workspaces/artifact-receipts.js +89 -0
- package/dist/workspace-runtime/workspaces/artifacts.js +282 -0
- package/dist/workspace-runtime/workspaces/asset-library-import.js +387 -0
- package/dist/workspace-runtime/workspaces/asset-publication-access.js +25 -0
- package/dist/workspace-runtime/workspaces/asset-transfer-dependencies.js +81 -0
- package/dist/workspace-runtime/workspaces/asset-transfer-publish.js +438 -0
- package/dist/workspace-runtime/workspaces/asset-transfer-storage.js +389 -0
- package/dist/workspace-runtime/workspaces/attachment-content.js +73 -0
- package/dist/workspace-runtime/workspaces/attachments.js +185 -0
- package/dist/workspace-runtime/workspaces/batch-commit.js +142 -0
- package/dist/workspace-runtime/workspaces/binary-content.js +65 -0
- package/dist/workspace-runtime/workspaces/binary-write.js +117 -0
- package/dist/workspace-runtime/workspaces/cli-context.js +23 -0
- package/dist/workspace-runtime/workspaces/cli-credentials.js +115 -0
- package/dist/workspace-runtime/workspaces/composer-context.js +147 -0
- package/dist/workspace-runtime/workspaces/context-error.js +2 -0
- package/dist/workspace-runtime/workspaces/delivery-build.js +331 -0
- package/dist/workspace-runtime/workspaces/delivery-store.js +168 -0
- package/dist/workspace-runtime/workspaces/delivery.js +64 -0
- package/dist/workspace-runtime/workspaces/dependencies.js +279 -0
- package/dist/workspace-runtime/workspaces/developer-command.js +98 -0
- package/dist/workspace-runtime/workspaces/directories.js +135 -0
- package/dist/workspace-runtime/workspaces/directory-access.js +37 -0
- package/dist/workspace-runtime/workspaces/directory-attachments.js +245 -0
- package/dist/workspace-runtime/workspaces/directory-create.js +57 -0
- package/dist/workspace-runtime/workspaces/directory-maintenance.js +111 -0
- package/dist/workspace-runtime/workspaces/directory-mutations.js +238 -0
- package/dist/workspace-runtime/workspaces/directory-revisions.js +56 -0
- package/dist/workspace-runtime/workspaces/directory-stats.js +49 -0
- package/dist/workspace-runtime/workspaces/disk-snapshot.js +31 -0
- package/dist/workspace-runtime/workspaces/empty-template.js +43 -0
- package/dist/workspace-runtime/workspaces/file-content.js +48 -0
- package/dist/workspace-runtime/workspaces/files-search.js +116 -0
- package/dist/workspace-runtime/workspaces/files.js +150 -0
- package/dist/workspace-runtime/workspaces/git-credential-broker.js +312 -0
- package/dist/workspace-runtime/workspaces/git-credential-helper.js +68 -0
- package/dist/workspace-runtime/workspaces/git-direct-store.js +155 -0
- package/dist/workspace-runtime/workspaces/git.js +670 -0
- package/dist/workspace-runtime/workspaces/instructions.js +56 -0
- package/dist/workspace-runtime/workspaces/json5-edit.js +313 -0
- package/dist/workspace-runtime/workspaces/library-attachments.js +268 -0
- package/dist/workspace-runtime/workspaces/operation-log.js +23 -0
- package/dist/workspace-runtime/workspaces/optional-platform-skills.js +14 -0
- package/dist/workspace-runtime/workspaces/parameter-agent-inputs.js +97 -0
- package/dist/workspace-runtime/workspaces/parameter-agent-protocol.js +40 -0
- package/dist/workspace-runtime/workspaces/parameter-agent-store.js +58 -0
- package/dist/workspace-runtime/workspaces/parameter-agent.js +284 -0
- package/dist/workspace-runtime/workspaces/parameter-assets.js +189 -0
- package/dist/workspace-runtime/workspaces/parameters.js +329 -0
- package/dist/workspace-runtime/workspaces/prepare.js +284 -0
- package/dist/workspace-runtime/workspaces/registry.js +251 -0
- package/dist/workspace-runtime/workspaces/remix-references.js +301 -0
- package/dist/workspace-runtime/workspaces/revisions.js +31 -0
- package/dist/workspace-runtime/workspaces/session-image.js +104 -0
- package/dist/workspace-runtime/workspaces/shared-git.js +40 -0
- package/dist/workspace-runtime/workspaces/skill-artifact-loader.js +95 -0
- package/dist/workspace-runtime/workspaces/skills.js +191 -0
- package/dist/workspace-runtime/workspaces/theme-asset-index.js +157 -0
- package/dist/workspace-runtime/workspaces/transfer-quota.js +69 -0
- package/dist/workspace-runtime/workspaces/transfer.js +471 -0
- package/dist/workspace-runtime/workspaces/turn-changes.js +75 -0
- package/dist/workspace-runtime/workspaces/video-attachments.js +49 -0
- package/dist/workspace-runtime/workspaces/worktree-attachments.js +74 -0
- package/dist/workspace-runtime/workspaces/worktree-checkout.js +67 -0
- package/dist/workspace-runtime/workspaces/worktrees.js +73 -0
- package/package.json +16 -5
- package/project-template/.claude/skills/playcraft-audio-generation/SKILL.md +31 -4
- package/project-template/.claude/skills/playcraft-image-generation/SKILL.md +36 -5
- package/project-template/.claude/skills/playcraft-image-generation/reference/build-sprite-sheet.template.mjs +1 -1
- package/project-template/.claude/skills/playcraft-image-generation/reference/compare-style.template.mjs +1 -1
- package/project-template/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +1 -1
- package/project-template/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +1 -1
- package/project-template/.claude/skills/playcraft-image-generation/reference/gen-edit-variants.template.mjs +1 -1
- package/project-template/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +1 -1
- package/project-template/.claude/skills/playcraft-image-generation/reference/ta-image-generation-detail.md +300 -0
- package/project-template/.claude/skills/playcraft-image-generation/reference/validate-sprite-sheet.template.mjs +1 -1
- package/project-template/.claude/skills/playcraft-image-processing/SKILL.md +50 -25
- package/project-template/.claude/skills/playcraft-replica-validation/SKILL.md +25 -0
- package/project-template/.claude/skills/playcraft-replica-validation/references/contracts.md +79 -0
- package/project-template/.claude/skills/playcraft-video-understanding/SKILL.md +29 -0
- package/project-template/.claude/skills/playcraft-video-understanding/references/contracts.md +37 -0
- package/project-template/.claude/skills/playcraft-workspace-assets/SKILL.md +53 -0
- package/project-template/.claude/skills/playcraft-workspace-assets/references/requests.json +32 -0
- package/project-template-v2/.claude/agents/artist.md +82 -0
- package/project-template-v2/.claude/agents/developer.md +153 -0
- package/project-template-v2/.claude/agents/game-designer.md +264 -0
- package/project-template-v2/.claude/agents/refs/artist-art-style-catalog.md +533 -0
- package/project-template-v2/.claude/agents/refs/artist-color-audio-recipes.md +153 -0
- package/project-template-v2/.claude/agents/refs/artist-dimension-axis.md +27 -0
- package/project-template-v2/.claude/agents/refs/artist-master-composite-recipes.md +208 -0
- package/project-template-v2/.claude/agents/refs/atom-skill-library.md +81 -0
- package/project-template-v2/.claude/agents/refs/developer-impl-cookbook.md +432 -0
- package/project-template-v2/.claude/agents/refs/framework-5-component-filter.md +252 -0
- package/project-template-v2/.claude/agents/refs/framework-game-feel-juice.md +266 -0
- package/project-template-v2/.claude/agents/refs/framework-mda.md +147 -0
- package/project-template-v2/.claude/agents/refs/game-designer-gameplay-sufficiency.md +123 -0
- package/project-template-v2/.claude/agents/refs/ta-3d-flip-recipe.md +88 -0
- package/project-template-v2/.claude/agents/refs/ta-atlas-deliverable-standard.md +67 -0
- package/project-template-v2/.claude/agents/refs/ta-batch-pipeline-recipes.md +120 -0
- package/project-template-v2/.claude/agents/refs/ta-image-generation-detail.md +300 -0
- package/project-template-v2/.claude/agents/refs/ta-image-ops-reference.md +495 -0
- package/project-template-v2/.claude/agents/refs/ta-pipeline-cookbook.md +1141 -0
- package/project-template-v2/.claude/agents/refs/ta-tools-reference.md +111 -0
- package/project-template-v2/.claude/agents/refs/ta-vfx-preset-catalog.md +365 -0
- package/project-template-v2/.claude/agents/refs/threejs-cannon-pitfalls.md +412 -0
- package/project-template-v2/.claude/agents/reviewer.md +75 -0
- package/project-template-v2/.claude/agents/technical-artist.md +86 -0
- package/project-template-v2/.claude/hooks/snapshot-milestone.mjs +243 -0
- package/project-template-v2/.claude/hooks/user-prompt.mjs +133 -0
- package/project-template-v2/.claude/settings.json +33 -0
- package/project-template-v2/.claude/skills/brainstorming/SKILL.md +161 -0
- package/project-template-v2/.claude/skills/brainstorming/scripts/frame-template.html +270 -0
- package/project-template-v2/.claude/skills/brainstorming/scripts/helper.js +177 -0
- package/project-template-v2/.claude/skills/brainstorming/scripts/server.cjs +354 -0
- package/project-template-v2/.claude/skills/brainstorming/scripts/start-server.sh +148 -0
- package/project-template-v2/.claude/skills/brainstorming/scripts/stop-server.sh +56 -0
- package/project-template-v2/.claude/skills/brainstorming/scripts/wait-for-selection.sh +62 -0
- package/project-template-v2/.claude/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
- package/project-template-v2/.claude/skills/brainstorming/visual-companion.md +309 -0
- package/project-template-v2/.claude/skills/playcraft-ad-psychology/SKILL.md +182 -0
- package/project-template-v2/.claude/skills/playcraft-art-style-guide/SKILL.md +123 -0
- package/project-template-v2/.claude/skills/playcraft-asset-state-sheet/SKILL.md +205 -0
- package/project-template-v2/.claude/skills/playcraft-audio-generation/SKILL.md +307 -0
- package/project-template-v2/.claude/skills/playcraft-batch-pipeline/SKILL.md +184 -0
- package/project-template-v2/.claude/skills/playcraft-build-optimizer/SKILL.md +306 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/SKILL.md +401 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/build-sprite-sheet.template.mjs +123 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/compare-style.template.mjs +254 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +333 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +95 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-edit-variants.template.mjs +118 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +136 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/prompt-cookbook.md +397 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/ta-image-generation-detail.md +300 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/validate-sprite-sheet.template.mjs +296 -0
- package/project-template-v2/.claude/skills/playcraft-image-ops/SKILL.md +122 -0
- package/project-template-v2/.claude/skills/playcraft-image-processing/SKILL.md +244 -0
- package/project-template-v2/.claude/skills/playcraft-masking/SKILL.md +373 -0
- package/project-template-v2/.claude/skills/playcraft-playable-optimization/SKILL.md +161 -0
- package/project-template-v2/.claude/skills/playcraft-research/SKILL.md +215 -0
- package/project-template-v2/.claude/skills/playcraft-skill-recommender/SKILL.md +382 -0
- package/project-template-v2/.claude/skills/playcraft-sprite-generation/SKILL.md +423 -0
- package/project-template-v2/.claude/skills/playcraft-sprite-remix/SKILL.md +158 -0
- package/project-template-v2/.claude/skills/playcraft-sprite-sheet/SKILL.md +100 -0
- package/project-template-v2/.claude/skills/playcraft-storyboard/SKILL.md +167 -0
- package/project-template-v2/.claude/skills/playcraft-style-qa/SKILL.md +270 -0
- package/project-template-v2/.claude/skills/playcraft-text-rendering/SKILL.md +236 -0
- package/project-template-v2/.claude/skills/playcraft-vfx-animation/SKILL.md +130 -0
- package/project-template-v2/.claude/skills/playcraft-workspace-assets/SKILL.md +53 -0
- package/project-template-v2/.claude/skills/playcraft-workspace-assets/references/requests.json +32 -0
- package/project-template-v2/.claude/skills/playwright-cli/SKILL.md +390 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/element-attributes.md +23 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/playwright-tests.md +39 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/request-mocking.md +87 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/running-code.md +240 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/session-management.md +226 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/spec-driven-testing.md +308 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/storage-state.md +275 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/test-generation.md +134 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/tracing.md +142 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/video-recording.md +153 -0
- package/project-template-v2/.claude/skills/session-analyzer/SKILL.md +386 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/execution-breakdown.mjs +182 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/find-turns.mjs +72 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/heavy-output.mjs +121 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/resolve-session.mjs +102 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/subagent-stats.mjs +127 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/subagent-tool-timeline.mjs +106 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/time-gaps.mjs +128 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/turn-timeline.mjs +67 -0
- package/project-template-v2/.claude/snapshot.mjs +263 -0
- package/project-template-v2/.playcraft/skills.lock.json +152 -0
- package/project-template-v2/CLAUDE.md +146 -0
- package/project-template-v2/assets/audio/bgm/.gitkeep +0 -0
- package/project-template-v2/assets/audio/sfx/.gitkeep +0 -0
- package/project-template-v2/assets/bundles/.gitkeep +0 -0
- package/project-template-v2/assets/images/bg/.gitkeep +0 -0
- package/project-template-v2/assets/images/reference/.gitkeep +0 -0
- package/project-template-v2/assets/images/storyboard/.gitkeep +0 -0
- package/project-template-v2/assets/images/tiles/.gitkeep +0 -0
- package/project-template-v2/assets/images/ui/.gitkeep +0 -0
- package/project-template-v2/assets/images/vfx/.gitkeep +0 -0
- package/project-template-v2/assets/models/.gitkeep +0 -0
- package/project-template-v2/docs/harness/iteration-1/context-flow.md +254 -0
- package/project-template-v2/docs/harness/iteration-1/generate-flow.md +91 -0
- package/project-template-v2/docs/harness/iteration-1/ideate-flow.md +214 -0
- package/project-template-v2/docs/harness/iteration-1/optimize-flow.md +75 -0
- package/project-template-v2/docs/harness/iteration-1/wrapup-flow.md +63 -0
- package/project-template-v2/docs/harness/iteration-2/context-flow.md +223 -0
- package/project-template-v2/docs/harness/iteration-2/generate-flow.md +129 -0
- package/project-template-v2/docs/harness/iteration-2/ideate-flow.md +267 -0
- package/project-template-v2/docs/harness/iteration-2/optimize-flow.md +164 -0
- package/project-template-v2/docs/harness/iteration-2/wrapup-flow.md +115 -0
- package/project-template-v2/docs/harness/orchestrator-flow.md +364 -0
- package/project-template-v2/docs/project-state.json +60 -0
- package/project-template-v2/docs/project-state.md +72 -0
- package/project-template-v2/docs/standards/README.md +225 -0
- package/project-template-v2/docs/standards/agent-behavior-standards.md +174 -0
- package/project-template-v2/docs/standards/artifacts/design-brief.md +19 -0
- package/project-template-v2/docs/standards/artifacts/design.md +22 -0
- package/project-template-v2/docs/standards/artifacts/game-code.md +41 -0
- package/project-template-v2/docs/standards/artifacts/todo-list.md +41 -0
- package/project-template-v2/docs/standards/iter1-agent-behavior-standards.md +343 -0
- package/project-template-v2/game/index.ts +18 -0
- package/project-template-v2/globals.d.ts +51 -0
- package/project-template-v2/index.css +34 -0
- package/project-template-v2/index.html +18 -0
- package/project-template-v2/main.ts +9 -0
- package/project-template-v2/package.json +46 -0
- package/project-template-v2/skills/_shared/scripts/dispatch-clear.mjs +31 -0
- package/project-template-v2/skills/_shared/scripts/dispatch-set.mjs +86 -0
- package/project-template-v2/skills/_shared/scripts/dod-check.mjs +153 -0
- package/project-template-v2/skills/_shared/scripts/handoff-append.mjs +70 -0
- package/project-template-v2/skills/_shared/scripts/lib/validator-artifacts.mjs +91 -0
- package/project-template-v2/skills/_shared/scripts/pipeline/dod-config.mjs +131 -0
- package/project-template-v2/skills/_shared/scripts/pipeline/index.mjs +80 -0
- package/project-template-v2/skills/_shared/scripts/pipeline/iteration-1-core.mjs +90 -0
- package/project-template-v2/skills/_shared/scripts/pipeline/iteration-2-wrap.mjs +93 -0
- package/project-template-v2/skills/_shared/scripts/pipeline/iteration-3-visual.mjs +23 -0
- package/project-template-v2/skills/_shared/scripts/render-project-state.mjs +230 -0
- package/project-template-v2/skills/_shared/scripts/state-advance-stage.mjs +58 -0
- package/project-template-v2/skills/_shared/scripts/state-get.mjs +339 -0
- package/project-template-v2/skills/_shared/scripts/state-handoff.mjs +39 -0
- package/project-template-v2/skills/_shared/scripts/state-set.mjs +94 -0
- package/project-template-v2/skills/_shared/scripts/state-store.mjs +783 -0
- package/project-template-v2/skills/_shared/scripts/todo-add.mjs +88 -0
- package/project-template-v2/skills/_shared/scripts/todo-get.mjs +130 -0
- package/project-template-v2/skills/_shared/scripts/todo-remove.mjs +33 -0
- package/project-template-v2/skills/_shared/scripts/todo-set.mjs +47 -0
- package/project-template-v2/skills/_shared/scripts/verify-asset-code-sync.mjs +268 -0
- package/project-template-v2/skills/_shared/scripts/verify-env.mjs +285 -0
- package/project-template-v2/skills/_shared/scripts/verify-placeholders.mjs +161 -0
- package/project-template-v2/skills/playable-autoplay/SKILL.md +176 -0
- package/project-template-v2/skills/playable-autoplay/agents/openai.yaml +4 -0
- package/project-template-v2/skills/playable-debug/SKILL.md +116 -0
- package/project-template-v2/skills/playable-debug/agents/openai.yaml +4 -0
- package/project-template-v2/skills/playable-debug/references/debug-config.md +40 -0
- package/project-template-v2/skills/playable-record/SKILL.md +140 -0
- package/project-template-v2/skills/playable-record/scripts/lib/dev-server.mjs +104 -0
- package/project-template-v2/skills/playable-record/scripts/lib/record-audio-bridge.js +141 -0
- package/project-template-v2/skills/playable-record/scripts/record-playable.mjs +425 -0
- package/project-template-v2/skills/playable-record/scripts/verify-contract.mjs +261 -0
- package/project-template-v2/skills/playable-record/scripts/verify-firstwin.mjs +398 -0
- package/project-template-v2/skills/playable-record/scripts/verify-fusion.mjs +322 -0
- package/project-template-v2/skills/playable-record/scripts/verify-lifecycle.mjs +105 -0
- package/project-template-v2/skills/playable-record/scripts/verify-vlm-video.mjs +230 -0
- package/project-template-v2/skills/playable-validate/SKILL.md +61 -0
- package/project-template-v2/skills/playable-validate/validation-rules.md +14 -0
- package/project-template-v2/skills/playable-verify-ui/SKILL.md +63 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/lib/__init__.py +1 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/lib/config_expr.js +218 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/lib/node_utils.js +51 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/lib/profile_loader.py +59 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/lib/report.py +106 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/lib/runtime_contract.js +116 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/verify_fetch_antipatterns.py +59 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/verify_hardcoded_layout.js +64 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/verify_runtime_contract.js +58 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/verify_text_overlap.py +333 -0
- package/project-template-v2/ta-workspace/scripts/.gitkeep +0 -0
- package/project-template-v2/tsconfig.json +20 -0
- package/project-template-v2/vite.config.ts +27 -0
- package/project-templates/batch-locks/phaser.yaml +922 -0
- package/project-templates/batch-locks/threejs.yaml +978 -0
- package/project-templates/empty/AGENTS.md +53 -0
- package/project-templates/empty/gitignore +33 -0
- package/project-templates/phaser/.claude/skills/playcraft-audio-generation/SKILL.md +31 -4
- package/project-templates/phaser/.claude/skills/playcraft-image-generation/SKILL.md +36 -5
- package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/build-sprite-sheet.template.mjs +1 -1
- package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/compare-style.template.mjs +1 -1
- package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +1 -1
- package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +1 -1
- package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/gen-edit-variants.template.mjs +1 -1
- package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +1 -1
- package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/ta-image-generation-detail.md +300 -0
- package/project-templates/phaser/.claude/skills/playcraft-image-generation/reference/validate-sprite-sheet.template.mjs +1 -1
- package/project-templates/phaser/.claude/skills/playcraft-image-processing/SKILL.md +50 -25
- package/project-templates/phaser/.claude/skills/playcraft-workspace-assets/SKILL.md +53 -0
- package/project-templates/phaser/.claude/skills/playcraft-workspace-assets/references/requests.json +32 -0
- package/project-templates/threejs/.claude/skills/playcraft-audio-generation/SKILL.md +31 -4
- package/project-templates/threejs/.claude/skills/playcraft-image-generation/SKILL.md +36 -5
- package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/build-sprite-sheet.template.mjs +1 -1
- package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/compare-style.template.mjs +1 -1
- package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +1 -1
- package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +1 -1
- package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/gen-edit-variants.template.mjs +1 -1
- package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +1 -1
- package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/ta-image-generation-detail.md +300 -0
- package/project-templates/threejs/.claude/skills/playcraft-image-generation/reference/validate-sprite-sheet.template.mjs +1 -1
- package/project-templates/threejs/.claude/skills/playcraft-image-processing/SKILL.md +50 -25
- package/project-templates/threejs/.claude/skills/playcraft-workspace-assets/SKILL.md +53 -0
- package/project-templates/threejs/.claude/skills/playcraft-workspace-assets/references/requests.json +32 -0
- package/templates/preview-runtime/v1/README.md +71 -0
- package/templates/preview-runtime/v1/build-preview.mjs +1324 -0
- package/templates/preview-runtime/v1/manifest.json +17 -0
- package/templates/preview-runtime/v1/release-guard.mjs +87 -0
- package/templates/preview-runtime/v1/runtime.d.mts +3 -0
- package/templates/preview-runtime/v1/runtime.d.ts +3 -0
- package/templates/preview-runtime/v1/runtime.mjs +1121 -0
- package/templates/preview-runtime/v1/types/adapters.d.ts +26 -0
- package/templates/preview-runtime/v1/types/preview.d.ts +23 -0
- package/templates/preview-runtime/v1/types/protocol.d.ts +94 -0
- package/templates/preview-runtime/v1/types/runtime.d.ts +14 -0
|
@@ -0,0 +1,1121 @@
|
|
|
1
|
+
// ../iframe-bridge/package.json
|
|
2
|
+
var package_default = {
|
|
3
|
+
name: "@playcraft/iframe-bridge",
|
|
4
|
+
version: "0.0.55",
|
|
5
|
+
private: false,
|
|
6
|
+
type: "module",
|
|
7
|
+
description: "PlayCraft iframe postMessage bridge SDK for parent \u2194 child communication",
|
|
8
|
+
sideEffects: false,
|
|
9
|
+
publishConfig: {
|
|
10
|
+
access: "public"
|
|
11
|
+
},
|
|
12
|
+
main: "./dist/index.js",
|
|
13
|
+
types: "./dist/index.d.ts",
|
|
14
|
+
exports: {
|
|
15
|
+
".": {
|
|
16
|
+
types: "./dist/index.d.ts",
|
|
17
|
+
default: "./dist/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
files: [
|
|
21
|
+
"dist",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
scripts: {
|
|
25
|
+
build: `node -e "require('fs').rmSync('dist',{recursive:true,force:true})" && rollup -c`,
|
|
26
|
+
dev: "rollup -c -w",
|
|
27
|
+
typecheck: "tsc -p tsconfig.json --noEmit",
|
|
28
|
+
prepublishOnly: "pnpm build",
|
|
29
|
+
test: "vitest run",
|
|
30
|
+
"test:watch": "vitest",
|
|
31
|
+
playground: 'pnpm --filter "@playcraft/iframe-bridge-playground-*" --parallel dev',
|
|
32
|
+
lint: "echo 'No eslint config yet'",
|
|
33
|
+
release: "node ../../scripts/release-npm.mjs --packages=iframe-bridge --skip-install --skip-tests --skip-git-push"
|
|
34
|
+
},
|
|
35
|
+
devDependencies: {
|
|
36
|
+
"@rollup/plugin-json": "6.1.0",
|
|
37
|
+
"@rollup/plugin-node-resolve": "16.0.3",
|
|
38
|
+
"@rollup/plugin-swc": "0.4.0",
|
|
39
|
+
"@swc/core": "1.15.3",
|
|
40
|
+
"@types/node": "^25.2.0",
|
|
41
|
+
"happy-dom": "^20.0.10",
|
|
42
|
+
rollup: "4.57.1",
|
|
43
|
+
"rollup-plugin-dts": "6.3.0",
|
|
44
|
+
typescript: "^5.9.3",
|
|
45
|
+
vite: "^8.0.3",
|
|
46
|
+
vitest: "^3.2.4"
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// ../iframe-bridge/src/configs/constants.ts
|
|
51
|
+
var PROTOCOL_VERSION = package_default.version;
|
|
52
|
+
var DEFAULT_REQUEST_TIMEOUT_MS = 15e4;
|
|
53
|
+
var BridgeErrorCodes = {
|
|
54
|
+
ABORTED: "ABORTED",
|
|
55
|
+
DESTROYED: "DESTROYED",
|
|
56
|
+
INTERNAL_ERROR: "INTERNAL_ERROR",
|
|
57
|
+
INVALID_PARAM: "INVALID_PARAM",
|
|
58
|
+
METHOD_NOT_FOUND: "METHOD_NOT_FOUND",
|
|
59
|
+
PEER_UNAVAILABLE: "PEER_UNAVAILABLE",
|
|
60
|
+
REQUEST_FAILED: "REQUEST_FAILED",
|
|
61
|
+
TIMEOUT: "TIMEOUT"
|
|
62
|
+
};
|
|
63
|
+
var RetCodes = {
|
|
64
|
+
OK: 0,
|
|
65
|
+
INVALID_PARAM: 1,
|
|
66
|
+
TIMEOUT: 2,
|
|
67
|
+
ABORTED: 3,
|
|
68
|
+
REQUEST_FAILED: 4,
|
|
69
|
+
INTERNAL_ERROR: 5,
|
|
70
|
+
PEER_UNAVAILABLE: 6,
|
|
71
|
+
DESTROYED: 7,
|
|
72
|
+
METHOD_NOT_FOUND: 8
|
|
73
|
+
};
|
|
74
|
+
var ERROR_CODE_TO_RET = {
|
|
75
|
+
[BridgeErrorCodes.INVALID_PARAM]: RetCodes.INVALID_PARAM,
|
|
76
|
+
[BridgeErrorCodes.TIMEOUT]: RetCodes.TIMEOUT,
|
|
77
|
+
[BridgeErrorCodes.ABORTED]: RetCodes.ABORTED,
|
|
78
|
+
[BridgeErrorCodes.REQUEST_FAILED]: RetCodes.REQUEST_FAILED,
|
|
79
|
+
[BridgeErrorCodes.INTERNAL_ERROR]: RetCodes.INTERNAL_ERROR,
|
|
80
|
+
[BridgeErrorCodes.PEER_UNAVAILABLE]: RetCodes.PEER_UNAVAILABLE,
|
|
81
|
+
[BridgeErrorCodes.DESTROYED]: RetCodes.DESTROYED,
|
|
82
|
+
[BridgeErrorCodes.METHOD_NOT_FOUND]: RetCodes.METHOD_NOT_FOUND
|
|
83
|
+
};
|
|
84
|
+
var RET_TO_ERROR_CODE = {
|
|
85
|
+
[RetCodes.INVALID_PARAM]: BridgeErrorCodes.INVALID_PARAM,
|
|
86
|
+
[RetCodes.TIMEOUT]: BridgeErrorCodes.TIMEOUT,
|
|
87
|
+
[RetCodes.ABORTED]: BridgeErrorCodes.ABORTED,
|
|
88
|
+
[RetCodes.REQUEST_FAILED]: BridgeErrorCodes.REQUEST_FAILED,
|
|
89
|
+
[RetCodes.INTERNAL_ERROR]: BridgeErrorCodes.INTERNAL_ERROR,
|
|
90
|
+
[RetCodes.PEER_UNAVAILABLE]: BridgeErrorCodes.PEER_UNAVAILABLE,
|
|
91
|
+
[RetCodes.DESTROYED]: BridgeErrorCodes.DESTROYED,
|
|
92
|
+
[RetCodes.METHOD_NOT_FOUND]: BridgeErrorCodes.METHOD_NOT_FOUND
|
|
93
|
+
};
|
|
94
|
+
function errorCodeToRet(code) {
|
|
95
|
+
return ERROR_CODE_TO_RET[code] ?? RetCodes.REQUEST_FAILED;
|
|
96
|
+
}
|
|
97
|
+
function retToErrorCode(ret) {
|
|
98
|
+
return RET_TO_ERROR_CODE[ret] ?? BridgeErrorCodes.REQUEST_FAILED;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// ../iframe-bridge/src/utils/envelope.ts
|
|
102
|
+
function isEnvelopeKind(kind) {
|
|
103
|
+
return kind === "req" || kind === "res";
|
|
104
|
+
}
|
|
105
|
+
function isPlaycraftEnvelopeShape(data) {
|
|
106
|
+
if (!data || typeof data !== "object") return false;
|
|
107
|
+
const env = data;
|
|
108
|
+
return typeof env.__playcraft__ === "string" && isEnvelopeKind(env.kind) && typeof env.id === "string" && typeof env.name === "string";
|
|
109
|
+
}
|
|
110
|
+
function getPlaycraftEnvelopeVersionMismatch(data) {
|
|
111
|
+
if (!isPlaycraftEnvelopeShape(data)) return void 0;
|
|
112
|
+
const peer = data.__playcraft__;
|
|
113
|
+
if (peer === PROTOCOL_VERSION) return void 0;
|
|
114
|
+
return { local: PROTOCOL_VERSION, peer };
|
|
115
|
+
}
|
|
116
|
+
function createEnvelope(kind, id, name, data) {
|
|
117
|
+
return { __playcraft__: PROTOCOL_VERSION, kind, id, name, data };
|
|
118
|
+
}
|
|
119
|
+
function createSuccessResponse(id, name, data) {
|
|
120
|
+
return { ...createEnvelope("res", id, name), ret: RetCodes.OK, data };
|
|
121
|
+
}
|
|
122
|
+
function createErrorResponse(id, name, error) {
|
|
123
|
+
return {
|
|
124
|
+
...createEnvelope("res", id, name),
|
|
125
|
+
ret: error.ret,
|
|
126
|
+
msg: error.msg
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function isPlaycraftEnvelope(data) {
|
|
130
|
+
return isPlaycraftEnvelopeShape(data);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// ../iframe-bridge/src/utils/errors.ts
|
|
134
|
+
var PlaycraftBridgeError = class extends Error {
|
|
135
|
+
code;
|
|
136
|
+
detail;
|
|
137
|
+
constructor(code, message, detail) {
|
|
138
|
+
super(message);
|
|
139
|
+
this.name = "PlaycraftBridgeError";
|
|
140
|
+
this.code = code;
|
|
141
|
+
this.detail = detail;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
function isRpcError(value) {
|
|
145
|
+
return !!value && typeof value === "object" && "ret" in value && "msg" in value && typeof value.ret === "number" && typeof value.msg === "string";
|
|
146
|
+
}
|
|
147
|
+
function isLegacyCodeMessageError(value) {
|
|
148
|
+
return !!value && typeof value === "object" && "code" in value && "message" in value && typeof value.code === "string" && typeof value.message === "string";
|
|
149
|
+
}
|
|
150
|
+
function toPlaycraftError(err) {
|
|
151
|
+
if (isRpcError(err)) {
|
|
152
|
+
return err;
|
|
153
|
+
}
|
|
154
|
+
if (err instanceof PlaycraftBridgeError) {
|
|
155
|
+
return {
|
|
156
|
+
ret: errorCodeToRet(err.code),
|
|
157
|
+
msg: err.message
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
if (isLegacyCodeMessageError(err)) {
|
|
161
|
+
return {
|
|
162
|
+
ret: errorCodeToRet(err.code),
|
|
163
|
+
msg: err.message
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
ret: RetCodes.INTERNAL_ERROR,
|
|
168
|
+
msg: err instanceof Error ? err.message : String(err)
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// ../iframe-bridge/src/configs/method-names.ts
|
|
173
|
+
var BridgeMethods = {
|
|
174
|
+
form: {
|
|
175
|
+
get: "form.get",
|
|
176
|
+
set: "form.set"
|
|
177
|
+
},
|
|
178
|
+
image: {
|
|
179
|
+
aiGenerate: "image.aiGenerate"
|
|
180
|
+
},
|
|
181
|
+
dialog: {
|
|
182
|
+
close: "dialog.close"
|
|
183
|
+
},
|
|
184
|
+
storage: {
|
|
185
|
+
get: "storage.get"
|
|
186
|
+
},
|
|
187
|
+
child: {
|
|
188
|
+
ready: "child.ready"
|
|
189
|
+
},
|
|
190
|
+
host: {
|
|
191
|
+
init: "host.init"
|
|
192
|
+
},
|
|
193
|
+
runtimeParameters: {
|
|
194
|
+
hello: "runtime.parameters.hello",
|
|
195
|
+
snapshot: "runtime.parameters.snapshot",
|
|
196
|
+
patch: "runtime.parameters.patch",
|
|
197
|
+
restart: "runtime.parameters.restart",
|
|
198
|
+
status: "runtime.parameters.status",
|
|
199
|
+
dispose: "runtime.parameters.dispose",
|
|
200
|
+
capabilities: "runtime.parameters.capabilities",
|
|
201
|
+
result: "runtime.parameters.result",
|
|
202
|
+
resyncRequired: "runtime.parameters.resync-required"
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
var BRIDGE_EVENT_NAMES = [
|
|
206
|
+
BridgeMethods.child.ready,
|
|
207
|
+
BridgeMethods.host.init,
|
|
208
|
+
BridgeMethods.dialog.close,
|
|
209
|
+
BridgeMethods.runtimeParameters.capabilities,
|
|
210
|
+
BridgeMethods.runtimeParameters.result,
|
|
211
|
+
BridgeMethods.runtimeParameters.resyncRequired
|
|
212
|
+
];
|
|
213
|
+
var BRIDGE_RPC_NAMES = [
|
|
214
|
+
BridgeMethods.form.get,
|
|
215
|
+
BridgeMethods.form.set,
|
|
216
|
+
BridgeMethods.image.aiGenerate,
|
|
217
|
+
BridgeMethods.storage.get,
|
|
218
|
+
BridgeMethods.runtimeParameters.hello,
|
|
219
|
+
BridgeMethods.runtimeParameters.snapshot,
|
|
220
|
+
BridgeMethods.runtimeParameters.patch,
|
|
221
|
+
BridgeMethods.runtimeParameters.restart,
|
|
222
|
+
BridgeMethods.runtimeParameters.status,
|
|
223
|
+
BridgeMethods.runtimeParameters.dispose
|
|
224
|
+
];
|
|
225
|
+
|
|
226
|
+
// ../iframe-bridge/src/configs/perspective.ts
|
|
227
|
+
var BridgePerspectives = {
|
|
228
|
+
parent: "parent",
|
|
229
|
+
child: "child"
|
|
230
|
+
};
|
|
231
|
+
function bridgePeerForPerspective(perspective) {
|
|
232
|
+
return perspective === BridgePerspectives.parent ? "Parent" : "Child";
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// ../iframe-bridge/src/utils/debug-log.ts
|
|
236
|
+
var PARENT_TO_CHILD_REQS = /* @__PURE__ */ new Set([BridgeMethods.host.init]);
|
|
237
|
+
var PEER_CONSOLE_STYLES = {
|
|
238
|
+
Parent: "color: #6366f1; font-weight: bold",
|
|
239
|
+
Child: "color: #fead43; font-weight: bold"
|
|
240
|
+
};
|
|
241
|
+
var LOCAL_CONSOLE_STYLES = {
|
|
242
|
+
[BridgePerspectives.parent]: "color: #6366f1; font-weight: bold",
|
|
243
|
+
[BridgePerspectives.child]: "color: #fead43; font-weight: bold"
|
|
244
|
+
};
|
|
245
|
+
function resolveWireFlow(name, kind) {
|
|
246
|
+
if (kind === "res" || PARENT_TO_CHILD_REQS.has(name)) {
|
|
247
|
+
return { from: "Parent", to: "Child" };
|
|
248
|
+
}
|
|
249
|
+
return { from: "Child", to: "Parent" };
|
|
250
|
+
}
|
|
251
|
+
function logBridgeDebug(perspective, direction, msg) {
|
|
252
|
+
if (!perspective) {
|
|
253
|
+
console.debug(`[playcraft:${direction}]`, msg);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
const { from, to } = resolveWireFlow(msg.name, msg.kind);
|
|
257
|
+
const localLabel = bridgePeerForPerspective(perspective);
|
|
258
|
+
console.debug(
|
|
259
|
+
`%c[${localLabel}]%c %c${from}%c \u2192 %c${to}%c \xB7 ${direction} \xB7 ${msg.kind} \xB7 ${msg.name}`,
|
|
260
|
+
LOCAL_CONSOLE_STYLES[perspective],
|
|
261
|
+
"",
|
|
262
|
+
PEER_CONSOLE_STYLES[from],
|
|
263
|
+
"color: inherit",
|
|
264
|
+
PEER_CONSOLE_STYLES[to],
|
|
265
|
+
"color: inherit",
|
|
266
|
+
msg
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// ../iframe-bridge/src/utils/is-event-name.ts
|
|
271
|
+
var EVENT_NAMES = new Set(BRIDGE_EVENT_NAMES);
|
|
272
|
+
function isEventName(name) {
|
|
273
|
+
return EVENT_NAMES.has(name);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// ../iframe-bridge/src/utils/id.ts
|
|
277
|
+
var idSeq = 0;
|
|
278
|
+
function genId() {
|
|
279
|
+
return `${Date.now()}-${idSeq++}`;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// ../iframe-bridge/src/utils/send-req.ts
|
|
283
|
+
function sendReq(bridge, name, data) {
|
|
284
|
+
bridge.postMessage(createEnvelope("req", genId(), name, data));
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// ../iframe-bridge/src/libs/invoke.ts
|
|
288
|
+
function normalizeInvokeCall(call) {
|
|
289
|
+
if (Array.isArray(call)) {
|
|
290
|
+
const [name, data, options] = call;
|
|
291
|
+
return { name, data, options };
|
|
292
|
+
}
|
|
293
|
+
return call;
|
|
294
|
+
}
|
|
295
|
+
function isInvokeGroups(input) {
|
|
296
|
+
return Array.isArray(input) && input.length > 0 && typeof input[0] === "object" && input[0] !== null && "calls" in input[0];
|
|
297
|
+
}
|
|
298
|
+
async function settleParallel(promises) {
|
|
299
|
+
const settled = await Promise.allSettled(promises);
|
|
300
|
+
return settled.map(
|
|
301
|
+
(outcome) => outcome.status === "fulfilled" ? outcome.value : { error: toPlaycraftError(outcome.reason) }
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
async function runInvokeCalls(bridge, calls, mode, batchOptions = {}, defaultTimeout = DEFAULT_REQUEST_TIMEOUT_MS) {
|
|
305
|
+
const normalized = calls.map(normalizeInvokeCall);
|
|
306
|
+
const shared = { timeout: batchOptions.timeout, signal: batchOptions.signal };
|
|
307
|
+
if (mode === "parallel") {
|
|
308
|
+
return settleParallel(
|
|
309
|
+
normalized.map(
|
|
310
|
+
(call) => emitOne(bridge, call.name, call.data, { ...shared, ...call.options }, defaultTimeout)
|
|
311
|
+
)
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
const results = [];
|
|
315
|
+
for (const call of normalized) {
|
|
316
|
+
results.push(
|
|
317
|
+
await emitOne(bridge, call.name, call.data, { ...shared, ...call.options }, defaultTimeout)
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
return results;
|
|
321
|
+
}
|
|
322
|
+
function emitOne(bridge, name, data, options = {}, defaultTimeout = DEFAULT_REQUEST_TIMEOUT_MS) {
|
|
323
|
+
if (isEventName(name)) {
|
|
324
|
+
sendReq(bridge, name, data ?? {});
|
|
325
|
+
return Promise.resolve(void 0);
|
|
326
|
+
}
|
|
327
|
+
const timeout = options.timeout ?? defaultTimeout;
|
|
328
|
+
const id = genId();
|
|
329
|
+
return new Promise((resolve, reject) => {
|
|
330
|
+
let pending;
|
|
331
|
+
const offMessage = bridge.addEventListener("message", (e) => {
|
|
332
|
+
const msg = e.data;
|
|
333
|
+
if (msg.kind !== "res" || msg.id !== id || msg.name !== name) return;
|
|
334
|
+
clearTimeout(pending.timer);
|
|
335
|
+
pending.cleanupAbortListener?.();
|
|
336
|
+
offMessage();
|
|
337
|
+
if (msg.ret === RetCodes.OK) {
|
|
338
|
+
resolve(msg.data);
|
|
339
|
+
} else {
|
|
340
|
+
reject(
|
|
341
|
+
new PlaycraftBridgeError(
|
|
342
|
+
retToErrorCode(msg.ret ?? RetCodes.REQUEST_FAILED),
|
|
343
|
+
msg.msg ?? "request failed"
|
|
344
|
+
)
|
|
345
|
+
);
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
pending = {
|
|
349
|
+
resolve,
|
|
350
|
+
reject,
|
|
351
|
+
timer: setTimeout(() => {
|
|
352
|
+
offMessage();
|
|
353
|
+
reject(
|
|
354
|
+
new PlaycraftBridgeError(
|
|
355
|
+
BridgeErrorCodes.TIMEOUT,
|
|
356
|
+
`[playcraft] emit "${name}" timeout after ${timeout}ms`
|
|
357
|
+
)
|
|
358
|
+
);
|
|
359
|
+
}, timeout),
|
|
360
|
+
offMessage
|
|
361
|
+
};
|
|
362
|
+
if (options.signal) {
|
|
363
|
+
const onAbort = () => {
|
|
364
|
+
clearTimeout(pending.timer);
|
|
365
|
+
offMessage();
|
|
366
|
+
reject(
|
|
367
|
+
new PlaycraftBridgeError(BridgeErrorCodes.ABORTED, `[playcraft] emit "${name}" aborted`)
|
|
368
|
+
);
|
|
369
|
+
};
|
|
370
|
+
if (options.signal.aborted) {
|
|
371
|
+
onAbort();
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
options.signal.addEventListener("abort", onAbort, { once: true });
|
|
375
|
+
pending.cleanupAbortListener = () => options.signal?.removeEventListener("abort", onAbort);
|
|
376
|
+
}
|
|
377
|
+
try {
|
|
378
|
+
bridge.postMessage(createEnvelope("req", id, name, data));
|
|
379
|
+
} catch (err) {
|
|
380
|
+
clearTimeout(pending.timer);
|
|
381
|
+
offMessage();
|
|
382
|
+
reject(err);
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
function emitForBridge(bridge, nameOrCalls, dataOrOptions, options) {
|
|
387
|
+
if (typeof nameOrCalls === "string") {
|
|
388
|
+
return emitOne(
|
|
389
|
+
bridge,
|
|
390
|
+
nameOrCalls,
|
|
391
|
+
dataOrOptions,
|
|
392
|
+
options
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
const batchOptions = dataOrOptions ?? {};
|
|
396
|
+
if (isInvokeGroups(nameOrCalls)) {
|
|
397
|
+
const outerMode = batchOptions.mode ?? "serial";
|
|
398
|
+
const runGroup = (group) => runInvokeCalls(bridge, group.calls, group.mode ?? "serial", batchOptions);
|
|
399
|
+
if (outerMode === "parallel") {
|
|
400
|
+
return settleParallel(nameOrCalls.map(runGroup));
|
|
401
|
+
}
|
|
402
|
+
return (async () => {
|
|
403
|
+
const results = [];
|
|
404
|
+
for (const group of nameOrCalls) {
|
|
405
|
+
results.push(await runGroup(group));
|
|
406
|
+
}
|
|
407
|
+
return results;
|
|
408
|
+
})();
|
|
409
|
+
}
|
|
410
|
+
return runInvokeCalls(bridge, nameOrCalls, batchOptions.mode ?? "serial", batchOptions);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
// ../iframe-bridge/src/libs/handle.ts
|
|
414
|
+
function safeReply(bridge, message) {
|
|
415
|
+
try {
|
|
416
|
+
bridge.postMessage(message);
|
|
417
|
+
} catch (err) {
|
|
418
|
+
if (err instanceof PlaycraftBridgeError && err.code === BridgeErrorCodes.PEER_UNAVAILABLE) {
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
throw err;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
function onForBridge(bridge, name, fn) {
|
|
425
|
+
return bridge.addEventListener("message", async (e) => {
|
|
426
|
+
const msg = e.data;
|
|
427
|
+
if (msg.kind !== "req" || msg.name !== name) return;
|
|
428
|
+
if (isEventName(name)) {
|
|
429
|
+
await fn(msg.data);
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
try {
|
|
433
|
+
const data = await fn(msg.data, {
|
|
434
|
+
id: msg.id
|
|
435
|
+
});
|
|
436
|
+
safeReply(bridge, createSuccessResponse(msg.id, msg.name, data));
|
|
437
|
+
} catch (err) {
|
|
438
|
+
safeReply(bridge, createErrorResponse(msg.id, msg.name, toPlaycraftError(err)));
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// ../iframe-bridge/src/libs/bridge.ts
|
|
444
|
+
var Bridge = class {
|
|
445
|
+
constructor(options) {
|
|
446
|
+
this.options = options;
|
|
447
|
+
this.targetOrigin = options.targetOrigin;
|
|
448
|
+
this.messageTarget = options.messageTarget ?? window;
|
|
449
|
+
this.messageTarget.addEventListener("message", this.onWindowMessage);
|
|
450
|
+
}
|
|
451
|
+
options;
|
|
452
|
+
targetOrigin;
|
|
453
|
+
listeners = /* @__PURE__ */ new Set();
|
|
454
|
+
warnedPeerVersions = /* @__PURE__ */ new Set();
|
|
455
|
+
destroyed = false;
|
|
456
|
+
messageTarget;
|
|
457
|
+
emit(nameOrCalls, dataOrOptions, options) {
|
|
458
|
+
return emitForBridge(this, nameOrCalls, dataOrOptions, options);
|
|
459
|
+
}
|
|
460
|
+
on(name, fn) {
|
|
461
|
+
return onForBridge(this, name, fn);
|
|
462
|
+
}
|
|
463
|
+
postMessage(message, targetOrigin = this.options.targetOrigin, transfer) {
|
|
464
|
+
this.assertAlive();
|
|
465
|
+
const peer = this.options.peer();
|
|
466
|
+
if (!peer) {
|
|
467
|
+
throw new PlaycraftBridgeError(
|
|
468
|
+
BridgeErrorCodes.PEER_UNAVAILABLE,
|
|
469
|
+
"[playcraft] peer window is not available"
|
|
470
|
+
);
|
|
471
|
+
}
|
|
472
|
+
this.log("send", message);
|
|
473
|
+
peer.postMessage(message, targetOrigin, transfer ?? []);
|
|
474
|
+
}
|
|
475
|
+
addEventListener(type, listener) {
|
|
476
|
+
this.assertAlive();
|
|
477
|
+
this.listeners.add(listener);
|
|
478
|
+
return () => this.listeners.delete(listener);
|
|
479
|
+
}
|
|
480
|
+
destroy() {
|
|
481
|
+
if (this.destroyed) return;
|
|
482
|
+
this.destroyed = true;
|
|
483
|
+
this.messageTarget.removeEventListener("message", this.onWindowMessage);
|
|
484
|
+
this.listeners.clear();
|
|
485
|
+
}
|
|
486
|
+
assertAlive() {
|
|
487
|
+
if (this.destroyed) {
|
|
488
|
+
throw new PlaycraftBridgeError(BridgeErrorCodes.DESTROYED, "[playcraft] bridge destroyed");
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
log(event, msg) {
|
|
492
|
+
const { debug, perspective } = this.options;
|
|
493
|
+
if (!debug) return;
|
|
494
|
+
if (typeof debug === "function") debug(event, msg);
|
|
495
|
+
else logBridgeDebug(perspective, event, msg);
|
|
496
|
+
}
|
|
497
|
+
warnVersionMismatch(localVersion, peerVersion) {
|
|
498
|
+
if (this.warnedPeerVersions.has(peerVersion)) return;
|
|
499
|
+
this.warnedPeerVersions.add(peerVersion);
|
|
500
|
+
console.warn(
|
|
501
|
+
`[playcraft] protocol version mismatch: local ${localVersion}, peer ${peerVersion}. Messages are still processed; align @playcraft/iframe-bridge versions when possible.`
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
onWindowMessage = (e) => {
|
|
505
|
+
const msgEvent = e;
|
|
506
|
+
if (this.destroyed || !this.options.allowedOrigins.includes(msgEvent.origin)) return;
|
|
507
|
+
if (this.options.strictSource) {
|
|
508
|
+
const peer = this.options.peer();
|
|
509
|
+
if (!peer || msgEvent.source !== peer) return;
|
|
510
|
+
}
|
|
511
|
+
if (!isPlaycraftEnvelope(msgEvent.data)) return;
|
|
512
|
+
const mismatch = getPlaycraftEnvelopeVersionMismatch(msgEvent.data);
|
|
513
|
+
if (mismatch) {
|
|
514
|
+
this.warnVersionMismatch(mismatch.local, mismatch.peer);
|
|
515
|
+
}
|
|
516
|
+
this.log("recv", msgEvent.data);
|
|
517
|
+
const event = {
|
|
518
|
+
data: msgEvent.data,
|
|
519
|
+
origin: msgEvent.origin,
|
|
520
|
+
source: msgEvent.source
|
|
521
|
+
};
|
|
522
|
+
this.listeners.forEach((fn) => fn(event));
|
|
523
|
+
};
|
|
524
|
+
};
|
|
525
|
+
|
|
526
|
+
// ../preview-runtime/src/protocol.ts
|
|
527
|
+
var ProtocolError = class extends Error {
|
|
528
|
+
constructor(code, message) {
|
|
529
|
+
super(message);
|
|
530
|
+
this.code = code;
|
|
531
|
+
this.name = "ProtocolError";
|
|
532
|
+
}
|
|
533
|
+
code;
|
|
534
|
+
};
|
|
535
|
+
var forbidden = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
536
|
+
var record = (value) => !!value && typeof value === "object" && !Array.isArray(value) && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
|
|
537
|
+
var exactKeys = (value, allowed) => {
|
|
538
|
+
if (Object.keys(value).some((key) => !allowed.includes(key)))
|
|
539
|
+
throw new ProtocolError("INVALID", "Unexpected message field");
|
|
540
|
+
};
|
|
541
|
+
var string = (v) => typeof v === "string" && v.length > 0 && v.length <= 1024;
|
|
542
|
+
var revision = (v) => Number.isSafeInteger(v) && v >= 0;
|
|
543
|
+
function assertJson(value, depth = 0) {
|
|
544
|
+
if (depth > 64) throw new ProtocolError("LIMIT", "Configuration nesting exceeds limit");
|
|
545
|
+
if (value === null || typeof value === "boolean" || typeof value === "string" || typeof value === "number" && Number.isFinite(value))
|
|
546
|
+
return;
|
|
547
|
+
if (Array.isArray(value)) {
|
|
548
|
+
for (const child of value) assertJson(child, depth + 1);
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
if (record(value)) {
|
|
552
|
+
for (const [key, child] of Object.entries(value)) {
|
|
553
|
+
if (forbidden.has(key)) throw new ProtocolError("INVALID", "Unsafe configuration key");
|
|
554
|
+
assertJson(child, depth + 1);
|
|
555
|
+
}
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
throw new ProtocolError("INVALID", "Configuration must contain finite JSON data");
|
|
559
|
+
}
|
|
560
|
+
function clone(value) {
|
|
561
|
+
return structuredClone(value);
|
|
562
|
+
}
|
|
563
|
+
function freeze(value) {
|
|
564
|
+
if (value && typeof value === "object") {
|
|
565
|
+
Object.freeze(value);
|
|
566
|
+
for (const child of Object.values(value)) freeze(child);
|
|
567
|
+
}
|
|
568
|
+
return value;
|
|
569
|
+
}
|
|
570
|
+
function fingerprint(value) {
|
|
571
|
+
if (Array.isArray(value)) return "[" + value.map(fingerprint).join(",") + "]";
|
|
572
|
+
if (record(value))
|
|
573
|
+
return "{" + Object.keys(value).sort().map((k) => JSON.stringify(k) + ":" + fingerprint(value[k])).join(",") + "}";
|
|
574
|
+
return JSON.stringify(value);
|
|
575
|
+
}
|
|
576
|
+
function assertHello(value) {
|
|
577
|
+
if (!record(value) || value.protocolVersion !== 1 || !string(value.sessionId) || !revision(value.frameEpoch) || !string(value.schemaVersion) || !string(value.configContractVersion) || !string(value.locale) || !record(value.scope))
|
|
578
|
+
throw new ProtocolError("IDENTITY", "Invalid runtime session binding");
|
|
579
|
+
if (!["projectId", "branchName", "themeId"].every(
|
|
580
|
+
(k) => string(value.scope[k])
|
|
581
|
+
))
|
|
582
|
+
throw new ProtocolError("IDENTITY", "Invalid configuration scope");
|
|
583
|
+
exactKeys(value.scope, ["projectId", "branchName", "themeId"]);
|
|
584
|
+
}
|
|
585
|
+
function assertIdentity(value) {
|
|
586
|
+
assertHello(value);
|
|
587
|
+
if (!string(value.runtimeInstanceId))
|
|
588
|
+
throw new ProtocolError("IDENTITY", "Missing runtime instance");
|
|
589
|
+
}
|
|
590
|
+
function sameIdentity(a, b) {
|
|
591
|
+
try {
|
|
592
|
+
assertIdentity(b);
|
|
593
|
+
} catch {
|
|
594
|
+
return false;
|
|
595
|
+
}
|
|
596
|
+
return [
|
|
597
|
+
"protocolVersion",
|
|
598
|
+
"sessionId",
|
|
599
|
+
"frameEpoch",
|
|
600
|
+
"runtimeInstanceId",
|
|
601
|
+
"schemaVersion",
|
|
602
|
+
"configContractVersion",
|
|
603
|
+
"locale"
|
|
604
|
+
].every((k) => a[k] === b[k]) && fingerprint(a.scope) === fingerprint(b.scope);
|
|
605
|
+
}
|
|
606
|
+
function assertBinding(expected, actual) {
|
|
607
|
+
if (fingerprint(expected.scope) !== fingerprint(actual.scope) || expected.locale !== actual.locale || expected.schemaVersion !== actual.schemaVersion || expected.configContractVersion !== actual.configContractVersion)
|
|
608
|
+
throw new ProtocolError("CONTRACT", "Scope, locale, schema or configuration contract mismatch");
|
|
609
|
+
}
|
|
610
|
+
function assertDocuments(value) {
|
|
611
|
+
assertJson(value);
|
|
612
|
+
if (!record(value) || Object.values(value).some((v) => !record(v)))
|
|
613
|
+
throw new ProtocolError("INVALID", "Expected raw document objects");
|
|
614
|
+
}
|
|
615
|
+
var identityKeys = [
|
|
616
|
+
"protocolVersion",
|
|
617
|
+
"sessionId",
|
|
618
|
+
"frameEpoch",
|
|
619
|
+
"runtimeInstanceId",
|
|
620
|
+
"scope",
|
|
621
|
+
"schemaVersion",
|
|
622
|
+
"configContractVersion",
|
|
623
|
+
"locale"
|
|
624
|
+
];
|
|
625
|
+
function assertSnapshot(value) {
|
|
626
|
+
assertIdentity(value);
|
|
627
|
+
exactKeys(value, [
|
|
628
|
+
...identityKeys,
|
|
629
|
+
"draftRevision",
|
|
630
|
+
"documents"
|
|
631
|
+
]);
|
|
632
|
+
if (!revision(value.draftRevision))
|
|
633
|
+
throw new ProtocolError("INVALID", "Invalid snapshot revision");
|
|
634
|
+
assertDocuments(value.documents);
|
|
635
|
+
limit(value, 512 * 1024);
|
|
636
|
+
}
|
|
637
|
+
function assertPatch(value) {
|
|
638
|
+
assertIdentity(value);
|
|
639
|
+
const v = value;
|
|
640
|
+
exactKeys(v, [
|
|
641
|
+
...identityKeys,
|
|
642
|
+
"baseDraftRevision",
|
|
643
|
+
"draftRevision",
|
|
644
|
+
"phase",
|
|
645
|
+
"operations"
|
|
646
|
+
]);
|
|
647
|
+
if (!revision(v.baseDraftRevision) || !revision(v.draftRevision) || v.draftRevision !== v.baseDraftRevision + 1 || !["preview", "commit"].includes(v.phase) || !Array.isArray(v.operations) || v.operations.length > 256)
|
|
648
|
+
throw new ProtocolError("INVALID", "Invalid patch sequence or operation count");
|
|
649
|
+
for (const op of v.operations) {
|
|
650
|
+
if (!record(op) || !["set", "remove"].includes(op.op) || !string(op.documentId) || forbidden.has(op.documentId) || !Array.isArray(op.path) || !op.path.length || op.path.length > 32 || op.path.some((p) => !string(p) || forbidden.has(p)))
|
|
651
|
+
throw new ProtocolError("INVALID", "Unsafe or invalid operation path");
|
|
652
|
+
exactKeys(
|
|
653
|
+
op,
|
|
654
|
+
op.op === "set" ? ["op", "documentId", "path", "value"] : ["op", "documentId", "path"]
|
|
655
|
+
);
|
|
656
|
+
if (op.op === "set") assertJson(op.value);
|
|
657
|
+
}
|
|
658
|
+
limit(v, 64 * 1024);
|
|
659
|
+
}
|
|
660
|
+
function limit(value, bytes) {
|
|
661
|
+
if (new TextEncoder().encode(JSON.stringify(value)).length > bytes)
|
|
662
|
+
throw new ProtocolError("LIMIT", "Runtime message exceeds byte limit");
|
|
663
|
+
}
|
|
664
|
+
function applyOperations(documents, operations) {
|
|
665
|
+
const next = clone(documents);
|
|
666
|
+
for (const op of operations) {
|
|
667
|
+
if (op.op === "remove" && readPath(next[op.documentId], op.path) === void 0) continue;
|
|
668
|
+
let target = next[op.documentId] ??= {};
|
|
669
|
+
for (const part of op.path.slice(0, -1)) {
|
|
670
|
+
if (!record(target[part])) target[part] = {};
|
|
671
|
+
target = target[part];
|
|
672
|
+
}
|
|
673
|
+
const key = op.path[op.path.length - 1];
|
|
674
|
+
if (op.op === "set") target[key] = clone(op.value);
|
|
675
|
+
else delete target[key];
|
|
676
|
+
}
|
|
677
|
+
return next;
|
|
678
|
+
}
|
|
679
|
+
function readPath(value, path) {
|
|
680
|
+
for (const key of path) {
|
|
681
|
+
if (!record(value) && !Array.isArray(value)) return void 0;
|
|
682
|
+
value = value[key];
|
|
683
|
+
}
|
|
684
|
+
return value;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
// ../preview-runtime/src/runtime.ts
|
|
688
|
+
function createParameterRuntime(options) {
|
|
689
|
+
const runtimeInstanceId = crypto.randomUUID();
|
|
690
|
+
let identity;
|
|
691
|
+
let controller = new AbortController();
|
|
692
|
+
let queue = Promise.resolve();
|
|
693
|
+
let adapter;
|
|
694
|
+
let target;
|
|
695
|
+
let installed;
|
|
696
|
+
let receivedRevision = -1, installedRevision = -1, appliedRevision = -1;
|
|
697
|
+
let stage = "bootstrap-ready";
|
|
698
|
+
let status = "idle";
|
|
699
|
+
let error;
|
|
700
|
+
let disposed = false;
|
|
701
|
+
let cleanupFailure;
|
|
702
|
+
let resultSequence = 0;
|
|
703
|
+
const retiredSessions = /* @__PURE__ */ new Set();
|
|
704
|
+
const groups = /* @__PURE__ */ new Map();
|
|
705
|
+
const receipts = /* @__PURE__ */ new Map();
|
|
706
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
707
|
+
const capabilityListeners = /* @__PURE__ */ new Set();
|
|
708
|
+
async function release(game) {
|
|
709
|
+
try {
|
|
710
|
+
await game?.dispose();
|
|
711
|
+
} catch (e) {
|
|
712
|
+
cleanupFailure = e;
|
|
713
|
+
throw e;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
for (const field of options.fields)
|
|
717
|
+
groups.set(field.groupId, { groupId: field.groupId, appliedRevision: -1, status: "unknown" });
|
|
718
|
+
const capabilities = () => ({
|
|
719
|
+
...requireIdentity(),
|
|
720
|
+
stage,
|
|
721
|
+
canAcceptSnapshot: true,
|
|
722
|
+
fields: clone(options.fields)
|
|
723
|
+
});
|
|
724
|
+
function requireIdentity() {
|
|
725
|
+
if (!identity || disposed)
|
|
726
|
+
throw new ProtocolError("SESSION", "Runtime session is not connected");
|
|
727
|
+
return identity;
|
|
728
|
+
}
|
|
729
|
+
function check(value) {
|
|
730
|
+
assertIdentity(value);
|
|
731
|
+
if (!sameIdentity(requireIdentity(), value))
|
|
732
|
+
throw new ProtocolError("STALE", "Stale runtime identity");
|
|
733
|
+
}
|
|
734
|
+
const result = () => ({
|
|
735
|
+
...requireIdentity(),
|
|
736
|
+
resultSequence,
|
|
737
|
+
receivedRevision,
|
|
738
|
+
installedRevision,
|
|
739
|
+
appliedRevision,
|
|
740
|
+
status,
|
|
741
|
+
groups: clone([...groups.values()]),
|
|
742
|
+
...error ? { error } : {}
|
|
743
|
+
});
|
|
744
|
+
function publish() {
|
|
745
|
+
if (!identity || disposed) return;
|
|
746
|
+
resultSequence++;
|
|
747
|
+
const value = result();
|
|
748
|
+
listeners.forEach((fn) => fn(value));
|
|
749
|
+
}
|
|
750
|
+
function context(config, beforeConfig, draftRevision, fields, signal) {
|
|
751
|
+
return {
|
|
752
|
+
config,
|
|
753
|
+
beforeConfig,
|
|
754
|
+
draftRevision,
|
|
755
|
+
fields,
|
|
756
|
+
signal,
|
|
757
|
+
assertCurrent() {
|
|
758
|
+
signal.throwIfAborted();
|
|
759
|
+
if (signal !== controller.signal || disposed)
|
|
760
|
+
throw new ProtocolError("STALE", "Application task expired");
|
|
761
|
+
}
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
function enqueue(work) {
|
|
765
|
+
const signal = controller.signal;
|
|
766
|
+
queue = queue.then(async () => {
|
|
767
|
+
if (signal.aborted) return;
|
|
768
|
+
try {
|
|
769
|
+
await work(signal);
|
|
770
|
+
} catch (e) {
|
|
771
|
+
if (signal.aborted) return;
|
|
772
|
+
status = "error";
|
|
773
|
+
installedRevision = appliedRevision = -1;
|
|
774
|
+
error = e instanceof Error ? e.message : String(e);
|
|
775
|
+
for (const group of groups.values()) group.status = "unknown";
|
|
776
|
+
publish();
|
|
777
|
+
}
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
function remember(kind, request) {
|
|
781
|
+
const key = `${kind}:${request.draftRevision}`;
|
|
782
|
+
const previous = receipts.get(key);
|
|
783
|
+
if (previous) {
|
|
784
|
+
if (previous.fingerprint !== fingerprint(request))
|
|
785
|
+
throw new ProtocolError("CONFLICT", "Revision was already accepted with different content");
|
|
786
|
+
return previous.receipt;
|
|
787
|
+
}
|
|
788
|
+
return void 0;
|
|
789
|
+
}
|
|
790
|
+
function accept(kind, request) {
|
|
791
|
+
receivedRevision = request.draftRevision;
|
|
792
|
+
const receipt = { accepted: true, receivedRevision };
|
|
793
|
+
receipts.set(`${kind}:${receivedRevision}`, { fingerprint: fingerprint(request), receipt });
|
|
794
|
+
if (receipts.size > 256) receipts.delete(receipts.keys().next().value);
|
|
795
|
+
return receipt;
|
|
796
|
+
}
|
|
797
|
+
function updateState(rev, changed) {
|
|
798
|
+
for (const field of changed)
|
|
799
|
+
groups.set(field.groupId, {
|
|
800
|
+
groupId: field.groupId,
|
|
801
|
+
appliedRevision: rev,
|
|
802
|
+
status: "applied"
|
|
803
|
+
});
|
|
804
|
+
let pending = false, reload = false;
|
|
805
|
+
for (const field of options.fields) {
|
|
806
|
+
if (fingerprint(readPath(installed?.[field.documentId], field.path)) !== fingerprint(readPath(target?.[field.documentId], field.path))) {
|
|
807
|
+
const group = groups.get(field.groupId);
|
|
808
|
+
group.status = field.mode === "reload" ? "requires-reload" : "pending-commit";
|
|
809
|
+
pending = true;
|
|
810
|
+
reload ||= field.mode === "reload";
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
if (fingerprint(installed) === fingerprint(target)) {
|
|
814
|
+
appliedRevision = receivedRevision;
|
|
815
|
+
installedRevision = receivedRevision;
|
|
816
|
+
status = "applied";
|
|
817
|
+
} else status = reload ? "requires-reload" : pending ? "pending-commit" : "applying";
|
|
818
|
+
publish();
|
|
819
|
+
}
|
|
820
|
+
async function applyTarget(documents, rev, commit, signal) {
|
|
821
|
+
if (status === "error") return;
|
|
822
|
+
if (!adapter || !installed)
|
|
823
|
+
throw new ProtocolError("STATE", "Initial snapshot must create the game first");
|
|
824
|
+
const operations = [];
|
|
825
|
+
for (const field of options.fields) {
|
|
826
|
+
if (field.mode !== "live" && !(commit && field.mode === "restart-scene")) continue;
|
|
827
|
+
const value = readPath(documents[field.documentId], field.path);
|
|
828
|
+
operations.push(
|
|
829
|
+
value === void 0 ? { op: "remove", documentId: field.documentId, path: field.path } : {
|
|
830
|
+
op: "set",
|
|
831
|
+
documentId: field.documentId,
|
|
832
|
+
path: field.path,
|
|
833
|
+
value: clone(value)
|
|
834
|
+
}
|
|
835
|
+
);
|
|
836
|
+
}
|
|
837
|
+
const candidate = applyOperations(installed, operations);
|
|
838
|
+
const before = options.source.get();
|
|
839
|
+
const config = freeze(options.resolve(freeze(clone(candidate))));
|
|
840
|
+
const changed = options.fields.filter(
|
|
841
|
+
(field) => fingerprint(readPath(before, field.effectivePath)) !== fingerprint(readPath(config, field.effectivePath))
|
|
842
|
+
);
|
|
843
|
+
const ctx = context(config, before, rev, changed, signal);
|
|
844
|
+
ctx.assertCurrent();
|
|
845
|
+
status = "applying";
|
|
846
|
+
publish();
|
|
847
|
+
options.source.install(config);
|
|
848
|
+
installedRevision = fingerprint(candidate) === fingerprint(documents) ? rev : -1;
|
|
849
|
+
try {
|
|
850
|
+
if (changed.some((field) => field.mode === "restart-scene")) await adapter.restartScene(ctx);
|
|
851
|
+
else if (changed.length) await adapter.apply(ctx);
|
|
852
|
+
ctx.assertCurrent();
|
|
853
|
+
await adapter.afterRender(ctx);
|
|
854
|
+
ctx.assertCurrent();
|
|
855
|
+
installed = candidate;
|
|
856
|
+
updateState(rev, changed);
|
|
857
|
+
} catch (e) {
|
|
858
|
+
if (!signal.aborted) options.source.install(before);
|
|
859
|
+
throw e;
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
return {
|
|
863
|
+
hello(value) {
|
|
864
|
+
assertHello(value);
|
|
865
|
+
assertBinding(options.binding, value);
|
|
866
|
+
if (disposed) throw new ProtocolError("DISPOSED", "Runtime endpoint is disposed");
|
|
867
|
+
if (retiredSessions.has(value.sessionId))
|
|
868
|
+
throw new ProtocolError("STALE", "Retired runtime session");
|
|
869
|
+
if (identity && value.sessionId === identity.sessionId && value.frameEpoch < identity.frameEpoch)
|
|
870
|
+
throw new ProtocolError("STALE", "Old frame epoch");
|
|
871
|
+
if (identity && fingerprint({ ...identity, runtimeInstanceId: void 0 }) === fingerprint({ ...value, runtimeInstanceId: void 0 }))
|
|
872
|
+
return capabilities();
|
|
873
|
+
if (identity && identity.sessionId !== value.sessionId)
|
|
874
|
+
retiredSessions.add(identity.sessionId);
|
|
875
|
+
controller.abort();
|
|
876
|
+
controller = new AbortController();
|
|
877
|
+
const previous = adapter;
|
|
878
|
+
adapter = void 0;
|
|
879
|
+
queue = queue.then(async () => {
|
|
880
|
+
await release(previous);
|
|
881
|
+
}).catch((e) => {
|
|
882
|
+
cleanupFailure = e;
|
|
883
|
+
});
|
|
884
|
+
identity = freeze({ ...clone(value), runtimeInstanceId });
|
|
885
|
+
target = installed = void 0;
|
|
886
|
+
receivedRevision = installedRevision = appliedRevision = -1;
|
|
887
|
+
receipts.clear();
|
|
888
|
+
stage = "bootstrap-ready";
|
|
889
|
+
status = "idle";
|
|
890
|
+
error = void 0;
|
|
891
|
+
resultSequence = 0;
|
|
892
|
+
for (const group of groups.values()) {
|
|
893
|
+
group.appliedRevision = -1;
|
|
894
|
+
group.status = "unknown";
|
|
895
|
+
}
|
|
896
|
+
return capabilities();
|
|
897
|
+
},
|
|
898
|
+
snapshot(value) {
|
|
899
|
+
assertSnapshot(value);
|
|
900
|
+
check(value);
|
|
901
|
+
const previous = remember("snapshot", value);
|
|
902
|
+
if (previous) return previous;
|
|
903
|
+
if (value.draftRevision < receivedRevision)
|
|
904
|
+
throw new ProtocolError("STALE", "Old snapshot revision");
|
|
905
|
+
if (value.draftRevision === receivedRevision && fingerprint(value.documents) !== fingerprint(target))
|
|
906
|
+
throw new ProtocolError("CONFLICT", "Snapshot cannot change an already accepted revision");
|
|
907
|
+
const rev = value.draftRevision;
|
|
908
|
+
const documents = freeze(clone(value.documents));
|
|
909
|
+
options.resolve(documents);
|
|
910
|
+
target = documents;
|
|
911
|
+
const receipt = accept("snapshot", value);
|
|
912
|
+
enqueue(async (signal) => {
|
|
913
|
+
if (cleanupFailure)
|
|
914
|
+
throw new ProtocolError(
|
|
915
|
+
"RECOVERY",
|
|
916
|
+
"Previous game cleanup failed; reload the preview frame"
|
|
917
|
+
);
|
|
918
|
+
const before = options.source.get();
|
|
919
|
+
const config = freeze(options.resolve(documents));
|
|
920
|
+
const ctx = context(config, before, rev, clone(options.fields), signal);
|
|
921
|
+
ctx.assertCurrent();
|
|
922
|
+
status = "applying";
|
|
923
|
+
publish();
|
|
924
|
+
const previousAdapter = adapter;
|
|
925
|
+
adapter = void 0;
|
|
926
|
+
stage = "bootstrap-ready";
|
|
927
|
+
await release(previousAdapter);
|
|
928
|
+
ctx.assertCurrent();
|
|
929
|
+
options.source.install(config);
|
|
930
|
+
installedRevision = rev;
|
|
931
|
+
let created;
|
|
932
|
+
try {
|
|
933
|
+
created = await options.createGame(ctx);
|
|
934
|
+
if (signal.aborted) {
|
|
935
|
+
await release(created);
|
|
936
|
+
return;
|
|
937
|
+
}
|
|
938
|
+
ctx.assertCurrent();
|
|
939
|
+
adapter = created;
|
|
940
|
+
stage = "game-ready";
|
|
941
|
+
capabilityListeners.forEach((fn) => fn(capabilities()));
|
|
942
|
+
await created.afterRender(ctx);
|
|
943
|
+
ctx.assertCurrent();
|
|
944
|
+
installed = clone(documents);
|
|
945
|
+
error = void 0;
|
|
946
|
+
updateState(rev, options.fields);
|
|
947
|
+
} catch (e) {
|
|
948
|
+
if (!signal.aborted) {
|
|
949
|
+
adapter = void 0;
|
|
950
|
+
stage = "bootstrap-ready";
|
|
951
|
+
options.source.install(before);
|
|
952
|
+
capabilityListeners.forEach((fn) => fn(capabilities()));
|
|
953
|
+
}
|
|
954
|
+
await release(created);
|
|
955
|
+
throw e;
|
|
956
|
+
}
|
|
957
|
+
});
|
|
958
|
+
return receipt;
|
|
959
|
+
},
|
|
960
|
+
patch(value) {
|
|
961
|
+
assertPatch(value);
|
|
962
|
+
check(value);
|
|
963
|
+
const previous = remember("patch", value);
|
|
964
|
+
if (previous) return previous;
|
|
965
|
+
if (!target || value.baseDraftRevision !== receivedRevision)
|
|
966
|
+
throw new ProtocolError("RESYNC", "Patch base does not match received revision");
|
|
967
|
+
if (status === "error")
|
|
968
|
+
throw new ProtocolError(
|
|
969
|
+
"RECOVERY",
|
|
970
|
+
"Application state is unknown; send a recovery snapshot"
|
|
971
|
+
);
|
|
972
|
+
for (const op of value.operations)
|
|
973
|
+
if (!options.fields.some(
|
|
974
|
+
(field) => field.documentId === op.documentId && fingerprint(field.path) === fingerprint(op.path)
|
|
975
|
+
))
|
|
976
|
+
throw new ProtocolError("UNSUPPORTED", "Unregistered parameter path");
|
|
977
|
+
const documents = freeze(applyOperations(target, value.operations));
|
|
978
|
+
const rev = value.draftRevision, commit = value.phase === "commit";
|
|
979
|
+
options.resolve(documents);
|
|
980
|
+
target = documents;
|
|
981
|
+
const receipt = accept("patch", value);
|
|
982
|
+
enqueue((signal) => applyTarget(documents, rev, commit, signal));
|
|
983
|
+
return receipt;
|
|
984
|
+
},
|
|
985
|
+
restart(value) {
|
|
986
|
+
check(value);
|
|
987
|
+
if (status === "error")
|
|
988
|
+
throw new ProtocolError(
|
|
989
|
+
"RECOVERY",
|
|
990
|
+
"Application state is unknown; send a recovery snapshot"
|
|
991
|
+
);
|
|
992
|
+
const rev = value.draftRevision;
|
|
993
|
+
if (rev !== receivedRevision || !target)
|
|
994
|
+
throw new ProtocolError("STALE", "Restart must name the current target");
|
|
995
|
+
const documents = clone(target);
|
|
996
|
+
enqueue((signal) => applyTarget(documents, rev, true, signal));
|
|
997
|
+
return { accepted: true, receivedRevision };
|
|
998
|
+
},
|
|
999
|
+
status(value) {
|
|
1000
|
+
check(value);
|
|
1001
|
+
return result();
|
|
1002
|
+
},
|
|
1003
|
+
subscribe(fn) {
|
|
1004
|
+
listeners.add(fn);
|
|
1005
|
+
return () => listeners.delete(fn);
|
|
1006
|
+
},
|
|
1007
|
+
onCapabilities(fn) {
|
|
1008
|
+
capabilityListeners.add(fn);
|
|
1009
|
+
return () => capabilityListeners.delete(fn);
|
|
1010
|
+
},
|
|
1011
|
+
async settled() {
|
|
1012
|
+
await queue;
|
|
1013
|
+
},
|
|
1014
|
+
async dispose() {
|
|
1015
|
+
if (disposed) return;
|
|
1016
|
+
disposed = true;
|
|
1017
|
+
controller.abort();
|
|
1018
|
+
listeners.clear();
|
|
1019
|
+
capabilityListeners.clear();
|
|
1020
|
+
await queue;
|
|
1021
|
+
await adapter?.dispose();
|
|
1022
|
+
adapter = void 0;
|
|
1023
|
+
}
|
|
1024
|
+
};
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
// ../preview-runtime/src/preview.ts
|
|
1028
|
+
function readWorkspacePreviewContext(expectedContractVersion) {
|
|
1029
|
+
try {
|
|
1030
|
+
const mark = "playcraft-preview-storage:";
|
|
1031
|
+
if (!window.name.startsWith(mark)) throw new Error("Missing workspace context");
|
|
1032
|
+
const context = JSON.parse(window.name.slice(mark.length)).__playcraft_preview_context__;
|
|
1033
|
+
if (!context || typeof context.parentOrigin !== "string" || !context.binding)
|
|
1034
|
+
throw new Error("Missing workspace binding");
|
|
1035
|
+
const parent = new URL(context.parentOrigin);
|
|
1036
|
+
if (!["http:", "https:"].includes(parent.protocol) || parent.origin !== context.parentOrigin || parent.origin === "null")
|
|
1037
|
+
throw new Error("Invalid parent origin");
|
|
1038
|
+
const hello = {
|
|
1039
|
+
...context.binding,
|
|
1040
|
+
protocolVersion: 1,
|
|
1041
|
+
sessionId: "workspace-context",
|
|
1042
|
+
frameEpoch: 0
|
|
1043
|
+
};
|
|
1044
|
+
assertHello(hello);
|
|
1045
|
+
if (context.binding.configContractVersion !== expectedContractVersion)
|
|
1046
|
+
throw new Error("Unexpected configuration contract");
|
|
1047
|
+
const profiles = document.querySelectorAll("script#playcraft-runtime-profile");
|
|
1048
|
+
if (profiles.length !== 1 || profiles[0].getAttribute("type") !== "application/json")
|
|
1049
|
+
throw new Error("Missing build profile");
|
|
1050
|
+
const profile = JSON.parse(profiles[0].textContent ?? "");
|
|
1051
|
+
if (profile.version !== 1 || profile.protocolVersion !== 1 || profile.target !== "editor-static")
|
|
1052
|
+
throw new Error("Invalid build profile");
|
|
1053
|
+
assertBinding(profile.binding, hello);
|
|
1054
|
+
return freeze(
|
|
1055
|
+
clone({ binding: context.binding, parentOrigin: parent.origin })
|
|
1056
|
+
);
|
|
1057
|
+
} catch (error) {
|
|
1058
|
+
throw new ProtocolError(
|
|
1059
|
+
"CONTEXT",
|
|
1060
|
+
error instanceof Error ? error.message : "Invalid workspace preview context"
|
|
1061
|
+
);
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
function connectPreviewRuntime(options) {
|
|
1065
|
+
const origin = new URL(options.parentOrigin).origin;
|
|
1066
|
+
if (origin === "null" || options.parentOrigin !== origin)
|
|
1067
|
+
throw new ProtocolError("ORIGIN", "An exact parent origin is required");
|
|
1068
|
+
const runtime = createParameterRuntime(options);
|
|
1069
|
+
const bridge = new Bridge({
|
|
1070
|
+
peer: () => window.parent,
|
|
1071
|
+
targetOrigin: origin,
|
|
1072
|
+
allowedOrigins: [origin],
|
|
1073
|
+
strictSource: true
|
|
1074
|
+
});
|
|
1075
|
+
const names = BridgeMethods.runtimeParameters;
|
|
1076
|
+
const off = [
|
|
1077
|
+
bridge.on(names.hello, (value) => runtime.hello(value)),
|
|
1078
|
+
bridge.on(names.snapshot, (value) => runtime.snapshot(value)),
|
|
1079
|
+
bridge.on(names.patch, (value) => {
|
|
1080
|
+
try {
|
|
1081
|
+
return runtime.patch(value);
|
|
1082
|
+
} catch (error) {
|
|
1083
|
+
if (error instanceof ProtocolError && error.code === "RESYNC")
|
|
1084
|
+
void bridge.emit(
|
|
1085
|
+
names.resyncRequired,
|
|
1086
|
+
{ ...runtime.status(value), reason: error.message },
|
|
1087
|
+
{ timeout: 1e3 }
|
|
1088
|
+
).catch(() => {
|
|
1089
|
+
});
|
|
1090
|
+
throw error;
|
|
1091
|
+
}
|
|
1092
|
+
}),
|
|
1093
|
+
bridge.on(names.restart, (value) => runtime.restart(value)),
|
|
1094
|
+
bridge.on(names.status, (value) => runtime.status(value)),
|
|
1095
|
+
bridge.on(names.dispose, async (value) => {
|
|
1096
|
+
runtime.status(value);
|
|
1097
|
+
await runtime.dispose();
|
|
1098
|
+
return { disposed: true };
|
|
1099
|
+
}),
|
|
1100
|
+
runtime.subscribe((value) => {
|
|
1101
|
+
void bridge.emit(names.result, value, { timeout: 1e3 }).catch(() => {
|
|
1102
|
+
});
|
|
1103
|
+
}),
|
|
1104
|
+
runtime.onCapabilities((value) => {
|
|
1105
|
+
void bridge.emit(names.capabilities, value, { timeout: 1e3 }).catch(() => {
|
|
1106
|
+
});
|
|
1107
|
+
})
|
|
1108
|
+
];
|
|
1109
|
+
return {
|
|
1110
|
+
runtime,
|
|
1111
|
+
async dispose() {
|
|
1112
|
+
off.forEach((fn) => fn());
|
|
1113
|
+
bridge.destroy();
|
|
1114
|
+
await runtime.dispose();
|
|
1115
|
+
}
|
|
1116
|
+
};
|
|
1117
|
+
}
|
|
1118
|
+
export {
|
|
1119
|
+
connectPreviewRuntime,
|
|
1120
|
+
readWorkspacePreviewContext
|
|
1121
|
+
};
|