roamwright 0.20.1 → 0.55.1
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/.prettierrc.yaml +12 -0
- package/CONTRIBUTING.md +19 -14
- package/README.md +35 -16
- package/examples/animals.html +49 -0
- package/examples/animals.js +209 -0
- package/examples/crowds.html +50 -0
- package/examples/crowds.js +268 -0
- package/examples/effects.html +53 -0
- package/examples/effects.js +343 -0
- package/examples/figure-motion.html +55 -0
- package/examples/figure-motion.js +265 -0
- package/examples/figure.html +49 -0
- package/examples/figure.js +238 -0
- package/examples/fliers.html +53 -0
- package/examples/fliers.js +292 -0
- package/examples/fortification.html +54 -0
- package/examples/fortification.js +288 -0
- package/examples/house-kit.html +48 -0
- package/examples/house-kit.js +175 -0
- package/examples/index.html +26 -16
- package/examples/island.html +48 -0
- package/examples/island.js +134 -52
- package/examples/land.html +54 -0
- package/examples/land.js +392 -0
- package/examples/props-and-plants.html +53 -0
- package/examples/props-and-plants.js +275 -0
- package/examples/rooms.html +48 -0
- package/examples/rooms.js +242 -0
- package/examples/ships.html +51 -0
- package/examples/ships.js +235 -0
- package/examples/showcase.css +320 -0
- package/examples/small-world-land.js +151 -0
- package/examples/small-world-life.js +160 -0
- package/examples/small-world-town.js +127 -0
- package/examples/small-world.html +57 -0
- package/examples/small-world.js +226 -0
- package/examples/soundscape.html +138 -0
- package/examples/soundscape.js +467 -0
- package/examples/stage-kits.js +300 -0
- package/examples/stage.js +374 -0
- package/examples/towns.html +50 -0
- package/examples/towns.js +325 -0
- package/examples/viaduct-camera.js +8 -4
- package/examples/viaduct-landscape.js +28 -17
- package/examples/viaduct.html +45 -43
- package/examples/viaduct.js +68 -92
- package/geometry/animal-camel-body.js +410 -0
- package/geometry/animal-camel-head.js +118 -0
- package/geometry/animal-canine-body.js +361 -0
- package/geometry/animal-canine-breeds.js +316 -0
- package/geometry/animal-canine-head.js +337 -0
- package/geometry/animal-cattle-body.js +391 -0
- package/geometry/animal-cattle-coat.js +42 -0
- package/geometry/animal-cattle-head.js +152 -0
- package/geometry/animal-hen.js +248 -0
- package/geometry/animal-horse-body.js +446 -0
- package/geometry/animal-horse-bridle.js +171 -0
- package/geometry/animal-horse-coat.js +68 -0
- package/geometry/animal-horse-face.js +162 -0
- package/geometry/animal-horse-hair.js +304 -0
- package/geometry/animal-horse-head.js +133 -0
- package/geometry/animal-horse-tack.js +157 -0
- package/geometry/animal-options.js +59 -0
- package/geometry/animal-shapes.js +21 -0
- package/geometry/animal-skin.js +390 -0
- package/geometry/builder-cells.js +10 -2
- package/geometry/builder-frame.js +2 -1
- package/geometry/builder.js +15 -4
- package/geometry/card-emblem.js +437 -0
- package/geometry/catenary-canvas.js +396 -0
- package/geometry/cloth-folds.js +143 -0
- package/geometry/crawl-shapes.js +71 -0
- package/geometry/creased-sheet.js +7 -2
- package/geometry/crowd-dress.js +315 -0
- package/geometry/crowd-far.js +174 -0
- package/geometry/crowd-look.js +42 -0
- package/geometry/crowd-weld.js +218 -0
- package/geometry/ear.js +9 -4
- package/geometry/erosion.js +7 -4
- package/geometry/face-grid.js +26 -6
- package/geometry/field-map.js +59 -0
- package/geometry/figure-arms.js +339 -0
- package/geometry/figure-beard.js +250 -0
- package/geometry/figure-body.js +297 -0
- package/geometry/figure-bow.js +105 -0
- package/geometry/figure-cloak.js +189 -0
- package/geometry/figure-clothes.js +337 -0
- package/geometry/figure-face-grids.js +75 -0
- package/geometry/figure-gear.js +446 -0
- package/geometry/figure-hair-far.js +151 -0
- package/geometry/figure-hair-hangs.js +108 -0
- package/geometry/figure-hair-patch.js +66 -0
- package/geometry/figure-hair.js +320 -0
- package/geometry/figure-hands.js +321 -0
- package/geometry/figure-head-features.js +280 -0
- package/geometry/figure-head.js +375 -0
- package/geometry/figure-headwear.js +223 -0
- package/geometry/figure-legs.js +231 -0
- package/geometry/figure-limbs.js +39 -0
- package/geometry/figure-sculpt.js +82 -0
- package/geometry/figure-skin.js +97 -0
- package/geometry/figure-skirts.js +303 -0
- package/geometry/figure-trunk.js +411 -0
- package/geometry/flier-corvid-body.js +322 -0
- package/geometry/flier-corvid-wings.js +154 -0
- package/geometry/flier-long-body.js +195 -0
- package/geometry/flier-shapes.js +219 -0
- package/geometry/flier-soaring-bird.js +84 -0
- package/geometry/foliage.js +177 -4
- package/geometry/fort-city-walls.js +479 -0
- package/geometry/fort-gate-approach.js +233 -0
- package/geometry/fort-great-walls.js +280 -0
- package/geometry/fort-keep.js +297 -0
- package/geometry/fort-parts.js +261 -0
- package/geometry/fort-polyline.js +261 -0
- package/geometry/fort-portal.js +96 -0
- package/geometry/fort-ring-wall.js +267 -0
- package/geometry/fort-seawall.js +104 -0
- package/geometry/fort-terrace-gates.js +323 -0
- package/geometry/fort-terrace-plan.js +250 -0
- package/geometry/fort-terrace-wall.js +345 -0
- package/geometry/garment-tags.js +11 -3
- package/geometry/grid-gather.js +69 -0
- package/geometry/grid-sample.js +185 -0
- package/geometry/hair-gathers.js +19 -4
- package/geometry/hair-locks.js +1 -1
- package/geometry/hair-patch.js +6 -2
- package/geometry/hair-shell.js +14 -2
- package/geometry/head-presets.js +103 -0
- package/geometry/head-profile.js +13 -2
- package/geometry/head-shape.js +51 -23
- package/geometry/heightfield.js +26 -9
- package/geometry/horizon-angles.js +166 -0
- package/geometry/house-kit-body.js +195 -0
- package/geometry/house-kit-courtyard-parts.js +340 -0
- package/geometry/house-kit-courtyard-roof.js +223 -0
- package/geometry/house-kit-courtyard.js +409 -0
- package/geometry/house-kit-cut.js +29 -0
- package/geometry/house-kit-extras.js +192 -0
- package/geometry/house-kit-forms.js +298 -0
- package/geometry/house-kit-frame.js +74 -0
- package/geometry/house-kit-marks.js +93 -0
- package/geometry/house-kit-openings.js +193 -0
- package/geometry/house-kit-palette.js +54 -0
- package/geometry/house-kit-pool.js +71 -0
- package/geometry/house-kit-roofs.js +151 -0
- package/geometry/house-kit.js +202 -0
- package/geometry/instances.js +4 -4
- package/geometry/lamp-wash.js +65 -0
- package/geometry/land-clearings.js +83 -0
- package/geometry/land-ditches.js +290 -0
- package/geometry/land-dry-basin.js +327 -0
- package/geometry/land-dunes.js +150 -0
- package/geometry/land-earthworks.js +432 -0
- package/geometry/land-edge.js +292 -0
- package/geometry/land-mound-faces.js +349 -0
- package/geometry/land-near-relief.js +102 -0
- package/geometry/land-sheet.js +220 -0
- package/geometry/land-town-ground.js +256 -0
- package/geometry/land-waters.js +228 -0
- package/geometry/land-wildness.js +123 -0
- package/geometry/lathed-vessel.js +293 -0
- package/geometry/outline-grid.js +5 -4
- package/geometry/outline-segments.js +74 -0
- package/geometry/part-ranges.js +35 -0
- package/geometry/path-field.js +35 -1
- package/geometry/planked-floor.js +149 -0
- package/geometry/plant-broadleaf.js +268 -0
- package/geometry/plant-shrub.js +198 -0
- package/geometry/plant-tints.js +80 -0
- package/geometry/plant-trees.js +453 -0
- package/geometry/plant-tussock.js +107 -0
- package/geometry/primitives.js +65 -23
- package/geometry/prop-battlefield.js +69 -0
- package/geometry/prop-camp.js +175 -0
- package/geometry/prop-door.js +26 -0
- package/geometry/prop-harbour.js +105 -0
- package/geometry/prop-haycock.js +60 -0
- package/geometry/prop-sacks.js +74 -0
- package/geometry/prop-sheaf.js +68 -0
- package/geometry/prop-street.js +69 -0
- package/geometry/prop-tents.js +396 -0
- package/geometry/prop-tombs.js +80 -0
- package/geometry/prop-trade.js +393 -0
- package/geometry/prop-vehicles.js +218 -0
- package/geometry/props.js +58 -0
- package/geometry/room-arcade.js +134 -0
- package/geometry/room-dome.js +188 -0
- package/geometry/room-flames.js +138 -0
- package/geometry/room-frame.js +106 -0
- package/geometry/room-furniture.js +260 -0
- package/geometry/room-hearth.js +98 -0
- package/geometry/room-kit.js +59 -0
- package/geometry/room-openings.js +142 -0
- package/geometry/room-stairs.js +180 -0
- package/geometry/room-surfaces.js +272 -0
- package/geometry/sampled-surface.js +24 -10
- package/geometry/scatter-grid.js +6 -3
- package/geometry/sculpt.js +5 -1
- package/geometry/ship-fittings.js +350 -0
- package/geometry/ship-hull.js +460 -0
- package/geometry/ship-kit.js +208 -0
- package/geometry/ship-lines.js +69 -0
- package/geometry/ship-oars.js +150 -0
- package/geometry/ship-presets.js +131 -0
- package/geometry/ship-rig.js +374 -0
- package/geometry/ship-sails.js +148 -0
- package/geometry/shore-grid.js +5 -1
- package/geometry/strata-field.js +44 -11
- package/geometry/strata-tiles.js +20 -6
- package/geometry/stream.js +32 -17
- package/geometry/swept-tube.js +124 -0
- package/geometry/terrain-chunks.js +139 -51
- package/geometry/terrain-extension.js +24 -8
- package/geometry/town-courtyard-inn.js +272 -0
- package/geometry/town-ground.js +76 -0
- package/geometry/town-houses.js +343 -0
- package/geometry/town-lights.js +254 -0
- package/geometry/town-lots.js +172 -0
- package/geometry/town-plan.js +370 -0
- package/geometry/town-works.js +465 -0
- package/geometry/village-layout.js +181 -0
- package/geometry/village-yards.js +167 -0
- package/geometry/wall-runs.js +64 -0
- package/index.js +139 -3
- package/math/cloud-textures.js +3 -7
- package/math/curve.js +5 -1
- package/math/lamp-texels.js +43 -0
- package/math/lit-share.js +22 -0
- package/math/mountain-ranges.js +177 -54
- package/math/periodic.js +6 -0
- package/math/rectangles.js +8 -2
- package/math/rock-texture.js +17 -12
- package/math/surface-textures.js +24 -9
- package/math/wandering-path.js +40 -0
- package/math/ways.js +120 -0
- package/motion/action-dynamics.js +398 -0
- package/motion/animal-bearing.js +247 -0
- package/motion/animal-canine-bearing.js +178 -0
- package/motion/animal-canine-cast.js +131 -0
- package/motion/animal-cattle-cast.js +64 -0
- package/motion/animal-herd-cast.js +154 -0
- package/motion/animal-horse-still.js +161 -0
- package/motion/animal-troop-cast.js +43 -0
- package/motion/arm-reach.js +3 -2
- package/motion/ballistic-arc.js +182 -2
- package/motion/biped-cycle.js +4 -2
- package/motion/biped-leg.js +4 -1
- package/motion/biped-posture.js +459 -0
- package/motion/biped-stride.js +142 -32
- package/motion/boat-sailing.js +214 -0
- package/motion/cast-actors.js +379 -0
- package/motion/cast-manager.js +321 -0
- package/motion/contact-transition.js +5 -6
- package/motion/crowd-alarms.js +36 -6
- package/motion/crowd-attention.js +108 -0
- package/motion/crowd-beasts.js +203 -0
- package/motion/crowd-camp.js +295 -0
- package/motion/crowd-figure.js +100 -0
- package/motion/crowd-herd.js +86 -0
- package/motion/crowd-hold.js +130 -0
- package/motion/crowd-pose.js +296 -0
- package/motion/crowd-poses.js +481 -0
- package/motion/crowd-routine.js +44 -14
- package/motion/crowd-town.js +166 -0
- package/motion/crowd-water.js +143 -0
- package/motion/deck-surface.js +4 -2
- package/motion/figure-acts.js +411 -0
- package/motion/figure-arms.js +437 -0
- package/motion/figure-blade-slide.js +149 -0
- package/motion/figure-body-place.js +180 -0
- package/motion/figure-bones.js +118 -0
- package/motion/figure-bow-draw.js +70 -0
- package/motion/figure-fingers.js +215 -0
- package/motion/figure-gaze.js +205 -0
- package/motion/figure-gestures.js +452 -0
- package/motion/figure-grip.js +134 -0
- package/motion/figure-head.js +287 -0
- package/motion/figure-legs.js +264 -0
- package/motion/figure-links.js +293 -0
- package/motion/figure-locomotion.js +391 -0
- package/motion/figure-mount-up.js +180 -0
- package/motion/figure-mount.js +201 -0
- package/motion/figure-pose-frame.js +375 -0
- package/motion/figure-pose-table.js +156 -0
- package/motion/figure-pose.js +343 -0
- package/motion/figure-seat.js +267 -0
- package/motion/figure-sway.js +125 -0
- package/motion/flier-corvid-pose.js +74 -0
- package/motion/flier-flight-air.js +122 -0
- package/motion/flier-flight-echelon.js +164 -0
- package/motion/flier-flight-roost.js +131 -0
- package/motion/flier-swarm-flight.js +252 -0
- package/motion/formation.js +193 -0
- package/motion/instance-sight.js +8 -1
- package/motion/melee-contact.js +143 -0
- package/motion/moorings.js +48 -0
- package/motion/path-steering.js +358 -0
- package/motion/player.js +7 -6
- package/motion/quadruped.js +109 -33
- package/motion/spaces.js +58 -6
- package/motion/speech-cadence.js +304 -0
- package/motion/vessel-motion.js +57 -0
- package/motion/walk-grid.js +235 -0
- package/motion/weather.js +70 -12
- package/motion/wind.js +27 -1
- package/package.json +46 -4
- package/rendering/alpha-mips.js +340 -0
- package/rendering/animal-camel-figure.js +29 -0
- package/rendering/animal-canine-figure.js +59 -0
- package/rendering/animal-cattle-figure.js +36 -0
- package/rendering/animal-horse-figure.js +49 -0
- package/rendering/atmosphere.js +86 -0
- package/rendering/camera-track.js +156 -0
- package/rendering/{road-surface.js → cart-track.js} +40 -11
- package/rendering/cast-stage.js +299 -0
- package/rendering/caster-motion.js +2 -1
- package/rendering/cell-lod-options.js +46 -0
- package/rendering/cell-lod.js +665 -80
- package/rendering/cloth-material.js +140 -0
- package/rendering/cloud-dome.js +2 -2
- package/rendering/compilation-schedule.js +18 -10
- package/rendering/contact-shadows.js +5 -2
- package/rendering/context.js +47 -8
- package/rendering/crowd-batches.js +420 -0
- package/rendering/crowd-herd.js +198 -0
- package/rendering/crowd-rig.js +132 -0
- package/rendering/crowd-skinning.js +52 -9
- package/rendering/crowd-update.js +419 -0
- package/rendering/crowd-visibility.js +107 -0
- package/rendering/day-cycle-defaults.js +200 -0
- package/rendering/day-cycle.js +487 -0
- package/rendering/daylight.js +1 -3
- package/rendering/detail-range.js +6 -5
- package/rendering/dof.js +11 -4
- package/rendering/effects-frame.js +149 -0
- package/rendering/effects-water-rises.js +221 -0
- package/rendering/energy-stream.js +128 -0
- package/rendering/facade-glass-material.js +105 -0
- package/rendering/far-shadow.js +81 -54
- package/rendering/field-surface.js +138 -0
- package/rendering/figure-shield.js +105 -0
- package/rendering/figure-skeleton.js +329 -0
- package/rendering/fire-light-watch.js +197 -0
- package/rendering/fire-pools.js +148 -0
- package/rendering/flame-sources.js +86 -0
- package/rendering/flier-bird-looks.js +97 -0
- package/rendering/flier-corvid-figure.js +67 -0
- package/rendering/flier-long-body-company.js +169 -0
- package/rendering/flier-swarm.js +186 -0
- package/rendering/flocks.js +6 -2
- package/rendering/garment-material.js +145 -49
- package/rendering/glsl-literal.js +19 -0
- package/rendering/ground-marks.js +316 -0
- package/rendering/hair-strands.js +38 -24
- package/rendering/height-haze.js +80 -33
- package/rendering/height-probe.js +15 -3
- package/rendering/house-kit-meshes.js +124 -0
- package/rendering/interior-bake.js +807 -0
- package/rendering/label-layout.js +13 -3
- package/rendering/label-range.js +5 -2
- package/rendering/lamp-light-map.js +159 -0
- package/rendering/lamp-maps.js +62 -0
- package/rendering/lamp-wash.js +51 -0
- package/rendering/light-budget.js +19 -3
- package/rendering/light-points.js +21 -5
- package/rendering/local-lights.js +27 -7
- package/rendering/material-lod.js +5 -6
- package/rendering/memory-estimate.js +84 -0
- package/rendering/moored-fleet.js +186 -0
- package/rendering/nameplate-groups.js +84 -0
- package/rendering/nameplates.js +386 -0
- package/rendering/part-costs.js +104 -0
- package/rendering/particle-bursts.js +386 -0
- package/rendering/particle-emitters.js +61 -25
- package/rendering/particle-light-bursts.js +189 -0
- package/rendering/particles.js +134 -34
- package/rendering/pen-flocks.js +118 -0
- package/rendering/piece-batch.js +282 -6
- package/rendering/planar-reflection-options.js +159 -0
- package/rendering/planar-reflection.js +780 -77
- package/rendering/plant-cells.js +122 -0
- package/rendering/plant-reeds.js +113 -0
- package/rendering/plant-shade-trees.js +239 -0
- package/rendering/plant-tuft-patch.js +122 -0
- package/rendering/post-shaders.js +84 -21
- package/rendering/post.js +39 -19
- package/rendering/pressed-cover.js +135 -0
- package/rendering/prop-dig.js +136 -0
- package/rendering/room-light.js +250 -0
- package/rendering/room-materials.js +78 -0
- package/rendering/room-space.js +111 -0
- package/rendering/scene-lights.js +106 -0
- package/rendering/sea-shaders.js +83 -26
- package/rendering/settlement-approach.js +226 -0
- package/rendering/settlement-dissolve.js +89 -0
- package/rendering/settlement-quarter-warm.js +55 -0
- package/rendering/settlement-quarter.js +477 -0
- package/rendering/settlement-switch.js +42 -0
- package/rendering/settlement-town.js +110 -0
- package/rendering/shader-warmup.js +80 -36
- package/rendering/shadow-depth.js +40 -18
- package/rendering/ship-meshes.js +150 -0
- package/rendering/shot-cuts.js +68 -0
- package/rendering/sky-occlusion.js +42 -15
- package/rendering/sky-pmrem.js +216 -0
- package/rendering/sky.js +112 -50
- package/rendering/smoke-shadows.js +201 -0
- package/rendering/stage-framing.js +182 -0
- package/rendering/stage-lights.js +46 -39
- package/rendering/stain-material.js +74 -0
- package/rendering/static-point-shadow.js +62 -23
- package/rendering/still-casters.js +77 -27
- package/rendering/strata-material.js +2 -2
- package/rendering/street-lamps.js +166 -0
- package/rendering/sunbeam-motes.js +670 -0
- package/rendering/surface-light.js +65 -6
- package/rendering/surface-material.js +306 -0
- package/rendering/surface-projection.js +32 -0
- package/rendering/surface-snippets.js +314 -0
- package/rendering/taa.js +49 -18
- package/rendering/tree-impostor.js +929 -0
- package/rendering/vehicle-train.js +92 -0
- package/rendering/viewport.js +67 -4
- package/rendering/water-material.js +270 -82
- package/rendering/waypoint-beacons.js +191 -0
- package/rendering/world-matrices.js +0 -2
- package/ruff.toml +20 -0
- package/runtime/cue-cursor.js +21 -0
- package/runtime/device-quality.js +13 -2
- package/runtime/device.js +73 -0
- package/runtime/diagnostic-log.js +11 -3
- package/runtime/effect-sites.js +85 -0
- package/runtime/figure-orders.js +59 -0
- package/runtime/first-use.js +8 -5
- package/runtime/foley-script.js +124 -0
- package/runtime/foley-strides.js +333 -0
- package/runtime/frame-pacing.js +18 -4
- package/runtime/frame-yield.js +18 -0
- package/runtime/gpu-timing.js +8 -4
- package/runtime/grid-cache.js +16 -6
- package/runtime/grid-rows.js +5 -5
- package/runtime/hand-over.js +7 -2
- package/runtime/land-bake.js +78 -0
- package/runtime/lazy-sets.js +105 -0
- package/runtime/pool.js +17 -3
- package/runtime/quality-fit.js +59 -27
- package/runtime/region-pass-lay.js +40 -0
- package/runtime/region-pass.js +78 -0
- package/runtime/search.js +6 -2
- package/runtime/settlement-reach.js +42 -0
- package/runtime/sound-calls.js +113 -0
- package/runtime/sound-impacts.js +297 -0
- package/runtime/sound-voices.js +194 -0
- package/runtime/soundscape.js +282 -0
- package/runtime/spatial-audio.js +69 -20
- package/runtime/steady-frames.js +221 -0
- package/runtime/withdrawable-task.js +19 -8
- package/scripts/app-parts.mjs +118 -0
- package/scripts/bake-revisions.mjs +81 -0
- package/scripts/browser-scripts.mjs +64 -0
- package/scripts/bundle.mjs +192 -0
- package/scripts/check-app.sh +26 -0
- package/scripts/eslint-config.mjs +119 -0
- package/scripts/format.sh +92 -0
- package/scripts/keep-builds.mjs +158 -0
- package/scripts/layers.mjs +112 -0
- package/scripts/lint.sh +49 -0
- package/scripts/module-graph.mjs +123 -0
- package/scripts/pre-commit.sh +38 -0
- package/scripts/serve.py +5 -3
- package/scripts/site.mjs +358 -0
- package/scripts/test-runner.sh +42 -0
- package/scripts/vendor.mjs +221 -0
- package/scripts/verify-publish.mjs +175 -0
- package/scripts/world.mk +59 -0
- package/tools/README.md +73 -0
- package/tools/contact-sheet.cjs +137 -0
- package/tools/cpu-profile.cjs +275 -0
- package/tools/cpu-profile.test.cjs +98 -0
- package/tools/first-draws.cjs +395 -0
- package/tools/flight-guard.cjs +482 -0
- package/tools/flight-guard.test.cjs +153 -0
- package/tools/flight-profile.cjs +145 -0
- package/tools/frame-bench.cjs +336 -0
- package/tools/frame-parts.cjs +365 -0
- package/tools/ios-sim.sh +145 -0
- package/tools/load-audit.cjs +201 -0
- package/tools/look-compare.cjs +304 -0
- package/tools/look-guard.cjs +407 -0
- package/tools/look-guard.test.cjs +93 -0
- package/tools/look-stats.cjs +185 -0
- package/tools/look-stats.test.cjs +71 -0
- package/tools/memory-audit.cjs +323 -0
- package/tools/page-driver.cjs +320 -0
- package/tools/page-driver.test.cjs +219 -0
- package/tools/program-census-report.cjs +191 -0
- package/tools/program-census.cjs +465 -0
- package/tools/program-census.test.cjs +332 -0
- package/tools/remote-runner.sh +265 -0
- package/tools/runners.test.cjs +59 -0
- package/tools/scene-audit-beat.cjs +344 -0
- package/tools/scene-audit-sheet.cjs +282 -0
- package/tools/scene-audit.cjs +471 -0
- package/tools/scene-audit.test.cjs +201 -0
- package/tools/scene-batch.cjs +219 -0
- package/tools/scene-bench.cjs +149 -0
- package/tools/scene-bench.test.cjs +33 -0
- package/tools/scene-run.cjs +443 -0
- package/tools/scene-run.test.cjs +94 -0
- package/tools/servers.sh +59 -0
- package/tools/shader-arrival.cjs +316 -0
- package/tools/shader-renewal.cjs +53 -0
- package/tools/shader-renewal.test.cjs +115 -0
- package/tools/speed-guard.cjs +258 -0
- package/tools/stills.cjs +492 -0
- package/tools/stills.test.cjs +49 -0
- package/tools/turns.sh +7 -0
- package/tools/yaml.cjs +158 -0
- package/examples/viaduct.css +0 -75
- package/rendering/light-shafts.js +0 -131
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Shared repository formatter for Roamwright and worlds built on it:
|
|
3
|
+
# - Python (*.py) via Ruff (ruff.toml, installed in .venv via uv)
|
|
4
|
+
# - Shell (*.sh and .githooks/*) via shfmt (.venv/bin/shfmt via uv)
|
|
5
|
+
# - Markdown, JS/MJS/CJS, HTML, CSS, YAML, and JSON via Prettier (roamwright/.prettierrc.yaml)
|
|
6
|
+
# `scripts/format.sh --check` reports unformatted files without modifying them (`make lint` runs this).
|
|
7
|
+
#
|
|
8
|
+
# Consumer overrides:
|
|
9
|
+
# FORMAT_ROOT repository root to format (default: engine root)
|
|
10
|
+
# FORMAT_SHELL_PATHS space-separated directories checked by shfmt (default: ".githooks scripts tools")
|
|
11
|
+
# FORMAT_CACHE Prettier cache file path relative to FORMAT_ROOT (default: ".prettier-cache/cache")
|
|
12
|
+
# FORMAT_PRETTIER_CONFIG Prettier config file (default: engine's .prettierrc.yaml)
|
|
13
|
+
set -eu
|
|
14
|
+
ENGINE_ROOT=$(cd "$(dirname "$0")/.." && pwd)
|
|
15
|
+
ROOT="${FORMAT_ROOT:-$ENGINE_ROOT}"
|
|
16
|
+
cd "$ROOT"
|
|
17
|
+
|
|
18
|
+
resolve_venv_bin() {
|
|
19
|
+
bin_name=$1
|
|
20
|
+
if [ -x ".venv/bin/$bin_name" ]; then
|
|
21
|
+
printf '%s\n' ".venv/bin/$bin_name"
|
|
22
|
+
return
|
|
23
|
+
fi
|
|
24
|
+
common_dir=$(git rev-parse --path-format=absolute --git-common-dir 2>/dev/null || true)
|
|
25
|
+
if [ -n "$common_dir" ] && [ -x "$(dirname "$common_dir")/.venv/bin/$bin_name" ]; then
|
|
26
|
+
printf '%s\n' "$(dirname "$common_dir")/.venv/bin/$bin_name"
|
|
27
|
+
return
|
|
28
|
+
fi
|
|
29
|
+
if command -v uv >/dev/null 2>&1; then
|
|
30
|
+
uv sync --frozen --quiet 2>/dev/null || uv sync --quiet
|
|
31
|
+
printf '%s\n' ".venv/bin/$bin_name"
|
|
32
|
+
return
|
|
33
|
+
fi
|
|
34
|
+
if command -v "$bin_name" >/dev/null 2>&1; then
|
|
35
|
+
printf '%s\n' "$bin_name"
|
|
36
|
+
return
|
|
37
|
+
fi
|
|
38
|
+
echo "format: '$bin_name' not found; run 'make deps' or 'uv sync'" >&2
|
|
39
|
+
exit 1
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
RUFF=$(resolve_venv_bin ruff)
|
|
43
|
+
SHFMT=$(resolve_venv_bin shfmt)
|
|
44
|
+
SHELL_PATHS="${FORMAT_SHELL_PATHS:-.githooks scripts tools}"
|
|
45
|
+
CACHE="${FORMAT_CACHE:-.prettier-cache/cache}"
|
|
46
|
+
PRETTIER_CONFIG="${FORMAT_PRETTIER_CONFIG:-$ENGINE_ROOT/.prettierrc.yaml}"
|
|
47
|
+
RUFF_ARGS=""
|
|
48
|
+
if [ ! -f "$ROOT/ruff.toml" ] || { grep -q 'node_modules/roamwright/ruff.toml' "$ROOT/ruff.toml" 2>/dev/null && [ ! -f "$ROOT/node_modules/roamwright/ruff.toml" ]; }; then
|
|
49
|
+
RUFF_ARGS="--config $ENGINE_ROOT/ruff.toml"
|
|
50
|
+
fi
|
|
51
|
+
mkdir -p "$(dirname "$CACHE")"
|
|
52
|
+
|
|
53
|
+
if [ "${1:-}" = "--check" ]; then
|
|
54
|
+
# shellcheck disable=SC2086
|
|
55
|
+
"$RUFF" check $RUFF_ARGS --select I --quiet . || {
|
|
56
|
+
echo "format: run make format"
|
|
57
|
+
exit 1
|
|
58
|
+
}
|
|
59
|
+
# shellcheck disable=SC2086
|
|
60
|
+
"$RUFF" format $RUFF_ARGS --check --quiet . || {
|
|
61
|
+
echo "format: run make format"
|
|
62
|
+
exit 1
|
|
63
|
+
}
|
|
64
|
+
# shellcheck disable=SC2086
|
|
65
|
+
"$SHFMT" -i 2 -ci -l $SHELL_PATHS | grep -q . && {
|
|
66
|
+
# shellcheck disable=SC2086
|
|
67
|
+
"$SHFMT" -i 2 -ci -l $SHELL_PATHS >&2
|
|
68
|
+
echo "format: run make format"
|
|
69
|
+
exit 1
|
|
70
|
+
} || true
|
|
71
|
+
npx --yes prettier@3.6.2 --config "$PRETTIER_CONFIG" --check --ignore-unknown --cache --cache-location "$CACHE" --log-level warn . || {
|
|
72
|
+
rm -f "$CACHE" # see below
|
|
73
|
+
echo "format: run make format"
|
|
74
|
+
exit 1
|
|
75
|
+
}
|
|
76
|
+
echo "format: every file is formatted"
|
|
77
|
+
else
|
|
78
|
+
# shellcheck disable=SC2086
|
|
79
|
+
"$RUFF" check $RUFF_ARGS --select I --fix --quiet .
|
|
80
|
+
# shellcheck disable=SC2086
|
|
81
|
+
"$RUFF" format $RUFF_ARGS --quiet .
|
|
82
|
+
# shellcheck disable=SC2086
|
|
83
|
+
"$SHFMT" -i 2 -ci -w $SHELL_PATHS
|
|
84
|
+
# A file Prettier cannot read fails this run, but its cache then holds the file as done and every later check passes it:
|
|
85
|
+
# drop the cache on failure so the next run re-reads everything until the file is mended.
|
|
86
|
+
npx --yes prettier@3.6.2 --config "$PRETTIER_CONFIG" --write --ignore-unknown --cache --cache-location "$CACHE" --log-level warn . || {
|
|
87
|
+
rm -f "$CACHE"
|
|
88
|
+
echo "format: Prettier could not read a file (above): mend it and run make format again" >&2
|
|
89
|
+
exit 1
|
|
90
|
+
}
|
|
91
|
+
echo "format: done"
|
|
92
|
+
fi
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// Retains recent deployed builds alongside a newly generated static site so tabs opened before
|
|
2
|
+
// a deployment can still fetch lazy chunks, older engine bundles, and older Three.js folders.
|
|
3
|
+
import { mkdir, readdir, readFile, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { dirname, join, relative } from 'node:path';
|
|
5
|
+
import { walkFilesAsync } from './module-graph.mjs';
|
|
6
|
+
|
|
7
|
+
const DEFAULT_LEGACY_ADDONS = [
|
|
8
|
+
'postprocessing/EffectComposer.js',
|
|
9
|
+
'postprocessing/MaskPass.js',
|
|
10
|
+
'postprocessing/Pass.js',
|
|
11
|
+
'postprocessing/ShaderPass.js',
|
|
12
|
+
'shaders/CopyShader.js',
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
async function fetchAsset(url, kind, tries = 3) {
|
|
16
|
+
try {
|
|
17
|
+
const res = await fetch(url, { cache: 'no-store', signal: AbortSignal.timeout(20000) });
|
|
18
|
+
if (res.status === 404) tries = 1;
|
|
19
|
+
if (!res.ok) throw new Error(`${res.status} ${url}`);
|
|
20
|
+
return kind === 'json' ? await res.json() : Buffer.from(await res.arrayBuffer());
|
|
21
|
+
} catch (e) {
|
|
22
|
+
if (tries <= 1) throw e;
|
|
23
|
+
await new Promise(r => setTimeout(r, 500));
|
|
24
|
+
return fetchAsset(url, kind, tries - 1);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Writes `app-<current>/files.json` and `builds.json`, copying recent prior builds' runtime files,
|
|
30
|
+
* engine modules, and older Three.js bundles from `live` into `folder`.
|
|
31
|
+
*
|
|
32
|
+
* @param {object} config
|
|
33
|
+
* @param {string} config.folder Newly built site subfolder (e.g. `.site/world`).
|
|
34
|
+
* @param {string} config.live Live site base URL corresponding to `folder`.
|
|
35
|
+
* @param {boolean} [config.requireCurrent=false] Fail if the currently live build cannot be retained completely.
|
|
36
|
+
* @param {number} [config.keep=4] Maximum prior builds retained besides the new one.
|
|
37
|
+
* @param {number} [config.keepHours=24] Maximum age (hours since replacement) of older builds.
|
|
38
|
+
* @param {number} [config.concurrency=16] Parallel asset fetches.
|
|
39
|
+
* @param {string[]} [config.legacyAddons] Legacy r170 addon paths retained when an old bundle references `three/addons/`.
|
|
40
|
+
* @param {Function} [config.fetcher] Optional fetch override for testing.
|
|
41
|
+
* @returns {Promise<{ current: string, kept: object[] }>}
|
|
42
|
+
*/
|
|
43
|
+
export async function retainBuilds({
|
|
44
|
+
folder,
|
|
45
|
+
live,
|
|
46
|
+
requireCurrent = false,
|
|
47
|
+
keep = 4,
|
|
48
|
+
keepHours = 24,
|
|
49
|
+
concurrency = 16,
|
|
50
|
+
legacyAddons = DEFAULT_LEGACY_ADDONS,
|
|
51
|
+
fetcher = fetchAsset,
|
|
52
|
+
}) {
|
|
53
|
+
const base = live.endsWith('/') ? live : live + '/';
|
|
54
|
+
const current = JSON.parse(await readFile(join(folder, 'version.json'), 'utf8')).build;
|
|
55
|
+
const own = join(folder, `app-${current}`);
|
|
56
|
+
await writeFile(join(own, 'files.json'), JSON.stringify((await walkFilesAsync(own)).map(f => relative(own, f))));
|
|
57
|
+
|
|
58
|
+
let previous = null;
|
|
59
|
+
if (requireCurrent) {
|
|
60
|
+
previous = (await fetcher(base + 'version.json', 'json')).build;
|
|
61
|
+
if (!/^[a-f0-9]{10}$/.test(previous)) throw new Error('keep-builds: the live build identifier is missing or invalid');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
let earlier = [];
|
|
65
|
+
try {
|
|
66
|
+
earlier = (await fetcher(base + 'builds.json', 'json')).builds ?? [];
|
|
67
|
+
} catch (e) {
|
|
68
|
+
if (requireCurrent) throw new Error('keep-builds: the live build list is unavailable', { cause: e });
|
|
69
|
+
console.log(`keep-builds: no list of builds at the live site (${e.message})`);
|
|
70
|
+
}
|
|
71
|
+
if (requireCurrent && earlier[0]?.hash !== previous) {
|
|
72
|
+
throw new Error('keep-builds: the live version and build list disagree');
|
|
73
|
+
}
|
|
74
|
+
if (requireCurrent && (!Array.isArray(earlier[0].engineFiles) || !earlier[0].engineFiles.length)) {
|
|
75
|
+
throw new Error('keep-builds: the live build has no engine asset list');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const engineFiles = (await walkFilesAsync(join(folder, 'roamwright'))).map(file => relative(folder, file)).sort();
|
|
79
|
+
const availableEngine = new Set(engineFiles);
|
|
80
|
+
const availableThree = new Set(
|
|
81
|
+
(await readdir(folder, { withFileTypes: true })).filter(e => e.isDirectory() && /^three-r\d+$/.test(e.name)).map(e => e.name),
|
|
82
|
+
);
|
|
83
|
+
let availableLegacyAddons = false;
|
|
84
|
+
|
|
85
|
+
async function keepBuild({ hash, engineFiles: oldEngine = [] }) {
|
|
86
|
+
if (!/^[a-f0-9]{10}$/.test(hash)) throw new Error('Invalid retained build identifier');
|
|
87
|
+
const files = await fetcher(`${base}app-${hash}/files.json`, 'json');
|
|
88
|
+
if (
|
|
89
|
+
!Array.isArray(files) ||
|
|
90
|
+
!files.includes('main.js') ||
|
|
91
|
+
!files.includes('app.css') ||
|
|
92
|
+
files.some(name => !/^[\w.-]+$/.test(name) || name === '.' || name === '..')
|
|
93
|
+
) {
|
|
94
|
+
throw new Error('Invalid retained build assets');
|
|
95
|
+
}
|
|
96
|
+
const runtimeFiles = files.filter(name => name !== 'roamwright.json' && name !== 'parts.json');
|
|
97
|
+
const queue = [...runtimeFiles, 'files.json'].map(name => `app-${hash}/${name}`);
|
|
98
|
+
for (const p of oldEngine) {
|
|
99
|
+
if (!/^roamwright\/[\w.+-]+\/[\w-]+\.js$/.test(p)) throw new Error('Invalid engine asset: ' + p);
|
|
100
|
+
if (!availableEngine.has(p)) queue.push(p);
|
|
101
|
+
}
|
|
102
|
+
let needsLegacyAddons = false;
|
|
103
|
+
const worker = async () => {
|
|
104
|
+
for (let name; (name = queue.shift()); ) {
|
|
105
|
+
const to = join(folder, name);
|
|
106
|
+
await mkdir(dirname(to), { recursive: true });
|
|
107
|
+
const bytes = await fetcher(base + name);
|
|
108
|
+
if (name.endsWith('.js') && !name.startsWith('three-r')) {
|
|
109
|
+
const text = bytes.toString('utf8');
|
|
110
|
+
for (const match of text.matchAll(/\b(three-r\d+)\//g)) {
|
|
111
|
+
const threeDir = match[1];
|
|
112
|
+
if (availableThree.has(threeDir)) continue;
|
|
113
|
+
availableThree.add(threeDir);
|
|
114
|
+
queue.push(`${threeDir}/three.module.min.js`, `${threeDir}/LICENSE`);
|
|
115
|
+
}
|
|
116
|
+
if (text.includes('three/addons/')) needsLegacyAddons = true;
|
|
117
|
+
}
|
|
118
|
+
await writeFile(to, bytes);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
await Promise.all(Array.from({ length: concurrency }, worker));
|
|
122
|
+
if (needsLegacyAddons && !availableLegacyAddons) {
|
|
123
|
+
availableLegacyAddons = true;
|
|
124
|
+
await Promise.all(
|
|
125
|
+
legacyAddons.map(async rel => {
|
|
126
|
+
const p = `three-r170/addons/${rel}`;
|
|
127
|
+
const to = join(folder, p);
|
|
128
|
+
await mkdir(dirname(to), { recursive: true });
|
|
129
|
+
await writeFile(to, await fetcher(base + p));
|
|
130
|
+
}),
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
for (const p of oldEngine) availableEngine.add(p);
|
|
134
|
+
return files.length;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const now = Date.now();
|
|
138
|
+
const kept = [{ hash: current, at: now, engineFiles }];
|
|
139
|
+
let replacedAt = now;
|
|
140
|
+
for (const b of earlier) {
|
|
141
|
+
if (kept.length > keep || now - replacedAt > keepHours * 3600e3) break;
|
|
142
|
+
if (b.hash === current) continue;
|
|
143
|
+
replacedAt = b.at;
|
|
144
|
+
try {
|
|
145
|
+
const n = await keepBuild(b);
|
|
146
|
+
kept.push(b);
|
|
147
|
+
console.log(`keep-builds: kept app-${b.hash} (${n} files)`);
|
|
148
|
+
} catch (e) {
|
|
149
|
+
if (b.hash === previous) throw new Error(`keep-builds: could not retain the live build app-${previous}`, { cause: e });
|
|
150
|
+
console.log(`keep-builds: could not keep app-${b.hash} (${e.message})`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (requireCurrent && (await fetcher(base + 'version.json', 'json')).build !== previous) {
|
|
154
|
+
throw new Error('keep-builds: the live build changed while its assets were copied');
|
|
155
|
+
}
|
|
156
|
+
await writeFile(join(folder, 'builds.json'), JSON.stringify({ builds: kept }));
|
|
157
|
+
return { current, kept };
|
|
158
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// Checks application module layer boundaries, duplicate/private imports, and unused named exports.
|
|
2
|
+
// Callers supply the ordered layer table and JS parser (`acorn.parse`) so Roamwright remains independent
|
|
3
|
+
// of both any world's folder layout and external parser packages.
|
|
4
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
5
|
+
import { dirname, join, relative, resolve, sep } from 'node:path';
|
|
6
|
+
import { walkAstNodes } from './module-graph.mjs';
|
|
7
|
+
|
|
8
|
+
const MODULE_DECLARATIONS = new Set(['ImportDeclaration', 'ExportNamedDeclaration', 'ExportAllDeclaration', 'ImportExpression']);
|
|
9
|
+
const nameOf = node => node.name ?? node.value;
|
|
10
|
+
|
|
11
|
+
function sourceOf(node) {
|
|
12
|
+
if (node.type === 'Literal') return typeof node.value === 'string' ? node.value : null;
|
|
13
|
+
if (node.type === 'TemplateLiteral' && !node.expressions.length) return node.quasis[0].value.cooked;
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Checks that every relative import inside `<root>/<srcDir>` points down or sideways in `layers`,
|
|
19
|
+
* forbids duplicate static imports and `_`-prefixed private imports, and reports named exports
|
|
20
|
+
* unused by any module or extra consumer directory.
|
|
21
|
+
*
|
|
22
|
+
* @param {string} root Repository root directory.
|
|
23
|
+
* @param {object} options
|
|
24
|
+
* @param {string[]} options.layers Ordered layer names from lowest to highest.
|
|
25
|
+
* @param {(source: string, opts: object) => object} options.parse ESTree parser (e.g. `acorn.parse`).
|
|
26
|
+
* @param {Record<string, string>} [options.entryAliases={'main.js': 'app'}] Maps top-level source filenames to a layer name.
|
|
27
|
+
* @param {string[]} [options.extraConsumerDirs=['scripts']] Additional directories whose `.mjs` files count as export consumers.
|
|
28
|
+
* @param {string} [options.srcDir='src'] Application source directory relative to `root`.
|
|
29
|
+
* @returns {{ count: number, problems: string[] }}
|
|
30
|
+
*/
|
|
31
|
+
export function checkLayers(root, { layers, parse, entryAliases = { 'main.js': 'app' }, extraConsumerDirs = ['scripts'], srcDir = 'src' }) {
|
|
32
|
+
const src = join(root, srcDir);
|
|
33
|
+
const files = readdirSync(src, { recursive: true })
|
|
34
|
+
.filter(p => p.endsWith('.js'))
|
|
35
|
+
.sort();
|
|
36
|
+
const records = new Map(files.map(file => [file, { used: new Set(), exports: new Map(), namespace: false }]));
|
|
37
|
+
const problems = [];
|
|
38
|
+
|
|
39
|
+
const layerOf = file => {
|
|
40
|
+
const folder = file.split(sep)[0];
|
|
41
|
+
return entryAliases[folder] ?? folder;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
function checkFile(file, inApp) {
|
|
45
|
+
const seen = new Set();
|
|
46
|
+
let program;
|
|
47
|
+
try {
|
|
48
|
+
program = parse(readFileSync(join(src, file), 'utf8'), { sourceType: 'module', ecmaVersion: 'latest', locations: true });
|
|
49
|
+
} catch (error) {
|
|
50
|
+
problems.push(`${file}:${error.loc?.line ?? 1}: ${error.message}`);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
for (const node of walkAstNodes(program)) {
|
|
54
|
+
if (!MODULE_DECLARATIONS.has(node.type)) continue;
|
|
55
|
+
const location = `${file}:${node.loc.start.line}`;
|
|
56
|
+
const specifiers = node.specifiers ?? [];
|
|
57
|
+
if (inApp && node.type === 'ExportNamedDeclaration') {
|
|
58
|
+
for (const spec of specifiers) records.get(file).exports.set(nameOf(spec.exported), location);
|
|
59
|
+
}
|
|
60
|
+
if (!node.source) continue;
|
|
61
|
+
const specifier = sourceOf(node.source);
|
|
62
|
+
if (specifier === null) {
|
|
63
|
+
if (inApp) problems.push(`${location}: use a literal module path so the layer can be checked`);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (!specifier.startsWith('.')) continue;
|
|
67
|
+
const target = relative(src, resolve(src, dirname(file), specifier));
|
|
68
|
+
const record = records.get(target);
|
|
69
|
+
if (!record) {
|
|
70
|
+
if (inApp) problems.push(`${location}: cannot resolve ${specifier} to a source module`);
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (inApp) {
|
|
74
|
+
const from = layers.indexOf(layerOf(file));
|
|
75
|
+
const to = layers.indexOf(layerOf(target));
|
|
76
|
+
if (from < 0 || to < 0 || to > from) {
|
|
77
|
+
problems.push(`${location}: ${specifier} crosses from ${layerOf(file)} to ${layerOf(target)}`);
|
|
78
|
+
}
|
|
79
|
+
if (node.type === 'ImportDeclaration') {
|
|
80
|
+
if (seen.has(target)) problems.push(`${location}: imports ${specifier} twice`);
|
|
81
|
+
seen.add(target);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (node.type === 'ImportExpression' || node.type === 'ExportAllDeclaration') record.namespace = true;
|
|
85
|
+
for (const spec of specifiers) {
|
|
86
|
+
if (spec.type === 'ImportNamespaceSpecifier') {
|
|
87
|
+
record.namespace = true;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const name = spec.type === 'ImportDefaultSpecifier' ? 'default' : nameOf(spec.imported ?? spec.local);
|
|
91
|
+
if (inApp && name.startsWith('_')) problems.push(`${location}: imports private name ${name} from ${specifier}`);
|
|
92
|
+
record.used.add(name);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
for (const file of files) checkFile(file, true);
|
|
98
|
+
for (const dir of extraConsumerDirs) {
|
|
99
|
+
const fullDir = join(root, dir);
|
|
100
|
+
if (!existsSync(fullDir)) continue;
|
|
101
|
+
for (const file of readdirSync(fullDir).filter(f => f.endsWith('.mjs'))) {
|
|
102
|
+
checkFile(join('..', dir, file), false);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
for (const record of records.values()) {
|
|
106
|
+
if (record.namespace) continue;
|
|
107
|
+
for (const [name, location] of record.exports) {
|
|
108
|
+
if (!record.used.has(name)) problems.push(`${location}: exports ${name}, which no module imports`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return { count: files.length, problems };
|
|
112
|
+
}
|
package/scripts/lint.sh
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Shared lint runner for Roamwright and worlds built on it:
|
|
3
|
+
# runs subsystem/layer checks, formatting check (scripts/format.sh --check), Ruff, and ESLint.
|
|
4
|
+
#
|
|
5
|
+
# Consumer overrides:
|
|
6
|
+
# LINT_ROOT repository root to lint (default: engine root)
|
|
7
|
+
# LINT_ESLINT_TARGETS space-separated ESLint targets (default: Roamwright engine modules)
|
|
8
|
+
# FORMAT_SHELL_PATHS / FORMAT_CACHE / FORMAT_PRETTIER_CONFIG forwarded to format.sh --check
|
|
9
|
+
set -eu
|
|
10
|
+
ENGINE_ROOT=$(cd "$(dirname "$0")/.." && pwd)
|
|
11
|
+
ROOT="${LINT_ROOT:-$ENGINE_ROOT}"
|
|
12
|
+
cd "$ROOT"
|
|
13
|
+
|
|
14
|
+
if [ "$ROOT" = "$ENGINE_ROOT" ]; then
|
|
15
|
+
node --input-type=module -e '
|
|
16
|
+
import { readdirSync, readFileSync } from "node:fs";
|
|
17
|
+
import { join } from "node:path";
|
|
18
|
+
for (const dir of ["math", "runtime"]) {
|
|
19
|
+
for (const name of readdirSync(dir).filter(f => f.endsWith(".js"))) {
|
|
20
|
+
const file = join(dir, name);
|
|
21
|
+
const src = readFileSync(file, "utf8");
|
|
22
|
+
if (/(?:from|import)\s+["\x27]three(?:\/|["\x27])/.test(src)) {
|
|
23
|
+
console.error(`boundary: ${file} must not import three`);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
console.log("boundary: math/ and runtime/ stay free of three");
|
|
29
|
+
'
|
|
30
|
+
fi
|
|
31
|
+
|
|
32
|
+
FORMAT_ROOT="$ROOT" sh "$ENGINE_ROOT/scripts/format.sh" --check
|
|
33
|
+
|
|
34
|
+
RUFF=".venv/bin/ruff"
|
|
35
|
+
if [ ! -x "$RUFF" ]; then
|
|
36
|
+
common_dir=$(git rev-parse --path-format=absolute --git-common-dir 2>/dev/null || true)
|
|
37
|
+
if [ -n "$common_dir" ] && [ -x "$(dirname "$common_dir")/.venv/bin/ruff" ]; then
|
|
38
|
+
RUFF="$(dirname "$common_dir")/.venv/bin/ruff"
|
|
39
|
+
else
|
|
40
|
+
RUFF="ruff"
|
|
41
|
+
fi
|
|
42
|
+
fi
|
|
43
|
+
"$RUFF" check --quiet .
|
|
44
|
+
echo "lint: Ruff found nothing"
|
|
45
|
+
|
|
46
|
+
ESLINT_TARGETS="${LINT_ESLINT_TARGETS:-index.js geometry math motion rendering runtime examples}"
|
|
47
|
+
# shellcheck disable=SC2086
|
|
48
|
+
npx --yes eslint@10.15.0 $ESLINT_TARGETS
|
|
49
|
+
echo "lint: ESLint found nothing"
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// Shared import-graph walker, recursive file walkers, AST traversal, and validated plain-data
|
|
2
|
+
// literal serialization for the Roamwright build and verification chain.
|
|
3
|
+
import { readdirSync } from 'node:fs';
|
|
4
|
+
import { readdir } from 'node:fs/promises';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Walks an import adjacency graph starting from `roots` and returns all reachable module ids
|
|
10
|
+
* in deterministic discovery order. Supports both `Map<id, imports[]>` (esbuild inputs) and
|
|
11
|
+
* plain objects `{ [id]: { imports: [...] } }` (esbuild outputs).
|
|
12
|
+
*
|
|
13
|
+
* @param {Map<string, Array<{ path: string, kind?: string, external?: boolean }>> | Record<string, { imports?: Array<{ path: string, kind?: string, external?: boolean }> }>} graph
|
|
14
|
+
* @param {Iterable<string>} roots Starting node ids.
|
|
15
|
+
* @param {object} [options]
|
|
16
|
+
* @param {string[] | Set<string> | null} [options.kinds=null] Restrict traversal to these import kinds (e.g. `['import-statement']`).
|
|
17
|
+
* @param {boolean} [options.includeExternal=false] Follow edges marked `external: true`.
|
|
18
|
+
* @param {(path: string) => string} [options.resolvePath] Normalizes each dependency path before lookup.
|
|
19
|
+
* @returns {Set<string>} Reachable node ids (insertion-ordered).
|
|
20
|
+
*/
|
|
21
|
+
export function walkReach(graph, roots, { kinds = null, includeExternal = false, resolvePath = p => p } = {}) {
|
|
22
|
+
const kindSet = kinds ? (kinds instanceof Set ? kinds : new Set(kinds)) : null;
|
|
23
|
+
const isMap = graph instanceof Map;
|
|
24
|
+
const seen = new Set();
|
|
25
|
+
const stack = [...roots];
|
|
26
|
+
while (stack.length) {
|
|
27
|
+
const id = stack.pop();
|
|
28
|
+
if (seen.has(id)) continue;
|
|
29
|
+
const entry = isMap ? graph.get(id) : graph[id];
|
|
30
|
+
if (!entry) continue;
|
|
31
|
+
seen.add(id);
|
|
32
|
+
const edges = Array.isArray(entry) ? entry : (entry.imports ?? []);
|
|
33
|
+
for (const edge of edges) {
|
|
34
|
+
if (!includeExternal && edge.external) continue;
|
|
35
|
+
if (kindSet && !kindSet.has(edge.kind)) continue;
|
|
36
|
+
stack.push(resolvePath(edge.path));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return seen;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Recursively lists every file path under `root` in lexicographical order.
|
|
44
|
+
*
|
|
45
|
+
* @param {string} root Directory to walk.
|
|
46
|
+
* @returns {string[]}
|
|
47
|
+
*/
|
|
48
|
+
export function walkFiles(root) {
|
|
49
|
+
const out = [];
|
|
50
|
+
for (const entry of readdirSync(root, { withFileTypes: true })) {
|
|
51
|
+
const full = join(root, entry.name);
|
|
52
|
+
if (entry.isDirectory()) out.push(...walkFiles(full));
|
|
53
|
+
else out.push(full);
|
|
54
|
+
}
|
|
55
|
+
return out.sort();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Async variant of `walkFiles`, returning every file path under `root`.
|
|
60
|
+
*
|
|
61
|
+
* @param {string} root Directory to walk.
|
|
62
|
+
* @returns {Promise<string[]>}
|
|
63
|
+
*/
|
|
64
|
+
export async function walkFilesAsync(root) {
|
|
65
|
+
const out = [];
|
|
66
|
+
for (const entry of await readdir(root, { withFileTypes: true })) {
|
|
67
|
+
const full = join(root, entry.name);
|
|
68
|
+
if (entry.isDirectory()) out.push(...(await walkFilesAsync(full)));
|
|
69
|
+
else out.push(full);
|
|
70
|
+
}
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Yields every ESTree AST node beneath `node` in pre-order.
|
|
76
|
+
*
|
|
77
|
+
* @param {object} node Root AST node.
|
|
78
|
+
* @returns {Generator<object>}
|
|
79
|
+
*/
|
|
80
|
+
export function* walkAstNodes(node) {
|
|
81
|
+
yield node;
|
|
82
|
+
for (const child of Object.values(node)) {
|
|
83
|
+
if (Array.isArray(child)) {
|
|
84
|
+
for (const item of child) if (item?.type) yield* walkAstNodes(item);
|
|
85
|
+
} else if (child?.type) yield* walkAstNodes(child);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function serializeLiteral(value, where) {
|
|
90
|
+
if (value === undefined) return 'undefined';
|
|
91
|
+
if (value === null || typeof value === 'boolean' || typeof value === 'string') return JSON.stringify(value);
|
|
92
|
+
if (typeof value === 'number') {
|
|
93
|
+
if (!Number.isFinite(value)) throw new Error(`${where} is ${value}`);
|
|
94
|
+
return Object.is(value, -0) ? '-0' : String(value);
|
|
95
|
+
}
|
|
96
|
+
if (Array.isArray(value)) return '[' + Array.from(value, (v, i) => serializeLiteral(v, `${where}[${i}]`)).join(',') + ']';
|
|
97
|
+
if (typeof value === 'object' && Object.getPrototypeOf(value) === Object.prototype) {
|
|
98
|
+
return (
|
|
99
|
+
'{' +
|
|
100
|
+
Object.entries(value)
|
|
101
|
+
.map(([k, v]) => `${JSON.stringify(k)}:${serializeLiteral(v, `${where}.${k}`)}`)
|
|
102
|
+
.join(',') +
|
|
103
|
+
'}'
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
throw new Error(`${where} is a ${typeof value === 'object' ? value.constructor?.name : typeof value}, not plain data`);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Serializes plain data (objects, arrays, strings, finite numbers including `-0`, booleans, `null`,
|
|
111
|
+
* and `undefined`) as JavaScript source and verifies round-trip equality.
|
|
112
|
+
*
|
|
113
|
+
* @param {unknown} value Plain data value to serialize.
|
|
114
|
+
* @param {string} where Context label included in error messages.
|
|
115
|
+
* @returns {string} JavaScript literal source.
|
|
116
|
+
*/
|
|
117
|
+
export function checkedLiteral(value, where) {
|
|
118
|
+
const text = serializeLiteral(value, where);
|
|
119
|
+
if (!isDeepStrictEqual(new Function(`return ${text}`)(), value)) {
|
|
120
|
+
throw new Error(`${where} does not come out as it went in`);
|
|
121
|
+
}
|
|
122
|
+
return text;
|
|
123
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Shared git pre-commit hook for Roamwright and worlds built on it.
|
|
3
|
+
# Runs `make format` before recording a commit, refuses partial staging alongside unstaged hunks,
|
|
4
|
+
# and re-stages cleanly formatted files.
|
|
5
|
+
set -eu
|
|
6
|
+
|
|
7
|
+
repo_root=$(git rev-parse --show-toplevel)
|
|
8
|
+
cd "$repo_root"
|
|
9
|
+
|
|
10
|
+
staged_files=$(git diff --cached --name-only --diff-filter=ACMR)
|
|
11
|
+
[ -n "$staged_files" ] || exit 0
|
|
12
|
+
|
|
13
|
+
unstaged_before=$(git diff --name-only)
|
|
14
|
+
|
|
15
|
+
make --no-print-directory format
|
|
16
|
+
|
|
17
|
+
err=0
|
|
18
|
+
old_ifs=$IFS
|
|
19
|
+
IFS='
|
|
20
|
+
'
|
|
21
|
+
for file in $staged_files; do
|
|
22
|
+
[ -n "$file" ] && [ -e "$file" ] || continue
|
|
23
|
+
was_unstaged=0
|
|
24
|
+
for u in $unstaged_before; do
|
|
25
|
+
if [ "$u" = "$file" ]; then
|
|
26
|
+
was_unstaged=1
|
|
27
|
+
break
|
|
28
|
+
fi
|
|
29
|
+
done
|
|
30
|
+
if [ "$was_unstaged" = 1 ]; then
|
|
31
|
+
echo "pre-commit: '$file' had unstaged hunks alongside staged changes; stage or stash before committing so 'make format' can stage cleanly." >&2
|
|
32
|
+
err=1
|
|
33
|
+
else
|
|
34
|
+
git add -- "$file"
|
|
35
|
+
fi
|
|
36
|
+
done
|
|
37
|
+
IFS=$old_ifs
|
|
38
|
+
exit "$err"
|
package/scripts/serve.py
CHANGED
|
@@ -17,9 +17,11 @@ if __name__ == "__main__":
|
|
|
17
17
|
port = int(sys.argv[1]) if len(sys.argv) > 1 else 8080
|
|
18
18
|
with ExampleServer(("127.0.0.1", port), Handler) as server:
|
|
19
19
|
print(f"Serving Roamwright on port {server.server_port}", flush=True)
|
|
20
|
-
|
|
21
|
-
print(f"
|
|
22
|
-
print(f"
|
|
20
|
+
root = f"http://127.0.0.1:{server.server_port}/"
|
|
21
|
+
print(f"All examples: {root}", flush=True)
|
|
22
|
+
print(f"A small world: {root}examples/small-world.html?seed=42", flush=True)
|
|
23
|
+
print(f"Alpine viaduct: {root}examples/viaduct.html?seed=42", flush=True)
|
|
24
|
+
print(f"Island: {root}examples/island.html?seed=42", flush=True)
|
|
23
25
|
try:
|
|
24
26
|
server.serve_forever()
|
|
25
27
|
except KeyboardInterrupt:
|