@vgai/engine 0.5.5 → 0.5.7
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/adapter/adapter-surface.d.ts +30 -0
- package/dist/adapter/adapter-surface.d.ts.map +1 -0
- package/dist/adapter/adapter-surface.js +18 -0
- package/dist/adapter/authoring.d.ts +597 -0
- package/dist/adapter/authoring.d.ts.map +1 -0
- package/dist/adapter/authoring.js +22 -0
- package/dist/adapter/colyseus-networking-adapter.d.ts +77 -0
- package/dist/adapter/colyseus-networking-adapter.d.ts.map +1 -0
- package/dist/adapter/colyseus-networking-adapter.js +76 -0
- package/dist/adapter/first-party-systems.d.ts +23 -0
- package/dist/adapter/first-party-systems.d.ts.map +1 -0
- package/dist/adapter/first-party-systems.js +196 -0
- package/dist/adapter/host-context.d.ts +194 -0
- package/dist/adapter/host-context.d.ts.map +1 -0
- package/dist/adapter/host-context.js +80 -0
- package/dist/adapter/index.d.ts +33 -0
- package/dist/adapter/index.d.ts.map +1 -0
- package/dist/adapter/index.js +25 -0
- package/dist/adapter/ingest/game-contract.d.ts +53 -0
- package/dist/adapter/ingest/game-contract.d.ts.map +1 -0
- package/dist/adapter/ingest/game-contract.js +30 -0
- package/dist/adapter/ingest/scene-capture.d.ts +121 -0
- package/dist/adapter/ingest/scene-capture.d.ts.map +1 -0
- package/dist/adapter/ingest/scene-capture.js +270 -0
- package/dist/adapter/ingest/structural-ids.d.ts +64 -0
- package/dist/adapter/ingest/structural-ids.d.ts.map +1 -0
- package/dist/adapter/ingest/structural-ids.js +110 -0
- package/dist/adapter/ingest/upstream-pin.d.ts +44 -0
- package/dist/adapter/ingest/upstream-pin.d.ts.map +1 -0
- package/dist/adapter/ingest/upstream-pin.js +47 -0
- package/dist/adapter/loop-gate-report.d.ts +34 -0
- package/dist/adapter/loop-gate-report.d.ts.map +1 -0
- package/dist/adapter/loop-gate-report.js +37 -0
- package/dist/adapter/rapier-physics-adapter.d.ts +69 -0
- package/dist/adapter/rapier-physics-adapter.d.ts.map +1 -0
- package/dist/adapter/rapier-physics-adapter.js +135 -0
- package/dist/adapter/root-adapter.d.ts +195 -0
- package/dist/adapter/root-adapter.d.ts.map +1 -0
- package/dist/adapter/root-adapter.js +25 -0
- package/dist/adapter/setup-three-root-adapter.d.ts +87 -0
- package/dist/adapter/setup-three-root-adapter.d.ts.map +1 -0
- package/dist/adapter/setup-three-root-adapter.js +791 -0
- package/dist/adapter/system-adapter.d.ts +453 -0
- package/dist/adapter/system-adapter.d.ts.map +1 -0
- package/dist/adapter/system-adapter.js +13 -0
- package/dist/adapter/transform.d.ts +18 -0
- package/dist/adapter/transform.d.ts.map +1 -0
- package/dist/adapter/transform.js +1 -0
- package/dist/ai/navigation.d.ts +78 -0
- package/dist/ai/navigation.d.ts.map +1 -0
- package/dist/ai/navigation.js +152 -0
- package/dist/animation/anim-graph-types.d.ts +25 -0
- package/dist/animation/anim-graph-types.d.ts.map +1 -0
- package/dist/animation/anim-graph-types.js +1 -0
- package/dist/animation/animation-clock.d.ts +213 -0
- package/dist/animation/animation-clock.d.ts.map +1 -0
- package/dist/animation/animation-clock.js +301 -0
- package/dist/animation/blend-node.d.ts +22 -0
- package/dist/animation/blend-node.d.ts.map +1 -0
- package/dist/animation/blend-node.js +97 -0
- package/dist/animation/camera-ownership.d.ts +249 -0
- package/dist/animation/camera-ownership.d.ts.map +1 -0
- package/dist/animation/camera-ownership.js +169 -0
- package/dist/animation/cinematic-cues.d.ts +200 -0
- package/dist/animation/cinematic-cues.d.ts.map +1 -0
- package/dist/animation/cinematic-cues.js +213 -0
- package/dist/animation/clip-map.d.ts +12 -0
- package/dist/animation/clip-map.d.ts.map +1 -0
- package/dist/animation/clip-map.js +31 -0
- package/dist/animation/cubic-spline-interpolant.d.ts +54 -0
- package/dist/animation/cubic-spline-interpolant.d.ts.map +1 -0
- package/dist/animation/cubic-spline-interpolant.js +111 -0
- package/dist/animation/theatre-clock-binding.d.ts +89 -0
- package/dist/animation/theatre-clock-binding.d.ts.map +1 -0
- package/dist/animation/theatre-clock-binding.js +29 -0
- package/dist/animation/theatre-director.d.ts +277 -0
- package/dist/animation/theatre-director.d.ts.map +1 -0
- package/dist/animation/theatre-director.js +248 -0
- package/dist/animation/theatre-object-binding.d.ts +305 -0
- package/dist/animation/theatre-object-binding.d.ts.map +1 -0
- package/dist/animation/theatre-object-binding.js +351 -0
- package/dist/animation/xstate-animation-binding.d.ts +119 -0
- package/dist/animation/xstate-animation-binding.d.ts.map +1 -0
- package/dist/animation/xstate-animation-binding.js +349 -0
- package/dist/animation/xstate-animation-meta.d.ts +266 -0
- package/dist/animation/xstate-animation-meta.d.ts.map +1 -0
- package/dist/animation/xstate-animation-meta.js +252 -0
- package/dist/asset-formats/camera.d.ts +15 -0
- package/dist/asset-formats/camera.d.ts.map +1 -0
- package/dist/asset-formats/camera.js +15 -0
- package/dist/asset-formats/collider.d.ts +21 -0
- package/dist/asset-formats/collider.d.ts.map +1 -0
- package/dist/asset-formats/collider.js +53 -0
- package/dist/asset-formats/index.d.ts +46 -0
- package/dist/asset-formats/index.d.ts.map +1 -0
- package/dist/asset-formats/index.js +36 -0
- package/dist/asset-formats/instances.d.ts +17 -0
- package/dist/asset-formats/instances.d.ts.map +1 -0
- package/dist/asset-formats/instances.js +31 -0
- package/dist/asset-formats/light.d.ts +21 -0
- package/dist/asset-formats/light.d.ts.map +1 -0
- package/dist/asset-formats/light.js +35 -0
- package/dist/asset-formats/material.d.ts +129 -0
- package/dist/asset-formats/material.d.ts.map +1 -0
- package/dist/asset-formats/material.js +88 -0
- package/dist/asset-formats/mesh.d.ts +22 -0
- package/dist/asset-formats/mesh.d.ts.map +1 -0
- package/dist/asset-formats/mesh.js +64 -0
- package/dist/asset-formats/parse.d.ts +20 -0
- package/dist/asset-formats/parse.d.ts.map +1 -0
- package/dist/asset-formats/parse.js +34 -0
- package/dist/asset-formats/particles.d.ts +1390 -0
- package/dist/asset-formats/particles.d.ts.map +1 -0
- package/dist/asset-formats/particles.js +319 -0
- package/dist/asset-formats/render-env.d.ts +387 -0
- package/dist/asset-formats/render-env.d.ts.map +1 -0
- package/dist/asset-formats/render-env.js +300 -0
- package/dist/asset-formats/tuples.d.ts +12 -0
- package/dist/asset-formats/tuples.d.ts.map +1 -0
- package/dist/asset-formats/tuples.js +14 -0
- package/dist/asset-loaders.d.ts +97 -0
- package/dist/asset-loaders.d.ts.map +1 -0
- package/dist/asset-loaders.js +209 -0
- package/dist/asset-parse-error.d.ts +24 -0
- package/dist/asset-parse-error.d.ts.map +1 -0
- package/dist/asset-parse-error.js +29 -0
- package/dist/asset-registry.d.ts +38 -0
- package/dist/asset-registry.d.ts.map +1 -0
- package/dist/asset-registry.js +66 -0
- package/dist/assets.d.ts +26 -0
- package/dist/assets.d.ts.map +1 -0
- package/dist/assets.js +55 -0
- package/dist/audio/wav-encode.d.ts +38 -0
- package/dist/audio/wav-encode.d.ts.map +1 -0
- package/dist/audio/wav-encode.js +97 -0
- package/dist/canvas-react/engine-bridge.d.ts +45 -0
- package/dist/canvas-react/engine-bridge.d.ts.map +1 -0
- package/dist/canvas-react/engine-bridge.js +45 -0
- package/dist/canvas-react/index.d.ts +42 -0
- package/dist/canvas-react/index.d.ts.map +1 -0
- package/dist/canvas-react/index.js +41 -0
- package/dist/canvas-react/pixi-primitive.d.ts +85 -0
- package/dist/canvas-react/pixi-primitive.d.ts.map +1 -0
- package/dist/canvas-react/pixi-primitive.js +181 -0
- package/dist/canvas-react/pixi-react-adapter.d.ts +71 -0
- package/dist/canvas-react/pixi-react-adapter.d.ts.map +1 -0
- package/dist/canvas-react/pixi-react-adapter.js +229 -0
- package/dist/canvas-react/pixi-react-root-factory.d.ts +56 -0
- package/dist/canvas-react/pixi-react-root-factory.d.ts.map +1 -0
- package/dist/canvas-react/pixi-react-root-factory.js +73 -0
- package/dist/canvas-react/world-context.d.ts +88 -0
- package/dist/canvas-react/world-context.d.ts.map +1 -0
- package/dist/canvas-react/world-context.js +212 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +8 -0
- package/dist/core/frame-pacing.d.ts +90 -0
- package/dist/core/frame-pacing.d.ts.map +1 -0
- package/dist/core/frame-pacing.js +89 -0
- package/dist/core/game-loop.d.ts +62 -0
- package/dist/core/game-loop.d.ts.map +1 -0
- package/dist/core/game-loop.js +189 -0
- package/dist/core/seeded-random.d.ts +69 -0
- package/dist/core/seeded-random.d.ts.map +1 -0
- package/dist/core/seeded-random.js +121 -0
- package/dist/core/sim-clock.d.ts +199 -0
- package/dist/core/sim-clock.d.ts.map +1 -0
- package/dist/core/sim-clock.js +291 -0
- package/dist/core/system-runner.d.ts +96 -0
- package/dist/core/system-runner.d.ts.map +1 -0
- package/dist/core/system-runner.js +253 -0
- package/dist/core/types.d.ts +111 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +25 -0
- package/dist/data/data-asset.d.ts +101 -0
- package/dist/data/data-asset.d.ts.map +1 -0
- package/dist/data/data-asset.js +122 -0
- package/dist/data/data-check-core.d.ts +109 -0
- package/dist/data/data-check-core.d.ts.map +1 -0
- package/dist/data/data-check-core.js +177 -0
- package/dist/data/data-ref.d.ts +79 -0
- package/dist/data/data-ref.d.ts.map +1 -0
- package/dist/data/data-ref.js +130 -0
- package/dist/data/vite-plugin-data.d.ts +79 -0
- package/dist/data/vite-plugin-data.d.ts.map +1 -0
- package/dist/data/vite-plugin-data.js +217 -0
- package/dist/defaults.d.ts +233 -0
- package/dist/defaults.d.ts.map +1 -0
- package/dist/defaults.js +137 -0
- package/dist/dev/chrome-trace.d.ts +45 -0
- package/dist/dev/chrome-trace.d.ts.map +1 -0
- package/dist/dev/chrome-trace.js +114 -0
- package/dist/dev/console-bridge.d.ts +22 -0
- package/dist/dev/console-bridge.d.ts.map +1 -0
- package/dist/dev/console-bridge.js +71 -0
- package/dist/dev/debug-draw.d.ts +24 -0
- package/dist/dev/debug-draw.d.ts.map +1 -0
- package/dist/dev/debug-draw.js +73 -0
- package/dist/dev/instruments.d.ts +133 -0
- package/dist/dev/instruments.d.ts.map +1 -0
- package/dist/dev/instruments.js +231 -0
- package/dist/dev/logger.d.ts +30 -0
- package/dist/dev/logger.d.ts.map +1 -0
- package/dist/dev/logger.js +90 -0
- package/dist/dev/performance-profiler.d.ts +111 -0
- package/dist/dev/performance-profiler.d.ts.map +1 -0
- package/dist/dev/performance-profiler.js +215 -0
- package/dist/dev/render-debug-adapter.d.ts +57 -0
- package/dist/dev/render-debug-adapter.d.ts.map +1 -0
- package/dist/dev/render-debug-adapter.js +141 -0
- package/dist/dev/render-memory.d.ts +53 -0
- package/dist/dev/render-memory.d.ts.map +1 -0
- package/dist/dev/render-memory.js +190 -0
- package/dist/dev/webgl-frame-capture.d.ts +134 -0
- package/dist/dev/webgl-frame-capture.d.ts.map +1 -0
- package/dist/dev/webgl-frame-capture.js +270 -0
- package/dist/dev/webgl-gpu-timer.d.ts +8 -0
- package/dist/dev/webgl-gpu-timer.d.ts.map +1 -0
- package/dist/dev/webgl-gpu-timer.js +52 -0
- package/dist/ecs/scene-index.d.ts +179 -0
- package/dist/ecs/scene-index.d.ts.map +1 -0
- package/dist/ecs/scene-index.js +331 -0
- package/dist/ecs/scene-query.d.ts +6 -0
- package/dist/ecs/scene-query.d.ts.map +1 -0
- package/dist/ecs/scene-query.js +40 -0
- package/dist/ecs/user-data.d.ts +193 -0
- package/dist/ecs/user-data.d.ts.map +1 -0
- package/dist/ecs/user-data.js +145 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/input/input-manager.d.ts +944 -0
- package/dist/input/input-manager.d.ts.map +1 -0
- package/dist/input/input-manager.js +2209 -0
- package/dist/input/input-types.d.ts +174 -0
- package/dist/input/input-types.d.ts.map +1 -0
- package/dist/input/input-types.js +1 -0
- package/dist/input/prompt-labels.d.ts +21 -0
- package/dist/input/prompt-labels.d.ts.map +1 -0
- package/dist/input/prompt-labels.js +121 -0
- package/dist/input/rebind-controller.d.ts +59 -0
- package/dist/input/rebind-controller.d.ts.map +1 -0
- package/dist/input/rebind-controller.js +85 -0
- package/dist/input/schema.d.ts +16 -0
- package/dist/input/schema.d.ts.map +1 -0
- package/dist/input/schema.js +228 -0
- package/dist/loader.d.ts +76 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +114 -0
- package/dist/manifest/editor-port.d.ts +53 -0
- package/dist/manifest/editor-port.d.ts.map +1 -0
- package/dist/manifest/editor-port.js +67 -0
- package/dist/manifest/filename.d.ts +14 -0
- package/dist/manifest/filename.d.ts.map +1 -0
- package/dist/manifest/filename.js +43 -0
- package/dist/manifest/index.d.ts +6 -0
- package/dist/manifest/index.d.ts.map +1 -0
- package/dist/manifest/index.js +9 -0
- package/dist/manifest/load-file.d.ts +7 -0
- package/dist/manifest/load-file.d.ts.map +1 -0
- package/dist/manifest/load-file.js +23 -0
- package/dist/manifest/load.d.ts +161 -0
- package/dist/manifest/load.d.ts.map +1 -0
- package/dist/manifest/load.js +269 -0
- package/dist/manifest/locate.d.ts +24 -0
- package/dist/manifest/locate.d.ts.map +1 -0
- package/dist/manifest/locate.js +48 -0
- package/dist/manifest/schema.d.ts +293 -0
- package/dist/manifest/schema.d.ts.map +1 -0
- package/dist/manifest/schema.js +633 -0
- package/dist/physics/collider-dimensions.d.ts +63 -0
- package/dist/physics/collider-dimensions.d.ts.map +1 -0
- package/dist/physics/collider-dimensions.js +98 -0
- package/dist/physics/collision-system.d.ts +41 -0
- package/dist/physics/collision-system.d.ts.map +1 -0
- package/dist/physics/collision-system.js +64 -0
- package/dist/physics/physics-registry.d.ts +45 -0
- package/dist/physics/physics-registry.d.ts.map +1 -0
- package/dist/physics/physics-registry.js +65 -0
- package/dist/physics/transform-writer.d.ts +16 -0
- package/dist/physics/transform-writer.d.ts.map +1 -0
- package/dist/physics/transform-writer.js +38 -0
- package/dist/pixi/authoring.d.ts +93 -0
- package/dist/pixi/authoring.d.ts.map +1 -0
- package/dist/pixi/authoring.js +207 -0
- package/dist/pixi/index.d.ts +16 -0
- package/dist/pixi/index.d.ts.map +1 -0
- package/dist/pixi/index.js +15 -0
- package/dist/pixi/ingest-iframe.d.ts +82 -0
- package/dist/pixi/ingest-iframe.d.ts.map +1 -0
- package/dist/pixi/ingest-iframe.js +166 -0
- package/dist/pixi/ingest.d.ts +97 -0
- package/dist/pixi/ingest.d.ts.map +1 -0
- package/dist/pixi/ingest.js +40 -0
- package/dist/pixi/physics-registry.d.ts +24 -0
- package/dist/pixi/physics-registry.d.ts.map +1 -0
- package/dist/pixi/physics-registry.js +38 -0
- package/dist/pixi/scene-capture.d.ts +43 -0
- package/dist/pixi/scene-capture.d.ts.map +1 -0
- package/dist/pixi/scene-capture.js +92 -0
- package/dist/pixi/system-adapters.d.ts +16 -0
- package/dist/pixi/system-adapters.d.ts.map +1 -0
- package/dist/pixi/system-adapters.js +37 -0
- package/dist/react/unmanaged-root-detector.d.ts +18 -0
- package/dist/react/unmanaged-root-detector.d.ts.map +1 -0
- package/dist/react/unmanaged-root-detector.js +70 -0
- package/dist/react/use-data.d.ts +60 -0
- package/dist/react/use-data.d.ts.map +1 -0
- package/dist/react/use-data.js +101 -0
- package/dist/react/use-selection.d.ts +54 -0
- package/dist/react/use-selection.d.ts.map +1 -0
- package/dist/react/use-selection.js +71 -0
- package/dist/react/world-state.d.ts +154 -0
- package/dist/react/world-state.d.ts.map +1 -0
- package/dist/react/world-state.js +220 -0
- package/dist/render/auto-batcher.d.ts +34 -0
- package/dist/render/auto-batcher.d.ts.map +1 -0
- package/dist/render/auto-batcher.js +140 -0
- package/dist/render/instance-mesh.d.ts +5 -0
- package/dist/render/instance-mesh.d.ts.map +1 -0
- package/dist/render/instance-mesh.js +19 -0
- package/dist/render/light-camera-factory.d.ts +24 -0
- package/dist/render/light-camera-factory.d.ts.map +1 -0
- package/dist/render/light-camera-factory.js +71 -0
- package/dist/render/lod.d.ts +13 -0
- package/dist/render/lod.d.ts.map +1 -0
- package/dist/render/lod.js +16 -0
- package/dist/render/material-factory.d.ts +15 -0
- package/dist/render/material-factory.d.ts.map +1 -0
- package/dist/render/material-factory.js +186 -0
- package/dist/render/mesh-shadow.d.ts +11 -0
- package/dist/render/mesh-shadow.d.ts.map +1 -0
- package/dist/render/mesh-shadow.js +19 -0
- package/dist/render/particles-factory.d.ts +99 -0
- package/dist/render/particles-factory.d.ts.map +1 -0
- package/dist/render/particles-factory.js +361 -0
- package/dist/render/render-batch-system.d.ts +33 -0
- package/dist/render/render-batch-system.d.ts.map +1 -0
- package/dist/render/render-batch-system.js +223 -0
- package/dist/render/render-features.d.ts +47 -0
- package/dist/render/render-features.d.ts.map +1 -0
- package/dist/render/render-features.js +105 -0
- package/dist/render/render-settings.d.ts +35 -0
- package/dist/render/render-settings.d.ts.map +1 -0
- package/dist/render/render-settings.js +51 -0
- package/dist/render/spark-renderer-lifecycle.d.ts +18 -0
- package/dist/render/spark-renderer-lifecycle.d.ts.map +1 -0
- package/dist/render/spark-renderer-lifecycle.js +57 -0
- package/dist/render/viewport-shading.d.ts +17 -0
- package/dist/render/viewport-shading.d.ts.map +1 -0
- package/dist/render/viewport-shading.js +87 -0
- package/dist/runtime/create-runtime.d.ts +259 -0
- package/dist/runtime/create-runtime.d.ts.map +1 -0
- package/dist/runtime/create-runtime.js +666 -0
- package/dist/runtime/debug-bridge.d.ts +288 -0
- package/dist/runtime/debug-bridge.d.ts.map +1 -0
- package/dist/runtime/debug-bridge.js +277 -0
- package/dist/runtime/debug-registry.d.ts +287 -0
- package/dist/runtime/debug-registry.d.ts.map +1 -0
- package/dist/runtime/debug-registry.js +528 -0
- package/dist/runtime/dev-layers.d.ts +34 -0
- package/dist/runtime/dev-layers.d.ts.map +1 -0
- package/dist/runtime/dev-layers.js +40 -0
- package/dist/runtime/frame-selector-cache.d.ts +41 -0
- package/dist/runtime/frame-selector-cache.d.ts.map +1 -0
- package/dist/runtime/frame-selector-cache.js +65 -0
- package/dist/runtime/game.d.ts +576 -0
- package/dist/runtime/game.d.ts.map +1 -0
- package/dist/runtime/game.js +1003 -0
- package/dist/runtime/gameplay-rng-trap.d.ts +47 -0
- package/dist/runtime/gameplay-rng-trap.d.ts.map +1 -0
- package/dist/runtime/gameplay-rng-trap.js +95 -0
- package/dist/runtime/input-router.d.ts +78 -0
- package/dist/runtime/input-router.d.ts.map +1 -0
- package/dist/runtime/input-router.js +171 -0
- package/dist/runtime/mount-game.d.ts +126 -0
- package/dist/runtime/mount-game.d.ts.map +1 -0
- package/dist/runtime/mount-game.js +159 -0
- package/dist/runtime/mount-manifest.d.ts +174 -0
- package/dist/runtime/mount-manifest.d.ts.map +1 -0
- package/dist/runtime/mount-manifest.js +304 -0
- package/dist/runtime/presentation.d.ts +85 -0
- package/dist/runtime/presentation.d.ts.map +1 -0
- package/dist/runtime/presentation.js +92 -0
- package/dist/runtime/render-audio-control.d.ts +126 -0
- package/dist/runtime/render-audio-control.d.ts.map +1 -0
- package/dist/runtime/render-audio-control.js +116 -0
- package/dist/runtime/render-control.d.ts +347 -0
- package/dist/runtime/render-control.d.ts.map +1 -0
- package/dist/runtime/render-control.js +317 -0
- package/dist/runtime/render-seed.d.ts +56 -0
- package/dist/runtime/render-seed.d.ts.map +1 -0
- package/dist/runtime/render-seed.js +73 -0
- package/dist/runtime/state-bridge.d.ts +60 -0
- package/dist/runtime/state-bridge.d.ts.map +1 -0
- package/dist/runtime/state-bridge.js +62 -0
- package/dist/runtime/types.d.ts +285 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/types.js +1 -0
- package/dist/runtime/unexported-game-trap.d.ts +36 -0
- package/dist/runtime/unexported-game-trap.d.ts.map +1 -0
- package/dist/runtime/unexported-game-trap.js +80 -0
- package/dist/setup/setup-audio.d.ts +20 -0
- package/dist/setup/setup-audio.d.ts.map +1 -0
- package/dist/setup/setup-audio.js +41 -0
- package/dist/setup/setup-particles.d.ts +17 -0
- package/dist/setup/setup-particles.d.ts.map +1 -0
- package/dist/setup/setup-particles.js +16 -0
- package/dist/setup/setup-physics.d.ts +25 -0
- package/dist/setup/setup-physics.d.ts.map +1 -0
- package/dist/setup/setup-physics.js +51 -0
- package/dist/setup/setup-renderer.d.ts +82 -0
- package/dist/setup/setup-renderer.d.ts.map +1 -0
- package/dist/setup/setup-renderer.js +381 -0
- package/dist/world3d-react/engine-bridge.d.ts +47 -0
- package/dist/world3d-react/engine-bridge.d.ts.map +1 -0
- package/dist/world3d-react/engine-bridge.js +48 -0
- package/dist/world3d-react/index.d.ts +47 -0
- package/dist/world3d-react/index.d.ts.map +1 -0
- package/dist/world3d-react/index.js +46 -0
- package/dist/world3d-react/r3f-adapter.d.ts +51 -0
- package/dist/world3d-react/r3f-adapter.d.ts.map +1 -0
- package/dist/world3d-react/r3f-adapter.js +368 -0
- package/dist/world3d-react/r3f-root-factory.d.ts +62 -0
- package/dist/world3d-react/r3f-root-factory.d.ts.map +1 -0
- package/dist/world3d-react/r3f-root-factory.js +79 -0
- package/dist/world3d-react/rapier-physics-bridge.d.ts +76 -0
- package/dist/world3d-react/rapier-physics-bridge.d.ts.map +1 -0
- package/dist/world3d-react/rapier-physics-bridge.js +120 -0
- package/dist/world3d-react/renderer-config.d.ts +58 -0
- package/dist/world3d-react/renderer-config.d.ts.map +1 -0
- package/dist/world3d-react/renderer-config.js +96 -0
- package/dist/world3d-react/world-context.d.ts +123 -0
- package/dist/world3d-react/world-context.d.ts.map +1 -0
- package/dist/world3d-react/world-context.js +204 -0
- package/dist-config/config.js +303 -0
- package/dist-config/config.js.map +7 -0
- package/package.json +14 -3
- package/src/adapter/rapier-physics-adapter.ts +77 -34
- package/src/config.ts +8 -0
- package/src/core/frame-pacing.ts +26 -0
- package/src/core/game-loop.ts +4 -3
- package/src/dev/instruments.ts +302 -0
- package/src/setup/setup-renderer.ts +2 -0
- package/src/world3d-react/index.ts +9 -0
- package/src/world3d-react/rapier-physics-bridge.tsx +137 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `file#key` refs — the resolvable half.
|
|
3
|
+
*
|
|
4
|
+
* Cross-asset references (`"enemies#goblin"`, `"tuning#economy.slotGrowth"`)
|
|
5
|
+
* have been DETECTED and VALIDATED since W5 (`data-check-core.ts`'s
|
|
6
|
+
* `DATA_REF_PATTERN` + `findDanglingDataRefs`, enforced by both `vgai doctor`
|
|
7
|
+
* and the build plugin) — but nothing could actually RESOLVE one at runtime,
|
|
8
|
+
* and nothing declared a field AS a ref in its schema (detection was by
|
|
9
|
+
* string-shape convention alone). This module closes both halves:
|
|
10
|
+
*
|
|
11
|
+
* - {@link dataRef} — a typed Zod schema for a ref FIELD. Stamps the emitted
|
|
12
|
+
* JSON Schema with a precise `pattern` (the target stem is baked into the
|
|
13
|
+
* regex, so VS Code validates the prefix for free) and a machine-readable
|
|
14
|
+
* `"x-vgai-ref": target` marker (a Zod `.meta()` that survives
|
|
15
|
+
* `toDataJsonSchema`, including inside a table's `additionalProperties` row
|
|
16
|
+
* schema — no emitter changes needed). The editor's Data panel
|
|
17
|
+
* (`json-schema-fields.ts`'s `'ref'` kind) reads that marker to render a
|
|
18
|
+
* `stem#key` PICKER instead of free text.
|
|
19
|
+
* - {@link getRef} — lazy, read-time resolution. The caller names the target
|
|
20
|
+
* HANDLE explicitly (`getRef(items, goblin.drop)`), so the resolved type is
|
|
21
|
+
* the handle's own row type — no stem→handle registry, no load-order
|
|
22
|
+
* problem, no cycle hazard (nothing walks a graph; two refs resolved when
|
|
23
|
+
* you choose to resolve them isn't a cycle), and it's HMR-correct for free
|
|
24
|
+
* (it reads `target.get()` at CALL time, same doctrine as every other data
|
|
25
|
+
* read — "read every frame", never cache across frames).
|
|
26
|
+
*
|
|
27
|
+
* Deliberately NOT built (and the design note this module's history carries):
|
|
28
|
+
* eager resolution inside `defineData` (would change `get()`'s shipped output
|
|
29
|
+
* type and entangle HMR — an edit to `enemies.data.json` would have to
|
|
30
|
+
* re-notify every OTHER asset that references it), and a global
|
|
31
|
+
* `resolveRef(addressString)` (needs a runtime stem→handle registry that
|
|
32
|
+
* `src/data/assets.ts` — side-effect-free, config-load-time, schemas-only by
|
|
33
|
+
* its own module doc — must not become).
|
|
34
|
+
*/
|
|
35
|
+
import { z } from 'zod';
|
|
36
|
+
import type { DataHandle } from './data-asset';
|
|
37
|
+
/** An asset-stem-tagged `file#key` string — `` `${Stem}#${string}` ``. */
|
|
38
|
+
export type DataRef<Stem extends string = string> = `${Stem}#${string}`;
|
|
39
|
+
/**
|
|
40
|
+
* A Zod schema for a data-asset FIELD that references another asset by
|
|
41
|
+
* `"<target>#<key>(.<field>)*"`. Use it in a `.schema.ts`:
|
|
42
|
+
*
|
|
43
|
+
* ```ts
|
|
44
|
+
* export const EnemyRowSchema = z.object({
|
|
45
|
+
* name: z.string(),
|
|
46
|
+
* drop: dataRef('items'), // -> "items#potion"
|
|
47
|
+
* });
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* The emitted JSON Schema (`toDataJsonSchema`) carries both a precise
|
|
51
|
+
* `pattern` (VS Code validates the target-stem prefix for free) and
|
|
52
|
+
* `"x-vgai-ref": target` (the editor's Data panel picker keys off this).
|
|
53
|
+
* Detection by `data-check-core.ts`'s conventional-string calibration still
|
|
54
|
+
* applies at the VALUE level (a `dataRef` field's actual string still has to
|
|
55
|
+
* look like `target#key` to resolve) — this only makes the field's INTENT
|
|
56
|
+
* declared in the schema, closing the §9.4 "renamed target file silently
|
|
57
|
+
* un-checks its refs" hole for anything that adopts it (see
|
|
58
|
+
* `collectDeclaredRefFields`/`findMissingRefTargets` in `data-check-core.ts`).
|
|
59
|
+
*/
|
|
60
|
+
export declare function dataRef<Stem extends string>(target: Stem): z.ZodType<DataRef<Stem>>;
|
|
61
|
+
/**
|
|
62
|
+
* Resolve a `"target#key(.field)*"` ref against the named target HANDLE,
|
|
63
|
+
* read live (`target.get()` at call time — HMR-correct, no caching across
|
|
64
|
+
* frames, same doctrine as any other data read).
|
|
65
|
+
*
|
|
66
|
+
* `ref`'s stem prefix should name `target`'s own asset — when `target` was
|
|
67
|
+
* built with a `sourcePath` (every `defineData` call populates it), a
|
|
68
|
+
* mismatch throws a teaching error instead of silently walking the wrong
|
|
69
|
+
* handle's data. Without a `sourcePath` (a hand-rolled `DataHandle`, or an
|
|
70
|
+
* older one built before this field existed) the mismatch check is skipped —
|
|
71
|
+
* resolution still proceeds against `target`, since the caller named it
|
|
72
|
+
* explicitly and that's the actual contract.
|
|
73
|
+
*
|
|
74
|
+
* Throws a teaching error naming the ref and the first key-path segment that
|
|
75
|
+
* doesn't resolve (a deleted row, a typo'd key) — never returns `undefined`
|
|
76
|
+
* silently, matching `parseDataJson`'s "errors teach" doctrine (§6.5).
|
|
77
|
+
*/
|
|
78
|
+
export declare function getRef<T>(target: DataHandle<Record<string, T>>, ref: string): T;
|
|
79
|
+
//# sourceMappingURL=data-ref.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-ref.d.ts","sourceRoot":"","sources":["../../src/data/data-ref.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C,0EAA0E;AAC1E,MAAM,MAAM,OAAO,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,IAAI,GAAG,IAAI,IAAI,MAAM,EAAE,CAAC;AAOxE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,OAAO,CAAC,IAAI,SAAS,MAAM,EAAE,MAAM,EAAE,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CASnF;AAcD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,CAoC/E"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `file#key` refs — the resolvable half.
|
|
3
|
+
*
|
|
4
|
+
* Cross-asset references (`"enemies#goblin"`, `"tuning#economy.slotGrowth"`)
|
|
5
|
+
* have been DETECTED and VALIDATED since W5 (`data-check-core.ts`'s
|
|
6
|
+
* `DATA_REF_PATTERN` + `findDanglingDataRefs`, enforced by both `vgai doctor`
|
|
7
|
+
* and the build plugin) — but nothing could actually RESOLVE one at runtime,
|
|
8
|
+
* and nothing declared a field AS a ref in its schema (detection was by
|
|
9
|
+
* string-shape convention alone). This module closes both halves:
|
|
10
|
+
*
|
|
11
|
+
* - {@link dataRef} — a typed Zod schema for a ref FIELD. Stamps the emitted
|
|
12
|
+
* JSON Schema with a precise `pattern` (the target stem is baked into the
|
|
13
|
+
* regex, so VS Code validates the prefix for free) and a machine-readable
|
|
14
|
+
* `"x-vgai-ref": target` marker (a Zod `.meta()` that survives
|
|
15
|
+
* `toDataJsonSchema`, including inside a table's `additionalProperties` row
|
|
16
|
+
* schema — no emitter changes needed). The editor's Data panel
|
|
17
|
+
* (`json-schema-fields.ts`'s `'ref'` kind) reads that marker to render a
|
|
18
|
+
* `stem#key` PICKER instead of free text.
|
|
19
|
+
* - {@link getRef} — lazy, read-time resolution. The caller names the target
|
|
20
|
+
* HANDLE explicitly (`getRef(items, goblin.drop)`), so the resolved type is
|
|
21
|
+
* the handle's own row type — no stem→handle registry, no load-order
|
|
22
|
+
* problem, no cycle hazard (nothing walks a graph; two refs resolved when
|
|
23
|
+
* you choose to resolve them isn't a cycle), and it's HMR-correct for free
|
|
24
|
+
* (it reads `target.get()` at CALL time, same doctrine as every other data
|
|
25
|
+
* read — "read every frame", never cache across frames).
|
|
26
|
+
*
|
|
27
|
+
* Deliberately NOT built (and the design note this module's history carries):
|
|
28
|
+
* eager resolution inside `defineData` (would change `get()`'s shipped output
|
|
29
|
+
* type and entangle HMR — an edit to `enemies.data.json` would have to
|
|
30
|
+
* re-notify every OTHER asset that references it), and a global
|
|
31
|
+
* `resolveRef(addressString)` (needs a runtime stem→handle registry that
|
|
32
|
+
* `src/data/assets.ts` — side-effect-free, config-load-time, schemas-only by
|
|
33
|
+
* its own module doc — must not become).
|
|
34
|
+
*/
|
|
35
|
+
import { z } from 'zod';
|
|
36
|
+
import { DATA_REF_PATTERN } from './data-check-core';
|
|
37
|
+
/** Prefix/key-path grammar a ref must match, parameterized by target stem (mirrors `DATA_REF_PATTERN` in `data-check-core.ts`, minus the alternation — this one is anchored to ONE target). */
|
|
38
|
+
function refPattern(target) {
|
|
39
|
+
return new RegExp(`^${target}#[A-Za-z0-9_-]+(?:\\.[A-Za-z0-9_-]+)*$`);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A Zod schema for a data-asset FIELD that references another asset by
|
|
43
|
+
* `"<target>#<key>(.<field>)*"`. Use it in a `.schema.ts`:
|
|
44
|
+
*
|
|
45
|
+
* ```ts
|
|
46
|
+
* export const EnemyRowSchema = z.object({
|
|
47
|
+
* name: z.string(),
|
|
48
|
+
* drop: dataRef('items'), // -> "items#potion"
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* The emitted JSON Schema (`toDataJsonSchema`) carries both a precise
|
|
53
|
+
* `pattern` (VS Code validates the target-stem prefix for free) and
|
|
54
|
+
* `"x-vgai-ref": target` (the editor's Data panel picker keys off this).
|
|
55
|
+
* Detection by `data-check-core.ts`'s conventional-string calibration still
|
|
56
|
+
* applies at the VALUE level (a `dataRef` field's actual string still has to
|
|
57
|
+
* look like `target#key` to resolve) — this only makes the field's INTENT
|
|
58
|
+
* declared in the schema, closing the §9.4 "renamed target file silently
|
|
59
|
+
* un-checks its refs" hole for anything that adopts it (see
|
|
60
|
+
* `collectDeclaredRefFields`/`findMissingRefTargets` in `data-check-core.ts`).
|
|
61
|
+
*/
|
|
62
|
+
export function dataRef(target) {
|
|
63
|
+
return z
|
|
64
|
+
.string()
|
|
65
|
+
.regex(refPattern(target), {
|
|
66
|
+
message: `must be a "${target}#<key>" reference — ` +
|
|
67
|
+
`expected the target asset stem "${target}", e.g. "${target}#some-key".`,
|
|
68
|
+
})
|
|
69
|
+
.meta({ 'x-vgai-ref': target });
|
|
70
|
+
}
|
|
71
|
+
/** First failing key-path segment, or `null` if the whole path resolves — same walk `data-check-core.ts`'s `firstUnresolvedSegment` does over parsed JSON, here over a live handle's value. */
|
|
72
|
+
function firstMissingSegment(root, keyPath) {
|
|
73
|
+
let node = root;
|
|
74
|
+
for (const segment of keyPath) {
|
|
75
|
+
if (node === null || typeof node !== 'object' || Array.isArray(node) || !(segment in node)) {
|
|
76
|
+
return segment;
|
|
77
|
+
}
|
|
78
|
+
node = node[segment];
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Resolve a `"target#key(.field)*"` ref against the named target HANDLE,
|
|
84
|
+
* read live (`target.get()` at call time — HMR-correct, no caching across
|
|
85
|
+
* frames, same doctrine as any other data read).
|
|
86
|
+
*
|
|
87
|
+
* `ref`'s stem prefix should name `target`'s own asset — when `target` was
|
|
88
|
+
* built with a `sourcePath` (every `defineData` call populates it), a
|
|
89
|
+
* mismatch throws a teaching error instead of silently walking the wrong
|
|
90
|
+
* handle's data. Without a `sourcePath` (a hand-rolled `DataHandle`, or an
|
|
91
|
+
* older one built before this field existed) the mismatch check is skipped —
|
|
92
|
+
* resolution still proceeds against `target`, since the caller named it
|
|
93
|
+
* explicitly and that's the actual contract.
|
|
94
|
+
*
|
|
95
|
+
* Throws a teaching error naming the ref and the first key-path segment that
|
|
96
|
+
* doesn't resolve (a deleted row, a typo'd key) — never returns `undefined`
|
|
97
|
+
* silently, matching `parseDataJson`'s "errors teach" doctrine (§6.5).
|
|
98
|
+
*/
|
|
99
|
+
export function getRef(target, ref) {
|
|
100
|
+
const m = DATA_REF_PATTERN.exec(ref);
|
|
101
|
+
if (!m) {
|
|
102
|
+
throw new Error(`getRef: "${ref}" is not a "file#key" reference — ` +
|
|
103
|
+
'expected a string shaped like "some-file#some-key".');
|
|
104
|
+
}
|
|
105
|
+
const refStem = m[1];
|
|
106
|
+
const keyPathStr = m[2];
|
|
107
|
+
const targetStem = target.sourcePath
|
|
108
|
+
?.split('\\')
|
|
109
|
+
.join('/')
|
|
110
|
+
.split('/')
|
|
111
|
+
.pop()
|
|
112
|
+
?.replace(/\.data\.json$/, '');
|
|
113
|
+
if (targetStem !== undefined && targetStem !== refStem) {
|
|
114
|
+
throw new Error(`getRef: ref "${ref}" names target asset "${refStem}", but the handle passed in is ` +
|
|
115
|
+
`"${targetStem}" (${target.sourcePath}). Pass the handle ` +
|
|
116
|
+
`"${refStem}#..." actually names — getRef(${refStem}, ...), not getRef(${targetStem}, ...).`);
|
|
117
|
+
}
|
|
118
|
+
const keyPath = keyPathStr.split('.');
|
|
119
|
+
const root = target.get();
|
|
120
|
+
const missing = firstMissingSegment(root, keyPath);
|
|
121
|
+
if (missing !== null) {
|
|
122
|
+
throw new Error(`getRef: dangling ref "${ref}" — "${missing}" does not exist` +
|
|
123
|
+
(targetStem ? ` in ${targetStem}.data.json` : '') +
|
|
124
|
+
'. Fix the key or remove the ref (refs are "file#key" strings).');
|
|
125
|
+
}
|
|
126
|
+
let node = root;
|
|
127
|
+
for (const segment of keyPath)
|
|
128
|
+
node = node[segment];
|
|
129
|
+
return node;
|
|
130
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `vgaiDataCheck` — build-path validation for data assets and project tools (the
|
|
3
|
+
* enforcement half of W5). A Vite plugin for the PROJECT's own `vite.config.ts`
|
|
4
|
+
* (the template wires it; the editor dev server boots Vite from the ENGINE's
|
|
5
|
+
* config and never runs this — its surface is covered by `vgai doctor` instead).
|
|
6
|
+
* Build-only (`apply: 'build'`): in dev, `defineData`'s parse-on-load already
|
|
7
|
+
* fails loud in the console.
|
|
8
|
+
*
|
|
9
|
+
* Three checks, all failing the build loud:
|
|
10
|
+
*
|
|
11
|
+
* 1. **Schema integrity** (`buildStart`): every registered asset's
|
|
12
|
+
* `.data.json` is read fresh from disk and validated through
|
|
13
|
+
* {@link parseDataJson} — the EXACT parse `defineData` runs at load (§9.1:
|
|
14
|
+
* an emitted-JSON-Schema validator here could disagree with runtime; the
|
|
15
|
+
* Zod schema itself never can). The schemas arrive EXECUTABLE because
|
|
16
|
+
* `vite.config.ts` statically imports the project's data-asset registry
|
|
17
|
+
* (`src/data/assets.ts` in the template) — Vite's config loader bundles
|
|
18
|
+
* config-relative TS imports, which is what makes this the one build-side
|
|
19
|
+
* place project Zod schemas can run.
|
|
20
|
+
* 2. **Ref integrity** (`buildStart`): every `file#key(.field)*` string in
|
|
21
|
+
* every `src/data/*.data.json` (registered or not) must resolve — shared
|
|
22
|
+
* definition with `vgai doctor` via {@link findDanglingDataRefs}, so the
|
|
23
|
+
* two surfaces can never disagree about what "dangling" means. A second,
|
|
24
|
+
* narrower ref check runs alongside it for REGISTERED assets only: any
|
|
25
|
+
* field declared with `dataRef(target)` (`./data-ref.ts`) whose `target`
|
|
26
|
+
* names no asset currently on disk fails loud too (§9.4's "renamed the
|
|
27
|
+
* target file" hole, closed for declared refs — see
|
|
28
|
+
* `collectDeclaredRefFields`/`findMissingRefTargets` in `data-check-core.ts`).
|
|
29
|
+
* 3. **Tools never ship** (`generateBundle`): no emitted chunk may contain a
|
|
30
|
+
* module from `src/tools/` or a `*.tool.*` file (§4: tester serves and
|
|
31
|
+
* standalone builds strip tools entirely; W4 made this true by
|
|
32
|
+
* construction — nothing imports tools — and this check PINS it against
|
|
33
|
+
* the day some game module imports a tool "just for a helper").
|
|
34
|
+
*
|
|
35
|
+
* Unregistered data files (a `.data.json` with no entry in the passed
|
|
36
|
+
* `assets` list) are a WARNING, not an error: they still get ref-integrity
|
|
37
|
+
* and runtime parse-on-load, but no build-time schema check — the warning
|
|
38
|
+
* names the registry file to fix.
|
|
39
|
+
*/
|
|
40
|
+
import type { Plugin } from 'vite';
|
|
41
|
+
import type { z } from 'zod';
|
|
42
|
+
/** One registered data asset: its executable Zod schema + the project-relative path of its `.data.json`. */
|
|
43
|
+
export interface DataCheckAsset {
|
|
44
|
+
readonly schema: z.ZodType;
|
|
45
|
+
/** e.g. `'src/data/tuning.data.json'` — read fresh from disk at buildStart. */
|
|
46
|
+
readonly sourcePath: string;
|
|
47
|
+
}
|
|
48
|
+
export interface VgaiDataCheckOptions {
|
|
49
|
+
readonly assets: readonly DataCheckAsset[];
|
|
50
|
+
/** Project root the `sourcePath`s resolve against. Default: `process.cwd()` (vite build's cwd). */
|
|
51
|
+
readonly root?: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The fs half of checks 1 + 2, extracted from the plugin hook so it is
|
|
55
|
+
* directly unit-testable against a fixture folder (no rollup context needed).
|
|
56
|
+
*/
|
|
57
|
+
export declare function collectDataCheckProblems(options: VgaiDataCheckOptions): {
|
|
58
|
+
errors: string[];
|
|
59
|
+
warnings: string[];
|
|
60
|
+
};
|
|
61
|
+
/** True iff a bundled module id is tool code that must never ship (§4). Pure, unit-tested. */
|
|
62
|
+
export declare function isToolModuleId(id: string): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Build-path validation plugin — see the module doc. Wire it in the project's
|
|
65
|
+
* `vite.config.ts`, passing the data-asset registry:
|
|
66
|
+
*
|
|
67
|
+
* ```ts
|
|
68
|
+
* import { vgaiDataCheck } from '@vgai/engine/data/vite-plugin-data';
|
|
69
|
+
* import { dataAssets } from './src/data/assets';
|
|
70
|
+
* export default defineConfig({
|
|
71
|
+
* plugins: [vgaiDataCheck({
|
|
72
|
+
* root: __dirname,
|
|
73
|
+
* assets: dataAssets.map((a) => ({ schema: a.schema, sourcePath: `src/data/${a.name}.data.json` })),
|
|
74
|
+
* })],
|
|
75
|
+
* });
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export declare function vgaiDataCheck(options: VgaiDataCheckOptions): Plugin;
|
|
79
|
+
//# sourceMappingURL=vite-plugin-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-plugin-data.d.ts","sourceRoot":"","sources":["../../src/data/vite-plugin-data.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQ7B,4GAA4G;AAC5G,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC;IAC3B,+EAA+E;IAC/E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,CAAC;IAC3C,mGAAmG;IACnG,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAuGD;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,oBAAoB,GAAG;IACvE,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CA2DA;AAED,8FAA8F;AAC9F,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAGlD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAmCnE"}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `vgaiDataCheck` — build-path validation for data assets and project tools (the
|
|
3
|
+
* enforcement half of W5). A Vite plugin for the PROJECT's own `vite.config.ts`
|
|
4
|
+
* (the template wires it; the editor dev server boots Vite from the ENGINE's
|
|
5
|
+
* config and never runs this — its surface is covered by `vgai doctor` instead).
|
|
6
|
+
* Build-only (`apply: 'build'`): in dev, `defineData`'s parse-on-load already
|
|
7
|
+
* fails loud in the console.
|
|
8
|
+
*
|
|
9
|
+
* Three checks, all failing the build loud:
|
|
10
|
+
*
|
|
11
|
+
* 1. **Schema integrity** (`buildStart`): every registered asset's
|
|
12
|
+
* `.data.json` is read fresh from disk and validated through
|
|
13
|
+
* {@link parseDataJson} — the EXACT parse `defineData` runs at load (§9.1:
|
|
14
|
+
* an emitted-JSON-Schema validator here could disagree with runtime; the
|
|
15
|
+
* Zod schema itself never can). The schemas arrive EXECUTABLE because
|
|
16
|
+
* `vite.config.ts` statically imports the project's data-asset registry
|
|
17
|
+
* (`src/data/assets.ts` in the template) — Vite's config loader bundles
|
|
18
|
+
* config-relative TS imports, which is what makes this the one build-side
|
|
19
|
+
* place project Zod schemas can run.
|
|
20
|
+
* 2. **Ref integrity** (`buildStart`): every `file#key(.field)*` string in
|
|
21
|
+
* every `src/data/*.data.json` (registered or not) must resolve — shared
|
|
22
|
+
* definition with `vgai doctor` via {@link findDanglingDataRefs}, so the
|
|
23
|
+
* two surfaces can never disagree about what "dangling" means. A second,
|
|
24
|
+
* narrower ref check runs alongside it for REGISTERED assets only: any
|
|
25
|
+
* field declared with `dataRef(target)` (`./data-ref.ts`) whose `target`
|
|
26
|
+
* names no asset currently on disk fails loud too (§9.4's "renamed the
|
|
27
|
+
* target file" hole, closed for declared refs — see
|
|
28
|
+
* `collectDeclaredRefFields`/`findMissingRefTargets` in `data-check-core.ts`).
|
|
29
|
+
* 3. **Tools never ship** (`generateBundle`): no emitted chunk may contain a
|
|
30
|
+
* module from `src/tools/` or a `*.tool.*` file (§4: tester serves and
|
|
31
|
+
* standalone builds strip tools entirely; W4 made this true by
|
|
32
|
+
* construction — nothing imports tools — and this check PINS it against
|
|
33
|
+
* the day some game module imports a tool "just for a helper").
|
|
34
|
+
*
|
|
35
|
+
* Unregistered data files (a `.data.json` with no entry in the passed
|
|
36
|
+
* `assets` list) are a WARNING, not an error: they still get ref-integrity
|
|
37
|
+
* and runtime parse-on-load, but no build-time schema check — the warning
|
|
38
|
+
* names the registry file to fix.
|
|
39
|
+
*/
|
|
40
|
+
import { readdirSync, readFileSync, statSync } from 'node:fs';
|
|
41
|
+
import { join, relative } from 'node:path';
|
|
42
|
+
import { parseDataJson, toDataJsonSchema } from './data-asset';
|
|
43
|
+
import { collectDeclaredRefFields, findDanglingDataRefs, findMissingRefTargets, } from './data-check-core';
|
|
44
|
+
/** Recursively collect `*.data.json` under `dir` (absent dir → empty — a project with no data assets builds fine). */
|
|
45
|
+
function findDataFiles(dir) {
|
|
46
|
+
let entries;
|
|
47
|
+
try {
|
|
48
|
+
entries = readdirSync(dir);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
const out = [];
|
|
54
|
+
for (const entry of entries) {
|
|
55
|
+
const full = join(dir, entry);
|
|
56
|
+
if (statSync(full).isDirectory())
|
|
57
|
+
out.push(...findDataFiles(full));
|
|
58
|
+
else if (entry.endsWith('.data.json'))
|
|
59
|
+
out.push(full);
|
|
60
|
+
}
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
/** `src/data/tuning.data.json` → `tuning` (normalizing either slash direction). */
|
|
64
|
+
function assetStem(sourcePath) {
|
|
65
|
+
const rel = sourcePath.split('\\').join('/');
|
|
66
|
+
return (rel
|
|
67
|
+
.split('/')
|
|
68
|
+
.pop()
|
|
69
|
+
?.replace(/\.data\.json$/, '') ?? rel);
|
|
70
|
+
}
|
|
71
|
+
function parseAllDataFiles(root, registered, errors, warnings) {
|
|
72
|
+
const parsedByStem = new Map();
|
|
73
|
+
const pathsByStem = new Map();
|
|
74
|
+
for (const abs of findDataFiles(join(root, 'src', 'data'))) {
|
|
75
|
+
const rel = relative(root, abs).split('\\').join('/');
|
|
76
|
+
const stem = assetStem(rel);
|
|
77
|
+
const paths = pathsByStem.get(stem);
|
|
78
|
+
if (paths)
|
|
79
|
+
paths.push(rel);
|
|
80
|
+
else
|
|
81
|
+
pathsByStem.set(stem, [rel]);
|
|
82
|
+
try {
|
|
83
|
+
parsedByStem.set(stem, JSON.parse(readFileSync(abs, 'utf-8')));
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
errors.push(`"${rel}" is not valid JSON: ${err instanceof Error ? err.message : String(err)}`);
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (!registered.has(rel)) {
|
|
90
|
+
warnings.push(`"${rel}" is not registered in the data-asset registry (src/data/assets.ts), so it gets ` +
|
|
91
|
+
'no build-time schema check (runtime parse-on-load still applies). Register it there — ' +
|
|
92
|
+
'the template ships the worked example.');
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const ambiguousStems = new Set();
|
|
96
|
+
for (const [stem, paths] of pathsByStem) {
|
|
97
|
+
if (paths.length < 2)
|
|
98
|
+
continue;
|
|
99
|
+
ambiguousStems.add(stem);
|
|
100
|
+
errors.push(`asset stem "${stem}" is claimed by ${paths.length} files (${paths.join(', ')}) — ` +
|
|
101
|
+
'"file#key" refs and the data-asset registry address a file by its stem alone (§2.2), so ' +
|
|
102
|
+
'this is an unresolvable identity collision. Rename one — asset stems must be unique ' +
|
|
103
|
+
'across the whole project, not just per directory.');
|
|
104
|
+
parsedByStem.delete(stem); // arbitrary otherwise — neither check below may resolve through it
|
|
105
|
+
}
|
|
106
|
+
return { parsedByStem, ambiguousStems };
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The fs half of checks 1 + 2, extracted from the plugin hook so it is
|
|
110
|
+
* directly unit-testable against a fixture folder (no rollup context needed).
|
|
111
|
+
*/
|
|
112
|
+
export function collectDataCheckProblems(options) {
|
|
113
|
+
const root = options.root ?? process.cwd();
|
|
114
|
+
const errors = [];
|
|
115
|
+
const warnings = [];
|
|
116
|
+
const registered = new Set(options.assets.map((a) => a.sourcePath.split('\\').join('/')));
|
|
117
|
+
const { parsedByStem, ambiguousStems } = parseAllDataFiles(root, registered, errors, warnings);
|
|
118
|
+
// Check 1 — registered assets validate through the exact runtime parse.
|
|
119
|
+
for (const asset of options.assets) {
|
|
120
|
+
const rel = asset.sourcePath.split('\\').join('/');
|
|
121
|
+
if (!parsedByStem.has(assetStem(rel))) {
|
|
122
|
+
// An AMBIGUOUS stem already has its own duplicate-stem error above,
|
|
123
|
+
// which fully explains why there's no single payload to validate
|
|
124
|
+
// against — a second "not found on disk" here would just be
|
|
125
|
+
// confusing noise about a file that plainly IS on disk.
|
|
126
|
+
if (!ambiguousStems.has(assetStem(rel))) {
|
|
127
|
+
errors.push(`registered data asset "${rel}" was not found on disk — fix the path in the registry ` +
|
|
128
|
+
'(src/data/assets.ts) or restore the file.');
|
|
129
|
+
}
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
parseDataJson(asset.schema, parsedByStem.get(assetStem(rel)), rel);
|
|
134
|
+
}
|
|
135
|
+
catch (err) {
|
|
136
|
+
errors.push(err instanceof Error ? err.message : String(err));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// Check 2 — no dangling refs anywhere.
|
|
140
|
+
for (const dangling of findDanglingDataRefs(parsedByStem)) {
|
|
141
|
+
errors.push(`dangling data ref in "src/data/${dangling.inAsset}.data.json" at ${dangling.atPath}: ` +
|
|
142
|
+
`"${dangling.ref}" — "${dangling.missingSegment}" does not exist in ` +
|
|
143
|
+
`src/data/${dangling.targetAsset}.data.json. Fix the key or remove the ref ` +
|
|
144
|
+
'(refs are "file#key" strings).');
|
|
145
|
+
}
|
|
146
|
+
// Check 2b — every declared `dataRef(target)` field (registered assets
|
|
147
|
+
// only, same set check 1 already validates) must name a target that's
|
|
148
|
+
// actually on disk — the §9.4 fix: this fires even if NO current value
|
|
149
|
+
// happens to look like a ref, unlike check 2 above (see
|
|
150
|
+
// `data-check-core.ts`'s module doc).
|
|
151
|
+
const assetNames = new Set(parsedByStem.keys());
|
|
152
|
+
for (const asset of options.assets) {
|
|
153
|
+
const rel = asset.sourcePath.split('\\').join('/');
|
|
154
|
+
const declared = collectDeclaredRefFields(toDataJsonSchema(asset.schema));
|
|
155
|
+
for (const missing of findMissingRefTargets(declared, assetNames)) {
|
|
156
|
+
errors.push(`"${rel}" declares field "${missing.fieldPath}" as dataRef('${missing.targetStem}'), but ` +
|
|
157
|
+
`no "src/data/${missing.targetStem}.data.json" exists. Restore/rename the target file, ` +
|
|
158
|
+
`or update the dataRef('${missing.targetStem}') call in the schema.`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return { errors, warnings };
|
|
162
|
+
}
|
|
163
|
+
/** True iff a bundled module id is tool code that must never ship (§4). Pure, unit-tested. */
|
|
164
|
+
export function isToolModuleId(id) {
|
|
165
|
+
const normalized = id.split('\\').join('/');
|
|
166
|
+
return /\/src\/tools\//.test(normalized) || /\.tool\.[tj]sx?(\?|$)/.test(normalized);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Build-path validation plugin — see the module doc. Wire it in the project's
|
|
170
|
+
* `vite.config.ts`, passing the data-asset registry:
|
|
171
|
+
*
|
|
172
|
+
* ```ts
|
|
173
|
+
* import { vgaiDataCheck } from '@vgai/engine/data/vite-plugin-data';
|
|
174
|
+
* import { dataAssets } from './src/data/assets';
|
|
175
|
+
* export default defineConfig({
|
|
176
|
+
* plugins: [vgaiDataCheck({
|
|
177
|
+
* root: __dirname,
|
|
178
|
+
* assets: dataAssets.map((a) => ({ schema: a.schema, sourcePath: `src/data/${a.name}.data.json` })),
|
|
179
|
+
* })],
|
|
180
|
+
* });
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
export function vgaiDataCheck(options) {
|
|
184
|
+
return {
|
|
185
|
+
name: 'vgai:data-check',
|
|
186
|
+
apply: 'build',
|
|
187
|
+
buildStart() {
|
|
188
|
+
const { errors, warnings } = collectDataCheckProblems(options);
|
|
189
|
+
for (const warning of warnings)
|
|
190
|
+
this.warn(warning);
|
|
191
|
+
if (errors.length > 0) {
|
|
192
|
+
// ONE error carrying every problem — fail loud with the full picture,
|
|
193
|
+
// not a fix-one-rebuild-see-the-next loop.
|
|
194
|
+
this.error(`data-asset validation failed (${errors.length} problem${errors.length === 1 ? '' : 's'}` +
|
|
195
|
+
`):\n${errors.map((e) => ` - ${e}`).join('\n')}`);
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
generateBundle(_outputOptions, bundle) {
|
|
199
|
+
const leaked = new Set();
|
|
200
|
+
for (const output of Object.values(bundle)) {
|
|
201
|
+
if (output.type !== 'chunk')
|
|
202
|
+
continue;
|
|
203
|
+
for (const id of Object.keys(output.modules)) {
|
|
204
|
+
if (isToolModuleId(id))
|
|
205
|
+
leaked.add(id.split('\\').join('/'));
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (leaked.size > 0) {
|
|
209
|
+
this.error('project tool code reached the game build — tools are editor-only and must never ship ' +
|
|
210
|
+
'to players. Remove every game-code import of these ' +
|
|
211
|
+
`modules (tools may import game code, never the reverse):\n${[...leaked]
|
|
212
|
+
.map((id) => ` - ${id}`)
|
|
213
|
+
.join('\n')}`);
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
}
|