@scm-js/core 0.13.0 → 0.13.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/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.1 — 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,52 @@ 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;
3247
3293
  /**
3248
3294
  * 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
3295
  * files under the game's folders, the shallower on a tie; "" is the root. Paths use forward slashes. At any depth, as
@@ -3285,9 +3331,9 @@ export declare class ModSourceError extends Error {
3285
3331
  export declare function readZip(b: Uint8Array): ZipMember[];
3286
3332
  /**
3287
3333
  * 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.
3334
+ * lower case with backslashes), sorted by name, joined with newlines, hashed again; the first sixteen hex digits. An
3335
+ * operating system's files (`isSystemFile`) have no line. A mod's hash also has lines for its plugins and FireGraft
3336
+ * project: `modHash` / `modHashOfDigests` in `hash.ts`; for a mod without either the two agree.
3291
3337
  */
3292
3338
  export declare function dataSetHash(files: readonly {
3293
3339
  name: string;
@@ -3312,8 +3358,18 @@ export declare const pluginLine: (name: string, sha256: string) => string;
3312
3358
  export declare const firegraftLine: (name: string, sha256: string) => string;
3313
3359
  /** A game file's line: its game name. */
3314
3360
  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. */
3361
+ /** Whether a line `name<TAB>sha256` is of an operating system's file (`isSystemFile`), which the hash has no line for. */
3362
+ export declare const isSystemLine: (line: string) => boolean;
3363
+ /**
3364
+ * The hash of lines `name<TAB>sha256` in any order: sorted by name, joined with "\n", SHA-256, sixteen hex digits. A
3365
+ * line of an operating system's file (`isSystemLine`) is dropped first.
3366
+ */
3316
3367
  export declare function hashLines(lines: readonly string[]): Promise<string>;
3368
+ /**
3369
+ * `hashLines` as it was until 2026-11-09: every line given, an operating system's files among them. For matching a
3370
+ * hash made then (a replay's tag, a mod kept in a browser), never for naming a mod now.
3371
+ */
3372
+ export declare function hashLinesAsWere(lines: readonly string[]): Promise<string>;
3317
3373
  /** A file by its name and its bytes' SHA-256 (`fileDigest`). */
3318
3374
  export interface Digest {
3319
3375
  name: string;
@@ -3336,11 +3392,20 @@ export interface ModHash {
3336
3392
  lines: string[];
3337
3393
  /** The plugins' lines (sorted). */
3338
3394
  pluginLines: string[];
3395
+ /**
3396
+ * There when an operating system's files were among what was given (`isSystemFile`): the mod's hashes as they were
3397
+ * while those files had lines (`hashLinesAsWere`), and the names left out. Matched as an older form, never presented.
3398
+ */
3399
+ older?: {
3400
+ hash: string;
3401
+ withoutPlugins: string;
3402
+ left: string[];
3403
+ };
3339
3404
  }
3340
3405
  /**
3341
3406
  * The mod's hash and its hash without plugins. Game files are taken once by game name (the last given wins, as a
3342
3407
  * 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).
3408
+ * as on the play page). An operating system's files have no line, and `older` says what the hashes were with them.
3344
3409
  */
3345
3410
  export declare function modHashOfDigests(input: ModHashInput): Promise<ModHash>;
3346
3411
  /** `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,52 @@ 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
+ /**
19701
19799
  * 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
19800
  * files under the game's folders, the shallower on a tie; "" is the root. Paths use forward slashes. At any depth, as
19703
19801
  * 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 +19949,9 @@ var hex = (b) => [...new Uint8Array(b)].map((x) => x.toString(16).padStart(2, "0
19851
19949
  var sha256 = async (bytes) => hex(await crypto.subtle.digest("SHA-256", bytes));
19852
19950
  /**
19853
19951
  * 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.
19952
+ * lower case with backslashes), sorted by name, joined with newlines, hashed again; the first sixteen hex digits. An
19953
+ * operating system's files (`isSystemFile`) have no line. A mod's hash also has lines for its plugins and FireGraft
19954
+ * project: `modHash` / `modHashOfDigests` in `hash.ts`; for a mod without either the two agree.
19857
19955
  */
19858
19956
  async function dataSetHash(files) {
19859
19957
  const digests = [];
@@ -19867,7 +19965,7 @@ async function dataSetHash(files) {
19867
19965
  var fileDigest = (bytes) => sha256(bytes);
19868
19966
  /** `dataSetHash` from each file's `fileDigest` rather than its bytes: the same rule, the same hash. */
19869
19967
  async function dataSetHashOfDigests(files) {
19870
- const lines = files.map((f) => ({
19968
+ const lines = files.filter((f) => !isSystemFile(f.name)).map((f) => ({
19871
19969
  name: gameName(f.name),
19872
19970
  sha256: f.sha256
19873
19971
  })).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0).map((f) => `${f.name}\t${f.sha256}`);
@@ -19891,6 +19989,18 @@ async function dataSetHashOfDigests(files) {
19891
19989
  * the first sixteen hex digits of their SHA-256. A page that does not run the plugins presents the hash of the lines
19892
19990
  * without the plugins' ("without plugins").
19893
19991
  *
19992
+ * **No line for an operating system's files** (`sources.ts#SYSTEM_FILES`: `desktop.ini`, `Thumbs.db`, `.DS_Store`, a
19993
+ * zip's `__MACOSX/` and the rest of that list), wherever one lies: loose in a game folder, or a member of an archive
19994
+ * that was packed from such a folder. The game never asks for one, and not every route hands them over (a browser's
19995
+ * folder handle hides `desktop.ini`), so with them a mod's hash followed how its folder was read. `hashLines` drops
19996
+ * such lines itself, so the hash is the same whatever list a caller made; the readers leave the files out too, so the
19997
+ * counts agree.
19998
+ *
19999
+ * **The older form.** Until 2026-11-09 those files had lines. A mod kept in a browser and a replay tagged before then
20000
+ * name the mod by that hash, so where hashes are matched it is still accepted: `hashLinesAsWere` is the rule as it
20001
+ * was, and `ModHash.older` the mod's hashes by it, there only when the files were seen (a route that never saw them
20002
+ * cannot work the older hash out).
20003
+ *
19894
20004
  * Pure: the command line, the editor's worker and any page share it.
19895
20005
  */
19896
20006
  /** A plugin a mod carries: MPQDraft's `.qdp`, Chaoslauncher's `.bwl`. */
@@ -19906,37 +20016,66 @@ var pluginLine = (name, sha256) => `plugins\\${leafOf$1(name).toLowerCase()}\t${
19906
20016
  var firegraftLine = (name, sha256) => `${leafOf$1(name).toLowerCase()}\t${sha256}`;
19907
20017
  /** A game file's line: its game name. */
19908
20018
  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. */
20019
+ var lineName = (l) => l.slice(0, l.indexOf(" "));
20020
+ /** Whether a line `name<TAB>sha256` is of an operating system's file (`isSystemFile`), which the hash has no line for. */
20021
+ var isSystemLine = (line) => isSystemFile(lineName(line));
20022
+ /**
20023
+ * The hash of lines `name<TAB>sha256` in any order: sorted by name, joined with "\n", SHA-256, sixteen hex digits. A
20024
+ * line of an operating system's file (`isSystemLine`) is dropped first.
20025
+ */
19910
20026
  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);
20027
+ return hashLinesAsWere(lines.filter((l) => !isSystemLine(l)));
20028
+ }
20029
+ /**
20030
+ * `hashLines` as it was until 2026-11-09: every line given, an operating system's files among them. For matching a
20031
+ * hash made then (a replay's tag, a mod kept in a browser), never for naming a mod now.
20032
+ */
20033
+ async function hashLinesAsWere(lines) {
20034
+ const sorted = [...lines].sort((a, b) => lineName(a) < lineName(b) ? -1 : lineName(a) > lineName(b) ? 1 : 0);
19913
20035
  return (await fileDigest(new TextEncoder().encode(sorted.join("\n")))).slice(0, 16);
19914
20036
  }
19915
20037
  /**
19916
20038
  * The mod's hash and its hash without plugins. Game files are taken once by game name (the last given wins, as a
19917
20039
  * 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).
20040
+ * as on the play page). An operating system's files have no line, and `older` says what the hashes were with them.
19919
20041
  */
19920
20042
  async function modHashOfDigests(input) {
19921
20043
  const game = /* @__PURE__ */ new Map();
19922
- for (const f of input.files) game.set(gameName(f.name), f.sha256);
20044
+ for (const f of input.files) game.set(gameName(f.name), {
20045
+ sha256: f.sha256,
20046
+ system: isSystemFile(f.name)
20047
+ });
19923
20048
  const once = (list, keep, line) => {
19924
20049
  const seen = /* @__PURE__ */ new Set(), out = [];
19925
20050
  for (const f of list) {
19926
20051
  const key = leafOf$1(f.name).toLowerCase();
19927
20052
  if (!keep(f.name) || seen.has(key)) continue;
19928
20053
  seen.add(key);
19929
- out.push(line(f.name, f.sha256));
20054
+ out.push({
20055
+ line: line(f.name, f.sha256),
20056
+ system: isSystemFile(f.name)
20057
+ });
19930
20058
  }
19931
20059
  return out;
19932
20060
  };
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();
20061
+ const byLine = (a, b) => a.line < b.line ? -1 : a.line > b.line ? 1 : 0;
20062
+ const were = [...[...game].map(([name, f]) => ({
20063
+ line: `${name}\t${f.sha256}`,
20064
+ system: f.system
20065
+ })), ...once(input.firegraft ?? [], isFiregraftProject, firegraftLine)].sort(byLine);
20066
+ const pluginsWere = once(input.plugins ?? [], isPluginFile, pluginLine).sort(byLine);
20067
+ const lines = were.filter((l) => !l.system).map((l) => l.line), pluginLines = pluginsWere.filter((l) => !l.system).map((l) => l.line);
20068
+ const left = [...were, ...pluginsWere].filter((l) => l.system).map((l) => lineName(l.line));
19935
20069
  return {
19936
20070
  hash: await hashLines([...lines, ...pluginLines]),
19937
20071
  withoutPlugins: await hashLines(lines),
19938
20072
  lines,
19939
- pluginLines
20073
+ pluginLines,
20074
+ ...left.length ? { older: {
20075
+ hash: await hashLinesAsWere([...were, ...pluginsWere].map((l) => l.line)),
20076
+ withoutPlugins: await hashLinesAsWere(were.map((l) => l.line)),
20077
+ left
20078
+ } } : {}
19940
20079
  };
19941
20080
  }
19942
20081
  /** `modHashOfDigests` from the files' bytes. */
@@ -21801,4 +21940,4 @@ function canonicalSpec(source) {
21801
21940
  return source.kind === "builtin" ? `builtin:${source.name}` : source.display;
21802
21941
  }
21803
21942
  //#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 };
21943
+ 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, 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, 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.1",
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",