@mailwoman/core 10.5.0 → 10.6.0

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.
Files changed (41) hide show
  1. package/lib/geocode/result.ts +46 -0
  2. package/lib/git.ts +357 -55
  3. package/lib/layers/manifest.ts +31 -0
  4. package/lib/layers/schema.ts +14 -0
  5. package/lib/process.ts +320 -0
  6. package/lib/resources/git.ts +9 -5
  7. package/lib/utils/events.ts +23 -0
  8. package/out/geocode/result.d.ts +25 -0
  9. package/out/geocode/result.d.ts.map +1 -1
  10. package/out/geocode/result.js +40 -0
  11. package/out/geocode/result.js.map +1 -1
  12. package/out/git.d.ts +180 -4
  13. package/out/git.d.ts.map +1 -1
  14. package/out/git.js +227 -37
  15. package/out/git.js.map +1 -1
  16. package/out/layers/manifest.d.ts +19 -0
  17. package/out/layers/manifest.d.ts.map +1 -1
  18. package/out/layers/manifest.js +12 -0
  19. package/out/layers/manifest.js.map +1 -1
  20. package/out/layers/schema.d.ts +10 -0
  21. package/out/layers/schema.d.ts.map +1 -1
  22. package/out/layers/schema.js +4 -0
  23. package/out/layers/schema.js.map +1 -1
  24. package/out/process.d.ts +146 -0
  25. package/out/process.d.ts.map +1 -1
  26. package/out/process.js +158 -0
  27. package/out/process.js.map +1 -1
  28. package/out/resources/git.d.ts +5 -1
  29. package/out/resources/git.d.ts.map +1 -1
  30. package/out/resources/git.js +8 -5
  31. package/out/resources/git.js.map +1 -1
  32. package/out/tools/download/libpostal-resources.d.ts +2 -2
  33. package/out/tools/download/libpostal-resources.d.ts.map +1 -1
  34. package/out/tools/download/libpostal-resources.js +4 -4
  35. package/out/tools/download/libpostal-resources.js.map +1 -1
  36. package/out/utils/events.d.ts +13 -0
  37. package/out/utils/events.d.ts.map +1 -1
  38. package/out/utils/events.js +19 -0
  39. package/out/utils/events.js.map +1 -1
  40. package/package.json +7 -7
  41. package/tools/download/libpostal-resources.ts +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":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I,MAAM,WAAW,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACzC,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YACnB,MAAM,EAAE,CAAC,sFAAsF,CAAC,CAAA;YAChG,MAAM,mBAAmB,CAAC,gBAAgB,CAAC,CAAA;QAC5C,CAAC;aAAM,CAAC;YACP,MAAM,IAAI,YAAY,CAAC,6EAA6E,CAAC,CAAA;QACtG,CAAC;IACF,CAAC;IAED,YAAY,OAAO,GAAG,MAAM,kBAAkB,CAAC,YAAY,CAAC,CAAA;IAE5D,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IAC1C,MAAM,IAAI,SAAS,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAA;IAElF,MAAM,WAAW,GAAG,QAAQ,CAAC,WAAW,EAAE,cAAc,CAAC,CAAA;IAEzD,6DAA6D;IAC7D,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QAC7G,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;YACpB,MAAM,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;QAC/C,CAAC;IACF,CAAC;IAED,yEAAyE;IACzE,MAAM,QAAQ,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAA;AAC9C,CAAC"}
@@ -8,4 +8,17 @@
8
8
  * `await once(child, "exit")` — rejecting on its `error`.
9
9
  */
10
10
  export { once } from "node:events";
11
+ /**
12
+ * An `EventTarget` whose events hold a typed `detail`, keyed by type in `EventMap`.
13
+ *
14
+ * Subclasses dispatch with `emit`, and listeners subscribe with `on`.
15
+ * The base `addEventListener` still works for a caller that wants the `CustomEvent` itself.
16
+ */
17
+ export declare class TypedEventTarget<EventMap extends object> extends EventTarget {
18
+ /**
19
+ * Listen for one event type with its typed `detail`, answering a function that removes the listener.
20
+ */
21
+ on<K extends keyof EventMap & string>(type: K, listener: (detail: EventMap[K]) => void): () => void;
22
+ protected emit<K extends keyof EventMap & string>(type: K, detail: EventMap[K]): void;
23
+ }
11
24
  //# sourceMappingURL=events.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../lib/utils/events.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../lib/utils/events.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAElC;;;;;GAKG;AACH,qBAAa,gBAAgB,CAAC,QAAQ,SAAS,MAAM,CAAE,SAAQ,WAAW;IACzE;;OAEG;IACI,EAAE,CAAC,CAAC,SAAS,MAAM,QAAQ,GAAG,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAMzG;IAED,SAAS,CAAC,IAAI,CAAC,CAAC,SAAS,MAAM,QAAQ,GAAG,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAEpF;CACD"}
@@ -8,4 +8,23 @@
8
8
  * `await once(child, "exit")` — rejecting on its `error`.
9
9
  */
10
10
  export { once } from "node:events";
11
+ /**
12
+ * An `EventTarget` whose events hold a typed `detail`, keyed by type in `EventMap`.
13
+ *
14
+ * Subclasses dispatch with `emit`, and listeners subscribe with `on`.
15
+ * The base `addEventListener` still works for a caller that wants the `CustomEvent` itself.
16
+ */
17
+ export class TypedEventTarget extends EventTarget {
18
+ /**
19
+ * Listen for one event type with its typed `detail`, answering a function that removes the listener.
20
+ */
21
+ on(type, listener) {
22
+ const handler = (event) => listener(event.detail);
23
+ this.addEventListener(type, handler);
24
+ return () => this.removeEventListener(type, handler);
25
+ }
26
+ emit(type, detail) {
27
+ this.dispatchEvent(new CustomEvent(type, { detail }));
28
+ }
29
+ }
11
30
  //# sourceMappingURL=events.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"events.js","sourceRoot":"","sources":["../../lib/utils/events.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../../lib/utils/events.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAElC;;;;;GAKG;AACH,MAAM,OAAO,gBAA0C,SAAQ,WAAW;IACzE;;OAEG;IACI,EAAE,CAAoC,IAAO,EAAE,QAAuC;QAC5F,MAAM,OAAO,GAAG,CAAC,KAAY,EAAQ,EAAE,CAAC,QAAQ,CAAE,KAAkC,CAAC,MAAM,CAAC,CAAA;QAE5F,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QAEpC,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IACrD,CAAC;IAES,IAAI,CAAoC,IAAO,EAAE,MAAmB;QAC7E,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;IACtD,CAAC;CACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mailwoman/core",
3
- "version": "10.5.0",
3
+ "version": "10.6.0",
4
4
  "description": "Mailwoman core: tokenization, decoder, formatter, resources, filters, utils.",
5
5
  "license": "AGPL-3.0-only OR LicenseRef-Commercial",
6
6
  "repository": {
@@ -1256,11 +1256,11 @@
1256
1256
  }
1257
1257
  },
1258
1258
  "dependencies": {
1259
- "@mailwoman/annotations": "10.5.0",
1260
- "@mailwoman/codex": "10.5.0",
1261
- "@mailwoman/evidence": "10.5.0",
1262
- "@mailwoman/query-shape": "10.5.0",
1263
- "@mailwoman/sqlite": "10.5.0",
1259
+ "@mailwoman/annotations": "10.6.0",
1260
+ "@mailwoman/codex": "10.6.0",
1261
+ "@mailwoman/evidence": "10.6.0",
1262
+ "@mailwoman/query-shape": "10.6.0",
1263
+ "@mailwoman/sqlite": "10.6.0",
1264
1264
  "adm-zip": "^0.6.1",
1265
1265
  "async-init": "^1.0.0",
1266
1266
  "axios": "^1.20.0",
@@ -1289,7 +1289,7 @@
1289
1289
  },
1290
1290
  "devDependencies": {
1291
1291
  "@duckdb/node-api": "1.5.6-r.1",
1292
- "@mailwoman/spatial": "10.5.0",
1292
+ "@mailwoman/spatial": "10.6.0",
1293
1293
  "@types/d3-color": "^3.1.3",
1294
1294
  "@types/d3-scale-chromatic": "^3.1.0",
1295
1295
  "@types/trusted-types": "^2.0.7",
@@ -9,8 +9,8 @@
9
9
  * The script shallow-clones {@link https://github.com/openvenues/libpostal openvenues/libpostal}.
10
10
  * It sorts each dictionary file in place and copies the `dictionaries/` tree beside this script.
11
11
  *
12
- * Replaces the bash `resources-download.sh`. `git clone` runs through zx's `$` (no clean native
13
- * equivalent); everything else is `node:fs` / `node:os`. The script sorts in-process with a plain
12
+ * Replaces the bash `resources-download.sh`. `git clone` runs through `GitClient`.
13
+ * Everything else is `@mailwoman/core/fs`. The script sorts in-process with a plain
14
14
  * code-point `Array.sort()`, which matches `LC_ALL=C sort` byte order — deterministic and free of
15
15
  * the shell `sort`'s locale dependency (the original relied on the ambient locale).
16
16
  *
@@ -32,6 +32,7 @@ import { readLocalTextFile } from "#fs/readers"
32
32
  import { isDirectory } from "#fs/readers/stat"
33
33
  import { temporaryDirectory } from "#fs/temporary"
34
34
  import { copyPath, removePathIfPresent, writeLocalTextFile } from "#fs/writers"
35
+ import { GitClient } from "#git"
35
36
  import { resourceDictionaryPath } from "#paths"
36
37
  import { CommandError } from "#scripting/command"
37
38
 
@@ -81,11 +82,10 @@ export async function downloadLibpostalResources(
81
82
  }
82
83
  }
83
84
 
84
- const { $ } = await import("zx")
85
85
  await using tempDir = await temporaryDirectory("libpostal-")
86
86
 
87
87
  const cloneDir = tempDir.path("libpostal")
88
- await $`git clone --depth 1 ${REPO_URL} ${cloneDir}`
88
+ await new GitClient({ cwd: tempDir.path }).clone(REPO_URL, cloneDir, { depth: 1 })
89
89
 
90
90
  const sourceDicts = cloneDir("resources", "dictionaries")
91
91