@scm-js/core 0.13.0 → 0.13.2

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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @scm-js/core 0.13.0 — StarCraft maps as the scmJS editor reads and writes them.
2
+ * @scm-js/core 0.13.2 — StarCraft maps as the scmJS editor reads and writes them.
3
3
  * Generated by `npm run build:core` in github.com/scm-js/scm-js from core/src/index.ts; the guide is docs/core.md.
4
4
  */
5
5
  import { Archive, HashEntry, StoredMember } from 'mopaq';
@@ -1231,7 +1231,7 @@ export declare function loadTileset(files: TilesetFiles): Tileset;
1231
1231
  */
1232
1232
  export declare function tileGroupOf(tileId: number, groupCount?: number): number;
1233
1233
  /** Resolve an MTXM tile id to a VX4 megatile index, or -1 when the id is out of range. */
1234
- export declare function megatileForTile(tileset: Tileset, tileId: number): number;
1234
+ export declare function megatileForTile(tileset: Pick<Tileset, "groups" | "megatileCount">, tileId: number): number;
1235
1235
  /**
1236
1236
  * Paint one 32x32 megatile as RGBA into `dest` at (dx, dy) of a `destWidth`-pixel row.
1237
1237
  * Works on a plain array, so it is equally usable against ImageData in the browser and
@@ -3244,6 +3244,74 @@ export declare function pngToGrp(png: Uint8Array, palette: NamedPalette, options
3244
3244
  export declare const GAME_FOLDERS: string[];
3245
3245
  /** A path as the game names it: backslashes, lower case (`arr\units.dat`). Two paths are one file when these agree. */
3246
3246
  export declare const gameName: (path: string) => string;
3247
+ /**
3248
+ * Files an operating system or its file manager leaves in folders, and into the archives and zips made of them: never
3249
+ * the game's, so never a mod's. Told by name alone, any case — the last part of a path, or a folder on the way to it:
3250
+ *
3251
+ * - `desktop.ini`: Windows Explorer's settings for a folder (its view, its icon);
3252
+ * - `Thumbs.db`, `ehthumbs.db`, `ehthumbs_vista.db`: Explorer's and Media Center's caches of thumbnails;
3253
+ * - `.DS_Store`: the macOS Finder's settings for a folder; `Icon\r`: a folder's own icon there;
3254
+ * - `._<name>`: the AppleDouble half of a file, which macOS writes beside it on a disk that is not its own and into
3255
+ * every zip it makes; `__MACOSX/`: the folder those zips keep them in;
3256
+ * - `.directory`: KDE's settings for a folder.
3257
+ *
3258
+ * A mod's hash has no line for one (`hash.ts`), and what reads a mod leaves them out of its files. Why it matters:
3259
+ * the same folder is not handed over alike by every route. A browser's folder handle (the folder picker, a dropped
3260
+ * folder read through its handle) never hands over `desktop.ini` or `Thumbs.db`: Chromium's
3261
+ * `FileSystemAccessManagerImpl::IsSafePathComponent` refuses the names `base::IsReservedNameOnWindows` lists, on every
3262
+ * system. A drop read through its entries, an `<input webkitdirectory>` and the command line hand them over. With
3263
+ * these files in the hash a mod was named by how its folder had been read.
3264
+ *
3265
+ * Only names that are certain never to be a game file are here. A handle hides more than these (`.lnk`, `.url` and
3266
+ * `.scf` files, Windows' device names such as `aux.wav`, names that begin or end with a space, a dot or `~`, and on
3267
+ * Windows, by Chromium's table of file types, every `.ini`, `.cfg`, `.dll` and `.manifest`): those may be a mod's own
3268
+ * files, so they keep their lines, and a route that cannot read one has a mod short of that file and says so with
3269
+ * another hash.
3270
+ */
3271
+ export declare const SYSTEM_FILES: {
3272
+ /** File names, lower case. */
3273
+ readonly names: readonly [
3274
+ "desktop.ini",
3275
+ "thumbs.db",
3276
+ "ehthumbs.db",
3277
+ "ehthumbs_vista.db",
3278
+ ".ds_store",
3279
+ "icon\r",
3280
+ ".directory"
3281
+ ];
3282
+ /** What a file name starts with. */
3283
+ readonly prefixes: readonly [
3284
+ "._"
3285
+ ];
3286
+ /** Folder names, lower case: everything under one. */
3287
+ readonly folders: readonly [
3288
+ "__macosx"
3289
+ ];
3290
+ };
3291
+ /** Whether a path (either slash, any case) is one of `SYSTEM_FILES`: by its file name, or by a folder it is under. */
3292
+ export declare function isSystemFile(path: string): boolean;
3293
+ /** The game's own archives, by file name (lower case): what a 1.16.1 installation holds beside its program. */
3294
+ export declare const GAME_ARCHIVES: readonly [
3295
+ "stardat.mpq",
3296
+ "broodat.mpq",
3297
+ "patch_rt.mpq",
3298
+ "starcraft.mpq",
3299
+ "broodwar.mpq"
3300
+ ];
3301
+ /**
3302
+ * The files among `paths` (forward slashes) that are a copy of the game's own and so no part of a mod: in every folder
3303
+ * that holds a `StarDat.mpq`, that folder's `GAME_ARCHIVES` and every file under its `Maps` folder.
3304
+ *
3305
+ * A copy of the game in what was handed over is not the mod. A person hands over a folder that holds the mod's release
3306
+ * and, beside it, the whole game the mod runs on (Cosmonarchy's download: `Release/` and `Starcraft/`); laid as layers
3307
+ * of the mod, the game's archives became "the mod's" files, and in Windows' folder order `StarDat.mpq` came last and
3308
+ * carried original StarCraft's tables and iscript over Brood War's. A copy's `Maps` folder is the person's maps folder:
3309
+ nothing under it is a mod's (Cosmonarchy's copy keeps campaigns at `Maps/CMBW-Root/CMBW-maps/campaign/…`, and
3310
+ `campaign` is one of the game's folders, so they were taken for a mod's root). Apply it to each list a walk is given (a folder's
3311
+ * files, a zip's members), never to a single file the person names: some old mods ship as a replaced `patch_rt.mpq`.
3312
+ * The same rule is in the play page and the Mod Editor plugin: change them together.
3313
+ */
3314
+ export declare function gameCopyFiles(paths: readonly string[]): Set<string>;
3247
3315
  /**
3248
3316
  * The folder of a set of paths the game's paths start in: the one that holds `arr/`, else the one holding the most
3249
3317
  * files under the game's folders, the shallower on a tie; "" is the root. Paths use forward slashes. At any depth, as
@@ -3285,9 +3353,9 @@ export declare class ModSourceError extends Error {
3285
3353
  export declare function readZip(b: Uint8Array): ZipMember[];
3286
3354
  /**
3287
3355
  * The hash of game files alone, by the mod hash's rule (`hash.ts`): a line `name<TAB>sha256` a file (the game's name,
3288
- * lower case with backslashes), sorted by name, joined with newlines, hashed again; the first sixteen hex digits. A
3289
- * mod's hash also has lines for its plugins and FireGraft project: `modHash` / `modHashOfDigests` in `hash.ts`; for a
3290
- * mod without either the two agree.
3356
+ * lower case with backslashes), sorted by name, joined with newlines, hashed again; the first sixteen hex digits. An
3357
+ * operating system's files (`isSystemFile`) have no line. A mod's hash also has lines for its plugins and FireGraft
3358
+ * project: `modHash` / `modHashOfDigests` in `hash.ts`; for a mod without either the two agree.
3291
3359
  */
3292
3360
  export declare function dataSetHash(files: readonly {
3293
3361
  name: string;
@@ -3312,8 +3380,18 @@ export declare const pluginLine: (name: string, sha256: string) => string;
3312
3380
  export declare const firegraftLine: (name: string, sha256: string) => string;
3313
3381
  /** A game file's line: its game name. */
3314
3382
  export declare const gameLine: (name: string, sha256: string) => string;
3315
- /** The hash of lines `name<TAB>sha256` in any order: sorted by name, joined with "\n", SHA-256, sixteen hex digits. */
3383
+ /** Whether a line `name<TAB>sha256` is of an operating system's file (`isSystemFile`), which the hash has no line for. */
3384
+ export declare const isSystemLine: (line: string) => boolean;
3385
+ /**
3386
+ * The hash of lines `name<TAB>sha256` in any order: sorted by name, joined with "\n", SHA-256, sixteen hex digits. A
3387
+ * line of an operating system's file (`isSystemLine`) is dropped first.
3388
+ */
3316
3389
  export declare function hashLines(lines: readonly string[]): Promise<string>;
3390
+ /**
3391
+ * `hashLines` as it was until 2026-11-09: every line given, an operating system's files among them. For matching a
3392
+ * hash made then (a replay's tag, a mod kept in a browser), never for naming a mod now.
3393
+ */
3394
+ export declare function hashLinesAsWere(lines: readonly string[]): Promise<string>;
3317
3395
  /** A file by its name and its bytes' SHA-256 (`fileDigest`). */
3318
3396
  export interface Digest {
3319
3397
  name: string;
@@ -3336,11 +3414,20 @@ export interface ModHash {
3336
3414
  lines: string[];
3337
3415
  /** The plugins' lines (sorted). */
3338
3416
  pluginLines: string[];
3417
+ /**
3418
+ * There when an operating system's files were among what was given (`isSystemFile`): the mod's hashes as they were
3419
+ * while those files had lines (`hashLinesAsWere`), and the names left out. Matched as an older form, never presented.
3420
+ */
3421
+ older?: {
3422
+ hash: string;
3423
+ withoutPlugins: string;
3424
+ left: string[];
3425
+ };
3339
3426
  }
3340
3427
  /**
3341
3428
  * The mod's hash and its hash without plugins. Game files are taken once by game name (the last given wins, as a
3342
3429
  * later layer does in the game); plugins and FireGraft projects once by file name, any case (the first given wins,
3343
- * as on the play page).
3430
+ * as on the play page). An operating system's files have no line, and `older` says what the hashes were with them.
3344
3431
  */
3345
3432
  export declare function modHashOfDigests(input: ModHashInput): Promise<ModHash>;
3346
3433
  /** `modHashOfDigests` from the files' bytes. */
package/dist/index.mjs CHANGED
@@ -9186,7 +9186,6 @@ async function writeMapBytes(scenario, options) {
9186
9186
  }
9187
9187
  var MEGATILE_PX = 32;
9188
9188
  var MINITILE_BYTES = 64;
9189
- var CV5_ENTRY_BYTES = 52;
9190
9189
  var CV5_MEGATILE_OFFSET = 20;
9191
9190
  var MEGATILES_PER_GROUP = 16;
9192
9191
  /** WPE is 256 entries of R,G,B,pad. Expanded to RGBA with a fully opaque alpha. */
@@ -9203,10 +9202,10 @@ function decodePalette(wpe) {
9203
9202
  }
9204
9203
  function decodeCv5(cv5) {
9205
9204
  const view = new DataView(cv5.buffer, cv5.byteOffset, cv5.byteLength);
9206
- const count = Math.floor(cv5.length / CV5_ENTRY_BYTES);
9205
+ const count = Math.floor(cv5.length / 52);
9207
9206
  const groups = Array.from({ length: count });
9208
9207
  for (let g = 0; g < count; g++) {
9209
- const at = g * CV5_ENTRY_BYTES;
9208
+ const at = g * 52;
9210
9209
  const megatiles = new Uint16Array(MEGATILES_PER_GROUP);
9211
9210
  for (let m = 0; m < MEGATILES_PER_GROUP; m++) megatiles[m] = view.getUint16(at + CV5_MEGATILE_OFFSET + m * 2, true);
9212
9211
  const index = view.getUint16(at, true);
@@ -9958,7 +9957,8 @@ function statisticsText(s) {
9958
9957
  * eight tilesets, and with them tile groups the 1.16 tables do not hold: every group past
9959
9958
  * the end of the 1.16 table, and on three tilesets a run of groups below 1024 that 1.16
9960
9959
  * had left empty and Remastered filled. A map that uses one of these tiles is drawn only
9961
- * from Remastered's files.
9960
+ * from Remastered's files. A group past Remastered's table too is no StarCraft's: the map
9961
+ * was made on a mod's tileset (Cosmonarchy's Jungle has 4,095 groups).
9962
9962
  *
9963
9963
  * The figures are the tile tables' own, measured from both sets of files
9964
9964
  * (`tests/remastered.test.ts` checks them against the real ones when it can): per tileset,
@@ -10009,13 +10009,51 @@ var GROUPS = [
10009
10009
  ];
10010
10010
  /** Doodad groups start here; the groups below are terrain, which is where 1.16 had room left. */
10011
10011
  var FIRST_DOODAD_GROUP = 1024;
10012
+ /** The group counts and filled range for a tileset, by its ERA index. */
10013
+ function tileGroupRanges(era) {
10014
+ const [classic, remastered, filledFrom] = GROUPS[era & 7];
10015
+ return {
10016
+ classic,
10017
+ remastered,
10018
+ filledFrom
10019
+ };
10020
+ }
10021
+ /**
10022
+ * The group an MTXM value names with all twelve bits above the slot, bit 15 included: what a
10023
+ * mod's extended tileset reads (`decode.ts#tileGroupOf` past 2,048 groups). The game's own
10024
+ * tilesets take bit 15 as the creep flag, but maps made for them do not set it (of some 600
10025
+ * on hand, Blizzard's and the ladder's, only a probe made to test the flag does), while a
10026
+ * map made on a mod's extended tileset sets it on every tile past group 2,047 (291 of
10027
+ * Cosmonarchy's 404 maps). So the questions here — whose tile is this, and has
10028
+ * the data set in use got it — are asked of the whole group; drawing keeps the game's rule.
10029
+ */
10030
+ var fullGroup = (tile) => tile >> 4 & 4095;
10012
10031
  /** Whether a tile (an MTXM value) is one only Remastered's tables have, on the tileset with ERA index `era`. */
10013
10032
  function isRemasteredOnlyTile(era, tile) {
10014
- const group = tile >> 4 & 2047;
10033
+ const group = fullGroup(tile);
10015
10034
  const [classic, remastered, filledFrom] = GROUPS[era & 7];
10016
10035
  if (group >= classic) return group < remastered;
10017
10036
  return group >= filledFrom && group < FIRST_DOODAD_GROUP;
10018
10037
  }
10038
+ /**
10039
+ * Whether a tile's group is past Remastered's table too: terrain no StarCraft has, in 1.16.1
10040
+ * or Remastered, so the map was made on a mod's tileset.
10041
+ */
10042
+ function isModTile(era, tile) {
10043
+ return fullGroup(tile) >= GROUPS[era & 7][1];
10044
+ }
10045
+ /**
10046
+ * Whether a tileset of `groups` groups (the one the data set in use gave for ERA `era`) has
10047
+ * the tile. A group past its table it has not; nor, when its table is shorter than
10048
+ * Remastered's, one of the low groups 1.16 left empty and Remastered filled, which a 1.16
10049
+ * table holds with no picture.
10050
+ */
10051
+ function tilesetHasTile(era, tile, groups) {
10052
+ const group = fullGroup(tile);
10053
+ if (group >= groups) return false;
10054
+ const [classic, remastered] = GROUPS[era & 7];
10055
+ return !(group < classic && groups < remastered && isRemasteredOnlyTile(era, tile));
10056
+ }
10019
10057
  //#endregion
10020
10058
  //#region src/editor/stockSounds.ts
10021
10059
  /** Every sound the game ships lives under this folder of its archives. */
@@ -10931,10 +10969,22 @@ function validateScenario(scn, ctx = {}) {
10931
10969
  const { rects, mismatched, inherent } = ctx.isom.report;
10932
10970
  add("warn", t("ISOM is behind the tiles on {pct}% of the map (the Repair plugin rebuilds it: Tools ▸ Repair Map…).", { pct: Math.round((mismatched - inherent) / Math.max(1, rects) * 100) }), msg("Terrain"));
10933
10971
  }
10934
- let creep = 0, outside = 0, firstOutside = -1;
10972
+ const groups = ctx.tileset?.groups.length;
10973
+ const hasTile = (tile) => groups !== void 0 && tilesetHasTile(era, tile, groups);
10974
+ const modTable = groups !== void 0 && groups > tileGroupRanges(era).remastered;
10975
+ let creep = 0, outside = 0, firstOutside = -1, mod = 0, firstMod = -1, added = 0, first = -1;
10935
10976
  for (let i = 0; i < scn.tiles.length; i++) {
10936
- if (hasCreepFlag(scn.tiles[i], ctx.tileset?.groups.length)) creep++;
10937
- if (ctx.tileset && tileGroupOf(scn.tiles[i], ctx.tileset.groups.length) >= ctx.tileset.groups.length && !isRemasteredOnlyTile(era, scn.tiles[i])) {
10977
+ const tile = scn.tiles[i];
10978
+ if (hasCreepFlag(tile, groups)) creep++;
10979
+ if (isModTile(era, tile)) {
10980
+ if (hasTile(tile)) continue;
10981
+ if (firstMod < 0) firstMod = i;
10982
+ mod++;
10983
+ } else if (isRemasteredOnlyTile(era, tile)) {
10984
+ if (modTable && hasTile(tile)) continue;
10985
+ if (first < 0) first = i;
10986
+ added++;
10987
+ } else if (groups !== void 0 && tileGroupOf(tile, groups) >= groups) {
10938
10988
  if (firstOutside < 0) firstOutside = i;
10939
10989
  outside++;
10940
10990
  }
@@ -10945,12 +10995,14 @@ function validateScenario(scn, ctx = {}) {
10945
10995
  x: firstOutside % scn.width,
10946
10996
  y: Math.floor(firstOutside / scn.width)
10947
10997
  }), msg("Terrain"));
10948
- let added = 0, first = -1;
10949
- for (let i = 0; i < scn.tiles.length; i++) {
10950
- if (!isRemasteredOnlyTile(era, scn.tiles[i])) continue;
10951
- if (first < 0) first = i;
10952
- added++;
10953
- }
10998
+ if (mod > 0) add("warn", t("{n, plural, one {# tile is} other {# tiles are}} terrain StarCraft has not got, in 1.16.1 or Remastered (the first at {x}, {y}). The map was made for a mod, and it draws and plays as made only with that mod's files.", {
10999
+ n: mod,
11000
+ x: firstMod % scn.width,
11001
+ y: Math.floor(firstMod / scn.width)
11002
+ }), msg("Terrain"), {
11003
+ kind: "dialog",
11004
+ id: "gameData"
11005
+ });
10954
11006
  if (added > 0) add("info", t("{n, plural, one {# tile is} other {# tiles are}} from what StarCraft: Remastered added to this tileset (the first at {x}, {y}). The map draws in full only with Remastered's game data, and the 1.16 game's files do not have these tiles.", {
10955
11007
  n: added,
10956
11008
  x: first % scn.width,
@@ -19698,6 +19750,91 @@ var GAME_FOLDERS = [
19698
19750
  /** A path as the game names it: backslashes, lower case (`arr\units.dat`). Two paths are one file when these agree. */
19699
19751
  var gameName = (path) => path.replace(/\//g, "\\").replace(/^\\+/, "").toLowerCase();
19700
19752
  /**
19753
+ * Files an operating system or its file manager leaves in folders, and into the archives and zips made of them: never
19754
+ * the game's, so never a mod's. Told by name alone, any case — the last part of a path, or a folder on the way to it:
19755
+ *
19756
+ * - `desktop.ini`: Windows Explorer's settings for a folder (its view, its icon);
19757
+ * - `Thumbs.db`, `ehthumbs.db`, `ehthumbs_vista.db`: Explorer's and Media Center's caches of thumbnails;
19758
+ * - `.DS_Store`: the macOS Finder's settings for a folder; `Icon\r`: a folder's own icon there;
19759
+ * - `._<name>`: the AppleDouble half of a file, which macOS writes beside it on a disk that is not its own and into
19760
+ * every zip it makes; `__MACOSX/`: the folder those zips keep them in;
19761
+ * - `.directory`: KDE's settings for a folder.
19762
+ *
19763
+ * A mod's hash has no line for one (`hash.ts`), and what reads a mod leaves them out of its files. Why it matters:
19764
+ * the same folder is not handed over alike by every route. A browser's folder handle (the folder picker, a dropped
19765
+ * folder read through its handle) never hands over `desktop.ini` or `Thumbs.db`: Chromium's
19766
+ * `FileSystemAccessManagerImpl::IsSafePathComponent` refuses the names `base::IsReservedNameOnWindows` lists, on every
19767
+ * system. A drop read through its entries, an `<input webkitdirectory>` and the command line hand them over. With
19768
+ * these files in the hash a mod was named by how its folder had been read.
19769
+ *
19770
+ * Only names that are certain never to be a game file are here. A handle hides more than these (`.lnk`, `.url` and
19771
+ * `.scf` files, Windows' device names such as `aux.wav`, names that begin or end with a space, a dot or `~`, and on
19772
+ * Windows, by Chromium's table of file types, every `.ini`, `.cfg`, `.dll` and `.manifest`): those may be a mod's own
19773
+ * files, so they keep their lines, and a route that cannot read one has a mod short of that file and says so with
19774
+ * another hash.
19775
+ */
19776
+ var SYSTEM_FILES = {
19777
+ /** File names, lower case. */
19778
+ names: [
19779
+ "desktop.ini",
19780
+ "thumbs.db",
19781
+ "ehthumbs.db",
19782
+ "ehthumbs_vista.db",
19783
+ ".ds_store",
19784
+ "icon\r",
19785
+ ".directory"
19786
+ ],
19787
+ /** What a file name starts with. */
19788
+ prefixes: ["._"],
19789
+ /** Folder names, lower case: everything under one. */
19790
+ folders: ["__macosx"]
19791
+ };
19792
+ /** Whether a path (either slash, any case) is one of `SYSTEM_FILES`: by its file name, or by a folder it is under. */
19793
+ function isSystemFile(path) {
19794
+ const parts = path.toLowerCase().split(/[\\/]/).filter(Boolean);
19795
+ const leaf = parts.pop() ?? "";
19796
+ return SYSTEM_FILES.names.includes(leaf) || SYSTEM_FILES.prefixes.some((p) => leaf.startsWith(p)) || parts.some((folder) => SYSTEM_FILES.folders.includes(folder));
19797
+ }
19798
+ /** The game's own archives, by file name (lower case): what a 1.16.1 installation holds beside its program. */
19799
+ var GAME_ARCHIVES = [
19800
+ "stardat.mpq",
19801
+ "broodat.mpq",
19802
+ "patch_rt.mpq",
19803
+ "starcraft.mpq",
19804
+ "broodwar.mpq"
19805
+ ];
19806
+ /**
19807
+ * The files among `paths` (forward slashes) that are a copy of the game's own and so no part of a mod: in every folder
19808
+ * that holds a `StarDat.mpq`, that folder's `GAME_ARCHIVES` and every file under its `Maps` folder.
19809
+ *
19810
+ * A copy of the game in what was handed over is not the mod. A person hands over a folder that holds the mod's release
19811
+ * and, beside it, the whole game the mod runs on (Cosmonarchy's download: `Release/` and `Starcraft/`); laid as layers
19812
+ * of the mod, the game's archives became "the mod's" files, and in Windows' folder order `StarDat.mpq` came last and
19813
+ * carried original StarCraft's tables and iscript over Brood War's. A copy's `Maps` folder is the person's maps folder:
19814
+ nothing under it is a mod's (Cosmonarchy's copy keeps campaigns at `Maps/CMBW-Root/CMBW-maps/campaign/…`, and
19815
+ `campaign` is one of the game's folders, so they were taken for a mod's root). Apply it to each list a walk is given (a folder's
19816
+ * files, a zip's members), never to a single file the person names: some old mods ship as a replaced `patch_rt.mpq`.
19817
+ * The same rule is in the play page and the Mod Editor plugin: change them together.
19818
+ */
19819
+ function gameCopyFiles(paths) {
19820
+ const dir = (p) => p.slice(0, Math.max(0, p.lastIndexOf("/")));
19821
+ const leaf = (p) => p.slice(p.lastIndexOf("/") + 1).toLowerCase();
19822
+ const copies = new Set(paths.filter((p) => leaf(p) === "stardat.mpq").map((p) => dir(p).toLowerCase()));
19823
+ const out = /* @__PURE__ */ new Set();
19824
+ if (!copies.size) return out;
19825
+ for (const p of paths) {
19826
+ if (copies.has(dir(p).toLowerCase()) && GAME_ARCHIVES.includes(leaf(p))) {
19827
+ out.add(p);
19828
+ continue;
19829
+ }
19830
+ for (const c of copies) if (p.toLowerCase().startsWith(c ? `${c}/maps/` : "maps/")) {
19831
+ out.add(p);
19832
+ break;
19833
+ }
19834
+ }
19835
+ return out;
19836
+ }
19837
+ /**
19701
19838
  * The folder of a set of paths the game's paths start in: the one that holds `arr/`, else the one holding the most
19702
19839
  * files under the game's folders, the shallower on a tie; "" is the root. Paths use forward slashes. At any depth, as
19703
19840
  * the play page looks (a zip's `Mod 1.2/mpq/arr/…`); a game folder's name deeper in a root (`unit/terran/unit/`)
@@ -19851,9 +19988,9 @@ var hex = (b) => [...new Uint8Array(b)].map((x) => x.toString(16).padStart(2, "0
19851
19988
  var sha256 = async (bytes) => hex(await crypto.subtle.digest("SHA-256", bytes));
19852
19989
  /**
19853
19990
  * The hash of game files alone, by the mod hash's rule (`hash.ts`): a line `name<TAB>sha256` a file (the game's name,
19854
- * lower case with backslashes), sorted by name, joined with newlines, hashed again; the first sixteen hex digits. A
19855
- * mod's hash also has lines for its plugins and FireGraft project: `modHash` / `modHashOfDigests` in `hash.ts`; for a
19856
- * mod without either the two agree.
19991
+ * lower case with backslashes), sorted by name, joined with newlines, hashed again; the first sixteen hex digits. An
19992
+ * operating system's files (`isSystemFile`) have no line. A mod's hash also has lines for its plugins and FireGraft
19993
+ * project: `modHash` / `modHashOfDigests` in `hash.ts`; for a mod without either the two agree.
19857
19994
  */
19858
19995
  async function dataSetHash(files) {
19859
19996
  const digests = [];
@@ -19867,7 +20004,7 @@ async function dataSetHash(files) {
19867
20004
  var fileDigest = (bytes) => sha256(bytes);
19868
20005
  /** `dataSetHash` from each file's `fileDigest` rather than its bytes: the same rule, the same hash. */
19869
20006
  async function dataSetHashOfDigests(files) {
19870
- const lines = files.map((f) => ({
20007
+ const lines = files.filter((f) => !isSystemFile(f.name)).map((f) => ({
19871
20008
  name: gameName(f.name),
19872
20009
  sha256: f.sha256
19873
20010
  })).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0).map((f) => `${f.name}\t${f.sha256}`);
@@ -19891,6 +20028,18 @@ async function dataSetHashOfDigests(files) {
19891
20028
  * the first sixteen hex digits of their SHA-256. A page that does not run the plugins presents the hash of the lines
19892
20029
  * without the plugins' ("without plugins").
19893
20030
  *
20031
+ * **No line for an operating system's files** (`sources.ts#SYSTEM_FILES`: `desktop.ini`, `Thumbs.db`, `.DS_Store`, a
20032
+ * zip's `__MACOSX/` and the rest of that list), wherever one lies: loose in a game folder, or a member of an archive
20033
+ * that was packed from such a folder. The game never asks for one, and not every route hands them over (a browser's
20034
+ * folder handle hides `desktop.ini`), so with them a mod's hash followed how its folder was read. `hashLines` drops
20035
+ * such lines itself, so the hash is the same whatever list a caller made; the readers leave the files out too, so the
20036
+ * counts agree.
20037
+ *
20038
+ * **The older form.** Until 2026-11-09 those files had lines. A mod kept in a browser and a replay tagged before then
20039
+ * name the mod by that hash, so where hashes are matched it is still accepted: `hashLinesAsWere` is the rule as it
20040
+ * was, and `ModHash.older` the mod's hashes by it, there only when the files were seen (a route that never saw them
20041
+ * cannot work the older hash out).
20042
+ *
19894
20043
  * Pure: the command line, the editor's worker and any page share it.
19895
20044
  */
19896
20045
  /** A plugin a mod carries: MPQDraft's `.qdp`, Chaoslauncher's `.bwl`. */
@@ -19906,37 +20055,66 @@ var pluginLine = (name, sha256) => `plugins\\${leafOf$1(name).toLowerCase()}\t${
19906
20055
  var firegraftLine = (name, sha256) => `${leafOf$1(name).toLowerCase()}\t${sha256}`;
19907
20056
  /** A game file's line: its game name. */
19908
20057
  var gameLine = (name, sha256) => `${gameName(name)}\t${sha256}`;
19909
- /** The hash of lines `name<TAB>sha256` in any order: sorted by name, joined with "\n", SHA-256, sixteen hex digits. */
20058
+ var lineName = (l) => l.slice(0, l.indexOf(" "));
20059
+ /** Whether a line `name<TAB>sha256` is of an operating system's file (`isSystemFile`), which the hash has no line for. */
20060
+ var isSystemLine = (line) => isSystemFile(lineName(line));
20061
+ /**
20062
+ * The hash of lines `name<TAB>sha256` in any order: sorted by name, joined with "\n", SHA-256, sixteen hex digits. A
20063
+ * line of an operating system's file (`isSystemLine`) is dropped first.
20064
+ */
19910
20065
  async function hashLines(lines) {
19911
- const name = (l) => l.slice(0, l.indexOf(" "));
19912
- const sorted = [...lines].sort((a, b) => name(a) < name(b) ? -1 : name(a) > name(b) ? 1 : 0);
20066
+ return hashLinesAsWere(lines.filter((l) => !isSystemLine(l)));
20067
+ }
20068
+ /**
20069
+ * `hashLines` as it was until 2026-11-09: every line given, an operating system's files among them. For matching a
20070
+ * hash made then (a replay's tag, a mod kept in a browser), never for naming a mod now.
20071
+ */
20072
+ async function hashLinesAsWere(lines) {
20073
+ const sorted = [...lines].sort((a, b) => lineName(a) < lineName(b) ? -1 : lineName(a) > lineName(b) ? 1 : 0);
19913
20074
  return (await fileDigest(new TextEncoder().encode(sorted.join("\n")))).slice(0, 16);
19914
20075
  }
19915
20076
  /**
19916
20077
  * The mod's hash and its hash without plugins. Game files are taken once by game name (the last given wins, as a
19917
20078
  * later layer does in the game); plugins and FireGraft projects once by file name, any case (the first given wins,
19918
- * as on the play page).
20079
+ * as on the play page). An operating system's files have no line, and `older` says what the hashes were with them.
19919
20080
  */
19920
20081
  async function modHashOfDigests(input) {
19921
20082
  const game = /* @__PURE__ */ new Map();
19922
- for (const f of input.files) game.set(gameName(f.name), f.sha256);
20083
+ for (const f of input.files) game.set(gameName(f.name), {
20084
+ sha256: f.sha256,
20085
+ system: isSystemFile(f.name)
20086
+ });
19923
20087
  const once = (list, keep, line) => {
19924
20088
  const seen = /* @__PURE__ */ new Set(), out = [];
19925
20089
  for (const f of list) {
19926
20090
  const key = leafOf$1(f.name).toLowerCase();
19927
20091
  if (!keep(f.name) || seen.has(key)) continue;
19928
20092
  seen.add(key);
19929
- out.push(line(f.name, f.sha256));
20093
+ out.push({
20094
+ line: line(f.name, f.sha256),
20095
+ system: isSystemFile(f.name)
20096
+ });
19930
20097
  }
19931
20098
  return out;
19932
20099
  };
19933
- const lines = [...[...game].map(([name, sha]) => `${name}\t${sha}`), ...once(input.firegraft ?? [], isFiregraftProject, firegraftLine)].sort();
19934
- const pluginLines = once(input.plugins ?? [], isPluginFile, pluginLine).sort();
20100
+ const byLine = (a, b) => a.line < b.line ? -1 : a.line > b.line ? 1 : 0;
20101
+ const were = [...[...game].map(([name, f]) => ({
20102
+ line: `${name}\t${f.sha256}`,
20103
+ system: f.system
20104
+ })), ...once(input.firegraft ?? [], isFiregraftProject, firegraftLine)].sort(byLine);
20105
+ const pluginsWere = once(input.plugins ?? [], isPluginFile, pluginLine).sort(byLine);
20106
+ const lines = were.filter((l) => !l.system).map((l) => l.line), pluginLines = pluginsWere.filter((l) => !l.system).map((l) => l.line);
20107
+ const left = [...were, ...pluginsWere].filter((l) => l.system).map((l) => lineName(l.line));
19935
20108
  return {
19936
20109
  hash: await hashLines([...lines, ...pluginLines]),
19937
20110
  withoutPlugins: await hashLines(lines),
19938
20111
  lines,
19939
- pluginLines
20112
+ pluginLines,
20113
+ ...left.length ? { older: {
20114
+ hash: await hashLinesAsWere([...were, ...pluginsWere].map((l) => l.line)),
20115
+ withoutPlugins: await hashLinesAsWere(were.map((l) => l.line)),
20116
+ left
20117
+ } } : {}
19940
20118
  };
19941
20119
  }
19942
20120
  /** `modHashOfDigests` from the files' bytes. */
@@ -21801,4 +21979,4 @@ function canonicalSpec(source) {
21801
21979
  return source.kind === "builtin" ? `builtin:${source.name}` : source.display;
21802
21980
  }
21803
21981
  //#endregion
21804
- export { ACTION_DEFS, AI_ENUMS, AI_FLAGS, AI_OPCODES, AI_SCRIPT_FLAGS, AI_SCRIPT_NAMES, ANYWHERE_NAME, ActionType, AiScriptTextError, BRIEFING_ACTION_DEFS, BUILD_MANIFEST_MEMBER, BUILD_SOURCE_MEMBER, CHOICES, CONDITION_DEFS, ColorMode, Comparison, ConditionType, DAT_SCHEMAS, DAT_TABLES, DEFAULT_DOODAD_PLACEMENT, DEFAULT_GAS, DEFAULT_MINERALS, DEFAULT_PALETTE, DEFAULT_PLACEMENT, DEFAULT_SAVE_OPTIONS, DEFAULT_START_PLACEMENT, DEFAULT_TEXT_ENCODING, DIRT, DatTextError, FIND_KINDS, FORCE_SLOTS, ForceFlag, GAME_FOLDERS, GAME_ISCRIPT_LAST, GraftTextError, ISCRIPT_ANIMS, ISCRIPT_OPCODES, ISCRIPT_TYPE_ANIMS, IscriptTextError, MAP_SIZES, MAP_VERSIONS, MEGATILE_PX, MINERAL_FIELD_IDS, MODELLED_SECTIONS, MOD_FOLDERS, MOD_FORMAT, MOD_MANIFEST, MapLoadError, ModFolderError, ModSourceError, NAME_TEXT_FILES, PLAYER_COLORS, PLAYER_RACES, PLAYER_SLOTS, PLAYER_TYPES, PLUGIN_API_VERSION, PlayerGroup, PlayerRace, PlayerType, REQUIRED_SECTIONS, ResourceType, SAVE_PRESETS, SCENARIO_PATH, START_LOCATION, STRX_CAPACITY, SetModifier, SwitchAction, SwitchState, TECH_NAMES, TEXT_CODES, TEXT_ENCODINGS, TILESETS, TILESET_BY_ID, TRIGGER_OWNERS, TileFlag, TriggerTextError, UNIT_LIMIT, UNIT_NAMES, UNIT_TYPE_COUNT, UPGRADE_NAMES, UnitClass, UnitUsed, VESPENE_GEYSER, WAV_FORMAT, WEAPON_NAMES, actionDef, actionDefByName, addLocation, addUnits, aiNames, aiScriptByName, aiScriptName, aiStringText, aiscriptFromText, aiscriptToText, applyBriefing, applyChanges, applyDoodadChanges, applyForceSettings, applyLocationChanges, applyPlayerSettings, applySounds, applyStringImport, applyStrings, applyTechSettings, applyTriggers, applyUnitChanges, applyUnitSettings, applyUpgradeSettings, baseTerrain, buildChk, buildDoodadCatalogue, buildMapFile, buttonGraftFromText, buttonGraftToText, canDecodeWav, changeMapVersion, changeTextEncoding, checkDoodadPlacement, checkIsom, checkMod, choiceLabel, choiceValue, conditionDef, conditionDefByName, createScenario, datEntrySize, datFromRows, datFromText, datHas, datRow, datRows, datShape, datStandardSize, datTableOf, datToText, dataSetHash, dataSetHashOfDigests, decodeButtonGraft, decodeDat, decodeFlingyDat, decodeGrpImage, decodeImaAdpcm, decodeImagesDat, decodeIscript, decodeLoFile, decodePcmWav, decodePcxImage, decodePng, decodeReqGraft, decodeSpritesDat, decodeTblFile, decodeText, decodeTrg, decodeUnitsDat, decodeWav, defaultSaveOptions, defaultTechRestrictions, defaultTechSettings, defaultUnitAvailability, defaultUnitSettings, defaultUpgradeRestrictions, defaultUpgradeSettings, deflate, deleteUnused, diamondAt, diffMods, displayColorHex, drawMegatile, editLocation, emptyDat, emptyManifest, encodeButtonGraft, encodeDat, encodeGrpFrame, encodeGrpImage, encodeGrpLine, encodeLoFile, encodePcxImage, encodePng, encodeReqGraft, encodeSection, encodeTblFile, encodeTrg, encodeWav, entryText, escapeStringText, exeArchive, extraKind, fieldType, fileDigest, findInScenario, fingerprintTrigger, firegraftLine, flatRow, flatTerrain, folderPath, forceName, formatBytes, formatOf, formatStringTable, formatTrigger, formatTriggers, frameFromPicture, framePicture, gameLine, gameName, groupBuildable, grpToPng, hasIsom, hashLines, idealStarts, inflate, internString, isExe, isExpansion, isFiregraftProject, isModCode, isMpq, isPlainPcm, isPluginFile, isPng, isPreserved, isRemasteredRevision, isResource, isZip, iscriptEntryCount, iscriptFromText, iscriptToText, isomTables, issueCounts, keptExtras, loFromText, loToText, loadMap, loadModData, loadTileset, locationCapacity, locationName, locationSlots, looksLikeMpq, makeUnit, mapStatistics, mapVersionOf, markDirty, megatileForTile, megatileHeight, memberInfo, memberOf, memberPath, mirroredOwner, modHash, modHashOfDigests, modRoot, moveLocations, moveUnits, nameFileText, nameList, namesOf, newAction, newCondition, newTrigger, nextSerial, opaqueBox, openMapBytes, ownEntry, packBuiltMap, packFile, paintIsom, paintIsomDiamonds, parseChk, parseDatText, parseScenario, parseStringTable, parseTriggers, parseWavHeader, placeDoodad, placeOf, placeStartLocations, placedLocations, plainText, planSave, playableCount, playerColorHex, playerRaceLabel, playerTypeLabel, pluginLine, pngToGrp, probeNames, programEnd, readArchive, readBriefing, readBuildManifest, readExtras, readForceSettings, readIscriptHeaders, readManifest, readMembers, readPlayerSettings, readStrings, readSwitchNames, readTechSettings, readTriggerFile, readTriggers, readUnitSettings, readUpgradeSettings, readWavs, readZip, recordRendered, removeLocations, removeUnits, renderAiScripts, renderMember, reqGraftFromText, reqGraftToText, requiredSections, resizeScenario, resolveIcon, restoreBuiltMap, rowChanges, runsOf, sameTriggers, scenarioDescription, scenarioName, serializeChk, serializeScenario, setDatRow, setExtendedStrings, setMapVersion, setPreserved, setScenarioDescription, setScenarioName, setTextEncoding, sheetColumns, soundList, statTextEntries, statWithText, statisticsText, storedRange, stringCapacity, stringUsages, summarizeTrigger, symmetryImages, tblEscape, tblFromText, tblToText, tblUnescape, techName, techRestrictionSections, techSettingsSections, textCode, tidyManifest, tileGroupOf, tilesetIndex, triggerComment, triggerFormatOf, triggerNames, triggerReferences, triggerUsage, triggersFromText, triggersToText, unescapeStringText, unitAt, unitCustomName, unitGeometry, unitName, unitSettingsSections, unitsInBox, unusedStrings, updateUnits, upgradeName, upgradeRestrictionSections, upgradeSettingsSections, usedLocations, validateManifest, validateScenario, walkSpeed, wavCodecName, wavDuration, wavFormatLabel, wavFrames, weaponName, writeArchiveBytes, writeMapBytes };
21982
+ export { ACTION_DEFS, AI_ENUMS, AI_FLAGS, AI_OPCODES, AI_SCRIPT_FLAGS, AI_SCRIPT_NAMES, ANYWHERE_NAME, ActionType, AiScriptTextError, BRIEFING_ACTION_DEFS, BUILD_MANIFEST_MEMBER, BUILD_SOURCE_MEMBER, CHOICES, CONDITION_DEFS, ColorMode, Comparison, ConditionType, DAT_SCHEMAS, DAT_TABLES, DEFAULT_DOODAD_PLACEMENT, DEFAULT_GAS, DEFAULT_MINERALS, DEFAULT_PALETTE, DEFAULT_PLACEMENT, DEFAULT_SAVE_OPTIONS, DEFAULT_START_PLACEMENT, DEFAULT_TEXT_ENCODING, DIRT, DatTextError, FIND_KINDS, FORCE_SLOTS, ForceFlag, GAME_ARCHIVES, GAME_FOLDERS, GAME_ISCRIPT_LAST, GraftTextError, ISCRIPT_ANIMS, ISCRIPT_OPCODES, ISCRIPT_TYPE_ANIMS, IscriptTextError, MAP_SIZES, MAP_VERSIONS, MEGATILE_PX, MINERAL_FIELD_IDS, MODELLED_SECTIONS, MOD_FOLDERS, MOD_FORMAT, MOD_MANIFEST, MapLoadError, ModFolderError, ModSourceError, NAME_TEXT_FILES, PLAYER_COLORS, PLAYER_RACES, PLAYER_SLOTS, PLAYER_TYPES, PLUGIN_API_VERSION, PlayerGroup, PlayerRace, PlayerType, REQUIRED_SECTIONS, ResourceType, SAVE_PRESETS, SCENARIO_PATH, START_LOCATION, STRX_CAPACITY, SYSTEM_FILES, SetModifier, SwitchAction, SwitchState, TECH_NAMES, TEXT_CODES, TEXT_ENCODINGS, TILESETS, TILESET_BY_ID, TRIGGER_OWNERS, TileFlag, TriggerTextError, UNIT_LIMIT, UNIT_NAMES, UNIT_TYPE_COUNT, UPGRADE_NAMES, UnitClass, UnitUsed, VESPENE_GEYSER, WAV_FORMAT, WEAPON_NAMES, actionDef, actionDefByName, addLocation, addUnits, aiNames, aiScriptByName, aiScriptName, aiStringText, aiscriptFromText, aiscriptToText, applyBriefing, applyChanges, applyDoodadChanges, applyForceSettings, applyLocationChanges, applyPlayerSettings, applySounds, applyStringImport, applyStrings, applyTechSettings, applyTriggers, applyUnitChanges, applyUnitSettings, applyUpgradeSettings, baseTerrain, buildChk, buildDoodadCatalogue, buildMapFile, buttonGraftFromText, buttonGraftToText, canDecodeWav, changeMapVersion, changeTextEncoding, checkDoodadPlacement, checkIsom, checkMod, choiceLabel, choiceValue, conditionDef, conditionDefByName, createScenario, datEntrySize, datFromRows, datFromText, datHas, datRow, datRows, datShape, datStandardSize, datTableOf, datToText, dataSetHash, dataSetHashOfDigests, decodeButtonGraft, decodeDat, decodeFlingyDat, decodeGrpImage, decodeImaAdpcm, decodeImagesDat, decodeIscript, decodeLoFile, decodePcmWav, decodePcxImage, decodePng, decodeReqGraft, decodeSpritesDat, decodeTblFile, decodeText, decodeTrg, decodeUnitsDat, decodeWav, defaultSaveOptions, defaultTechRestrictions, defaultTechSettings, defaultUnitAvailability, defaultUnitSettings, defaultUpgradeRestrictions, defaultUpgradeSettings, deflate, deleteUnused, diamondAt, diffMods, displayColorHex, drawMegatile, editLocation, emptyDat, emptyManifest, encodeButtonGraft, encodeDat, encodeGrpFrame, encodeGrpImage, encodeGrpLine, encodeLoFile, encodePcxImage, encodePng, encodeReqGraft, encodeSection, encodeTblFile, encodeTrg, encodeWav, entryText, escapeStringText, exeArchive, extraKind, fieldType, fileDigest, findInScenario, fingerprintTrigger, firegraftLine, flatRow, flatTerrain, folderPath, forceName, formatBytes, formatOf, formatStringTable, formatTrigger, formatTriggers, frameFromPicture, framePicture, gameCopyFiles, gameLine, gameName, groupBuildable, grpToPng, hasIsom, hashLines, hashLinesAsWere, idealStarts, inflate, internString, isExe, isExpansion, isFiregraftProject, isModCode, isMpq, isPlainPcm, isPluginFile, isPng, isPreserved, isRemasteredRevision, isResource, isSystemFile, isSystemLine, isZip, iscriptEntryCount, iscriptFromText, iscriptToText, isomTables, issueCounts, keptExtras, loFromText, loToText, loadMap, loadModData, loadTileset, locationCapacity, locationName, locationSlots, looksLikeMpq, makeUnit, mapStatistics, mapVersionOf, markDirty, megatileForTile, megatileHeight, memberInfo, memberOf, memberPath, mirroredOwner, modHash, modHashOfDigests, modRoot, moveLocations, moveUnits, nameFileText, nameList, namesOf, newAction, newCondition, newTrigger, nextSerial, opaqueBox, openMapBytes, ownEntry, packBuiltMap, packFile, paintIsom, paintIsomDiamonds, parseChk, parseDatText, parseScenario, parseStringTable, parseTriggers, parseWavHeader, placeDoodad, placeOf, placeStartLocations, placedLocations, plainText, planSave, playableCount, playerColorHex, playerRaceLabel, playerTypeLabel, pluginLine, pngToGrp, probeNames, programEnd, readArchive, readBriefing, readBuildManifest, readExtras, readForceSettings, readIscriptHeaders, readManifest, readMembers, readPlayerSettings, readStrings, readSwitchNames, readTechSettings, readTriggerFile, readTriggers, readUnitSettings, readUpgradeSettings, readWavs, readZip, recordRendered, removeLocations, removeUnits, renderAiScripts, renderMember, reqGraftFromText, reqGraftToText, requiredSections, resizeScenario, resolveIcon, restoreBuiltMap, rowChanges, runsOf, sameTriggers, scenarioDescription, scenarioName, serializeChk, serializeScenario, setDatRow, setExtendedStrings, setMapVersion, setPreserved, setScenarioDescription, setScenarioName, setTextEncoding, sheetColumns, soundList, statTextEntries, statWithText, statisticsText, storedRange, stringCapacity, stringUsages, summarizeTrigger, symmetryImages, tblEscape, tblFromText, tblToText, tblUnescape, techName, techRestrictionSections, techSettingsSections, textCode, tidyManifest, tileGroupOf, tilesetIndex, triggerComment, triggerFormatOf, triggerNames, triggerReferences, triggerUsage, triggersFromText, triggersToText, unescapeStringText, unitAt, unitCustomName, unitGeometry, unitName, unitSettingsSections, unitsInBox, unusedStrings, updateUnits, upgradeName, upgradeRestrictionSections, upgradeSettingsSections, usedLocations, validateManifest, validateScenario, walkSpeed, wavCodecName, wavDuration, wavFormatLabel, wavFrames, weaponName, writeArchiveBytes, writeMapBytes };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scm-js/core",
3
- "version": "0.13.0",
3
+ "version": "0.13.2",
4
4
  "description": "StarCraft: Brood War maps in Node.js and the browser, as the scmJS editor reads and writes them: open .scm/.scx/.chk, triggers, strings, units, locations, settings, Check Map, and write the map back",
5
5
  "keywords": [
6
6
  "starcraft",