@wildshard/sdk 0.0.1 → 0.2.3
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 +790 -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 +46 -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 +24 -0
- package/src/cli/bin.mjs +8 -0
- package/src/cli/delete/delete.ts +258 -0
- package/src/cli/help.ts +196 -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 +292 -0
- package/src/cli/report.ts +16 -0
- package/src/cli/shardfile/command.ts +50 -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/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 +117 -0
- package/src/sharddev/checkProject.ts +126 -0
- package/src/sharddev/cli.ts +191 -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 +247 -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 +18 -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 +234 -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,311 @@
|
|
|
1
|
+
// E357 F9: folder discovery is the sole authored shard list.
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { dirname, resolve, relative } from 'node:path';
|
|
5
|
+
import { pathToFileURL } from 'node:url';
|
|
6
|
+
import ts from '@typescript/typescript6';
|
|
7
|
+
import { productManifestPath, authoredManifestSource } from '@wildshard/engine/scripts/authored-manifest.mjs';
|
|
8
|
+
import { outputManifest, shardProducts } from '@wildshard/engine/scripts/shard-outputs.mjs';
|
|
9
|
+
import { genShardWords } from '@wildshard/engine/scripts/gen-shard-words.mjs';
|
|
10
|
+
import { readProgramDiscovery, usesProgramDiscovery } from '@wildshard/engine/scripts/program-discovery.mjs';
|
|
11
|
+
import { authoredManifestImports } from '@wildshard/engine/scripts/manifest-static-imports.mjs';
|
|
12
|
+
|
|
13
|
+
/** Static runtime imports only: lazy plugin/look thunks and erased types stay out of the startup closure. */
|
|
14
|
+
export function manifestClosure(root) {
|
|
15
|
+
const configPath = ts.findConfigFile(root, (file) => ts.sys.fileExists(file));
|
|
16
|
+
const config = configPath ? ts.readConfigFile(configPath, (file) => ts.sys.readFile(file)).config : {};
|
|
17
|
+
const { options } = ts.parseJsonConfigFileContent(config, ts.sys, root);
|
|
18
|
+
// All products in this synchronous walk resolve against the same options.
|
|
19
|
+
// Reuse resolution work and immutable syntax, never the closure or file bytes.
|
|
20
|
+
const resolutions = ts.createModuleResolutionCache(root, name => ts.sys.useCaseSensitiveFileNames ? name : name.toLowerCase(), options);
|
|
21
|
+
/** @type {Map<string,{text:string,source:import('@typescript/typescript6').SourceFile}>} */
|
|
22
|
+
const syntax = new Map();
|
|
23
|
+
const result = {};
|
|
24
|
+
for (const product of shardProducts(root, shardFolders(root))) {
|
|
25
|
+
const slug = product.slug, seen = new Set();
|
|
26
|
+
const entry = resolve(root, productManifestPath(root, product));
|
|
27
|
+
const authored = resolve(root, `src/shards/${product.folder}/manifest.json`);
|
|
28
|
+
const visit = (file) => {
|
|
29
|
+
const id = relative(root, file).replaceAll('\\', '/');
|
|
30
|
+
if (seen.has(id)) return;
|
|
31
|
+
seen.add(id);
|
|
32
|
+
if (!/\.[cm]?[jt]sx?$/.test(file)) return;
|
|
33
|
+
const text = file === entry && existsSync(authored)
|
|
34
|
+
? relocateDiscoverySource(root, product, authoredManifestImports(root, product.folder, product.output === null ? JSON.parse(readFileSync(authored, 'utf8')) : outputManifest(root, product.folder, product.output), product.output !== null)
|
|
35
|
+
.map(specifier => `import ${JSON.stringify(specifier)};`).join('\n'))
|
|
36
|
+
: readFileSync(file, 'utf8');
|
|
37
|
+
let parsed = syntax.get(file);
|
|
38
|
+
if (parsed?.text !== text) {
|
|
39
|
+
parsed = { text, source: ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true) };
|
|
40
|
+
syntax.set(file, parsed);
|
|
41
|
+
}
|
|
42
|
+
const source = parsed.source;
|
|
43
|
+
for (const node of source.statements) {
|
|
44
|
+
if (!ts.isImportDeclaration(node) && !ts.isExportDeclaration(node)) continue;
|
|
45
|
+
if (!node.moduleSpecifier || !ts.isStringLiteral(node.moduleSpecifier)) continue;
|
|
46
|
+
if (ts.isImportDeclaration(node)) {
|
|
47
|
+
if (node.importClause?.phaseModifier === ts.SyntaxKind.TypeKeyword) continue;
|
|
48
|
+
const bindings = node.importClause?.namedBindings;
|
|
49
|
+
if (!node.importClause?.name && bindings && ts.isNamedImports(bindings) && bindings.elements.length > 0 && bindings.elements.every((e) => e.isTypeOnly)) continue;
|
|
50
|
+
} else if (node.isTypeOnly || (node.exportClause && ts.isNamedExports(node.exportClause) && node.exportClause.elements.length > 0 && node.exportClause.elements.every((e) => e.isTypeOnly))) continue;
|
|
51
|
+
const specifier = node.moduleSpecifier.text;
|
|
52
|
+
const target = ts.resolveModuleName(specifier, file, options, ts.sys, resolutions).resolvedModule?.resolvedFileName;
|
|
53
|
+
if (target && !target.includes('/node_modules/') && !target.endsWith('.d.ts')) visit(target);
|
|
54
|
+
// TypeScript intentionally does not resolve raster imports; include their bundler module ids too.
|
|
55
|
+
else if (specifier.startsWith('.') && existsSync(resolve(dirname(file), specifier))) visit(resolve(dirname(file), specifier));
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
visit(entry);
|
|
59
|
+
result[slug] = [...seen].sort((a, b) => a.localeCompare(b));
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Every product slug (SF88g: a folder's declared outputs, else the folder itself). */
|
|
65
|
+
export function shardSlugs(root) { return shardProducts(root, shardFolders(root)).map((row) => row.slug); }
|
|
66
|
+
export function shardFolders(root) {
|
|
67
|
+
return readdirSync(resolve(root, 'src/shards'), { withFileTypes: true })
|
|
68
|
+
.filter((entry) => entry.isDirectory() && ['manifest.ts', 'manifest.json'].some(file => existsSync(resolve(root, 'src/shards', entry.name, file))))
|
|
69
|
+
.map((entry) => entry.name).sort();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The shard list (E362 AG4): every manifest, imported by the composition root (src/shards.generated.ts, installed by
|
|
75
|
+
* src/shardList.ts) so the game layer imports no shard, and its TypeScript project builds without them.
|
|
76
|
+
*/
|
|
77
|
+
export function shardSource(root) {
|
|
78
|
+
const products = shardProducts(root, shardFolders(root)), slugs = products.map((row) => row.slug);
|
|
79
|
+
if (slugs.length === 0) throw new Error('gen-shards: no shard manifests');
|
|
80
|
+
const catalogue = resolve(root, 'src/shared/game/grid/singleplayer.json');
|
|
81
|
+
const placements = existsSync(catalogue) ? JSON.parse(readFileSync(catalogue, 'utf8')).placements : null;
|
|
82
|
+
if (placements !== null) {
|
|
83
|
+
const seen = new Set();
|
|
84
|
+
for (const p of placements) {
|
|
85
|
+
if (!slugs.includes(p.slug) || seen.has(p.slug) || !Array.isArray(p.cell) || p.cell.length !== 2 || !p.cell.every(Number.isSafeInteger) || !Array.isArray(p.size) || p.size.length !== 3 || !p.size.every((n) => n === 500) || typeof p.instance !== 'string') throw new Error('gen-shards: invalid grid placement');
|
|
86
|
+
seen.add(p.slug);
|
|
87
|
+
}
|
|
88
|
+
if (seen.size !== slugs.length) throw new Error('gen-shards: missing grid placement');
|
|
89
|
+
}
|
|
90
|
+
const placed = slugs.flatMap((slug, i) => {
|
|
91
|
+
if (placements === null) return [`m${i}`];
|
|
92
|
+
const p = placements.find((entry) => entry.slug === slug);
|
|
93
|
+
return [`{ ...m${i}, placement: { grid: ${JSON.stringify(p.cell)}, size: ${JSON.stringify(p.size)}, instance: ${JSON.stringify(p.instance)} } }`];
|
|
94
|
+
});
|
|
95
|
+
const metadata = placements === null ? '' : ' & { placement: { grid: [number, number]; size: [number, number, number]; instance: string } }';
|
|
96
|
+
return `// Generated by gen:source (scripts/gen-shards.mjs) from authored manifests, outputs and grid placements; do not edit.
|
|
97
|
+
import type { ShardManifest } from './game/client/shard/manifest';
|
|
98
|
+
${products.map((product, i) => `import m${i} from '${moduleRelative(resolve(root, 'src'), resolve(root, productManifestPath(root, product))).slice(0, -'.ts'.length)}';`).join('\n')}
|
|
99
|
+
const placed: (ShardManifest${metadata})[] = [${placed.join(', ')}];
|
|
100
|
+
export const SHARDS: typeof placed = placed.sort((a, b) => a.order - b.order);
|
|
101
|
+
`;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const LOAD = /\bload:\s*\(\)\s*=>\s*import\(\s*['"]\.\.?\/plugin(?:\.ts)?['"]\s*\)/u;
|
|
105
|
+
const BUDGET_FILE = 'lint/manifest-closure-budget.json';
|
|
106
|
+
/** Only the exported manifest object can opt into the data-descriptor contract. */
|
|
107
|
+
export function shardfileDescriptor(text) {
|
|
108
|
+
const source = ts.createSourceFile('manifest.ts', text, ts.ScriptTarget.Latest, true);
|
|
109
|
+
const variables = new Map(); let expression;
|
|
110
|
+
for (const statement of source.statements) {
|
|
111
|
+
if (ts.isVariableStatement(statement)) for (const declaration of statement.declarationList.declarations) {
|
|
112
|
+
if (ts.isIdentifier(declaration.name)) variables.set(declaration.name.text, declaration.initializer);
|
|
113
|
+
}
|
|
114
|
+
if (ts.isExportAssignment(statement) && !statement.isExportEquals) expression = statement.expression;
|
|
115
|
+
}
|
|
116
|
+
if (expression && ts.isIdentifier(expression)) expression = variables.get(expression.text);
|
|
117
|
+
while (expression && (ts.isSatisfiesExpression(expression) || ts.isAsExpression(expression) || ts.isParenthesizedExpression(expression))) expression = expression.expression;
|
|
118
|
+
if (!expression || !ts.isObjectLiteralExpression(expression)) return null;
|
|
119
|
+
const named = (property, name) => property.name && (ts.isIdentifier(property.name) || ts.isStringLiteral(property.name)) && property.name.text === name;
|
|
120
|
+
const property = expression.properties.find((row) => named(row, 'shardfile'));
|
|
121
|
+
if (property === undefined) return null;
|
|
122
|
+
return { path: ts.isPropertyAssignment(property) && ts.isStringLiteral(property.initializer) ? property.initializer.text : null,
|
|
123
|
+
load: expression.properties.some((row) => named(row, 'load')) };
|
|
124
|
+
}
|
|
125
|
+
function descriptorContract(root, slug, text) {
|
|
126
|
+
const descriptor = shardfileDescriptor(text);
|
|
127
|
+
if (descriptor === null) return null;
|
|
128
|
+
const failures = [];
|
|
129
|
+
if (descriptor.path !== `/shardfiles/${slug}/shard.json`) failures.push('shardfile must be the literal canonical /shardfiles/<slug>/shard.json path');
|
|
130
|
+
if (!existsSync(resolve(root, `src/shards/${slug}/shard.config.ts`))) failures.push('shardfile descriptor requires its buildable shard.config.ts project');
|
|
131
|
+
if (descriptor.load) failures.push('shardfile descriptor cannot also load a runtime plugin');
|
|
132
|
+
return failures;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* E362 AG10: a legacy `load` is `() => import('./plugin')`; a data descriptor has a canonical shardfile path and no load.
|
|
136
|
+
* manifest's static closure stays inside its file budget (`lint/manifest-closure-budget.json`: one `default` limit for
|
|
137
|
+
* every shard, not a ratchet); every `ShardManifest` field is read by the engine, the game or the tooling (`fields`).
|
|
138
|
+
* Slug = folder is check-shards' (AG9).
|
|
139
|
+
*/
|
|
140
|
+
export function manifestContract(root, closure, fields = false) {
|
|
141
|
+
const failures = [];
|
|
142
|
+
const budgetPath = resolve(root, BUDGET_FILE);
|
|
143
|
+
const budgets = existsSync(budgetPath) ? JSON.parse(readFileSync(budgetPath, 'utf8')).budgets : {};
|
|
144
|
+
for (const product of shardProducts(root, shardFolders(root))) {
|
|
145
|
+
const slug = product.slug, folder = product.folder;
|
|
146
|
+
const json = existsSync(resolve(root, `src/shards/${folder}/manifest.json`));
|
|
147
|
+
const source = readFileSync(resolve(root, json ? `src/shards/${folder}/manifest.json` : `src/shards/${folder}/manifest.ts`), 'utf8');
|
|
148
|
+
const descriptor = json ? null : descriptorContract(root, slug, source);
|
|
149
|
+
const authored = !json ? null : product.output === null ? JSON.parse(source) : outputManifest(root, folder, product.output);
|
|
150
|
+
const dataOnly = json && authored.shardfile === `/shardfiles/${slug}/shard.json` && authored.bindings?.load === undefined && authored.bindings?.entry === undefined && existsSync(resolve(root, `src/shards/${folder}/shard.config.ts`));
|
|
151
|
+
if (descriptor !== null) failures.push(...descriptor.map((message) => `src/shards/${slug}/manifest.ts: ${message}`));
|
|
152
|
+
else if (!dataOnly && (json ? authored.bindings?.entry === undefined && authored.bindings?.load?.module !== './plugin' : !LOAD.test(source))) failures.push(`src/shards/${slug}/manifest.ts: load must be \`() => import('./plugin')\` (a lazy plugin, never a static import)`);
|
|
153
|
+
if (/^import\s[^;]*['"]\.\.?\/plugin(?:\.ts)?['"]/mu.test(source)) failures.push(`src/shards/${slug}/manifest.ts imports ./plugin statically: it would ride in cold boot`);
|
|
154
|
+
const budget = budgets[slug] ?? budgets.default, size = closure[slug]?.length ?? 0;
|
|
155
|
+
if (typeof budget === 'number' && size > budget) failures.push(`src/shards/${slug}/manifest.ts: its static closure is ${size} files, over its budget ${budget} (${BUDGET_FILE}); move the new imports behind load / a lazy thunk`);
|
|
156
|
+
}
|
|
157
|
+
if (fields) {
|
|
158
|
+
const file = resolve(root, 'src/client/game/shard/manifest.ts');
|
|
159
|
+
const decl = ts.createSourceFile(file, readFileSync(file, 'utf8'), ts.ScriptTarget.Latest, true);
|
|
160
|
+
let names = [];
|
|
161
|
+
decl.forEachChild((n) => { if (ts.isInterfaceDeclaration(n) && n.name.text === 'ShardManifest') names = n.members.filter(ts.isPropertySignature).map((m) => m.name.getText(decl)); });
|
|
162
|
+
const texts = [];
|
|
163
|
+
const scan = (dir) => {
|
|
164
|
+
if (!existsSync(resolve(root, dir))) return;
|
|
165
|
+
for (const entry of readdirSync(resolve(root, dir), { withFileTypes: true })) {
|
|
166
|
+
const path = `${dir}/${entry.name}`;
|
|
167
|
+
if (entry.isDirectory()) scan(path);
|
|
168
|
+
else if (/\.[cm]?[jt]s$/u.test(entry.name) && !entry.name.endsWith('.generated.ts')) texts.push(readFileSync(resolve(root, path), 'utf8'));
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
for (const dir of ['src/engine', 'src/game', 'lint', 'scripts']) scan(dir);
|
|
172
|
+
const all = texts.join('\n');
|
|
173
|
+
for (const name of names) if (!new RegExp(`\\.${name}\\b|['"]${name}['"]`, 'u').test(all)) failures.push(`ShardManifest.${name}: nothing in the engine, the game or the tooling reads it; drop the field`);
|
|
174
|
+
}
|
|
175
|
+
return failures;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** A product's discovery module source (its manifest.json bindings, its composed output when it declares one). */
|
|
179
|
+
function discoverySource(root, product) {
|
|
180
|
+
const composed = product.output === null ? null : outputManifest(root, product.folder, product.output);
|
|
181
|
+
const metadata = composed ?? JSON.parse(readFileSync(resolve(root, `src/shards/${product.folder}/manifest.json`), 'utf8'));
|
|
182
|
+
const program = usesProgramDiscovery(metadata);
|
|
183
|
+
return relocateDiscoverySource(root, product, authoredManifestSource(root, product.slug, { folder: product.folder, composed,
|
|
184
|
+
...(program ? { discovery: readProgramDiscovery(root, product.slug) } : {}) }));
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function moduleRelative(from, to) {
|
|
188
|
+
const path = relative(from, to).replaceAll('\\', '/');
|
|
189
|
+
return path.startsWith('.') ? path : `./${path}`;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** Rebase only actual module specifiers, never identically spelled authored data strings. */
|
|
193
|
+
export function relocateDiscoverySource(root, product, text) {
|
|
194
|
+
const original = resolve(root, 'src/shards', product.folder), destination = dirname(resolve(root, productManifestPath(root, product)));
|
|
195
|
+
if (original === destination) return text;
|
|
196
|
+
const source = ts.createSourceFile('discovery.ts', text, ts.ScriptTarget.Latest, true), edits = [];
|
|
197
|
+
const visit = node => {
|
|
198
|
+
const specifier = (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) ? node.moduleSpecifier
|
|
199
|
+
: ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword ? node.arguments[0] : undefined;
|
|
200
|
+
if (specifier !== undefined && ts.isStringLiteral(specifier) && specifier.text.startsWith('.'))
|
|
201
|
+
edits.push({ start: specifier.getStart(source), end: specifier.getEnd(), value: JSON.stringify(moduleRelative(destination, resolve(original, specifier.text))) });
|
|
202
|
+
ts.forEachChild(node, visit);
|
|
203
|
+
};
|
|
204
|
+
visit(source);
|
|
205
|
+
let output = text;
|
|
206
|
+
for (const edit of edits.sort((left, right) => right.start - left.start)) output = output.slice(0, edit.start) + edit.value + output.slice(edit.end);
|
|
207
|
+
return output;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** Publish a complete replacement without truncating the module concurrent readers hold.
|
|
211
|
+
* @param {string} path @param {string} source */
|
|
212
|
+
function writeDiscovery(path, source) {
|
|
213
|
+
if (existsSync(path) && readFileSync(path, 'utf8') === source) return;
|
|
214
|
+
const temporary = `${path}.${randomUUID()}.tmp`;
|
|
215
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
216
|
+
try { writeFileSync(temporary, source, { flag: 'wx' }); renameSync(temporary, path); }
|
|
217
|
+
finally { rmSync(temporary, { force: true }); }
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** Refresh every provider whose receipt/bindings are available. A missing or stale
|
|
221
|
+
* product never deletes its last published module: a later generation failure must
|
|
222
|
+
* not break concurrent source readers. genShards still requires current products and
|
|
223
|
+
* strictly replaces these modules after program construction; no placeholder is emitted. */
|
|
224
|
+
export function refreshDiscovery(root = resolve(import.meta.dirname, '..')) {
|
|
225
|
+
for (const product of shardProducts(root, shardFolders(root))) {
|
|
226
|
+
if (!existsSync(resolve(root, `src/shards/${product.folder}/manifest.json`))) continue;
|
|
227
|
+
const path = resolve(root, productManifestPath(root, product));
|
|
228
|
+
let source;
|
|
229
|
+
try { source = discoverySource(root, product); } catch { continue; }
|
|
230
|
+
writeDiscovery(path, source);
|
|
231
|
+
// Retire the old source wrapper only after its complete replacement exists.
|
|
232
|
+
const prior = resolve(root, 'src/shards', product.folder, product.output === null ? 'discovery.generated.ts' : `discovery.${product.slug}.generated.ts`);
|
|
233
|
+
if (prior !== path && existsSync(prior)) rmSync(prior);
|
|
234
|
+
}
|
|
235
|
+
retireDiscoveryBank(root);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** This generator owns only its marked discovery modules, never other .app products. */
|
|
239
|
+
function retireDiscoveryBank(root) {
|
|
240
|
+
const bank = resolve(root, 'out/.app');
|
|
241
|
+
if (!existsSync(bank)) return;
|
|
242
|
+
const owned = new Set(shardProducts(root, shardFolders(root)).map(product => resolve(root, productManifestPath(root, product))));
|
|
243
|
+
for (const file of readdirSync(bank)) {
|
|
244
|
+
if (!/^discovery\.[a-z0-9_.-]+\.generated\.ts$/u.test(file)) continue;
|
|
245
|
+
const path = resolve(bank, file);
|
|
246
|
+
if (!owned.has(path) && readFileSync(path, 'utf8').startsWith('// Generated by scripts/gen-shards.mjs — do not edit or commit.\n')) rmSync(path);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** The build-written shard tables (the shard list, the manifest closure), which import and walk every product's
|
|
251
|
+
* discovery module, by output path. genShards writes them; gen:source registers both. */
|
|
252
|
+
export function shardTables(root) {
|
|
253
|
+
const closure = manifestClosure(root);
|
|
254
|
+
return { 'src/shards.generated.ts': shardSource(root), 'src/server/game/shard/manifest-closure.generated.json': `${JSON.stringify(closure, null, 2)}\n` };
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** Emit the manifest inputs the boot writer actually consumes. Title data
|
|
258
|
+
* is emitted by the final genShards pass after boot tables are complete. */
|
|
259
|
+
export function genShardInputs(root = resolve(import.meta.dirname, '..'), check = false, initializeMissing = false, shard = '') {
|
|
260
|
+
genShardWords(root, check, shard);
|
|
261
|
+
for (const product of shardProducts(root, shardFolders(root))) {
|
|
262
|
+
if (!existsSync(resolve(root, `src/shards/${product.folder}/manifest.json`))) continue;
|
|
263
|
+
const path = resolve(root, productManifestPath(root, product)), source = discoverySource(root, product);
|
|
264
|
+
if (check && existsSync(path) && readFileSync(path, 'utf8') !== source) throw new Error(`gen-shards: stale ${path}`);
|
|
265
|
+
if (!check || !existsSync(path)) writeDiscovery(path, source);
|
|
266
|
+
}
|
|
267
|
+
// SF88g: a discovery module no product owns any more (a folder that now declares outputs, a dropped output) is removed,
|
|
268
|
+
// so no tree, mirror or loader keeps importing a retired product's manifest
|
|
269
|
+
const owned = new Set(shardProducts(root, shardFolders(root)).map((product) => resolve(root, productManifestPath(root, product))));
|
|
270
|
+
for (const folder of shardFolders(root)) for (const file of readdirSync(resolve(root, 'src/shards', folder))) {
|
|
271
|
+
const path = resolve(root, 'src/shards', folder, file);
|
|
272
|
+
if (!/^discovery(?:\.[a-z0-9-]+)?\.generated\.ts$/u.test(file) || owned.has(path)) continue;
|
|
273
|
+
if (check) throw new Error(`gen-shards: stale ${relative(root, path)} (run pnpm gen)`);
|
|
274
|
+
rmSync(path);
|
|
275
|
+
}
|
|
276
|
+
if (!check) retireDiscoveryBank(root);
|
|
277
|
+
writeTables(root, shardTables(root), check, initializeMissing);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function writeTables(root, outputs, check, initializeMissing) {
|
|
281
|
+
for (const [name, source] of Object.entries(outputs)) {
|
|
282
|
+
const out = resolve(root, name);
|
|
283
|
+
const exists = existsSync(out), same = exists && readFileSync(out, 'utf8') === source;
|
|
284
|
+
// A staged-tree export lacks these untracked tables. Only that caller initializes missing outputs;
|
|
285
|
+
// committed vocabulary above and any existing runtime table still have strict --check semantics.
|
|
286
|
+
const initialize = initializeMissing && !exists;
|
|
287
|
+
if (check && !same && !initialize) throw new Error(`gen-shards: stale ${name} (run pnpm gen)`);
|
|
288
|
+
if ((!check || initialize) && !same) { mkdirSync(dirname(out), { recursive: true }); writeFileSync(out, source); }
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/** Full standalone generation and strict checking. */
|
|
293
|
+
export function genShards(root = resolve(import.meta.dirname, '..'), check = false, initializeMissing = false, shard = '') {
|
|
294
|
+
genShardInputs(root, check, initializeMissing, shard);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// C3: the client builds from a catalogue and its packs, so a tree with no shard source has nothing to generate.
|
|
298
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(realpathSync(process.argv[1])).href && existsSync(resolve(import.meta.dirname, '../src/shards'))) {
|
|
299
|
+
try {
|
|
300
|
+
const shard = process.argv.find((arg) => arg.startsWith('--shard='))?.slice(8);
|
|
301
|
+
genShards(undefined, process.argv.includes('--check'), false, shard);
|
|
302
|
+
// Vite runs discovery before boot byte tables exist. Budget generation belongs to pnpm gen after those tables.
|
|
303
|
+
if (process.argv.includes('--check')) {
|
|
304
|
+
const root = resolve(import.meta.dirname, '..'), failures = manifestContract(root, manifestClosure(root), true);
|
|
305
|
+
if (failures.length > 0) throw new Error(`gen-shards: the manifest contract (AG10):\n ${failures.join('\n ')}`);
|
|
306
|
+
const { genBudgetDerivations } = await import('@wildshard/engine/scripts/gen-budget-derivations.mjs');
|
|
307
|
+
await genBudgetDerivations(undefined, true, shard);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
catch (error) { console.error(error instanceof Error ? error.message : String(error)); process.exitCode = 1; }
|
|
311
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export const DEFAULT_GOLDEN_CAMERAS: string;
|
|
2
|
+
export function goldenPreviewIdentity(value:unknown,expected?:string):{build:string;sha:string};
|
|
3
|
+
export function selectGoldenShards(cameras:Readonly<Record<string,unknown>>,requested?:string):string[];
|
|
4
|
+
export function selectGoldenCameraNumbers(value:string):Set<number>|null;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
|
|
3
|
+
export const DEFAULT_GOLDEN_CAMERAS = 'art/legacy-goldens/compare/cameras24.json';
|
|
4
|
+
|
|
5
|
+
/** The served artifact identifies a capture. HEAD may have moved, and a
|
|
6
|
+
* working-tree candidate deliberately keeps its parent commit's build id.
|
|
7
|
+
* @param {unknown} value @param {string} [expected] */
|
|
8
|
+
export function goldenPreviewIdentity(value, expected = '') {
|
|
9
|
+
const {build} = v.parse(v.object({build:v.string()}), value);
|
|
10
|
+
const matched = /^([a-f0-9]{7,40})(?:-|$)/u.exec(build), prefix = matched?.[1];
|
|
11
|
+
if (prefix === undefined) throw new Error('Preview version has no source SHA');
|
|
12
|
+
if (expected !== '' && !/^[a-f0-9]{40}$/u.test(expected)) throw new Error('--sha requires a full source SHA');
|
|
13
|
+
if (expected !== '' && !expected.startsWith(prefix)) throw new Error(`Preview ${build} does not match --sha ${expected}`);
|
|
14
|
+
return {build, sha:expected || prefix};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Reject a typo before launching a browser rather than silently capturing
|
|
18
|
+
* nothing or falling back to another shard.
|
|
19
|
+
* @param {Readonly<Record<string,unknown>>} cameras @param {string} [requested] */
|
|
20
|
+
export function selectGoldenShards(cameras, requested) {
|
|
21
|
+
const shards = requested === undefined ? Object.keys(cameras) : requested.split(',');
|
|
22
|
+
if (shards.length === 0 || new Set(shards).size !== shards.length
|
|
23
|
+
|| shards.some(slug => slug.length === 0 || !Object.hasOwn(cameras,slug))) throw new Error('--shards requires unique names from the camera set');
|
|
24
|
+
return shards;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** @param {string} value */
|
|
28
|
+
export function selectGoldenCameraNumbers(value) {
|
|
29
|
+
if (value === '') return null;
|
|
30
|
+
const words = value.split(',');
|
|
31
|
+
if (words.some(word => !/^(?:[1-9]|1[0-9]|2[0-4])$/u.test(word)) || new Set(words).size !== words.length)
|
|
32
|
+
throw new Error('--cams requires unique camera numbers 1..24');
|
|
33
|
+
return new Set(words.map(Number));
|
|
34
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""Coarse whole-frame colour guard: sRGB luma and HSV saturation, both 0..1.
|
|
2
|
+
|
|
3
|
+
These limits catch large exposure/grade regressions without treating ordinary
|
|
4
|
+
pixel motion as an exact-image failure. A board still needs its visual read.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
LUMA_SHIFT_LIMIT = 0.15
|
|
8
|
+
SATURATION_SHIFT_LIMIT = 0.08
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def mean_colour(pixels):
|
|
12
|
+
count, luma, saturation = 0, 0.0, 0.0
|
|
13
|
+
for r, g, b in pixels:
|
|
14
|
+
high, low = max(r, g, b), min(r, g, b)
|
|
15
|
+
luma += (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255
|
|
16
|
+
saturation += (high - low) / high if high else 0
|
|
17
|
+
count += 1
|
|
18
|
+
if not count:
|
|
19
|
+
raise ValueError('Colour comparison needs pixels')
|
|
20
|
+
return luma / count, saturation / count
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def colour_shift(golden, now):
|
|
24
|
+
before, after = mean_colour(golden), mean_colour(now)
|
|
25
|
+
luma, saturation = after[0] - before[0], after[1] - before[1]
|
|
26
|
+
return {'luma_delta': luma, 'saturation_delta': saturation,
|
|
27
|
+
'red': abs(luma) >= LUMA_SHIFT_LIMIT or abs(saturation) >= SATURATION_SHIFT_LIMIT}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function queueGoldenResidencyInstall(install:()=>Promise<void>):void;
|
|
2
|
+
export function workingGoldenPreviewFolder(record:string):string;
|
|
3
|
+
export function goldenRefinementBinding(base:string,source:{build:string;sha:string}):Promise<{
|
|
4
|
+
initializerExport:string;classExport:string;sha:string;build:string;preview:string;nineIndexSHA256:string;chunk:string;chunkSHA256:string;
|
|
5
|
+
}>;
|
|
6
|
+
export function refinementExports(source:string):{initializerExport:string;classExport:string};
|
|
7
|
+
export function observeRefinement<T extends readonly unknown[]>(proto:{add:(...args:T)=>Promise<boolean>}):{
|
|
8
|
+
jobs:{id:T[0];at:T[1];state:string;error?:string}[];
|
|
9
|
+
};
|
|
10
|
+
export function heldGoldenResidency():Promise<unknown>;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import {createHash} from 'node:crypto';
|
|
2
|
+
import {existsSync,readdirSync,readFileSync} from 'node:fs';
|
|
3
|
+
import {homedir} from 'node:os';
|
|
4
|
+
import {join,dirname} from 'node:path';
|
|
5
|
+
|
|
6
|
+
/** Working candidates use the ordinary port registry, not a committed-SHA
|
|
7
|
+
* shared lease. Its dist must still identify the actual served build.
|
|
8
|
+
* @param {string} record */
|
|
9
|
+
export function workingGoldenPreviewFolder(record) {
|
|
10
|
+
const matched=/^\d+\s+\d+\s+(.+)\s+\S+\s+\S+\s*$/u.exec(record.trim());
|
|
11
|
+
const folder=matched?.[1];
|
|
12
|
+
if(folder===undefined||!folder.startsWith('/')) throw new Error('Invalid working preview registry record');
|
|
13
|
+
return folder;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** SHARD SELECT replaces the document. Schedule this in every init-script
|
|
17
|
+
* realm, after module-script bases exist and before the async world boot. */
|
|
18
|
+
export function queueGoldenResidencyInstall(install) {
|
|
19
|
+
if (document.readyState==='loading') document.addEventListener('DOMContentLoaded',()=>{void install();},{once:true});
|
|
20
|
+
else void install();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Rebind the release reader to this actual shared preview, never a copied chunk name.
|
|
24
|
+
* @param {string} base @param {{build:string,sha:string}} source */
|
|
25
|
+
export async function goldenRefinementBinding(base,source) {
|
|
26
|
+
const url=new URL(base);
|
|
27
|
+
if (!['127.0.0.1','localhost'].includes(url.hostname)) throw new Error('Nine settled reader requires a local serve-build preview');
|
|
28
|
+
const registry=join(homedir(),'.dev-servers','.shared');
|
|
29
|
+
const matches=readdirSync(registry).filter(file=>file.endsWith('.json')).map(file=>JSON.parse(readFileSync(join(registry,file),'utf8')))
|
|
30
|
+
.filter(row=>row.status==='ready'&&String(row.port)===url.port&&row.sha.startsWith(source.sha)&&row.coverage==='all'&&row.mode==='production');
|
|
31
|
+
if (matches.length>1) throw new Error('Nine settled reader preview binding is ambiguous');
|
|
32
|
+
const pinned=matches[0],folder=pinned?.out??workingGoldenPreviewFolder(readFileSync(join(dirname(registry),url.port),'utf8'));
|
|
33
|
+
const root=join(folder,'dist'),version=JSON.parse(readFileSync(join(root,'version.json'),'utf8'));
|
|
34
|
+
if(version.build!==source.build)throw new Error('Native reader dist differs from served version');
|
|
35
|
+
const index=readFileSync(join(root,'shardfiles','nine-dragon-stack','shard.json'));
|
|
36
|
+
const product=JSON.parse(index.toString('utf8'));
|
|
37
|
+
if(product.format!=='wildshard.shardfile'||product.formatVersion!==2||product.identity?.slug!=='nine-dragon-stack')
|
|
38
|
+
throw new Error('Native reader requires the served Nine product');
|
|
39
|
+
const servedIndex=Buffer.from(await(await fetch(new URL('/shardfiles/nine-dragon-stack/shard.json',base))).arrayBuffer());
|
|
40
|
+
if(!servedIndex.equals(index))throw new Error('Served Nine index differs from exact preview');
|
|
41
|
+
const code=`b/${source.build}`,codeFolder=existsSync(join(root,code))?code:'assets',dist=join(root,codeFolder);
|
|
42
|
+
const chunks=readdirSync(dist).filter(file=>file.endsWith('.js')).map(file=>({file,bytes:readFileSync(join(dist,file))}))
|
|
43
|
+
.filter(row=>row.bytes.includes('Invalid or duplicate refinement job'));
|
|
44
|
+
if (chunks.length!==1) throw new Error('Native refinement chunk is missing or ambiguous');
|
|
45
|
+
const {file,bytes}=chunks[0],binding=refinementExports(bytes.toString('utf8'));
|
|
46
|
+
const chunk=`/${codeFolder}/${file}`,served=Buffer.from(await(await fetch(new URL(chunk,base))).arrayBuffer());
|
|
47
|
+
if (!served.equals(bytes)) throw new Error('Served native refinement differs from exact preview');
|
|
48
|
+
return {...binding,sha:pinned?.sha??source.sha,build:source.build,preview:pinned===undefined?'working-tree':'pinned',
|
|
49
|
+
nineIndexSHA256:createHash('sha256').update(index).digest('hex'),chunk,chunkSHA256:createHash('sha256').update(served).digest('hex')};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Fail closed when the compiler shape changes; no guessed export or copied release binding.
|
|
53
|
+
* @param {string} source */
|
|
54
|
+
export function refinementExports(source) {
|
|
55
|
+
const classes=[...source.matchAll(/([\w$]+)=class\{view;waiting=new Map;known=new Set/gu)];
|
|
56
|
+
if (classes.length!==1) throw new Error('Native refinement class identity ambiguous');
|
|
57
|
+
const match=classes[0],initializers=[...source.slice(0,match.index).matchAll(/function ([\w$]+)\(\)\{return\(/gu)];
|
|
58
|
+
const initializer=initializers.at(-1)?.[1];
|
|
59
|
+
if (initializer===undefined) throw new Error('Native refinement initializer unavailable');
|
|
60
|
+
const exports=source.slice(source.lastIndexOf('export'));
|
|
61
|
+
const alias=name=>{
|
|
62
|
+
const escaped=name.replaceAll(/[.*+?^${}()|[\]\\]/gu,String.raw`\$&`);
|
|
63
|
+
const rows=[...exports.matchAll(new RegExp(`(?<![\\w$])${escaped}\\s+as\\s+([\\w$]+)`,'gu'))];
|
|
64
|
+
if (rows.length!==1) throw new Error('Native refinement export unavailable or ambiguous');
|
|
65
|
+
return rows[0][1];
|
|
66
|
+
};
|
|
67
|
+
return {initializerExport:alias(initializer),classExport:alias(match[1])};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Observe publication without changing the native receiver, arguments or returned promise.
|
|
71
|
+
* Serialized into the pre-navigation observer. */
|
|
72
|
+
export function observeRefinement(proto) {
|
|
73
|
+
const original=proto.add,jobs=[];
|
|
74
|
+
if (typeof original!=='function') throw new Error('Native refinement add missing');
|
|
75
|
+
proto.add=function add(...args) {
|
|
76
|
+
const promise=Reflect.apply(original,this,args),row={id:args[0],at:args[1],state:'pending'};
|
|
77
|
+
jobs.push(row);
|
|
78
|
+
void (async()=>{
|
|
79
|
+
try {row.state=await promise?'published':'retired';}
|
|
80
|
+
catch(error) {row.state='failed';row.error=String(error);}
|
|
81
|
+
})();
|
|
82
|
+
return promise;
|
|
83
|
+
};
|
|
84
|
+
return {jobs};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Same native publication fence as sp-ci-deploy's reader; the golden camera/composer protocol stays intact. */
|
|
88
|
+
export async function heldGoldenResidency() {
|
|
89
|
+
const w=window.__wildshard.world,g=w.game,ledger=window.__goldenResidency;
|
|
90
|
+
const snapshot=()=>JSON.stringify({frame:g.frameCount,clock:g.app.clock.snapshot(),camera:g.camera.matrixWorld.elements,player:w.player.position.toArray()});
|
|
91
|
+
if (!g.hold||!ledger||ledger.jobs.length===0) throw new Error(`Native residency observer is not bound to a held world ${JSON.stringify({hold:g.hold,ledger:ledger!==undefined,jobs:ledger?.jobs.length??0,documentOrigin:performance.timeOrigin})}`);
|
|
92
|
+
const before=snapshot(),start=Date.now();let turns=0;
|
|
93
|
+
for (;;) {
|
|
94
|
+
await new Promise(resolve=>{requestAnimationFrame(resolve);});turns++;
|
|
95
|
+
if (ledger.jobs.some(row=>row.state==='failed'||row.state==='retired')) throw new Error('Native publication failed or retired');
|
|
96
|
+
if (!ledger.jobs.some(row=>row.state==='pending')) {
|
|
97
|
+
await new Promise(resolve=>{setTimeout(resolve,0);});
|
|
98
|
+
if (!ledger.jobs.some(row=>row.state==='pending')) break;
|
|
99
|
+
}
|
|
100
|
+
if (Date.now()-start>=29000) throw new Error('Native publication did not settle');
|
|
101
|
+
}
|
|
102
|
+
if (snapshot()!==before) throw new Error('Native wait changed frame, clock, camera or player');
|
|
103
|
+
return {jobs:ledger.jobs,heldState:JSON.parse(before),turns,elapsedMs:Date.now()-start,pending:0};
|
|
104
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type {FloorGridState} from '@wildshard/engine/scripts/frame-floor-grid.mjs';
|
|
2
|
+
|
|
3
|
+
export interface PlotGoldenView {
|
|
4
|
+
n:number;name:string;label:string;player:[number,number];eye:[number,number,number];look:[number,number,number];
|
|
5
|
+
hfov:62;aspect:'2:3';world:{eye:[number,number,number];look:[number,number,number];fov:number};inside:string|null;note?:string;
|
|
6
|
+
}
|
|
7
|
+
export interface PlotGoldens {schema:'golden-cameras/1';slug:string;instance:string;origin:{x:number;z:number};pitch:number;convention:string;views:PlotGoldenView[]}
|
|
8
|
+
export function parsePlotGoldens(input:unknown):PlotGoldens;
|
|
9
|
+
export function plotGoldenCamera(row:Pick<PlotGoldenView,'eye'|'look'|'hfov'>,origin:{x:number;z:number}):{eye:number[];look:number[];fov:number};
|
|
10
|
+
export function plotGoldenPlacement(plan:PlotGoldens,grid:Pick<FloorGridState,'pitch'|'cells'>):{
|
|
11
|
+
instance:string;origin:{x:number;z:number};pitch:number;sourceInstance:string;sourceOrigin:{x:number;z:number};
|
|
12
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
|
|
3
|
+
const finite = v.pipe(v.number(), v.finite());
|
|
4
|
+
const name = v.pipe(v.string(), v.regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/u));
|
|
5
|
+
const point = v.tuple([finite, finite, finite]);
|
|
6
|
+
const world = v.strictObject({eye:point,look:point,fov:finite});
|
|
7
|
+
const view = v.strictObject({n:finite,name,label:v.string(),player:v.tuple([finite,finite]),eye:point,look:point,
|
|
8
|
+
hfov:v.literal(62),aspect:v.literal('2:3'),world,inside:v.nullable(name),note:v.optional(v.string())});
|
|
9
|
+
const schema = v.strictObject({schema:v.literal('golden-cameras/1'),slug:name,instance:name,
|
|
10
|
+
origin:v.strictObject({x:finite,z:finite}),pitch:finite,convention:v.string(),views:v.pipe(v.array(view),v.length(8))});
|
|
11
|
+
|
|
12
|
+
/** Keep the historical world coordinates as provenance and reject corrupt local/world pairs.
|
|
13
|
+
* @param {unknown} input */
|
|
14
|
+
export function parsePlotGoldens(input) {
|
|
15
|
+
const plan = v.parse(schema,input);
|
|
16
|
+
if (plan.pitch <= 500 || !plan.slug.startsWith('open-plot-') || new Set(plan.views.map(row=>row.name)).size !== 8)
|
|
17
|
+
throw new Error('Invalid golden plot identity');
|
|
18
|
+
for (const [index,row] of plan.views.entries()) {
|
|
19
|
+
const camera = plotGoldenCamera(row,plan.origin);
|
|
20
|
+
if (row.n !== index+1 || row.player.some(word=>Math.abs(word)>250) || !row.eye.some((word,i)=>word !== row.look[i])
|
|
21
|
+
|| Math.abs(camera.fov-row.world.fov)>1e-6
|
|
22
|
+
|| camera.eye.some((word,i)=>Math.abs(word-row.world.eye[i])>1e-6)
|
|
23
|
+
|| camera.look.some((word,i)=>Math.abs(word-row.world.look[i])>1e-6)) throw new Error('Golden camera provenance differs');
|
|
24
|
+
}
|
|
25
|
+
return plan;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** @param {{eye:readonly number[],look:readonly number[],hfov:number}} row
|
|
29
|
+
* @param {{x:number,z:number}} origin */
|
|
30
|
+
export function plotGoldenCamera(row,origin) {
|
|
31
|
+
return {eye:[row.eye[0]+origin.x,row.eye[1],row.eye[2]+origin.z],
|
|
32
|
+
look:[row.look[0]+origin.x,row.look[1],row.look[2]+origin.z],
|
|
33
|
+
fov:2*Math.atan(Math.tan(row.hfov*Math.PI/360)/(2/3))*180/Math.PI};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Resolve by product identity, never the pre-G986 instance or world origin.
|
|
37
|
+
* @param {ReturnType<typeof parsePlotGoldens>} plan
|
|
38
|
+
* @param {Pick<import('@wildshard/engine/scripts/frame-floor-grid.mjs').FloorGridState,'pitch'|'cells'>} grid */
|
|
39
|
+
export function plotGoldenPlacement(plan,grid) {
|
|
40
|
+
const cells=grid.cells.filter(row=>row.slug===plan.slug), pitch=grid.pitch;
|
|
41
|
+
if (cells.length!==1 || pitch===undefined || !Number.isFinite(pitch) || pitch<=500) throw new Error('Golden plot needs one served cell and explicit pitch');
|
|
42
|
+
const cell=cells[0];
|
|
43
|
+
if (cell===undefined) throw new Error('Missing golden plot');
|
|
44
|
+
return {instance:cell.instance,origin:{x:cell.cell[0]*pitch,z:cell.cell[1]*pitch},pitch,
|
|
45
|
+
sourceInstance:plan.instance,sourceOrigin:plan.origin};
|
|
46
|
+
}
|