@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,219 @@
|
|
|
1
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- Build programs cache immutable outputs outside the source tree.
|
|
2
|
+
import { existsSync, realpathSync } from 'node:fs';
|
|
3
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- The cache belongs to this user's author tools.
|
|
4
|
+
import { homedir } from 'node:os';
|
|
5
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- Explicit inputs stay inside the author project.
|
|
6
|
+
import { basename, isAbsolute, resolve, sep } from 'node:path';
|
|
7
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- Product receipts observe keys without depending on cache paths.
|
|
8
|
+
import { channel } from 'node:diagnostics_channel';
|
|
9
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- Native output keys include the original runtime and host.
|
|
10
|
+
import process from 'node:process';
|
|
11
|
+
import * as v from 'valibot';
|
|
12
|
+
import { reportBuildCache } from './buildCacheMetrics';
|
|
13
|
+
import { encodeCanonicalJson, hashImmutableBytes } from './immutable';
|
|
14
|
+
import { copyAssetBytes, hashAssetBytes } from './assetHandle';
|
|
15
|
+
import { readBoundedFile } from './sourceReader';
|
|
16
|
+
import { projectCompilerIdentity } from './projectCompilerIdentity';
|
|
17
|
+
import { compileScript } from './bake/compileScript';
|
|
18
|
+
import { compileScriptV2 } from './bake/compileScriptV2';
|
|
19
|
+
import { compileReturnProjectionV2 } from './returnProjectionV2';
|
|
20
|
+
import { compileDeclaredDecisionScripts, compileDecisionScripts } from './buildDecisionScripts';
|
|
21
|
+
import { proveStaticPortalEntries } from './projectEntryProof';
|
|
22
|
+
import { readImagePixels, writeImagePixels } from './bake/image';
|
|
23
|
+
import { normalizeWorldGlb } from './bake/world';
|
|
24
|
+
import { createBasisEncoder } from './bake/basisEncoder';
|
|
25
|
+
import { phoneAstcKtx2 } from './bake/phoneAstc';
|
|
26
|
+
import { encodeGainKeyMemo } from './bake/keyedSkyMemo';
|
|
27
|
+
import { encodePortableBytesMemo } from './bake/portableBytesMemo';
|
|
28
|
+
import { encodeZstdBytesMemo } from './bake/zstdBytesMemo';
|
|
29
|
+
import { memoAssemblyScript } from './bake/assemblyscriptMemo';
|
|
30
|
+
import { meshoptNoLargerMemo } from './bake/meshoptChoiceMemo';
|
|
31
|
+
import { projectInputFiles } from './projectInputFiles';
|
|
32
|
+
import { generationCache, maybePruneGenerationCache } from './generationCache.ts';
|
|
33
|
+
import type { Shardfile } from '@wildshard/engine/host/shardfile';
|
|
34
|
+
import type { ProjectOutput } from './projectOutput';
|
|
35
|
+
import type { DiscoveryInput } from '@wildshard/format/discoveryValues';
|
|
36
|
+
|
|
37
|
+
const hash = v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/u));
|
|
38
|
+
const Manifest = v.strictObject({ key: hash, files: v.pipe(v.array(v.strictObject({ name: v.string(), hash, bytes: v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(256_000_000)) })), v.maxLength(4096)) });
|
|
39
|
+
const keys = channel('wildshard.generation-key');
|
|
40
|
+
const text = new TextEncoder();
|
|
41
|
+
|
|
42
|
+
/** An immutable step returns named byte files, including JSON metadata when needed. */
|
|
43
|
+
export interface ProjectGenerationStep {
|
|
44
|
+
readonly id: string;
|
|
45
|
+
/** Project-relative paths, or URLs beneath roots explicitly supplied by the author CLI. */
|
|
46
|
+
readonly inputs?: readonly string[];
|
|
47
|
+
readonly native?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/** Explicit filesystem capability for authored public assets; never inferred from a shard name or parent path. */
|
|
50
|
+
export interface ProjectGenerationInputRoot { readonly prefix: string; readonly directory: string }
|
|
51
|
+
/** GR9: a multi-output folder's build program for one output (`programs[slug]` beside `outputs` in shard.config.ts), run
|
|
52
|
+
* when that output builds: its world GLB bytes stand in for reading the declaration's `world.glb`, and its map lattice is
|
|
53
|
+
* published as the output's map. Neither is written into source. */
|
|
54
|
+
export interface OutputProgramResult {
|
|
55
|
+
readonly world?: Uint8Array;
|
|
56
|
+
readonly map?: { readonly pixels: Uint8Array; readonly name?: string };
|
|
57
|
+
}
|
|
58
|
+
/** A build may return output metadata alongside the declaration it describes. Neither is written into source. */
|
|
59
|
+
export interface GeneratedProject {
|
|
60
|
+
readonly shard: Shardfile;
|
|
61
|
+
readonly output: ProjectOutput;
|
|
62
|
+
readonly map?: { readonly pixels: Uint8Array; readonly name?: string };
|
|
63
|
+
/** Computed data bindings admitted into the product receipt, never imported at runtime. */
|
|
64
|
+
readonly discovery?: DiscoveryInput;
|
|
65
|
+
}
|
|
66
|
+
/** Build-only capabilities. No cache filename or intermediate source file enters a product. */
|
|
67
|
+
export interface ProjectGenerationContext {
|
|
68
|
+
/** Always fresh: prove real static portal capsule walks and dispose their native world. */
|
|
69
|
+
proveStaticPortalEntries: typeof proveStaticPortalEntries;
|
|
70
|
+
/** Decode bounded still image bytes into owned RGBA at build time; no Sharp dependency enters the author bundle. */
|
|
71
|
+
readImagePixels: typeof readImagePixels;
|
|
72
|
+
/** Encode a bounded RGBA raster as a deterministic lossless PNG at build time (GR9); older adapters may omit it. */
|
|
73
|
+
writeImagePixels?: typeof writeImagePixels;
|
|
74
|
+
/** The authored-world GLB reader (`bake/world.ts`), so an author bundle decodes model kits without Sharp (GR9); older
|
|
75
|
+
* adapters may omit it. */
|
|
76
|
+
normalizeWorldGlb?: typeof normalizeWorldGlb;
|
|
77
|
+
/** The keyed sky's gain-key gzip (`bake/keyedSky.ts`) with its exact memo in the gen cache (CI6), so an author bundle
|
|
78
|
+
* reaches no file access; older adapters may omit it. */
|
|
79
|
+
encodeGainKey?: (data: Uint16Array) => Uint8Array;
|
|
80
|
+
/** The portable deflate (`bake/portableBytes.ts` encodePortableBytes) with its exact memo in the gen cache (CI6), for a
|
|
81
|
+
* large baked payload whose input rarely changes; older adapters may omit it. */
|
|
82
|
+
encodePortableBytes?: (input: Uint8Array, level?: number) => Uint8Array<ArrayBuffer>;
|
|
83
|
+
/** Original native Zstd bytes with a content/codec/level memo outside the product; older adapters may omit it. */
|
|
84
|
+
encodeZstdBytes?: (input: Uint8Array, level?: number) => Uint8Array<ArrayBuffer>;
|
|
85
|
+
/** The meshopt GLB choice (`blobs.ts` meshoptNoLarger, for nameMeshoptBlob) with its exact memo in the gen cache (CI6);
|
|
86
|
+
* older adapters may omit it. */
|
|
87
|
+
meshoptNoLarger?: (packed: Uint8Array, input: Uint8Array) => Promise<boolean>;
|
|
88
|
+
/** Trusted original UASTC build recipe; older adapters may omit this capability. */
|
|
89
|
+
basisEncoder?: typeof createBasisEncoder;
|
|
90
|
+
/** DL9: a phone-tier UASTC KTX2 as ASTC 4×4 (`bake/phoneAstc.ts`, three's own transcoder at build time); older
|
|
91
|
+
* adapters may omit it, and the phone keeps transcoding at load. */
|
|
92
|
+
phoneAstcKtx2?: typeof phoneAstcKtx2;
|
|
93
|
+
/** Fresh bounded names below project-relative directories or declared URL roots; older adapters may omit it. */
|
|
94
|
+
inputFiles?: (prefixes: readonly string[]) => readonly string[];
|
|
95
|
+
cached: (step: ProjectGenerationStep, generate: (inputs: ReadonlyMap<string, Uint8Array>) => ReadonlyMap<string, Uint8Array> | Promise<ReadonlyMap<string, Uint8Array>>, recipe?: string) => Promise<ReadonlyMap<string, Uint8Array>>;
|
|
96
|
+
asset: (bytes: Uint8Array) => string;
|
|
97
|
+
compileScript: typeof compileScript;
|
|
98
|
+
compileScriptV2: typeof compileScriptV2;
|
|
99
|
+
compileDecisionScripts: typeof compileDeclaredDecisionScripts;
|
|
100
|
+
/** Exact registries for stateless projections; older adapters may omit it. */
|
|
101
|
+
compileDecisionRows?: typeof compileDecisionScripts;
|
|
102
|
+
/** Dual stateless projection compilation, retaining the original witness and every source/admission check. */
|
|
103
|
+
compileReturnProjection?: typeof compileReturnProjectionV2;
|
|
104
|
+
}
|
|
105
|
+
/** Build entries are trusted functions; their returned declaration still crosses normal shardfile admission. */
|
|
106
|
+
export function isProjectGenerator(input: unknown): input is (ctx: ProjectGenerationContext) => unknown { return typeof input === 'function'; }
|
|
107
|
+
const stores = new WeakMap<ProjectGenerationContext, ReturnType<typeof generationCache>>();
|
|
108
|
+
/** Seal completed generation's current keys, release its lease and schedule G430. */
|
|
109
|
+
export async function finishProjectGeneration(context: ProjectGenerationContext, success: boolean): Promise<void> {
|
|
110
|
+
const store = stores.get(context);
|
|
111
|
+
if (store === undefined) return;
|
|
112
|
+
await store.finish(success); stores.delete(context);
|
|
113
|
+
maybePruneGenerationCache(store.root);
|
|
114
|
+
}
|
|
115
|
+
function name(value: string): void {
|
|
116
|
+
if (value.length === 0 || isAbsolute(value) || value.includes('\\') || value.split('/').some(part => part === '' || part === '.' || part === '..')) throw new Error('Invalid generation file name');
|
|
117
|
+
}
|
|
118
|
+
function detached(files: ReadonlyMap<string, Uint8Array>): Map<string, Uint8Array> {
|
|
119
|
+
if (files.size > 4096) throw new Error('Too many generation files');
|
|
120
|
+
return new Map([...files].map(([file, bytes]) => {
|
|
121
|
+
name(file);
|
|
122
|
+
if (!(bytes instanceof Uint8Array) || bytes.byteLength > 256_000_000) throw new Error('Invalid generation bytes');
|
|
123
|
+
return [file, copyAssetBytes(bytes)];
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
/** Bundled steps carry their own lexical recipe identity. Direct callers retain
|
|
127
|
+
* the conservative program identity unless they supply an exact recipe.
|
|
128
|
+
* Explicit input bytes are read on hits too, preserving the product receipt. */
|
|
129
|
+
export function createProjectGeneration(project: string, programHash: string, assets: Map<string, Uint8Array>, cacheRoot: string = process.env['WILDSHARD_GEN_CACHE'] ?? resolve(homedir(), '.cache/wildshard/gen'), inputRoots: readonly ProjectGenerationInputRoot[] = [], scope = ''): ProjectGenerationContext {
|
|
130
|
+
v.parse(hash, programHash);
|
|
131
|
+
const root = realpathSync(project), pending = new Map<string, Promise<ReadonlyMap<string, Uint8Array>>>();
|
|
132
|
+
if (inputRoots.length > 32) throw new Error('Too many generation input roots');
|
|
133
|
+
// A folder an outside project doesn't have holds no inputs: a project needs no `public/`.
|
|
134
|
+
const roots = inputRoots.flatMap(source => {
|
|
135
|
+
if (!/^\/(?:[a-zA-Z0-9_-]+\/)+$/u.test(source.prefix)) throw new Error('Generation input root needs a bounded absolute URL prefix');
|
|
136
|
+
return existsSync(source.directory) ? [{ prefix: source.prefix, directory: realpathSync(source.directory) }] : [];
|
|
137
|
+
});
|
|
138
|
+
const store = generationCache(cacheRoot, root, scope);
|
|
139
|
+
const context: ProjectGenerationContext = {
|
|
140
|
+
compileScript: (source, options) => compileScript(source, { ...options, compileMemo: memoAssemblyScript }),
|
|
141
|
+
compileScriptV2: (source, options) => compileScriptV2(source, { ...options, compileMemo: memoAssemblyScript }),
|
|
142
|
+
compileDecisionScripts: (input, source, moves, authored, options) => compileDeclaredDecisionScripts(input, source, moves, authored, { ...options, compileMemo: memoAssemblyScript }),
|
|
143
|
+
compileDecisionRows: (input, registries, authored, options) => compileDecisionScripts(input, registries, authored, { ...options, compileMemo: memoAssemblyScript }),
|
|
144
|
+
compileReturnProjection: (input, registries, authored, options) => compileReturnProjectionV2(input, registries, authored, { ...options, compileMemo: memoAssemblyScript }),
|
|
145
|
+
proveStaticPortalEntries, readImagePixels, writeImagePixels, normalizeWorldGlb,
|
|
146
|
+
basisEncoder: createBasisEncoder, phoneAstcKtx2, encodeGainKey: encodeGainKeyMemo, encodePortableBytes: encodePortableBytesMemo, encodeZstdBytes: encodeZstdBytesMemo, meshoptNoLarger: meshoptNoLargerMemo,
|
|
147
|
+
inputFiles: prefixes => projectInputFiles(roots, prefixes, root),
|
|
148
|
+
asset(bytes) {
|
|
149
|
+
if (!(bytes instanceof Uint8Array) || bytes.byteLength > 256_000_000) throw new Error('Invalid generation asset bytes');
|
|
150
|
+
const copy = copyAssetBytes(bytes), key = hashAssetBytes(copy); assets.set(key, copy); return key;
|
|
151
|
+
},
|
|
152
|
+
async cached(step, generate, recipe) {
|
|
153
|
+
if (recipe !== undefined) v.parse(hash, recipe);
|
|
154
|
+
if (!/^[a-z0-9][a-z0-9-]{0,79}$/u.test(step.id)) throw new Error('Invalid generation step id');
|
|
155
|
+
if ((step.inputs?.length ?? 0) > 4096) throw new Error('Too many generation inputs');
|
|
156
|
+
const inputs = new Map<string, Uint8Array>();
|
|
157
|
+
for (const file of step.inputs ?? []) {
|
|
158
|
+
if (inputs.has(file)) throw new Error('Duplicate generation input');
|
|
159
|
+
let base = root, relative = file;
|
|
160
|
+
if (file.startsWith('/')) {
|
|
161
|
+
const matches = roots.filter(source => file.startsWith(source.prefix)), source = matches[0];
|
|
162
|
+
if (matches.length !== 1 || source === undefined) throw new Error('Generation input needs exactly one declared root');
|
|
163
|
+
base = source.directory; relative = file.slice(source.prefix.length);
|
|
164
|
+
if (/[%?#]/u.test(relative)) throw new Error('Generation input URL escapes its root');
|
|
165
|
+
}
|
|
166
|
+
name(relative);
|
|
167
|
+
const path = realpathSync(resolve(base, relative));
|
|
168
|
+
if (!path.startsWith(base + sep)) throw new Error('Generation input escaped its declared root');
|
|
169
|
+
inputs.set(file, readBoundedFile(path, 256_000_000));
|
|
170
|
+
}
|
|
171
|
+
let diagnosticId='';
|
|
172
|
+
const key = hashImmutableBytes(text.encode(encodeCanonicalJson({ version: 3, recipe: recipe ?? programHash, compiler: await projectCompilerIdentity(), id: diagnosticId=step.id, node: process.version,
|
|
173
|
+
native: step.native === true ? [process.platform, process.arch] : null,
|
|
174
|
+
inputs: [...inputs].map(([file, bytes]) => [file, hashImmutableBytes(bytes)]).sort(([a], [b]) => String(a).localeCompare(String(b))) })));
|
|
175
|
+
keys.publish({ key });
|
|
176
|
+
const metric=(event:Parameters<typeof reportBuildCache>[0]['event'],bytes:number):void=>{
|
|
177
|
+
reportBuildCache({cache:'generation-step',project:basename(root),step:diagnosticId,event,bytes});
|
|
178
|
+
};
|
|
179
|
+
metric('lookup',0);
|
|
180
|
+
let work = pending.get(key);
|
|
181
|
+
const memoryHit=work!==undefined;
|
|
182
|
+
if (work === undefined) {
|
|
183
|
+
work = (async () => {
|
|
184
|
+
const saved = await store.read(step.id, key);
|
|
185
|
+
if (saved !== undefined) {
|
|
186
|
+
const manifest = v.parse(Manifest, saved);
|
|
187
|
+
if (manifest.key !== key) throw new Error('Generation cache key mismatch');
|
|
188
|
+
const files = new Map<string, Uint8Array>();
|
|
189
|
+
for (const row of manifest.files) {
|
|
190
|
+
name(row.name);
|
|
191
|
+
if (files.has(row.name)) throw new Error('Duplicate generation cache file');
|
|
192
|
+
const bytes = readBoundedFile(resolve(store.blobs, row.hash), row.bytes);
|
|
193
|
+
if (bytes.byteLength !== row.bytes || hashAssetBytes(bytes) !== row.hash) throw new Error('Generation cache byte mismatch');
|
|
194
|
+
files.set(row.name, bytes);
|
|
195
|
+
}
|
|
196
|
+
metric('disk-hit',[...files.values()].reduce((sum,bytes)=>sum+bytes.byteLength,0));
|
|
197
|
+
return files;
|
|
198
|
+
}
|
|
199
|
+
// Input URL keys have already crossed the explicit-root checks above;
|
|
200
|
+
// output names still cross the stricter cache-file path contract.
|
|
201
|
+
metric('miss',0);
|
|
202
|
+
const copy = new Map([...inputs].map(([file, bytes]) => [file, new Uint8Array(bytes)]));
|
|
203
|
+
const files = detached(await generate(copy));
|
|
204
|
+
const payloadBytes=[...files.values()].reduce((sum,body)=>sum+body.byteLength,0);
|
|
205
|
+
metric('computed',payloadBytes);
|
|
206
|
+
const rows = [...files].map(([file, bytes]) => ({ name: file, hash: hashAssetBytes(bytes), bytes: bytes.byteLength }));
|
|
207
|
+
metric(await store.populate(step.id, { key, files: rows }, files) ? 'population' : 'population-race', payloadBytes);
|
|
208
|
+
return files;
|
|
209
|
+
})();
|
|
210
|
+
pending.set(key, work);
|
|
211
|
+
}
|
|
212
|
+
const files=await work;
|
|
213
|
+
if(memoryHit)metric('memory-hit',[...files.values()].reduce((sum,bytes)=>sum+bytes.byteLength,0));
|
|
214
|
+
return detached(files);
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
stores.set(context, store);
|
|
218
|
+
return context;
|
|
219
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- The injected build context owns declared input directories.
|
|
2
|
+
import { lstatSync, readdirSync, realpathSync } from 'node:fs';
|
|
3
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- Confine URL prefixes to their explicitly owned physical roots.
|
|
4
|
+
import { resolve, sep } from 'node:path';
|
|
5
|
+
|
|
6
|
+
/** Fresh presence facts only: no file payload or native service enters the author module. */
|
|
7
|
+
export function projectInputFiles(roots: readonly { readonly prefix: string; readonly directory: string }[], prefixes: readonly string[], project?: string): readonly string[] {
|
|
8
|
+
if (prefixes.length === 0 || prefixes.length > 8) throw new Error('Invalid generation inventory prefix count');
|
|
9
|
+
const selected = [...prefixes].sort();
|
|
10
|
+
for (const [index, prefix] of selected.entries()) {
|
|
11
|
+
if (!/^\/?(?:[a-zA-Z0-9._-]+\/)+$/u.test(prefix) || prefix.split('/').some(part => part === '.' || part === '..')) throw new Error('Invalid generation inventory prefix');
|
|
12
|
+
const previous = selected[index - 1];
|
|
13
|
+
if (previous !== undefined && prefix.startsWith(previous)) throw new Error('Overlapping generation inventory prefixes');
|
|
14
|
+
}
|
|
15
|
+
const files: string[] = []; let directories = 0;
|
|
16
|
+
for (const prefix of selected) {
|
|
17
|
+
const matches = prefix.startsWith('/') ? roots.filter(root => prefix.startsWith(root.prefix)) : project === undefined ? [] : [{ prefix: '', directory: project }], root = matches[0];
|
|
18
|
+
if (matches.length !== 1 || root === undefined) throw new Error('Generation inventory needs exactly one declared root');
|
|
19
|
+
const relative = prefix.slice(root.prefix.length), directory = resolve(root.directory, relative);
|
|
20
|
+
if (directory !== root.directory && !directory.startsWith(root.directory + sep)) throw new Error('Generation inventory escaped its declared root');
|
|
21
|
+
let parent = root.directory;
|
|
22
|
+
for (const part of relative.split('/').filter(Boolean)) {
|
|
23
|
+
parent = resolve(parent, part);
|
|
24
|
+
const stat = lstatSync(parent);
|
|
25
|
+
if (stat.isSymbolicLink()) throw new Error('Linked generation inventory input');
|
|
26
|
+
if (!stat.isDirectory()) throw new Error('Generation inventory prefix is not a directory');
|
|
27
|
+
}
|
|
28
|
+
const pending = [{ directory, url: prefix, depth: 0 }];
|
|
29
|
+
while (pending.length > 0) {
|
|
30
|
+
const next = pending.pop(); if (next === undefined) throw new Error('Missing generation inventory directory');
|
|
31
|
+
if (++directories > 4096 || next.depth > 32) throw new Error('Generation inventory directory bound exceeded');
|
|
32
|
+
if (realpathSync(next.directory) !== next.directory) throw new Error('Linked generation inventory input');
|
|
33
|
+
const entries = readdirSync(next.directory, { withFileTypes: true });
|
|
34
|
+
if (entries.length > 8192) throw new Error('Generation inventory entry bound exceeded');
|
|
35
|
+
for (const entry of entries) {
|
|
36
|
+
if (entry.isSymbolicLink()) throw new Error('Linked generation inventory input');
|
|
37
|
+
const path = resolve(next.directory, entry.name), url = next.url + entry.name;
|
|
38
|
+
if (entry.isDirectory()) pending.push({ directory: path, url: `${url}/`, depth: next.depth + 1 });
|
|
39
|
+
else if (entry.isFile()) {
|
|
40
|
+
if (files.length >= 4096) throw new Error('Generation inventory file bound exceeded');
|
|
41
|
+
files.push(url);
|
|
42
|
+
} else throw new Error('Nonregular generation inventory input');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return files.sort();
|
|
47
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { AdmissionLate } from '@wildshard/format/admissionLate';
|
|
2
|
+
import { parseManifestMetadata, type ManifestMetadata } from '@wildshard/format/minimap';
|
|
3
|
+
import { hashAssetBytes } from './assetHandle';
|
|
4
|
+
import { nameBlob, type NamedBlob } from './blobs';
|
|
5
|
+
import { STILL_IMAGE_LIMITS } from '@wildshard/format/stillImage';
|
|
6
|
+
|
|
7
|
+
/** Explicit author-side file intake. URL prefixes are mapped by the caller;
|
|
8
|
+
* the SDK knows no repository layout and never resolves a runtime source URL. */
|
|
9
|
+
export interface ProjectManifestSource {
|
|
10
|
+
readonly folder: string;
|
|
11
|
+
readonly file?: string;
|
|
12
|
+
/** SF88g: an output's composed manifest (its folder's manifest.json with the output's overrides), in place of `file`. */
|
|
13
|
+
readonly composed?: unknown;
|
|
14
|
+
readonly imageRoots: readonly { readonly prefix: string; readonly directory: string }[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Read bounded author JSON and its images only through declared local roots.
|
|
18
|
+
* Symlink/traversal escapes, missing images and ambiguous prefixes refuse. File
|
|
19
|
+
* services are loaded only here, so the in-memory packer stays config-safe.
|
|
20
|
+
* A generated map replaces only its declared minimap URL with owned, bounded
|
|
21
|
+
* bytes; URL-root/path checks and normal image admission still apply. */
|
|
22
|
+
export async function readManifestSource(source: ProjectManifestSource, declared?: unknown, generatedMap?: Uint8Array): Promise<{ readonly authored: ManifestMetadata; readonly manifest: ManifestMetadata; readonly blobs: readonly NamedBlob[]; readonly late: AdmissionLate }> {
|
|
23
|
+
const [fs, paths, reader] = await Promise.all([
|
|
24
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- Explicit author file intake owns its bounded disk reads.
|
|
25
|
+
import('node:fs'),
|
|
26
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- Resolve images beneath caller-declared filesystem roots.
|
|
27
|
+
import('node:path'),
|
|
28
|
+
import('./sourceReader'),
|
|
29
|
+
]);
|
|
30
|
+
if (source.imageRoots.length > 32) throw new Error('Too many manifest image roots');
|
|
31
|
+
const roots = source.imageRoots.flatMap(root => {
|
|
32
|
+
if (!/^\/(?:[a-zA-Z0-9_-]+\/)+$/u.test(root.prefix)) throw new Error('Manifest image root needs a bounded absolute URL prefix');
|
|
33
|
+
return fs.existsSync(root.directory) ? [{ prefix: root.prefix, directory: fs.realpathSync(root.directory) }] : [];
|
|
34
|
+
});
|
|
35
|
+
const input = source.composed ?? (source.file === undefined ? declared : reader.readShardfileSource(source.file));
|
|
36
|
+
if (input === undefined) throw new Error('Manifest intake requires an explicit file or declared level metadata');
|
|
37
|
+
const authored = parseManifestMetadata(input, source.folder), images = new Map<string, Uint8Array>();
|
|
38
|
+
for (const { url } of manifestImages(authored)) {
|
|
39
|
+
if (url.startsWith('data:image/') || images.has(url)) continue;
|
|
40
|
+
// Generated bytes still need one confined URL, but no existing directory.
|
|
41
|
+
const generated = generatedMap !== undefined && url === authored.minimap.image;
|
|
42
|
+
const matches = (generated ? source.imageRoots : roots).filter(root => url.startsWith(root.prefix)), root = matches[0];
|
|
43
|
+
if (matches.length !== 1 || root === undefined) throw new Error(`Manifest image needs exactly one declared root: ${url}`);
|
|
44
|
+
const tail = url.slice(root.prefix.length);
|
|
45
|
+
if (/[\\%?#]/u.test(tail) || tail.includes(String.fromCodePoint(0)) || tail.split('/').some(part => part === '' || part === '.' || part === '..')) throw new Error(`Manifest image path escapes its root: ${url}`);
|
|
46
|
+
if (generated && generatedMap !== undefined) {
|
|
47
|
+
if (generatedMap.byteLength > STILL_IMAGE_LIMITS.bytes) throw new Error('Generated manifest map exceeds image bounds');
|
|
48
|
+
images.set(url, new Uint8Array(generatedMap)); continue;
|
|
49
|
+
}
|
|
50
|
+
const file = fs.realpathSync(paths.resolve(root.directory, tail));
|
|
51
|
+
if (!file.startsWith(`${root.directory}${paths.sep}`)) throw new Error(`Manifest image path escapes its root: ${url}`);
|
|
52
|
+
images.set(url, reader.readBoundedFile(file, STILL_IMAGE_LIMITS.bytes));
|
|
53
|
+
}
|
|
54
|
+
return { authored, ...packManifestImages(source.folder, authored, images) };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Build-only image inputs. Every non-data image is resolved by orchestration
|
|
58
|
+
* before packing, never by runtime source imports or network fallback. */
|
|
59
|
+
export function manifestImages(metadata: ManifestMetadata): readonly { readonly name: string; readonly url: string }[] {
|
|
60
|
+
const rows = [
|
|
61
|
+
...Object.entries(metadata.card).map(([name,url])=>({name:`card-${name}`,url})),
|
|
62
|
+
{name:'map',url:metadata.minimap.image},
|
|
63
|
+
...Object.entries(metadata.explore.art).map(([name,url])=>({name:`explore-${name}`,url})),
|
|
64
|
+
...(metadata.explore.compare?.flatMap((row,index)=>[{name:`compare-${index}-live`,url:row.live},{name:`compare-${index}-target`,url:row.image}])??[]),
|
|
65
|
+
];
|
|
66
|
+
const hdri=metadata.sky.hdri;
|
|
67
|
+
if(hdri!==undefined&&(hdri.startsWith('/')||hdri.startsWith('data:image/')))rows.push({name:'sky',url:hdri});
|
|
68
|
+
const horizon=metadata.horizonStrips;
|
|
69
|
+
if(horizon!==undefined){rows.push({name:'horizon-day',url:horizon.day},{name:'horizon-night',url:horizon.night});if(horizon.phone!==undefined)rows.push({name:'horizon-phone-day',url:horizon.phone.day},{name:'horizon-phone-night',url:horizon.phone.night});}
|
|
70
|
+
return rows;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Prepare complete plain level metadata and one charged named blob per distinct
|
|
74
|
+
* image. Exact image bytes survive; identical card/art/map images share one
|
|
75
|
+
* entry. Project declaration intake, not this packer, performs library admission. */
|
|
76
|
+
export function packManifestImages(folder: string, input: unknown, images: ReadonlyMap<string,Uint8Array>): { readonly manifest: ManifestMetadata; readonly blobs: readonly NamedBlob[]; readonly late: AdmissionLate } {
|
|
77
|
+
if(!/^(?:_[a-z]+|[a-z][a-z0-9-]*)$/u.test(folder))throw new Error('Invalid output folder');
|
|
78
|
+
const metadata=parseManifestMetadata(input,folder), packed=new Map<string,NamedBlob>(), urls=new Map<string,string>();
|
|
79
|
+
for(const row of manifestImages(metadata)){
|
|
80
|
+
if(row.url.startsWith('data:image/')){urls.set(row.url,row.url);continue;}
|
|
81
|
+
if(urls.has(row.url))continue;
|
|
82
|
+
const bytes=images.get(row.url);if(bytes===undefined)throw new Error(`Manifest image bytes are missing: ${row.url}`);
|
|
83
|
+
const hash=hashAssetBytes(bytes);let blob=packed.get(hash);
|
|
84
|
+
if(blob===undefined){blob=nameBlob(`ui/images/${row.name}`,'image',bytes);packed.set(hash,blob);}
|
|
85
|
+
urls.set(row.url,`/shardfiles/${folder}/${blob.file.path}`);
|
|
86
|
+
}
|
|
87
|
+
const image=(url:string):string=>{const value=urls.get(url);if(value===undefined)throw new Error('Manifest image was not packed');return value;};
|
|
88
|
+
const compare=metadata.explore.compare?.map(row=>({...row,live:image(row.live),image:image(row.image)}));
|
|
89
|
+
const horizon=metadata.horizonStrips;
|
|
90
|
+
const hdri=metadata.sky.hdri;
|
|
91
|
+
const manifest=parseManifestMetadata({...metadata,card:{thumb:image(metadata.card.thumb),portrait:image(metadata.card.portrait),landscape:image(metadata.card.landscape)},
|
|
92
|
+
minimap:{...metadata.minimap,image:image(metadata.minimap.image)},
|
|
93
|
+
explore:{...metadata.explore,art:{world:image(metadata.explore.art.world),models:image(metadata.explore.art.models),sets:image(metadata.explore.art.sets),practice:image(metadata.explore.art.practice)},...(compare===undefined?{}:{compare})},
|
|
94
|
+
sky:{...metadata.sky,...(hdri===undefined||!urls.has(hdri)?{}:{hdri:image(hdri)})},
|
|
95
|
+
...(horizon===undefined?{}:{horizonStrips:{...horizon,day:image(horizon.day),night:image(horizon.night),...(horizon.phone===undefined?{}:{phone:{day:image(horizon.phone.day),night:image(horizon.phone.night)}})}}),
|
|
96
|
+
},folder);
|
|
97
|
+
// Explorer-only art is demand UI, never part of the spawn view. Content aliases shared with
|
|
98
|
+
// cards, map, sky or horizon stay early, even when their original URLs differ.
|
|
99
|
+
const early = new Set<string>(), deferred = new Set<string>();
|
|
100
|
+
for (const row of manifestImages(metadata)) {
|
|
101
|
+
if (row.url.startsWith('data:image/')) continue;
|
|
102
|
+
const bytes = images.get(row.url); if (bytes === undefined) throw new Error('Manifest image bytes are missing');
|
|
103
|
+
const hash = hashAssetBytes(bytes);
|
|
104
|
+
(row.name.startsWith('explore-') || row.name.startsWith('compare-') ? deferred : early).add(hash);
|
|
105
|
+
}
|
|
106
|
+
const late = [...deferred].filter(hash => !early.has(hash)).map(hash => ({hash}));
|
|
107
|
+
return{manifest,blobs:[...packed.values()],late};
|
|
108
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { parseShardfile, type Shardfile } from '@wildshard/format/shardSchema';
|
|
2
|
+
import { assetCost } from '@wildshard/format/product';
|
|
3
|
+
import { hashAssetBytes } from './assetHandle';
|
|
4
|
+
|
|
5
|
+
/** Build input for a baked map; paths and URLs never enter the authored product. */
|
|
6
|
+
export interface ProjectMap { readonly bytes: Uint8Array; readonly tilesHash: string }
|
|
7
|
+
|
|
8
|
+
/** Pack a bounded still image once into the charged library, retaining the exact authored pixels. */
|
|
9
|
+
export function packProjectMap(source: Shardfile, map: ProjectMap): { shard: Shardfile; hash: string } {
|
|
10
|
+
const hash = hashAssetBytes(map.bytes), cost = assetCost('image', map.bytes);
|
|
11
|
+
if (source.map !== undefined && (source.map.image !== hash || source.map.tilesHash !== map.tilesHash)) throw new Error('Build map differs from the declared map');
|
|
12
|
+
const existing = source.files.find(file => file.hash === hash);
|
|
13
|
+
if (existing !== undefined && (existing.kind !== 'image' || existing.compressed !== map.bytes.length || existing.decoded !== cost.decoded || existing.gpu !== cost.gpu)) throw new Error('Build map differs from its declared image cost');
|
|
14
|
+
const included = source.library.includes(hash);
|
|
15
|
+
return { hash, shard: parseShardfile({ ...source, map: { image: hash, tilesHash: map.tilesHash },
|
|
16
|
+
files: existing === undefined ? [...source.files, { hash, kind: 'image', compressed: map.bytes.length, ...cost, dependencies: [], critical: false }] : source.files,
|
|
17
|
+
library: included ? source.library : [...source.library, hash],
|
|
18
|
+
budgets: { ...source.budgets, library: { ...source.budgets.library,
|
|
19
|
+
...(source.budgets.library.downloadAllowance === undefined ? {} : { downloadAllowance: source.budgets.library.downloadAllowance + (included ? 0 : map.bytes.length) }),
|
|
20
|
+
compressed: source.budgets.library.compressed + (included ? 0 : map.bytes.length),
|
|
21
|
+
resident: source.budgets.library.resident + (included ? 0 : cost.decoded + cost.gpu) } },
|
|
22
|
+
}) };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Encode the source program's fixed 1000-square RGBA lattice through the original lossless map codec.
|
|
26
|
+
* The root adapter may supply its exact world-input key; standalone builds use their bundled program identity. */
|
|
27
|
+
export async function generatedProjectMap(input: unknown, tilesHash: string): Promise<{ map: ProjectMap; name: string | undefined }> {
|
|
28
|
+
if (typeof input !== 'object' || input === null || !('pixels' in input) || !(input.pixels instanceof Uint8Array)
|
|
29
|
+
|| input.pixels.length !== 1000 * 1000 * 4 || Object.keys(input).some(key => key !== 'pixels' && key !== 'name')
|
|
30
|
+
|| 'name' in input && typeof input.name !== 'string' || !/^[a-f0-9]{64}$/u.test(tilesHash)) throw new Error('Invalid generated map lattice or source identity');
|
|
31
|
+
const { default: sharp } = await import('sharp');
|
|
32
|
+
const pixels = new Uint8Array(input.pixels);
|
|
33
|
+
const bytes = new Uint8Array(await sharp(pixels, { raw: { width: 1000, height: 1000, channels: 4 } }).webp({ lossless: true, effort: 6 }).toBuffer());
|
|
34
|
+
return { map: { bytes, tilesHash }, name: 'name' in input && typeof input.name === 'string' ? input.name : undefined };
|
|
35
|
+
}
|