@mailwoman/registry 5.9.0 → 5.10.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 (108) hide show
  1. package/out/address-key.d.ts +1 -1
  2. package/out/geocode-handler.d.ts +2 -2
  3. package/out/geojson.d.ts +1 -1
  4. package/out/index.d.ts +10 -10
  5. package/out/ingest.d.ts +1 -1
  6. package/out/learned-scorer.d.ts +2 -2
  7. package/out/learned-scorer.js +1 -1
  8. package/out/map-html.d.ts +1 -1
  9. package/out/reconcile.d.ts +2 -2
  10. package/out/reconcile.js +1 -1
  11. package/out/resolve.d.ts +1 -1
  12. package/out/tools/coverage-reconciliation.d.ts +51 -0
  13. package/out/tools/coverage-reconciliation.d.ts.map +1 -0
  14. package/out/tools/coverage-reconciliation.js +166 -0
  15. package/out/tools/coverage-reconciliation.js.map +1 -0
  16. package/out/tools/cross-dataset-correlation.d.ts +49 -0
  17. package/out/tools/cross-dataset-correlation.d.ts.map +1 -0
  18. package/out/tools/cross-dataset-correlation.js +340 -0
  19. package/out/tools/cross-dataset-correlation.js.map +1 -0
  20. package/out/tools/cross-source-threshold-sweep.d.ts +52 -0
  21. package/out/tools/cross-source-threshold-sweep.d.ts.map +1 -0
  22. package/out/tools/cross-source-threshold-sweep.js +328 -0
  23. package/out/tools/cross-source-threshold-sweep.js.map +1 -0
  24. package/out/tools/dedup-ceiling.d.ts +21 -3
  25. package/out/tools/dedup-ceiling.d.ts.map +1 -1
  26. package/out/tools/dedup-ceiling.js +16 -30
  27. package/out/tools/dedup-ceiling.js.map +1 -1
  28. package/out/tools/eval-geocoder.d.ts +45 -0
  29. package/out/tools/eval-geocoder.d.ts.map +1 -0
  30. package/out/tools/eval-geocoder.js +14 -0
  31. package/out/tools/eval-geocoder.js.map +1 -0
  32. package/out/tools/geocoder-namesake-probe.d.ts +26 -0
  33. package/out/tools/geocoder-namesake-probe.d.ts.map +1 -0
  34. package/out/tools/geocoder-namesake-probe.js +59 -0
  35. package/out/tools/geocoder-namesake-probe.js.map +1 -0
  36. package/out/tools/geocoder-vs-provided-coords.d.ts +38 -0
  37. package/out/tools/geocoder-vs-provided-coords.d.ts.map +1 -0
  38. package/out/tools/geocoder-vs-provided-coords.js +132 -0
  39. package/out/tools/geocoder-vs-provided-coords.js.map +1 -0
  40. package/out/tools/gold-set-sample.d.ts +22 -3
  41. package/out/tools/gold-set-sample.d.ts.map +1 -1
  42. package/out/tools/gold-set-sample.js +17 -32
  43. package/out/tools/gold-set-sample.js.map +1 -1
  44. package/out/tools/index.d.ts +36 -0
  45. package/out/tools/index.d.ts.map +1 -0
  46. package/out/tools/index.js +36 -0
  47. package/out/tools/index.js.map +1 -0
  48. package/out/tools/learned-scorer-clustering-eval.d.ts +54 -0
  49. package/out/tools/learned-scorer-clustering-eval.d.ts.map +1 -0
  50. package/out/tools/learned-scorer-clustering-eval.js +368 -0
  51. package/out/tools/learned-scorer-clustering-eval.js.map +1 -0
  52. package/out/tools/learned-scorer-crossstate-eval.d.ts +43 -0
  53. package/out/tools/learned-scorer-crossstate-eval.d.ts.map +1 -0
  54. package/out/tools/learned-scorer-crossstate-eval.js +305 -0
  55. package/out/tools/learned-scorer-crossstate-eval.js.map +1 -0
  56. package/out/tools/learned-scorer-eval.d.ts +59 -0
  57. package/out/tools/learned-scorer-eval.d.ts.map +1 -0
  58. package/out/tools/learned-scorer-eval.js +450 -0
  59. package/out/tools/learned-scorer-eval.js.map +1 -0
  60. package/out/tools/matcher-scale.d.ts +17 -3
  61. package/out/tools/matcher-scale.d.ts.map +1 -1
  62. package/out/tools/matcher-scale.js +14 -30
  63. package/out/tools/matcher-scale.js.map +1 -1
  64. package/out/tools/nppes-dedup-benchmark.d.ts +75 -0
  65. package/out/tools/nppes-dedup-benchmark.d.ts.map +1 -0
  66. package/out/tools/nppes-dedup-benchmark.js +846 -0
  67. package/out/tools/nppes-dedup-benchmark.js.map +1 -0
  68. package/out/tools/train-cross-gbt.d.ts +58 -0
  69. package/out/tools/train-cross-gbt.d.ts.map +1 -0
  70. package/out/tools/train-cross-gbt.js +324 -0
  71. package/out/tools/train-cross-gbt.js.map +1 -0
  72. package/out/tools/train-gbt.d.ts +51 -0
  73. package/out/tools/train-gbt.d.ts.map +1 -0
  74. package/out/tools/train-gbt.js +268 -0
  75. package/out/tools/train-gbt.js.map +1 -0
  76. package/out/tools/train-org-cross-gbt.d.ts +51 -0
  77. package/out/tools/train-org-cross-gbt.d.ts.map +1 -0
  78. package/out/tools/train-org-cross-gbt.js +296 -0
  79. package/out/tools/train-org-cross-gbt.js.map +1 -0
  80. package/out/tools/txhhsc-to-oarow.d.ts +14 -3
  81. package/out/tools/txhhsc-to-oarow.d.ts.map +1 -1
  82. package/out/tools/txhhsc-to-oarow.js +44 -52
  83. package/out/tools/txhhsc-to-oarow.js.map +1 -1
  84. package/out/tools/viz/cross-dataset-map.d.ts +23 -4
  85. package/out/tools/viz/cross-dataset-map.d.ts.map +1 -1
  86. package/out/tools/viz/cross-dataset-map.js +42 -46
  87. package/out/tools/viz/cross-dataset-map.js.map +1 -1
  88. package/out/tools/viz/geocode-first-surface.d.ts +17 -4
  89. package/out/tools/viz/geocode-first-surface.d.ts.map +1 -1
  90. package/out/tools/viz/geocode-first-surface.js +71 -78
  91. package/out/tools/viz/geocode-first-surface.js.map +1 -1
  92. package/out/tools/viz/render-map.d.ts +17 -3
  93. package/out/tools/viz/render-map.d.ts.map +1 -1
  94. package/out/tools/viz/render-map.js +26 -26
  95. package/out/tools/viz/render-map.js.map +1 -1
  96. package/out/tools/viz/render.d.ts +21 -3
  97. package/out/tools/viz/render.d.ts.map +1 -1
  98. package/out/tools/viz/render.js +43 -39
  99. package/out/tools/viz/render.js.map +1 -1
  100. package/out/tools/viz/source-provenance-map.d.ts +24 -5
  101. package/out/tools/viz/source-provenance-map.d.ts.map +1 -1
  102. package/out/tools/viz/source-provenance-map.js +53 -62
  103. package/out/tools/viz/source-provenance-map.js.map +1 -1
  104. package/out/tools/viz/yardstick-figure.d.ts +11 -3
  105. package/out/tools/viz/yardstick-figure.d.ts.map +1 -1
  106. package/out/tools/viz/yardstick-figure.js +68 -73
  107. package/out/tools/viz/yardstick-figure.js.map +1 -1
  108. package/package.json +50 -10
@@ -3,7 +3,9 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * Render a {@link toMapHTML} page (MapLibre GL + Protomaps basemap) to a PNG via headless Chromium.
6
+ * Render a {@link toMapHTML} page (MapLibre GL + Protomaps basemap) to a PNG via headless Chromium
7
+ * — the shared map renderer behind the `registry viz` map figures (an internal helper, not a
8
+ * command).
7
9
  *
8
10
  * Two house-stack constraints make this fiddlier than the Plotly/SVG renderers:
9
11
  *
@@ -17,7 +19,19 @@
17
19
  * The map paints asynchronously after the network settles; we wait for networkidle, then a fixed
18
20
  * beat for the basemap tiles + marker layer to finish compositing.
19
21
  *
20
- * Run: node registry/tools/viz/render-map.ts <served-url> <out.png>
22
+ * Playwright (headless Chromium) is a heavy dev-only dependency — lazy-imported inside the entry
23
+ * fn (the corpus-tools lazy-import convention).
21
24
  */
22
- export {};
25
+ /** Options for {@linkcode renderServedMapToPNG}. */
26
+ export interface RenderMapOptions {
27
+ /** The served localhost URL of the map page (NOT a file:// path — see the module doc). */
28
+ url: string;
29
+ /** Output PNG path. */
30
+ outPNG: string;
31
+ }
32
+ /** Screenshot a served MapLibre map page once the tiles + marker layer settle. */
33
+ export declare function renderServedMapToPNG(options: RenderMapOptions, report?: (line: string) => void): Promise<{
34
+ outPNG: string;
35
+ consoleErrors: string[];
36
+ }>;
23
37
  //# sourceMappingURL=render-map.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"render-map.d.ts","sourceRoot":"","sources":["../../../tools/viz/render-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG"}
1
+ {"version":3,"file":"render-map.d.ts","sourceRoot":"","sources":["../../../tools/viz/render-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,oDAAoD;AACpD,MAAM,WAAW,gBAAgB;IAChC,0FAA0F;IAC1F,GAAG,EAAE,MAAM,CAAA;IACX,uBAAuB;IACvB,MAAM,EAAE,MAAM,CAAA;CACd;AAED,kFAAkF;AAClF,wBAAsB,oBAAoB,CACzC,OAAO,EAAE,gBAAgB,EACzB,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CA0BtD"}
@@ -3,7 +3,9 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * Render a {@link toMapHTML} page (MapLibre GL + Protomaps basemap) to a PNG via headless Chromium.
6
+ * Render a {@link toMapHTML} page (MapLibre GL + Protomaps basemap) to a PNG via headless Chromium
7
+ * — the shared map renderer behind the `registry viz` map figures (an internal helper, not a
8
+ * command).
7
9
  *
8
10
  * Two house-stack constraints make this fiddlier than the Plotly/SVG renderers:
9
11
  *
@@ -17,31 +19,29 @@
17
19
  * The map paints asynchronously after the network settles; we wait for networkidle, then a fixed
18
20
  * beat for the basemap tiles + marker layer to finish compositing.
19
21
  *
20
- * Run: node registry/tools/viz/render-map.ts <served-url> <out.png>
22
+ * Playwright (headless Chromium) is a heavy dev-only dependency — lazy-imported inside the entry
23
+ * fn (the corpus-tools lazy-import convention).
21
24
  */
22
- import { parseArgs } from "node:util";
23
- import { chromium } from "playwright";
24
- const { positionals } = parseArgs({ allowPositionals: true, strict: false });
25
- const url = positionals[0];
26
- const out = positionals[1];
27
- if (!url || !out) {
28
- console.error("usage: render-map.ts <served-localhost-url> <out.png>");
29
- process.exit(1);
30
- }
31
- const browser = await chromium.launch({
32
- args: ["--use-gl=angle", "--use-angle=swiftshader", "--enable-unsafe-swiftshader", "--ignore-gpu-blocklist"],
33
- });
34
- const page = await browser.newPage({ viewport: { width: 1100, height: 760 }, deviceScaleFactor: 2 });
35
- const errors = [];
36
- page.on("console", (m) => m.type() === "error" && errors.push(m.text()));
37
- page.on("pageerror", (e) => errors.push(String(e)));
38
- await page.goto(url, { waitUntil: "networkidle", timeout: 30_000 });
39
- // MapLibre composites tiles + the marker layer async after the network settles; give it a beat.
40
- await page.waitForTimeout(4_000);
41
- await page.screenshot({ path: out });
42
- await browser.close();
43
- console.error(`[map-render] ${out}; console errors=${errors.length}`);
44
- for (const e of errors.slice(0, 6)) {
45
- console.error(" " + e);
25
+ /** Screenshot a served MapLibre map page once the tiles + marker layer settle. */
26
+ export async function renderServedMapToPNG(options, report) {
27
+ // playwright + Chromium are heavy — lazy import (the pipeline convention).
28
+ const { chromium } = await import("playwright");
29
+ const browser = await chromium.launch({
30
+ args: ["--use-gl=angle", "--use-angle=swiftshader", "--enable-unsafe-swiftshader", "--ignore-gpu-blocklist"],
31
+ });
32
+ const page = await browser.newPage({ viewport: { width: 1100, height: 760 }, deviceScaleFactor: 2 });
33
+ const errors = [];
34
+ page.on("console", (m) => m.type() === "error" && errors.push(m.text()));
35
+ page.on("pageerror", (e) => errors.push(String(e)));
36
+ await page.goto(options.url, { waitUntil: "networkidle", timeout: 30_000 });
37
+ // MapLibre composites tiles + the marker layer async after the network settles; give it a beat.
38
+ await page.waitForTimeout(4_000);
39
+ await page.screenshot({ path: options.outPNG });
40
+ await browser.close();
41
+ report?.(`[map-render] ${options.outPNG}; console errors=${errors.length}`);
42
+ for (const e of errors.slice(0, 6)) {
43
+ report?.(" " + e);
44
+ }
45
+ return { outPNG: options.outPNG, consoleErrors: errors };
46
46
  }
47
47
  //# sourceMappingURL=render-map.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"render-map.js","sourceRoot":"","sources":["../../../tools/viz/render-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,OAA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AAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;IACxE,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAEnD,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAA;IAC3E,gGAAgG;IAChG,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;IAChC,MAAM,IAAI,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IAC/C,MAAM,OAAO,CAAC,KAAK,EAAE,CAAA;IAErB,MAAM,EAAE,CAAC,gBAAgB,OAAO,CAAC,MAAM,oBAAoB,MAAM,CAAC,MAAM,EAAE,CAAC,CAAA;IAE3E,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;QACpC,MAAM,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,CAAA;IACnB,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,CAAA;AACzD,CAAC"}
@@ -3,7 +3,8 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * Render a self-contained Plotly HTML to a PNG via headless Chromium.
6
+ * Render a self-contained Plotly HTML to a PNG via headless Chromium — the shared renderer behind
7
+ * the `registry viz` figures (an internal helper, not a command).
7
8
  *
8
9
  * Plotly 3D (`surface`/`scatter3d`) needs a real WebGL context; headless Chromium has none by
9
10
  * default, so we force ANGLE's SwiftShader software rasterizer (`--use-gl=angle
@@ -11,7 +12,24 @@
11
12
  * on the 2D canvas regardless. We wait for Plotly's `plotly_afterplot` to fire on every graph div
12
13
  * rather than a fixed sleep, so the screenshot can't race the (async) WebGL paint.
13
14
  *
14
- * Run: node registry/tools/viz/render.ts <in.html> <out.png> [width] [height]
15
+ * Playwright (headless Chromium) is a heavy dev-only dependency — lazy-imported inside the entry
16
+ * fn (the corpus-tools lazy-import convention), so importing `@mailwoman/registry/tools` never
17
+ * pays for it.
15
18
  */
16
- export {};
19
+ /** Options for {@linkcode renderPlotlyHTMLToPNG}. */
20
+ export interface RenderPlotlyOptions {
21
+ /** The self-contained Plotly HTML file. */
22
+ inHTML: string;
23
+ /** Output PNG path. */
24
+ outPNG: string;
25
+ /** Viewport width. Default 1160. */
26
+ width?: number;
27
+ /** Viewport height. Default 1000. */
28
+ height?: number;
29
+ }
30
+ /** Screenshot a Plotly HTML page after every graph div's `plotly_afterplot` fires. */
31
+ export declare function renderPlotlyHTMLToPNG(options: RenderPlotlyOptions, report?: (line: string) => void): Promise<{
32
+ outPNG: string;
33
+ consoleErrors: string[];
34
+ }>;
17
35
  //# sourceMappingURL=render.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../tools/viz/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG"}
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../tools/viz/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAKH,qDAAqD;AACrD,MAAM,WAAW,mBAAmB;IACnC,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAA;IACd,uBAAuB;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,qCAAqC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAA;CACf;AAED,sFAAsF;AACtF,wBAAsB,qBAAqB,CAC1C,OAAO,EAAE,mBAAmB,EAC5B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAwDtD"}
@@ -3,7 +3,8 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * Render a self-contained Plotly HTML to a PNG via headless Chromium.
6
+ * Render a self-contained Plotly HTML to a PNG via headless Chromium — the shared renderer behind
7
+ * the `registry viz` figures (an internal helper, not a command).
7
8
  *
8
9
  * Plotly 3D (`surface`/`scatter3d`) needs a real WebGL context; headless Chromium has none by
9
10
  * default, so we force ANGLE's SwiftShader software rasterizer (`--use-gl=angle
@@ -11,47 +12,50 @@
11
12
  * on the 2D canvas regardless. We wait for Plotly's `plotly_afterplot` to fire on every graph div
12
13
  * rather than a fixed sleep, so the screenshot can't race the (async) WebGL paint.
13
14
  *
14
- * Run: node registry/tools/viz/render.ts <in.html> <out.png> [width] [height]
15
+ * Playwright (headless Chromium) is a heavy dev-only dependency — lazy-imported inside the entry
16
+ * fn (the corpus-tools lazy-import convention), so importing `@mailwoman/registry/tools` never
17
+ * pays for it.
15
18
  */
16
19
  import { resolve } from "node:path";
17
20
  import { pathToFileURL } from "node:url";
18
- import { parseArgs } from "node:util";
19
- import { chromium } from "playwright";
20
- const { positionals } = parseArgs({ allowPositionals: true, strict: false });
21
- const [inHTML, outPNG, w = "1160", h = "1000"] = positionals;
22
- if (!inHTML || !outPNG) {
23
- console.error("usage: render.ts <in.html> <out.png> [width] [height]");
24
- process.exit(1);
25
- }
26
- const browser = await chromium.launch({
27
- args: ["--use-gl=angle", "--use-angle=swiftshader", "--enable-unsafe-swiftshader", "--ignore-gpu-blocklist"],
28
- });
29
- const page = await browser.newPage({ viewport: { width: Number(w), height: Number(h) }, deviceScaleFactor: 2 });
30
- const errors = [];
31
- page.on("console", (m) => m.type() === "error" && errors.push(m.text()));
32
- page.on("pageerror", (e) => errors.push(String(e)));
33
- await page.goto(pathToFileURL(resolve(inHTML)).href, { waitUntil: "networkidle" });
34
- // Resolve once every Plotly graph div has fired plotly_afterplot (3D paints land async, after
35
- // newPlot's promise resolves), with a per-div fallback so an already-painted div can't hang us.
36
- await page.evaluate(async () => {
37
- const doc = globalThis.document;
38
- const divs = [...doc.querySelectorAll("div")]
39
- .map((d) => d)
40
- .filter((d) => d._fullLayout && typeof d.on === "function");
41
- await Promise.all(divs.map((d) => new Promise((res) => {
42
- d.on("plotly_afterplot", () => res());
43
- setTimeout(() => res(), 2000);
44
- })));
45
- });
46
- // Final settle for the software WebGL rasterizer.
47
- await page.waitForTimeout(800);
48
- await page.screenshot({ path: resolve(outPNG), fullPage: true });
49
- await browser.close();
50
- if (errors.length) {
51
- console.error(`[render] ${errors.length} console error(s):`);
52
- for (const e of errors.slice(0, 8)) {
53
- console.error(" " + e);
21
+ /** Screenshot a Plotly HTML page after every graph div's `plotly_afterplot` fires. */
22
+ export async function renderPlotlyHTMLToPNG(options, report) {
23
+ // playwright + Chromium are heavy — lazy import (the pipeline convention).
24
+ const { chromium } = await import("playwright");
25
+ const browser = await chromium.launch({
26
+ args: ["--use-gl=angle", "--use-angle=swiftshader", "--enable-unsafe-swiftshader", "--ignore-gpu-blocklist"],
27
+ });
28
+ const page = await browser.newPage({
29
+ viewport: { width: options.width ?? 1160, height: options.height ?? 1000 },
30
+ deviceScaleFactor: 2,
31
+ });
32
+ const errors = [];
33
+ page.on("console", (m) => m.type() === "error" && errors.push(m.text()));
34
+ page.on("pageerror", (e) => errors.push(String(e)));
35
+ await page.goto(pathToFileURL(resolve(options.inHTML)).href, { waitUntil: "networkidle" });
36
+ // Resolve once every Plotly graph div has fired plotly_afterplot (3D paints land async, after
37
+ // newPlot's promise resolves), with a per-div fallback so an already-painted div can't hang us.
38
+ await page.evaluate(async () => {
39
+ const doc = globalThis.document;
40
+ const divs = [...doc.querySelectorAll("div")]
41
+ .map((d) => d)
42
+ .filter((d) => d._fullLayout && typeof d.on === "function");
43
+ await Promise.all(divs.map((d) => new Promise((res) => {
44
+ d.on("plotly_afterplot", () => res());
45
+ setTimeout(() => res(), 2000);
46
+ })));
47
+ });
48
+ // Final settle for the software WebGL rasterizer.
49
+ await page.waitForTimeout(800);
50
+ await page.screenshot({ path: resolve(options.outPNG), fullPage: true });
51
+ await browser.close();
52
+ if (errors.length) {
53
+ report?.(`[render] ${errors.length} console error(s):`);
54
+ for (const e of errors.slice(0, 8)) {
55
+ report?.(" " + e);
56
+ }
54
57
  }
58
+ report?.(`[render] ${options.outPNG}`);
59
+ return { outPNG: options.outPNG, consoleErrors: errors };
55
60
  }
56
- console.error(`[render] ${outPNG}`);
57
61
  //# sourceMappingURL=render.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"render.js","sourceRoot":"","sources":["../../../tools/viz/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,MAAM,EAAE,WAAW,EAAE,GAAG,SAAS,CAAC,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAA;AAC5E,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC,GAAG,WAAW,CAAA;AAE5D,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;IACxB,OAAO,CAAC,KAAK,CAAC,uDAAuD,CAAC,CAAA;IACtE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAChB,CAAC;AAED,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;IACrC,IAAI,EAAE,CAAC,gBAAgB,EAAE,yBAAyB,EAAE,6BAA6B,EAAE,wBAAwB,C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AAK,UAAU,CAAC,CAAA;QAC5D,MAAM,OAAO,CAAC,GAAG,CAChB,IAAI,CAAC,GAAG,CACP,CAAC,CAAC,EAAE,EAAE,CACL,IAAI,OAAO,CAAO,CAAC,GAAG,EAAE,EAAE;YACzB,CAAC,CAAC,EAAG,CAAC,kBAAkB,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,CAAA;YACtC,UAAU,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAA;QAC9B,CAAC,CAAC,CACH,CACD,CAAA;IACF,CAAC,CAAC,CAAA;IACF,kDAAkD;IAClD,MAAM,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAA;IAE9B,MAAM,IAAI,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;IACxE,MAAM,OAAO,CAAC,KAAK,EAAE,CAAA;IAErB,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QACnB,MAAM,EAAE,CAAC,YAAY,MAAM,CAAC,MAAM,oBAAoB,CAAC,CAAA;QAEvD,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;YACpC,MAAM,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,CAAA;QACnB,CAAC;IACF,CAAC;IACD,MAAM,EAAE,CAAC,YAAY,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IAEtC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,CAAA;AACzD,CAAC"}
@@ -20,11 +20,30 @@
20
20
  * layer not plotted here; this map is the rooftop-point sources only.
21
21
  *
22
22
  * SERVE THE OUTPUT OVER LOCALHOST (the house tile server CORS-restricts to localhost + the docs
23
- * domains). e.g. `python3 -m http.server -d <dir>`, or `render-map.mjs` against the served URL.
23
+ * domains). e.g. `python3 -m http.server -d <dir>`, or `renderServedMapToPNG` (`./render-map.ts`)
24
+ * against the served URL.
24
25
  *
25
- * Run: node --experimental-strip-types registry/tools/viz/source-provenance-map.ts\
26
- * [--state ny] [--db <address-points-us-XX.db>] [--out-html /tmp/source-provenance.html]\
27
- * [--nad-mod 700] [--oa-mod 120] [--cap 7000]
26
+ * Run: `mailwoman registry viz source-provenance-map [--state ny] [--db <address-points-us-XX.db>]
27
+ * [--out-html /tmp/source-provenance.html] [--nad-mod 700] [--oa-mod 120] [--cap 7000]`
28
28
  */
29
- export {};
29
+ /** Options for {@linkcode sourceProvenanceMap}. */
30
+ export interface SourceProvenanceMapOptions {
31
+ /** State (lowercase postal). Default ny. */
32
+ state?: string;
33
+ /** Address-point DB path. Default `$MAILWOMAN_DATA_ROOT/address-points/address-points-us-<state>.db`. */
34
+ db?: string;
35
+ /** Output HTML path. Default `/tmp/source-provenance.html`. */
36
+ outHtml?: string;
37
+ /** Keep ~1/N of NAD points. Default 700. */
38
+ nadMod?: number;
39
+ /** Keep ~1/N of OpenAddresses points. Default 120. */
40
+ oaMod?: number;
41
+ /** Per-source marker cap. Default 7000. */
42
+ cap?: number;
43
+ }
44
+ /** Render the per-state address-point provenance map — see the module doc. */
45
+ export declare function sourceProvenanceMap(options?: SourceProvenanceMapOptions, report?: (line: string) => void): {
46
+ outHtml: string;
47
+ points: number;
48
+ };
30
49
  //# sourceMappingURL=source-provenance-map.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"source-provenance-map.d.ts","sourceRoot":"","sources":["../../../tools/viz/source-provenance-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG"}
1
+ {"version":3,"file":"source-provenance-map.d.ts","sourceRoot":"","sources":["../../../tools/viz/source-provenance-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAQH,mDAAmD;AACnD,MAAM,WAAW,0BAA0B;IAC1C,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,yGAAyG;IACzG,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,4CAA4C;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,2CAA2C;IAC3C,GAAG,CAAC,EAAE,MAAM,CAAA;CACZ;AAmBD,8EAA8E;AAC9E,wBAAgB,mBAAmB,CAClC,OAAO,GAAE,0BAA+B,EACxC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CA8DrC"}
@@ -20,38 +20,16 @@
20
20
  * layer not plotted here; this map is the rooftop-point sources only.
21
21
  *
22
22
  * SERVE THE OUTPUT OVER LOCALHOST (the house tile server CORS-restricts to localhost + the docs
23
- * domains). e.g. `python3 -m http.server -d <dir>`, or `render-map.mjs` against the served URL.
23
+ * domains). e.g. `python3 -m http.server -d <dir>`, or `renderServedMapToPNG` (`./render-map.ts`)
24
+ * against the served URL.
24
25
  *
25
- * Run: node --experimental-strip-types registry/tools/viz/source-provenance-map.ts\
26
- * [--state ny] [--db <address-points-us-XX.db>] [--out-html /tmp/source-provenance.html]\
27
- * [--nad-mod 700] [--oa-mod 120] [--cap 7000]
26
+ * Run: `mailwoman registry viz source-provenance-map [--state ny] [--db <address-points-us-XX.db>]
27
+ * [--out-html /tmp/source-provenance.html] [--nad-mod 700] [--oa-mod 120] [--cap 7000]`
28
28
  */
29
29
  import { writeFileSync } from "node:fs";
30
30
  import { DatabaseSync } from "node:sqlite";
31
- import { parseArgs } from "node:util";
32
31
  import { dataRootPath } from "@mailwoman/core/utils";
33
32
  import { toMapHTML } from "@mailwoman/registry";
34
- // Loose scan parity with the retired local argv helpers: unknown flags tolerated.
35
- const { values: rawValues } = parseArgs({
36
- options: {
37
- cap: { type: "string" },
38
- db: { type: "string" },
39
- "nad-mod": { type: "string" },
40
- "oa-mod": { type: "string" },
41
- "out-html": { type: "string" },
42
- state: { type: "string" },
43
- },
44
- strict: false,
45
- allowPositionals: true,
46
- });
47
- // Typed view: strict:false loosens TS inference, but declared options always parse to their schema type.
48
- const values = rawValues;
49
- const STATE = (values["state"] || "ny").toLowerCase();
50
- const DB = values["db"] || `${dataRootPath("address-points")}/address-points-us-${STATE}.db`;
51
- const OUT = values["out-html"] || "/tmp/source-provenance.html";
52
- const NAD_MOD = Number(values["nad-mod"] || "700"); // keep ~1/700 of NAD points
53
- const OA_MOD = Number(values["oa-mod"] || "120"); // keep ~1/120 of OpenAddresses points
54
- const CAP = Number(values["cap"] || "7000"); // per-source marker cap
55
33
  // Collapse the raw `source` string into a human, mappable category. The address-point DB stores e.g.
56
34
  // "overture:NAD" or "overture:OpenAddresses/NY/NYC Open Data" — the suffix is the real upstream
57
35
  // publisher, which is what we want to color by (the "overture:" prefix is just the theme it arrived in).
@@ -64,43 +42,56 @@ function categorize(source) {
64
42
  }
65
43
  return { bucket: source, publisher: source };
66
44
  }
67
- const db = new DatabaseSync(DB, { readOnly: true });
68
- // Two stratified samples so the smaller source (OpenAddresses, ~1/6 of NY) stays visible next to NAD.
69
- // abs(random()) % mod == 0 keeps a spatially-uniform ~1/mod fraction; LIMIT caps the marker count.
70
- const sample = (where, mod) => db
71
- .prepare(`SELECT lat, lon, source, number, street_raw FROM address_point
45
+ /** Render the per-state address-point provenance map — see the module doc. */
46
+ export function sourceProvenanceMap(options = {}, report) {
47
+ const STATE = (options.state || "ny").toLowerCase();
48
+ const DB = options.db || `${dataRootPath("address-points")}/address-points-us-${STATE}.db`;
49
+ const OUT = options.outHtml || "/tmp/source-provenance.html";
50
+ const NAD_MOD = options.nadMod ?? 700; // keep ~1/700 of NAD points
51
+ const OA_MOD = options.oaMod ?? 120; // keep ~1/120 of OpenAddresses points
52
+ const CAP = options.cap ?? 7000; // per-source marker cap
53
+ const db = new DatabaseSync(DB, { readOnly: true });
54
+ // Two stratified samples so the smaller source (OpenAddresses, ~1/6 of NY) stays visible next to NAD.
55
+ // abs(random()) % mod == 0 keeps a spatially-uniform ~1/mod fraction; LIMIT caps the marker count.
56
+ const sample = (where, mod) => db
57
+ .prepare(`SELECT lat, lon, source, number, street_raw FROM address_point
72
58
  WHERE ${where} AND lat IS NOT NULL AND lon IS NOT NULL AND abs(random()) % ${mod} = 0
73
59
  LIMIT ${CAP}`)
74
- .all();
75
- const rows = [...sample("source = 'overture:NAD'", NAD_MOD), ...sample("source LIKE 'overture:OpenAddresses%'", OA_MOD)];
76
- db.close();
77
- const counts = new Map();
78
- const features = rows.map((r) => {
79
- const { bucket, publisher } = categorize(r.source);
80
- counts.set(bucket, (counts.get(bucket) ?? 0) + 1);
81
- const addr = [r.number, r.street_raw].filter(Boolean).join(" ").trim();
82
- return {
83
- type: "Feature",
84
- geometry: { type: "Point", coordinates: [r.lon, r.lat] },
85
- properties: {
86
- bucket,
87
- sources: [bucket],
88
- recordCount: 1,
89
- geocodeTier: "address_point",
90
- organization: publisher,
91
- address: addr || null,
92
- },
93
- };
94
- });
95
- const geojson = { type: "FeatureCollection", features };
96
- const html = toMapHTML(geojson, {
97
- title: `Address-point provenance — ${STATE.toUpperCase()}, every point colored by its open-data source`,
98
- flavor: "light",
99
- colorBy: "bucket",
100
- });
101
- writeFileSync(OUT, html);
102
- console.error(`[written] ${OUT} (${features.length} points)`);
103
- for (const [bucket, n] of [...counts.entries()].sort((a, b) => b[1] - a[1])) {
104
- console.error(` ${n.toString().padStart(5)} ${bucket}`);
60
+ .all();
61
+ const rows = [
62
+ ...sample("source = 'overture:NAD'", NAD_MOD),
63
+ ...sample("source LIKE 'overture:OpenAddresses%'", OA_MOD),
64
+ ];
65
+ db.close();
66
+ const counts = new Map();
67
+ const features = rows.map((r) => {
68
+ const { bucket, publisher } = categorize(r.source);
69
+ counts.set(bucket, (counts.get(bucket) ?? 0) + 1);
70
+ const addr = [r.number, r.street_raw].filter(Boolean).join(" ").trim();
71
+ return {
72
+ type: "Feature",
73
+ geometry: { type: "Point", coordinates: [r.lon, r.lat] },
74
+ properties: {
75
+ bucket,
76
+ sources: [bucket],
77
+ recordCount: 1,
78
+ geocodeTier: "address_point",
79
+ organization: publisher,
80
+ address: addr || null,
81
+ },
82
+ };
83
+ });
84
+ const geojson = { type: "FeatureCollection", features };
85
+ const html = toMapHTML(geojson, {
86
+ title: `Address-point provenance — ${STATE.toUpperCase()}, every point colored by its open-data source`,
87
+ flavor: "light",
88
+ colorBy: "bucket",
89
+ });
90
+ writeFileSync(OUT, html);
91
+ report?.(`[written] ${OUT} (${features.length} points)`);
92
+ for (const [bucket, n] of [...counts.entries()].sort((a, b) => b[1] - a[1])) {
93
+ report?.(` ${n.toString().padStart(5)} ${bucket}`);
94
+ }
95
+ return { outHtml: OUT, points: features.length };
105
96
  }
106
97
  //# sourceMappingURL=source-provenance-map.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"source-provenance-map.js","sourceRoot":"","sources":["../../../tools/viz/source-provenance-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAE/C,kFAAkF;AAClF,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,SAAS,CAAC;IACvC,OAAO,EAAE;QACR,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACvB,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACtB,SAAS,EAA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C,MAAM,CAAC;gBACjB,WAAW,EAAE,CAAC;gBACd,WAAW,EAAE,eAAe;gBAC5B,YAAY,EAAE,SAAS;gBACvB,OAAO,EAAE,IAAI,IAAI,IAAI;aACrB;SACD,CAAA;IACF,CAAC,CAAC,CAAA;IAEF,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,mBAA4B,EAAE,QAAQ,EAAE,CAAA;IAChE,MAAM,IAAI,GAAG,SAAS,CAAC,OAAgB,EAAE;QACxC,KAAK,EAAE,8BAA8B,KAAK,CAAC,WAAW,EAAE,+CAA+C;QACvG,MAAM,EAAE,OAAO;QACf,OAAO,EAAE,QAAQ;KACjB,CAAC,CAAA;IAEF,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IACxB,MAAM,EAAE,CAAC,aAAa,GAAG,MAAM,QAAQ,CAAC,MAAM,UAAU,CAAC,CAAA;IAEzD,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7E,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC,CAAA;IACrD,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAA;AACjD,CAAC"}
@@ -20,8 +20,16 @@
20
20
  * Emits a self-contained SVG (the docs' committed-chart-asset convention — see
21
21
  * `docs/articles/evals/charts/*.svg`), no browser required.
22
22
  *
23
- * Run: node --experimental-strip-types registry/tools/viz/yardstick-figure.ts\
24
- * [--out-svg docs/articles/evals/charts/dedup-yardstick.svg]
23
+ * Run: `mailwoman registry viz yardstick-figure
24
+ * [--out-svg docs/articles/evals/charts/dedup-yardstick.svg]`
25
25
  */
26
- export {};
26
+ /** Options for {@linkcode yardstickFigure}. */
27
+ export interface YardstickFigureOptions {
28
+ /** Output SVG path. Default `docs/articles/evals/charts/dedup-yardstick.svg` (relative to cwd). */
29
+ outSvg?: string;
30
+ }
31
+ /** Emit the dedup-yardstick slope chart as a self-contained SVG — see the module doc. */
32
+ export declare function yardstickFigure(options?: YardstickFigureOptions, report?: (line: string) => void): {
33
+ outSvg: string;
34
+ };
27
35
  //# sourceMappingURL=yardstick-figure.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"yardstick-figure.d.ts","sourceRoot":"","sources":["../../../tools/viz/yardstick-figure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG"}
1
+ {"version":3,"file":"yardstick-figure.d.ts","sourceRoot":"","sources":["../../../tools/viz/yardstick-figure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAIH,+CAA+C;AAC/C,MAAM,WAAW,sBAAsB;IACtC,mGAAmG;IACnG,MAAM,CAAC,EAAE,MAAM,CAAA;CACf;AAuDD,yFAAyF;AACzF,wBAAgB,eAAe,CAC9B,OAAO,GAAE,sBAA2B,EACpC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAgHpB"}