@wildshard/sdk 0.0.1 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/GUIDE.md +895 -0
- package/README.md +13 -5
- package/bin/wildshard.mjs +38 -0
- package/lint/declaration-config.d.mts +2 -0
- package/lint/declaration-config.mjs +19 -0
- package/lint/engine-plugin.d.mts +2 -0
- package/lint/engine-plugin.mjs +40 -0
- package/lint/host-callbacks.d.mts +6 -0
- package/lint/host-callbacks.mjs +123 -0
- package/lint/host-files.d.mts +1 -0
- package/lint/host-files.mjs +7 -0
- package/lint/layer-exports.d.mts +2 -0
- package/lint/layer-exports.mjs +21 -0
- package/lint/legacy-line-basis.json +995 -0
- package/lint/nine-tiling-baseline.json +35 -0
- package/lint/ratchet.json +11 -0
- package/lint/runtime-files.d.mts +12 -0
- package/lint/runtime-files.json +16 -0
- package/lint/runtime-files.mjs +69 -0
- package/lint/runtime-performance.d.mts +6 -0
- package/lint/runtime-performance.mjs +184 -0
- package/lint/sdk-plugin.d.mts +4 -0
- package/lint/sdk-plugin.mjs +134 -0
- package/lint/shardfile-boundaries.d.mts +10 -0
- package/lint/shardfile-boundaries.mjs +122 -0
- package/lint/tile-bake-debt.json +556 -0
- package/package.json +365 -3
- package/scripts/agent-parity.mjs +1524 -0
- package/scripts/agent-sync.mjs +518 -0
- package/scripts/apfs-clone.mjs +67 -0
- package/scripts/assert-store-layout.mjs +23 -0
- package/scripts/astc6-phone-cap.d.mts +3 -0
- package/scripts/astc6-phone-cap.mjs +137 -0
- package/scripts/audit-assets.d.mts +10 -0
- package/scripts/audit-assets.mjs +151 -0
- package/scripts/bake/coatFiles.d.mts +6 -0
- package/scripts/bake/coatFiles.mjs +37 -0
- package/scripts/bake/environment.d.mts +2 -0
- package/scripts/bake/environment.mjs +58 -0
- package/scripts/bake/far-proxies.mjs +45 -0
- package/scripts/bake/keyed-sky.d.mts +4 -0
- package/scripts/bake/keyed-sky.mjs +34 -0
- package/scripts/bake/movers.mjs +56 -0
- package/scripts/bake/nativeWorld.d.mts +6 -0
- package/scripts/bake/nativeWorld.mjs +43 -0
- package/scripts/bake/navmeshGround.ts +22 -0
- package/scripts/bake/near-placeholder.mjs +331 -0
- package/scripts/bake/placeholderShards.mjs +41 -0
- package/scripts/bake/skins.mjs +15 -0
- package/scripts/bake/template-skins.mjs +33 -0
- package/scripts/bake/viewmodelBytes.ts +26 -0
- package/scripts/bake/viewmodelPage.ts +11 -0
- package/scripts/bake/worldHost.d.mts +35 -0
- package/scripts/bake/worldHost.mjs +110 -0
- package/scripts/bake-astc6.cache.json +80 -0
- package/scripts/bake-astc6.far-reach.cache.json +23 -0
- package/scripts/bake-astc6.list.json +111 -0
- package/scripts/bake-astc6.mjs +279 -0
- package/scripts/bake-astc6.nalati-grasslands.cache.json +42 -0
- package/scripts/bake-catalogue.mjs +44 -0
- package/scripts/bake-check.mjs +54 -0
- package/scripts/bake-chunk.mjs +124 -0
- package/scripts/bake-cloud-field.mjs +24 -0
- package/scripts/bake-coats.mjs +110 -0
- package/scripts/bake-data-maps.d.mts +24 -0
- package/scripts/bake-data-maps.mjs +72 -0
- package/scripts/bake-entry-programs.mjs +117 -0
- package/scripts/bake-geometry.mjs +106 -0
- package/scripts/bake-hybrid-tiles.mjs +28 -0
- package/scripts/bake-ktx2.cache.json +276 -0
- package/scripts/bake-ktx2.list.json +365 -0
- package/scripts/bake-ktx2.mjs +477 -0
- package/scripts/bake-map-glb.mjs +127 -0
- package/scripts/bake-map-rest.d.mts +7 -0
- package/scripts/bake-map-rest.mjs +50 -0
- package/scripts/bake-maps.mjs +200 -0
- package/scripts/bake-navmesh.mjs +259 -0
- package/scripts/bake-packs.mjs +129 -0
- package/scripts/bake-pickups.mjs +102 -0
- package/scripts/bake-query-terrain.mjs +64 -0
- package/scripts/bake-recurve-pool.mjs +16 -0
- package/scripts/bake-section-schemas.d.mts +3 -0
- package/scripts/bake-template-shardfile.mjs +32 -0
- package/scripts/bake-textures.mjs +80 -0
- package/scripts/bake-viewmodel-sets.json +45 -0
- package/scripts/bake-viewmodel-sets.mjs +137 -0
- package/scripts/bake-voxel-ao.mjs +119 -0
- package/scripts/bake-water-ripples.mjs +25 -0
- package/scripts/blender/README.md +129 -0
- package/scripts/blender/build.sh +166 -0
- package/scripts/blender/lib/export-scene.mjs +129 -0
- package/scripts/blender/lib/glb-digest.mjs +188 -0
- package/scripts/blender/lib/glb.py +68 -0
- package/scripts/blender/lib/save_blend.py +17 -0
- package/scripts/blender/lib/world_fixture.py +55 -0
- package/scripts/blender/targets.json +591 -0
- package/scripts/build-sdk.mjs +95 -0
- package/scripts/build-shardfiles.d.mts +7 -0
- package/scripts/build-shardfiles.mjs +206 -0
- package/scripts/capture-hero.mjs +137 -0
- package/scripts/check-lift-review.mjs +23 -0
- package/scripts/chromium-keychain-check.mjs +139 -0
- package/scripts/chromium-keychain.d.mts +1 -0
- package/scripts/chromium-keychain.mjs +5 -0
- package/scripts/compile-script.d.mts +3 -0
- package/scripts/compile-script.mjs +8 -0
- package/scripts/creature-color.mjs +255 -0
- package/scripts/decide/calibrate.py +127 -0
- package/scripts/decide/calibration/2026-10-03/labels-s1.tsv +281 -0
- package/scripts/decide/calibration/2026-10-03/labels-s2.tsv +97 -0
- package/scripts/decide/calibration/2026-10-03/labels-s3.tsv +48 -0
- package/scripts/decide/calibration/2026-10-03/labels-s3b.tsv +26 -0
- package/scripts/decide/calibration/2026-10-03/res-capture-status-v1.jsonl +376 -0
- package/scripts/decide/calibration/2026-10-03/res-text-garbled-strings.jsonl +48 -0
- package/scripts/decide/calibration/2026-10-03/res-text-garbled-v1.jsonl +73 -0
- package/scripts/decide/decide.py +262 -0
- package/scripts/decide/decide.sh +50 -0
- package/scripts/decide/layer-purity-pilot.mjs +41 -0
- package/scripts/decide/sets/capture-status.json +46 -0
- package/scripts/decide/sets/layer-purity.json +28 -0
- package/scripts/decide/sets/text-garbled.json +17 -0
- package/scripts/decide/test_decide.py +37 -0
- package/scripts/docs.mjs +15 -0
- package/scripts/entry-reads/crawl.ts +152 -0
- package/scripts/entry-reads/tsconfig.json +25 -0
- package/scripts/gen-format-schema.d.mts +2 -0
- package/scripts/gen-format-schema.mjs +21 -0
- package/scripts/gen-host-catalogue.d.mts +14 -0
- package/scripts/gen-host-catalogue.mjs +108 -0
- package/scripts/gen-shard-layout-doc.d.mts +4 -0
- package/scripts/gen-shard-layout-doc.mjs +55 -0
- package/scripts/gen-shards.d.mts +17 -0
- package/scripts/gen-shards.mjs +311 -0
- package/scripts/goldens/capture-inputs.d.mts +4 -0
- package/scripts/goldens/capture-inputs.mjs +34 -0
- package/scripts/goldens/colour_shift.py +27 -0
- package/scripts/goldens/native-residency.d.mts +10 -0
- package/scripts/goldens/native-residency.mjs +104 -0
- package/scripts/goldens/plot-inputs.d.mts +12 -0
- package/scripts/goldens/plot-inputs.mjs +46 -0
- package/scripts/gpu-texmem.mjs +98 -0
- package/scripts/horizon-matte/config.py +24 -0
- package/scripts/horizon-matte/encode.py +91 -0
- package/scripts/horizon-matte/key.py +141 -0
- package/scripts/horizon-matte/mkjobs.py +33 -0
- package/scripts/horizon-matte/mkjobs_day2.py +11 -0
- package/scripts/horizon-matte/overlap.py +80 -0
- package/scripts/horizon-matte/run_codex.py +57 -0
- package/scripts/horizon-matte/stitch.py +133 -0
- package/scripts/img2mesh/CC0.md +105 -0
- package/scripts/img2mesh/README.md +209 -0
- package/scripts/img2mesh/ab_board.py +102 -0
- package/scripts/img2mesh/birds/birds.json +255 -0
- package/scripts/img2mesh/birds/birds_atlas.py +150 -0
- package/scripts/img2mesh/birds/birds_fix_preview.mjs +103 -0
- package/scripts/img2mesh/birds/birds_fix_render.py +75 -0
- package/scripts/img2mesh/birds/birds_pack.py +110 -0
- package/scripts/img2mesh/birds/birds_phone_b.py +112 -0
- package/scripts/img2mesh/birds/birds_post.py +550 -0
- package/scripts/img2mesh/birds/birds_render.py +125 -0
- package/scripts/img2mesh/birds/birds_sheet.py +33 -0
- package/scripts/img2mesh/birds/birds_view.py +60 -0
- package/scripts/img2mesh/board.py +100 -0
- package/scripts/img2mesh/build_cc0.sh +52 -0
- package/scripts/img2mesh/build_driftwood.sh +12 -0
- package/scripts/img2mesh/build_faces.sh +53 -0
- package/scripts/img2mesh/build_props.py +81 -0
- package/scripts/img2mesh/cc0_export.py +186 -0
- package/scripts/img2mesh/driftwood_post.py +571 -0
- package/scripts/img2mesh/e304_faces.sh +67 -0
- package/scripts/img2mesh/face_remaster.py +911 -0
- package/scripts/img2mesh/face_views.py +95 -0
- package/scripts/img2mesh/faces-e304.json +9 -0
- package/scripts/img2mesh/faces.json +30 -0
- package/scripts/img2mesh/head_cut.py +100 -0
- package/scripts/img2mesh/hi3d_paint.py +94 -0
- package/scripts/img2mesh/hi3d_refine.py +161 -0
- package/scripts/img2mesh/hunyuan_cpu_rasterizer.sh +42 -0
- package/scripts/img2mesh/pine_hollow_phone.sh +13 -0
- package/scripts/img2mesh/props/coral-arch.json +32 -0
- package/scripts/img2mesh/props/ember-furnace.json +30 -0
- package/scripts/img2mesh/props/night-market-gate.json +10 -0
- package/scripts/img2mesh/render_still.py +86 -0
- package/scripts/img2mesh/rig_strip.mjs +46 -0
- package/scripts/img2mesh/rig_transfer.mjs +104 -0
- package/scripts/img2mesh/split_sheet.py +48 -0
- package/scripts/img2mesh/trellis_batch.py +110 -0
- package/scripts/img2mesh/versus_board.py +114 -0
- package/scripts/import-bundle.d.mts +2 -0
- package/scripts/import-bundle.mjs +20 -0
- package/scripts/ktx2-ab-board.py +133 -0
- package/scripts/ktx2-ab.mjs +111 -0
- package/scripts/ktx2-settings.mjs +18 -0
- package/scripts/land.d.mts +14 -0
- package/scripts/land.mjs +809 -0
- package/scripts/lint-dispatch.mjs +14 -0
- package/scripts/map-bake-frames.d.mts +4 -0
- package/scripts/map-bake-frames.mjs +23 -0
- package/scripts/map-geometry.d.mts +9 -0
- package/scripts/map-geometry.mjs +29 -0
- package/scripts/map-world.mjs +162 -0
- package/scripts/mockup-local.sh +46 -0
- package/scripts/music/export-midi.mjs +68 -0
- package/scripts/music/gen/analyze.py +308 -0
- package/scripts/music/gen/audio_jobs.py +46 -0
- package/scripts/music/gen/briefs.json +51 -0
- package/scripts/music/gen/build_page.py +334 -0
- package/scripts/music/gen/folk.json +3187 -0
- package/scripts/music/gen/gen_ace_step.py +156 -0
- package/scripts/music/gen/gen_heartmula.py +187 -0
- package/scripts/music/gen/gen_minimax.py +143 -0
- package/scripts/music/gen/gen_sao.py +122 -0
- package/scripts/music/gen/gen_sao_small.py +104 -0
- package/scripts/music/gen/gen_sfx.py +98 -0
- package/scripts/music/gen/gen_sfx_ezaudio.py +112 -0
- package/scripts/music/gen/gen_sfx_moss.py +112 -0
- package/scripts/music/gen/models.json +61 -0
- package/scripts/music/gen/nalati-jobs.json +104 -0
- package/scripts/music/gen/nalati-score-build.json +119 -0
- package/scripts/music/gen/nalati-score.json +3448 -0
- package/scripts/music/gen/ob7-fit-decisions.json +38 -0
- package/scripts/music/gen/ob7-score-jobs.json +152 -0
- package/scripts/music/gen/ob7-sfx-jobs.json +897 -0
- package/scripts/music/gen/ob7_build.py +469 -0
- package/scripts/music/gen/ob7_generate.py +67 -0
- package/scripts/music/gen/ob7_run.sh +42 -0
- package/scripts/music/gen/orchestral.json +3187 -0
- package/scripts/music/gen/own_score.py +486 -0
- package/scripts/music/gen/ph-jobs.json +27 -0
- package/scripts/music/gen/ph_page.py +222 -0
- package/scripts/music/gen/piano.json +3175 -0
- package/scripts/music/gen/rank_v3.py +248 -0
- package/scripts/music/gen/sfx-best.json +2486 -0
- package/scripts/music/gen/sfx-ezaudio.json +4082 -0
- package/scripts/music/gen/sfx-jobs.json +57 -0
- package/scripts/music/gen/sfx-minimax-jobs.json +16 -0
- package/scripts/music/gen/sfx-minimax.json +289 -0
- package/scripts/music/gen/sfx-moss.json +4082 -0
- package/scripts/music/gen/sfx-nalati-b3-jobs.json +17 -0
- package/scripts/music/gen/sfx-nalati-jobs.json +338 -0
- package/scripts/music/gen/sfx-nalati.json +11202 -0
- package/scripts/music/gen/sfx-nd-jobs.json +57 -0
- package/scripts/music/gen/sfx-nd-moss.json +2097 -0
- package/scripts/music/gen/sfx-nd-sa3-medium.json +2097 -0
- package/scripts/music/gen/sfx-nd-summary.json +38 -0
- package/scripts/music/gen/sfx-peaks.json +7 -0
- package/scripts/music/gen/sfx-ph-jobs.json +169 -0
- package/scripts/music/gen/sfx-ph-moss.json +6564 -0
- package/scripts/music/gen/sfx-ph-sa3-medium.json +7239 -0
- package/scripts/music/gen/sfx-ph-summary.json +63 -0
- package/scripts/music/gen/sfx-sa3-medium.json +4082 -0
- package/scripts/music/gen/sfx-sa3.json +4082 -0
- package/scripts/music/gen/sfx-summary.json +107 -0
- package/scripts/music/gen/sfx_build.py +332 -0
- package/scripts/music/gen/sfx_merge.py +255 -0
- package/scripts/music/gen/sfx_minimax.py +61 -0
- package/scripts/music/gen/sfx_nalati.py +331 -0
- package/scripts/music/gen/sfx_sprite.py +424 -0
- package/scripts/music/gen/stems.py +539 -0
- package/scripts/music/gen/test_loop_meter.py +29 -0
- package/scripts/music/gen/test_ob7_provenance.py +77 -0
- package/scripts/music/gen/v3-folk-build.json +148 -0
- package/scripts/music/gen/v3-folk.json +1818 -0
- package/scripts/music/gen/v3-jobs.json +145 -0
- package/scripts/music/gen/v3-orchestral-build.json +148 -0
- package/scripts/music/gen/v3-orchestral.json +1813 -0
- package/scripts/music/gen/v3-ph-folk-build.json +94 -0
- package/scripts/music/gen/v3-ph-folk.json +1806 -0
- package/scripts/music/gen/v3-ph-orchestral-build.json +94 -0
- package/scripts/music/gen/v3-ph-orchestral.json +1824 -0
- package/scripts/music/gen/v3-ph-piano-build.json +94 -0
- package/scripts/music/gen/v3-ph-piano.json +1818 -0
- package/scripts/music/gen/v3-piano-build.json +148 -0
- package/scripts/music/gen/v3-piano.json +1813 -0
- package/scripts/music/wildshard-theme.mid +0 -0
- package/scripts/music/wildshard-trailer30.mid +0 -0
- package/scripts/named-blob-output.d.mts +8 -0
- package/scripts/named-blob-output.mjs +48 -0
- package/scripts/pack-all.mjs +15 -0
- package/scripts/pid-lock.d.mts +1 -0
- package/scripts/pid-lock.mjs +63 -0
- package/scripts/practice/bake_dummy.py +53 -0
- package/scripts/practice/build_dummies.sh +43 -0
- package/scripts/practice/dummy_parts.py +568 -0
- package/scripts/practice/dummy_rig_gate.py +139 -0
- package/scripts/practice/gate_sheet.py +36 -0
- package/scripts/practice/generate_dummy_unimate.py +132 -0
- package/scripts/practice/pack_dummy.mjs +59 -0
- package/scripts/practice/repair_dummy_weights.mjs +68 -0
- package/scripts/practice/rig_dummy.py +828 -0
- package/scripts/practice/verify_unimate_skin.mjs +356 -0
- package/scripts/preparation-seed.mjs +15 -0
- package/scripts/prepare-basis-tool.mjs +6 -0
- package/scripts/prepare-product.d.mts +14 -0
- package/scripts/prepare-product.mjs +101 -0
- package/scripts/product-build-tools.d.mts +3 -0
- package/scripts/product-build-tools.json +3 -0
- package/scripts/product-build-tools.mjs +31 -0
- package/scripts/publish-public.mjs +7 -0
- package/scripts/push-tables.d.mts +1 -0
- package/scripts/push-tables.mjs +28 -0
- package/scripts/record-shard-mounts.mjs +133 -0
- package/scripts/sdk-externals.d.mts +2 -0
- package/scripts/sdk-externals.mjs +2 -0
- package/scripts/section-inventory.ts +209 -0
- package/scripts/select-candidate.mjs +15 -0
- package/scripts/shard-build-pool.d.mts +4 -0
- package/scripts/shard-build-pool.mjs +53 -0
- package/scripts/shard-line-baseline.json +17 -0
- package/scripts/shard-milestones.d.mts +15 -0
- package/scripts/shard-milestones.mjs +105 -0
- package/scripts/shard-output-report.d.mts +9 -0
- package/scripts/shard-output-report.mjs +85 -0
- package/scripts/shard-platform-cli.mjs +93 -0
- package/scripts/shard-progress.mjs +212 -0
- package/scripts/shard-timelapse.py +102 -0
- package/scripts/shardfile-cold-boot.mjs +79 -0
- package/scripts/shardfile-vite.d.mts +4 -0
- package/scripts/shardfile-vite.mjs +20 -0
- package/scripts/simplify-models.mjs +24 -0
- package/scripts/site-facts.mjs +88 -0
- package/scripts/test-template-gate.mjs +44 -0
- package/scripts/test_golden_compare.py +68 -0
- package/scripts/tex-tiers.cache.json +181 -0
- package/scripts/tex-tiers.mjs +240 -0
- package/scripts/texmem-probe.mjs +184 -0
- package/scripts/unused-assets.mjs +173 -0
- package/scripts/vite-tmp.d.mts +23 -0
- package/scripts/vite-tmp.mjs +157 -0
- package/scripts/wave-line-baselines.json +32 -0
- package/scripts/wildshard.d.mts +4 -0
- package/scripts/wildshard.mjs +105 -0
- package/scripts/witness-checkpoints.d.mts +10 -0
- package/scripts/witness-checkpoints.mjs +84 -0
- package/scripts/witness-generation.d.mts +10 -0
- package/scripts/witness-generation.mjs +45 -0
- package/scripts/witness-manifests.d.mts +8 -0
- package/scripts/witness-manifests.mjs +157 -0
- package/scripts/worktree-ignore.d.mts +4 -0
- package/scripts/worktree-ignore.mjs +36 -0
- package/scripts/worktree-reap.mjs +214 -0
- package/scripts/worktree.mjs +396 -0
- package/scripts/worldclaw/capture-front.sh +28 -0
- package/scripts/worldclaw/design-template.md +62 -0
- package/scripts/worldclaw/spec-map.py +92 -0
- package/scripts/worldclaw/spec.ts +96 -0
- package/skills/wildshard/SKILL.md +50 -0
- package/skills/wildshard-goldens/SKILL.md +54 -0
- package/skills/wildshard-mockup-to-model/SKILL.md +56 -0
- package/skills/wildshard-upgrade/SKILL.md +47 -0
- package/src/.oxfmtrc.json +50 -0
- package/src/.oxlintrc.json +173 -0
- package/src/cli/account/account.ts +199 -0
- package/src/cli/account/command.ts +193 -0
- package/src/cli/account/key.ts +154 -0
- package/src/cli/args.ts +97 -0
- package/src/cli/audio/audio.ts +39 -0
- package/src/cli/bin.mjs +8 -0
- package/src/cli/delete/delete.ts +258 -0
- package/src/cli/help.ts +204 -0
- package/src/cli/hero/adopt.ts +103 -0
- package/src/cli/hero/hero.ts +112 -0
- package/src/cli/hero/stamp.ts +298 -0
- package/src/cli/main.ts +291 -0
- package/src/cli/report.ts +20 -0
- package/src/cli/shardfile/command.ts +49 -0
- package/src/cli/shardfile/shardfile.ts +192 -0
- package/src/cli/upload/api.ts +246 -0
- package/src/cli/upload/compress.ts +55 -0
- package/src/cli/upload/hero.ts +62 -0
- package/src/cli/upload/placement.ts +115 -0
- package/src/cli/upload/provenance.ts +192 -0
- package/src/cli/upload/signature.ts +30 -0
- package/src/cli/upload/upload.ts +269 -0
- package/src/cli/upload/validate.ts +74 -0
- package/src/cli/upload/wire.ts +147 -0
- package/src/cli/version.ts +63 -0
- package/src/commons/bake/portableMath.ts +187 -0
- package/src/commons/catalogue.ts +10 -0
- package/src/commons/courseProgram.ts +32 -0
- package/src/commons/practiceCourse.ts +16 -0
- package/src/commons/scripts/abi.as +14 -0
- package/src/commons/scripts/bridge.as +14 -0
- package/src/commons/scripts/course.as +63 -0
- package/src/scripts/ask-new.sh +29 -0
- package/src/scripts/asks.mjs +141 -0
- package/src/scripts/herdr-prompt.sh +34 -0
- package/src/scripts/herdr-question-open.sh +67 -0
- package/src/scripts/md-wrap.mjs +229 -0
- package/src/server/app.ts +19 -0
- package/src/server/serve.ts +49 -0
- package/src/sharddev/admission.ts +7 -0
- package/src/sharddev/agentFiles.ts +127 -0
- package/src/sharddev/arenaView.ts +15 -0
- package/src/sharddev/as/groupBankV2.ts +36 -0
- package/src/sharddev/as/groupStepV2.ts +13 -0
- package/src/sharddev/as/ws.ts +30 -0
- package/src/sharddev/as/wsV2.ts +180 -0
- package/src/sharddev/assemblyscriptCompiler.d.mts +5 -0
- package/src/sharddev/assemblyscriptCompiler.mjs +14 -0
- package/src/sharddev/assetHandle.ts +84 -0
- package/src/sharddev/assetOwner.ts +70 -0
- package/src/sharddev/assetScope.ts +30 -0
- package/src/sharddev/assets.ts +21 -0
- package/src/sharddev/audio.ts +9 -0
- package/src/sharddev/audioEncode.ts +211 -0
- package/src/sharddev/author.ts +3 -0
- package/src/sharddev/authorError.ts +28 -0
- package/src/sharddev/authorManifest.ts +39 -0
- package/src/sharddev/bake/annulus.ts +19 -0
- package/src/sharddev/bake/assemblyscriptMemo.ts +76 -0
- package/src/sharddev/bake/assemblyscriptMemoPort.ts +4 -0
- package/src/sharddev/bake/authoredWorld.ts +201 -0
- package/src/sharddev/bake/basisEncoder.ts +95 -0
- package/src/sharddev/bake/basisGlb.ts +85 -0
- package/src/sharddev/bake/basisTool.ts +74 -0
- package/src/sharddev/bake/basisToolInputs.ts +476 -0
- package/src/sharddev/bake/byteCodec.ts +33 -0
- package/src/sharddev/bake/canvasAtlas.ts +406 -0
- package/src/sharddev/bake/coarseCopy.ts +59 -0
- package/src/sharddev/bake/colliders.ts +87 -0
- package/src/sharddev/bake/compactGlb.ts +224 -0
- package/src/sharddev/bake/compileScript.ts +119 -0
- package/src/sharddev/bake/compileScriptV2.ts +75 -0
- package/src/sharddev/bake/contactRows.ts +84 -0
- package/src/sharddev/bake/creaturePlacement.ts +117 -0
- package/src/sharddev/bake/export.ts +67 -0
- package/src/sharddev/bake/facetedGeometry.ts +379 -0
- package/src/sharddev/bake/farImpostor.ts +120 -0
- package/src/sharddev/bake/forest.ts +100 -0
- package/src/sharddev/bake/format-hook.mjs +2 -0
- package/src/sharddev/bake/generatorGlb.ts +23 -0
- package/src/sharddev/bake/geometryBounds.ts +77 -0
- package/src/sharddev/bake/geometryError.ts +48 -0
- package/src/sharddev/bake/glb.ts +355 -0
- package/src/sharddev/bake/glbCompression.ts +143 -0
- package/src/sharddev/bake/gltfSource.ts +59 -0
- package/src/sharddev/bake/groundMap.ts +142 -0
- package/src/sharddev/bake/image.ts +20 -0
- package/src/sharddev/bake/isleMap.ts +64 -0
- package/src/sharddev/bake/json.mjs +84 -0
- package/src/sharddev/bake/keyedSky.ts +47 -0
- package/src/sharddev/bake/keyedSkyMemo.ts +39 -0
- package/src/sharddev/bake/kinds.ts +137 -0
- package/src/sharddev/bake/lightSources.ts +31 -0
- package/src/sharddev/bake/mapAssembly.ts +84 -0
- package/src/sharddev/bake/mapRaster.ts +173 -0
- package/src/sharddev/bake/mapRest.ts +57 -0
- package/src/sharddev/bake/mapScenes.ts +234 -0
- package/src/sharddev/bake/materialGraph.ts +32 -0
- package/src/sharddev/bake/meadow.ts +27 -0
- package/src/sharddev/bake/meshoptChoiceMemo.ts +34 -0
- package/src/sharddev/bake/nativeInteractionFacts.ts +5 -0
- package/src/sharddev/bake/nativeLattice.ts +178 -0
- package/src/sharddev/bake/nativeRaster.ts +106 -0
- package/src/sharddev/bake/nativeTerrainField.ts +11 -0
- package/src/sharddev/bake/navigation-json.mjs +38 -0
- package/src/sharddev/bake/navigation.ts +113 -0
- package/src/sharddev/bake/navigationAsset.ts +18 -0
- package/src/sharddev/bake/nearPlaceholder.ts +206 -0
- package/src/sharddev/bake/normalizeRig.ts +80 -0
- package/src/sharddev/bake/phoneAstc.ts +93 -0
- package/src/sharddev/bake/placeholders.ts +581 -0
- package/src/sharddev/bake/placement.ts +80 -0
- package/src/sharddev/bake/portableBytes.ts +18 -0
- package/src/sharddev/bake/portableBytesMemo.ts +50 -0
- package/src/sharddev/bake/practiceCourse.ts +49 -0
- package/src/sharddev/bake/primitives.ts +96 -0
- package/src/sharddev/bake/props.ts +443 -0
- package/src/sharddev/bake/questPlacement.ts +98 -0
- package/src/sharddev/bake/rawTexture.ts +26 -0
- package/src/sharddev/bake/riderArms.ts +97 -0
- package/src/sharddev/bake/rig.ts +95 -0
- package/src/sharddev/bake/riggedHullRecipes.ts +40 -0
- package/src/sharddev/bake/signPlacements.ts +25 -0
- package/src/sharddev/bake/simplifier.ts +52 -0
- package/src/sharddev/bake/skinned.ts +312 -0
- package/src/sharddev/bake/slabChunks.ts +149 -0
- package/src/sharddev/bake/slabs.ts +263 -0
- package/src/sharddev/bake/source-loader.mjs +55 -0
- package/src/sharddev/bake/sourceMetadata.ts +54 -0
- package/src/sharddev/bake/species.ts +368 -0
- package/src/sharddev/bake/specimenCatalogue.ts +47 -0
- package/src/sharddev/bake/splatGround.ts +141 -0
- package/src/sharddev/bake/staticMaterials.ts +171 -0
- package/src/sharddev/bake/terrain.ts +195 -0
- package/src/sharddev/bake/texture.ts +33 -0
- package/src/sharddev/bake/textureWasm.ts +81 -0
- package/src/sharddev/bake/tileEncoder.ts +11 -0
- package/src/sharddev/bake/tileGrid.ts +62 -0
- package/src/sharddev/bake/v2Finite.ts +160 -0
- package/src/sharddev/bake/v2Fuel.ts +71 -0
- package/src/sharddev/bake/wholePartition.ts +74 -0
- package/src/sharddev/bake/wholePieceJoin.ts +147 -0
- package/src/sharddev/bake/world.ts +173 -0
- package/src/sharddev/bake/worldCollision.ts +128 -0
- package/src/sharddev/bake/worldGeometry.ts +237 -0
- package/src/sharddev/bake/worldGlb.ts +123 -0
- package/src/sharddev/bake/worldImage.ts +12 -0
- package/src/sharddev/bake/worldLod.ts +128 -0
- package/src/sharddev/bake/worldRows.ts +102 -0
- package/src/sharddev/bake/worldTextureMemo.ts +63 -0
- package/src/sharddev/bake/zstdBytesMemo.ts +52 -0
- package/src/sharddev/bake.ts +193 -0
- package/src/sharddev/bakePublication.ts +31 -0
- package/src/sharddev/behaviourSource.ts +94 -0
- package/src/sharddev/bin/wildshard.mjs +7 -0
- package/src/sharddev/blobBytes.ts +65 -0
- package/src/sharddev/blobs.ts +138 -0
- package/src/sharddev/bootInventory.ts +129 -0
- package/src/sharddev/bossProfiles.ts +18 -0
- package/src/sharddev/buildBehaviour.ts +77 -0
- package/src/sharddev/buildCacheMetrics.ts +17 -0
- package/src/sharddev/buildDecisionScripts.ts +122 -0
- package/src/sharddev/check.ts +118 -0
- package/src/sharddev/checkProject.ts +127 -0
- package/src/sharddev/cli.ts +200 -0
- package/src/sharddev/clientChannels.ts +169 -0
- package/src/sharddev/clientScripts.ts +10 -0
- package/src/sharddev/commons.ts +77 -0
- package/src/sharddev/commonsCosts.ts +11 -0
- package/src/sharddev/compileMovers.ts +11 -0
- package/src/sharddev/configBoundary.ts +6 -0
- package/src/sharddev/cookInput.ts +40 -0
- package/src/sharddev/crowds.ts +6 -0
- package/src/sharddev/decisionBindingMap.ts +11 -0
- package/src/sharddev/decisionScriptBindings.ts +117 -0
- package/src/sharddev/decisionScripts.ts +28 -0
- package/src/sharddev/decisionSource.ts +51 -0
- package/src/sharddev/dev.ts +113 -0
- package/src/sharddev/director.ts +26 -0
- package/src/sharddev/directorAbi.ts +77 -0
- package/src/sharddev/discoveryDocument.ts +97 -0
- package/src/sharddev/draft.ts +11 -0
- package/src/sharddev/eliteEntryRows.ts +29 -0
- package/src/sharddev/entries.ts +76 -0
- package/src/sharddev/entryReads.ts +73 -0
- package/src/sharddev/executeBundle.ts +55 -0
- package/src/sharddev/finds.ts +5 -0
- package/src/sharddev/formatJsonSchema.ts +3 -0
- package/src/sharddev/generationCache.ts +257 -0
- package/src/sharddev/generationRecipe.ts +94 -0
- package/src/sharddev/handwritten.ts +110 -0
- package/src/sharddev/immutable.ts +14 -0
- package/src/sharddev/interactions.ts +38 -0
- package/src/sharddev/kit/bakedGeometry.ts +16 -0
- package/src/sharddev/kit/geometryPack.ts +110 -0
- package/src/sharddev/ledger.ts +13 -0
- package/src/sharddev/looks/tileField.ts +67 -0
- package/src/sharddev/materialGraphFiles.ts +57 -0
- package/src/sharddev/materials.ts +574 -0
- package/src/sharddev/measure.ts +18 -0
- package/src/sharddev/modes.ts +115 -0
- package/src/sharddev/moverPrograms.ts +213 -0
- package/src/sharddev/movers.ts +75 -0
- package/src/sharddev/nativePopulationRows.ts +46 -0
- package/src/sharddev/newProject.ts +226 -0
- package/src/sharddev/noise.ts +54 -0
- package/src/sharddev/outputProduct.ts +188 -0
- package/src/sharddev/outputRuntime.ts +66 -0
- package/src/sharddev/performancePolicy.ts +29 -0
- package/src/sharddev/phasedBoss.ts +34 -0
- package/src/sharddev/physics.ts +194 -0
- package/src/sharddev/platformSections.ts +42 -0
- package/src/sharddev/plumbing.ts +8 -0
- package/src/sharddev/productOutput.ts +128 -0
- package/src/sharddev/project.ts +337 -0
- package/src/sharddev/projectCompilerIdentity.ts +94 -0
- package/src/sharddev/projectDecisions.ts +66 -0
- package/src/sharddev/projectEntryProof.ts +32 -0
- package/src/sharddev/projectGeneration.ts +219 -0
- package/src/sharddev/projectInputFiles.ts +47 -0
- package/src/sharddev/projectManifest.ts +108 -0
- package/src/sharddev/projectMap.ts +35 -0
- package/src/sharddev/projectOutput.ts +242 -0
- package/src/sharddev/projectPolicy.ts +17 -0
- package/src/sharddev/projectSections.ts +27 -0
- package/src/sharddev/questGraph.ts +25 -0
- package/src/sharddev/quests.ts +65 -0
- package/src/sharddev/random.ts +61 -0
- package/src/sharddev/refusals.ts +304 -0
- package/src/sharddev/reportCard.ts +13 -0
- package/src/sharddev/returnProjectionV2.ts +81 -0
- package/src/sharddev/rows.ts +192 -0
- package/src/sharddev/runtimeImports.ts +38 -0
- package/src/sharddev/runtimeMirrors.ts +39 -0
- package/src/sharddev/runtimePerformance.ts +38 -0
- package/src/sharddev/scene.ts +321 -0
- package/src/sharddev/sceneAnimation.ts +54 -0
- package/src/sharddev/sceneAudio.ts +64 -0
- package/src/sharddev/sceneDeclarations.ts +100 -0
- package/src/sharddev/sceneGraph.ts +139 -0
- package/src/sharddev/sceneTransform.ts +12 -0
- package/src/sharddev/schemaValidation.ts +61 -0
- package/src/sharddev/sections.ts +47 -0
- package/src/sharddev/shardSource.ts +59 -0
- package/src/sharddev/sourceReader.ts +26 -0
- package/src/sharddev/spawns.ts +38 -0
- package/src/sharddev/species/clips.ts +24 -0
- package/src/sharddev/species.ts +29 -0
- package/src/sharddev/speciesBrains.ts +19 -0
- package/src/sharddev/synth.ts +66 -0
- package/src/sharddev/test/compileDualScriptV2.ts +71 -0
- package/src/sharddev/test/compileSimV2.ts +21 -0
- package/src/sharddev/test/diskScriptScenario.ts +86 -0
- package/src/sharddev/test/scriptScenario.ts +249 -0
- package/src/sharddev/test/scriptSource.ts +12 -0
- package/src/sharddev/version.ts +4 -0
- package/src/sharddev/weapons/bowProfile.ts +20 -0
- package/src/sharddev/weapons/firearmRows.ts +11 -0
- package/src/sharddev/weapons/meleeProfile.ts +71 -0
- package/src/sharddev/weapons/thrownProfile.ts +10 -0
- package/src/sharddev/worldScenes.ts +308 -0
- package/src/sharddev/worldSource.ts +82 -0
- package/src/shards/_template/README.md +78 -0
- package/src/shards/_template/assets/2bf489fdb15f1734ddb4c4f32d500ec6da85c765ec7a4eb28dc6781160e7ec8c +0 -0
- package/src/shards/_template/assets/97ec4d8f75f5fa6239ee919444d6dc19fd35896bb305930c1f050ac6e0e0e6a6 +1 -0
- package/src/shards/_template/assets/a6a587a31327f936b1b04c05ade818c73fc8964260918662db43539465e27586 +0 -0
- package/src/shards/_template/assets/b4fbde0422e125b498c3dc8b9a5cc2516c8598f09e9d0e5f6b639b32f98179e6 +0 -0
- package/src/shards/_template/assets/bfa4dfc9c18979f904557ee8deab0058b8a399be10266f5fb1578b403f482fd4 +1 -0
- package/src/shards/_template/assets/ef3b7ff4fd22715771cb7d68a3977a903c5e7c3dc293542687d04b3ef3ace2cb +0 -0
- package/src/shards/_template/assets/f2db05998615ce1cb79ea96be32c168842eb6a2b34ec01feb86d36404603ee54 +0 -0
- package/src/shards/_template/assets/fef98ebb7fce6f66b26e78ac699e5c90f9bdcfaf8cabeb2b58125347eea8b4ab +0 -0
- package/src/shards/_template/behaviour/boss.as +39 -0
- package/src/shards/_template/behaviour/door.as +32 -0
- package/src/shards/_template/behaviour/hooks.json +129 -0
- package/src/shards/_template/behaviour/idle.as +75 -0
- package/src/shards/_template/behaviour/items.as +22 -0
- package/src/shards/_template/card/landscape.jpg +0 -0
- package/src/shards/_template/card/portrait.jpg +0 -0
- package/src/shards/_template/card/thumb.jpg +0 -0
- package/src/shards/_template/data/audio.json +45 -0
- package/src/shards/_template/data/bossDecision.json +83 -0
- package/src/shards/_template/data/budgets.json +70 -0
- package/src/shards/_template/data/card.json +281 -0
- package/src/shards/_template/data/clientScripts.json +987 -0
- package/src/shards/_template/data/creatures.json +65 -0
- package/src/shards/_template/data/director.json +39 -0
- package/src/shards/_template/data/encounters.json +96 -0
- package/src/shards/_template/data/items.json +172 -0
- package/src/shards/_template/data/layout.json +66 -0
- package/src/shards/_template/data/ledger.json +32 -0
- package/src/shards/_template/data/look.json +521 -0
- package/src/shards/_template/data/map.json +64 -0
- package/src/shards/_template/data/moves.json +16 -0
- package/src/shards/_template/data/placeholder.json +8 -0
- package/src/shards/_template/data/plumbing.json +32 -0
- package/src/shards/_template/data/quests.json +223 -0
- package/src/shards/_template/data/rows.json +423 -0
- package/src/shards/_template/data/skins.json +66 -0
- package/src/shards/_template/data/spawn.json +6 -0
- package/src/shards/_template/data/targets.json +150 -0
- package/src/shards/_template/data/text.json +12 -0
- package/src/shards/_template/data/ui.json +33 -0
- package/src/shards/_template/data/water.json +13 -0
- package/src/shards/_template/generators/behaviour.ts +34 -0
- package/src/shards/_template/generators/boss.ts +29 -0
- package/src/shards/_template/generators/buildOptions.ts +2 -0
- package/src/shards/_template/generators/cell.ts +224 -0
- package/src/shards/_template/generators/districts.ts +215 -0
- package/src/shards/_template/generators/farLook.ts +15 -0
- package/src/shards/_template/generators/generate.ts +27 -0
- package/src/shards/_template/generators/ground.ts +15 -0
- package/src/shards/_template/generators/kit.ts +69 -0
- package/src/shards/_template/generators/landscape.ts +59 -0
- package/src/shards/_template/generators/landscapeNoise.ts +62 -0
- package/src/shards/_template/generators/mapInputs.ts +10 -0
- package/src/shards/_template/generators/product.ts +100 -0
- package/src/shards/_template/generators/productOutput.ts +18 -0
- package/src/shards/_template/generators/props.ts +9 -0
- package/src/shards/_template/generators/templatePropsSource.ts +58 -0
- package/src/shards/_template/generators/terrain.ts +17 -0
- package/src/shards/_template/generators/world.ts +630 -0
- package/src/shards/_template/hero.json +10 -0
- package/src/shards/_template/look/entry-reads.json +20 -0
- package/src/shards/_template/manifest.json +281 -0
- package/src/shards/_template/shard.config.ts +10 -0
- package/src/shared/health.ts +10 -0
- package/src/tools/build-web.ts +59 -0
- package/src/tsconfig.json +30 -0
- package/src/web/app.tsx +53 -0
- package/src/web/index.html +12 -0
- package/src/web/main.tsx +10 -0
- package/src/web/tsconfig.json +13 -0
- package/tsconfig.author.json +23 -0
- package/tsconfig.commons.json +21 -0
- package/tsconfig.json +47 -0
- package/tsconfig.sharddev.json +20 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- Build admission compares every byte with the native comparator.
|
|
2
|
+
import { Buffer } from 'node:buffer';
|
|
3
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- Proxy inputs retain their original getter/callback path.
|
|
4
|
+
import { isProxy } from 'node:util/types';
|
|
5
|
+
import { parseRiggedHullBook } from '@wildshard/format/riggedHulls';
|
|
6
|
+
import { AdmissionLateSchema, lateLibraryRootsValid, type AdmissionLate, type LateFile } from '@wildshard/format/admissionLate';
|
|
7
|
+
import * as v from 'valibot';
|
|
8
|
+
import { ScriptContractSchema, decisionModuleContracts, type ScriptContractInput, type ScriptContract } from '@wildshard/format/scriptContract';
|
|
9
|
+
import { OutputIndexSchema, type OutputFile } from '@wildshard/format/outputIndex';
|
|
10
|
+
import { ShardNaturalSchema } from '@wildshard/format/shardSections';
|
|
11
|
+
import { parseShardfile, type Shardfile } from '@wildshard/engine/host/shardfile';
|
|
12
|
+
import { readNamedBlob, emitNamedBlobs, nameBlob, type NamedBlob, type ServerBlob } from './blobs';
|
|
13
|
+
import { encodeCanonicalJson } from './immutable';
|
|
14
|
+
import { copyAssetBytes, hashAssetBytes } from './assetHandle';
|
|
15
|
+
import { defineMirror, type RuntimeMirror } from './runtimeMirrors';
|
|
16
|
+
import type { EmittedSections } from './sections';
|
|
17
|
+
import { outputDecisionScripts, outputScriptAdmissionRows, type OutputProductOptions } from './outputProduct';
|
|
18
|
+
import { prepareProjectDecisions, replacedDecisionBlob, decisionBlobNames } from './projectDecisions';
|
|
19
|
+
import type { DecisionBuildOptions } from './buildDecisionScripts';
|
|
20
|
+
|
|
21
|
+
const bytes = v.custom<Uint8Array>(value => value instanceof Uint8Array);
|
|
22
|
+
const assetMap = v.map(v.string(), bytes);
|
|
23
|
+
const emitted = v.strictObject({ sections: OutputIndexSchema.entries.sections, files: assetMap });
|
|
24
|
+
const options = v.strictObject({
|
|
25
|
+
decoded: v.exactOptional(ShardNaturalSchema), gpu: v.exactOptional(ShardNaturalSchema),
|
|
26
|
+
triangles: v.exactOptional(ShardNaturalSchema), draws: v.exactOptional(ShardNaturalSchema),
|
|
27
|
+
script: v.exactOptional(ScriptContractSchema),
|
|
28
|
+
jsonSchema: v.exactOptional(v.record(v.string(), v.unknown())),
|
|
29
|
+
meshopt: v.exactOptional(v.boolean()), critical: v.exactOptional(v.boolean()), dependencies: v.exactOptional(v.array(v.string())),
|
|
30
|
+
});
|
|
31
|
+
const declaration: v.StrictObjectSchema<{ readonly name: v.StringSchema<undefined>; readonly kind: v.PicklistSchema<["glb", "ktx2", "image", "audio", "wasm", "bin", "tile", "json"], undefined>; readonly source: v.StringSchema<undefined>; readonly options: v.ExactOptionalSchema<v.StrictObjectSchema<{ readonly decoded: v.ExactOptionalSchema<v.GenericSchema<number, number>, undefined>; readonly gpu: v.ExactOptionalSchema<v.GenericSchema<number, number>, undefined>; readonly triangles: v.ExactOptionalSchema<v.GenericSchema<number, number>, undefined>; readonly draws: v.ExactOptionalSchema<v.GenericSchema<number, number>, undefined>; readonly script: v.ExactOptionalSchema<v.GenericSchema<ScriptContractInput, ScriptContract>, undefined>; readonly jsonSchema: v.ExactOptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>; readonly meshopt: v.ExactOptionalSchema<v.BooleanSchema<undefined>, undefined>; readonly critical: v.ExactOptionalSchema<v.BooleanSchema<undefined>, undefined>; readonly dependencies: v.ExactOptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>; }, undefined>, undefined>; }, undefined> = v.strictObject({
|
|
32
|
+
name: v.string(), kind: v.picklist(['glb', 'ktx2', 'image', 'audio', 'wasm', 'bin', 'tile', 'json']),
|
|
33
|
+
source: v.string(), options: v.exactOptional(options),
|
|
34
|
+
});
|
|
35
|
+
const output = v.strictObject({
|
|
36
|
+
blobs: v.optional(v.pipe(v.array(declaration), v.maxLength(8192)), []),
|
|
37
|
+
platform: v.exactOptional(emitted),
|
|
38
|
+
late: v.exactOptional(AdmissionLateSchema),
|
|
39
|
+
server: v.exactOptional(v.pipe(v.array(v.custom<ServerBlob>(row => typeof row === 'object' && row !== null && 'file' in row && 'bytes' in row && row.bytes instanceof Uint8Array)), v.maxLength(256))),
|
|
40
|
+
namedFiles: v.optional(OutputIndexSchema.entries.files, []), assets: v.optional(assetMap, () => new Map()),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
/** Build-only config export: source paths are resolved by the CLI, never by author module side effects. */
|
|
44
|
+
export interface ProjectOutput extends Omit<OutputProductOptions, 'runtime' | 'discovery'> {
|
|
45
|
+
/** Existing or newly emitted library hashes; merged only after blob admission establishes every root. */
|
|
46
|
+
readonly late?: readonly LateFile[];
|
|
47
|
+
readonly blobs?: readonly v.InferOutput<typeof declaration>[];
|
|
48
|
+
readonly assets?: ReadonlyMap<string, Uint8Array>;
|
|
49
|
+
}
|
|
50
|
+
/** Prepared extensions and new named bytes, still subject to complete product/disk admission. */
|
|
51
|
+
export interface PreparedProjectOutput {
|
|
52
|
+
readonly late?: AdmissionLate;
|
|
53
|
+
readonly blobs: readonly NamedBlob[];
|
|
54
|
+
readonly options: Omit<OutputProductOptions, 'runtime'>;
|
|
55
|
+
readonly assets: ReadonlyMap<string, Uint8Array>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function ownedAssets(input: ReadonlyMap<string, Uint8Array>): Map<string, Uint8Array> {
|
|
59
|
+
const assets = new Map<string, Uint8Array>();
|
|
60
|
+
for (const [hash, value] of input) {
|
|
61
|
+
if (hashAssetBytes(value) !== hash) throw new Error('Authored output asset hash differs from its bytes');
|
|
62
|
+
assets.set(hash, copyAssetBytes(value));
|
|
63
|
+
}
|
|
64
|
+
return assets;
|
|
65
|
+
}
|
|
66
|
+
function ownedSections(input: EmittedSections): EmittedSections {
|
|
67
|
+
return { sections: input.sections.map(row => ({ ...row })), files: new Map([...input.files].map(([path, value]) => [path, copyAssetBytes(value)])) };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Product hull bodies, maps and coat fallbacks have asynchronous readers, not synchronous admitted-map inputs.
|
|
71
|
+
* Keep their complete files/costs; early demand and critical/dependency roots still win. */
|
|
72
|
+
function riggedHullLate(platform: EmittedSections | undefined, files: readonly OutputFile[], critical: ReadonlySet<string>): LateFile[] {
|
|
73
|
+
const section = platform?.sections.find(row => row.name === 'look/rigged-hulls');
|
|
74
|
+
if (section === undefined) return [];
|
|
75
|
+
const wire = platform?.files.get(section.path);
|
|
76
|
+
if (wire === undefined || wire.length !== section.bytes || hashAssetBytes(wire) !== section.hash)
|
|
77
|
+
throw new Error('Rigged hull coat section differs from its declared bytes');
|
|
78
|
+
const book = parseRiggedHullBook(JSON.parse(new TextDecoder().decode(wire)));
|
|
79
|
+
if (!book.productFiles) return [];
|
|
80
|
+
const names = new Set(Object.values(book.tiers).flatMap(tier =>
|
|
81
|
+
Object.values(tier.files).flatMap(file => typeof file === 'string' ? [file] : [file.rig, file.base, file.normal])
|
|
82
|
+
.concat(Object.values(tier.coats).map(coat => coat.image), tier.parts === undefined ? [] : [tier.parts.file])));
|
|
83
|
+
return [...new Set(files.filter(file => (file.kind === 'image' || file.kind === 'glb' || file.kind === 'ktx2') && !file.critical && !critical.has(file.hash) && file.name !== undefined && names.has(file.name)).map(file => file.hash))]
|
|
84
|
+
.map(hash => ({ hash }));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Parse the optional output export and compile project-contained inputs (including glTF) into immutable blobs. */
|
|
88
|
+
export async function prepareProjectOutput(project: string, input: unknown, decisions?: { source: Shardfile; options: DecisionBuildOptions }): Promise<PreparedProjectOutput> {
|
|
89
|
+
let parsed = v.parse(output, input === undefined ? {} : input);
|
|
90
|
+
const blobs: NamedBlob[] = [], overlays: OutputFile[] = [];
|
|
91
|
+
if (decisions !== undefined) {
|
|
92
|
+
const built = await prepareProjectDecisions(project, decisions.source, parsed.platform, decisions.options);
|
|
93
|
+
blobs.push(...decisionBlobNames(built.blobs, parsed.namedFiles, parsed.blobs, outputDecisionScripts(parsed.platform)));
|
|
94
|
+
const assets = new Map(parsed.assets); for (const hash of built.replaced) assets.delete(hash);
|
|
95
|
+
parsed = { ...parsed, ...(built.platform === undefined ? {} : { platform: v.parse(emitted, built.platform) }), assets,
|
|
96
|
+
namedFiles: parsed.namedFiles.filter(file => !built.replaced.has(file.hash)),
|
|
97
|
+
blobs: parsed.blobs.filter(row => !replacedDecisionBlob(row, built.replaced)) };
|
|
98
|
+
}
|
|
99
|
+
for (const row of parsed.blobs) blobs.push(await readNamedBlob(project, row.name, row.source, row.kind, row.options));
|
|
100
|
+
const inventory = [...parsed.namedFiles, ...blobs.map(row => row.file)];
|
|
101
|
+
// Other rows may name files already declared by the root source; full product admission resolves those.
|
|
102
|
+
const scripts = outputScriptAdmissionRows(parsed.platform).filter(row => inventory.some(file => file.path === row.module));
|
|
103
|
+
const contracts = decisionModuleContracts(scripts, inventory);
|
|
104
|
+
for (const file of parsed.namedFiles) {
|
|
105
|
+
const value = parsed.assets.get(file.hash);
|
|
106
|
+
if (value === undefined) overlays.push(file);
|
|
107
|
+
else {
|
|
108
|
+
const script = file.kind === 'wasm' ? contracts.get(file.hash) ?? { abi: 0 as const } : undefined;
|
|
109
|
+
const checked = emitNamedBlobs([{ file, bytes: value, ...(script === undefined ? {} : { script }) }]), owned = checked.assets.get(file.hash);
|
|
110
|
+
if (owned === undefined) throw new Error('Named output asset was not admitted');
|
|
111
|
+
blobs.push({ file, bytes: owned, ...(script === undefined ? {} : { script }) });
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const explicit = new Set(parsed.late?.map(row => row.hash));
|
|
115
|
+
const critical = new Set([...inventory.filter(file => file.critical).map(file => file.hash), ...(decisions?.source.critical ?? []), ...(decisions?.source.files.filter(file => file.critical).map(file => file.hash) ?? [])]);
|
|
116
|
+
const late = [...parsed.late ?? [], ...riggedHullLate(parsed.platform, inventory, critical).filter(row => !explicit.has(row.hash))];
|
|
117
|
+
return { blobs, assets: ownedAssets(parsed.assets), ...(parsed.late === undefined && late.length === 0 ? {} : { late }), options: {
|
|
118
|
+
namedFiles: overlays,
|
|
119
|
+
...(parsed.platform === undefined ? {} : { platform: ownedSections(parsed.platform) }),
|
|
120
|
+
...(parsed.server === undefined ? {} : { server: parsed.server }),
|
|
121
|
+
} };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Expose build-time mirrors without loading or executing the copied runtime module. */
|
|
125
|
+
export function projectMirrors(input: unknown): readonly RuntimeMirror[] {
|
|
126
|
+
const rows = v.parse(v.pipe(v.array(v.strictObject({ name: v.string(), value: v.unknown() })), v.maxLength(8192)), input === undefined ? [] : input);
|
|
127
|
+
const names = new Set<string>();
|
|
128
|
+
return rows.map(row => {
|
|
129
|
+
if (names.has(row.name)) throw new Error('Duplicate runtime mirror');
|
|
130
|
+
names.add(row.name); return defineMirror(row.name, row.value);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function libraryCost(source: Shardfile): { compressed: number; resident: number } {
|
|
135
|
+
const files = new Map(source.files.map(file => [file.hash, file])), seen = new Set<string>(), pending = [...source.library];
|
|
136
|
+
let compressed = 0, resident = 0;
|
|
137
|
+
while (pending.length > 0) {
|
|
138
|
+
const hash = pending.pop(); if (hash === undefined || seen.has(hash)) continue;
|
|
139
|
+
seen.add(hash);
|
|
140
|
+
if (hash.startsWith('commons:')) {
|
|
141
|
+
const key = hash.slice(8), cost = source.requires.commonsCosts[key];
|
|
142
|
+
if (cost === undefined) throw new Error('Missing named library commons cost');
|
|
143
|
+
compressed += source.requires.commonsWire[key] ?? 0; resident += cost.decoded + cost.gpu;
|
|
144
|
+
} else {
|
|
145
|
+
const file = files.get(hash); if (file === undefined) throw new Error('Missing named library dependency');
|
|
146
|
+
compressed += file.compressed; resident += file.decoded + file.gpu; pending.push(...file.dependencies);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return { compressed, resident };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const comparisonPrototype: object | null = Object.getPrototypeOf(Uint8Array.prototype);
|
|
153
|
+
const comparisonSome: unknown = Reflect.get(Uint8Array.prototype, 'some');
|
|
154
|
+
function comparisonAccessor(name: 'length' | 'buffer'): unknown {
|
|
155
|
+
const descriptor = comparisonPrototype === null ? undefined : Object.getOwnPropertyDescriptor(comparisonPrototype, name);
|
|
156
|
+
return descriptor === undefined ? undefined : Reflect.get(descriptor, 'get');
|
|
157
|
+
}
|
|
158
|
+
const comparisonLength = comparisonAccessor('length'), comparisonBuffer = comparisonAccessor('buffer');
|
|
159
|
+
const comparisonNative = typeof comparisonSome === 'function' && !isProxy(comparisonSome) && Function.prototype.toString.call(comparisonSome).includes('[native code]');
|
|
160
|
+
|
|
161
|
+
/** Only ordinary nonempty unshared views can avoid the original per-byte callback.
|
|
162
|
+
* No authored accessor or proxy trap is invoked to select this path. */
|
|
163
|
+
function comparisonBytes(value: unknown): value is Uint8Array {
|
|
164
|
+
if (!comparisonNative || !ArrayBuffer.isView(value) || isProxy(value) || Object.getPrototypeOf(value) !== Uint8Array.prototype
|
|
165
|
+
|| Object.hasOwn(value, 'length') || Object.hasOwn(value, 'some') || comparisonPrototype === null
|
|
166
|
+
|| Object.getPrototypeOf(Uint8Array.prototype) !== comparisonPrototype
|
|
167
|
+
|| Object.hasOwn(Uint8Array.prototype, 'length') || Object.hasOwn(Uint8Array.prototype, 'some')
|
|
168
|
+
|| Object.getOwnPropertyDescriptor(comparisonPrototype, 'length')?.get !== comparisonLength
|
|
169
|
+
|| Object.getOwnPropertyDescriptor(comparisonPrototype, 'some')?.value !== comparisonSome
|
|
170
|
+
|| typeof comparisonLength !== 'function' || typeof comparisonBuffer !== 'function') return false;
|
|
171
|
+
try {
|
|
172
|
+
const length: unknown = Reflect.apply(comparisonLength, value, []);
|
|
173
|
+
return typeof length === 'number' && length > 0 && Reflect.apply(comparisonBuffer, value, []) instanceof ArrayBuffer;
|
|
174
|
+
} catch { return false; }
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function conflictingBytes(previous: Uint8Array, blob: NamedBlob): boolean {
|
|
178
|
+
if (!isProxy(blob)) {
|
|
179
|
+
const candidate: unknown = Object.getOwnPropertyDescriptor(blob, 'bytes')?.value;
|
|
180
|
+
if (comparisonBytes(previous) && comparisonBytes(candidate) && previous.length === candidate.length)
|
|
181
|
+
return Buffer.compare(previous, candidate) !== 0;
|
|
182
|
+
}
|
|
183
|
+
return previous.some((value, index) => value !== blob.bytes[index]);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** Admit named bytes once. Existing declarations, conservative costs and names win when content is reused;
|
|
187
|
+
* new content becomes a library root and charges only the newly reachable closure. Inputs are never mutated. */
|
|
188
|
+
export function mergeProjectBlobs(input: Shardfile, inputAssets: ReadonlyMap<string, Uint8Array>, blobs: readonly NamedBlob[], namedFiles: readonly OutputFile[] = [], late: readonly LateFile[] = []): { shard: Shardfile; assets: Map<string, Uint8Array>; namedFiles: readonly OutputFile[] } {
|
|
189
|
+
const source = parseShardfile(input), before = libraryCost(source), assets = new Map(inputAssets);
|
|
190
|
+
const files = new Map(source.files.map(file => [file.hash, file]));
|
|
191
|
+
const named = new Map<string, OutputFile>(), names = new Map<string, string>();
|
|
192
|
+
for (const file of v.parse(OutputIndexSchema.entries.files, namedFiles)) {
|
|
193
|
+
if (file.name === undefined || named.has(file.hash) || names.has(file.name)) throw new Error('Duplicate or absent named output identity');
|
|
194
|
+
named.set(file.hash, file); names.set(file.name, file.hash);
|
|
195
|
+
}
|
|
196
|
+
for (const blob of blobs) {
|
|
197
|
+
emitNamedBlobs([blob]);
|
|
198
|
+
const file = blob.file, name = file.name;
|
|
199
|
+
if (name === undefined) throw new Error('Named source blob needs a name');
|
|
200
|
+
const claimed = names.get(name);
|
|
201
|
+
if (claimed !== undefined && claimed !== file.hash) throw new Error('Blob logical name has conflicting content');
|
|
202
|
+
const existing = files.get(file.hash), common = source.requires.commons.includes(file.hash);
|
|
203
|
+
const previous = assets.get(file.hash) ?? (common ? assets.get(`commons:${file.hash}`) : undefined);
|
|
204
|
+
if (previous !== undefined && (hashAssetBytes(previous) !== file.hash || previous.length !== blob.bytes.length || conflictingBytes(previous, blob))) throw new Error('Blob conflicts with admitted asset bytes');
|
|
205
|
+
let overlay: OutputFile;
|
|
206
|
+
if (existing !== undefined) {
|
|
207
|
+
if (existing.kind !== (file.kind === 'bin' || file.kind === 'tile' ? 'binary' : file.kind) || existing.compressed !== blob.bytes.length) throw new Error('Blob kind or size differs from admitted declaration');
|
|
208
|
+
overlay = nameBlob(name, file.kind, blob.bytes, { ...existing, ...(file.jsonSchema === undefined ? {} : { jsonSchema: file.jsonSchema }), ...(file.tier === undefined ? {} : { tier: file.tier }), ...(file.variantOf === undefined ? {} : { variantOf: file.variantOf }), ...(blob.script === undefined ? {} : { script: blob.script }) }).file;
|
|
209
|
+
} else if (common) {
|
|
210
|
+
const cost = source.requires.commonsCosts[file.hash];
|
|
211
|
+
if (cost === undefined || source.requires.commonsWire[file.hash] !== blob.bytes.length) throw new Error('Blob differs from admitted commons');
|
|
212
|
+
overlay = { ...nameBlob(name, file.kind, blob.bytes, { ...cost, ...(file.jsonSchema === undefined ? {} : { jsonSchema: file.jsonSchema }), ...(blob.script === undefined ? {} : { script: blob.script }) }).file, commons: true };
|
|
213
|
+
} else {
|
|
214
|
+
// the tier is the named file's (the output index carries it); the declaration's file row has none
|
|
215
|
+
const { name: _name, path: _path, jsonSchema: _schema, tier: _tier, variantOf: _variant, kind, ...metadata } = file;
|
|
216
|
+
const added = { ...metadata, kind: kind === 'bin' || kind === 'tile' ? 'binary' as const : kind };
|
|
217
|
+
source.files.push(added); files.set(file.hash, added);
|
|
218
|
+
if (file.critical) {
|
|
219
|
+
source.critical.push(file.hash);
|
|
220
|
+
source.budgets.sim.compressed += file.compressed;
|
|
221
|
+
source.budgets.sim.resident += file.decoded + file.gpu;
|
|
222
|
+
} else source.library.push(file.hash);
|
|
223
|
+
overlay = file;
|
|
224
|
+
}
|
|
225
|
+
const old = named.get(file.hash);
|
|
226
|
+
if (old !== undefined) {
|
|
227
|
+
const { name: _oldName, ...oldMetadata } = old, { name: _newName, ...newMetadata } = overlay;
|
|
228
|
+
if (encodeCanonicalJson(oldMetadata) !== encodeCanonicalJson(newMetadata)) throw new Error('Named blob metadata conflicts with admission');
|
|
229
|
+
} else named.set(file.hash, overlay);
|
|
230
|
+
names.set(name, file.hash);
|
|
231
|
+
if (existing !== undefined || !common) assets.set(file.hash, copyAssetBytes(blob.bytes));
|
|
232
|
+
}
|
|
233
|
+
if (late.length > 0) {
|
|
234
|
+
const scheduled = v.parse(AdmissionLateSchema, [...source.late ?? [], ...late]);
|
|
235
|
+
if (!lateLibraryRootsValid(scheduled, files, new Set(source.library))) throw new Error('late files are declared library roots');
|
|
236
|
+
source.late = scheduled;
|
|
237
|
+
}
|
|
238
|
+
const after = libraryCost(source), budget = source.budgets.library;
|
|
239
|
+
budget.compressed += after.compressed - before.compressed; budget.resident += after.resident - before.resident;
|
|
240
|
+
if (budget.downloadAllowance !== undefined) budget.downloadAllowance += after.compressed - before.compressed;
|
|
241
|
+
return { shard: parseShardfile(source), assets, namedFiles: [...named.values()] };
|
|
242
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- Author-only project policy is an optional bounded build input.
|
|
2
|
+
import { existsSync, realpathSync } from 'node:fs';
|
|
3
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- The policy must remain inside the author project.
|
|
4
|
+
import { resolve, sep } from 'node:path';
|
|
5
|
+
import * as v from 'valibot';
|
|
6
|
+
import { readBoundedFile } from './sourceReader';
|
|
7
|
+
|
|
8
|
+
const policy = v.strictObject({ version: v.literal(1), decisionLegacyLines: v.pipe(v.number(), v.safeInteger(), v.minValue(1)) });
|
|
9
|
+
/** A portable generated policy input carries the first-party denominator to every project reader.
|
|
10
|
+
* The SDK never imports repository policy or guesses a first-party identity from a folder name. */
|
|
11
|
+
export function projectDecisionBudget(project: string, explicit?: number): number | undefined {
|
|
12
|
+
if (explicit !== undefined) return explicit;
|
|
13
|
+
const root = realpathSync(project), path = resolve(root, '.wildshard/build-policy.json');
|
|
14
|
+
if (!existsSync(path)) return undefined;
|
|
15
|
+
if (!realpathSync(path).startsWith(`${root}${sep}`)) throw new Error('Project build policy escapes the project');
|
|
16
|
+
return v.parse(policy, JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(readBoundedFile(path, 4096)))).decisionLegacyLines;
|
|
17
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { isJsonData } from '@wildshard/format/json';
|
|
2
|
+
import { parseOutputSection } from '@wildshard/format/outputIndex';
|
|
3
|
+
import { SHARDFILE_ADMISSION_LIMITS } from '@wildshard/format/admissionLimits';
|
|
4
|
+
import { parseShardfile, type Shardfile } from '@wildshard/engine/host/shardfile';
|
|
5
|
+
import { encodeCanonicalJson } from './immutable';
|
|
6
|
+
|
|
7
|
+
/** CLI-only root-mapped section declarations. Existing nonempty fields cannot be overridden. */
|
|
8
|
+
export function mergeProjectSections(source: Shardfile, input: unknown): Shardfile {
|
|
9
|
+
if (input === undefined) return source;
|
|
10
|
+
if (!isJsonData(input) || input === null || typeof input !== 'object' || Array.isArray(input)
|
|
11
|
+
|| Object.keys(input).length > 256 || new TextEncoder().encode(encodeCanonicalJson(input)).length > SHARDFILE_ADMISSION_LIMITS.sourceBytes) throw new Error('Invalid authored section inventory');
|
|
12
|
+
const result: Record<string, unknown> = { ...source, rows: { ...source.rows }, runtime: source.runtime === null ? null : { ...source.runtime } };
|
|
13
|
+
const set = (target: object, key: string, value: unknown): void => {
|
|
14
|
+
const previous: unknown = Reflect.get(target, key);
|
|
15
|
+
if (previous !== undefined && previous !== null && !(Array.isArray(previous) && previous.length === 0)
|
|
16
|
+
&& !(typeof previous === 'object' && !Array.isArray(previous) && Object.keys(previous).length === 0)) throw new Error(`Authored section conflicts with configured field: ${key}`);
|
|
17
|
+
if (!Reflect.set(target, key, value)) throw new Error('Authored section field is not writable');
|
|
18
|
+
};
|
|
19
|
+
for (const [name, payload] of Object.entries(input)) for (const [key, value] of Object.entries(parseOutputSection(name, payload))) {
|
|
20
|
+
if (key === 'rows' || key === 'runtime') {
|
|
21
|
+
const target = result[key];
|
|
22
|
+
if (typeof target !== 'object' || target === null || typeof value !== 'object' || value === null) throw new Error('Authored section requires its declared owner');
|
|
23
|
+
for (const [field, data] of Object.entries(value)) set(target, field, data);
|
|
24
|
+
} else set(result, key, value);
|
|
25
|
+
}
|
|
26
|
+
return parseShardfile(result);
|
|
27
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import type { InteractTable } from '@wildshard/engine/world/interact/types';
|
|
3
|
+
import { NpcRowSchema as npcSchema, parseNpcRow as parseNpc, parseNpcDialogueRow as parseDialogue, type NpcDialogueRow as Dialogue, type NpcRow as Npc } from '@wildshard/format/npcs';
|
|
4
|
+
import { compileQuestTable as compileTable } from '@wildshard/engine/game/plugin/quests';
|
|
5
|
+
import { QuestGraphSchema as graphSchema, parseQuestGraph as parseGraph, type QuestGraphRow as Graph } from '@wildshard/format/questGraph';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/** A quest-giver NPC row (SF27): who it is, where it stands, what it says and how its pivot figure moves. */
|
|
9
|
+
export const NpcRowSchema: v.GenericSchema<unknown, Npc> = v.pipe(npcSchema);
|
|
10
|
+
/** A validated quest-giver NPC row. */
|
|
11
|
+
export type NpcRow = Npc;
|
|
12
|
+
/** Compile an authored NPC row; an unknown field or an empty dialogue refuses. */
|
|
13
|
+
export function parseNpcRow(input: unknown): Npc { return parseNpc(input); }
|
|
14
|
+
/** A quest graph's runtime row (SF27): its interaction actor, its marks' step id and its actions (`summon` a boss). */
|
|
15
|
+
export const QuestGraphSchema: v.SchemaWithPipe<readonly [typeof graphSchema]> = v.pipe(graphSchema);
|
|
16
|
+
/** A validated quest graph runtime row. */
|
|
17
|
+
export type QuestGraphRow = Graph;
|
|
18
|
+
/** Compile an authored quest graph runtime row; an unknown field refuses. */
|
|
19
|
+
export function parseQuestGraph(input: unknown): Graph { return parseGraph(input); }
|
|
20
|
+
|
|
21
|
+
/** Compile dialogue for a skinned or pivot NPC while its existing view owns the figure. */
|
|
22
|
+
export function parseNpcDialogueRow(input: unknown): Dialogue { return parseDialogue(input); }
|
|
23
|
+
|
|
24
|
+
/** Compile supported table flag actions while the current renderer and modal owner keep their side effects. */
|
|
25
|
+
export function compileQuestTable(table: InteractTable, bindings: readonly { readonly id: string; readonly act: number }[]): ReturnType<typeof compileTable> { return compileTable(table, bindings); }
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import { parsePersistedQuestPage as parsePage, parseQuestStory, type PersistedQuestPage } from '@wildshard/format/questStory';
|
|
3
|
+
import { QuestDataSchema as schema, parseQuestData as parseData, type QuestData as Data } from '@wildshard/format/quests';
|
|
4
|
+
import { parseNativeQuestComposition } from '@wildshard/format/nativeQuestComposition';
|
|
5
|
+
import { NativeQuestPropsSchema } from '@wildshard/format/questInteractions';
|
|
6
|
+
import type { InteractDef } from '@wildshard/engine/world/interact/types';
|
|
7
|
+
import { parseCompletion } from '@wildshard/format/completion';
|
|
8
|
+
import type { QuestWorldRows } from '@wildshard/format/questWorld';
|
|
9
|
+
import { parseQuestHost } from '@wildshard/format/questHost';
|
|
10
|
+
import { parsePanelDefinition, type PanelTemplate, type PanelValue } from '@wildshard/format/panelTemplate';
|
|
11
|
+
import { parseChapterWake } from '@wildshard/format/chapterDirector';
|
|
12
|
+
import { parseDeclaredQuestPage } from '@wildshard/format/declaredQuestPage';
|
|
13
|
+
|
|
14
|
+
/** Admit native chapter cues and their complete encounter, effect and system ordering. */
|
|
15
|
+
export function chapterWakeRows(input: unknown): ReturnType<typeof parseChapterWake> { return parseChapterWake(input); }
|
|
16
|
+
|
|
17
|
+
/** Admit complete prompt/action/restore declarations before installing a quest page. */
|
|
18
|
+
export function declaredQuestPageRows(input: unknown): ReturnType<typeof parseDeclaredQuestPage> { return parseDeclaredQuestPage(input); }
|
|
19
|
+
|
|
20
|
+
/** Complete authored markup and expression grammar; no DOM or input owner is created. */
|
|
21
|
+
export type AuthorPanelTemplate = PanelTemplate;
|
|
22
|
+
/** Complete authored quest-world anchors and named sites, with native mutable row contracts. */
|
|
23
|
+
export type AuthorQuestWorld = QuestWorldRows;
|
|
24
|
+
/** A native read-only panel expression over caller-owned values. */
|
|
25
|
+
export type AuthorPanelValue = PanelValue;
|
|
26
|
+
/** Admit saved-state chapter presentation with its native bounded data grammar. */
|
|
27
|
+
export function questStoryRows(input: unknown): ReturnType<typeof parseQuestStory> { return parseQuestStory(input); }
|
|
28
|
+
/** Admit command priority, actor routes and graph references before a quest owner exists. */
|
|
29
|
+
export function questHostRows(input: unknown): ReturnType<typeof parseQuestHost> { return parseQuestHost(input); }
|
|
30
|
+
/** Admit static panel markup and all native expression/action checks without constructing UI. */
|
|
31
|
+
export function panelDefinitionRows(input: unknown): ReturnType<typeof parsePanelDefinition> { return parsePanelDefinition(input); }
|
|
32
|
+
|
|
33
|
+
/** Compile declared quest graphs and dialogue trees with bounded, serialisable script hook names. */
|
|
34
|
+
export const QuestDataSchema: v.SchemaWithPipe<readonly [typeof schema]> = v.pipe(schema);
|
|
35
|
+
/** Validated quest/dialogue declarations consumed by the platform runtime. */
|
|
36
|
+
export type QuestData = Data;
|
|
37
|
+
/** Compile TypeScript author data after checking declared flags and graph references. */
|
|
38
|
+
export function parseQuestData(input: unknown): Data { return parseData(input); }
|
|
39
|
+
|
|
40
|
+
/** Admit generated page policy for the shared saved-quest presenter. */
|
|
41
|
+
export function parsePersistedQuestPage(input: unknown): PersistedQuestPage { return parsePage(input); }
|
|
42
|
+
|
|
43
|
+
/** Admit native quest resource ownership and its defining cross-row checks without creating a page. */
|
|
44
|
+
export function nativeQuestCompositionRows(input: unknown): ReturnType<typeof parseNativeQuestComposition> { return parseNativeQuestComposition(input); }
|
|
45
|
+
|
|
46
|
+
/** Admit complete captured quest floors, drop identities and gate contacts before any physical owner exists. */
|
|
47
|
+
export function questPropRows(input: unknown): v.InferOutput<typeof NativeQuestPropsSchema> { return v.parse(NativeQuestPropsSchema, input); }
|
|
48
|
+
|
|
49
|
+
/** Admit complete completion card/stat/find policy with its original cross-row references and plain-data checks. */
|
|
50
|
+
export function completionCardRows(input: unknown): ReturnType<typeof parseCompletion> { return parseCompletion(input); }
|
|
51
|
+
|
|
52
|
+
/** Compile the shared table's automatic saved/transient flag; barrels own no automatic flag.
|
|
53
|
+
* This policy allocates data only, without raising a flag or installing an interaction. */
|
|
54
|
+
export function questAutomaticFlag(row: Pick<InteractDef, 'kind' | 'id'>): string | null {
|
|
55
|
+
switch (row.kind) {
|
|
56
|
+
case 'chest': case 'door': return `open:${row.id}`;
|
|
57
|
+
case 'key': case 'pickup': return `taken:${row.id}`;
|
|
58
|
+
case 'lever': return `lever:${row.id}`;
|
|
59
|
+
case 'plate': return `plate:${row.id}`;
|
|
60
|
+
case 'beacon': return `lit:${row.id}`;
|
|
61
|
+
case 'bench': case 'altar': return `used:${row.id}`;
|
|
62
|
+
case 'barrel': return null;
|
|
63
|
+
default: return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/** Build-only Mulberry32; permanent equality tests fence the engine counterpart. */
|
|
2
|
+
/** Mulberry32 continuation, including fork seed and the legacy scrambled-fork mode. */
|
|
3
|
+
export interface RngState { version: number; state: number; initial: number; scrambledFork: boolean }
|
|
4
|
+
const uint32 = (value: number): boolean => Number.isInteger(value) && value >= 0 && value <= 0xffffffff;
|
|
5
|
+
function validateRngState(state: RngState): void {
|
|
6
|
+
if (state.version !== 1 || !uint32(state.state) || !uint32(state.initial) || typeof state.scrambledFork !== 'boolean') throw new RangeError('Invalid RNG snapshot');
|
|
7
|
+
}
|
|
8
|
+
// Keep the instance shape structural: an engine RNG can exercise the same authored builder in oracle tests.
|
|
9
|
+
const states = new WeakMap<Rng, RngState>();
|
|
10
|
+
function continuation(rng: Rng): RngState {
|
|
11
|
+
const current = states.get(rng);
|
|
12
|
+
if (current === undefined) throw new Error('Author RNG has no continuation');
|
|
13
|
+
return current;
|
|
14
|
+
}
|
|
15
|
+
/** Build-only Mulberry32 with draws, forks and saved continuations identical to the engine RNG. */
|
|
16
|
+
export class Rng {
|
|
17
|
+
constructor(seed: number) { const initial = seed >>> 0; states.set(this, { version: 1, state: initial, initial, scrambledFork: false }); }
|
|
18
|
+
snapshot(): RngState { const current = continuation(this); return { version: 1, state: current.state, initial: current.initial, scrambledFork: current.scrambledFork }; }
|
|
19
|
+
restore(state: RngState): void {
|
|
20
|
+
validateRngState(state);
|
|
21
|
+
states.set(this, { version: 1, state: state.state, initial: state.initial, scrambledFork: state.scrambledFork });
|
|
22
|
+
}
|
|
23
|
+
/** Preserve the facade grammar's multiplicative constructor and numeric forks. */
|
|
24
|
+
static scrambled(seed: number): Rng {
|
|
25
|
+
const rng = new Rng((seed * 2654435761) >>> 0);
|
|
26
|
+
continuation(rng).scrambledFork = true;
|
|
27
|
+
return rng;
|
|
28
|
+
}
|
|
29
|
+
next(): number {
|
|
30
|
+
const current = continuation(this);
|
|
31
|
+
current.state = (current.state + 0x6d2b79f5) >>> 0;
|
|
32
|
+
let t = current.state;
|
|
33
|
+
t = Math.imul(t ^ (t >>> 15), t | 1);
|
|
34
|
+
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
|
35
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
36
|
+
}
|
|
37
|
+
range(a: number, b: number): number { return a + (b - a) * this.next(); }
|
|
38
|
+
int(a: number, b: number): number { return Math.floor(this.range(a, b + 1)); }
|
|
39
|
+
pick<T>(arr: readonly T[]): T { return arr[Math.floor(this.next() * arr.length)] as T; } // an empty list yields undefined, as it always did
|
|
40
|
+
chance(p: number): boolean { return this.next() < p; }
|
|
41
|
+
weighted<T>(pairs: readonly (readonly [T, number])[]): T {
|
|
42
|
+
let sum = 0;
|
|
43
|
+
for (const [, weight] of pairs) sum += weight;
|
|
44
|
+
let r = this.next() * sum;
|
|
45
|
+
for (const [item, weight] of pairs) { r -= weight; if (r <= 0) return item; }
|
|
46
|
+
const last = pairs[pairs.length - 1];
|
|
47
|
+
if (last === undefined) throw new Error('Rng.weighted on an empty list');
|
|
48
|
+
return last[0];
|
|
49
|
+
}
|
|
50
|
+
fork(salt: number | string): Rng {
|
|
51
|
+
if (typeof salt === 'string') return new Rng(fnv1a32(`${String(continuation(this).initial)}:${salt}`));
|
|
52
|
+
const seed = (continuation(this).state ^ Math.imul(salt + 1, 0x9e3779b1)) >>> 0;
|
|
53
|
+
return continuation(this).scrambledFork ? Rng.scrambled(seed) : new Rng(seed);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function fnv1a32(text: string): number {
|
|
58
|
+
let hash = 0x811c9dc5;
|
|
59
|
+
for (let i = 0; i < text.length; i++) hash = Math.imul(hash ^ (text.codePointAt(i) ?? 0), 0x01000193);
|
|
60
|
+
return hash >>> 0;
|
|
61
|
+
}
|