@vgai/engine 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/adapter/authoring.d.ts +404 -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 +43 -0
- package/dist/adapter/colyseus-networking-adapter.d.ts.map +1 -0
- package/dist/adapter/colyseus-networking-adapter.js +38 -0
- package/dist/adapter/first-party-systems.d.ts +38 -0
- package/dist/adapter/first-party-systems.d.ts.map +1 -0
- package/dist/adapter/first-party-systems.js +77 -0
- package/dist/adapter/game-adapter.d.ts +133 -0
- package/dist/adapter/game-adapter.d.ts.map +1 -0
- package/dist/adapter/game-adapter.js +10 -0
- package/dist/adapter/host-context.d.ts +73 -0
- package/dist/adapter/host-context.d.ts.map +1 -0
- package/dist/adapter/host-context.js +16 -0
- package/dist/adapter/index.d.ts +22 -0
- package/dist/adapter/index.d.ts.map +1 -0
- package/dist/adapter/index.js +15 -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/overlay-applier.d.ts +118 -0
- package/dist/adapter/ingest/overlay-applier.d.ts.map +1 -0
- package/dist/adapter/ingest/overlay-applier.js +132 -0
- package/dist/adapter/ingest/overlay-apply.d.ts +60 -0
- package/dist/adapter/ingest/overlay-apply.d.ts.map +1 -0
- package/dist/adapter/ingest/overlay-apply.js +101 -0
- package/dist/adapter/ingest/overlay-file.d.ts +79 -0
- package/dist/adapter/ingest/overlay-file.d.ts.map +1 -0
- package/dist/adapter/ingest/overlay-file.js +66 -0
- package/dist/adapter/ingest/overlay-report.d.ts +113 -0
- package/dist/adapter/ingest/overlay-report.d.ts.map +1 -0
- package/dist/adapter/ingest/overlay-report.js +103 -0
- package/dist/adapter/ingest/scene-capture.d.ts +97 -0
- package/dist/adapter/ingest/scene-capture.d.ts.map +1 -0
- package/dist/adapter/ingest/scene-capture.js +248 -0
- package/dist/adapter/ingest/upstream-pin.d.ts +47 -0
- package/dist/adapter/ingest/upstream-pin.d.ts.map +1 -0
- package/dist/adapter/ingest/upstream-pin.js +50 -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 +12 -0
- package/dist/adapter/rapier-physics-adapter.d.ts.map +1 -0
- package/dist/adapter/rapier-physics-adapter.js +46 -0
- package/dist/adapter/system-adapter.d.ts +133 -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/adapter/vgai-scene-game-adapter.d.ts +116 -0
- package/dist/adapter/vgai-scene-game-adapter.d.ts.map +1 -0
- package/dist/adapter/vgai-scene-game-adapter.js +714 -0
- package/dist/adapter/world-kind.d.ts +30 -0
- package/dist/adapter/world-kind.d.ts.map +1 -0
- package/dist/adapter/world-kind.js +18 -0
- package/dist/ai/navigation.d.ts +64 -0
- package/dist/ai/navigation.d.ts.map +1 -0
- package/dist/ai/navigation.js +133 -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 +250 -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 +37 -0
- package/dist/animation/gsap-registration.d.ts +119 -0
- package/dist/animation/gsap-registration.d.ts.map +1 -0
- package/dist/animation/gsap-registration.js +92 -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 +242 -0
- package/dist/animation/theatre-director.d.ts.map +1 -0
- package/dist/animation/theatre-director.js +235 -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 +111 -0
- package/dist/animation/xstate-animation-binding.d.ts.map +1 -0
- package/dist/animation/xstate-animation-binding.js +307 -0
- package/dist/animation/xstate-animation-meta.d.ts +228 -0
- package/dist/animation/xstate-animation-meta.d.ts.map +1 -0
- package/dist/animation/xstate-animation-meta.js +221 -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/index.d.ts +4 -0
- package/dist/audio/index.d.ts.map +1 -0
- package/dist/audio/index.js +24 -0
- package/dist/audio/tone-clock-binding.d.ts +75 -0
- package/dist/audio/tone-clock-binding.d.ts.map +1 -0
- package/dist/audio/tone-clock-binding.js +29 -0
- package/dist/audio/tone-context.d.ts +114 -0
- package/dist/audio/tone-context.d.ts.map +1 -0
- package/dist/audio/tone-context.js +39 -0
- package/dist/audio/tone-offline-render.d.ts +90 -0
- package/dist/audio/tone-offline-render.d.ts.map +1 -0
- package/dist/audio/tone-offline-render.js +56 -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/core/game-loop.d.ts +21 -0
- package/dist/core/game-loop.d.ts.map +1 -0
- package/dist/core/game-loop.js +130 -0
- package/dist/core/system-runner.d.ts +120 -0
- package/dist/core/system-runner.d.ts.map +1 -0
- package/dist/core/system-runner.js +286 -0
- package/dist/core/types.d.ts +58 -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 +110 -0
- package/dist/data/data-check-core.d.ts.map +1 -0
- package/dist/data/data-check-core.js +178 -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/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/logger.d.ts +30 -0
- package/dist/dev/logger.d.ts.map +1 -0
- package/dist/dev/logger.js +90 -0
- package/dist/ecs/component-manager.d.ts +189 -0
- package/dist/ecs/component-manager.d.ts.map +1 -0
- package/dist/ecs/component-manager.js +676 -0
- package/dist/ecs/game-component.d.ts +97 -0
- package/dist/ecs/game-component.d.ts.map +1 -0
- package/dist/ecs/game-component.js +80 -0
- package/dist/ecs/hmr-swap-report.d.ts +53 -0
- package/dist/ecs/hmr-swap-report.d.ts.map +1 -0
- package/dist/ecs/hmr-swap-report.js +55 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/input/input-manager.d.ts +596 -0
- package/dist/input/input-manager.d.ts.map +1 -0
- package/dist/input/input-manager.js +1564 -0
- package/dist/input/input-types.d.ts +171 -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 +43 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +59 -0
- package/dist/manifest/index.d.ts +5 -0
- package/dist/manifest/index.d.ts.map +1 -0
- package/dist/manifest/index.js +8 -0
- package/dist/manifest/load-file.d.ts +4 -0
- package/dist/manifest/load-file.d.ts.map +1 -0
- package/dist/manifest/load-file.js +14 -0
- package/dist/manifest/load.d.ts +117 -0
- package/dist/manifest/load.d.ts.map +1 -0
- package/dist/manifest/load.js +255 -0
- package/dist/manifest/schema.d.ts +173 -0
- package/dist/manifest/schema.d.ts.map +1 -0
- package/dist/manifest/schema.js +302 -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/physics/trigger-dispatch.d.ts +24 -0
- package/dist/physics/trigger-dispatch.d.ts.map +1 -0
- package/dist/physics/trigger-dispatch.js +80 -0
- package/dist/react/game-state.d.ts +105 -0
- package/dist/react/game-state.d.ts.map +1 -0
- package/dist/react/game-state.js +144 -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 +96 -0
- package/dist/react/use-selection.d.ts +75 -0
- package/dist/react/use-selection.d.ts.map +1 -0
- package/dist/react/use-selection.js +90 -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/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 +230 -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 +36 -0
- package/dist/render/render-settings.d.ts.map +1 -0
- package/dist/render/render-settings.js +51 -0
- package/dist/runtime/create-runtime.d.ts +280 -0
- package/dist/runtime/create-runtime.d.ts.map +1 -0
- package/dist/runtime/create-runtime.js +795 -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 +433 -0
- package/dist/runtime/game.d.ts.map +1 -0
- package/dist/runtime/game.js +569 -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 +129 -0
- package/dist/runtime/mount-game.d.ts.map +1 -0
- package/dist/runtime/mount-game.js +152 -0
- package/dist/runtime/mount-manifest.d.ts +119 -0
- package/dist/runtime/mount-manifest.d.ts.map +1 -0
- package/dist/runtime/mount-manifest.js +204 -0
- package/dist/runtime/render-audio-control.d.ts +110 -0
- package/dist/runtime/render-audio-control.d.ts.map +1 -0
- package/dist/runtime/render-audio-control.js +111 -0
- package/dist/runtime/render-control.d.ts +291 -0
- package/dist/runtime/render-control.d.ts.map +1 -0
- package/dist/runtime/render-control.js +264 -0
- package/dist/runtime/render-seed.d.ts +57 -0
- package/dist/runtime/render-seed.d.ts.map +1 -0
- package/dist/runtime/render-seed.js +74 -0
- package/dist/runtime/scene-ui-bridge.d.ts +69 -0
- package/dist/runtime/scene-ui-bridge.d.ts.map +1 -0
- package/dist/runtime/scene-ui-bridge.js +23 -0
- package/dist/runtime/scene-ui-data.d.ts +13 -0
- package/dist/runtime/scene-ui-data.d.ts.map +1 -0
- package/dist/runtime/scene-ui-data.js +92 -0
- package/dist/runtime/state-bridge.d.ts +47 -0
- package/dist/runtime/state-bridge.d.ts.map +1 -0
- package/dist/runtime/state-bridge.js +53 -0
- package/dist/runtime/types.d.ts +179 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/types.js +1 -0
- package/dist/scene/asset-loaders.d.ts +79 -0
- package/dist/scene/asset-loaders.d.ts.map +1 -0
- package/dist/scene/asset-loaders.js +141 -0
- package/dist/scene/asset-paths.d.ts +11 -0
- package/dist/scene/asset-paths.d.ts.map +1 -0
- package/dist/scene/asset-paths.js +108 -0
- package/dist/scene/asset-ref-check.d.ts +88 -0
- package/dist/scene/asset-ref-check.d.ts.map +1 -0
- package/dist/scene/asset-ref-check.js +214 -0
- package/dist/scene/asset-registry.d.ts +30 -0
- package/dist/scene/asset-registry.d.ts.map +1 -0
- package/dist/scene/asset-registry.js +50 -0
- package/dist/scene/collider-dimensions.d.ts +63 -0
- package/dist/scene/collider-dimensions.d.ts.map +1 -0
- package/dist/scene/collider-dimensions.js +98 -0
- package/dist/scene/component-registry.d.ts +17 -0
- package/dist/scene/component-registry.d.ts.map +1 -0
- package/dist/scene/component-registry.js +28 -0
- package/dist/scene/defaults.d.ts +252 -0
- package/dist/scene/defaults.d.ts.map +1 -0
- package/dist/scene/defaults.js +151 -0
- package/dist/scene/geometries/index.d.ts +8 -0
- package/dist/scene/geometries/index.d.ts.map +1 -0
- package/dist/scene/geometries/index.js +7 -0
- package/dist/scene/geometries/terrain.d.ts +2 -0
- package/dist/scene/geometries/terrain.d.ts.map +1 -0
- package/dist/scene/geometries/terrain.js +37 -0
- package/dist/scene/geometry-registry.d.ts +24 -0
- package/dist/scene/geometry-registry.d.ts.map +1 -0
- package/dist/scene/geometry-registry.js +20 -0
- package/dist/scene/instance-registry.d.ts +36 -0
- package/dist/scene/instance-registry.d.ts.map +1 -0
- package/dist/scene/instance-registry.js +55 -0
- package/dist/scene/instancers/grid.d.ts +2 -0
- package/dist/scene/instancers/grid.d.ts.map +1 -0
- package/dist/scene/instancers/grid.js +36 -0
- package/dist/scene/instancers/index.d.ts +8 -0
- package/dist/scene/instancers/index.d.ts.map +1 -0
- package/dist/scene/instancers/index.js +7 -0
- package/dist/scene/light-camera-factory.d.ts +23 -0
- package/dist/scene/light-camera-factory.d.ts.map +1 -0
- package/dist/scene/light-camera-factory.js +68 -0
- package/dist/scene/material-factory.d.ts +17 -0
- package/dist/scene/material-factory.d.ts.map +1 -0
- package/dist/scene/material-factory.js +197 -0
- package/dist/scene/material-registry.d.ts +40 -0
- package/dist/scene/material-registry.d.ts.map +1 -0
- package/dist/scene/material-registry.js +44 -0
- package/dist/scene/materials/index.d.ts +8 -0
- package/dist/scene/materials/index.d.ts.map +1 -0
- package/dist/scene/materials/index.js +7 -0
- package/dist/scene/materials/water.d.ts +2 -0
- package/dist/scene/materials/water.d.ts.map +1 -0
- package/dist/scene/materials/water.js +54 -0
- package/dist/scene/parse.d.ts +23 -0
- package/dist/scene/parse.d.ts.map +1 -0
- package/dist/scene/parse.js +179 -0
- package/dist/scene/particles-factory.d.ts +33 -0
- package/dist/scene/particles-factory.d.ts.map +1 -0
- package/dist/scene/particles-factory.js +282 -0
- package/dist/scene/scene-apply.d.ts +109 -0
- package/dist/scene/scene-apply.d.ts.map +1 -0
- package/dist/scene/scene-apply.js +326 -0
- package/dist/scene/scene-diff-schema.d.ts +285 -0
- package/dist/scene/scene-diff-schema.d.ts.map +1 -0
- package/dist/scene/scene-diff-schema.js +92 -0
- package/dist/scene/scene-diff-types.d.ts +40 -0
- package/dist/scene/scene-diff-types.d.ts.map +1 -0
- package/dist/scene/scene-diff-types.js +14 -0
- package/dist/scene/scene-loader.d.ts +177 -0
- package/dist/scene/scene-loader.d.ts.map +1 -0
- package/dist/scene/scene-loader.js +1213 -0
- package/dist/scene/scene-query.d.ts +11 -0
- package/dist/scene/scene-query.d.ts.map +1 -0
- package/dist/scene/scene-query.js +63 -0
- package/dist/scene/scene-types.d.ts +10 -0
- package/dist/scene/scene-types.d.ts.map +1 -0
- package/dist/scene/scene-types.js +8 -0
- package/dist/scene/scene-version.d.ts +26 -0
- package/dist/scene/scene-version.d.ts.map +1 -0
- package/dist/scene/scene-version.js +34 -0
- package/dist/scene/schema/animation.d.ts +8 -0
- package/dist/scene/schema/animation.d.ts.map +1 -0
- package/dist/scene/schema/animation.js +42 -0
- package/dist/scene/schema/audio.d.ts +13 -0
- package/dist/scene/schema/audio.d.ts.map +1 -0
- package/dist/scene/schema/audio.js +22 -0
- package/dist/scene/schema/camera.d.ts +28 -0
- package/dist/scene/schema/camera.d.ts.map +1 -0
- package/dist/scene/schema/camera.js +17 -0
- package/dist/scene/schema/collider.d.ts +40 -0
- package/dist/scene/schema/collider.d.ts.map +1 -0
- package/dist/scene/schema/collider.js +55 -0
- package/dist/scene/schema/entity-ref.d.ts +31 -0
- package/dist/scene/schema/entity-ref.d.ts.map +1 -0
- package/dist/scene/schema/entity-ref.js +61 -0
- package/dist/scene/schema/entity.d.ts +1036 -0
- package/dist/scene/schema/entity.d.ts.map +1 -0
- package/dist/scene/schema/entity.js +153 -0
- package/dist/scene/schema/environment.d.ts +425 -0
- package/dist/scene/schema/environment.d.ts.map +1 -0
- package/dist/scene/schema/environment.js +357 -0
- package/dist/scene/schema/index.d.ts +39 -0
- package/dist/scene/schema/index.d.ts.map +1 -0
- package/dist/scene/schema/index.js +20 -0
- package/dist/scene/schema/instances.d.ts +14 -0
- package/dist/scene/schema/instances.d.ts.map +1 -0
- package/dist/scene/schema/instances.js +28 -0
- package/dist/scene/schema/joint.d.ts +23 -0
- package/dist/scene/schema/joint.d.ts.map +1 -0
- package/dist/scene/schema/joint.js +23 -0
- package/dist/scene/schema/light.d.ts +38 -0
- package/dist/scene/schema/light.d.ts.map +1 -0
- package/dist/scene/schema/light.js +26 -0
- package/dist/scene/schema/material.d.ts +199 -0
- package/dist/scene/schema/material.d.ts.map +1 -0
- package/dist/scene/schema/material.js +99 -0
- package/dist/scene/schema/mesh.d.ts +48 -0
- package/dist/scene/schema/mesh.d.ts.map +1 -0
- package/dist/scene/schema/mesh.js +82 -0
- package/dist/scene/schema/particles.d.ts +2178 -0
- package/dist/scene/schema/particles.d.ts.map +1 -0
- package/dist/scene/schema/particles.js +321 -0
- package/dist/scene/schema/physics.d.ts +56 -0
- package/dist/scene/schema/physics.d.ts.map +1 -0
- package/dist/scene/schema/physics.js +37 -0
- package/dist/scene/schema/scene-file.d.ts +304 -0
- package/dist/scene/schema/scene-file.d.ts.map +1 -0
- package/dist/scene/schema/scene-file.js +262 -0
- package/dist/scene/schema/shadow.d.ts +28 -0
- package/dist/scene/schema/shadow.d.ts.map +1 -0
- package/dist/scene/schema/shadow.js +20 -0
- package/dist/scene/schema/spline.d.ts +25 -0
- package/dist/scene/schema/spline.d.ts.map +1 -0
- package/dist/scene/schema/spline.js +15 -0
- package/dist/scene/schema/tuples.d.ts +12 -0
- package/dist/scene/schema/tuples.d.ts.map +1 -0
- package/dist/scene/schema/tuples.js +14 -0
- package/dist/scene/schema/ui.d.ts +880 -0
- package/dist/scene/schema/ui.d.ts.map +1 -0
- package/dist/scene/schema/ui.js +506 -0
- package/dist/scene/user-data.d.ts +171 -0
- package/dist/scene/user-data.d.ts.map +1 -0
- package/dist/scene/user-data.js +137 -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 +69 -0
- package/dist/setup/setup-renderer.d.ts.map +1 -0
- package/dist/setup/setup-renderer.js +363 -0
- package/dist/tools/define-tool.d.ts +105 -0
- package/dist/tools/define-tool.d.ts.map +1 -0
- package/dist/tools/define-tool.js +82 -0
- package/dist/world2d/authoring-2d.d.ts +76 -0
- package/dist/world2d/authoring-2d.d.ts.map +1 -0
- package/dist/world2d/authoring-2d.js +176 -0
- package/dist/world2d/capture-to-scene2d.d.ts +5 -0
- package/dist/world2d/capture-to-scene2d.d.ts.map +1 -0
- package/dist/world2d/capture-to-scene2d.js +49 -0
- package/dist/world2d/collision-2d.d.ts +52 -0
- package/dist/world2d/collision-2d.d.ts.map +1 -0
- package/dist/world2d/collision-2d.js +70 -0
- package/dist/world2d/components-2d.d.ts +47 -0
- package/dist/world2d/components-2d.d.ts.map +1 -0
- package/dist/world2d/components-2d.js +77 -0
- package/dist/world2d/index.d.ts +34 -0
- package/dist/world2d/index.d.ts.map +1 -0
- package/dist/world2d/index.js +32 -0
- package/dist/world2d/ingest-iframe-2d.d.ts +82 -0
- package/dist/world2d/ingest-iframe-2d.d.ts.map +1 -0
- package/dist/world2d/ingest-iframe-2d.js +166 -0
- package/dist/world2d/ingest2d.d.ts +97 -0
- package/dist/world2d/ingest2d.d.ts.map +1 -0
- package/dist/world2d/ingest2d.js +40 -0
- package/dist/world2d/physics2d-registry.d.ts +24 -0
- package/dist/world2d/physics2d-registry.d.ts.map +1 -0
- package/dist/world2d/physics2d-registry.js +38 -0
- package/dist/world2d/pixi-game-adapter.d.ts +107 -0
- package/dist/world2d/pixi-game-adapter.d.ts.map +1 -0
- package/dist/world2d/pixi-game-adapter.js +211 -0
- package/dist/world2d/pixi-surface.d.ts +39 -0
- package/dist/world2d/pixi-surface.d.ts.map +1 -0
- package/dist/world2d/pixi-surface.js +47 -0
- package/dist/world2d/scene-capture-2d.d.ts +43 -0
- package/dist/world2d/scene-capture-2d.d.ts.map +1 -0
- package/dist/world2d/scene-capture-2d.js +92 -0
- package/dist/world2d/scene2d-loader.d.ts +27 -0
- package/dist/world2d/scene2d-loader.d.ts.map +1 -0
- package/dist/world2d/scene2d-loader.js +274 -0
- package/dist/world2d/schema/entity2d.d.ts +102 -0
- package/dist/world2d/schema/entity2d.d.ts.map +1 -0
- package/dist/world2d/schema/entity2d.js +119 -0
- package/dist/world2d/schema/physics2d.d.ts +46 -0
- package/dist/world2d/schema/physics2d.d.ts.map +1 -0
- package/dist/world2d/schema/physics2d.js +45 -0
- package/dist/world2d/schema/sprite.d.ts +42 -0
- package/dist/world2d/schema/sprite.d.ts.map +1 -0
- package/dist/world2d/schema/sprite.js +63 -0
- package/dist/world2d/schema/tilemap.d.ts +15 -0
- package/dist/world2d/schema/tilemap.d.ts.map +1 -0
- package/dist/world2d/schema/tilemap.js +19 -0
- package/dist/world2d/schema/tuples2d.d.ts +20 -0
- package/dist/world2d/schema/tuples2d.d.ts.map +1 -0
- package/dist/world2d/schema/tuples2d.js +19 -0
- package/dist/world2d/system-adapters-2d.d.ts +16 -0
- package/dist/world2d/system-adapters-2d.d.ts.map +1 -0
- package/dist/world2d/system-adapters-2d.js +37 -0
- package/dist/world2d/transform-writer-2d.d.ts +16 -0
- package/dist/world2d/transform-writer-2d.d.ts.map +1 -0
- package/dist/world2d/transform-writer-2d.js +22 -0
- package/dist/world2d/types.d.ts +53 -0
- package/dist/world2d/types.d.ts.map +1 -0
- package/dist/world2d/types.js +1 -0
- package/package.json +18 -4
- package/src/adapter/authoring.ts +10 -0
- package/src/adapter/first-party-systems.ts +23 -34
- package/src/adapter/index.ts +1 -3
- package/src/adapter/system-adapter.ts +15 -22
- package/src/adapter/vgai-scene-game-adapter.ts +5 -14
- package/src/animation/anim-graph-types.ts +12 -43
- package/src/animation/animation-clock.ts +479 -0
- package/src/animation/camera-ownership.ts +467 -0
- package/src/animation/cinematic-cues.ts +451 -0
- package/src/animation/clip-map.ts +41 -0
- package/src/animation/gsap-registration.ts +184 -0
- package/src/animation/theatre-clock-binding.ts +111 -0
- package/src/animation/theatre-director.ts +347 -0
- package/src/animation/theatre-object-binding.ts +661 -0
- package/src/animation/xstate-animation-binding.ts +398 -0
- package/src/animation/xstate-animation-meta.ts +282 -0
- package/src/audio/index.ts +39 -7
- package/src/audio/tone-clock-binding.ts +98 -0
- package/src/audio/tone-context.ts +129 -0
- package/src/audio/tone-offline-render.ts +167 -0
- package/src/audio/wav-encode.ts +119 -0
- package/src/core/game-loop.ts +17 -0
- package/src/core/types.ts +13 -0
- package/src/data/data-asset.ts +167 -0
- package/src/data/data-check-core.ts +242 -0
- package/src/data/data-ref.ts +145 -0
- package/src/data/vite-plugin-data.ts +290 -0
- package/src/index.ts +48 -0
- package/src/input/input-manager.ts +1206 -32
- package/src/input/input-types.ts +155 -3
- package/src/input/prompt-labels.ts +122 -0
- package/src/input/rebind-controller.ts +105 -0
- package/src/input/schema.ts +206 -52
- package/src/react/use-data.ts +114 -0
- package/src/react/use-selection.tsx +135 -0
- package/src/runtime/create-runtime.ts +30 -9
- package/src/runtime/render-audio-control.ts +168 -0
- package/src/runtime/render-control.ts +522 -0
- package/src/runtime/render-seed.ts +79 -0
- package/src/runtime/types.ts +0 -5
- package/src/scene/asset-loaders.ts +10 -36
- package/src/scene/asset-paths.ts +0 -2
- package/src/scene/asset-ref-check.ts +248 -0
- package/src/scene/parse.ts +133 -0
- package/src/scene/scene-loader.ts +81 -96
- package/src/scene/schema/animation.ts +30 -79
- package/src/scene/schema/entity.ts +20 -0
- package/src/scene/schema/index.ts +2 -12
- package/src/scene/user-data.ts +8 -9
- package/src/setup/setup-renderer.ts +9 -2
- package/src/tools/define-tool.ts +152 -0
- package/src/animation/anim-graph.ts +0 -406
- package/src/animation/anim-system.ts +0 -28
- package/src/animation/property-track.ts +0 -178
- package/src/animation/schema.ts +0 -204
- package/src/audio/ambient.ts +0 -300
- package/src/audio/impacts.ts +0 -212
- package/src/audio/movement.ts +0 -140
- package/src/audio/musical.ts +0 -200
- package/src/audio/ui-sounds.ts +0 -171
- package/src/audio/vehicle.ts +0 -235
- package/src/audio/weapons.ts +0 -152
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data-asset integrity core — the PURE half of W5 enforcement
|
|
3
|
+
* (docs/DATA-TOOLS-DESIGN.md §6.6 "dangling `file#key` ref" / §6.7 build-path
|
|
4
|
+
* validation). No filesystem, no vite, no zod: plain parsed-JSON in, findings
|
|
5
|
+
* out, so BOTH consumers — `vgai doctor`'s data checks
|
|
6
|
+
* (`packages/editor/src/doctor/data-checks.ts`) and the build-time plugin
|
|
7
|
+
* (`./vite-plugin-data.ts`) — share one definition of "what is a ref" and
|
|
8
|
+
* "what counts as dangling" and can never drift apart.
|
|
9
|
+
*
|
|
10
|
+
* What is a ref (§2.2): a cross-asset reference is a plain string
|
|
11
|
+
* `"file#key"` — optionally with a field path, `"tuning#economy.slotGrowth"`
|
|
12
|
+
* (file `#` key `.` field-path). There is no branded-ref Zod helper shipped
|
|
13
|
+
* yet (W1 deferred it), so ref DETECTION is by convention, tuned against
|
|
14
|
+
* false positives: a string is treated as a ref IFF it matches
|
|
15
|
+
* {@link DATA_REF_PATTERN} AND its `file` prefix names a data asset that
|
|
16
|
+
* actually exists in the project (`src/data/<file>.data.json`). Strings that
|
|
17
|
+
* merely contain `#` — hex colors (`"#ff0000"`, no prefix), URLs with
|
|
18
|
+
* fragments (`/` and `:` never match), musical pitches (`"C#4"` only matches
|
|
19
|
+
* if a `C.data.json` exists) — never fire. The flip side is deliberate and
|
|
20
|
+
* honest: a ref whose file prefix names a NONEXISTENT asset is
|
|
21
|
+
* indistinguishable from an arbitrary string and is NOT flagged ("error if
|
|
22
|
+
* refs exist yet" — the check only bites once the target file exists).
|
|
23
|
+
*
|
|
24
|
+
* `dataRef` (`./data-ref.ts`) now exists, closing that flip side for anyone
|
|
25
|
+
* who adopts it: a `dataRef(target)` field's EMITTED schema carries
|
|
26
|
+
* `"x-vgai-ref": target` — a declared intent, independent of whether the
|
|
27
|
+
* target file currently exists. {@link collectDeclaredRefFields} /
|
|
28
|
+
* {@link findMissingRefTargets} below walk that (zod-free — plain emitted
|
|
29
|
+
* JSON Schema in, findings out, same purity contract as the rest of this
|
|
30
|
+
* module) to catch the §9.4 hole for DECLARED refs: renaming/deleting a
|
|
31
|
+
* target file used to silently un-check every ref into it; now a declared
|
|
32
|
+
* ref's target is checked by NAME, not by "does a string happen to look
|
|
33
|
+
* like one right now." Undeclared conventional-string refs keep the
|
|
34
|
+
* calibrated behavior above, unchanged.
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* `file#key(.field)*` — prefix must look like an asset stem (letters,
|
|
38
|
+
* digits, `_`, `-`), key path is dot-separated segments of the same alphabet.
|
|
39
|
+
*/
|
|
40
|
+
export declare const DATA_REF_PATTERN: RegExp;
|
|
41
|
+
/** One ref-shaped string found while walking a data file's parsed JSON. */
|
|
42
|
+
export interface DataRefOccurrence {
|
|
43
|
+
/** Asset stem of the data file the ref string was found IN (e.g. `"tuning"`). */
|
|
44
|
+
readonly inAsset: string;
|
|
45
|
+
/** JSON path of the string inside that file (e.g. `"rows.goblin.drops[2]"`). */
|
|
46
|
+
readonly atPath: string;
|
|
47
|
+
/** The full ref string, verbatim (e.g. `"enemies#goblin"`). */
|
|
48
|
+
readonly ref: string;
|
|
49
|
+
/** Parsed target asset stem (`"enemies"`). */
|
|
50
|
+
readonly targetAsset: string;
|
|
51
|
+
/** Parsed dot-separated key path into the target (`["goblin"]`). */
|
|
52
|
+
readonly targetKeyPath: readonly string[];
|
|
53
|
+
}
|
|
54
|
+
/** One dangling ref: the target FILE exists but the key path does not resolve in it. */
|
|
55
|
+
export interface DanglingRefFinding extends DataRefOccurrence {
|
|
56
|
+
/** The first key-path segment that failed to resolve, for the teaching message. */
|
|
57
|
+
readonly missingSegment: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Walk one data file's parsed JSON and collect every ref-shaped string whose
|
|
61
|
+
* file prefix names an asset in `assetNames`. The top-level `"$schema"`
|
|
62
|
+
* interchange line is skipped (it is wiring, not data — same special-casing
|
|
63
|
+
* as `parseDataJson`'s strip).
|
|
64
|
+
*/
|
|
65
|
+
export declare function collectDataRefs(inAsset: string, json: unknown, assetNames: ReadonlySet<string>): DataRefOccurrence[];
|
|
66
|
+
/**
|
|
67
|
+
* Find every dangling `file#key(.field)*` ref across a project's data assets.
|
|
68
|
+
*
|
|
69
|
+
* @param files parsed `.data.json` payloads keyed by asset stem (the
|
|
70
|
+
* filename minus `.data.json` — the same name the ref's prefix uses, §2.2).
|
|
71
|
+
* Pass only files that parsed as JSON; unparseable files are already an
|
|
72
|
+
* error in their own right and can't be resolved against anyway.
|
|
73
|
+
* @returns one finding per ref whose target FILE is in `files` but whose key
|
|
74
|
+
* path does not fully resolve inside it (a table row that doesn't exist, a
|
|
75
|
+
* singleton field path that walks off the object).
|
|
76
|
+
*/
|
|
77
|
+
export declare function findDanglingDataRefs(files: ReadonlyMap<string, unknown>): DanglingRefFinding[];
|
|
78
|
+
/** One `dataRef` field declared in an emitted JSON Schema. */
|
|
79
|
+
export interface DeclaredRefField {
|
|
80
|
+
/** Dot-separated field path within the schema (e.g. `"drop"`, `"loot.dropTable"`). A table's row-schema fields are reported WITHOUT a row-key segment — the declaration applies to every row alike. */
|
|
81
|
+
readonly fieldPath: string;
|
|
82
|
+
/** The asset stem the field's `dataRef(...)` call named. */
|
|
83
|
+
readonly targetStem: string;
|
|
84
|
+
}
|
|
85
|
+
/** One declared ref whose target stem names no asset that currently exists. */
|
|
86
|
+
export interface MissingRefTargetFinding {
|
|
87
|
+
readonly fieldPath: string;
|
|
88
|
+
readonly targetStem: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Walk an emitted data-asset JSON Schema (`toDataJsonSchema`'s output, or the
|
|
92
|
+
* committed `.schema.json` twin — same shape either way) and collect every
|
|
93
|
+
* field stamped `"x-vgai-ref": <target>` by `dataRef` (`./data-ref.ts`).
|
|
94
|
+
* Handles both blessed shapes (spec §2.1): a singleton's `properties`, and a
|
|
95
|
+
* table's `additionalProperties` row schema — walked with the SAME field
|
|
96
|
+
* path (a table's declared ref applies uniformly to every row, there is no
|
|
97
|
+
* per-row schema variation). Nested `properties` inside a ref-declaring
|
|
98
|
+
* field are not walked further (a ref leaf has no children); nested groups
|
|
99
|
+
* elsewhere recurse via their own `properties`.
|
|
100
|
+
*/
|
|
101
|
+
export declare function collectDeclaredRefFields(schema: unknown): DeclaredRefField[];
|
|
102
|
+
/**
|
|
103
|
+
* Every declared ref field whose target stem names no asset in
|
|
104
|
+
* `assetNames` — the §9.4 fix: a `dataRef('items')` field stays flagged if
|
|
105
|
+
* `items.data.json` is renamed or deleted, independent of whether any
|
|
106
|
+
* CURRENT value happens to look like an `items#...` string (the gap the
|
|
107
|
+
* conventional-string calibration above deliberately leaves open).
|
|
108
|
+
*/
|
|
109
|
+
export declare function findMissingRefTargets(declared: readonly DeclaredRefField[], assetNames: ReadonlySet<string>): MissingRefTargetFinding[];
|
|
110
|
+
//# sourceMappingURL=data-check-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-check-core.d.ts","sourceRoot":"","sources":["../../src/data/data-check-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH;;;GAGG;AACH,eAAO,MAAM,gBAAgB,QAA6D,CAAC;AAE3F,2EAA2E;AAC3E,MAAM,WAAW,iBAAiB;IAChC,iFAAiF;IACjF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,gFAAgF;IAChF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,+DAA+D;IAC/D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,8CAA8C;IAC9C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,oEAAoE;IACpE,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3C;AAED,wFAAwF;AACxF,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D,mFAAmF;IACnF,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAMD;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,OAAO,EACb,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,GAC9B,iBAAiB,EAAE,CAOrB;AA6CD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,kBAAkB,EAAE,CAU9F;AAYD,8DAA8D;AAC9D,MAAM,WAAW,gBAAgB;IAC/B,uMAAuM;IACvM,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,4DAA4D;IAC5D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,+EAA+E;AAC/E,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAeD;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,OAAO,GAAG,gBAAgB,EAAE,CAI5E;AAwBD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,SAAS,gBAAgB,EAAE,EACrC,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,GAC9B,uBAAuB,EAAE,CAI3B"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data-asset integrity core — the PURE half of W5 enforcement
|
|
3
|
+
* (docs/DATA-TOOLS-DESIGN.md §6.6 "dangling `file#key` ref" / §6.7 build-path
|
|
4
|
+
* validation). No filesystem, no vite, no zod: plain parsed-JSON in, findings
|
|
5
|
+
* out, so BOTH consumers — `vgai doctor`'s data checks
|
|
6
|
+
* (`packages/editor/src/doctor/data-checks.ts`) and the build-time plugin
|
|
7
|
+
* (`./vite-plugin-data.ts`) — share one definition of "what is a ref" and
|
|
8
|
+
* "what counts as dangling" and can never drift apart.
|
|
9
|
+
*
|
|
10
|
+
* What is a ref (§2.2): a cross-asset reference is a plain string
|
|
11
|
+
* `"file#key"` — optionally with a field path, `"tuning#economy.slotGrowth"`
|
|
12
|
+
* (file `#` key `.` field-path). There is no branded-ref Zod helper shipped
|
|
13
|
+
* yet (W1 deferred it), so ref DETECTION is by convention, tuned against
|
|
14
|
+
* false positives: a string is treated as a ref IFF it matches
|
|
15
|
+
* {@link DATA_REF_PATTERN} AND its `file` prefix names a data asset that
|
|
16
|
+
* actually exists in the project (`src/data/<file>.data.json`). Strings that
|
|
17
|
+
* merely contain `#` — hex colors (`"#ff0000"`, no prefix), URLs with
|
|
18
|
+
* fragments (`/` and `:` never match), musical pitches (`"C#4"` only matches
|
|
19
|
+
* if a `C.data.json` exists) — never fire. The flip side is deliberate and
|
|
20
|
+
* honest: a ref whose file prefix names a NONEXISTENT asset is
|
|
21
|
+
* indistinguishable from an arbitrary string and is NOT flagged ("error if
|
|
22
|
+
* refs exist yet" — the check only bites once the target file exists).
|
|
23
|
+
*
|
|
24
|
+
* `dataRef` (`./data-ref.ts`) now exists, closing that flip side for anyone
|
|
25
|
+
* who adopts it: a `dataRef(target)` field's EMITTED schema carries
|
|
26
|
+
* `"x-vgai-ref": target` — a declared intent, independent of whether the
|
|
27
|
+
* target file currently exists. {@link collectDeclaredRefFields} /
|
|
28
|
+
* {@link findMissingRefTargets} below walk that (zod-free — plain emitted
|
|
29
|
+
* JSON Schema in, findings out, same purity contract as the rest of this
|
|
30
|
+
* module) to catch the §9.4 hole for DECLARED refs: renaming/deleting a
|
|
31
|
+
* target file used to silently un-check every ref into it; now a declared
|
|
32
|
+
* ref's target is checked by NAME, not by "does a string happen to look
|
|
33
|
+
* like one right now." Undeclared conventional-string refs keep the
|
|
34
|
+
* calibrated behavior above, unchanged.
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* `file#key(.field)*` — prefix must look like an asset stem (letters,
|
|
38
|
+
* digits, `_`, `-`), key path is dot-separated segments of the same alphabet.
|
|
39
|
+
*/
|
|
40
|
+
export const DATA_REF_PATTERN = /^([A-Za-z0-9_-]+)#([A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*)$/;
|
|
41
|
+
function isPlainObject(value) {
|
|
42
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Walk one data file's parsed JSON and collect every ref-shaped string whose
|
|
46
|
+
* file prefix names an asset in `assetNames`. The top-level `"$schema"`
|
|
47
|
+
* interchange line is skipped (it is wiring, not data — same special-casing
|
|
48
|
+
* as `parseDataJson`'s strip).
|
|
49
|
+
*/
|
|
50
|
+
export function collectDataRefs(inAsset, json, assetNames) {
|
|
51
|
+
const out = [];
|
|
52
|
+
visitForRefs(json, '', true, (node, path) => {
|
|
53
|
+
const occurrence = asRefOccurrence(inAsset, node, path, assetNames);
|
|
54
|
+
if (occurrence)
|
|
55
|
+
out.push(occurrence);
|
|
56
|
+
});
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
/** Depth-first walk over parsed JSON, calling `onString` for every string leaf with its JSON path. */
|
|
60
|
+
function visitForRefs(node, path, topLevel, onString) {
|
|
61
|
+
if (typeof node === 'string') {
|
|
62
|
+
onString(node, path);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (Array.isArray(node)) {
|
|
66
|
+
node.forEach((item, i) => {
|
|
67
|
+
visitForRefs(item, `${path}[${i}]`, false, onString);
|
|
68
|
+
});
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (isPlainObject(node)) {
|
|
72
|
+
for (const [key, value] of Object.entries(node)) {
|
|
73
|
+
if (topLevel && key === '$schema')
|
|
74
|
+
continue;
|
|
75
|
+
visitForRefs(value, path ? `${path}.${key}` : key, false, onString);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/** The string is a ref iff it matches the pattern AND its file prefix names a real asset. */
|
|
80
|
+
function asRefOccurrence(inAsset, value, path, assetNames) {
|
|
81
|
+
const m = DATA_REF_PATTERN.exec(value);
|
|
82
|
+
if (!m || !assetNames.has(m[1]))
|
|
83
|
+
return null;
|
|
84
|
+
return {
|
|
85
|
+
inAsset,
|
|
86
|
+
atPath: path || '(root)',
|
|
87
|
+
ref: value,
|
|
88
|
+
targetAsset: m[1],
|
|
89
|
+
targetKeyPath: m[2].split('.'),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Find every dangling `file#key(.field)*` ref across a project's data assets.
|
|
94
|
+
*
|
|
95
|
+
* @param files parsed `.data.json` payloads keyed by asset stem (the
|
|
96
|
+
* filename minus `.data.json` — the same name the ref's prefix uses, §2.2).
|
|
97
|
+
* Pass only files that parsed as JSON; unparseable files are already an
|
|
98
|
+
* error in their own right and can't be resolved against anyway.
|
|
99
|
+
* @returns one finding per ref whose target FILE is in `files` but whose key
|
|
100
|
+
* path does not fully resolve inside it (a table row that doesn't exist, a
|
|
101
|
+
* singleton field path that walks off the object).
|
|
102
|
+
*/
|
|
103
|
+
export function findDanglingDataRefs(files) {
|
|
104
|
+
const assetNames = new Set(files.keys());
|
|
105
|
+
const findings = [];
|
|
106
|
+
for (const [name, json] of files) {
|
|
107
|
+
for (const occurrence of collectDataRefs(name, json, assetNames)) {
|
|
108
|
+
const missing = firstUnresolvedSegment(files.get(occurrence.targetAsset), occurrence);
|
|
109
|
+
if (missing !== null)
|
|
110
|
+
findings.push({ ...occurrence, missingSegment: missing });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return findings;
|
|
114
|
+
}
|
|
115
|
+
/** The first key-path segment that fails to resolve in the target payload, or `null` if the whole path resolves. */
|
|
116
|
+
function firstUnresolvedSegment(target, ref) {
|
|
117
|
+
let node = target;
|
|
118
|
+
for (const segment of ref.targetKeyPath) {
|
|
119
|
+
if (!isPlainObject(node) || !(segment in node))
|
|
120
|
+
return segment;
|
|
121
|
+
node = node[segment];
|
|
122
|
+
}
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
function asSchemaNode(value) {
|
|
126
|
+
return value && typeof value === 'object' && !Array.isArray(value)
|
|
127
|
+
? value
|
|
128
|
+
: null;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Walk an emitted data-asset JSON Schema (`toDataJsonSchema`'s output, or the
|
|
132
|
+
* committed `.schema.json` twin — same shape either way) and collect every
|
|
133
|
+
* field stamped `"x-vgai-ref": <target>` by `dataRef` (`./data-ref.ts`).
|
|
134
|
+
* Handles both blessed shapes (spec §2.1): a singleton's `properties`, and a
|
|
135
|
+
* table's `additionalProperties` row schema — walked with the SAME field
|
|
136
|
+
* path (a table's declared ref applies uniformly to every row, there is no
|
|
137
|
+
* per-row schema variation). Nested `properties` inside a ref-declaring
|
|
138
|
+
* field are not walked further (a ref leaf has no children); nested groups
|
|
139
|
+
* elsewhere recurse via their own `properties`.
|
|
140
|
+
*/
|
|
141
|
+
export function collectDeclaredRefFields(schema) {
|
|
142
|
+
const out = [];
|
|
143
|
+
walkForDeclaredRefs(schema, '', out);
|
|
144
|
+
return out;
|
|
145
|
+
}
|
|
146
|
+
function walkForDeclaredRefs(raw, path, out) {
|
|
147
|
+
const node = asSchemaNode(raw);
|
|
148
|
+
if (!node)
|
|
149
|
+
return;
|
|
150
|
+
if (typeof node['x-vgai-ref'] === 'string') {
|
|
151
|
+
out.push({ fieldPath: path || '(root)', targetStem: node['x-vgai-ref'] });
|
|
152
|
+
return; // a ref leaf — nothing further to walk under it
|
|
153
|
+
}
|
|
154
|
+
if (isPlainObject(node.properties)) {
|
|
155
|
+
for (const [key, child] of Object.entries(node.properties)) {
|
|
156
|
+
if (key === '$schema')
|
|
157
|
+
continue;
|
|
158
|
+
walkForDeclaredRefs(child, path ? `${path}.${key}` : key, out);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
// A table's row schema (`z.record(rowSchema)` emits an object-valued
|
|
162
|
+
// `additionalProperties`) — same field-path grammar, no row-key segment.
|
|
163
|
+
if (isPlainObject(node.additionalProperties)) {
|
|
164
|
+
walkForDeclaredRefs(node.additionalProperties, path, out);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Every declared ref field whose target stem names no asset in
|
|
169
|
+
* `assetNames` — the §9.4 fix: a `dataRef('items')` field stays flagged if
|
|
170
|
+
* `items.data.json` is renamed or deleted, independent of whether any
|
|
171
|
+
* CURRENT value happens to look like an `items#...` string (the gap the
|
|
172
|
+
* conventional-string calibration above deliberately leaves open).
|
|
173
|
+
*/
|
|
174
|
+
export function findMissingRefTargets(declared, assetNames) {
|
|
175
|
+
return declared
|
|
176
|
+
.filter((d) => !assetNames.has(d.targetStem))
|
|
177
|
+
.map((d) => ({ fieldPath: d.fieldPath, targetStem: d.targetStem }));
|
|
178
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `file#key` refs — the resolvable half (docs/DATA-TOOLS-DESIGN.md §2.2).
|
|
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 (see docs/DATA-TOOLS-DESIGN.md §2.2 and the design
|
|
28
|
+
* note this module's history carries): eager resolution inside `defineData`
|
|
29
|
+
* (would change `get()`'s shipped output type and entangle HMR — an edit to
|
|
30
|
+
* `enemies.data.json` would have to re-notify every OTHER asset that
|
|
31
|
+
* references it), and a global `resolveRef(addressString)` (needs a runtime
|
|
32
|
+
* stem→handle registry that `src/data/assets.ts` — side-effect-free,
|
|
33
|
+
* config-load-time, schemas-only by 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 (docs/DATA-TOOLS-DESIGN.md §2.2).
|
|
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 (see docs/DATA-TOOLS-DESIGN.md §2.2 and the design
|
|
28
|
+
* note this module's history carries): eager resolution inside `defineData`
|
|
29
|
+
* (would change `get()`'s shipped output type and entangle HMR — an edit to
|
|
30
|
+
* `enemies.data.json` would have to re-notify every OTHER asset that
|
|
31
|
+
* references it), and a global `resolveRef(addressString)` (needs a runtime
|
|
32
|
+
* stem→handle registry that `src/data/assets.ts` — side-effect-free,
|
|
33
|
+
* config-load-time, schemas-only by 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 (docs/DATA-TOOLS-DESIGN.md §2.2) — ` +
|
|
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 (docs/DATA-TOOLS-DESIGN.md §2.2) — ` +
|
|
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 — docs/DATA-TOOLS-DESIGN.md §2.2).');
|
|
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
|
|
3
|
+
* (docs/DATA-TOOLS-DESIGN.md §6.7, the enforcement half of W5). A Vite plugin
|
|
4
|
+
* for the PROJECT's own `vite.config.ts` (the template wires it; the editor
|
|
5
|
+
* dev server boots Vite from the ENGINE's config and never runs this — its
|
|
6
|
+
* surface is covered by `vgai doctor` instead). Build-only (`apply: 'build'`):
|
|
7
|
+
* in dev, `defineData`'s parse-on-load already 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"}
|