@volter/editor-game 0.5.66 → 0.5.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (236) hide show
  1. package/contributions/audio-unlock.service.ts +2 -2
  2. package/contributions/autoplay.service.ts +1 -1
  3. package/contributions/bridge.command.ts +3 -3
  4. package/contributions/canvas/component-board.service.ts +16 -0
  5. package/contributions/canvas/design-time-mount.service.ts +45 -0
  6. package/contributions/canvas-story-capture.service.ts +12 -0
  7. package/contributions/edit-mode-audio.service.ts +2 -2
  8. package/contributions/edit-mode-networking.service.ts +1 -1
  9. package/contributions/gameplay.command.ts +4 -4
  10. package/contributions/generation.service.ts +1 -1
  11. package/contributions/godot.style.ts +26 -6
  12. package/contributions/godot.view.ts +6 -0
  13. package/contributions/ingest.service.ts +2 -2
  14. package/contributions/instances.command.ts +1 -1
  15. package/contributions/navmesh.menu.ts +1 -1
  16. package/contributions/network-observer.service.ts +14 -0
  17. package/contributions/play.command.ts +10 -4
  18. package/contributions/react/component-board.service.ts +1 -1
  19. package/contributions/react/design-time-mount.service.ts +1 -1
  20. package/contributions/scene-document.service.ts +3 -3
  21. package/contributions/state-watch.menu.ts +1 -1
  22. package/contributions/state-watch.utility.tsx +1 -1
  23. package/contributions/team-playtest.service.ts +4 -4
  24. package/contributions/three/component-board.service.ts +1 -1
  25. package/contributions/three/component-verbs.command.ts +6 -6
  26. package/contributions/three/three-authoring.service.ts +8 -5
  27. package/contributions/three-story-capture.service.ts +12 -0
  28. package/contributions/unity.style.ts +17 -7
  29. package/contributions/unity.view.ts +6 -0
  30. package/contributions/unreal.style.ts +10 -2
  31. package/contributions/unreal.view.ts +5 -0
  32. package/package.json +20 -10
  33. package/src/asset-budget/AssetBudgetPanel.tsx +1 -1
  34. package/src/asset-budget/asset-budget-model.ts +1 -1
  35. package/src/audio/AudioDebuggerPanel.tsx +1 -1
  36. package/src/bridge/dispatch.ts +14 -14
  37. package/src/bridge/live-frames.ts +1 -1
  38. package/src/bridge/screenshot.ts +3 -3
  39. package/src/build/BuildProfilesPanel.tsx +3 -3
  40. package/src/canvas/canvas-board/CanvasBoardDocument.tsx +676 -0
  41. package/src/canvas/canvas-board/canvas-board-model.ts +407 -0
  42. package/src/canvas/canvas-board/canvas-component-board.ts +56 -0
  43. package/src/canvas/canvas-design-mount.ts +524 -0
  44. package/src/canvas/design-time-canvas-mount.ts +79 -0
  45. package/src/coverage/live-authoring-surface.ts +5 -5
  46. package/src/coverage/live-project-verbs.ts +1 -1
  47. package/src/coverage/native-system-coverage.ts +5 -5
  48. package/src/coverage/root-coverage.ts +1 -1
  49. package/src/coverage/session-coverage.ts +3 -3
  50. package/src/design-system-stories/ApplicationChrome.stories.tsx +5 -5
  51. package/src/design-system-stories/InspectorNarrowBodies.stories.tsx +7 -7
  52. package/src/edit-mode/edit-mode-audio.ts +4 -4
  53. package/src/edit-mode/edit-mode-networking.ts +2 -2
  54. package/src/game-document/GameCaptureFrameButton.tsx +1 -1
  55. package/src/game-document/GameDocument.tsx +2 -2
  56. package/src/game-document/GamePanel.tsx +4 -4
  57. package/src/game-document/InstanceInspectorPicker.tsx +2 -2
  58. package/src/game-document/crowd-debug.ts +1 -1
  59. package/src/game-document/device-preview.ts +10 -11
  60. package/src/game-document/physics-debug.ts +1 -1
  61. package/src/generation/GenerationActivity.tsx +3 -3
  62. package/src/generation/generation-documents.tsx +5 -5
  63. package/src/generation/generation-jobs.ts +1 -1
  64. package/src/host/adapter-runtime-bindings.ts +96 -5
  65. package/src/host/authoring/babylon-authoring-adapter.ts +6 -6
  66. package/src/host/authoring/gesture-persist.ts +1 -1
  67. package/src/host/authoring/ingest-data-writer.ts +1 -1
  68. package/src/host/authoring/ingest-source-persistence.ts +4 -4
  69. package/src/host/authoring/mounted-authoring.ts +4 -4
  70. package/src/host/authoring/phaser-live-authoring-adapter.ts +4 -4
  71. package/src/host/authoring/pixi-authoring-adapter.ts +40 -15
  72. package/src/host/authoring/pixi-creation-site-write-target.ts +2 -2
  73. package/src/host/authoring/pixi-live-write-target.ts +4 -4
  74. package/src/host/authoring/pixi-source-identity.ts +3 -3
  75. package/src/host/authoring/pixi-source-write-target.ts +1614 -0
  76. package/src/host/authoring/pixi-still-presentation.ts +1 -1
  77. package/src/host/authoring/pixi-structure-history.ts +2 -2
  78. package/src/host/authoring/pixi-transform-channels.ts +16 -14
  79. package/src/host/authoring/source-persistence-backend.ts +3 -3
  80. package/src/host/authoring/struct-write-pipe.ts +1 -1
  81. package/src/host/binding-resolver.ts +8 -9
  82. package/src/host/browser-transpile.ts +1 -1
  83. package/src/host/canvas-entry-runtime.ts +58 -47
  84. package/src/host/canvas-preview-frames.ts +482 -0
  85. package/src/host/components/CameraAuthoringOverlay.tsx +1 -1
  86. package/src/host/components/HeaderTelemetry.tsx +4 -4
  87. package/src/host/components/PixiIsolationSceneContent.tsx +10 -10
  88. package/src/host/components/ThreeIsolationSceneContent.tsx +3 -3
  89. package/src/host/components/frame-debugger-model.ts +2 -2
  90. package/src/host/components/header-telemetry-model.ts +2 -2
  91. package/src/host/components/scene-document.tsx +14 -14
  92. package/src/host/components/utility-view-state.ts +1 -1
  93. package/src/host/components/world-root-stage-binding.tsx +12 -12
  94. package/src/host/components/world-root-stage.ts +70 -49
  95. package/src/host/coverage/system-adapter-coverage.ts +3 -4
  96. package/src/host/design-system-stories/fixtures/editor-runtime.tsx +9 -11
  97. package/src/host/document-preview-three.ts +1 -1
  98. package/src/host/entry-adjudication.ts +6 -6
  99. package/src/host/game-css-scope-transform.ts +4 -0
  100. package/src/host/game-realm-page.ts +1 -1
  101. package/src/host/gameplay-export.ts +25 -14
  102. package/src/host/gameplay-recording.ts +5 -5
  103. package/src/host/gated-globals.ts +2 -2
  104. package/src/host/history/json-history-resource.ts +1 -1
  105. package/src/host/projection/pixi.ts +24 -2
  106. package/src/host/r3f-entry-runtime.ts +65 -34
  107. package/src/host/react-mount-runtime.ts +7 -48
  108. package/src/host/realm-services.ts +1 -1
  109. package/src/host/roots/canvas-root.tsx +361 -0
  110. package/src/host/roots/r3f-root.tsx +473 -0
  111. package/src/host/roots/react-root.ts +9 -43
  112. package/src/host/served-bundle-runtime-modules.ts +1 -19
  113. package/src/host/server-log-bridge.ts +2 -2
  114. package/src/host/stories/mounted-story-viewport-source.ts +1 -1
  115. package/src/host/stories/pixi-story-model.ts +30 -0
  116. package/src/host/stories/story-media-captures.ts +46 -0
  117. package/src/host/stories/story-media-presence.ts +3 -3
  118. package/src/host/stories/story-pixi-preview.ts +408 -0
  119. package/src/host/stories/story-three-preview.ts +806 -0
  120. package/src/host/stories/three-story-captures.ts +35 -0
  121. package/src/host/story-three-preview-runtime.ts +56 -0
  122. package/src/host/use-active-performance-source.ts +2 -2
  123. package/src/host/viewport-pose-memory.ts +1 -1
  124. package/src/host/viewport-root-presentation.ts +6 -5
  125. package/src/ingest/active-ingest.ts +1 -1
  126. package/src/ingest/authoring/ingest-dom-surface-authoring.ts +4 -4
  127. package/src/ingest/authoring/ingest-root-adapter.ts +8 -8
  128. package/src/ingest/deferred-ingest-play.ts +6 -6
  129. package/src/ingest/discovery-public-ingest.ts +2 -2
  130. package/src/ingest/ingest-boot-viewport.ts +2 -2
  131. package/src/ingest/ingest-canvas-scene-document.tsx +8 -8
  132. package/src/ingest/ingest-canvas-scene.ts +3 -3
  133. package/src/ingest/ingest-evidence-hook.ts +1 -1
  134. package/src/ingest/ingest-frame-snapshot.ts +1 -1
  135. package/src/ingest/ingest-play-control.ts +1 -1
  136. package/src/ingest/ingest-render-debug.ts +10 -10
  137. package/src/ingest/ingest-siblings.ts +13 -25
  138. package/src/ingest/module-mode.ts +14 -14
  139. package/src/ingest/mount-canvas-ingest-root.ts +21 -21
  140. package/src/ingest/mount-coverage.ts +2 -2
  141. package/src/ingest/mount-dom-ingest-root.ts +11 -11
  142. package/src/ingest/mount-ingest-root.ts +8 -8
  143. package/src/ingest/mount-three-ingest-root.ts +8 -8
  144. package/src/ingest/resolve-canvas.ts +1 -1
  145. package/src/ingest/served-html-boot.ts +1 -1
  146. package/src/ingest/surface-canvas.ts +1 -1
  147. package/src/ingest/unmount-ingest-root.ts +5 -5
  148. package/src/navmesh/navmesh-handler.ts +24 -16
  149. package/src/network/NetworkInspectorPanel.tsx +449 -14
  150. package/src/network/network-inspector-model.ts +14 -2
  151. package/src/play/play-log-events.ts +1 -1
  152. package/src/play/play-mode.ts +76 -133
  153. package/src/play/play-recording.ts +1 -1
  154. package/src/play/react-play-live-authoring.ts +3 -3
  155. package/src/play/run-selection.ts +93 -0
  156. package/src/play-bar/PlayBar.tsx +20 -39
  157. package/src/profiler/FrameDebuggerPanel.tsx +1 -1
  158. package/src/profiler/PerformancePanel.tsx +3 -3
  159. package/src/react/design-time-react-mount.ts +23 -65
  160. package/src/react/dom-authoring-adapter.ts +9 -9
  161. package/src/react/react-inspector-section.tsx +5 -5
  162. package/src/react/react-world-authoring-adapter.ts +11 -11
  163. package/src/react/story-documents/story-documents.tsx +9 -9
  164. package/src/react/ui-board-document.tsx +7 -7
  165. package/src/react/ui-component-board.ts +2 -2
  166. package/src/runtime/adapter/audio-meter.ts +21 -0
  167. package/src/runtime/adapter/first-party-audio-system.ts +230 -0
  168. package/src/runtime/adapter/ingest/contract-debug-adapter.ts +114 -0
  169. package/src/runtime/adapter/ingest/contract-system-adapters.ts +256 -0
  170. package/src/runtime/adapter/ingest/merge-debug-adapters.ts +197 -0
  171. package/src/runtime/adapter/ingest/observation-debug-adapter.ts +162 -0
  172. package/src/runtime/adapter/ingest/upstream-pin.ts +51 -0
  173. package/src/runtime/adapter/native-debug-module.ts +498 -0
  174. package/src/runtime/audio/bus-mixer.ts +161 -0
  175. package/src/runtime/audio/pose-guard.ts +80 -0
  176. package/src/runtime/core/frame-pacing.ts +126 -0
  177. package/src/runtime/core/game-loop.ts +225 -0
  178. package/src/runtime/core/game-scoped-slot.ts +28 -0
  179. package/src/runtime/core/seeded-random.ts +162 -0
  180. package/src/runtime/core/sim-clock.ts +391 -0
  181. package/src/runtime/core/system-runner.ts +269 -0
  182. package/src/runtime/core/types.ts +104 -0
  183. package/src/runtime/create-runtime.ts +1128 -0
  184. package/src/runtime/debug-bridge.ts +570 -0
  185. package/src/runtime/debug-registry.ts +899 -0
  186. package/src/runtime/dev/chrome-trace.ts +153 -0
  187. package/src/runtime/dev/instruments.ts +403 -0
  188. package/src/runtime/dev/logger.ts +119 -0
  189. package/src/runtime/dev/performance-profiler.ts +367 -0
  190. package/src/runtime/dev/register-render-vitals.ts +276 -0
  191. package/src/runtime/dev/render-census.ts +354 -0
  192. package/src/runtime/dev/render-debug-adapter.ts +218 -0
  193. package/src/runtime/dev/render-memory.ts +226 -0
  194. package/src/runtime/dev/render-vitals.ts +338 -0
  195. package/src/runtime/dev/static-batch-advisor.ts +188 -0
  196. package/src/runtime/dev/webgl-frame-capture.ts +366 -0
  197. package/src/runtime/dev/webgl-gpu-timer.ts +53 -0
  198. package/src/runtime/dev-build.ts +47 -0
  199. package/src/runtime/game.ts +1636 -0
  200. package/src/runtime/gameplay-rng-trap.ts +135 -0
  201. package/src/runtime/host-context.ts +64 -0
  202. package/src/runtime/input-router.ts +169 -0
  203. package/src/runtime/mount-manifest.ts +480 -0
  204. package/src/runtime/pixi/authoring.ts +706 -0
  205. package/src/runtime/pixi/ingest.ts +116 -0
  206. package/src/runtime/pixi/physics-registry.ts +49 -0
  207. package/src/runtime/pixi/render-pass-bracket.ts +117 -0
  208. package/src/runtime/pixi/scene-capture.ts +179 -0
  209. package/src/runtime/pixi/system-adapters.ts +69 -0
  210. package/src/runtime/playtest.ts +22 -0
  211. package/src/runtime/presentation.ts +141 -0
  212. package/src/runtime/render-control.ts +642 -0
  213. package/src/runtime/render-seed.ts +77 -0
  214. package/src/runtime/run-ticks-settled.ts +73 -0
  215. package/src/runtime/setup/setup-audio.ts +72 -0
  216. package/src/services/audio-pose-guard.ts +2 -2
  217. package/src/services/game-audio.ts +152 -0
  218. package/src/services/game-network.ts +657 -0
  219. package/src/services/game-physics.ts +334 -0
  220. package/src/state-watch/StateWatchPanel.tsx +1 -1
  221. package/src/three/authoring/camera-runtime-inspector-section.tsx +3 -2
  222. package/src/three/authoring/constraint-inspector-section.tsx +6 -5
  223. package/src/three/authoring/model-asset-inspector-section.tsx +7 -6
  224. package/src/three/authoring/oid-source-persistence.ts +7 -7
  225. package/src/three/authoring/r3f-design-session.ts +58 -54
  226. package/src/three/authoring/r3f-source-authoring-adapter.ts +95 -91
  227. package/src/three/authoring/reflection-probe-inspector-section.tsx +3 -2
  228. package/src/three/authoring/three-authoring-adapter.ts +29 -29
  229. package/src/three/component-verbs/extract-menu.ts +7 -6
  230. package/src/three/component-verbs/fork-menu.ts +7 -6
  231. package/src/three/component-verbs/internals-menu.ts +2 -2
  232. package/src/three/story-documents/three-story-documents.tsx +13 -13
  233. package/src/three/three-board/ThreeBoardDocument.tsx +13 -12
  234. package/src/three/three-board/board-scene.ts +6 -6
  235. package/src/three/three-board/three-component-board.ts +2 -2
  236. package/src/services/game-audio-unlock.ts +0 -48
@@ -12,7 +12,7 @@
12
12
  * whose camera pose) — handed in as `renderScene`.
13
13
  */
14
14
 
15
- import { registerPresentedCanvasFrame } from '@volter/editor-core/canvas-preview-frames';
15
+ import { registerPresentedCanvasFrame } from '../canvas-preview-frames';
16
16
  import type { RootViewController } from '@volter/editor-sdk/kit/world-pan-state';
17
17
 
18
18
  /**
@@ -31,7 +31,7 @@
31
31
 
32
32
  import type { Container } from 'pixi.js';
33
33
  import { editorConsole } from '@volter/editor-sdk/kit/editor-console';
34
- import type { EditorShellStore } from '@volter/editor-core/editor-shell-store';
34
+ import type { EditorShellStore } from '@volter/editor-threejs/kit/editor-shell-store';
35
35
  import { type JournalSubject, JsonHistoryResource } from '../history/json-history-resource';
36
36
 
37
37
  /** The stage root's stand-in uid: it is not one of the adapter's nodes, but it
@@ -113,7 +113,7 @@ export class CanvasStructureHistory {
113
113
  /** Re-index + notify after a restore put objects back. */
114
114
  private readonly onRestored: () => void,
115
115
  ) {
116
- const history = store.projectHistory;
116
+ const history = store.shell.projectHistory;
117
117
  this.resource = history
118
118
  ? new JsonHistoryResource<CanvasStructureState>({
119
119
  history,
@@ -23,15 +23,16 @@
23
23
  * `<pixiContainer scale={0.5}>` is the shipped idiom (see any prefab under an
24
24
  * example project's `prefabs/`), and Pixi's own setter takes a number or a
25
25
  * `PointData` — never an array. So a UNIFORM scale writes the scalar back, and
26
- * a NON-UNIFORM one is only expressible through `@pixi/react`'s dashed-prop
27
- * piercing (`scale-x`/`scale-y`, which land on `container.scale.x`/`.y`). This
28
- * module writes the dashed pair when the tag already authors it, and otherwise
29
- * REFUSES a non-uniform scale in a sentence naming the pair — never a silently
30
- * lossy uniform write, and never an array literal Pixi would reject at
31
- * runtime.
26
+ * a NON-UNIFORM one writes the `{ x, y }` point the same setter takes. Not the
27
+ * dashed pair (`scale-x`/`scale-y`) as a new write: `@pixi/react` 8.0.5 hands
28
+ * every prop to the Pixi constructor, which copies `scale-x` onto the object as
29
+ * a plain property, so the pierce never runs when the node mounts (measured: a
30
+ * source with `scale-x={1.29}` mounts at scale 1). A tag that already authors
31
+ * the pair keeps it. Never a silently lossy uniform write, and never an array
32
+ * literal Pixi would reject at runtime.
32
33
  */
33
34
 
34
- import type { Transform2DValue } from '@volter/game-runtime/pixi/authoring';
35
+ import type { Transform2DValue } from '../../runtime/pixi/authoring';
35
36
  import type { Transform } from '@volter/editor-project/adapter';
36
37
 
37
38
  /** Quaternion (xyzw) about Z ⇄ scalar radians — the one mapping both canvas
@@ -83,6 +84,8 @@ export type PixiChannelPlan =
83
84
  | { readonly writable: false; readonly reason: string };
84
85
 
85
86
  const NUMBER_RE = /^-?\d+(\.\d+)?$/;
87
+ /** A number-point literal, `{ x: 1.2, y: 0.8 }` (the JSX expression's inside). */
88
+ const POINT_RE = /^\{\s*x\s*:\s*-?\d*\.?\d+(e[+-]?\d+)?\s*,\s*y\s*:\s*-?\d*\.?\d+(e[+-]?\d+)?\s*,?\s*\}$/i;
86
89
  const EPS = 1e-6;
87
90
 
88
91
  /** ≤4 decimals, no trailing zeros, no negative zero — the same source-number
@@ -165,21 +168,20 @@ export function planChannelWrite(
165
168
  const refusal = propRefusal(attrs, 'scale');
166
169
  if (refusal) return { writable: false, reason: refusal };
167
170
  const authored = attr(attrs, 'scale');
168
- if (authored && !NUMBER_RE.test(authored.rawValue.trim())) {
171
+ if (authored && !NUMBER_RE.test(authored.rawValue.trim()) && !POINT_RE.test(authored.rawValue.trim())) {
169
172
  return {
170
173
  writable: false,
171
174
  reason:
172
- `scale is authored as {${authored.rawValue}} — this editor writes the scalar ` +
173
- 'shorthand or the `scale-x`/`scale-y` pair, not an object literal.',
175
+ `scale is authored as {${authored.rawValue}} — this editor writes a number or an ` +
176
+ '`{ x, y }` point, not an expression.',
174
177
  };
175
178
  }
176
179
  const [sx, sy] = next.scale;
177
180
  if (Math.abs(sx - sy) >= EPS) {
181
+ // Two values: the `PointData` Pixi's own setter takes, which applies when the node mounts.
178
182
  return {
179
- writable: false,
180
- reason:
181
- 'A non-uniform scale needs the `scale-x`/`scale-y` props — this tag authors the ' +
182
- 'uniform `scale` shorthand, which cannot hold two values.',
183
+ writable: true,
184
+ writes: [{ prop: 'scale', value: `{ x: ${formatSourceNumber(sx)}, y: ${formatSourceNumber(sy)} }` }],
183
185
  };
184
186
  }
185
187
  return { writable: true, writes: [{ prop: 'scale', value: formatSourceNumber(sx) }] };
@@ -46,11 +46,11 @@ import type {
46
46
  CreationSiteLiteralReport,
47
47
  CreationSiteSurface,
48
48
  CreationSiteWriteScope,
49
- } from '@volter/editor-core/creation-site-edit';
49
+ } from '@volter/editor-sdk/kit/creation-site-edit';
50
50
  import { editorConsole } from '@volter/editor-sdk/kit/editor-console';
51
51
  import { editorIsAuthoring } from '@volter/editor-sdk/kit/editor-session-mode';
52
- import type { HistoryService } from '@volter/editor-core/history/history-service';
53
- import { ingestSourceWritesRecordedIfPrimed } from '@volter/editor-core/ui-source/tier-source-write-backend';
52
+ import type { HistoryService } from '@volter/editor-sdk/kit/history/history-service';
53
+ import { ingestSourceWritesRecordedIfPrimed } from '@volter/editor-sdk/kit/ui-source/tier-source-write-backend';
54
54
  import type { IngestInspectRequest } from './ingest-source-persistence';
55
55
  import {
56
56
  IngestSourcePersistence,
@@ -28,7 +28,7 @@
28
28
  */
29
29
 
30
30
  import { showTransientHint } from '@volter/editor-sdk/kit/transient-hint';
31
- import type { SourceWriteBackend } from '@volter/editor-core/ui-source/source-write-backend';
31
+ import type { SourceWriteBackend } from '@volter/editor-sdk/kit/ui-source/source-write-backend';
32
32
  import { resolvesLiveOnly, runWritePipe, type WriteAck, type WriteResolution } from '@volter/editor-sdk/kit/write-pipe';
33
33
 
34
34
  /** The `writeStruct` options bag, spelled once (the backend's own shape). */
@@ -41,9 +41,9 @@ import {
41
41
  import {
42
42
  nativeDebugBindingFromEntryModule,
43
43
  nativeSystemsBindingFromEntryModule,
44
- } from '@volter/game-runtime/adapter/native-debug-module';
45
- import type { RootMountSpec } from '@volter/game-runtime/runtime/create-runtime';
46
- import type { MountEntry } from '@volter/game-runtime/runtime/mount-manifest';
44
+ } from '../runtime/adapter/native-debug-module';
45
+ import type { RootMountSpec } from '../runtime/create-runtime';
46
+ import type { MountEntry } from '../runtime/mount-manifest';
47
47
  import type { SurfaceAdapter } from '@volter/editor-project/adapter';
48
48
  import type { AdapterDefinition } from '@volter/editor-project/adapter/adapter-module';
49
49
  import { assertNever } from '@volter/editor-project/adapter/adapter-surface';
@@ -51,7 +51,7 @@ import type { RootDeclaration } from '@volter/editor-project/adapter/binding';
51
51
  import { declaredRoots } from '@volter/editor-project/adapter/manifest-interpreter';
52
52
  import type { ResolvedAdapterRoot, ResolvedGameManifest } from '@volter/editor-project/manifest/load';
53
53
  import { adjudicateThreeEntry } from './entry-adjudication';
54
- import { projectAdapterDefinition } from '@volter/editor-core/project-adapter';
54
+ import { projectAdapterDefinition } from '@volter/editor-sdk/kit/project-adapter';
55
55
  import { activeRealmServices, type RealmServices } from './realm-services';
56
56
  import { resolveModuleAdapter } from './roots/module-root';
57
57
  import { resolveDomAdapter, resolveIngestReactAdapter } from './roots/react-root';
@@ -193,11 +193,10 @@ async function resolveThreeRoot(
193
193
  /**
194
194
  * A canvas root is source-as-truth exactly like a three root: its `entry` is a
195
195
  * TSX world file, and what that file EXPORTS is adjudicated in ONE place —
196
- * `resolveCanvasEntryAdapter` (`@volter/game-runtime/canvas-react`, reached through the
197
- * realm so the packaged runtime takes it from the PROJECT's graph), the same
198
- * function the standalone mount path uses. Keeping the adjudication there
199
- * rather than here is what stops the editor and the standalone build from
200
- * disagreeing about what a world file means.
196
+ * `resolveCanvasEntryAdapter` (`roots/canvas-root.tsx`, reached through the
197
+ * realm so the packaged runtime mounts with the PROJECT's graph), shared by
198
+ * Play and the design-time layer so the two never disagree about what a world
199
+ * file means.
201
200
  */
202
201
  async function resolveCanvasRoot(
203
202
  root: ResolvedAdapterRoot,
@@ -30,7 +30,7 @@ import { init as esModuleLexerInit, parse as parseEsModule } from 'es-module-lex
30
30
  import * as esbuild from 'esbuild-wasm';
31
31
  // Vite serves the wasm binary as a static asset URL — fully local, no CDN.
32
32
  import esbuildWasmUrl from 'esbuild-wasm/esbuild.wasm?url';
33
- import { GAME_GLOBALS_PRELUDE } from '@volter/editor-core/game-globals-prelude';
33
+ import { GAME_GLOBALS_PRELUDE } from '@volter/editor-sdk/kit/game-globals-prelude';
34
34
 
35
35
  /** Live runtime modules, keyed by the bare specifier used to import them. */
36
36
  type ModuleNamespace = Record<string, unknown>;
@@ -1,28 +1,26 @@
1
1
  /**
2
- * Resolve the canvas entry adapter from the same module graph as project
3
- * worlds — the `@pixi/react` sibling of `r3f-entry-runtime.ts`.
2
+ * The React, `@pixi/react` and `pixi.js` a project's canvas world is mounted
3
+ * with — the sibling of `r3f-entry-runtime.ts`.
4
4
  *
5
5
  * The packaged editor's UI is prebuilt with its own React, `@pixi/react` and
6
6
  * `pixi.js`, while project modules are transformed by a separate,
7
- * project-rooted Vite server. Building a project component's adapter with the
8
- * UI bundle's factory crosses those graphs: the reconciler's hooks and the
9
- * component's hooks come from two Reacts, the tree never commits, and
10
- * the canvas mount fails its own first-commit ceiling ten seconds
11
- * later. See `../vite-plugin-module-doorways.ts` for the measured failure.
7
+ * project-rooted Vite server. Mounting a project component with the UI
8
+ * bundle's reconciler crosses those graphs: the reconciler's hooks and the
9
+ * component's hooks come from two Reacts, the tree never commits, and the
10
+ * canvas mount fails its own first-commit ceiling ten seconds later. See
11
+ * `vite-plugin-module-doorways.ts` for the measured failure.
12
12
  *
13
- * `@volter/game-runtime/canvas-react` is dynamic-imported on BOTH branches, deliberately: a
14
- * static import would put `pixi.js` and the Pixi reconciler in every editor
15
- * bundle, including one opening a three-only project — the same reason the
16
- * call sites this replaces were already dynamic.
13
+ * `pixi.js` and `@pixi/react` are dynamic-imported on the checkout branch,
14
+ * deliberately: a static import would put the Pixi renderer and reconciler in
15
+ * every editor bundle, including one opening a three-only project.
17
16
  */
18
17
 
19
- import type { resolveCanvasEntryAdapter } from '@volter/game-runtime/canvas-react';
20
18
  import type { RootAdapter } from '@volter/editor-project/adapter';
21
- import type * as PIXI from 'pixi.js';
22
19
  import { CANVAS_RUNTIME_PATH } from '@volter/editor-sdk/host';
23
20
  import { isPackagedRuntime } from '@volter/editor-sdk/kit/packaged-runtime';
24
-
25
- type CanvasEntryResolver = typeof resolveCanvasEntryAdapter;
21
+ import type * as PIXI from 'pixi.js';
22
+ import { createElement, Fragment, useEffect, useLayoutEffect } from 'react';
23
+ import { type CanvasRuntime, resolveCanvasEntryAdapter } from './roots/canvas-root';
26
24
 
27
25
  /**
28
26
  * The `pixi.js` module namespace a canvas surface constructs and class-checks
@@ -32,36 +30,57 @@ type CanvasEntryResolver = typeof resolveCanvasEntryAdapter;
32
30
  */
33
31
  export type CanvasPixiNamespace = typeof PIXI;
34
32
 
35
- interface PackagedCanvasRuntime {
36
- readonly resolve: CanvasEntryResolver;
37
- readonly projectPixi: CanvasPixiNamespace;
38
- }
33
+ let cachedRuntime: Promise<CanvasRuntime> | null = null;
39
34
 
40
- let cachedPackagedRuntime: Promise<PackagedCanvasRuntime> | null = null;
35
+ const DOORWAY_MEMBERS = [
36
+ 'createElement',
37
+ 'Fragment',
38
+ 'useEffect',
39
+ 'useLayoutEffect',
40
+ 'createPixiRoot',
41
+ 'extendPixi',
42
+ 'projectPixi',
43
+ ] as const;
41
44
 
42
- async function packagedRuntime(): Promise<PackagedCanvasRuntime> {
43
- const mod = (await import(/* @vite-ignore */ CANVAS_RUNTIME_PATH)) as {
44
- resolveCanvasEntryAdapter?: unknown;
45
- projectPixi?: unknown;
46
- };
47
- if (typeof mod.resolveCanvasEntryAdapter !== 'function') {
48
- throw new Error(
49
- "The packaged runtime's synthetic canvas module did not export " +
50
- '`resolveCanvasEntryAdapter` — see vite-plugin-module-doorways.ts.',
51
- );
52
- }
53
- if (typeof mod.projectPixi !== 'object' || mod.projectPixi === null) {
45
+ async function packagedRuntime(): Promise<CanvasRuntime> {
46
+ const mod = (await import(/* @vite-ignore */ CANVAS_RUNTIME_PATH)) as Record<string, unknown>;
47
+ const missing = DOORWAY_MEMBERS.filter((name) => mod[name] === undefined || mod[name] === null);
48
+ if (missing.length > 0) {
54
49
  throw new Error(
55
- "The packaged runtime's synthetic canvas module did not export " +
56
- '`projectPixi` — see vite-plugin-module-doorways.ts.',
50
+ `The packaged runtime's synthetic canvas module did not export ${missing.join(', ')} — ` +
51
+ 'see CANVAS_DOORWAY in vite-plugin-module-doorways.ts.',
57
52
  );
58
53
  }
59
54
  return {
60
- resolve: mod.resolveCanvasEntryAdapter as CanvasEntryResolver,
61
- projectPixi: mod.projectPixi as CanvasPixiNamespace,
55
+ createElement: mod['createElement'] as CanvasRuntime['createElement'],
56
+ Fragment: mod['Fragment'] as CanvasRuntime['Fragment'],
57
+ useEffect: mod['useEffect'] as CanvasRuntime['useEffect'],
58
+ useLayoutEffect: mod['useLayoutEffect'] as CanvasRuntime['useLayoutEffect'],
59
+ createRoot: mod['createPixiRoot'] as CanvasRuntime['createRoot'],
60
+ extend: mod['extendPixi'] as CanvasRuntime['extend'],
61
+ pixi: mod['projectPixi'] as CanvasPixiNamespace,
62
62
  };
63
63
  }
64
64
 
65
+ async function checkoutRuntime(): Promise<CanvasRuntime> {
66
+ const [pixiReact, pixi] = await Promise.all([import('@pixi/react'), import('pixi.js')]);
67
+ return {
68
+ createElement,
69
+ Fragment,
70
+ useEffect,
71
+ useLayoutEffect,
72
+ createRoot: pixiReact.createRoot,
73
+ extend: pixiReact.extend,
74
+ pixi,
75
+ };
76
+ }
77
+
78
+ /** The canvas runtime of the graph a canvas world mounts in, loaded once per session. */
79
+ async function canvasRuntime(): Promise<CanvasRuntime> {
80
+ cachedRuntime ??= (async () => ((await isPackagedRuntime()) ? packagedRuntime() : checkoutRuntime()))();
81
+ return cachedRuntime;
82
+ }
83
+
65
84
  /**
66
85
  * THE `pixi.js` OF THE GRAPH A CANVAS WORLD MOUNTS IN — the project's under the
67
86
  * packaged runtime, this bundle's own copy otherwise.
@@ -75,21 +94,13 @@ async function packagedRuntime(): Promise<PackagedCanvasRuntime> {
75
94
  * between two collaborators of the same surface is the bug, not the seam.
76
95
  */
77
96
  export async function resolveCanvasPixiForEditor(): Promise<CanvasPixiNamespace> {
78
- if (!(await isPackagedRuntime())) return import('pixi.js');
79
- if (!cachedPackagedRuntime) cachedPackagedRuntime = packagedRuntime();
80
- return (await cachedPackagedRuntime).projectPixi;
97
+ return (await canvasRuntime()).pixi;
81
98
  }
82
99
 
83
- /** The adjudicator `resolveCanvasEntryAdapter` — from the PROJECT's graph
84
- * under the packaged runtime, from this bundle's own engine copy otherwise. */
100
+ /** The canvas entry adjudicator, handed the runtime of the graph the world mounts in. */
85
101
  export async function resolveCanvasEntryAdapterForEditor(
86
102
  entryModule: unknown,
87
103
  rootId: string,
88
104
  ): Promise<RootAdapter<'canvas'> | null> {
89
- if (!(await isPackagedRuntime())) {
90
- const { resolveCanvasEntryAdapter } = await import('@volter/game-runtime/canvas-react');
91
- return resolveCanvasEntryAdapter(entryModule, rootId);
92
- }
93
- if (!cachedPackagedRuntime) cachedPackagedRuntime = packagedRuntime();
94
- return (await cachedPackagedRuntime).resolve(entryModule, rootId);
105
+ return resolveCanvasEntryAdapter(entryModule, rootId, await canvasRuntime());
95
106
  }