@auraindustry/aurajs 0.0.7 → 0.1.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 +98 -2
- package/benchmarks/perf-thresholds.json +54 -0
- package/package.json +4 -7
- package/src/asset-pack.mjs +5 -1
- package/src/authored-project.mjs +1449 -0
- package/src/authored-runtime.mjs +2016 -0
- package/src/authoring/avatar-animation-graph.mjs +648 -0
- package/src/bin-integrity.mjs +272 -0
- package/src/build-contract/assets.mjs +130 -0
- package/src/build-contract/capabilities.mjs +116 -0
- package/src/build-contract/constants.mjs +6 -0
- package/src/build-contract/helpers.mjs +44 -0
- package/src/build-contract/web-templates.mjs +5993 -0
- package/src/build-contract.mjs +27 -2910
- package/src/bundler.mjs +188 -55
- package/src/cli.mjs +4825 -1512
- package/src/commands/project-authoring.mjs +434 -0
- package/src/config.mjs +27 -0
- package/src/conformance/cases/app-and-ui-runtime-cases.mjs +3309 -0
- package/src/conformance/cases/core-runtime-cases.mjs +1431 -0
- package/src/conformance/cases/index.mjs +11 -0
- package/src/conformance/cases/scene3d-and-media-cases.mjs +2094 -0
- package/src/conformance/cases/systems-and-gameplay-cases.mjs +1776 -0
- package/src/conformance/shared.mjs +27 -0
- package/src/conformance-runner.mjs +25 -13
- package/src/conformance.mjs +619 -4020
- package/src/cutscene.mjs +362 -5
- package/src/dev-cli-action.mjs +249 -0
- package/src/dev-cli-inspect.mjs +92 -0
- package/src/dev-cli-state.mjs +80 -0
- package/src/external-asset-cache.mjs +587 -0
- package/src/external-asset-policy.mjs +217 -0
- package/src/external-package-surface.mjs +206 -0
- package/src/game-action-runtime.mjs +869 -0
- package/src/game-state-runtime.mjs +206 -6
- package/src/headless-action.mjs +186 -0
- package/src/headless-test/runtime-animation.mjs +1173 -0
- package/src/headless-test/runtime-coordinator.mjs +1514 -0
- package/src/headless-test/runtime-primitives.mjs +320 -0
- package/src/headless-test/runtime-world.mjs +2253 -0
- package/src/headless-test.mjs +392 -4298
- package/src/host-binary.mjs +342 -14
- package/src/icon-discovery.mjs +64 -0
- package/src/make-catalog.mjs +109 -0
- package/src/make.mjs +197 -0
- package/src/package-integrity.mjs +586 -0
- package/src/perf-benchmark.mjs +353 -0
- package/src/postinstall.mjs +5 -5
- package/src/prefabs/index.mjs +34 -0
- package/src/prefabs/scene-serialization.mjs +184 -0
- package/src/project-importer.mjs +620 -0
- package/src/project-registry.mjs +24 -0
- package/src/publish-command.mjs +195 -0
- package/src/publish-env-example.mjs +83 -0
- package/src/publish-validation.mjs +708 -0
- package/src/retro/assets/compile.mjs +232 -0
- package/src/retro/backend-gba/authoring.mjs +1029 -0
- package/src/retro/backend-gba/rom.mjs +363 -0
- package/src/retro/backend-gbc/rom.mjs +85 -0
- package/src/retro/build.mjs +278 -0
- package/src/retro/cli/commands.mjs +292 -0
- package/src/retro/cli/templates.mjs +84 -0
- package/src/retro/diagnostics/catalog.mjs +110 -0
- package/src/retro/diagnostics/emit.mjs +72 -0
- package/src/retro/emulator/case-overlay.mjs +64 -0
- package/src/retro/emulator/discovery.mjs +158 -0
- package/src/retro/emulator/macos-case-overlay.swift +220 -0
- package/src/retro/emulator/profiles.mjs +146 -0
- package/src/retro/emulator/runner.mjs +289 -0
- package/src/retro/frontend/load-project.mjs +98 -0
- package/src/retro/index.mjs +30 -0
- package/src/retro/ir/build-ir.mjs +108 -0
- package/src/retro/runtime-gba/contract.mjs +151 -0
- package/src/retro/runtime-gbc/contract.mjs +117 -0
- package/src/retro/shared/span.mjs +26 -0
- package/src/retro/shared/targets.mjs +64 -0
- package/src/retro/validator/check-project.mjs +114 -0
- package/src/runtime-hotspot-audit.mjs +707 -0
- package/src/scaffold/config.mjs +1000 -0
- package/src/scaffold/fs.mjs +56 -0
- package/src/scaffold/layout.mjs +318 -0
- package/src/scaffold/project-docs.mjs +438 -0
- package/src/scaffold.mjs +93 -596
- package/src/scene-composition/index.mjs +326 -0
- package/src/scene-composition/runtime.mjs +751 -0
- package/src/self-hosted-assets.mjs +604 -0
- package/src/session-client.mjs +750 -0
- package/src/session-native-launcher.mjs +74 -0
- package/src/session-protocol.mjs +75 -0
- package/src/session-runtime.mjs +321 -0
- package/src/session-server.mjs +360 -0
- package/src/shader-kits/index.mjs +773 -0
- package/src/starter-content-registry.mjs +292 -0
- package/src/state-artifacts.mjs +662 -24
- package/src/state-dev-reload.mjs +99 -2
- package/src/terminal-ui.mjs +245 -0
- package/src/web-conformance.mjs +219 -0
- package/templates/create/2d/config/gameplay/shooter.config.js +26 -0
- package/templates/create/2d/content/gameplay/waves.json +26 -0
- package/templates/create/2d/content/registries/.gitkeep +1 -0
- package/templates/create/2d/docs/design/.gitkeep +1 -0
- package/templates/create/2d/docs/design/loop.md +5 -0
- package/templates/create/2d/prefabs/enemies.prefab.js +90 -0
- package/templates/create/2d/prefabs/enemy-basic.prefab.js +18 -0
- package/templates/create/2d/prefabs/player.prefab.js +36 -0
- package/templates/create/2d/prefabs/projectiles.prefab.js +35 -0
- package/templates/create/2d/scenes/boot.scene.js +12 -0
- package/templates/create/2d/scenes/gameplay.scene.js +230 -0
- package/templates/create/2d/scenes/menu.scene.js +9 -0
- package/templates/create/2d/src/main.js +6 -185
- package/templates/create/2d/src/runtime/app.js +49 -0
- package/templates/create/2d/src/runtime/capabilities.js +35 -0
- package/templates/create/2d/ui/hud.screen.js +40 -0
- package/templates/create/2d/ui/pause.screen.js +149 -0
- package/templates/create/2d/ui/settings.screen.js +347 -0
- package/templates/create/2d/ui/title.screen.js +13 -0
- package/templates/create/2d-adventure/aura.config.json +28 -0
- package/templates/create/2d-adventure/config/gameplay/adventure.config.js +14 -0
- package/templates/create/2d-adventure/content/gameplay/world.js +46 -0
- package/templates/create/2d-adventure/content/registries/.gitkeep +1 -0
- package/templates/create/2d-adventure/docs/design/loop.md +5 -0
- package/templates/create/2d-adventure/prefabs/player.prefab.js +54 -0
- package/templates/create/2d-adventure/prefabs/relic.prefab.js +38 -0
- package/templates/create/2d-adventure/prefabs/world.prefab.js +125 -0
- package/templates/create/2d-adventure/scenes/gameplay.scene.js +256 -0
- package/templates/create/2d-adventure/src/runtime/capabilities.js +34 -0
- package/templates/create/2d-adventure/ui/hud.screen.js +60 -0
- package/templates/create/2d-survivor/config/gameplay/survivor.config.js +33 -0
- package/templates/create/2d-survivor/content/gameplay/spawn-zones.json +29 -0
- package/templates/create/2d-survivor/content/registries/.gitkeep +1 -0
- package/templates/create/2d-survivor/docs/design/.gitkeep +1 -0
- package/templates/create/2d-survivor/docs/design/loop.md +5 -0
- package/templates/create/2d-survivor/prefabs/enemies.prefab.js +178 -0
- package/templates/create/2d-survivor/prefabs/enemy-swarm.prefab.js +18 -0
- package/templates/create/2d-survivor/prefabs/player.prefab.js +42 -0
- package/templates/create/2d-survivor/prefabs/projectiles.prefab.js +56 -0
- package/templates/create/2d-survivor/scenes/boot.scene.js +12 -0
- package/templates/create/2d-survivor/scenes/gameplay.scene.js +314 -0
- package/templates/create/2d-survivor/scenes/menu.scene.js +9 -0
- package/templates/create/2d-survivor/src/main.js +5 -332
- package/templates/create/2d-survivor/src/runtime/app.js +49 -0
- package/templates/create/2d-survivor/src/runtime/capabilities.js +35 -0
- package/templates/create/2d-survivor/ui/hud.screen.js +45 -0
- package/templates/create/2d-survivor/ui/title.screen.js +13 -0
- package/templates/create/3d/assets/models/starter-avatar.gltf +184 -0
- package/templates/create/3d/config/gameplay/.gitkeep +1 -0
- package/templates/create/3d/content/gameplay/checkpoints.json +33 -0
- package/templates/create/3d/content/gameplay/course.js +40 -0
- package/templates/create/3d/content/registries/.gitkeep +1 -0
- package/templates/create/3d/docs/design/.gitkeep +1 -0
- package/templates/create/3d/docs/design/loop.md +5 -0
- package/templates/create/3d/prefabs/checkpoint.prefab.js +15 -0
- package/templates/create/3d/prefabs/player.prefab.js +204 -0
- package/templates/create/3d/prefabs/world.prefab.js +112 -0
- package/templates/create/3d/scenes/boot.scene.js +12 -0
- package/templates/create/3d/scenes/checkpoint.scene.js +9 -0
- package/templates/create/3d/scenes/gameplay.scene.js +292 -0
- package/templates/create/3d/src/main.js +6 -295
- package/templates/create/3d/src/runtime/app.js +49 -0
- package/templates/create/3d/src/runtime/capabilities.js +53 -0
- package/templates/create/3d/src/runtime/materials.js +34 -0
- package/templates/create/3d/src/runtime/state.js +39 -0
- package/templates/create/3d/ui/hud.screen.js +75 -0
- package/templates/create/3d/ui/pause.screen.js +166 -0
- package/templates/create/3d/ui/settings.screen.js +387 -0
- package/templates/create/3d-adventure/assets/models/starter-avatar.gltf +184 -0
- package/templates/create/3d-adventure/aura.config.json +28 -0
- package/templates/create/3d-adventure/config/gameplay/adventure.config.js +9 -0
- package/templates/create/3d-adventure/content/gameplay/course.js +62 -0
- package/templates/create/3d-adventure/content/registries/.gitkeep +1 -0
- package/templates/create/3d-adventure/docs/design/loop.md +5 -0
- package/templates/create/3d-adventure/prefabs/player.prefab.js +168 -0
- package/templates/create/3d-adventure/prefabs/relic.prefab.js +35 -0
- package/templates/create/3d-adventure/prefabs/world.prefab.js +119 -0
- package/templates/create/3d-adventure/scenes/gameplay.scene.js +358 -0
- package/templates/create/3d-adventure/src/runtime/capabilities.js +56 -0
- package/templates/create/3d-adventure/src/runtime/materials.js +39 -0
- package/templates/create/3d-adventure/src/runtime/state.js +31 -0
- package/templates/create/3d-adventure/ui/hud.screen.js +70 -0
- package/templates/create/3d-adventure/ui/pause.screen.js +437 -0
- package/templates/create/3d-collectathon/assets/models/starter-avatar.gltf +184 -0
- package/templates/create/3d-collectathon/config/gameplay/.gitkeep +1 -0
- package/templates/create/3d-collectathon/content/gameplay/collectibles.json +26 -0
- package/templates/create/3d-collectathon/content/gameplay/course.js +46 -0
- package/templates/create/3d-collectathon/content/registries/.gitkeep +1 -0
- package/templates/create/3d-collectathon/docs/design/.gitkeep +1 -0
- package/templates/create/3d-collectathon/docs/design/loop.md +5 -0
- package/templates/create/3d-collectathon/prefabs/collectible.prefab.js +15 -0
- package/templates/create/3d-collectathon/prefabs/player.prefab.js +207 -0
- package/templates/create/3d-collectathon/prefabs/world.prefab.js +112 -0
- package/templates/create/3d-collectathon/scenes/boot.scene.js +12 -0
- package/templates/create/3d-collectathon/scenes/checkpoint.scene.js +9 -0
- package/templates/create/3d-collectathon/scenes/gameplay.scene.js +200 -0
- package/templates/create/3d-collectathon/src/main.js +5 -355
- package/templates/create/3d-collectathon/src/runtime/app.js +49 -0
- package/templates/create/3d-collectathon/src/runtime/capabilities.js +53 -0
- package/templates/create/3d-collectathon/src/runtime/materials.js +34 -0
- package/templates/create/3d-collectathon/src/runtime/state.js +27 -0
- package/templates/create/3d-collectathon/ui/hud.screen.js +66 -0
- package/templates/create/3d-collectathon/ui/pause.screen.js +13 -0
- package/templates/create/blank/config/gameplay/.gitkeep +1 -0
- package/templates/create/blank/content/gameplay/.gitkeep +1 -0
- package/templates/create/blank/content/registries/.gitkeep +1 -0
- package/templates/create/blank/docs/design/.gitkeep +1 -0
- package/templates/create/blank/docs/design/loop.md +5 -0
- package/templates/create/blank/prefabs/.gitkeep +1 -0
- package/templates/create/blank/scenes/.gitkeep +1 -0
- package/templates/create/blank/src/runtime/.gitkeep +1 -0
- package/templates/create/blank/ui/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/assets/audio/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/assets/fonts/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/assets/sprites/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/assets/starter/README.md +11 -0
- package/templates/create/deckbuilder-2d/assets/ui/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/aura.config.json +28 -0
- package/templates/create/deckbuilder-2d/config/gameplay/deckbuilder.config.js +26 -0
- package/templates/create/deckbuilder-2d/content/cards/guard.card.js +19 -0
- package/templates/create/deckbuilder-2d/content/cards/spark.card.js +20 -0
- package/templates/create/deckbuilder-2d/content/cards/starter.deck.js +69 -0
- package/templates/create/deckbuilder-2d/content/cards/strike.card.js +19 -0
- package/templates/create/deckbuilder-2d/content/cards/survey.card.js +20 -0
- package/templates/create/deckbuilder-2d/content/encounters/training-battle.encounter.js +14 -0
- package/templates/create/deckbuilder-2d/content/encounters/training-battle.js +65 -0
- package/templates/create/deckbuilder-2d/content/enemies/training-automaton.enemy.js +48 -0
- package/templates/create/deckbuilder-2d/content/gameplay/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/content/registries/cards.registry.js +26 -0
- package/templates/create/deckbuilder-2d/content/registries/encounters.registry.js +20 -0
- package/templates/create/deckbuilder-2d/content/registries/enemies.registry.js +20 -0
- package/templates/create/deckbuilder-2d/content/registries/relics.registry.js +20 -0
- package/templates/create/deckbuilder-2d/content/relics/ember-charm.relic.js +18 -0
- package/templates/create/deckbuilder-2d/docs/design/loop.md +12 -0
- package/templates/create/deckbuilder-2d/prefabs/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/scenes/boot.scene.js +84 -0
- package/templates/create/deckbuilder-2d/scenes/gameplay.scene.js +641 -0
- package/templates/create/deckbuilder-2d/src/components/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/src/main.js +17 -0
- package/templates/create/deckbuilder-2d/src/runtime/capabilities.js +22 -0
- package/templates/create/deckbuilder-2d/src/shared/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/src/systems/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/tests/smoke/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/ui/hud.screen.js +80 -0
- package/templates/create/deckbuilder-2d/ui/pause.screen.js +146 -0
- package/templates/create/deckbuilder-2d/ui/settings.screen.js +342 -0
- package/templates/create/local-multiplayer/aura.config.json +40 -0
- package/templates/create/local-multiplayer/config/gameplay/local-multiplayer.config.js +26 -0
- package/templates/create/local-multiplayer/content/gameplay/room-layout.js +13 -0
- package/templates/create/local-multiplayer/content/registries/.gitkeep +1 -0
- package/templates/create/local-multiplayer/docs/design/loop.md +14 -0
- package/templates/create/local-multiplayer/prefabs/player.prefab.js +99 -0
- package/templates/create/local-multiplayer/scenes/boot.scene.js +12 -0
- package/templates/create/local-multiplayer/scenes/gameplay.scene.js +443 -0
- package/templates/create/local-multiplayer/src/main.js +17 -0
- package/templates/create/local-multiplayer/src/runtime/capabilities.js +28 -0
- package/templates/create/local-multiplayer/ui/hud.screen.js +60 -0
- package/templates/create/shared/src/runtime/project-inspector.js +105 -0
- package/templates/create/shared/src/runtime/scene-flow.js +290 -0
- package/templates/create/shared/src/runtime/screen-shell.js +222 -0
- package/templates/create/shared/src/runtime/ui-forms.js +209 -0
- package/templates/create/shared/src/runtime/ui-settings.js +237 -0
- package/templates/create/shared/src/runtime/ui-theme.js +352 -0
- package/templates/create/shared/src/starter-utils/adventure-objectives.js +102 -0
- package/templates/create/shared/src/starter-utils/animation-2d.js +337 -0
- package/templates/create/shared/src/starter-utils/avatar-3d.js +404 -0
- package/templates/create/shared/src/starter-utils/combat-feedback-2d.js +320 -0
- package/templates/create/shared/src/starter-utils/core.js +39 -3
- package/templates/create/shared/src/starter-utils/index.js +8 -2
- package/templates/create/shared/src/starter-utils/platformer-3d.js +34 -3
- package/templates/create/shared/src/starter-utils/triggers.js +662 -0
- package/templates/create/shared/src/starter-utils/tween-2d.js +615 -0
- package/templates/create/video-cutscene/assets/video/.gitkeep +0 -0
- package/templates/create/video-cutscene/aura.config.json +28 -0
- package/templates/create/video-cutscene/config/gameplay/.gitkeep +0 -0
- package/templates/create/video-cutscene/content/gameplay/.gitkeep +0 -0
- package/templates/create/video-cutscene/content/registries/.gitkeep +0 -0
- package/templates/create/video-cutscene/docs/design/loop.md +22 -0
- package/templates/create/video-cutscene/prefabs/.gitkeep +0 -0
- package/templates/create/video-cutscene/scenes/boot.scene.js +11 -0
- package/templates/create/video-cutscene/scenes/cutscene.scene.js +113 -0
- package/templates/create/video-cutscene/scenes/gameplay.scene.js +50 -0
- package/templates/create/video-cutscene/src/main.js +17 -0
- package/templates/create/video-cutscene/src/runtime/app.js +52 -0
- package/templates/create/video-cutscene/src/runtime/capabilities.js +35 -0
- package/templates/create/video-cutscene/src/runtime/state.js +13 -0
- package/templates/create/video-cutscene/ui/.gitkeep +0 -0
- package/templates/create-bin/play.js +1187 -0
- package/templates/make/README.md +46 -0
- package/templates/make/catalog.json +51 -0
- package/templates/make/component/files/{{MAKE_NAME}}.component.js +20 -0
- package/templates/make/component/manifest.json +9 -0
- package/templates/make/data/files/{{MAKE_NAME}}.json +14 -0
- package/templates/make/data/manifest.json +9 -0
- package/templates/make/material/files/{{MAKE_NAME}}.material.json +17 -0
- package/templates/make/material/manifest.json +9 -0
- package/templates/make/prefab/files/{{MAKE_NAME}}.prefab.js +20 -0
- package/templates/make/prefab/manifest.json +9 -0
- package/templates/make/scene/files/{{MAKE_NAME}}.scene.js +31 -0
- package/templates/make/scene/manifest.json +9 -0
- package/templates/make/shader/files/{{MAKE_NAME}}.shader.js +23 -0
- package/templates/make/shader/manifest.json +9 -0
- package/templates/make/system/files/{{MAKE_NAME}}.system.js +15 -0
- package/templates/make/system/manifest.json +9 -0
- package/templates/make/ui-screen/files/{{MAKE_NAME}}.screen.js +16 -0
- package/templates/make/ui-screen/files/{{MAKE_NAME}}.screen.json +23 -0
- package/templates/make/ui-screen/manifest.json +10 -0
- package/templates/make-starters/deckbuilder-2d/card/files/{{MAKE_NAME}}.card.js +22 -0
- package/templates/make-starters/deckbuilder-2d/card/manifest.json +9 -0
- package/templates/make-starters/deckbuilder-2d/catalog.json +34 -0
- package/templates/make-starters/deckbuilder-2d/encounter/files/{{MAKE_NAME}}.encounter.js +18 -0
- package/templates/make-starters/deckbuilder-2d/encounter/manifest.json +9 -0
- package/templates/make-starters/deckbuilder-2d/enemy/files/{{MAKE_NAME}}.enemy.js +28 -0
- package/templates/make-starters/deckbuilder-2d/enemy/manifest.json +9 -0
- package/templates/make-starters/deckbuilder-2d/relic/files/{{MAKE_NAME}}.relic.js +23 -0
- package/templates/make-starters/deckbuilder-2d/relic/manifest.json +9 -0
- package/templates/retro/platformer/README.md +10 -0
- package/templates/retro/platformer/assets/retro/assets.json +91 -0
- package/templates/retro/platformer/aura.config.json +7 -0
- package/templates/retro/platformer/package.json +5 -0
- package/templates/retro/platformer/src/main.js +40 -0
- package/templates/retro/puzzle-grid/README.md +10 -0
- package/templates/retro/puzzle-grid/assets/retro/assets.json +90 -0
- package/templates/retro/puzzle-grid/aura.config.json +7 -0
- package/templates/retro/puzzle-grid/package.json +5 -0
- package/templates/retro/puzzle-grid/src/main.js +29 -0
- package/templates/retro/tactics-grid/README.md +10 -0
- package/templates/retro/tactics-grid/assets/retro/assets.json +90 -0
- package/templates/retro/tactics-grid/aura.config.json +7 -0
- package/templates/retro/tactics-grid/package.json +5 -0
- package/templates/retro/tactics-grid/src/main.js +35 -0
- package/templates/retro/topdown-adventure/README.md +10 -0
- package/templates/retro/topdown-adventure/assets/retro/assets.json +95 -0
- package/templates/retro/topdown-adventure/aura.config.json +7 -0
- package/templates/retro/topdown-adventure/package.json +5 -0
- package/templates/retro/topdown-adventure/src/main.js +29 -0
- package/templates/skills/aurajs/SKILL.md +61 -5
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, relative, resolve } from 'node:path';
|
|
3
|
+
import { pathToFileURL } from 'node:url';
|
|
4
|
+
|
|
5
|
+
import { loadMakeCatalog } from './make-catalog.mjs';
|
|
6
|
+
|
|
7
|
+
export const STARTER_CONTENT_REGISTRY_SCHEMA = 'aurajs.starter-content-registry.v1';
|
|
8
|
+
|
|
9
|
+
function normalizeProjectRelativePath(value) {
|
|
10
|
+
return String(value || '').split(/[/\\]+/g).filter(Boolean).join('/');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function toProjectRelativePath(projectRoot, absolutePath) {
|
|
14
|
+
return normalizeProjectRelativePath(relative(projectRoot, absolutePath));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function compareEntries(left, right) {
|
|
18
|
+
return left.id.localeCompare(right.id) || left.path.localeCompare(right.path);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function buildStarterContentEntry({ id, kind, path, exportName = 'default' }) {
|
|
22
|
+
return {
|
|
23
|
+
id: String(id || '').trim(),
|
|
24
|
+
kind: String(kind || '').trim(),
|
|
25
|
+
path: normalizeProjectRelativePath(path),
|
|
26
|
+
exportName: typeof exportName === 'string' && exportName.trim().length > 0 ? exportName.trim() : 'default',
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function normalizeStarterContentRegistry(data, { template, family }) {
|
|
31
|
+
if (!data || typeof data !== 'object' || Array.isArray(data)) {
|
|
32
|
+
throw new Error('Starter content registry must default-export an object.');
|
|
33
|
+
}
|
|
34
|
+
const normalizedEntries = Array.isArray(data.entries)
|
|
35
|
+
? data.entries.map((entry, index) => {
|
|
36
|
+
if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {
|
|
37
|
+
throw new Error(`Starter content registry entry at index ${index} must be an object.`);
|
|
38
|
+
}
|
|
39
|
+
const id = String(entry.id || '').trim();
|
|
40
|
+
const kind = String(entry.kind || '').trim();
|
|
41
|
+
const path = String(entry.path || '').trim();
|
|
42
|
+
if (!id) {
|
|
43
|
+
throw new Error(`Starter content registry entry at index ${index} is missing id.`);
|
|
44
|
+
}
|
|
45
|
+
if (!kind) {
|
|
46
|
+
throw new Error(`Starter content registry entry "${id}" is missing kind.`);
|
|
47
|
+
}
|
|
48
|
+
if (!path) {
|
|
49
|
+
throw new Error(`Starter content registry entry "${id}" is missing path.`);
|
|
50
|
+
}
|
|
51
|
+
return buildStarterContentEntry({
|
|
52
|
+
id,
|
|
53
|
+
kind,
|
|
54
|
+
path,
|
|
55
|
+
exportName: entry.exportName,
|
|
56
|
+
});
|
|
57
|
+
})
|
|
58
|
+
: [];
|
|
59
|
+
|
|
60
|
+
normalizedEntries.sort(compareEntries);
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
schema: typeof data.schema === 'string' && data.schema.trim().length > 0 ? data.schema.trim() : STARTER_CONTENT_REGISTRY_SCHEMA,
|
|
64
|
+
template: typeof data.template === 'string' && data.template.trim().length > 0 ? data.template.trim() : String(template || 'blank'),
|
|
65
|
+
family: typeof data.family === 'string' && data.family.trim().length > 0 ? data.family.trim() : String(family || ''),
|
|
66
|
+
title: typeof data.title === 'string' && data.title.trim().length > 0 ? data.title.trim() : null,
|
|
67
|
+
entries: normalizedEntries,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function serializeValue(value, indent = 0) {
|
|
72
|
+
return JSON.stringify(value, null, 2)
|
|
73
|
+
.split('\n')
|
|
74
|
+
.map((line, index) => (index === 0 ? line : `${' '.repeat(indent)}${line}`))
|
|
75
|
+
.join('\n');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function renderStarterContentRegistryModule(model) {
|
|
79
|
+
const normalized = normalizeStarterContentRegistry(model, {
|
|
80
|
+
template: model?.template,
|
|
81
|
+
family: model?.family,
|
|
82
|
+
});
|
|
83
|
+
return `const starterContentRegistry = ${serializeValue({
|
|
84
|
+
schema: STARTER_CONTENT_REGISTRY_SCHEMA,
|
|
85
|
+
template: normalized.template,
|
|
86
|
+
family: normalized.family,
|
|
87
|
+
title: normalized.title,
|
|
88
|
+
entries: normalized.entries,
|
|
89
|
+
}, 0)};
|
|
90
|
+
|
|
91
|
+
export function createStarterContentRegistry() {
|
|
92
|
+
return starterContentRegistry;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export default starterContentRegistry;
|
|
96
|
+
`;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function resolveStarterContentFamilies(projectRoot, options = {}) {
|
|
100
|
+
const catalog = loadMakeCatalog({
|
|
101
|
+
projectRoot,
|
|
102
|
+
catalogRoot: options.catalogRoot,
|
|
103
|
+
});
|
|
104
|
+
const families = new Map();
|
|
105
|
+
for (const entry of catalog) {
|
|
106
|
+
if (!entry.starterContentFamily || !entry.starterContentRegistry) continue;
|
|
107
|
+
const key = `${entry.starterContentFamily}::${entry.starterContentRegistry}`;
|
|
108
|
+
if (!families.has(key)) {
|
|
109
|
+
families.set(key, {
|
|
110
|
+
family: entry.starterContentFamily,
|
|
111
|
+
registryPath: normalizeProjectRelativePath(entry.starterContentRegistry),
|
|
112
|
+
kinds: new Set(),
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
families.get(key).kinds.add(entry.id);
|
|
116
|
+
}
|
|
117
|
+
return [...families.values()].map((entry) => ({
|
|
118
|
+
family: entry.family,
|
|
119
|
+
registryPath: entry.registryPath,
|
|
120
|
+
kinds: [...entry.kinds].sort(),
|
|
121
|
+
}));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async function importRegistryModule(projectRoot, registryPath) {
|
|
125
|
+
const absolutePath = resolve(projectRoot, registryPath);
|
|
126
|
+
return import(`${pathToFileURL(absolutePath).href}?t=${Date.now()}-${Math.random().toString(16).slice(2)}`);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async function loadStarterContentRegistryFile({ projectRoot, family, registryPath }) {
|
|
130
|
+
const absolutePath = resolve(projectRoot, registryPath);
|
|
131
|
+
if (!existsSync(absolutePath)) {
|
|
132
|
+
return normalizeStarterContentRegistry({
|
|
133
|
+
schema: STARTER_CONTENT_REGISTRY_SCHEMA,
|
|
134
|
+
template: null,
|
|
135
|
+
family,
|
|
136
|
+
title: null,
|
|
137
|
+
entries: [],
|
|
138
|
+
}, { template: null, family });
|
|
139
|
+
}
|
|
140
|
+
const imported = await importRegistryModule(projectRoot, registryPath);
|
|
141
|
+
return normalizeStarterContentRegistry(imported.default, { template: null, family });
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export async function listStarterContentRegistries({ projectRoot, catalogRoot = null }) {
|
|
145
|
+
const families = resolveStarterContentFamilies(resolve(projectRoot), { catalogRoot });
|
|
146
|
+
const results = [];
|
|
147
|
+
for (const spec of families) {
|
|
148
|
+
const registry = await loadStarterContentRegistryFile({
|
|
149
|
+
projectRoot,
|
|
150
|
+
family: spec.family,
|
|
151
|
+
registryPath: spec.registryPath,
|
|
152
|
+
});
|
|
153
|
+
results.push({
|
|
154
|
+
family: spec.family,
|
|
155
|
+
registryPath: spec.registryPath,
|
|
156
|
+
kinds: spec.kinds,
|
|
157
|
+
title: registry.title,
|
|
158
|
+
entries: registry.entries,
|
|
159
|
+
exists: existsSync(resolve(projectRoot, spec.registryPath)),
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
return results;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export async function registerGeneratedStarterContentFiles({ projectRoot, kindSpec, name, files }) {
|
|
166
|
+
if (!kindSpec?.starterContentFamily || !kindSpec?.starterContentRegistry) {
|
|
167
|
+
return {
|
|
168
|
+
changed: false,
|
|
169
|
+
registryPath: null,
|
|
170
|
+
files: [],
|
|
171
|
+
family: null,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const primaryFile = Array.isArray(files)
|
|
176
|
+
? files.find((entry) => String(entry).endsWith('.js')) || files[0] || null
|
|
177
|
+
: null;
|
|
178
|
+
if (!primaryFile) {
|
|
179
|
+
return {
|
|
180
|
+
changed: false,
|
|
181
|
+
registryPath: null,
|
|
182
|
+
files: [],
|
|
183
|
+
family: null,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const normalizedProjectRoot = resolve(projectRoot);
|
|
188
|
+
const registryPath = normalizeProjectRelativePath(kindSpec.starterContentRegistry);
|
|
189
|
+
const absoluteRegistryPath = resolve(normalizedProjectRoot, registryPath);
|
|
190
|
+
const existing = await loadStarterContentRegistryFile({
|
|
191
|
+
projectRoot: normalizedProjectRoot,
|
|
192
|
+
family: kindSpec.starterContentFamily,
|
|
193
|
+
registryPath,
|
|
194
|
+
});
|
|
195
|
+
const entries = [...existing.entries];
|
|
196
|
+
const nextEntry = buildStarterContentEntry({
|
|
197
|
+
id: name,
|
|
198
|
+
kind: kindSpec.id || kindSpec.kind,
|
|
199
|
+
path: primaryFile,
|
|
200
|
+
exportName: 'default',
|
|
201
|
+
});
|
|
202
|
+
const index = entries.findIndex((entry) => entry.id === nextEntry.id);
|
|
203
|
+
if (index === -1) {
|
|
204
|
+
entries.push(nextEntry);
|
|
205
|
+
} else {
|
|
206
|
+
entries[index] = {
|
|
207
|
+
...entries[index],
|
|
208
|
+
...nextEntry,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const nextRegistry = normalizeStarterContentRegistry({
|
|
213
|
+
schema: STARTER_CONTENT_REGISTRY_SCHEMA,
|
|
214
|
+
template: existing.template,
|
|
215
|
+
family: kindSpec.starterContentFamily,
|
|
216
|
+
title: existing.title,
|
|
217
|
+
entries,
|
|
218
|
+
}, {
|
|
219
|
+
template: existing.template,
|
|
220
|
+
family: kindSpec.starterContentFamily,
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
mkdirSync(dirname(absoluteRegistryPath), { recursive: true });
|
|
224
|
+
writeFileSync(absoluteRegistryPath, renderStarterContentRegistryModule(nextRegistry), 'utf8');
|
|
225
|
+
|
|
226
|
+
return {
|
|
227
|
+
changed: true,
|
|
228
|
+
family: kindSpec.starterContentFamily,
|
|
229
|
+
registryPath,
|
|
230
|
+
files: [toProjectRelativePath(normalizedProjectRoot, absoluteRegistryPath)],
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export async function validateStarterContentRegistries({ projectRoot, catalogRoot = null }) {
|
|
235
|
+
const registries = await listStarterContentRegistries({ projectRoot, catalogRoot });
|
|
236
|
+
const errors = [];
|
|
237
|
+
|
|
238
|
+
for (const registry of registries) {
|
|
239
|
+
if (!registry.exists) {
|
|
240
|
+
errors.push({
|
|
241
|
+
reasonCode: 'starter_content_registry_missing',
|
|
242
|
+
message: `Missing starter content registry: ${registry.registryPath}.`,
|
|
243
|
+
path: registry.registryPath,
|
|
244
|
+
});
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const seen = new Set();
|
|
249
|
+
for (const entry of registry.entries) {
|
|
250
|
+
if (seen.has(entry.id)) {
|
|
251
|
+
errors.push({
|
|
252
|
+
reasonCode: 'starter_content_duplicate_id',
|
|
253
|
+
message: `Duplicate starter content id "${entry.id}" in ${registry.registryPath}.`,
|
|
254
|
+
path: registry.registryPath,
|
|
255
|
+
});
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
seen.add(entry.id);
|
|
259
|
+
|
|
260
|
+
const absolutePath = resolve(projectRoot, entry.path);
|
|
261
|
+
if (!existsSync(absolutePath)) {
|
|
262
|
+
errors.push({
|
|
263
|
+
reasonCode: 'starter_content_path_missing',
|
|
264
|
+
message: `Starter content path does not exist: ${entry.path}`,
|
|
265
|
+
path: entry.path,
|
|
266
|
+
});
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
try {
|
|
271
|
+
const imported = await import(`${pathToFileURL(absolutePath).href}?t=${Date.now()}-${Math.random().toString(16).slice(2)}`);
|
|
272
|
+
if (entry.exportName !== 'default' && typeof imported?.[entry.exportName] === 'undefined') {
|
|
273
|
+
throw new Error(`Missing export "${entry.exportName}".`);
|
|
274
|
+
}
|
|
275
|
+
if (entry.exportName === 'default' && typeof imported?.default === 'undefined') {
|
|
276
|
+
throw new Error('Missing default export.');
|
|
277
|
+
}
|
|
278
|
+
} catch (error) {
|
|
279
|
+
errors.push({
|
|
280
|
+
reasonCode: 'starter_content_import_broken',
|
|
281
|
+
message: `Unable to import ${entry.path}: ${error instanceof Error ? error.message : String(error)}`,
|
|
282
|
+
path: entry.path,
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
return {
|
|
289
|
+
registries,
|
|
290
|
+
errors,
|
|
291
|
+
};
|
|
292
|
+
}
|