@fps-games/editor 0.2.1-beta.3 → 0.2.1-beta.4
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/dist/build-info.json +44 -44
- package/dist/editor-commands/capabilities/assets.d.ts +8 -0
- package/dist/editor-commands/capabilities/assets.d.ts.map +1 -0
- package/dist/{agent-bridge → editor-commands}/capabilities/assets.js +41 -41
- package/dist/editor-commands/capabilities/assets.js.map +1 -0
- package/dist/editor-commands/capabilities/editor-state.d.ts +5 -0
- package/dist/editor-commands/capabilities/editor-state.d.ts.map +1 -0
- package/dist/{agent-bridge → editor-commands}/capabilities/editor-state.js +22 -22
- package/dist/editor-commands/capabilities/editor-state.js.map +1 -0
- package/dist/editor-commands/capabilities/hierarchy.d.ts +4 -0
- package/dist/editor-commands/capabilities/hierarchy.d.ts.map +1 -0
- package/dist/{agent-bridge → editor-commands}/capabilities/hierarchy.js +5 -5
- package/dist/editor-commands/capabilities/hierarchy.js.map +1 -0
- package/dist/editor-commands/capabilities/host-lifecycle.d.ts +11 -0
- package/dist/editor-commands/capabilities/host-lifecycle.d.ts.map +1 -0
- package/dist/editor-commands/capabilities/host-lifecycle.js +149 -0
- package/dist/editor-commands/capabilities/host-lifecycle.js.map +1 -0
- package/dist/editor-commands/capabilities/prefabs.d.ts +5 -0
- package/dist/editor-commands/capabilities/prefabs.d.ts.map +1 -0
- package/dist/{agent-bridge → editor-commands}/capabilities/prefabs.js +93 -93
- package/dist/editor-commands/capabilities/prefabs.js.map +1 -0
- package/dist/editor-commands/capabilities/scene-objects.d.ts +8 -0
- package/dist/editor-commands/capabilities/scene-objects.d.ts.map +1 -0
- package/dist/editor-commands/capabilities/scene-objects.js +480 -0
- package/dist/editor-commands/capabilities/scene-objects.js.map +1 -0
- package/dist/editor-commands/capabilities/selection.d.ts +5 -0
- package/dist/editor-commands/capabilities/selection.d.ts.map +1 -0
- package/dist/editor-commands/capabilities/selection.js +60 -0
- package/dist/editor-commands/capabilities/selection.js.map +1 -0
- package/dist/editor-commands/capabilities/shadows.d.ts +5 -0
- package/dist/editor-commands/capabilities/shadows.d.ts.map +1 -0
- package/dist/{agent-bridge → editor-commands}/capabilities/shadows.js +74 -74
- package/dist/editor-commands/capabilities/shadows.js.map +1 -0
- package/dist/editor-commands/capabilities/transform.d.ts +5 -0
- package/dist/editor-commands/capabilities/transform.d.ts.map +1 -0
- package/dist/editor-commands/capabilities/transform.js +164 -0
- package/dist/editor-commands/capabilities/transform.js.map +1 -0
- package/dist/editor-commands/capabilities/ui-regions.d.ts +4 -0
- package/dist/editor-commands/capabilities/ui-regions.d.ts.map +1 -0
- package/dist/{agent-bridge → editor-commands}/capabilities/ui-regions.js +55 -57
- package/dist/editor-commands/capabilities/ui-regions.js.map +1 -0
- package/dist/editor-commands/capabilities/viewport.d.ts +5 -0
- package/dist/editor-commands/capabilities/viewport.d.ts.map +1 -0
- package/dist/{agent-bridge → editor-commands}/capabilities/viewport.js +100 -100
- package/dist/editor-commands/capabilities/viewport.js.map +1 -0
- package/dist/editor-commands/command-sources.d.ts +7 -0
- package/dist/editor-commands/command-sources.d.ts.map +1 -0
- package/dist/editor-commands/command-sources.js +34 -0
- package/dist/editor-commands/command-sources.js.map +1 -0
- package/dist/editor-commands/diagnostics.d.ts +12 -0
- package/dist/editor-commands/diagnostics.d.ts.map +1 -0
- package/dist/{agent-bridge → editor-commands}/diagnostics.js +4 -4
- package/dist/editor-commands/diagnostics.js.map +1 -0
- package/dist/{agent-bridge → editor-commands}/index.d.ts +1 -1
- package/dist/editor-commands/index.d.ts.map +1 -0
- package/dist/{agent-bridge → editor-commands}/index.js +1 -1
- package/dist/editor-commands/index.js.map +1 -0
- package/dist/editor-commands/register.d.ts +4 -0
- package/dist/editor-commands/register.d.ts.map +1 -0
- package/dist/{agent-bridge → editor-commands}/register.js +323 -286
- package/dist/editor-commands/register.js.map +1 -0
- package/dist/{agent-bridge → editor-commands}/shared.d.ts +80 -80
- package/dist/editor-commands/shared.d.ts.map +1 -0
- package/dist/{agent-bridge → editor-commands}/shared.js +29 -29
- package/dist/editor-commands/shared.js.map +1 -0
- package/dist/editor-commands/source-types.d.ts +110 -0
- package/dist/editor-commands/source-types.d.ts.map +1 -0
- package/dist/editor-commands/source-types.js.map +1 -0
- package/dist/editor-plugin-commands.d.ts +4 -0
- package/dist/editor-plugin-commands.d.ts.map +1 -0
- package/dist/editor-plugin-commands.js +18 -0
- package/dist/editor-plugin-commands.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/local-editor-commands.d.ts +2 -0
- package/dist/local-editor-commands.d.ts.map +1 -0
- package/dist/local-editor-commands.js +2 -0
- package/dist/local-editor-commands.js.map +1 -0
- package/dist/local-editor-harness.d.ts +35 -21
- package/dist/local-editor-harness.d.ts.map +1 -1
- package/dist/local-editor-harness.js +1721 -367
- package/dist/local-editor-harness.js.map +1 -1
- package/dist/local-editor-prefab-stage-transaction.d.ts +2 -1
- package/dist/local-editor-prefab-stage-transaction.d.ts.map +1 -1
- package/dist/local-editor-prefab-stage-transaction.js +6 -5
- package/dist/local-editor-prefab-stage-transaction.js.map +1 -1
- package/dist/local-editor-scene-view-interaction-runtime.d.ts.map +1 -1
- package/dist/local-editor-scene-view-interaction-runtime.js +2 -5
- package/dist/local-editor-scene-view-interaction-runtime.js.map +1 -1
- package/dist/playable-local-editor-entry.d.ts +10 -0
- package/dist/playable-local-editor-entry.d.ts.map +1 -1
- package/dist/playable-local-editor-entry.js +10 -2
- package/dist/playable-local-editor-entry.js.map +1 -1
- package/dist/playable-local-editor-host.d.ts +3 -32
- package/dist/playable-local-editor-host.d.ts.map +1 -1
- package/dist/playable-local-editor-host.js +6 -70
- package/dist/playable-local-editor-host.js.map +1 -1
- package/dist/playable-product-local-editor.d.ts +1 -2
- package/dist/playable-product-local-editor.d.ts.map +1 -1
- package/dist/playable-product-local-editor.js +0 -1
- package/dist/playable-product-local-editor.js.map +1 -1
- package/dist/playable-product-projection-preview.d.ts.map +1 -1
- package/dist/playable-product-projection-preview.js +1 -1
- package/dist/playable-product-projection-preview.js.map +1 -1
- package/dist/playable-product-scene-capabilities.d.ts +0 -2
- package/dist/playable-product-scene-capabilities.d.ts.map +1 -1
- package/dist/playable-product-scene-capabilities.js +33 -6
- package/dist/playable-product-scene-capabilities.js.map +1 -1
- package/dist/playable-runtime-babylon.d.ts +4 -0
- package/dist/playable-runtime-babylon.d.ts.map +1 -1
- package/dist/playable-runtime-babylon.js +4 -0
- package/dist/playable-runtime-babylon.js.map +1 -1
- package/dist/playable-sdk.d.ts +1 -1
- package/dist/playable-sdk.d.ts.map +1 -1
- package/dist/playable-sdk.js.map +1 -1
- package/dist/playable-standard-project.d.ts +0 -2
- package/dist/playable-standard-project.d.ts.map +1 -1
- package/dist/playable-standard-project.js +1 -2
- package/dist/playable-standard-project.js.map +1 -1
- package/dist/project-service-projection.d.ts +16 -0
- package/dist/project-service-projection.d.ts.map +1 -0
- package/dist/project-service-projection.js +67 -0
- package/dist/project-service-projection.js.map +1 -0
- package/node_modules/@fps-games/babylon-renderer/dist/post-process/babylon-default-pipeline.d.ts +18 -0
- package/node_modules/@fps-games/babylon-renderer/dist/post-process/babylon-default-pipeline.d.ts.map +1 -1
- package/node_modules/@fps-games/babylon-renderer/dist/post-process/babylon-default-pipeline.js +54 -18
- package/node_modules/@fps-games/babylon-renderer/dist/post-process/babylon-default-pipeline.js.map +1 -1
- package/node_modules/@fps-games/babylon-renderer/package.json +9 -9
- package/node_modules/@fps-games/editor-babylon/dist/projection.d.ts +1 -0
- package/node_modules/@fps-games/editor-babylon/dist/projection.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/projection.js +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/projection.js.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/selection-presentation-controller.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/selection-presentation-controller.js +127 -13
- package/node_modules/@fps-games/editor-babylon/dist/selection-presentation-controller.js.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/transform-gizmo-controller.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/transform-gizmo-controller.js +66 -1
- package/node_modules/@fps-games/editor-babylon/dist/transform-gizmo-controller.js.map +1 -1
- package/node_modules/@fps-games/editor-babylon/package.json +6 -6
- package/node_modules/@fps-games/editor-browser/dist/editor-command-service-client.d.ts +32 -0
- package/node_modules/@fps-games/editor-browser/dist/editor-command-service-client.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-browser/dist/editor-command-service-client.js +254 -0
- package/node_modules/@fps-games/editor-browser/dist/editor-command-service-client.js.map +1 -0
- package/node_modules/@fps-games/editor-browser/dist/index.d.ts +3 -1
- package/node_modules/@fps-games/editor-browser/dist/index.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/index.js +2 -0
- package/node_modules/@fps-games/editor-browser/dist/index.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-command-center.d.ts +68 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-command-center.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-command-center.js +650 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-command-center.js.map +1 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-formal-surface-visibility.d.ts +1 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-formal-surface-visibility.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-formal-surface-visibility.js +22 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-formal-surface-visibility.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-controller.d.ts +8 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-controller.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-controller.js +117 -6
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-controller.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-view.d.ts +14 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-view.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-view.js +100 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-view.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-panels.d.ts +8 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-panels.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-panels.js +75 -2
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-panels.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-types.d.ts +37 -12
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-types.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-types.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui.d.ts +25 -2
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui.js +332 -107
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/package.json +7 -7
- package/node_modules/@fps-games/editor-core/dist/editor-authoring-host.d.ts +107 -0
- package/node_modules/@fps-games/editor-core/dist/editor-authoring-host.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-core/dist/editor-authoring-host.js +1211 -0
- package/node_modules/@fps-games/editor-core/dist/editor-authoring-host.js.map +1 -0
- package/node_modules/@fps-games/editor-core/dist/editor-command-capability-adapter.d.ts +34 -0
- package/node_modules/@fps-games/editor-core/dist/editor-command-capability-adapter.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-core/dist/editor-command-capability-adapter.js +260 -0
- package/node_modules/@fps-games/editor-core/dist/editor-command-capability-adapter.js.map +1 -0
- package/node_modules/@fps-games/editor-core/dist/editor-command-composed-authority.d.ts +9 -0
- package/node_modules/@fps-games/editor-core/dist/editor-command-composed-authority.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-core/dist/editor-command-composed-authority.js +14 -0
- package/node_modules/@fps-games/editor-core/dist/editor-command-composed-authority.js.map +1 -0
- package/node_modules/@fps-games/editor-core/dist/editor-command-observability.d.ts +18 -0
- package/node_modules/@fps-games/editor-core/dist/editor-command-observability.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-core/dist/editor-command-observability.js +113 -0
- package/node_modules/@fps-games/editor-core/dist/editor-command-observability.js.map +1 -0
- package/node_modules/@fps-games/editor-core/dist/editor-command-system.d.ts +82 -0
- package/node_modules/@fps-games/editor-core/dist/editor-command-system.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-core/dist/editor-command-system.js +1098 -0
- package/node_modules/@fps-games/editor-core/dist/editor-command-system.js.map +1 -0
- package/node_modules/@fps-games/editor-core/dist/editor-plugin-host.d.ts +6 -7
- package/node_modules/@fps-games/editor-core/dist/editor-plugin-host.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-core/dist/editor-plugin-host.js +62 -103
- package/node_modules/@fps-games/editor-core/dist/editor-plugin-host.js.map +1 -1
- package/node_modules/@fps-games/editor-core/dist/editor-service-gateway.d.ts +30 -0
- package/node_modules/@fps-games/editor-core/dist/editor-service-gateway.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-core/dist/editor-service-gateway.js +540 -0
- package/node_modules/@fps-games/editor-core/dist/editor-service-gateway.js.map +1 -0
- package/node_modules/@fps-games/editor-core/dist/editor-session-authority.d.ts +9 -0
- package/node_modules/@fps-games/editor-core/dist/editor-session-authority.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-core/dist/editor-session-authority.js +61 -0
- package/node_modules/@fps-games/editor-core/dist/editor-session-authority.js.map +1 -0
- package/node_modules/@fps-games/editor-core/dist/editor-session.d.ts +55 -0
- package/node_modules/@fps-games/editor-core/dist/editor-session.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-core/dist/editor-session.js +247 -6
- package/node_modules/@fps-games/editor-core/dist/editor-session.js.map +1 -1
- package/node_modules/@fps-games/editor-core/dist/index.d.ts +6 -2
- package/node_modules/@fps-games/editor-core/dist/index.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-core/dist/index.js +6 -2
- package/node_modules/@fps-games/editor-core/dist/index.js.map +1 -1
- package/node_modules/@fps-games/editor-core/package.json +6 -6
- package/node_modules/@fps-games/editor-forge-play/dist/index.d.ts +0 -1
- package/node_modules/@fps-games/editor-forge-play/dist/index.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-forge-play/dist/index.js +0 -1
- package/node_modules/@fps-games/editor-forge-play/dist/index.js.map +1 -1
- package/node_modules/@fps-games/editor-forge-play/package.json +2 -2
- package/node_modules/@fps-games/editor-playable-sdk/dist/bridge-command/protocol.d.ts +2 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/bridge-command/protocol.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/document/helpers.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/document/helpers.js +41 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/document/helpers.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/local-harness/forge-play-types.d.ts +27 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/local-harness/forge-play-types.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/local-harness/forge-play-types.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/local-harness/forge-play.d.ts +2 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/local-harness/forge-play.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/local-harness/forge-play.js +214 -7
- package/node_modules/@fps-games/editor-playable-sdk/dist/local-harness/forge-play.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/local-harness/host-controller.d.ts +1 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/local-harness/host-controller.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/local-harness/host-controller.js +11 -3
- package/node_modules/@fps-games/editor-playable-sdk/dist/local-harness/host-controller.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/local-harness/index.d.ts +2 -4
- package/node_modules/@fps-games/editor-playable-sdk/dist/local-harness/index.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/local-harness/index.js +0 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/local-harness/index.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/local-harness/lifecycle.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/local-harness/lifecycle.js +77 -31
- package/node_modules/@fps-games/editor-playable-sdk/dist/local-harness/lifecycle.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/local-harness/types.d.ts +8 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/local-harness/types.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/local-harness/types.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/material-binding/asset-fields.d.ts +21 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/material-binding/asset-fields.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/material-binding/asset-fields.js +90 -4
- package/node_modules/@fps-games/editor-playable-sdk/dist/material-binding/asset-fields.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/material-binding/binding.d.ts +27 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/material-binding/binding.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/material-binding/binding.js +161 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/material-binding/binding.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/material-binding/inspector.d.ts +2 -2
- package/node_modules/@fps-games/editor-playable-sdk/dist/material-binding/inspector.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/material-binding/inspector.js +5 -92
- package/node_modules/@fps-games/editor-playable-sdk/dist/material-binding/inspector.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/material-binding/scene-inspector.d.ts +7 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/material-binding/scene-inspector.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/material-binding/scene-inspector.js +26 -9
- package/node_modules/@fps-games/editor-playable-sdk/dist/material-binding/scene-inspector.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/material-binding/slot-inspector.d.ts +9 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/material-binding/slot-inspector.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/material-binding/slot-inspector.js +19 -8
- package/node_modules/@fps-games/editor-playable-sdk/dist/material-binding/slot-inspector.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/prefab-stage/material-override-inspector.d.ts +5 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/prefab-stage/material-override-inspector.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/prefab-stage/material-override-inspector.js +16 -4
- package/node_modules/@fps-games/editor-playable-sdk/dist/prefab-stage/material-override-inspector.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/prefab-stage/stage-inspector.d.ts +9 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/prefab-stage/stage-inspector.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/prefab-stage/stage-inspector.js +12 -2
- package/node_modules/@fps-games/editor-playable-sdk/dist/prefab-stage/stage-inspector.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/product/ground-decal.d.ts +2 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/product/ground-decal.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/product/ground-decal.js +10 -5
- package/node_modules/@fps-games/editor-playable-sdk/dist/product/ground-decal.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/product/index.d.ts +1 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/product/index.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/product/index.js +1 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/product/index.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/product/project-host-services.d.ts +17 -82
- package/node_modules/@fps-games/editor-playable-sdk/dist/product/project-host-services.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/product/project-host-services.js +53 -57
- package/node_modules/@fps-games/editor-playable-sdk/dist/product/project-host-services.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/product/scene-session.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/product/scene-session.js +3 -2
- package/node_modules/@fps-games/editor-playable-sdk/dist/product/scene-session.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/product/standard-authoring-commands.d.ts +10 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/product/standard-authoring-commands.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/product/standard-authoring-commands.js +256 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/product/standard-authoring-commands.js.map +1 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/product/standard-scene-assembly.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/product/standard-scene-assembly.js +7 -5
- package/node_modules/@fps-games/editor-playable-sdk/dist/product/standard-scene-assembly.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/scene-source/client.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/scene-source/client.js +8 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/scene-source/client.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/scene-source/types.d.ts +1 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/scene-source/types.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/scene-source/types.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/upgrade-doctor/inspectors.js +134 -12
- package/node_modules/@fps-games/editor-playable-sdk/dist/upgrade-doctor/inspectors.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/editor-scene-workflow.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/editor-scene-workflow.js +47 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/editor-scene-workflow.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/editor-service-vite.d.ts +27 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/editor-service-vite.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/editor-service-vite.js +592 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/editor-service-vite.js.map +1 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/index.d.ts +3 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/index.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/index.js +2 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/index.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/plugin.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/plugin.js +61 -6
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/plugin.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/product-adapter.d.ts +0 -2
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/product-adapter.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/product-adapter.js +1 -10
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/product-adapter.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/product-authoring-api.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/product-authoring-api.js +21 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/product-authoring-api.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/project-authoring-backend.d.ts +13 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/project-authoring-backend.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/project-authoring-backend.js +18 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/project-authoring-backend.js.map +1 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/project-editor-service.d.ts +28 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/project-editor-service.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/project-editor-service.js +863 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/project-editor-service.js.map +1 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/types.d.ts +2 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/types.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/types.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/package.json +6 -6
- package/node_modules/@fps-games/editor-protocol/dist/editor-command-capabilities.d.ts +1626 -0
- package/node_modules/@fps-games/editor-protocol/dist/editor-command-capabilities.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-protocol/dist/{agent-bridge.js → editor-command-capabilities.js} +766 -620
- package/node_modules/@fps-games/editor-protocol/dist/editor-command-capabilities.js.map +1 -0
- package/node_modules/@fps-games/editor-protocol/dist/editor-command-trace.d.ts +69 -0
- package/node_modules/@fps-games/editor-protocol/dist/editor-command-trace.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-protocol/dist/editor-command-trace.js +22 -0
- package/node_modules/@fps-games/editor-protocol/dist/editor-command-trace.js.map +1 -0
- package/node_modules/@fps-games/editor-protocol/dist/editor-command.d.ts +136 -0
- package/node_modules/@fps-games/editor-protocol/dist/editor-command.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-protocol/dist/editor-command.js +2 -0
- package/node_modules/@fps-games/editor-protocol/dist/editor-command.js.map +1 -0
- package/node_modules/@fps-games/editor-protocol/dist/editor-service.d.ts +225 -0
- package/node_modules/@fps-games/editor-protocol/dist/editor-service.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-protocol/dist/editor-service.js +4 -0
- package/node_modules/@fps-games/editor-protocol/dist/editor-service.js.map +1 -0
- package/node_modules/@fps-games/editor-protocol/dist/index.d.ts +6 -3
- package/node_modules/@fps-games/editor-protocol/dist/index.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-protocol/dist/index.js +6 -3
- package/node_modules/@fps-games/editor-protocol/dist/index.js.map +1 -1
- package/node_modules/@fps-games/editor-protocol/package.json +2 -2
- package/node_modules/@fps-games/editor-tooling/package.json +3 -3
- package/node_modules/@fps-games/editor-ui/package.json +1 -1
- package/node_modules/@fps-games/playable-assets/package.json +1 -1
- package/node_modules/@fps-games/playable-contracts/package.json +1 -1
- package/node_modules/@fps-games/playable-rendering/package.json +2 -2
- package/node_modules/@fps-games/playable-runtime/package.json +12 -12
- package/node_modules/@fps-games/playable-runtime-data/package.json +4 -4
- package/node_modules/@fps-games/playable-scene/package.json +2 -2
- package/node_modules/@fps-games/plugin-api/package.json +1 -1
- package/node_modules/@fps-games/plugin-assets/dist/version.d.ts +1 -1
- package/node_modules/@fps-games/plugin-assets/dist/version.js +1 -1
- package/node_modules/@fps-games/plugin-assets/dist/version.js.map +1 -1
- package/node_modules/@fps-games/plugin-assets/package.json +6 -6
- package/node_modules/@fps-games/plugin-hierarchy/dist/kernel.d.ts +1 -0
- package/node_modules/@fps-games/plugin-hierarchy/dist/kernel.d.ts.map +1 -1
- package/node_modules/@fps-games/plugin-hierarchy/dist/kernel.js +78 -4
- package/node_modules/@fps-games/plugin-hierarchy/dist/kernel.js.map +1 -1
- package/node_modules/@fps-games/plugin-hierarchy/dist/version.d.ts +1 -1
- package/node_modules/@fps-games/plugin-hierarchy/dist/version.js +1 -1
- package/node_modules/@fps-games/plugin-hierarchy/dist/version.js.map +1 -1
- package/node_modules/@fps-games/plugin-hierarchy/package.json +5 -5
- package/node_modules/@fps-games/plugin-host/package.json +2 -2
- package/node_modules/@fps-games/plugin-markers/dist/version.d.ts +1 -1
- package/node_modules/@fps-games/plugin-markers/dist/version.js +1 -1
- package/node_modules/@fps-games/plugin-markers/dist/version.js.map +1 -1
- package/node_modules/@fps-games/plugin-markers/package.json +5 -5
- package/node_modules/@fps-games/plugin-materials/dist/version.d.ts +1 -1
- package/node_modules/@fps-games/plugin-materials/dist/version.js +1 -1
- package/node_modules/@fps-games/plugin-materials/dist/version.js.map +1 -1
- package/node_modules/@fps-games/plugin-materials/package.json +5 -5
- package/node_modules/@fps-games/plugin-rendering/dist/version.d.ts +1 -1
- package/node_modules/@fps-games/plugin-rendering/dist/version.js +1 -1
- package/node_modules/@fps-games/plugin-rendering/dist/version.js.map +1 -1
- package/node_modules/@fps-games/plugin-rendering/package.json +5 -5
- package/node_modules/@fps-games/plugin-scene/dist/version.d.ts +1 -1
- package/node_modules/@fps-games/plugin-scene/dist/version.js +1 -1
- package/node_modules/@fps-games/plugin-scene/dist/version.js.map +1 -1
- package/node_modules/@fps-games/plugin-scene/package.json +5 -5
- package/node_modules/@fps-games/plugin-shadow-map-experiment/dist/version.d.ts +1 -1
- package/node_modules/@fps-games/plugin-shadow-map-experiment/dist/version.js +1 -1
- package/node_modules/@fps-games/plugin-shadow-map-experiment/dist/version.js.map +1 -1
- package/node_modules/@fps-games/plugin-shadow-map-experiment/package.json +5 -5
- package/node_modules/@fps-games/plugin-shadows/dist/version.d.ts +1 -1
- package/node_modules/@fps-games/plugin-shadows/dist/version.js +1 -1
- package/node_modules/@fps-games/plugin-shadows/dist/version.js.map +1 -1
- package/node_modules/@fps-games/plugin-shadows/package.json +7 -7
- package/package.json +23 -23
- package/dist/agent-bridge/capabilities/assets.d.ts +0 -8
- package/dist/agent-bridge/capabilities/assets.d.ts.map +0 -1
- package/dist/agent-bridge/capabilities/assets.js.map +0 -1
- package/dist/agent-bridge/capabilities/editor-state.d.ts +0 -5
- package/dist/agent-bridge/capabilities/editor-state.d.ts.map +0 -1
- package/dist/agent-bridge/capabilities/editor-state.js.map +0 -1
- package/dist/agent-bridge/capabilities/hierarchy.d.ts +0 -4
- package/dist/agent-bridge/capabilities/hierarchy.d.ts.map +0 -1
- package/dist/agent-bridge/capabilities/hierarchy.js.map +0 -1
- package/dist/agent-bridge/capabilities/host-lifecycle.d.ts +0 -11
- package/dist/agent-bridge/capabilities/host-lifecycle.d.ts.map +0 -1
- package/dist/agent-bridge/capabilities/host-lifecycle.js +0 -149
- package/dist/agent-bridge/capabilities/host-lifecycle.js.map +0 -1
- package/dist/agent-bridge/capabilities/prefabs.d.ts +0 -5
- package/dist/agent-bridge/capabilities/prefabs.d.ts.map +0 -1
- package/dist/agent-bridge/capabilities/prefabs.js.map +0 -1
- package/dist/agent-bridge/capabilities/scene-objects.d.ts +0 -8
- package/dist/agent-bridge/capabilities/scene-objects.d.ts.map +0 -1
- package/dist/agent-bridge/capabilities/scene-objects.js +0 -480
- package/dist/agent-bridge/capabilities/scene-objects.js.map +0 -1
- package/dist/agent-bridge/capabilities/selection.d.ts +0 -5
- package/dist/agent-bridge/capabilities/selection.d.ts.map +0 -1
- package/dist/agent-bridge/capabilities/selection.js +0 -60
- package/dist/agent-bridge/capabilities/selection.js.map +0 -1
- package/dist/agent-bridge/capabilities/shadows.d.ts +0 -5
- package/dist/agent-bridge/capabilities/shadows.d.ts.map +0 -1
- package/dist/agent-bridge/capabilities/shadows.js.map +0 -1
- package/dist/agent-bridge/capabilities/transform.d.ts +0 -5
- package/dist/agent-bridge/capabilities/transform.d.ts.map +0 -1
- package/dist/agent-bridge/capabilities/transform.js +0 -164
- package/dist/agent-bridge/capabilities/transform.js.map +0 -1
- package/dist/agent-bridge/capabilities/ui-regions.d.ts +0 -4
- package/dist/agent-bridge/capabilities/ui-regions.d.ts.map +0 -1
- package/dist/agent-bridge/capabilities/ui-regions.js.map +0 -1
- package/dist/agent-bridge/capabilities/viewport.d.ts +0 -5
- package/dist/agent-bridge/capabilities/viewport.d.ts.map +0 -1
- package/dist/agent-bridge/capabilities/viewport.js.map +0 -1
- package/dist/agent-bridge/capability-sources.d.ts +0 -7
- package/dist/agent-bridge/capability-sources.d.ts.map +0 -1
- package/dist/agent-bridge/capability-sources.js +0 -34
- package/dist/agent-bridge/capability-sources.js.map +0 -1
- package/dist/agent-bridge/diagnostics.d.ts +0 -12
- package/dist/agent-bridge/diagnostics.d.ts.map +0 -1
- package/dist/agent-bridge/diagnostics.js.map +0 -1
- package/dist/agent-bridge/index.d.ts.map +0 -1
- package/dist/agent-bridge/index.js.map +0 -1
- package/dist/agent-bridge/register.d.ts +0 -4
- package/dist/agent-bridge/register.d.ts.map +0 -1
- package/dist/agent-bridge/register.js.map +0 -1
- package/dist/agent-bridge/shared.d.ts.map +0 -1
- package/dist/agent-bridge/shared.js.map +0 -1
- package/dist/agent-bridge/source-types.d.ts +0 -110
- package/dist/agent-bridge/source-types.d.ts.map +0 -1
- package/dist/agent-bridge/source-types.js.map +0 -1
- package/dist/editor-plugin-agent-capabilities.d.ts +0 -4
- package/dist/editor-plugin-agent-capabilities.d.ts.map +0 -1
- package/dist/editor-plugin-agent-capabilities.js +0 -64
- package/dist/editor-plugin-agent-capabilities.js.map +0 -1
- package/dist/local-editor-agent-actions.d.ts +0 -43
- package/dist/local-editor-agent-actions.d.ts.map +0 -1
- package/dist/local-editor-agent-actions.js +0 -321
- package/dist/local-editor-agent-actions.js.map +0 -1
- package/dist/local-editor-agent-bridge-transport.d.ts +0 -129
- package/dist/local-editor-agent-bridge-transport.d.ts.map +0 -1
- package/dist/local-editor-agent-bridge-transport.js +0 -403
- package/dist/local-editor-agent-bridge-transport.js.map +0 -1
- package/dist/local-editor-agent-bridge.d.ts +0 -2
- package/dist/local-editor-agent-bridge.d.ts.map +0 -1
- package/dist/local-editor-agent-bridge.js +0 -2
- package/dist/local-editor-agent-bridge.js.map +0 -1
- package/dist/local-editor-agent-context.d.ts +0 -68
- package/dist/local-editor-agent-context.d.ts.map +0 -1
- package/dist/local-editor-agent-context.js +0 -716
- package/dist/local-editor-agent-context.js.map +0 -1
- package/node_modules/@fps-games/editor-core/dist/agent-bridge.d.ts +0 -22
- package/node_modules/@fps-games/editor-core/dist/agent-bridge.d.ts.map +0 -1
- package/node_modules/@fps-games/editor-core/dist/agent-bridge.js +0 -106
- package/node_modules/@fps-games/editor-core/dist/agent-bridge.js.map +0 -1
- package/node_modules/@fps-games/editor-core/dist/agent-interaction.d.ts +0 -17
- package/node_modules/@fps-games/editor-core/dist/agent-interaction.d.ts.map +0 -1
- package/node_modules/@fps-games/editor-core/dist/agent-interaction.js +0 -14
- package/node_modules/@fps-games/editor-core/dist/agent-interaction.js.map +0 -1
- package/node_modules/@fps-games/editor-forge-play/dist/agent-transport.d.ts +0 -23
- package/node_modules/@fps-games/editor-forge-play/dist/agent-transport.d.ts.map +0 -1
- package/node_modules/@fps-games/editor-forge-play/dist/agent-transport.js +0 -47
- package/node_modules/@fps-games/editor-forge-play/dist/agent-transport.js.map +0 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/local-harness/agent-descriptions.d.ts +0 -112
- package/node_modules/@fps-games/editor-playable-sdk/dist/local-harness/agent-descriptions.d.ts.map +0 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/local-harness/agent-descriptions.js +0 -159
- package/node_modules/@fps-games/editor-playable-sdk/dist/local-harness/agent-descriptions.js.map +0 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/session-metadata.d.ts +0 -15
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/session-metadata.d.ts.map +0 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/session-metadata.js +0 -76
- package/node_modules/@fps-games/editor-playable-sdk/dist/vite/session-metadata.js.map +0 -1
- package/node_modules/@fps-games/editor-protocol/dist/agent-bridge.d.ts +0 -1622
- package/node_modules/@fps-games/editor-protocol/dist/agent-bridge.d.ts.map +0 -1
- package/node_modules/@fps-games/editor-protocol/dist/agent-bridge.js.map +0 -1
- package/node_modules/@fps-games/editor-protocol/dist/agent-trace.d.ts +0 -68
- package/node_modules/@fps-games/editor-protocol/dist/agent-trace.d.ts.map +0 -1
- package/node_modules/@fps-games/editor-protocol/dist/agent-trace.js +0 -23
- package/node_modules/@fps-games/editor-protocol/dist/agent-trace.js.map +0 -1
- package/node_modules/@fps-games/editor-protocol/dist/agent.d.ts +0 -187
- package/node_modules/@fps-games/editor-protocol/dist/agent.d.ts.map +0 -1
- package/node_modules/@fps-games/editor-protocol/dist/agent.js +0 -5
- package/node_modules/@fps-games/editor-protocol/dist/agent.js.map +0 -1
- /package/dist/{agent-bridge → editor-commands}/source-types.js +0 -0
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
import { EDITOR_SERVICE_PROTOCOL_VERSION, } from '@fps-games/editor-protocol';
|
|
2
|
+
const DEFAULT_CATALOG_PAGE_SIZE = 100;
|
|
3
|
+
const DEFAULT_TRACE_PAGE_SIZE = 100;
|
|
4
|
+
const DEFAULT_MAX_BROWSER_ATTACHMENTS = 32;
|
|
5
|
+
const MAX_LONG_POLL_MS = 30000;
|
|
6
|
+
export function createEditorServiceGateway(options) {
|
|
7
|
+
const host = options.host;
|
|
8
|
+
const now = options.now ?? Date.now;
|
|
9
|
+
const maxCatalogPageSize = normalizePositiveInteger(options.maxCatalogPageSize, DEFAULT_CATALOG_PAGE_SIZE);
|
|
10
|
+
const maxTracePageSize = normalizePositiveInteger(options.maxTracePageSize, DEFAULT_TRACE_PAGE_SIZE);
|
|
11
|
+
const maxBrowserAttachments = normalizePositiveInteger(options.maxBrowserAttachments, DEFAULT_MAX_BROWSER_ATTACHMENTS);
|
|
12
|
+
const browserAttachmentLeaseMs = normalizePositiveInteger(options.browserAttachmentLeaseMs, 40000);
|
|
13
|
+
const browserOperationTimeoutMs = normalizePositiveInteger(options.browserOperationTimeoutMs, 30000);
|
|
14
|
+
const attachments = new Map();
|
|
15
|
+
const forwardedCommands = new Map();
|
|
16
|
+
let disposed = false;
|
|
17
|
+
const leaseTimer = setInterval(expireStaleAttachments, Math.min(1000, Math.max(25, Math.floor(browserAttachmentLeaseMs / 2))));
|
|
18
|
+
leaseTimer.unref?.();
|
|
19
|
+
return Object.freeze({
|
|
20
|
+
serviceInstanceId: host.serviceInstanceId,
|
|
21
|
+
async handle(request, tokenScopes = ['read', 'write']) {
|
|
22
|
+
if (disposed)
|
|
23
|
+
return failure('service.disposed', 'Editor Service Gateway is disposed.');
|
|
24
|
+
expireStaleAttachments();
|
|
25
|
+
if (!request || typeof request !== 'object' || typeof request.kind !== 'string') {
|
|
26
|
+
return failure('request.invalid', 'Editor Service Gateway request is invalid.');
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
switch (request.kind) {
|
|
30
|
+
case 'status':
|
|
31
|
+
return { ok: true, kind: 'status', status: createStatus() };
|
|
32
|
+
case 'commands.list':
|
|
33
|
+
return { ok: true, kind: 'commands', page: await readCatalogPage('', request.cursor, request.limit) };
|
|
34
|
+
case 'commands.search':
|
|
35
|
+
return { ok: true, kind: 'commands', page: await readCatalogPage(request.query, request.cursor, request.limit) };
|
|
36
|
+
case 'commands.describe':
|
|
37
|
+
return { ok: true, kind: 'command', command: await describeGatewayCommand(request.commandId) };
|
|
38
|
+
case 'command.invoke':
|
|
39
|
+
return invokeCommand(request.invocation, request.timeoutMs, tokenScopes);
|
|
40
|
+
case 'operation.get':
|
|
41
|
+
return { ok: true, kind: 'operation', operation: host.commandSystem.getOperation(request.operationId) };
|
|
42
|
+
case 'operation.cancel':
|
|
43
|
+
if (forwardedCommands.get(request.operationId)?.dispatched) {
|
|
44
|
+
return {
|
|
45
|
+
ok: true,
|
|
46
|
+
kind: 'cancel',
|
|
47
|
+
cancelled: false,
|
|
48
|
+
operation: host.commandSystem.getOperation(request.operationId),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
ok: true,
|
|
53
|
+
kind: 'cancel',
|
|
54
|
+
cancelled: host.commandSystem.cancelOperation(request.operationId),
|
|
55
|
+
operation: host.commandSystem.getOperation(request.operationId),
|
|
56
|
+
};
|
|
57
|
+
case 'trace.get': {
|
|
58
|
+
const limit = normalizeLimit(request.limit, maxTracePageSize);
|
|
59
|
+
const page = options.readTraces
|
|
60
|
+
? await options.readTraces({ traceId: request.traceId, cursor: request.cursor, limit })
|
|
61
|
+
: { traces: [] };
|
|
62
|
+
return { ok: true, kind: 'traces', page };
|
|
63
|
+
}
|
|
64
|
+
case 'authoring.snapshot':
|
|
65
|
+
return {
|
|
66
|
+
ok: true,
|
|
67
|
+
kind: 'authoring.snapshot',
|
|
68
|
+
result: (request.afterEventCursor === undefined
|
|
69
|
+
? { kind: 'snapshot-required', reason: 'cursor.invalid', snapshot: host.getSnapshot() }
|
|
70
|
+
: host.readEvents(request.afterEventCursor, request.serviceInstanceId)),
|
|
71
|
+
};
|
|
72
|
+
case 'document.export.get':
|
|
73
|
+
return {
|
|
74
|
+
ok: true,
|
|
75
|
+
kind: 'document.export',
|
|
76
|
+
artifact: options.readDocumentExport
|
|
77
|
+
? await options.readDocumentExport(normalizeId(request.transactionId, 'transactionId'))
|
|
78
|
+
: null,
|
|
79
|
+
};
|
|
80
|
+
case 'attachment.register':
|
|
81
|
+
return registerAttachment(request.attachment);
|
|
82
|
+
case 'attachment.poll':
|
|
83
|
+
return pollAttachment(request.attachmentId, request.timeoutMs);
|
|
84
|
+
case 'attachment.result':
|
|
85
|
+
return acceptAttachmentResult(request.attachmentId, request.result);
|
|
86
|
+
case 'attachment.unregister':
|
|
87
|
+
return unregisterAttachment(request.attachmentId);
|
|
88
|
+
default:
|
|
89
|
+
return failure('request.unknown', 'Editor Service Gateway request kind is unknown.');
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
return failure('request.failed', error instanceof Error ? error.message : String(error));
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
forwardBrowserCommand,
|
|
97
|
+
dispose() {
|
|
98
|
+
if (disposed)
|
|
99
|
+
return;
|
|
100
|
+
disposed = true;
|
|
101
|
+
clearInterval(leaseTimer);
|
|
102
|
+
for (const attachment of attachments.values())
|
|
103
|
+
disconnectAttachment(attachment, 'attachment.disconnected');
|
|
104
|
+
attachments.clear();
|
|
105
|
+
for (const command of forwardedCommands.values()) {
|
|
106
|
+
settleForwardedCommand(command, {
|
|
107
|
+
ok: false,
|
|
108
|
+
diagnostics: [diagnostic('service.disposed', 'Editor Service Gateway is disposed.')],
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
forwardedCommands.clear();
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
function createStatus() {
|
|
115
|
+
const snapshot = host.getSnapshot();
|
|
116
|
+
return {
|
|
117
|
+
ok: true,
|
|
118
|
+
protocolVersion: EDITOR_SERVICE_PROTOCOL_VERSION,
|
|
119
|
+
serviceInstanceId: host.serviceInstanceId,
|
|
120
|
+
canonicalProjectRoot: options.canonicalProjectRoot,
|
|
121
|
+
packageVersion: options.packageVersion,
|
|
122
|
+
buildKey: options.buildKey,
|
|
123
|
+
startedAt: options.startedAt,
|
|
124
|
+
documentRevision: snapshot.documentRevision,
|
|
125
|
+
catalogRevision: host.commandSystem.catalogRevision,
|
|
126
|
+
dirty: snapshot.dirty,
|
|
127
|
+
browserAttachmentCount: attachments.size,
|
|
128
|
+
browserAttachments: [...attachments.values()]
|
|
129
|
+
.filter(attachment => attachment.connected)
|
|
130
|
+
.map(attachment => ({
|
|
131
|
+
attachmentId: attachment.registration.attachmentId,
|
|
132
|
+
...(attachment.registration.label ? { label: attachment.registration.label } : {}),
|
|
133
|
+
targets: attachment.registration.targets,
|
|
134
|
+
commandCount: attachment.registration.commandIds.length,
|
|
135
|
+
}))
|
|
136
|
+
.sort((left, right) => left.attachmentId.localeCompare(right.attachmentId)),
|
|
137
|
+
recovery: {
|
|
138
|
+
draftJournal: false,
|
|
139
|
+
unsavedWorkingStateRecovered: false,
|
|
140
|
+
message: 'Service restart loads the last saved checkpoint; unsaved working state is not recoverable.',
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
async function readCatalogPage(query, cursor, requestedLimit) {
|
|
145
|
+
const normalizedQuery = typeof query === 'string' ? query.trim().toLocaleLowerCase() : '';
|
|
146
|
+
const catalogRevision = host.commandSystem.catalogRevision;
|
|
147
|
+
const offset = decodeCatalogCursor(cursor, catalogRevision, normalizedQuery);
|
|
148
|
+
const limit = normalizeLimit(requestedLimit, maxCatalogPageSize);
|
|
149
|
+
const manifests = host.commandSystem.listManifests()
|
|
150
|
+
.filter(manifest => matchesManifest(manifest, normalizedQuery))
|
|
151
|
+
.sort((left, right) => left.id.localeCompare(right.id));
|
|
152
|
+
const pageManifests = manifests.slice(offset, offset + limit);
|
|
153
|
+
const commands = (await Promise.all(pageManifests.map(manifest => (describeGatewayCommand(manifest.id))))).filter((entry) => entry !== null);
|
|
154
|
+
const nextOffset = offset + pageManifests.length;
|
|
155
|
+
return {
|
|
156
|
+
catalogRevision,
|
|
157
|
+
commands,
|
|
158
|
+
...(nextOffset < manifests.length
|
|
159
|
+
? { nextCursor: encodeCatalogCursor(catalogRevision, normalizedQuery, nextOffset) }
|
|
160
|
+
: {}),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
async function describeGatewayCommand(commandId) {
|
|
164
|
+
const entry = await host.commandSystem.describeCommand(commandId);
|
|
165
|
+
if (!entry || (entry.manifest.target !== 'view' && entry.manifest.target !== 'renderer'))
|
|
166
|
+
return entry;
|
|
167
|
+
const target = entry.manifest.target;
|
|
168
|
+
const attached = [...attachments.values()].some(candidate => candidate.connected
|
|
169
|
+
&& candidate.registration.targets.includes(target)
|
|
170
|
+
&& candidate.registration.commandIds.includes(entry.manifest.id));
|
|
171
|
+
if (attached)
|
|
172
|
+
return entry;
|
|
173
|
+
return {
|
|
174
|
+
manifest: entry.manifest,
|
|
175
|
+
availability: {
|
|
176
|
+
available: false,
|
|
177
|
+
reasons: [diagnostic(`${target}.sessionUnavailable`, `No Browser attachment is available for ${entry.manifest.id}.`)],
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
async function invokeCommand(invocation, timeoutMs, tokenScopes) {
|
|
182
|
+
const capturedInvocation = cloneJson(invocation);
|
|
183
|
+
const expectedServiceInstanceId = capturedInvocation.expectedRevision?.serviceInstanceId;
|
|
184
|
+
if (expectedServiceInstanceId !== undefined && expectedServiceInstanceId !== host.serviceInstanceId) {
|
|
185
|
+
return failure('service.instanceConflict', `Editor Service instance changed: expected ${expectedServiceInstanceId}, current ${host.serviceInstanceId}.`);
|
|
186
|
+
}
|
|
187
|
+
const command = await host.commandSystem.describeCommand(capturedInvocation.commandId);
|
|
188
|
+
if (!command)
|
|
189
|
+
return failure('command.unknown', `Editor command is not registered: ${capturedInvocation.commandId}`);
|
|
190
|
+
if (command.manifest.access === 'write' && !tokenScopes.includes('write')) {
|
|
191
|
+
return failure('auth.writeScopeRequired', `Write scope is required: ${capturedInvocation.commandId}`);
|
|
192
|
+
}
|
|
193
|
+
const attachmentRequirement = validateInvocationAttachment(command.manifest, capturedInvocation.clientId);
|
|
194
|
+
if (attachmentRequirement)
|
|
195
|
+
return failure(attachmentRequirement.code, attachmentRequirement.message);
|
|
196
|
+
const handle = host.invoke(capturedInvocation);
|
|
197
|
+
const waitMs = normalizeTimeout(timeoutMs);
|
|
198
|
+
if (waitMs === 0) {
|
|
199
|
+
return { ok: true, kind: 'operation', operation: host.commandSystem.getOperation(handle.operationId) };
|
|
200
|
+
}
|
|
201
|
+
await waitForOperation(handle.completion, waitMs);
|
|
202
|
+
return { ok: true, kind: 'operation', operation: host.commandSystem.getOperation(handle.operationId) };
|
|
203
|
+
}
|
|
204
|
+
function validateInvocationAttachment(manifest, clientId) {
|
|
205
|
+
for (const target of ['view', 'renderer']) {
|
|
206
|
+
const required = target === 'view'
|
|
207
|
+
? manifest.requires?.viewAttached === true
|
|
208
|
+
: manifest.requires?.rendererAttached === true;
|
|
209
|
+
if (!required)
|
|
210
|
+
continue;
|
|
211
|
+
const attachment = clientId ? attachments.get(clientId) : undefined;
|
|
212
|
+
const commandMatches = manifest.target !== target
|
|
213
|
+
|| attachment?.registration.commandIds.includes(manifest.id) === true;
|
|
214
|
+
if (attachment?.connected
|
|
215
|
+
&& attachment.registration.targets.includes(target)
|
|
216
|
+
&& commandMatches)
|
|
217
|
+
continue;
|
|
218
|
+
return {
|
|
219
|
+
code: `${target}.sessionUnavailable`,
|
|
220
|
+
message: `The requested Browser attachment is unavailable for ${manifest.id}${clientId ? `: ${clientId}` : '.'}`,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
function forwardBrowserCommand(context, target) {
|
|
226
|
+
const attachment = context.clientId ? attachments.get(context.clientId) : undefined;
|
|
227
|
+
if (!attachment) {
|
|
228
|
+
return Promise.resolve({
|
|
229
|
+
ok: false,
|
|
230
|
+
diagnostics: [diagnostic(`${target}.sessionUnavailable`, `No Browser attachment is available for ${context.commandId}.`)],
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
if (!attachment.connected
|
|
234
|
+
|| !attachment.registration.targets.includes(target)
|
|
235
|
+
|| !attachment.registration.commandIds.includes(context.commandId)) {
|
|
236
|
+
return Promise.resolve({
|
|
237
|
+
ok: false,
|
|
238
|
+
diagnostics: [diagnostic(`${target}.sessionUnavailable`, `The requested Browser attachment is unavailable for ${context.commandId}: ${context.clientId}.`)],
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
if (forwardedCommands.has(context.operationId)) {
|
|
242
|
+
return Promise.resolve({
|
|
243
|
+
ok: false,
|
|
244
|
+
diagnostics: [diagnostic('attachment.operationConflict', `Browser command is already forwarded: ${context.operationId}`)],
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
const request = {
|
|
248
|
+
requestId: context.requestId,
|
|
249
|
+
operationId: context.operationId,
|
|
250
|
+
invocation: snapshotHandlerInvocation(context),
|
|
251
|
+
};
|
|
252
|
+
return new Promise(resolve => {
|
|
253
|
+
const command = {
|
|
254
|
+
attachmentId: attachment.registration.attachmentId,
|
|
255
|
+
request,
|
|
256
|
+
resolve,
|
|
257
|
+
signal: context.signal,
|
|
258
|
+
onAbort: () => {
|
|
259
|
+
settleForwardedCommand(command, {
|
|
260
|
+
ok: false,
|
|
261
|
+
diagnostics: [diagnostic('command.cancelled', `Browser command was cancelled: ${context.commandId}`)],
|
|
262
|
+
});
|
|
263
|
+
},
|
|
264
|
+
dispatched: false,
|
|
265
|
+
settled: false,
|
|
266
|
+
};
|
|
267
|
+
forwardedCommands.set(context.operationId, command);
|
|
268
|
+
context.signal.addEventListener('abort', command.onAbort, { once: true });
|
|
269
|
+
command.timeout = setTimeout(() => {
|
|
270
|
+
settleForwardedCommand(command, {
|
|
271
|
+
ok: false,
|
|
272
|
+
diagnostics: [diagnostic('command.timeout', `Browser command timed out: ${context.commandId}`)],
|
|
273
|
+
});
|
|
274
|
+
}, browserOperationTimeoutMs);
|
|
275
|
+
command.timeout.unref?.();
|
|
276
|
+
attachment.operations.add(context.operationId);
|
|
277
|
+
const waiter = attachment.waiters.values().next().value;
|
|
278
|
+
if (waiter) {
|
|
279
|
+
attachment.waiters.delete(waiter);
|
|
280
|
+
command.dispatched = true;
|
|
281
|
+
waiter(cloneJson(request));
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
attachment.queued.push(request);
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
function registerAttachment(registration) {
|
|
289
|
+
const normalized = normalizeAttachment(registration);
|
|
290
|
+
if (attachments.has(normalized.attachmentId)) {
|
|
291
|
+
return failure('attachment.conflict', `Browser attachment is already registered: ${normalized.attachmentId}`);
|
|
292
|
+
}
|
|
293
|
+
if (attachments.size >= maxBrowserAttachments) {
|
|
294
|
+
return failure('attachment.limitExceeded', `Browser attachment limit reached: ${maxBrowserAttachments}.`);
|
|
295
|
+
}
|
|
296
|
+
const manifests = new Map(host.commandSystem.listManifests().map(manifest => [manifest.id, manifest]));
|
|
297
|
+
for (const commandId of normalized.commandIds) {
|
|
298
|
+
const manifest = manifests.get(commandId);
|
|
299
|
+
if (!manifest || (manifest.target !== 'view' && manifest.target !== 'renderer')
|
|
300
|
+
|| !normalized.targets.includes(manifest.target)) {
|
|
301
|
+
return failure('attachment.commandMismatch', `Browser attachment command does not match its registered target: ${commandId}`);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
attachments.set(normalized.attachmentId, {
|
|
305
|
+
registration: normalized,
|
|
306
|
+
queued: [],
|
|
307
|
+
waiters: new Set(),
|
|
308
|
+
operations: new Set(),
|
|
309
|
+
connected: true,
|
|
310
|
+
lastSeenAt: readNow(),
|
|
311
|
+
});
|
|
312
|
+
return { ok: true, kind: 'attachment', attachmentId: normalized.attachmentId };
|
|
313
|
+
}
|
|
314
|
+
async function pollAttachment(attachmentId, timeoutMs) {
|
|
315
|
+
const attachment = attachments.get(normalizeId(attachmentId, 'attachmentId'));
|
|
316
|
+
if (!attachment?.connected)
|
|
317
|
+
return failure('attachment.notFound', `Browser attachment was not found: ${attachmentId}`);
|
|
318
|
+
attachment.lastSeenAt = readNow();
|
|
319
|
+
const queued = attachment.queued.shift();
|
|
320
|
+
if (queued) {
|
|
321
|
+
const command = forwardedCommands.get(queued.operationId);
|
|
322
|
+
if (command)
|
|
323
|
+
command.dispatched = true;
|
|
324
|
+
return { ok: true, kind: 'attachment.poll', request: cloneJson(queued) };
|
|
325
|
+
}
|
|
326
|
+
const waitMs = Math.min(normalizeTimeout(timeoutMs), MAX_LONG_POLL_MS);
|
|
327
|
+
if (waitMs === 0)
|
|
328
|
+
return { ok: true, kind: 'attachment.poll', request: null };
|
|
329
|
+
const request = await new Promise((resolve) => {
|
|
330
|
+
let settled = false;
|
|
331
|
+
const settle = (value) => {
|
|
332
|
+
if (settled)
|
|
333
|
+
return;
|
|
334
|
+
settled = true;
|
|
335
|
+
clearTimeout(timer);
|
|
336
|
+
attachment.waiters.delete(settle);
|
|
337
|
+
resolve(value);
|
|
338
|
+
};
|
|
339
|
+
const timer = setTimeout(() => settle(null), waitMs);
|
|
340
|
+
attachment.waiters.add(settle);
|
|
341
|
+
});
|
|
342
|
+
return { ok: true, kind: 'attachment.poll', request };
|
|
343
|
+
}
|
|
344
|
+
function acceptAttachmentResult(attachmentId, result) {
|
|
345
|
+
const attachment = attachments.get(normalizeId(attachmentId, 'attachmentId'));
|
|
346
|
+
const command = forwardedCommands.get(normalizeId(result?.operationId, 'operationId'));
|
|
347
|
+
if (!attachment || !command || command.attachmentId !== attachmentId
|
|
348
|
+
|| command.request.requestId !== result.requestId || !command.dispatched
|
|
349
|
+
|| command.settled) {
|
|
350
|
+
return { ok: true, kind: 'attachment.result', accepted: false };
|
|
351
|
+
}
|
|
352
|
+
attachment.lastSeenAt = readNow();
|
|
353
|
+
settleForwardedCommand(command, result.ok
|
|
354
|
+
? {
|
|
355
|
+
ok: true,
|
|
356
|
+
output: normalizeJsonValue(result.output),
|
|
357
|
+
...(result.diagnostics?.length ? { diagnostics: cloneJson(result.diagnostics) } : {}),
|
|
358
|
+
}
|
|
359
|
+
: {
|
|
360
|
+
ok: false,
|
|
361
|
+
diagnostics: result.diagnostics?.length
|
|
362
|
+
? cloneJson(result.diagnostics)
|
|
363
|
+
: [diagnostic('command.executionFailed', `Browser command failed: ${command.request.invocation.commandId}`)],
|
|
364
|
+
});
|
|
365
|
+
return { ok: true, kind: 'attachment.result', accepted: true };
|
|
366
|
+
}
|
|
367
|
+
function unregisterAttachment(attachmentId) {
|
|
368
|
+
const normalizedId = normalizeId(attachmentId, 'attachmentId');
|
|
369
|
+
const attachment = attachments.get(normalizedId);
|
|
370
|
+
if (!attachment)
|
|
371
|
+
return { ok: true, kind: 'attachment.unregister', removed: false };
|
|
372
|
+
disconnectAttachment(attachment, 'attachment.disconnected');
|
|
373
|
+
attachments.delete(normalizedId);
|
|
374
|
+
return { ok: true, kind: 'attachment.unregister', removed: true };
|
|
375
|
+
}
|
|
376
|
+
function disconnectAttachment(attachment, code) {
|
|
377
|
+
attachment.connected = false;
|
|
378
|
+
for (const waiter of attachment.waiters)
|
|
379
|
+
waiter(null);
|
|
380
|
+
attachment.waiters.clear();
|
|
381
|
+
attachment.queued.splice(0);
|
|
382
|
+
for (const operationId of attachment.operations) {
|
|
383
|
+
const command = forwardedCommands.get(operationId);
|
|
384
|
+
if (!command || command.settled)
|
|
385
|
+
continue;
|
|
386
|
+
settleForwardedCommand(command, {
|
|
387
|
+
ok: false,
|
|
388
|
+
diagnostics: [diagnostic(code, `Browser attachment disconnected: ${attachment.registration.attachmentId}`)],
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
attachment.operations.clear();
|
|
392
|
+
}
|
|
393
|
+
function settleForwardedCommand(command, outcome) {
|
|
394
|
+
if (command.settled)
|
|
395
|
+
return;
|
|
396
|
+
command.settled = true;
|
|
397
|
+
const attachment = attachments.get(command.attachmentId);
|
|
398
|
+
if (attachment) {
|
|
399
|
+
const index = attachment.queued.findIndex(candidate => candidate.operationId === command.request.operationId);
|
|
400
|
+
if (index >= 0)
|
|
401
|
+
attachment.queued.splice(index, 1);
|
|
402
|
+
attachment.operations.delete(command.request.operationId);
|
|
403
|
+
}
|
|
404
|
+
forwardedCommands.delete(command.request.operationId);
|
|
405
|
+
command.signal.removeEventListener('abort', command.onAbort);
|
|
406
|
+
if (command.timeout)
|
|
407
|
+
clearTimeout(command.timeout);
|
|
408
|
+
command.timeout = undefined;
|
|
409
|
+
command.resolve(outcome);
|
|
410
|
+
}
|
|
411
|
+
function expireStaleAttachments() {
|
|
412
|
+
if (disposed)
|
|
413
|
+
return;
|
|
414
|
+
const current = readNow();
|
|
415
|
+
for (const [attachmentId, attachment] of attachments) {
|
|
416
|
+
if (current - attachment.lastSeenAt <= browserAttachmentLeaseMs)
|
|
417
|
+
continue;
|
|
418
|
+
disconnectAttachment(attachment, 'attachment.leaseExpired');
|
|
419
|
+
attachments.delete(attachmentId);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
function readNow() {
|
|
423
|
+
const value = now();
|
|
424
|
+
return Number.isFinite(value) ? value : Date.now();
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
function normalizeAttachment(input) {
|
|
428
|
+
const attachmentId = normalizeId(input?.attachmentId, 'attachmentId');
|
|
429
|
+
const targets = [...new Set(input?.targets ?? [])];
|
|
430
|
+
if (targets.length === 0 || targets.some(target => target !== 'view' && target !== 'renderer')) {
|
|
431
|
+
throw new Error('Browser attachment targets must contain view or renderer.');
|
|
432
|
+
}
|
|
433
|
+
const commandIds = [...new Set((input?.commandIds ?? []).map(id => normalizeId(id, 'commandId')))];
|
|
434
|
+
return Object.freeze({
|
|
435
|
+
attachmentId,
|
|
436
|
+
targets: Object.freeze(targets),
|
|
437
|
+
commandIds: Object.freeze(commandIds),
|
|
438
|
+
...(input.label?.trim() ? { label: input.label.trim() } : {}),
|
|
439
|
+
...(input.connectedAt?.trim() ? { connectedAt: input.connectedAt.trim() } : {}),
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
function normalizeId(value, label) {
|
|
443
|
+
if (typeof value !== 'string' || !value.trim())
|
|
444
|
+
throw new Error(`${label} must be a non-empty string.`);
|
|
445
|
+
return value.trim();
|
|
446
|
+
}
|
|
447
|
+
function normalizePositiveInteger(value, fallback) {
|
|
448
|
+
return Number.isSafeInteger(value) && value > 0 ? value : fallback;
|
|
449
|
+
}
|
|
450
|
+
function normalizeLimit(value, maximum) {
|
|
451
|
+
if (value === undefined)
|
|
452
|
+
return Math.min(DEFAULT_CATALOG_PAGE_SIZE, maximum);
|
|
453
|
+
if (!Number.isSafeInteger(value) || value <= 0)
|
|
454
|
+
throw new Error('Pagination limit must be a positive safe integer.');
|
|
455
|
+
return Math.min(value, maximum);
|
|
456
|
+
}
|
|
457
|
+
function normalizeTimeout(value) {
|
|
458
|
+
if (value === undefined)
|
|
459
|
+
return 10000;
|
|
460
|
+
if (!Number.isSafeInteger(value) || value < 0)
|
|
461
|
+
throw new Error('timeoutMs must be a non-negative safe integer.');
|
|
462
|
+
return Math.min(value, MAX_LONG_POLL_MS);
|
|
463
|
+
}
|
|
464
|
+
function encodeCatalogCursor(revision, query, offset) {
|
|
465
|
+
return `${revision}.${offset}.${hashString(query)}`;
|
|
466
|
+
}
|
|
467
|
+
function decodeCatalogCursor(cursor, revision, query) {
|
|
468
|
+
if (cursor === undefined)
|
|
469
|
+
return 0;
|
|
470
|
+
const match = /^(\d+)\.(\d+)\.([0-9a-f]+)$/.exec(cursor);
|
|
471
|
+
if (!match || Number(match[1]) !== revision || match[3] !== hashString(query)) {
|
|
472
|
+
throw new Error('Command catalog cursor is invalid or stale.');
|
|
473
|
+
}
|
|
474
|
+
const offset = Number(match[2]);
|
|
475
|
+
if (!Number.isSafeInteger(offset) || offset < 0)
|
|
476
|
+
throw new Error('Command catalog cursor offset is invalid.');
|
|
477
|
+
return offset;
|
|
478
|
+
}
|
|
479
|
+
function hashString(value) {
|
|
480
|
+
let hash = 2166136261;
|
|
481
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
482
|
+
hash ^= value.charCodeAt(index);
|
|
483
|
+
hash = Math.imul(hash, 16777619);
|
|
484
|
+
}
|
|
485
|
+
return (hash >>> 0).toString(16);
|
|
486
|
+
}
|
|
487
|
+
function matchesManifest(manifest, query) {
|
|
488
|
+
if (!query)
|
|
489
|
+
return true;
|
|
490
|
+
return [manifest.id, manifest.title, manifest.description ?? '', ...(manifest.presentation?.aliases ?? []), ...(manifest.presentation?.keywords ?? [])]
|
|
491
|
+
.some(value => value.toLocaleLowerCase().includes(query));
|
|
492
|
+
}
|
|
493
|
+
function failure(code, message) {
|
|
494
|
+
return { ok: false, diagnostics: [diagnostic(code, message)] };
|
|
495
|
+
}
|
|
496
|
+
function diagnostic(code, message) {
|
|
497
|
+
return { severity: 'error', source: 'transport', code, message };
|
|
498
|
+
}
|
|
499
|
+
function snapshotHandlerInvocation(context) {
|
|
500
|
+
return cloneJson({
|
|
501
|
+
commandId: context.commandId,
|
|
502
|
+
...(context.intentCommandId ? { intentCommandId: context.intentCommandId } : {}),
|
|
503
|
+
...(context.input !== undefined ? { input: context.input } : {}),
|
|
504
|
+
requestId: context.requestId,
|
|
505
|
+
...(context.idempotencyKey ? { idempotencyKey: context.idempotencyKey } : {}),
|
|
506
|
+
...(context.expectedRevision ? { expectedRevision: context.expectedRevision } : {}),
|
|
507
|
+
principal: context.principal,
|
|
508
|
+
source: context.source,
|
|
509
|
+
...(context.traceId ? { traceId: context.traceId } : {}),
|
|
510
|
+
...(context.traceStepId ? { traceStepId: context.traceStepId } : {}),
|
|
511
|
+
...(context.transactionId ? { transactionId: context.transactionId } : {}),
|
|
512
|
+
...(context.clientId ? { clientId: context.clientId } : {}),
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
function waitForOperation(completion, timeoutMs) {
|
|
516
|
+
return new Promise(resolve => {
|
|
517
|
+
let settled = false;
|
|
518
|
+
const settle = () => {
|
|
519
|
+
if (settled)
|
|
520
|
+
return;
|
|
521
|
+
settled = true;
|
|
522
|
+
clearTimeout(timer);
|
|
523
|
+
resolve();
|
|
524
|
+
};
|
|
525
|
+
const timer = setTimeout(settle, timeoutMs);
|
|
526
|
+
completion.then(settle, settle);
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
function cloneJson(value) {
|
|
530
|
+
if (typeof structuredClone === 'function')
|
|
531
|
+
return structuredClone(value);
|
|
532
|
+
return JSON.parse(JSON.stringify(value));
|
|
533
|
+
}
|
|
534
|
+
function normalizeJsonValue(value) {
|
|
535
|
+
const serialized = JSON.stringify(value ?? null);
|
|
536
|
+
if (serialized === undefined)
|
|
537
|
+
return null;
|
|
538
|
+
return JSON.parse(serialized);
|
|
539
|
+
}
|
|
540
|
+
//# sourceMappingURL=editor-service-gateway.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-service-gateway.js","sourceRoot":"","sources":["../src/editor-service-gateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAUL,+BAA+B,GAOhC,MAAM,4BAA4B,CAAC;AA8DpC,MAAM,yBAAyB,GAAG,GAAG,CAAC;AACtC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AACpC,MAAM,+BAA+B,GAAG,EAAE,CAAC;AAC3C,MAAM,gBAAgB,GAAG,KAAM,CAAC;AAEhC,MAAM,UAAU,0BAA0B,CACxC,OAAuD;IAEvD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAC1B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC;IACpC,MAAM,kBAAkB,GAAG,wBAAwB,CAAC,OAAO,CAAC,kBAAkB,EAAE,yBAAyB,CAAC,CAAC;IAC3G,MAAM,gBAAgB,GAAG,wBAAwB,CAAC,OAAO,CAAC,gBAAgB,EAAE,uBAAuB,CAAC,CAAC;IACrG,MAAM,qBAAqB,GAAG,wBAAwB,CACpD,OAAO,CAAC,qBAAqB,EAC7B,+BAA+B,CAChC,CAAC;IACF,MAAM,wBAAwB,GAAG,wBAAwB,CAAC,OAAO,CAAC,wBAAwB,EAAE,KAAM,CAAC,CAAC;IACpG,MAAM,yBAAyB,GAAG,wBAAwB,CAAC,OAAO,CAAC,yBAAyB,EAAE,KAAM,CAAC,CAAC;IACtG,MAAM,WAAW,GAAG,IAAI,GAAG,EAA2B,CAAC;IACvD,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAA4B,CAA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,EAAE,CAAC;KAC5D,CAAC,CAAC;AACL,CAAC;AAED,SAAS,gBAAgB,CAAC,UAA4B,EAAE,SAAiB;IACvE,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;QAC3B,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,MAAM,MAAM,GAAG,GAAS,EAAE;YACxB,IAAI,OAAO;gBAAE,OAAO;YACpB,OAAO,GAAG,IAAI,CAAC;YACf,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC;QACF,MAAM,KAAK,GAAG,UAAU,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAC5C,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,SAAS,CAAI,KAAQ;IAC5B,IAAI,OAAO,eAAe,KAAK,UAAU;QAAE,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;IACzE,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAM,CAAC;AAChD,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAc;IACxC,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC;IACjD,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAC1C,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAA2B,CAAC;AAC1D,CAAC","sourcesContent":["import {\n type EditorBrowserAttachmentCommandRequest,\n type EditorBrowserAttachmentCommandResult,\n type EditorBrowserAttachmentRegistration,\n type EditorAuthoringEventReadResult,\n type EditorCommandCatalogEntry,\n type EditorCommandDiagnostic,\n type EditorCommandInvocation,\n type EditorCommandJsonValue,\n type EditorCommandManifest,\n EDITOR_SERVICE_PROTOCOL_VERSION,\n type EditorServiceGatewayRequest,\n type EditorServiceGatewayResponse,\n type EditorServiceStatus,\n type EditorServiceTokenScope,\n type EditorServiceDocumentExportArtifact,\n type EditorServiceTracePage,\n} from '@fps-games/editor-protocol';\nimport type { EditorAuthoringHost } from './editor-authoring-host.js';\nimport type {\n EditorCommandHandlerContext,\n EditorCommandHandlerOutcome,\n} from './editor-command-system.js';\n\nexport interface EditorServiceGatewayOptions<TDocument, TPatch> {\n readonly canonicalProjectRoot: string;\n readonly packageVersion: string;\n readonly buildKey: string;\n readonly startedAt: string;\n readonly host: EditorAuthoringHost<TDocument, TPatch>;\n readonly now?: () => number;\n readonly maxCatalogPageSize?: number;\n readonly maxTracePageSize?: number;\n readonly maxBrowserAttachments?: number;\n readonly browserAttachmentLeaseMs?: number;\n readonly browserOperationTimeoutMs?: number;\n readonly readTraces?: (input: {\n traceId?: string;\n cursor?: string;\n limit: number;\n }) => EditorServiceTracePage | Promise<EditorServiceTracePage>;\n readonly readDocumentExport?: (\n transactionId: string,\n ) => EditorServiceDocumentExportArtifact | null | Promise<EditorServiceDocumentExportArtifact | null>;\n}\n\nexport interface EditorServiceGateway {\n readonly serviceInstanceId: string;\n handle(\n request: EditorServiceGatewayRequest,\n tokenScopes?: readonly EditorServiceTokenScope[],\n ): Promise<EditorServiceGatewayResponse>;\n forwardBrowserCommand(\n context: EditorCommandHandlerContext,\n target: 'view' | 'renderer',\n ): Promise<EditorCommandHandlerOutcome<unknown>>;\n dispose(): void;\n}\n\ninterface AttachmentState {\n readonly registration: EditorBrowserAttachmentRegistration;\n readonly queued: EditorBrowserAttachmentCommandRequest[];\n readonly waiters: Set<(request: EditorBrowserAttachmentCommandRequest | null) => void>;\n readonly operations: Set<string>;\n connected: boolean;\n lastSeenAt: number;\n}\n\ninterface ForwardedCommand {\n readonly attachmentId: string;\n readonly request: EditorBrowserAttachmentCommandRequest;\n readonly resolve: (outcome: EditorCommandHandlerOutcome<unknown>) => void;\n readonly signal: AbortSignal;\n readonly onAbort: () => void;\n dispatched: boolean;\n settled: boolean;\n timeout?: ReturnType<typeof setTimeout>;\n}\n\nconst DEFAULT_CATALOG_PAGE_SIZE = 100;\nconst DEFAULT_TRACE_PAGE_SIZE = 100;\nconst DEFAULT_MAX_BROWSER_ATTACHMENTS = 32;\nconst MAX_LONG_POLL_MS = 30_000;\n\nexport function createEditorServiceGateway<TDocument, TPatch>(\n options: EditorServiceGatewayOptions<TDocument, TPatch>,\n): EditorServiceGateway {\n const host = options.host;\n const now = options.now ?? Date.now;\n const maxCatalogPageSize = normalizePositiveInteger(options.maxCatalogPageSize, DEFAULT_CATALOG_PAGE_SIZE);\n const maxTracePageSize = normalizePositiveInteger(options.maxTracePageSize, DEFAULT_TRACE_PAGE_SIZE);\n const maxBrowserAttachments = normalizePositiveInteger(\n options.maxBrowserAttachments,\n DEFAULT_MAX_BROWSER_ATTACHMENTS,\n );\n const browserAttachmentLeaseMs = normalizePositiveInteger(options.browserAttachmentLeaseMs, 40_000);\n const browserOperationTimeoutMs = normalizePositiveInteger(options.browserOperationTimeoutMs, 30_000);\n const attachments = new Map<string, AttachmentState>();\n const forwardedCommands = new Map<string, ForwardedCommand>();\n let disposed = false;\n const leaseTimer = setInterval(expireStaleAttachments, Math.min(1_000, Math.max(25, Math.floor(browserAttachmentLeaseMs / 2))));\n (leaseTimer as unknown as { unref?: () => void }).unref?.();\n\n return Object.freeze({\n serviceInstanceId: host.serviceInstanceId,\n async handle(\n request: EditorServiceGatewayRequest,\n tokenScopes: readonly EditorServiceTokenScope[] = ['read', 'write'],\n ): Promise<EditorServiceGatewayResponse> {\n if (disposed) return failure('service.disposed', 'Editor Service Gateway is disposed.');\n expireStaleAttachments();\n if (!request || typeof request !== 'object' || typeof request.kind !== 'string') {\n return failure('request.invalid', 'Editor Service Gateway request is invalid.');\n }\n try {\n switch (request.kind) {\n case 'status':\n return { ok: true, kind: 'status', status: createStatus() };\n case 'commands.list':\n return { ok: true, kind: 'commands', page: await readCatalogPage('', request.cursor, request.limit) };\n case 'commands.search':\n return { ok: true, kind: 'commands', page: await readCatalogPage(request.query, request.cursor, request.limit) };\n case 'commands.describe':\n return { ok: true, kind: 'command', command: await describeGatewayCommand(request.commandId) };\n case 'command.invoke':\n return invokeCommand(request.invocation, request.timeoutMs, tokenScopes);\n case 'operation.get':\n return { ok: true, kind: 'operation', operation: host.commandSystem.getOperation(request.operationId) };\n case 'operation.cancel':\n if (forwardedCommands.get(request.operationId)?.dispatched) {\n return {\n ok: true,\n kind: 'cancel',\n cancelled: false,\n operation: host.commandSystem.getOperation(request.operationId),\n };\n }\n return {\n ok: true,\n kind: 'cancel',\n cancelled: host.commandSystem.cancelOperation(request.operationId),\n operation: host.commandSystem.getOperation(request.operationId),\n };\n case 'trace.get': {\n const limit = normalizeLimit(request.limit, maxTracePageSize);\n const page = options.readTraces\n ? await options.readTraces({ traceId: request.traceId, cursor: request.cursor, limit })\n : { traces: [] };\n return { ok: true, kind: 'traces', page };\n }\n case 'authoring.snapshot':\n return {\n ok: true,\n kind: 'authoring.snapshot',\n result: (request.afterEventCursor === undefined\n ? { kind: 'snapshot-required', reason: 'cursor.invalid', snapshot: host.getSnapshot() }\n : host.readEvents(request.afterEventCursor, request.serviceInstanceId)) as unknown as EditorAuthoringEventReadResult,\n };\n case 'document.export.get':\n return {\n ok: true,\n kind: 'document.export',\n artifact: options.readDocumentExport\n ? await options.readDocumentExport(normalizeId(request.transactionId, 'transactionId'))\n : null,\n };\n case 'attachment.register':\n return registerAttachment(request.attachment);\n case 'attachment.poll':\n return pollAttachment(request.attachmentId, request.timeoutMs);\n case 'attachment.result':\n return acceptAttachmentResult(request.attachmentId, request.result);\n case 'attachment.unregister':\n return unregisterAttachment(request.attachmentId);\n default:\n return failure('request.unknown', 'Editor Service Gateway request kind is unknown.');\n }\n } catch (error) {\n return failure(\n 'request.failed',\n error instanceof Error ? error.message : String(error),\n );\n }\n },\n forwardBrowserCommand,\n dispose() {\n if (disposed) return;\n disposed = true;\n clearInterval(leaseTimer);\n for (const attachment of attachments.values()) disconnectAttachment(attachment, 'attachment.disconnected');\n attachments.clear();\n for (const command of forwardedCommands.values()) {\n settleForwardedCommand(command, {\n ok: false,\n diagnostics: [diagnostic('service.disposed', 'Editor Service Gateway is disposed.')],\n });\n }\n forwardedCommands.clear();\n },\n });\n\n function createStatus(): EditorServiceStatus {\n const snapshot = host.getSnapshot();\n return {\n ok: true,\n protocolVersion: EDITOR_SERVICE_PROTOCOL_VERSION,\n serviceInstanceId: host.serviceInstanceId,\n canonicalProjectRoot: options.canonicalProjectRoot,\n packageVersion: options.packageVersion,\n buildKey: options.buildKey,\n startedAt: options.startedAt,\n documentRevision: snapshot.documentRevision,\n catalogRevision: host.commandSystem.catalogRevision,\n dirty: snapshot.dirty,\n browserAttachmentCount: attachments.size,\n browserAttachments: [...attachments.values()]\n .filter(attachment => attachment.connected)\n .map(attachment => ({\n attachmentId: attachment.registration.attachmentId,\n ...(attachment.registration.label ? { label: attachment.registration.label } : {}),\n targets: attachment.registration.targets,\n commandCount: attachment.registration.commandIds.length,\n }))\n .sort((left, right) => left.attachmentId.localeCompare(right.attachmentId)),\n recovery: {\n draftJournal: false,\n unsavedWorkingStateRecovered: false,\n message: 'Service restart loads the last saved checkpoint; unsaved working state is not recoverable.',\n },\n };\n }\n\n async function readCatalogPage(query: string, cursor: string | undefined, requestedLimit: number | undefined) {\n const normalizedQuery = typeof query === 'string' ? query.trim().toLocaleLowerCase() : '';\n const catalogRevision = host.commandSystem.catalogRevision;\n const offset = decodeCatalogCursor(cursor, catalogRevision, normalizedQuery);\n const limit = normalizeLimit(requestedLimit, maxCatalogPageSize);\n const manifests = host.commandSystem.listManifests()\n .filter(manifest => matchesManifest(manifest, normalizedQuery))\n .sort((left, right) => left.id.localeCompare(right.id));\n const pageManifests = manifests.slice(offset, offset + limit);\n const commands = (await Promise.all(pageManifests.map(manifest => (\n describeGatewayCommand(manifest.id)\n )))).filter((entry): entry is EditorCommandCatalogEntry => entry !== null);\n const nextOffset = offset + pageManifests.length;\n return {\n catalogRevision,\n commands,\n ...(nextOffset < manifests.length\n ? { nextCursor: encodeCatalogCursor(catalogRevision, normalizedQuery, nextOffset) }\n : {}),\n };\n }\n\n async function describeGatewayCommand(commandId: string): Promise<EditorCommandCatalogEntry | null> {\n const entry = await host.commandSystem.describeCommand(commandId);\n if (!entry || (entry.manifest.target !== 'view' && entry.manifest.target !== 'renderer')) return entry;\n const target = entry.manifest.target;\n const attached = [...attachments.values()].some(candidate => candidate.connected\n && candidate.registration.targets.includes(target)\n && candidate.registration.commandIds.includes(entry.manifest.id));\n if (attached) return entry;\n return {\n manifest: entry.manifest,\n availability: {\n available: false,\n reasons: [diagnostic(`${target}.sessionUnavailable`, `No Browser attachment is available for ${entry.manifest.id}.`)],\n },\n };\n }\n\n async function invokeCommand(\n invocation: EditorCommandInvocation,\n timeoutMs: number | undefined,\n tokenScopes: readonly EditorServiceTokenScope[],\n ): Promise<EditorServiceGatewayResponse> {\n const capturedInvocation = cloneJson(invocation);\n const expectedServiceInstanceId = capturedInvocation.expectedRevision?.serviceInstanceId;\n if (expectedServiceInstanceId !== undefined && expectedServiceInstanceId !== host.serviceInstanceId) {\n return failure(\n 'service.instanceConflict',\n `Editor Service instance changed: expected ${expectedServiceInstanceId}, current ${host.serviceInstanceId}.`,\n );\n }\n const command = await host.commandSystem.describeCommand(capturedInvocation.commandId);\n if (!command) return failure('command.unknown', `Editor command is not registered: ${capturedInvocation.commandId}`);\n if (command.manifest.access === 'write' && !tokenScopes.includes('write')) {\n return failure('auth.writeScopeRequired', `Write scope is required: ${capturedInvocation.commandId}`);\n }\n const attachmentRequirement = validateInvocationAttachment(command.manifest, capturedInvocation.clientId);\n if (attachmentRequirement) return failure(attachmentRequirement.code, attachmentRequirement.message);\n const handle = host.invoke(capturedInvocation);\n const waitMs = normalizeTimeout(timeoutMs);\n if (waitMs === 0) {\n return { ok: true, kind: 'operation', operation: host.commandSystem.getOperation(handle.operationId) };\n }\n await waitForOperation(handle.completion, waitMs);\n return { ok: true, kind: 'operation', operation: host.commandSystem.getOperation(handle.operationId) };\n }\n\n function validateInvocationAttachment(\n manifest: EditorCommandManifest,\n clientId: string | undefined,\n ): { code: string; message: string } | null {\n for (const target of ['view', 'renderer'] as const) {\n const required = target === 'view'\n ? manifest.requires?.viewAttached === true\n : manifest.requires?.rendererAttached === true;\n if (!required) continue;\n const attachment = clientId ? attachments.get(clientId) : undefined;\n const commandMatches = manifest.target !== target\n || attachment?.registration.commandIds.includes(manifest.id) === true;\n if (attachment?.connected\n && attachment.registration.targets.includes(target)\n && commandMatches) continue;\n return {\n code: `${target}.sessionUnavailable`,\n message: `The requested Browser attachment is unavailable for ${manifest.id}${clientId ? `: ${clientId}` : '.'}`,\n };\n }\n return null;\n }\n\n function forwardBrowserCommand(\n context: EditorCommandHandlerContext,\n target: 'view' | 'renderer',\n ): Promise<EditorCommandHandlerOutcome<unknown>> {\n const attachment = context.clientId ? attachments.get(context.clientId) : undefined;\n if (!attachment) {\n return Promise.resolve({\n ok: false,\n diagnostics: [diagnostic(\n `${target}.sessionUnavailable`,\n `No Browser attachment is available for ${context.commandId}.`,\n )],\n });\n }\n if (!attachment.connected\n || !attachment.registration.targets.includes(target)\n || !attachment.registration.commandIds.includes(context.commandId)) {\n return Promise.resolve({\n ok: false,\n diagnostics: [diagnostic(\n `${target}.sessionUnavailable`,\n `The requested Browser attachment is unavailable for ${context.commandId}: ${context.clientId}.`,\n )],\n });\n }\n if (forwardedCommands.has(context.operationId)) {\n return Promise.resolve({\n ok: false,\n diagnostics: [diagnostic(\n 'attachment.operationConflict',\n `Browser command is already forwarded: ${context.operationId}`,\n )],\n });\n }\n const request: EditorBrowserAttachmentCommandRequest = {\n requestId: context.requestId,\n operationId: context.operationId,\n invocation: snapshotHandlerInvocation(context),\n };\n return new Promise(resolve => {\n const command: ForwardedCommand = {\n attachmentId: attachment.registration.attachmentId,\n request,\n resolve,\n signal: context.signal,\n onAbort: () => {\n settleForwardedCommand(command, {\n ok: false,\n diagnostics: [diagnostic('command.cancelled', `Browser command was cancelled: ${context.commandId}`)],\n });\n },\n dispatched: false,\n settled: false,\n };\n forwardedCommands.set(context.operationId, command);\n context.signal.addEventListener('abort', command.onAbort, { once: true });\n command.timeout = setTimeout(() => {\n settleForwardedCommand(command, {\n ok: false,\n diagnostics: [diagnostic('command.timeout', `Browser command timed out: ${context.commandId}`)],\n });\n }, browserOperationTimeoutMs);\n (command.timeout as unknown as { unref?: () => void }).unref?.();\n attachment.operations.add(context.operationId);\n const waiter = attachment.waiters.values().next().value as ((value: EditorBrowserAttachmentCommandRequest | null) => void) | undefined;\n if (waiter) {\n attachment.waiters.delete(waiter);\n command.dispatched = true;\n waiter(cloneJson(request));\n } else {\n attachment.queued.push(request);\n }\n });\n }\n\n function registerAttachment(registration: EditorBrowserAttachmentRegistration): EditorServiceGatewayResponse {\n const normalized = normalizeAttachment(registration);\n if (attachments.has(normalized.attachmentId)) {\n return failure('attachment.conflict', `Browser attachment is already registered: ${normalized.attachmentId}`);\n }\n if (attachments.size >= maxBrowserAttachments) {\n return failure(\n 'attachment.limitExceeded',\n `Browser attachment limit reached: ${maxBrowserAttachments}.`,\n );\n }\n const manifests = new Map(host.commandSystem.listManifests().map(manifest => [manifest.id, manifest]));\n for (const commandId of normalized.commandIds) {\n const manifest = manifests.get(commandId);\n if (!manifest || (manifest.target !== 'view' && manifest.target !== 'renderer')\n || !normalized.targets.includes(manifest.target)) {\n return failure('attachment.commandMismatch', `Browser attachment command does not match its registered target: ${commandId}`);\n }\n }\n attachments.set(normalized.attachmentId, {\n registration: normalized,\n queued: [],\n waiters: new Set(),\n operations: new Set(),\n connected: true,\n lastSeenAt: readNow(),\n });\n return { ok: true, kind: 'attachment', attachmentId: normalized.attachmentId };\n }\n\n async function pollAttachment(\n attachmentId: string,\n timeoutMs: number | undefined,\n ): Promise<EditorServiceGatewayResponse> {\n const attachment = attachments.get(normalizeId(attachmentId, 'attachmentId'));\n if (!attachment?.connected) return failure('attachment.notFound', `Browser attachment was not found: ${attachmentId}`);\n attachment.lastSeenAt = readNow();\n const queued = attachment.queued.shift();\n if (queued) {\n const command = forwardedCommands.get(queued.operationId);\n if (command) command.dispatched = true;\n return { ok: true, kind: 'attachment.poll', request: cloneJson(queued) };\n }\n const waitMs = Math.min(normalizeTimeout(timeoutMs), MAX_LONG_POLL_MS);\n if (waitMs === 0) return { ok: true, kind: 'attachment.poll', request: null };\n const request = await new Promise<EditorBrowserAttachmentCommandRequest | null>((resolve) => {\n let settled = false;\n const settle = (value: EditorBrowserAttachmentCommandRequest | null): void => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n attachment.waiters.delete(settle);\n resolve(value);\n };\n const timer = setTimeout(() => settle(null), waitMs);\n attachment.waiters.add(settle);\n });\n return { ok: true, kind: 'attachment.poll', request };\n }\n\n function acceptAttachmentResult(\n attachmentId: string,\n result: EditorBrowserAttachmentCommandResult,\n ): EditorServiceGatewayResponse {\n const attachment = attachments.get(normalizeId(attachmentId, 'attachmentId'));\n const command = forwardedCommands.get(normalizeId(result?.operationId, 'operationId'));\n if (!attachment || !command || command.attachmentId !== attachmentId\n || command.request.requestId !== result.requestId || !command.dispatched\n || command.settled) {\n return { ok: true, kind: 'attachment.result', accepted: false };\n }\n attachment.lastSeenAt = readNow();\n settleForwardedCommand(command, result.ok\n ? {\n ok: true,\n output: normalizeJsonValue(result.output),\n ...(result.diagnostics?.length ? { diagnostics: cloneJson(result.diagnostics) } : {}),\n }\n : {\n ok: false,\n diagnostics: result.diagnostics?.length\n ? cloneJson(result.diagnostics)\n : [diagnostic('command.executionFailed', `Browser command failed: ${command.request.invocation.commandId}`)],\n });\n return { ok: true, kind: 'attachment.result', accepted: true };\n }\n\n function unregisterAttachment(attachmentId: string): EditorServiceGatewayResponse {\n const normalizedId = normalizeId(attachmentId, 'attachmentId');\n const attachment = attachments.get(normalizedId);\n if (!attachment) return { ok: true, kind: 'attachment.unregister', removed: false };\n disconnectAttachment(attachment, 'attachment.disconnected');\n attachments.delete(normalizedId);\n return { ok: true, kind: 'attachment.unregister', removed: true };\n }\n\n function disconnectAttachment(attachment: AttachmentState, code: string): void {\n attachment.connected = false;\n for (const waiter of attachment.waiters) waiter(null);\n attachment.waiters.clear();\n attachment.queued.splice(0);\n for (const operationId of attachment.operations) {\n const command = forwardedCommands.get(operationId);\n if (!command || command.settled) continue;\n settleForwardedCommand(command, {\n ok: false,\n diagnostics: [diagnostic(code, `Browser attachment disconnected: ${attachment.registration.attachmentId}`)],\n });\n }\n attachment.operations.clear();\n }\n\n function settleForwardedCommand(\n command: ForwardedCommand,\n outcome: EditorCommandHandlerOutcome<unknown>,\n ): void {\n if (command.settled) return;\n command.settled = true;\n const attachment = attachments.get(command.attachmentId);\n if (attachment) {\n const index = attachment.queued.findIndex(candidate => candidate.operationId === command.request.operationId);\n if (index >= 0) attachment.queued.splice(index, 1);\n attachment.operations.delete(command.request.operationId);\n }\n forwardedCommands.delete(command.request.operationId);\n command.signal.removeEventListener('abort', command.onAbort);\n if (command.timeout) clearTimeout(command.timeout);\n command.timeout = undefined;\n command.resolve(outcome);\n }\n\n function expireStaleAttachments(): void {\n if (disposed) return;\n const current = readNow();\n for (const [attachmentId, attachment] of attachments) {\n if (current - attachment.lastSeenAt <= browserAttachmentLeaseMs) continue;\n disconnectAttachment(attachment, 'attachment.leaseExpired');\n attachments.delete(attachmentId);\n }\n }\n\n function readNow(): number {\n const value = now();\n return Number.isFinite(value) ? value : Date.now();\n }\n}\n\nfunction normalizeAttachment(input: EditorBrowserAttachmentRegistration): EditorBrowserAttachmentRegistration {\n const attachmentId = normalizeId(input?.attachmentId, 'attachmentId');\n const targets = [...new Set(input?.targets ?? [])];\n if (targets.length === 0 || targets.some(target => target !== 'view' && target !== 'renderer')) {\n throw new Error('Browser attachment targets must contain view or renderer.');\n }\n const commandIds = [...new Set((input?.commandIds ?? []).map(id => normalizeId(id, 'commandId')))];\n return Object.freeze({\n attachmentId,\n targets: Object.freeze(targets),\n commandIds: Object.freeze(commandIds),\n ...(input.label?.trim() ? { label: input.label.trim() } : {}),\n ...(input.connectedAt?.trim() ? { connectedAt: input.connectedAt.trim() } : {}),\n });\n}\n\nfunction normalizeId(value: unknown, label: string): string {\n if (typeof value !== 'string' || !value.trim()) throw new Error(`${label} must be a non-empty string.`);\n return value.trim();\n}\n\nfunction normalizePositiveInteger(value: number | undefined, fallback: number): number {\n return Number.isSafeInteger(value) && value! > 0 ? value! : fallback;\n}\n\nfunction normalizeLimit(value: number | undefined, maximum: number): number {\n if (value === undefined) return Math.min(DEFAULT_CATALOG_PAGE_SIZE, maximum);\n if (!Number.isSafeInteger(value) || value <= 0) throw new Error('Pagination limit must be a positive safe integer.');\n return Math.min(value, maximum);\n}\n\nfunction normalizeTimeout(value: number | undefined): number {\n if (value === undefined) return 10_000;\n if (!Number.isSafeInteger(value) || value < 0) throw new Error('timeoutMs must be a non-negative safe integer.');\n return Math.min(value, MAX_LONG_POLL_MS);\n}\n\nfunction encodeCatalogCursor(revision: number, query: string, offset: number): string {\n return `${revision}.${offset}.${hashString(query)}`;\n}\n\nfunction decodeCatalogCursor(cursor: string | undefined, revision: number, query: string): number {\n if (cursor === undefined) return 0;\n const match = /^(\\d+)\\.(\\d+)\\.([0-9a-f]+)$/.exec(cursor);\n if (!match || Number(match[1]) !== revision || match[3] !== hashString(query)) {\n throw new Error('Command catalog cursor is invalid or stale.');\n }\n const offset = Number(match[2]);\n if (!Number.isSafeInteger(offset) || offset < 0) throw new Error('Command catalog cursor offset is invalid.');\n return offset;\n}\n\nfunction hashString(value: string): string {\n let hash = 2166136261;\n for (let index = 0; index < value.length; index += 1) {\n hash ^= value.charCodeAt(index);\n hash = Math.imul(hash, 16777619);\n }\n return (hash >>> 0).toString(16);\n}\n\nfunction matchesManifest(manifest: { id: string; title: string; description?: string; presentation?: { aliases?: readonly string[]; keywords?: readonly string[] } }, query: string): boolean {\n if (!query) return true;\n return [manifest.id, manifest.title, manifest.description ?? '', ...(manifest.presentation?.aliases ?? []), ...(manifest.presentation?.keywords ?? [])]\n .some(value => value.toLocaleLowerCase().includes(query));\n}\n\nfunction failure(code: string, message: string): EditorServiceGatewayResponse {\n return { ok: false, diagnostics: [diagnostic(code, message)] };\n}\n\nfunction diagnostic(code: string, message: string): EditorCommandDiagnostic {\n return { severity: 'error', source: 'transport', code, message };\n}\n\nfunction snapshotHandlerInvocation(context: EditorCommandHandlerContext): EditorCommandInvocation {\n return cloneJson({\n commandId: context.commandId,\n ...(context.intentCommandId ? { intentCommandId: context.intentCommandId } : {}),\n ...(context.input !== undefined ? { input: context.input } : {}),\n requestId: context.requestId,\n ...(context.idempotencyKey ? { idempotencyKey: context.idempotencyKey } : {}),\n ...(context.expectedRevision ? { expectedRevision: context.expectedRevision } : {}),\n principal: context.principal,\n source: context.source,\n ...(context.traceId ? { traceId: context.traceId } : {}),\n ...(context.traceStepId ? { traceStepId: context.traceStepId } : {}),\n ...(context.transactionId ? { transactionId: context.transactionId } : {}),\n ...(context.clientId ? { clientId: context.clientId } : {}),\n });\n}\n\nfunction waitForOperation(completion: Promise<unknown>, timeoutMs: number): Promise<void> {\n return new Promise(resolve => {\n let settled = false;\n const settle = (): void => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n resolve();\n };\n const timer = setTimeout(settle, timeoutMs);\n completion.then(settle, settle);\n });\n}\n\nfunction cloneJson<T>(value: T): T {\n if (typeof structuredClone === 'function') return structuredClone(value);\n return JSON.parse(JSON.stringify(value)) as T;\n}\n\nfunction normalizeJsonValue(value: unknown): EditorCommandJsonValue {\n const serialized = JSON.stringify(value ?? null);\n if (serialized === undefined) return null;\n return JSON.parse(serialized) as EditorCommandJsonValue;\n}\n"]}
|