Skip to content

Add a wasm map summary and publish the bindings as @shieldbattery/broodmap - #5

Merged
tec27 merged 9 commits into
mainfrom
wasm-map-summary
Oct 24, 2026
Merged

tec27 merged 9 commits into
mainfrom
wasm-map-summary

Conversation

@2Pacalypse-

@2Pacalypse- 2Pacalypse- commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Adds summarizeMapJson(mapBytes) to broodmap-wasm and makes the bindings publishable as @shieldbattery/broodmap. The ShieldBattery app uses it to read the maps in a user's SC:R map folders: the name, size, tileset, slots and so on, so local files can be listed and filtered before they're uploaded. No game assets are needed.

Summary binding (src/summary.rs)

The binding exposes generic scenario facts only. ShieldBattery applies its own rules (melee vs UMS and so on) on top in its own code.

  • name, description (decoded, color codes kept)
  • width, height, tileset, stringEncoding
  • players: per slot, controller (OWNR), race (SIDE) and force
  • forces[].name
  • usesEud
  • triggerActionKinds (distinct action variant names, sorted) and triggerCount
  • placedUnits, playerUnits, startLocations

summarizeMapJson(bytes, options?) takes an optional JSON object overriding broodmap's default resource limits (maxMapBytes, maxMpqFileBytes, maxChkBytes, maxMergedChunkBytes). ShieldBattery passes the same limits its server parses uploads with, which leave room for a real map with a 129 MB CHK that the defaults refuse.

It throws if the file isn't a readable map within those limits, or lacks SPRP, OWNR, SIDE or FORC. The README documents the fields and options.

Package

  • package.json is now @shieldbattery/broodmap 0.1.0 (no longer private). It has the same layout as @shieldbattery/broodrep: a web build in pkg/ (ESM) and a Node build in pkg-node/ (CommonJS), behind exports.
  • scripts/finalize-package.mjs runs after each wasm-pack build:
    • it removes wasm-pack's ignore file, which would otherwise keep the artifacts out of the tarball
    • it marks each output directory's module format
    • it copies the root licenses into the package
  • scripts/package.test.mjs (pnpm run test:package) checks both entry points on the built package. prepublishOnly builds and runs both test suites.
  • Publishing is manual, as with broodrep.

Testing

  • cargo test -p broodmap-wasm (5 new tests, including limit options: a melee map, a UMS map's trigger kinds, non-maps rejected, camelCase JSON), clippy, fmt.
  • pnpm run build, then pnpm run test:package (4/4) and pnpm test (111/111).
  • npm pack --dry-run contents checked: both builds, the wasm, the licenses.
  • ShieldBattery's app-side rules applied to this summary agree with ShieldBattery's server parse on 854 real maps (492 prod samples plus 362 local files): name, size, tileset, melee/UMS, player count, EUD.

2Pacalypse- added a commit to ShieldBattery/ShieldBattery that referenced this pull request Oct 22, 2026
Built from ShieldBattery/broodmap#5 at 1ee4c5e. Swap the file: spec for a registry version once it's published.
2Pacalypse- added a commit to ShieldBattery/ShieldBattery that referenced this pull request Oct 22, 2026
Built from ShieldBattery/broodmap#5 at 1ee4c5e. Swap the file: spec for a registry version once it's published.
2Pacalypse- added a commit to ShieldBattery/ShieldBattery that referenced this pull request Oct 22, 2026
Built from ShieldBattery/broodmap#5 at 1ee4c5e. Swap the file: spec for a registry version once it's published.
2Pacalypse- added a commit to ShieldBattery/ShieldBattery that referenced this pull request Oct 22, 2026
…with broodmap. (#1772)

* Index the maps in the StarCraft map folders in the app, reading them with broodmap.

* Install broodmap from a vendored package until it is published to npm.

Built from ShieldBattery/broodmap#5 at 1ee4c5e. Swap the file: spec for a registry version once it's published.

* Keep watching map folders that are missing or get deleted, time out stuck map reads, and reuse a moved file's facts.

Deleting a recursively watched folder on Windows leaves its watch reporting the folder itself over and over (about 150k events a second under Electron 44), which kept resetting the reconcile debounce and pinned a core. A folder missing at startup was also never watched.

* Fail a dead map reader's requests instead of letting its error kill the index worker.
2Pacalypse- added a commit to ShieldBattery/ShieldBattery that referenced this pull request Oct 24, 2026
…with broodmap. (#1772)

* Index the maps in the StarCraft map folders in the app, reading them with broodmap.

* Install broodmap from a vendored package until it is published to npm.

Built from ShieldBattery/broodmap#5 at 1ee4c5e. Swap the file: spec for a registry version once it's published.

* Keep watching map folders that are missing or get deleted, time out stuck map reads, and reuse a moved file's facts.

Deleting a recursively watched folder on Windows leaves its watch reporting the folder itself over and over (about 150k events a second under Electron 44), which kept resetting the reconcile debounce and pinned a core. A folder missing at startup was also never watched.

* Fail a dead map reader's requests instead of letting its error kill the index worker.
tec27 added 7 commits October 24, 2026 15:21
Chk::trigger_action_stats() counts triggers and collects their action
types from the raw TRIG records, validating each action like
read_triggers does but without materializing a Vec of every action.
action_type_name() gives each type a stable name instead of callers
deriving one from Debug output.
Formatting every action with Debug to get its variant name was most of
a summary's cost on trigger-heavy maps (28 of ~60 ms on DSA) and tied
the published JSON to Debug output. Empty NoAction slots no longer
count as a kind, and trigger fields are no longer nullable since the
scan can't fail.

MapRenderer takes the same limit options and has summaryJson(), so a
map that's too big for the default limits can still be rendered, and
one that's rendered is only parsed once. The TypeScript declarations
now describe the summary and options JSON.
The nodejs and web targets produce byte-identical wasm, so shipping
both doubled the tarball, and the web build's types (init, initSync)
were served to Node consumers whose CommonJS build lacked them. Node
now gets node.js, which initializes the web build synchronously from
disk, so one set of declarations is correct everywhere and require()
still works through require(esm).

finalize-package also adds the esnext.disposable lib reference for
wasm-bindgen's Symbol.dispose declarations, which test:types checks.
22.13.1 is the January 2025 security release, and pnpm 11 can't run on
the 22.12 the wasm job was testing. The v4 actions ran on Node 20,
which GitHub Actions has deprecated.
The build input only named examples/index.html, already the default for
the examples root, and Vite 8 renames rollupOptions anyway.
@tec27
tec27 merged commit 803aa2c into main Oct 24, 2026
16 checks passed
@tec27
tec27 deleted the wasm-map-summary branch October 24, 2026 22:48
2Pacalypse- added a commit to ShieldBattery/ShieldBattery that referenced this pull request Oct 27, 2026
…with broodmap. (#1772)

* Index the maps in the StarCraft map folders in the app, reading them with broodmap.

* Install broodmap from a vendored package until it is published to npm.

Built from ShieldBattery/broodmap#5 at 1ee4c5e. Swap the file: spec for a registry version once it's published.

* Keep watching map folders that are missing or get deleted, time out stuck map reads, and reuse a moved file's facts.

Deleting a recursively watched folder on Windows leaves its watch reporting the folder itself over and over (about 150k events a second under Electron 44), which kept resetting the reconcile debounce and pinned a core. A folder missing at startup was also never watched.

* Fail a dead map reader's requests instead of letting its error kill the index worker.
2Pacalypse- added a commit to ShieldBattery/ShieldBattery that referenced this pull request Nov 10, 2026
…with broodmap. (#1772)

* Index the maps in the StarCraft map folders in the app, reading them with broodmap.

* Install broodmap from a vendored package until it is published to npm.

Built from ShieldBattery/broodmap#5 at 1ee4c5e. Swap the file: spec for a registry version once it's published.

* Keep watching map folders that are missing or get deleted, time out stuck map reads, and reuse a moved file's facts.

Deleting a recursively watched folder on Windows leaves its watch reporting the folder itself over and over (about 150k events a second under Electron 44), which kept resetting the reconcile debounce and pinned a core. A folder missing at startup was also never watched.

* Fail a dead map reader's requests instead of letting its error kill the index worker.
2Pacalypse- added a commit to ShieldBattery/ShieldBattery that referenced this pull request Nov 15, 2026
…with broodmap. (#1772)

* Index the maps in the StarCraft map folders in the app, reading them with broodmap.

* Install broodmap from a vendored package until it is published to npm.

Built from ShieldBattery/broodmap#5 at 1ee4c5e. Swap the file: spec for a registry version once it's published.

* Keep watching map folders that are missing or get deleted, time out stuck map reads, and reuse a moved file's facts.

Deleting a recursively watched folder on Windows leaves its watch reporting the folder itself over and over (about 150k events a second under Electron 44), which kept resetting the reconcile debounce and pinned a core. A folder missing at startup was also never watched.

* Fail a dead map reader's requests instead of letting its error kill the index worker.
2Pacalypse- added a commit to ShieldBattery/ShieldBattery that referenced this pull request Nov 17, 2026
…with broodmap. (#1772)

* Index the maps in the StarCraft map folders in the app, reading them with broodmap.

* Install broodmap from a vendored package until it is published to npm.

Built from ShieldBattery/broodmap#5 at 1ee4c5e. Swap the file: spec for a registry version once it's published.

* Keep watching map folders that are missing or get deleted, time out stuck map reads, and reuse a moved file's facts.

Deleting a recursively watched folder on Windows leaves its watch reporting the folder itself over and over (about 150k events a second under Electron 44), which kept resetting the reconcile debounce and pinned a core. A folder missing at startup was also never watched.

* Fail a dead map reader's requests instead of letting its error kill the index worker.
2Pacalypse- added a commit to ShieldBattery/ShieldBattery that referenced this pull request Nov 20, 2026
…with broodmap. (#1772)

* Index the maps in the StarCraft map folders in the app, reading them with broodmap.

* Install broodmap from a vendored package until it is published to npm.

Built from ShieldBattery/broodmap#5 at 1ee4c5e. Swap the file: spec for a registry version once it's published.

* Keep watching map folders that are missing or get deleted, time out stuck map reads, and reuse a moved file's facts.

Deleting a recursively watched folder on Windows leaves its watch reporting the folder itself over and over (about 150k events a second under Electron 44), which kept resetting the reconcile debounce and pinned a core. A folder missing at startup was also never watched.

* Fail a dead map reader's requests instead of letting its error kill the index worker.
2Pacalypse- added a commit to ShieldBattery/ShieldBattery that referenced this pull request Nov 21, 2026
…with broodmap. (#1772)

* Index the maps in the StarCraft map folders in the app, reading them with broodmap.

* Install broodmap from a vendored package until it is published to npm.

Built from ShieldBattery/broodmap#5 at 1ee4c5e. Swap the file: spec for a registry version once it's published.

* Keep watching map folders that are missing or get deleted, time out stuck map reads, and reuse a moved file's facts.

Deleting a recursively watched folder on Windows leaves its watch reporting the folder itself over and over (about 150k events a second under Electron 44), which kept resetting the reconcile debounce and pinned a core. A folder missing at startup was also never watched.

* Fail a dead map reader's requests instead of letting its error kill the index worker.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants