@wildshard/sdk 0.0.0 → 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 +14 -4
- 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 +371 -4
- 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,110 @@
|
|
|
1
|
+
// SA16 (J314): `new --template blender` is shard-format's hand-written template, `blender-template`
|
|
2
|
+
// (`corpus/handwritten`): a shard file folder held by hand, its sections JSON edited in place and its blobs frozen
|
|
3
|
+
// Blender output (J88), with no `shard.config.ts`, no sdk at runtime and no three.js. Format's own `shard-format pack`
|
|
4
|
+
// settles what the sections measure (hashes, sizes, packs, the source hash), so `new` and `check` run it, never a copy
|
|
5
|
+
// of its rules.
|
|
6
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- Format's pack CLI runs as a child, as an author runs it.
|
|
7
|
+
import { spawnSync } from 'node:child_process';
|
|
8
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- Settle hashes over the author's own folder.
|
|
9
|
+
import { createHash } from 'node:crypto';
|
|
10
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- The hand-written source and its settled copy are local folders.
|
|
11
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
12
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- Find format the way this installed package resolves it.
|
|
13
|
+
import { createRequire } from 'node:module';
|
|
14
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- Resolve files beneath the source and format's package.
|
|
15
|
+
import { dirname, resolve } from 'node:path';
|
|
16
|
+
import { readTar } from '@wildshard/format/tar';
|
|
17
|
+
import { SHARD_INDEX } from './shardSource';
|
|
18
|
+
|
|
19
|
+
// The bundled CLI defines import.meta.dirname as the package's src/sharddev, so the package root is two up.
|
|
20
|
+
const SDK_ROOT = resolve(import.meta.dirname, '../..');
|
|
21
|
+
/** The installed shard-format package root (its exports name `.ts` files under `src/format/`). */
|
|
22
|
+
function formatRoot(): string {
|
|
23
|
+
return resolve(dirname(createRequire(resolve(SDK_ROOT, 'package.json')).resolve('@wildshard/format/outputIndex')), '../..');
|
|
24
|
+
}
|
|
25
|
+
/** The hand-written template, as the installed shard-format ships it (`files`: `corpus/handwritten/**`). */
|
|
26
|
+
export function handwrittenTemplate(): string { return resolve(formatRoot(), 'corpus/handwritten'); }
|
|
27
|
+
|
|
28
|
+
interface Identity { readonly slug: string; readonly name: string }
|
|
29
|
+
interface Row { hash: string; bytes: number; path: string; url?: string }
|
|
30
|
+
function readJson(path: string): Record<string, unknown> {
|
|
31
|
+
const parsed: unknown = JSON.parse(readFileSync(path, 'utf8'));
|
|
32
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) throw new Error(`${path}: not a JSON object`);
|
|
33
|
+
return parsed as Record<string, unknown>;
|
|
34
|
+
}
|
|
35
|
+
/** Format holds each JSON file canonical: keys as written (already sorted), one trailing newline. */
|
|
36
|
+
function writeJson(path: string, value: unknown): void { writeFileSync(path, `${JSON.stringify(value)}\n`); }
|
|
37
|
+
function sha256(bytes: Uint8Array): string { return createHash('sha256').update(bytes).digest('hex'); }
|
|
38
|
+
|
|
39
|
+
/** The identity in a hand-written source's `shard.json`. */
|
|
40
|
+
export function handwrittenIdentity(source: string): Identity {
|
|
41
|
+
const identity = readJson(resolve(source, SHARD_INDEX))['identity'];
|
|
42
|
+
if (typeof identity !== 'object' || identity === null || !('slug' in identity) || typeof identity.slug !== 'string'
|
|
43
|
+
|| !('name' in identity) || typeof identity.name !== 'string') throw new Error(`${resolve(source, SHARD_INDEX)}: no identity slug and name`);
|
|
44
|
+
return { slug: identity.slug, name: identity.name };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Settle the hand-written folder `source` into `into` (the same folder, or a built folder it replaces): format's
|
|
49
|
+
* `shard-format pack` measures every section again and validates the whole folder, and its tarball's files are written
|
|
50
|
+
* out. Nothing is written unless format admits the folder. Returns the shard's slug.
|
|
51
|
+
*/
|
|
52
|
+
export function settleHandwritten(source: string, into: string): string {
|
|
53
|
+
const tar = `${into}.settle.tar`;
|
|
54
|
+
mkdirSync(dirname(tar), { recursive: true });
|
|
55
|
+
try {
|
|
56
|
+
const done = spawnSync(process.execPath, [resolve(formatRoot(), 'src/cli/bin.mjs'), 'pack', source, '--out', tar], { encoding: 'utf8' });
|
|
57
|
+
if (done.status !== 0) {
|
|
58
|
+
const reason = `${done.stderr}${done.stdout}`.split('\n').find(line => line.startsWith('shard-format:')) ?? done.error?.message ?? `exit ${String(done.status)}`;
|
|
59
|
+
throw new Error(`hand-written shard file does not pack: ${reason.replace(/^shard-format: /u, '')}`);
|
|
60
|
+
}
|
|
61
|
+
const files = readTar(new Uint8Array(readFileSync(tar)));
|
|
62
|
+
if (into !== source) { rmSync(into, { recursive: true, force: true }); mkdirSync(into, { recursive: true }); }
|
|
63
|
+
for (const [path, bytes] of files) {
|
|
64
|
+
const target = resolve(into, path);
|
|
65
|
+
if (!target.startsWith(`${resolve(into)}/`)) throw new Error(`hand-written shard file: ${path} leaves the folder`);
|
|
66
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
67
|
+
writeFileSync(target, bytes);
|
|
68
|
+
}
|
|
69
|
+
} finally { rmSync(tar, { force: true }); }
|
|
70
|
+
return handwrittenIdentity(into).slug;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Every JSON file a person holds in the folder: the index, the receipts, sections and mounts, never a baked blob. */
|
|
74
|
+
function heldJson(folder: string, prefix = ''): string[] {
|
|
75
|
+
return readdirSync(resolve(folder, prefix), { withFileTypes: true }).flatMap(entry => {
|
|
76
|
+
const path = prefix === '' ? entry.name : `${prefix}/${entry.name}`;
|
|
77
|
+
if (entry.isDirectory()) return path === 'blobs' ? [] : heldJson(folder, path);
|
|
78
|
+
return entry.name.endsWith('.json') ? [path] : [];
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Copy the installed hand-written template into `source` as shard `slug`: its slug and name become the new shard's in
|
|
84
|
+
* every held JSON file and its mount folder, the cook rows follow the rewritten mounts, and format's pack settles the
|
|
85
|
+
* rest, so `source` is a valid shard file folder from the start.
|
|
86
|
+
*/
|
|
87
|
+
export function writeHandwrittenSource(source: string, slug: string): void {
|
|
88
|
+
const template = handwrittenTemplate();
|
|
89
|
+
if (!existsSync(resolve(template, SHARD_INDEX))) throw new Error(`new: the installed @wildshard/format has no hand-written template at ${template}`);
|
|
90
|
+
const from = handwrittenIdentity(template);
|
|
91
|
+
cpSync(template, source, { recursive: true, errorOnExist: true, force: false });
|
|
92
|
+
const mounts = resolve(source, 'mounts/shardfiles');
|
|
93
|
+
if (existsSync(resolve(mounts, from.slug))) renameSync(resolve(mounts, from.slug), resolve(mounts, slug));
|
|
94
|
+
for (const path of heldJson(source)) {
|
|
95
|
+
const file = resolve(source, path), text = readFileSync(file, 'utf8');
|
|
96
|
+
const renamed = text.replaceAll(`/${from.slug}/`, `/${slug}/`).replaceAll(JSON.stringify(from.slug), JSON.stringify(slug))
|
|
97
|
+
.replaceAll(JSON.stringify(from.name), JSON.stringify(slug));
|
|
98
|
+
if (renamed !== text) writeFileSync(file, renamed);
|
|
99
|
+
}
|
|
100
|
+
// The cook receipt names each mount by hash, and the index names the cook receipt: both follow the rewritten files.
|
|
101
|
+
const cookFile = resolve(source, 'cook.json'), indexFile = resolve(source, SHARD_INDEX);
|
|
102
|
+
if (existsSync(cookFile)) {
|
|
103
|
+
const cook = readJson(cookFile), rows = Array.isArray(cook['mounts']) ? cook['mounts'] as Row[] : [];
|
|
104
|
+
for (const row of rows) { const bytes = new Uint8Array(readFileSync(resolve(source, row.path))); row.hash = sha256(bytes); row.bytes = bytes.length; }
|
|
105
|
+
writeJson(cookFile, cook);
|
|
106
|
+
const index = readJson(indexFile), cooked = new Uint8Array(readFileSync(cookFile));
|
|
107
|
+
if (typeof index['cook'] === 'object' && index['cook'] !== null) writeJson(indexFile, { ...index, cook: { ...index['cook'] as Row, hash: sha256(cooked), bytes: cooked.length } });
|
|
108
|
+
}
|
|
109
|
+
settleHandwritten(source, source);
|
|
110
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- Author tools hash exact immutable wire bytes.
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
|
|
4
|
+
/** Stable JSON encoding shared by author tools without importing the project compiler (SA7a: the SDK owns it, not engine/host). */
|
|
5
|
+
export function encodeCanonicalJson(value: unknown): string {
|
|
6
|
+
const canonical = (input: unknown): unknown => {
|
|
7
|
+
if (Array.isArray(input)) return input.map(canonical);
|
|
8
|
+
if (typeof input === 'object' && input !== null) return Object.fromEntries(Object.entries(input).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, val]) => [key, canonical(val)]));
|
|
9
|
+
return input;
|
|
10
|
+
};
|
|
11
|
+
return `${JSON.stringify(canonical(value))}\n`;
|
|
12
|
+
}
|
|
13
|
+
/** SHA-256 of exact wire bytes, independent of installation path or build time. */
|
|
14
|
+
export function hashImmutableBytes(bytes: Uint8Array): string { return createHash('sha256').update(bytes).digest('hex'); }
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import type { InteractTable, InteractPlacement } from '@wildshard/engine/world/interact/types';
|
|
3
|
+
import { InteractionRowsSchema as schema, parseInteractionRows as parseRows, type InteractionRowsData as Data } from '@wildshard/format/questInteractions';
|
|
4
|
+
|
|
5
|
+
/** Declared interaction rows: transient marks, prompt / crack rows at named spots with ordered needs and their sets (SF72). */
|
|
6
|
+
export const InteractionRowsSchema: v.SchemaWithPipe<readonly [typeof schema]> = v.pipe(schema);
|
|
7
|
+
/** Validated interaction rows, run by the platform in the browser and the renderer-free host alike. */
|
|
8
|
+
export type InteractionRows = Data;
|
|
9
|
+
/** Compile authored interaction rows; an unknown field, a duplicate id or act, or an empty `sets` refuses. */
|
|
10
|
+
export function parseInteractionRows(input: unknown): Data { return parseRows(input); }
|
|
11
|
+
|
|
12
|
+
/** Admit bounded finite placement rows before geometry, registry or prompt effects. */
|
|
13
|
+
export function readInteractionPlacements(input: unknown): readonly InteractPlacement[] {
|
|
14
|
+
if (!Array.isArray(input) || input.length > 4096) throw new Error('Invalid interactable placement rows');
|
|
15
|
+
const ids = new Set<string>();
|
|
16
|
+
return input.map((raw: unknown): InteractPlacement => {
|
|
17
|
+
if (typeof raw !== 'object' || raw === null || !('id' in raw) || !('kind' in raw) || !('x' in raw) || !('y' in raw) || !('z' in raw) || !('yaw' in raw)) throw new Error('Invalid interactable placement');
|
|
18
|
+
const { id, kind, x, y, z, yaw } = raw;
|
|
19
|
+
if (typeof id !== 'string' || id.length === 0 || id.length > 256 || ids.has(id) ||
|
|
20
|
+
typeof kind !== 'string' || kind.length === 0 || kind.length > 64 || typeof x !== 'number' || typeof y !== 'number' || typeof z !== 'number' || typeof yaw !== 'number' ||
|
|
21
|
+
![x, y, z, yaw].every(Number.isFinite) || Math.max(Math.abs(x), Math.abs(y), Math.abs(z)) > 1000000 || Math.abs(yaw) > 1000000) throw new Error('Invalid or duplicate interactable placement');
|
|
22
|
+
ids.add(id); return { id, kind, x, y, z, yaw };
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/** Bind each authored rest placement to the same table row, in original order.
|
|
26
|
+
* Missing, foreign or mismatched rows refuse before a table can build. Moving
|
|
27
|
+
* keys and barrel/body state retain their existing runtime owners afterward.
|
|
28
|
+
*/
|
|
29
|
+
export function bindInteractionPlacements(table: InteractTable, input: unknown): InteractTable {
|
|
30
|
+
const placements = new Map(readInteractionPlacements(input).map(row => [row.id, row]));
|
|
31
|
+
if (placements.size !== table.rows.length || new Set(table.rows.map(row => row.id)).size !== table.rows.length) throw new Error('Incomplete interactable placements');
|
|
32
|
+
const rows = table.rows.map(row => {
|
|
33
|
+
const at = placements.get(row.id);
|
|
34
|
+
if (at === undefined || at.kind !== row.kind) throw new Error(`Unknown interactable placement ${row.id}`);
|
|
35
|
+
return { ...row, at: { poi: 'world' as const, x: at.x, y: at.y, z: at.z, yaw: at.yaw } };
|
|
36
|
+
});
|
|
37
|
+
return { ...table, rows };
|
|
38
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BAKED_BYTES as platformBakedBytes, appendGeometry as platformAppendGeometry, bakedGeometryBytes as platformBakedGeometryBytes, pad4 as platformPad4, readBakedGeometry as platformReadBakedGeometry, type BakedGeometryRow as PlatformBakedGeometryRow, type BakedType as PlatformBakedType } from '@wildshard/engine/game/plugin/bakedGeometry';
|
|
2
|
+
|
|
3
|
+
/** An attribute's element type in a geometry bake ('f16' is a half float held in a Uint16Array). */
|
|
4
|
+
export type BakedType = PlatformBakedType;
|
|
5
|
+
/** One baked geometry: its attributes, vertex count, index kind and count, and whether it has a box (SHARD-PLATFORM M3, the kit system). */
|
|
6
|
+
export type BakedGeometryRow = PlatformBakedGeometryRow;
|
|
7
|
+
/** Bytes per element of each baked type. */
|
|
8
|
+
export const BAKED_BYTES: typeof platformBakedBytes = platformBakedBytes;
|
|
9
|
+
/** A block's length padded to 4 bytes. */
|
|
10
|
+
export const pad4: typeof platformPad4 = platformPad4;
|
|
11
|
+
/** The bytes a row's blocks take in a bake. */
|
|
12
|
+
export const bakedGeometryBytes: typeof platformBakedGeometryBytes = platformBakedGeometryBytes;
|
|
13
|
+
/** Reads one baked geometry from the bytes at an offset. */
|
|
14
|
+
export const readBakedGeometry: typeof platformReadBakedGeometry = platformReadBakedGeometry;
|
|
15
|
+
/** A baked builder's geometry with what was added to it after. */
|
|
16
|
+
export const appendGeometry: typeof platformAppendGeometry = platformAppendGeometry;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { BufferAttribute, BufferGeometry, InterleavedBufferAttribute } from 'three';
|
|
2
|
+
import * as platform from '@wildshard/format/geometryPack';
|
|
3
|
+
|
|
4
|
+
export type PackedGroup = platform.PackedGroup;
|
|
5
|
+
export type PackedGeometryRow = platform.PackedGeometryRow;
|
|
6
|
+
export type PackedGeometryRows = platform.PackedGeometryRows;
|
|
7
|
+
export type PackedGeometryJson = platform.PackedGeometryJson;
|
|
8
|
+
/** Authoring geometry projection; isolated bakers never import runtime services. */
|
|
9
|
+
export class GeometryPack extends platform.GeometryPackData {
|
|
10
|
+
/** Bind fresh decoded arrays to native geometry without sharing mutable storage. */
|
|
11
|
+
geometry(i: number): BufferGeometry {
|
|
12
|
+
const data = this.read(i), geometry = new BufferGeometry();
|
|
13
|
+
for (const attribute of data.attributes) geometry.setAttribute(attribute.name, new BufferAttribute(attribute.array, attribute.size));
|
|
14
|
+
if (data.index !== null) geometry.setIndex(new BufferAttribute(data.index, 1));
|
|
15
|
+
for (const group of data.groups) geometry.addGroup(group.start, group.count, group.materialIndex);
|
|
16
|
+
return geometry;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export const packedRows: typeof platform.packedRows = platform.packedRows;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The writer of a pack (build-time): geometries added in order, each attribute's floats then an index, every block padded
|
|
23
|
+
* to 4 bytes. A geometry built without an index stores its distinct vertices once (bit-equal floats in every attribute)
|
|
24
|
+
* and the index that expands them back, in order; one built with an index keeps its own (16 or 32 bit, as built).
|
|
25
|
+
* `GeometryPack` reads the bytes back to the builder's exact arrays.
|
|
26
|
+
*/
|
|
27
|
+
export class GeometryPackWriter {
|
|
28
|
+
private readonly packed: PackedGeometryRow[] = [];
|
|
29
|
+
private readonly chunks: Uint8Array[] = [];
|
|
30
|
+
private size = 0;
|
|
31
|
+
private readonly label: string;
|
|
32
|
+
|
|
33
|
+
/** `label` the error messages' name. */
|
|
34
|
+
constructor(label: string) { this.label = label; }
|
|
35
|
+
|
|
36
|
+
/** Append geometry `g` (plain float32 attributes only); returns its index in the pack. */
|
|
37
|
+
add(g: BufferGeometry): number {
|
|
38
|
+
const names = Object.keys(g.attributes), attrs = names.map((name): [string, number] => [name, g.getAttribute(name).itemSize]);
|
|
39
|
+
const count = g.getAttribute(names[0] ?? 'position').count, own = g.getIndex();
|
|
40
|
+
const groups = g.groups.length === 0 ? {} : { groups: g.groups.map((group) => ({ start: group.start, count: group.count, materialIndex: group.materialIndex ?? 0 })) };
|
|
41
|
+
const floats = (name: string): Float32Array => {
|
|
42
|
+
const a = g.getAttribute(name);
|
|
43
|
+
if (a instanceof InterleavedBufferAttribute || !(a.array instanceof Float32Array) || a.normalized) throw new Error(`[${this.label}] ${name}: plain float32 only`);
|
|
44
|
+
return a.array.subarray(0, a.count * a.itemSize);
|
|
45
|
+
};
|
|
46
|
+
if (own !== null) {
|
|
47
|
+
for (const name of names) this.push(new Uint8Array(floats(name).slice().buffer));
|
|
48
|
+
const u32 = own.array instanceof Uint32Array;
|
|
49
|
+
this.push(new Uint8Array((u32 ? Uint32Array.from(own.array) : Uint16Array.from(own.array)).buffer));
|
|
50
|
+
this.packed.push({ attrs, count, unique: count, own: u32 ? 'u32' : 'u16', indexCount: own.count, ...groups });
|
|
51
|
+
return this.packed.length - 1;
|
|
52
|
+
}
|
|
53
|
+
const arrays = names.map(floats), keys = new Map<string, number>(), index = new Uint32Array(count), firsts: number[] = [];
|
|
54
|
+
const bits = new Uint32Array(1), view = new Float32Array(bits.buffer);
|
|
55
|
+
for (let i = 0; i < count; i++) {
|
|
56
|
+
let key = '';
|
|
57
|
+
arrays.forEach((a, k) => { const w = attrs[k]?.[1] ?? 0; for (let c = 0; c < w; c++) { view[0] = a[i * w + c] ?? 0; key += `${String(bits[0])},`; } });
|
|
58
|
+
let at = keys.get(key);
|
|
59
|
+
if (at === undefined) { at = firsts.length; keys.set(key, at); firsts.push(i); }
|
|
60
|
+
index[i] = at;
|
|
61
|
+
}
|
|
62
|
+
arrays.forEach((a, k) => {
|
|
63
|
+
const w = attrs[k]?.[1] ?? 0, out = new Float32Array(firsts.length * w);
|
|
64
|
+
firsts.forEach((i, j) => { for (let c = 0; c < w; c++) out[j * w + c] = a[i * w + c] ?? 0; });
|
|
65
|
+
this.push(new Uint8Array(out.buffer));
|
|
66
|
+
});
|
|
67
|
+
this.push(new Uint8Array((firsts.length < 65536 ? Uint16Array.from(index) : index).buffer));
|
|
68
|
+
this.packed.push({ attrs, count, unique: firsts.length, own: null, indexCount: count, ...groups });
|
|
69
|
+
return this.packed.length - 1;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Append a block of floats (instance matrices, say: anything a page reads back bit for bit, which JSON cannot carry: it
|
|
74
|
+
* drops a `-0`'s sign), `size` floats to an item; returns its index (`GeometryPack.floats`).
|
|
75
|
+
*/
|
|
76
|
+
addFloats(values: Float32Array, size: number): number {
|
|
77
|
+
const g = new BufferGeometry(); g.setAttribute('values', new BufferAttribute(values, size));
|
|
78
|
+
return this.add(g);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** The pack's rows so far (its byte size and every geometry's row). */
|
|
82
|
+
rows(): PackedGeometryRows { return { bytes: this.size, geometries: this.packed.map((row) => ({ ...row, attrs: row.attrs.map(([name, w]) => [name, w] as const) })) }; }
|
|
83
|
+
|
|
84
|
+
/** The pack's bytes so far (uncompressed). */
|
|
85
|
+
bytes(): Uint8Array {
|
|
86
|
+
const out = new Uint8Array(this.size);
|
|
87
|
+
let at = 0;
|
|
88
|
+
for (const c of this.chunks) { out.set(c, at); at += c.length; }
|
|
89
|
+
return out;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private push(bytes: Uint8Array): void {
|
|
93
|
+
const padded = new Uint8Array(Math.ceil(bytes.length / 4) * 4); padded.set(bytes);
|
|
94
|
+
this.chunks.push(padded); this.size += padded.length;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Fetch a zlib-deflated bake and inflate it (a failed fetch throws). */
|
|
99
|
+
export async function fetchDeflated(url: string): Promise<Uint8Array> {
|
|
100
|
+
// The authoring codec is also imported by isolated Node bakers. Only a runtime
|
|
101
|
+
// fetch needs the engine's presentation-aware decoder.
|
|
102
|
+
const { fetchDeflatedBytes } = await import('@wildshard/engine/core/deflate');
|
|
103
|
+
return fetchDeflatedBytes(url);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Fetch a zlib bake whose four-byte words are stored in byte lanes, restoring them within the live frame budget. */
|
|
107
|
+
export async function fetchLaneBake(url: string): Promise<Uint8Array> {
|
|
108
|
+
const { fetchLaneBytes } = await import('@wildshard/engine/core/deflate');
|
|
109
|
+
return fetchLaneBytes(url);
|
|
110
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import { LedgerFactSchema as factSchema, LedgerRulesSchema as rulesSchema, parseLedgerRules as parseRules, type LedgerFact as Fact, type LedgerRule as Rule } from '@wildshard/format/ledger';
|
|
3
|
+
|
|
4
|
+
/** Compile a host-witnessed fact with placement identity and provenance. */
|
|
5
|
+
export const LedgerFactSchema: v.SchemaWithPipe<readonly [typeof factSchema]> = v.pipe(factSchema);
|
|
6
|
+
/** Compile profile reward mappings; coins and unreviewed local items stay outside the travelling profile. */
|
|
7
|
+
export const LedgerRulesSchema: v.SchemaWithPipe<readonly [typeof rulesSchema]> = v.pipe(rulesSchema);
|
|
8
|
+
/** The compiled fact contract consumed by the platform ledger. */
|
|
9
|
+
export type LedgerFact = Fact;
|
|
10
|
+
/** One declared fact-to-platform reward mapping. */
|
|
11
|
+
export type LedgerRule = Rule;
|
|
12
|
+
/** Validate ledger declarations in an author project before writing its shardfile. */
|
|
13
|
+
export function parseLedgerRules(input: unknown): Rule[] { return parseRules(input); }
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { BufferAttribute, InstancedBufferAttribute, InstancedBufferGeometry } from 'three';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A camera-tiled card field as a declared row (SHARD-PLATFORM M3, look-family rows; G395 paired it): a near meadow, a carpet
|
|
5
|
+
* of moss or flowers, any ground cover drawn as many small cards round the camera with nothing uploaded per frame. One
|
|
6
|
+
* square tile of `cards` cards is drawn as a grid of instances (`across` × `across` tiles, the camera's in the middle),
|
|
7
|
+
* then the inner 3 × 3 again `layers` more times (instance attribute `aTile` = tile x, tile z, layer), so the near field is
|
|
8
|
+
* denser with no more cards in the buffer. The vertex program places each card: its `aRoot` is (x, z, r) in [0, 1) — where
|
|
9
|
+
* in the tile and a per-card random — and `aShape` the card's outline vertex (across, up and, when the outline gives one,
|
|
10
|
+
* a part index); the camera snaps the grid to its tile lattice. Nothing here knows a shard: the
|
|
11
|
+
* outline, the lattice and the seed are data, the program is the shard's.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A card's outline: its vertices (`[across, up]`, or `[across, up, part]` for a card of several parts, such as crossed
|
|
16
|
+
* quads the program turns apart) and its triangles (indices into them, three per triangle).
|
|
17
|
+
*/
|
|
18
|
+
export interface TileCardRow {
|
|
19
|
+
readonly shape: readonly (readonly [number, number] | readonly [number, number, number])[];
|
|
20
|
+
readonly triangles: readonly number[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The field's lattice: tiles across (odd), extra layers of the inner 3 × 3, the cards' seed and their outline. With `grid`,
|
|
25
|
+
* the cards stand at the centres of a `grid` × `grid` lattice of cells in the tile (card `b` in cell `b mod grid`,
|
|
26
|
+
* `⌊b / grid⌋`; the program jitters them) instead of at seeded places; their `r` stays seeded.
|
|
27
|
+
*/
|
|
28
|
+
export interface TileFieldRow {
|
|
29
|
+
readonly across: number;
|
|
30
|
+
readonly layers: number;
|
|
31
|
+
readonly seed: number;
|
|
32
|
+
readonly card: TileCardRow;
|
|
33
|
+
readonly grid?: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The field's geometry: `cards` cards per tile (a tier knob), seeded so every load grows the same field; positions are
|
|
37
|
+
* zero (the program places every vertex from `aRoot`, `aShape` and `aTile`). */
|
|
38
|
+
export function tileFieldGeometry(row: TileFieldRow, cards: number): InstancedBufferGeometry {
|
|
39
|
+
const per = row.card.shape.length, tris = row.card.triangles, verts = cards * per;
|
|
40
|
+
const parts = row.card.shape.some((s) => s.length > 2) ? 3 : 2;
|
|
41
|
+
const root = new Float32Array(verts * 3), shape = new Float32Array(verts * parts), index = new Uint32Array(cards * tris.length);
|
|
42
|
+
let a = row.seed >>> 0;
|
|
43
|
+
const rnd = (): number => { a = (a + 0x6d2b79f5) >>> 0; let t = a; t = Math.imul(t ^ (t >>> 15), t | 1); t ^= t + Math.imul(t ^ (t >>> 7), t | 61); return ((t ^ (t >>> 14)) >>> 0) / 4294967296; };
|
|
44
|
+
const grid = row.grid;
|
|
45
|
+
for (let b = 0; b < cards; b++) {
|
|
46
|
+
const x = grid === undefined ? rnd() : ((b % grid) + 0.5) / grid, z = grid === undefined ? rnd() : (Math.floor(b / grid) + 0.5) / grid, r = rnd();
|
|
47
|
+
for (let v = 0; v < per; v++) {
|
|
48
|
+
const i = b * per + v, s = row.card.shape[v] ?? [0, 0];
|
|
49
|
+
root[i * 3] = x; root[i * 3 + 1] = z; root[i * 3 + 2] = r;
|
|
50
|
+
for (let k = 0; k < parts; k++) shape[i * parts + k] = s[k] ?? 0;
|
|
51
|
+
}
|
|
52
|
+
const o = b * per;
|
|
53
|
+
index.set(tris.map((k) => o + k), b * tris.length);
|
|
54
|
+
}
|
|
55
|
+
const g = new InstancedBufferGeometry();
|
|
56
|
+
g.setAttribute('position', new BufferAttribute(new Float32Array(verts * 3), 3));
|
|
57
|
+
g.setAttribute('aRoot', new BufferAttribute(root, 3)); g.setAttribute('aShape', new BufferAttribute(shape, parts));
|
|
58
|
+
g.setIndex(new BufferAttribute(index, 1));
|
|
59
|
+
// the tiles: every tile once (layer 0), then the inner 3 × 3 again per extra layer
|
|
60
|
+
const n = row.across, half = (n - 1) / 2, count = n * n + 9 * row.layers, tiles = new Float32Array(count * 3);
|
|
61
|
+
for (let i = 0; i < n * n; i++) { tiles[i * 3] = (i % n) - half; tiles[i * 3 + 1] = Math.floor(i / n) - half; }
|
|
62
|
+
for (let l = 1; l <= row.layers; l++) for (let k = 0; k < 9; k++) {
|
|
63
|
+
const i = n * n + (l - 1) * 9 + k; tiles[i * 3] = (k % 3) - 1; tiles[i * 3 + 1] = Math.floor(k / 3) - 1; tiles[i * 3 + 2] = l;
|
|
64
|
+
}
|
|
65
|
+
g.setAttribute('aTile', new InstancedBufferAttribute(tiles, 3)); g.instanceCount = count;
|
|
66
|
+
return g;
|
|
67
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { assetCost } from '@wildshard/format/product';
|
|
2
|
+
import { encodeCanonicalJson } from './immutable';
|
|
3
|
+
import { hashAssetBytes } from './assetHandle';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* D74: every inline material graph of an authored declaration becomes a content-addressed JSON file of its library
|
|
7
|
+
* closure, and its catalogue entry `{ family: 'graph', file: <hash> }`. Graphs were most of a declaration's JSON nodes
|
|
8
|
+
* (Nalati's 28 held 38,093 of the 100,000), and a file is charged by its bytes, not its nodes. One path for every shard:
|
|
9
|
+
* the file's row names the graph's texture params as its dependencies (so they stay in the closure, as the inline graph's
|
|
10
|
+
* did), identical graphs share one file, and the files' bytes join the build's owned assets. A declaration without a
|
|
11
|
+
* look catalogue is returned as it is.
|
|
12
|
+
*/
|
|
13
|
+
export function lowerMaterialGraphs(declaration: unknown): { readonly declaration: unknown; readonly assets: ReadonlyMap<string, Uint8Array> } {
|
|
14
|
+
const assets = new Map<string, Uint8Array>();
|
|
15
|
+
const look = isRecord(declaration) ? declaration['look'] : undefined, catalogue = isRecord(look) ? look['materials'] : undefined;
|
|
16
|
+
if (!isRecord(declaration) || !isRecord(look) || !isRecord(catalogue)) return { declaration, assets };
|
|
17
|
+
const materials: Record<string, unknown> = { ...catalogue };
|
|
18
|
+
const files: unknown[] = Array.isArray(declaration['files']) ? declaration['files'].slice() : [];
|
|
19
|
+
const library: unknown[] = Array.isArray(declaration['library']) ? declaration['library'].slice() : [];
|
|
20
|
+
const known = new Set(files.flatMap(row => isRecord(row) && typeof row['hash'] === 'string' ? [row['hash']] : []));
|
|
21
|
+
let lowered = false, compressed = 0, resident = 0;
|
|
22
|
+
for (const [id, entry] of Object.entries(materials)) {
|
|
23
|
+
if (!isRecord(entry) || entry['family'] !== 'graph' || !('graph' in entry)) continue;
|
|
24
|
+
const graph = entry['graph'], bytes = new TextEncoder().encode(encodeCanonicalJson(graph)), hash = hashAssetBytes(bytes);
|
|
25
|
+
materials[id] = { family: 'graph', file: hash }; lowered = true;
|
|
26
|
+
if (known.has(hash)) continue;
|
|
27
|
+
known.add(hash); assets.set(hash, bytes);
|
|
28
|
+
const cost = assetCost('json', bytes);
|
|
29
|
+
files.push({ hash, kind: 'json', compressed: bytes.length, decoded: cost.decoded, gpu: cost.gpu, triangles: cost.triangles, draws: cost.draws,
|
|
30
|
+
dependencies: textureParams(graph), critical: false });
|
|
31
|
+
if (!library.includes(hash)) { library.push(hash); compressed += bytes.length; resident += cost.decoded + cost.gpu; }
|
|
32
|
+
}
|
|
33
|
+
if (!lowered) return { declaration, assets };
|
|
34
|
+
return { declaration: { ...declaration, look: { ...look, materials }, files, library, budgets: withLibrary(declaration['budgets'], compressed, resident) }, assets };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** the library budget charged with the files the lowering adds (their textures were already in the closure), as a named
|
|
38
|
+
* blob's merge charges it */
|
|
39
|
+
function withLibrary(budgets: unknown, compressed: number, resident: number): unknown {
|
|
40
|
+
if (!isRecord(budgets) || !isRecord(budgets['library'])) return budgets;
|
|
41
|
+
const library = budgets['library'], add = (value: unknown, by: number): unknown => typeof value === 'number' ? value + by : value;
|
|
42
|
+
return { ...budgets, library: { ...library, compressed: add(library['compressed'], compressed), resident: add(library['resident'], resident),
|
|
43
|
+
...(library['downloadAllowance'] === undefined ? {} : { downloadAllowance: add(library['downloadAllowance'], compressed) }) } };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** a graph's texture params' files (a lent texture names none: its runtime lends it), once each, in param order */
|
|
47
|
+
function textureParams(graph: unknown): string[] {
|
|
48
|
+
const params = isRecord(graph) && isRecord(graph['params']) ? Object.values(graph['params']) : [], refs: string[] = [];
|
|
49
|
+
for (const param of params) {
|
|
50
|
+
if (!isRecord(param) || param['type'] !== 'texture' || param['role'] === 'lent') continue;
|
|
51
|
+
const value = param['value'];
|
|
52
|
+
if (typeof value === 'string' && !refs.includes(value)) refs.push(value);
|
|
53
|
+
}
|
|
54
|
+
return refs;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function isRecord(value: unknown): value is Record<string, unknown> { return typeof value === 'object' && value !== null && !Array.isArray(value); }
|