@mailwoman/core 9.4.0 → 10.0.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 (391) hide show
  1. package/lib/coarse-placer/tools/{build-dataset.ts → build/dataset.ts} +2 -1
  2. package/lib/coarse-placer/tools/{build-outlier-latin.ts → build/outlier/latin.ts} +4 -3
  3. package/lib/coarse-placer/tools/{eval-openset.ts → eval/openset.ts} +11 -7
  4. package/lib/coarse-placer/tools/{eval-quant-compare.ts → eval/quant-compare.ts} +2 -1
  5. package/lib/coarse-placer/tools/eval.ts +2 -2
  6. package/lib/coarse-placer/tools/index.ts +7 -7
  7. package/lib/coarse-placer/tools/train.ts +4 -6
  8. package/lib/decoder/build-tree.ts +2 -1
  9. package/lib/decoder/containment.ts +2 -1
  10. package/lib/decoder/index.ts +5 -5
  11. package/lib/decoder/parse-diff.ts +1 -1
  12. package/lib/decoder/proposals-to-tree.ts +3 -1
  13. package/lib/decoder/{serialize-json.ts → serialize/json.ts} +3 -2
  14. package/lib/decoder/{serialize-tuples.ts → serialize/tuples.ts} +2 -1
  15. package/lib/decoder/{tree-shape.ts → tree/shape.ts} +4 -3
  16. package/lib/decoder/types.ts +1 -3
  17. package/lib/decoder/unknown-spans.ts +1 -1
  18. package/lib/decoder/validate-tree.ts +2 -1
  19. package/lib/fs/readers/stat.ts +244 -0
  20. package/lib/fs/readers.ts +27 -271
  21. package/lib/fs/streams.ts +58 -0
  22. package/lib/fs/writers.ts +5 -5
  23. package/lib/fs/zip.ts +64 -8
  24. package/lib/license/configured.ts +2 -2
  25. package/lib/license/index.ts +2 -2
  26. package/lib/license/obligations.ts +1 -1
  27. package/lib/license/stamp.ts +1 -1
  28. package/lib/locale/locale.ts +2 -1
  29. package/lib/locale/registry.ts +2 -1
  30. package/lib/overture-pins.ts +24 -0
  31. package/lib/pipeline/preferences.ts +13 -0
  32. package/lib/pipeline/result.ts +84 -0
  33. package/lib/pipeline/runtime-pipeline.ts +9 -15
  34. package/lib/pipeline/types.ts +3 -73
  35. package/lib/policy/defaults.ts +2 -1
  36. package/lib/policy/policy.ts +3 -1
  37. package/lib/policy/registry.ts +3 -1
  38. package/lib/process.ts +3 -1
  39. package/lib/resolver/authoritative-provider.ts +1 -1
  40. package/lib/resolver/index.ts +1 -9
  41. package/lib/resolver/synthetic-id-ranges.ts +83 -0
  42. package/lib/resolver/types.ts +2 -10
  43. package/lib/resources/whosonfirst/placetypes/Placetype.ts +7 -6
  44. package/lib/scripting/arguments.ts +34 -0
  45. package/lib/scripting/utils/index.ts +1 -1
  46. package/lib/strings/case.ts +13 -2
  47. package/lib/tokenization/Graph.ts +3 -4
  48. package/lib/tools/{download-libpostal-resources.ts → download/libpostal-resources.ts} +3 -2
  49. package/lib/tools/generate-language-types.ts +3 -4
  50. package/lib/tools/index.ts +2 -2
  51. package/lib/types/classifier.ts +2 -1
  52. package/lib/types/index.ts +0 -1
  53. package/lib/types/mapping.ts +2 -1
  54. package/lib/workspaces.ts +9 -2
  55. package/out/api/APIClient.d.ts.map +1 -1
  56. package/out/api/arcgis.d.ts.map +1 -1
  57. package/out/api/defaults.d.ts.map +1 -1
  58. package/out/api/headless.d.ts.map +1 -1
  59. package/out/api/ogc.d.ts.map +1 -1
  60. package/out/api/paced-client.js.map +1 -1
  61. package/out/api/pacer.d.ts.map +1 -1
  62. package/out/api/pacer.js.map +1 -1
  63. package/out/api/responses.d.ts.map +1 -1
  64. package/out/api/{test-clocks.d.ts → test/clocks.d.ts} +1 -1
  65. package/out/api/test/clocks.d.ts.map +1 -0
  66. package/out/api/{test-clocks.js → test/clocks.js} +1 -1
  67. package/out/api/test/clocks.js.map +1 -0
  68. package/out/api/{test-transport.d.ts → test/transport.d.ts} +1 -1
  69. package/out/api/test/transport.d.ts.map +1 -0
  70. package/out/api/{test-transport.js → test/transport.js} +1 -1
  71. package/out/api/test/transport.js.map +1 -0
  72. package/out/coarse-placer/coarse-placer.d.ts.map +1 -1
  73. package/out/coarse-placer/coarse-placer.js.map +1 -1
  74. package/out/coarse-placer/featurize.d.ts.map +1 -1
  75. package/out/coarse-placer/tools/{build-dataset.d.ts → build/dataset.d.ts} +1 -1
  76. package/out/coarse-placer/tools/build/dataset.d.ts.map +1 -0
  77. package/out/coarse-placer/tools/{build-dataset.js → build/dataset.js} +3 -2
  78. package/out/coarse-placer/tools/build/dataset.js.map +1 -0
  79. package/out/coarse-placer/tools/{build-outlier-exposure.d.ts → build/outlier/exposure.d.ts} +1 -1
  80. package/out/coarse-placer/tools/build/outlier/exposure.d.ts.map +1 -0
  81. package/out/coarse-placer/tools/{build-outlier-exposure.js → build/outlier/exposure.js} +1 -1
  82. package/out/coarse-placer/tools/build/outlier/exposure.js.map +1 -0
  83. package/out/coarse-placer/tools/{build-outlier-latin.d.ts → build/outlier/latin.d.ts} +3 -3
  84. package/out/coarse-placer/tools/build/outlier/latin.d.ts.map +1 -0
  85. package/out/coarse-placer/tools/{build-outlier-latin.js → build/outlier/latin.js} +4 -3
  86. package/out/coarse-placer/tools/build/outlier/latin.js.map +1 -0
  87. package/out/coarse-placer/tools/{build-outlier-oa.d.ts → build/outlier/oa.d.ts} +1 -1
  88. package/out/coarse-placer/tools/build/outlier/oa.d.ts.map +1 -0
  89. package/out/coarse-placer/tools/{build-outlier-oa.js → build/outlier/oa.js} +1 -1
  90. package/out/coarse-placer/tools/build/outlier/oa.js.map +1 -0
  91. package/out/coarse-placer/tools/country-sets.d.ts.map +1 -1
  92. package/out/coarse-placer/tools/{eval-latin-offmap.d.ts → eval/latin-offmap.d.ts} +1 -1
  93. package/out/coarse-placer/tools/eval/latin-offmap.d.ts.map +1 -0
  94. package/out/coarse-placer/tools/{eval-latin-offmap.js → eval/latin-offmap.js} +1 -1
  95. package/out/coarse-placer/tools/eval/latin-offmap.js.map +1 -0
  96. package/out/coarse-placer/tools/{eval-openset.d.ts → eval/openset.d.ts} +1 -1
  97. package/out/coarse-placer/tools/eval/openset.d.ts.map +1 -0
  98. package/out/coarse-placer/tools/{eval-openset.js → eval/openset.js} +10 -7
  99. package/out/coarse-placer/tools/eval/openset.js.map +1 -0
  100. package/out/coarse-placer/tools/{eval-quant-compare.d.ts → eval/quant-compare.d.ts} +1 -1
  101. package/out/coarse-placer/tools/eval/quant-compare.d.ts.map +1 -0
  102. package/out/coarse-placer/tools/{eval-quant-compare.js → eval/quant-compare.js} +2 -2
  103. package/out/coarse-placer/tools/eval/quant-compare.js.map +1 -0
  104. package/out/coarse-placer/tools/eval.js +2 -2
  105. package/out/coarse-placer/tools/eval.js.map +1 -1
  106. package/out/coarse-placer/tools/index.d.ts +7 -7
  107. package/out/coarse-placer/tools/index.js +7 -7
  108. package/out/coarse-placer/tools/probe-frontier.js.map +1 -1
  109. package/out/coarse-placer/tools/quantize.js.map +1 -1
  110. package/out/coarse-placer/tools/train.d.ts.map +1 -1
  111. package/out/coarse-placer/tools/train.js +2 -3
  112. package/out/coarse-placer/tools/train.js.map +1 -1
  113. package/out/data-root.js.map +1 -1
  114. package/out/decoder/build-tree.d.ts.map +1 -1
  115. package/out/decoder/build-tree.js.map +1 -1
  116. package/out/decoder/containment.d.ts +2 -2
  117. package/out/decoder/containment.d.ts.map +1 -1
  118. package/out/decoder/containment.js.map +1 -1
  119. package/out/decoder/index.d.ts +5 -5
  120. package/out/decoder/index.js +5 -5
  121. package/out/decoder/parse-diff.js +1 -1
  122. package/out/decoder/parse-diff.js.map +1 -1
  123. package/out/decoder/proposals-to-tree.d.ts +2 -1
  124. package/out/decoder/proposals-to-tree.d.ts.map +1 -1
  125. package/out/decoder/proposals-to-tree.js.map +1 -1
  126. package/out/decoder/{serialize-json.d.ts → serialize/json.d.ts} +2 -2
  127. package/out/decoder/serialize/json.d.ts.map +1 -0
  128. package/out/decoder/{serialize-json.js → serialize/json.js} +2 -2
  129. package/out/decoder/serialize/json.js.map +1 -0
  130. package/out/decoder/{serialize-tuples.d.ts → serialize/tuples.d.ts} +2 -2
  131. package/out/decoder/serialize/tuples.d.ts.map +1 -0
  132. package/out/decoder/{serialize-tuples.js → serialize/tuples.js} +1 -1
  133. package/out/decoder/serialize/tuples.js.map +1 -0
  134. package/out/decoder/{serialize-xml.d.ts → serialize/xml.d.ts} +1 -1
  135. package/out/decoder/serialize/xml.d.ts.map +1 -0
  136. package/out/decoder/{serialize-xml.js → serialize/xml.js} +1 -1
  137. package/out/decoder/serialize/xml.js.map +1 -0
  138. package/out/decoder/{tree-shape.d.ts → tree/shape.d.ts} +2 -2
  139. package/out/decoder/tree/shape.d.ts.map +1 -0
  140. package/out/decoder/{tree-shape.js → tree/shape.js} +3 -3
  141. package/out/decoder/tree/shape.js.map +1 -0
  142. package/out/decoder/{tree-walk.d.ts → tree/walk.d.ts} +1 -1
  143. package/out/decoder/tree/walk.d.ts.map +1 -0
  144. package/out/decoder/{tree-walk.js → tree/walk.js} +1 -1
  145. package/out/decoder/tree/walk.js.map +1 -0
  146. package/out/decoder/types.d.ts +1 -2
  147. package/out/decoder/types.d.ts.map +1 -1
  148. package/out/decoder/types.js +1 -1
  149. package/out/decoder/types.js.map +1 -1
  150. package/out/decoder/unknown-spans.js +1 -1
  151. package/out/decoder/validate-tree.d.ts +1 -1
  152. package/out/decoder/validate-tree.d.ts.map +1 -1
  153. package/out/decoder/validate-tree.js.map +1 -1
  154. package/out/env/index.d.ts +1 -1
  155. package/out/env/schema.d.ts +4 -4
  156. package/out/errors/schema.d.ts.map +1 -1
  157. package/out/errors/schema.js.map +1 -1
  158. package/out/fs/formatters.d.ts.map +1 -1
  159. package/out/fs/formatters.js.map +1 -1
  160. package/out/fs/readers/stat.d.ts +126 -0
  161. package/out/fs/readers/stat.d.ts.map +1 -0
  162. package/out/fs/readers/stat.js +202 -0
  163. package/out/fs/readers/stat.js.map +1 -0
  164. package/out/fs/readers.d.ts +11 -150
  165. package/out/fs/readers.d.ts.map +1 -1
  166. package/out/fs/readers.js +22 -225
  167. package/out/fs/readers.js.map +1 -1
  168. package/out/fs/streams.d.ts +33 -0
  169. package/out/fs/streams.d.ts.map +1 -1
  170. package/out/fs/streams.js +49 -0
  171. package/out/fs/streams.js.map +1 -1
  172. package/out/fs/writers.d.ts +5 -5
  173. package/out/fs/writers.js +5 -5
  174. package/out/fs/zip.d.ts +21 -2
  175. package/out/fs/zip.d.ts.map +1 -1
  176. package/out/fs/zip.js +36 -8
  177. package/out/fs/zip.js.map +1 -1
  178. package/out/git.js.map +1 -1
  179. package/out/html/document.js.map +1 -1
  180. package/out/json.d.ts.map +1 -1
  181. package/out/layers/coverage.js.map +1 -1
  182. package/out/layers/schema.d.ts.map +1 -1
  183. package/out/license/configured.d.ts +1 -1
  184. package/out/license/configured.d.ts.map +1 -1
  185. package/out/license/configured.js +2 -2
  186. package/out/license/configured.js.map +1 -1
  187. package/out/license/docs-site.js.map +1 -1
  188. package/out/license/index.d.ts +2 -2
  189. package/out/license/index.d.ts.map +1 -1
  190. package/out/license/index.js +2 -2
  191. package/out/license/index.js.map +1 -1
  192. package/out/license/{key-file.d.ts → key/file.d.ts} +1 -1
  193. package/out/license/key/file.d.ts.map +1 -0
  194. package/out/license/{key-file.js → key/file.js} +1 -1
  195. package/out/license/key/file.js.map +1 -0
  196. package/out/license/{key.d.ts → key/index.d.ts} +1 -1
  197. package/out/license/key/index.d.ts.map +1 -0
  198. package/out/license/{key.js → key/index.js} +1 -1
  199. package/out/license/key/index.js.map +1 -0
  200. package/out/license/obligations.d.ts +1 -1
  201. package/out/license/obligations.d.ts.map +1 -1
  202. package/out/license/publication.js.map +1 -1
  203. package/out/license/register.d.ts.map +1 -1
  204. package/out/license/stamp.d.ts +1 -1
  205. package/out/license/stamp.d.ts.map +1 -1
  206. package/out/license/status.js.map +1 -1
  207. package/out/locale/locale.d.ts +1 -1
  208. package/out/locale/locale.d.ts.map +1 -1
  209. package/out/locale/registry.d.ts.map +1 -1
  210. package/out/locale/registry.js +1 -1
  211. package/out/locale/registry.js.map +1 -1
  212. package/out/locale/zh-cn-units.d.ts.map +1 -1
  213. package/out/logging/shared.d.ts.map +1 -1
  214. package/out/module/resolvers.js.map +1 -1
  215. package/out/objects.js.map +1 -1
  216. package/out/overture-pins.d.ts +24 -0
  217. package/out/overture-pins.d.ts.map +1 -0
  218. package/out/overture-pins.js +24 -0
  219. package/out/overture-pins.js.map +1 -0
  220. package/out/paths.js.map +1 -1
  221. package/out/pipeline/preferences.d.ts +13 -0
  222. package/out/pipeline/preferences.d.ts.map +1 -0
  223. package/out/pipeline/preferences.js +7 -0
  224. package/out/pipeline/preferences.js.map +1 -0
  225. package/out/pipeline/result.d.ts +72 -0
  226. package/out/pipeline/result.d.ts.map +1 -0
  227. package/out/pipeline/result.js +7 -0
  228. package/out/pipeline/result.js.map +1 -0
  229. package/out/pipeline/runtime-pipeline.d.ts.map +1 -1
  230. package/out/pipeline/runtime-pipeline.js +7 -13
  231. package/out/pipeline/runtime-pipeline.js.map +1 -1
  232. package/out/pipeline/span-proposer.js.map +1 -1
  233. package/out/pipeline/types.d.ts +3 -71
  234. package/out/pipeline/types.d.ts.map +1 -1
  235. package/out/pipeline/types.js +2 -0
  236. package/out/pipeline/types.js.map +1 -1
  237. package/out/policy/defaults.d.ts +1 -1
  238. package/out/policy/defaults.d.ts.map +1 -1
  239. package/out/policy/defaults.js +1 -1
  240. package/out/policy/defaults.js.map +1 -1
  241. package/out/policy/policy.d.ts +2 -1
  242. package/out/policy/policy.d.ts.map +1 -1
  243. package/out/policy/proposal-collection.js.map +1 -1
  244. package/out/policy/registry.d.ts +2 -1
  245. package/out/policy/registry.d.ts.map +1 -1
  246. package/out/policy/registry.js.map +1 -1
  247. package/out/process.d.ts +2 -2
  248. package/out/process.d.ts.map +1 -1
  249. package/out/process.js.map +1 -1
  250. package/out/random.d.ts.map +1 -1
  251. package/out/release-config.js.map +1 -1
  252. package/out/resolver/authoritative-provider.d.ts +1 -1
  253. package/out/resolver/authoritative-provider.d.ts.map +1 -1
  254. package/out/resolver/fixture-authoritative-provider.js.map +1 -1
  255. package/out/resolver/index.d.ts +2 -2
  256. package/out/resolver/index.d.ts.map +1 -1
  257. package/out/resolver/index.js +1 -1
  258. package/out/resolver/index.js.map +1 -1
  259. package/out/resolver/synthetic-id-ranges.d.ts +66 -0
  260. package/out/resolver/synthetic-id-ranges.d.ts.map +1 -0
  261. package/out/resolver/synthetic-id-ranges.js +73 -0
  262. package/out/resolver/synthetic-id-ranges.js.map +1 -0
  263. package/out/resolver/types.d.ts +1 -2
  264. package/out/resolver/types.d.ts.map +1 -1
  265. package/out/resolver/types.js +0 -1
  266. package/out/resolver/types.js.map +1 -1
  267. package/out/resources/languages/index.js.map +1 -1
  268. package/out/resources/languages/types.gen.d.ts.map +1 -1
  269. package/out/resources/locale.d.ts.map +1 -1
  270. package/out/resources/set.d.ts.map +1 -1
  271. package/out/resources/set.js.map +1 -1
  272. package/out/resources/whosonfirst/PlacetypeDataSource.d.ts +1 -1
  273. package/out/resources/whosonfirst/PlacetypeDataSource.d.ts.map +1 -1
  274. package/out/resources/whosonfirst/placetypes/Placetype.d.ts.map +1 -1
  275. package/out/resources/whosonfirst/placetypes/Placetype.js +7 -6
  276. package/out/resources/whosonfirst/placetypes/Placetype.js.map +1 -1
  277. package/out/resources/whosonfirst/placetypes/admin.d.ts +1 -1
  278. package/out/resources/whosonfirst/placetypes/admin.d.ts.map +1 -1
  279. package/out/resources/whosonfirst/placetypes/definition.d.ts.map +1 -1
  280. package/out/resources/whosonfirst/placetypes/mermaid.d.ts.map +1 -1
  281. package/out/resources/whosonfirst/placetypes/mermaid.js.map +1 -1
  282. package/out/routing/index.d.ts.map +1 -1
  283. package/out/routing/index.js.map +1 -1
  284. package/out/scripting/arguments.d.ts +7 -0
  285. package/out/scripting/arguments.d.ts.map +1 -1
  286. package/out/scripting/arguments.js +29 -0
  287. package/out/scripting/arguments.js.map +1 -1
  288. package/out/scripting/command.d.ts.map +1 -1
  289. package/out/scripting/ingest-chunk-script.d.ts.map +1 -1
  290. package/out/scripting/utils/index.d.ts +1 -1
  291. package/out/scripting/utils/index.d.ts.map +1 -1
  292. package/out/scripting/utils/index.js +1 -1
  293. package/out/scripting/utils/index.js.map +1 -1
  294. package/out/strings/case.d.ts +3 -0
  295. package/out/strings/case.d.ts.map +1 -1
  296. package/out/strings/case.js +12 -2
  297. package/out/strings/case.js.map +1 -1
  298. package/out/strings/python-json.js.map +1 -1
  299. package/out/tokenization/Graph.d.ts +3 -0
  300. package/out/tokenization/Graph.d.ts.map +1 -1
  301. package/out/tokenization/Graph.js +0 -4
  302. package/out/tokenization/Graph.js.map +1 -1
  303. package/out/tokenization/Span.d.ts.map +1 -1
  304. package/out/tokenization/Span.js.map +1 -1
  305. package/out/tokenization/normalizer.d.ts.map +1 -1
  306. package/out/tokenization/normalizer.js.map +1 -1
  307. package/out/tools/{download-libpostal-resources.d.ts → download/libpostal-resources.d.ts} +1 -1
  308. package/out/tools/download/libpostal-resources.d.ts.map +1 -0
  309. package/out/tools/{download-libpostal-resources.js → download/libpostal-resources.js} +4 -3
  310. package/out/tools/download/libpostal-resources.js.map +1 -0
  311. package/out/tools/{download-ssl-address.d.ts → download/ssl-address.d.ts} +1 -1
  312. package/out/tools/download/ssl-address.d.ts.map +1 -0
  313. package/out/tools/{download-ssl-address.js → download/ssl-address.js} +1 -1
  314. package/out/tools/download/ssl-address.js.map +1 -0
  315. package/out/tools/generate-language-types.d.ts.map +1 -1
  316. package/out/tools/generate-language-types.js +3 -4
  317. package/out/tools/generate-language-types.js.map +1 -1
  318. package/out/tools/index.d.ts +2 -2
  319. package/out/tools/index.js +2 -2
  320. package/out/types/Classification.d.ts +2 -2
  321. package/out/types/Classification.d.ts.map +1 -1
  322. package/out/types/classifier.d.ts +1 -1
  323. package/out/types/classifier.d.ts.map +1 -1
  324. package/out/types/index.d.ts +0 -1
  325. package/out/types/index.d.ts.map +1 -1
  326. package/out/types/index.js +0 -1
  327. package/out/types/index.js.map +1 -1
  328. package/out/types/mapping.d.ts +1 -1
  329. package/out/types/mapping.d.ts.map +1 -1
  330. package/out/types/mapping.js.map +1 -1
  331. package/out/utils/time.js.map +1 -1
  332. package/out/workspaces.d.ts.map +1 -1
  333. package/out/workspaces.js +7 -2
  334. package/out/workspaces.js.map +1 -1
  335. package/package.json +63 -53
  336. package/lib/resolver/placetype-map.ts +0 -157
  337. package/lib/types/component.ts +0 -96
  338. package/out/api/test-clocks.d.ts.map +0 -1
  339. package/out/api/test-clocks.js.map +0 -1
  340. package/out/api/test-transport.d.ts.map +0 -1
  341. package/out/api/test-transport.js.map +0 -1
  342. package/out/coarse-placer/tools/build-dataset.d.ts.map +0 -1
  343. package/out/coarse-placer/tools/build-dataset.js.map +0 -1
  344. package/out/coarse-placer/tools/build-outlier-exposure.d.ts.map +0 -1
  345. package/out/coarse-placer/tools/build-outlier-exposure.js.map +0 -1
  346. package/out/coarse-placer/tools/build-outlier-latin.d.ts.map +0 -1
  347. package/out/coarse-placer/tools/build-outlier-latin.js.map +0 -1
  348. package/out/coarse-placer/tools/build-outlier-oa.d.ts.map +0 -1
  349. package/out/coarse-placer/tools/build-outlier-oa.js.map +0 -1
  350. package/out/coarse-placer/tools/eval-latin-offmap.d.ts.map +0 -1
  351. package/out/coarse-placer/tools/eval-latin-offmap.js.map +0 -1
  352. package/out/coarse-placer/tools/eval-openset.d.ts.map +0 -1
  353. package/out/coarse-placer/tools/eval-openset.js.map +0 -1
  354. package/out/coarse-placer/tools/eval-quant-compare.d.ts.map +0 -1
  355. package/out/coarse-placer/tools/eval-quant-compare.js.map +0 -1
  356. package/out/decoder/serialize-json.d.ts.map +0 -1
  357. package/out/decoder/serialize-json.js.map +0 -1
  358. package/out/decoder/serialize-tuples.d.ts.map +0 -1
  359. package/out/decoder/serialize-tuples.js.map +0 -1
  360. package/out/decoder/serialize-xml.d.ts.map +0 -1
  361. package/out/decoder/serialize-xml.js.map +0 -1
  362. package/out/decoder/tree-shape.d.ts.map +0 -1
  363. package/out/decoder/tree-shape.js.map +0 -1
  364. package/out/decoder/tree-walk.d.ts.map +0 -1
  365. package/out/decoder/tree-walk.js.map +0 -1
  366. package/out/license/key-file.d.ts.map +0 -1
  367. package/out/license/key-file.js.map +0 -1
  368. package/out/license/key.d.ts.map +0 -1
  369. package/out/license/key.js.map +0 -1
  370. package/out/resolver/placetype-map.d.ts +0 -83
  371. package/out/resolver/placetype-map.d.ts.map +0 -1
  372. package/out/resolver/placetype-map.js +0 -130
  373. package/out/resolver/placetype-map.js.map +0 -1
  374. package/out/tools/download-libpostal-resources.d.ts.map +0 -1
  375. package/out/tools/download-libpostal-resources.js.map +0 -1
  376. package/out/tools/download-ssl-address.d.ts.map +0 -1
  377. package/out/tools/download-ssl-address.js.map +0 -1
  378. package/out/types/component.d.ts +0 -50
  379. package/out/types/component.d.ts.map +0 -1
  380. package/out/types/component.js +0 -84
  381. package/out/types/component.js.map +0 -1
  382. /package/lib/api/{test-clocks.ts → test/clocks.ts} +0 -0
  383. /package/lib/api/{test-transport.ts → test/transport.ts} +0 -0
  384. /package/lib/coarse-placer/tools/{build-outlier-exposure.ts → build/outlier/exposure.ts} +0 -0
  385. /package/lib/coarse-placer/tools/{build-outlier-oa.ts → build/outlier/oa.ts} +0 -0
  386. /package/lib/coarse-placer/tools/{eval-latin-offmap.ts → eval/latin-offmap.ts} +0 -0
  387. /package/lib/decoder/{serialize-xml.ts → serialize/xml.ts} +0 -0
  388. /package/lib/decoder/{tree-walk.ts → tree/walk.ts} +0 -0
  389. /package/lib/license/{key-file.ts → key/file.ts} +0 -0
  390. /package/lib/license/{key.ts → key/index.ts} +0 -0
  391. /package/lib/tools/{download-ssl-address.ts → download/ssl-address.ts} +0 -0
package/lib/fs/readers.ts CHANGED
@@ -8,224 +8,18 @@
8
8
  * code makes a blocking filesystem call, and the `debt` check in `packages/repo-health` counts any that appears.
9
9
  */
10
10
 
11
- import type { Dirent, Mode, Stats } from "node:fs"
12
- import {
13
- open as openNative,
14
- access,
15
- constants,
16
- glob,
17
- lstat,
18
- readFile,
19
- readdir,
20
- readlink,
21
- realpath,
22
- stat,
23
- type FileHandle,
24
- } from "node:fs/promises"
11
+ import { readFile } from "node:fs/promises"
25
12
 
26
13
  import { type PathBuilderLike, resolvePath } from "path-ts"
27
14
 
28
- import { ByteFormatter, type ByteFormatterOptions } from "#fs/formatters"
15
+ import { open } from "#fs/readers/stat"
29
16
  import { parseJSONStrict } from "#json"
30
17
 
18
+ export * from "#fs/readers/stat"
19
+
31
20
  export type { Dirent, PathLike, Stats } from "node:fs"
32
21
  export type { FileHandle } from "node:fs/promises"
33
22
 
34
- // #region Stat utils
35
-
36
- /**
37
- * Attempts to stat a file or directory.
38
- *
39
- * A `URL` is passed through rather than stringified: `node:fs` accepts a `file:` URL object, and rejects the string it
40
- * prints — `stat("file:///etc/hostname")` is ENOENT, which this function reports as absence. Every caller that looks a
41
- * file up by URL therefore read "not there" for everything, and `cli-native/command-router.ts` answered `Unknown
42
- * command` for every command it has.
43
- *
44
- * @throws If the path exists but cannot be statted for some reason other than non-existence.
45
- */
46
- export function tryStat(pathBuilderLike: PathBuilderLike | URL): Promise<Stats | null> {
47
- const target = pathBuilderLike instanceof URL ? pathBuilderLike : pathBuilderLike.toString()
48
-
49
- return stat(target).catch((error) => {
50
- if (error.code === "ENOENT") return null
51
-
52
- throw error
53
- })
54
- }
55
-
56
- /**
57
- * Stat a file or directory, raising ENOENT when nothing is there.
58
- *
59
- * The throwing counterpart to {@linkcode tryStat}. Reach for this one where absence is a defect the caller wants
60
- * reported, and for {@linkcode tryStat} where absence is an answer.
61
- */
62
- export function statPath(path: PathBuilderLike | URL): Promise<Stats> {
63
- return stat(path instanceof URL ? path : path.toString())
64
- }
65
-
66
- /**
67
- * Stat a path without following a symbolic link, so the answer describes the link itself.
68
- */
69
- export function statLink(path: PathBuilderLike | URL): Promise<Stats> {
70
- return lstat(path instanceof URL ? path : path.toString())
71
- }
72
-
73
- /**
74
- * Stat a path without following a symbolic link, answering `null` when nothing is there.
75
- *
76
- * The link-level counterpart to {@linkcode tryStat}.
77
- */
78
- export function tryStatLink(path: PathBuilderLike | URL): Promise<Stats | null> {
79
- return lstat(path instanceof URL ? path : path.toString()).catch((error) => {
80
- if (error.code === "ENOENT") return null
81
-
82
- throw error
83
- })
84
- }
85
-
86
- /**
87
- * Whether a path exists, whatever it is.
88
- *
89
- * The asynchronous answer to `existsSync`, which is the single most-called synchronous builtin in the repository.
90
- * Prefer {@linkcode isFile} or {@linkcode isDirectory} where the caller goes on to assume one or the other: a directory
91
- * where a file was expected passes this check and fails the next line.
92
- */
93
- export function pathExists(path: PathBuilderLike | URL): Promise<boolean> {
94
- return tryStat(path).then((stats) => stats !== null)
95
- }
96
-
97
- /**
98
- * Whether a path exists and is a directory.
99
- */
100
- export function isDirectory(path: PathBuilderLike | URL): Promise<boolean> {
101
- return tryStat(path).then((stats) => stats?.isDirectory() ?? false)
102
- }
103
-
104
- /**
105
- * Whether a path exists and is a file.
106
- */
107
- export function isFile(path: PathBuilderLike | URL): Promise<boolean> {
108
- return tryStat(path).then((stats) => stats?.isFile() ?? false)
109
- }
110
-
111
- /**
112
- * Whether a path exists and is a symbolic link.
113
- */
114
- export function isSymbolicLink(path: PathBuilderLike | URL): Promise<boolean> {
115
- return tryStatLink(path).then((stats) => stats?.isSymbolicLink() ?? false)
116
- }
117
-
118
- /**
119
- * Whether a directory entry leads to a directory, symbolic links included.
120
- *
121
- * `Dirent.isDirectory()` is FALSE for a symbolic link to a directory, so a walk keyed on it alone skips every linked
122
- * tree — while a glob with `followSymbolicLinks` (the default) descends into them, and the two then describe different
123
- * trees. A link is resolved through `stat`, which also answers `false` for a dangling one.
124
- */
125
- export function entryLeadsToDirectory(entry: Dirent): Promise<boolean> {
126
- if (entry.isDirectory()) return Promise.resolve(true)
127
-
128
- if (!entry.isSymbolicLink()) return Promise.resolve(false)
129
-
130
- return isDirectory(resolvePath(entry.parentPath, entry.name))
131
- }
132
-
133
- /**
134
- * The size of a file in bytes.
135
- *
136
- * @throws ENOENT when the file does not exist.
137
- */
138
- export function readFileSize(path: PathBuilderLike | URL): Promise<number> {
139
- return statPath(path).then((stats) => stats.size)
140
- }
141
-
142
- /**
143
- * The size of a file, rendered in IEC units (`12.3 MiB`) — the unit for anything a machine measured.
144
- *
145
- * @throws ENOENT when the file does not exist.
146
- */
147
- export async function formatFileSize(path: PathBuilderLike | URL, options?: ByteFormatterOptions): Promise<string> {
148
- return ByteFormatter.formatIEC(await readFileSize(path), options)
149
- }
150
-
151
- /**
152
- * Resolve a path to its canonical location, following every symbolic link.
153
- *
154
- * @throws ENOENT when nothing is there. {@linkcode tryRealPath} answers `null` instead.
155
- */
156
- export function realPath(path: PathBuilderLike): Promise<string> {
157
- return realpath(path.toString())
158
- }
159
-
160
- /**
161
- * Resolve a path to its canonical location, following every symbolic link.
162
- *
163
- * @returns The canonical path, or `null` when nothing is there.
164
- */
165
- export function tryRealPath(path: PathBuilderLike): Promise<string | null> {
166
- return realpath(path.toString()).catch((error) => {
167
- if (error.code === "ENOENT") return null
168
-
169
- throw error
170
- })
171
- }
172
-
173
- export function open(path: PathBuilderLike | URL, flags?: string | number, mode?: Mode): Promise<FileHandle> {
174
- return openNative(path instanceof URL ? path : path.toString(), flags, mode)
175
- }
176
-
177
- /**
178
- * The target a symbolic link points at, verbatim — relative if it was written relative.
179
- *
180
- * @throws EINVAL when the path is not a link, ENOENT when nothing is there.
181
- */
182
- export function readLink(path: PathBuilderLike): Promise<string> {
183
- return readlink(path.toString())
184
- }
185
-
186
- /**
187
- * Whether the process may WRITE to a path.
188
- *
189
- * A permission question, not an existence one: `access` answers about the caller's credentials against the file as it
190
- * stands, where a stat answers about the file. Absence reads as `false` here, which is what a caller checking "can I
191
- * write here" means by it.
192
- */
193
- export function isWritable(path: PathBuilderLike): Promise<boolean> {
194
- return access(path.toString(), constants.W_OK).then(
195
- () => true,
196
- () => false
197
- )
198
- }
199
-
200
- /**
201
- * Whether the process may EXECUTE a path.
202
- */
203
- export function isExecutable(path: PathBuilderLike): Promise<boolean> {
204
- return access(path.toString(), constants.X_OK).then(
205
- () => true,
206
- () => false
207
- )
208
- }
209
-
210
- /**
211
- * Every path matching a glob pattern.
212
- *
213
- * Sorted, because `glob` answers in directory order and a build that names its inputs in a receipt should name them the
214
- * same way twice.
215
- */
216
- export async function globPaths(pattern: string | string[]): Promise<string[]> {
217
- return (await Array.fromAsync(glob(pattern))).toSorted()
218
- }
219
-
220
- /**
221
- * A `file:` URL is passed through whole: `node:fs` accepts the object and rejects the string it prints.
222
- */
223
- function asTarget(path: PathBuilderLike | URL): URL | string {
224
- return path instanceof URL ? path : path.toString()
225
- }
226
-
227
- // #endregion
228
-
229
23
  // #region File Readers
230
24
 
231
25
  /**
@@ -295,8 +89,8 @@ function readTarget(pathSegments: Array<PathBuilderLike | URL>): URL | string {
295
89
  /**
296
90
  * Read a local text file.
297
91
  *
298
- * @category Node
299
92
  * @category Files
93
+ * @runtime node
300
94
  */
301
95
  export function readLocalTextFile<S extends Array<PathBuilderLike | URL>>(...pathSegments: S): Promise<string> {
302
96
  if (!pathSegments.length) {
@@ -307,7 +101,7 @@ export function readLocalTextFile<S extends Array<PathBuilderLike | URL>>(...pat
307
101
  }
308
102
 
309
103
  /**
310
- * @deprecated Use `readLocalJSONFile` instead
104
+ * @deprecated Use `readPackageJSONFile` instead
311
105
  */
312
106
  export function readLocalJSONFile<_T = Record<string, unknown>>(path: `${string}/package.json`): Promise<never>
313
107
 
@@ -316,8 +110,8 @@ export function readLocalJSONFile<_T = Record<string, unknown>>(path: `${string}
316
110
  *
317
111
  * Parsing is strict: a file that is not JSON throws here rather than answering `undefined` several frames later.
318
112
  *
319
- * @category Node
320
113
  * @category Files
114
+ * @runtime node
321
115
  * @see `readPackageJSON` in `#module/resolve-from` for a `package.json`, which answers the manifest shape and takes a
322
116
  * package name as readily as a path.
323
117
  */
@@ -334,76 +128,38 @@ export function readLocalJSONFile<
334
128
  }
335
129
 
336
130
  /**
337
- * Read a local file's bytes.
338
- *
339
- * @category Node
340
- * @category Files
341
- */
342
- export function readLocalBuffer<S extends Array<PathBuilderLike | URL>>(...pathSegments: S): Promise<Buffer> {
343
- if (!pathSegments.length) {
344
- throw new Error("No file path segments provided.")
345
- }
346
-
347
- return readFile(readTarget(pathSegments))
348
- }
349
-
350
- /**
351
- * List the entry names directly inside a directory.
352
- *
353
- * @category Node
354
- * @category Files
355
- */
356
- export function readDirectory(path: PathBuilderLike | URL): Promise<string[]> {
357
- return readdir(asTarget(path))
358
- }
359
-
360
- /**
361
- * List a directory's entries with their types, so a caller can tell a file from a directory without a stat apiece.
362
- *
363
- * @category Node
364
- * @category Files
365
- */
366
- export function readDirectoryEntries(path: PathBuilderLike | URL): Promise<Dirent[]> {
367
- return readdir(asTarget(path), { withFileTypes: true })
368
- }
369
-
370
- /**
371
- * List every entry under a directory, at any depth, as paths relative to it.
131
+ * Read a local JSON file, answering `null` when the file does not exist.
372
132
  *
373
- * The recursive counterpart to {@linkcode readDirectory}. It walks the whole tree before answering, so it is the wrong
374
- * reader for a directory whose size is unknown — reach for it where the tree is a build artifact you produced.
133
+ * Parsing is strict: a file that is not JSON throws here rather than answering `null` several frames later.
375
134
  *
376
- * @category Node
377
135
  * @category Files
136
+ * @runtime node
378
137
  */
379
- export function readDirectoryRecursive(path: PathBuilderLike | URL): Promise<string[]> {
380
- return readdir(asTarget(path), { recursive: true })
381
- }
138
+ export function tryReadLocalJSONFile<
139
+ T = Record<string, unknown>,
140
+ S extends Array<PathBuilderLike | URL> = Array<PathBuilderLike | URL>,
141
+ >(...pathSegments: S): Promise<T | null> {
142
+ return readLocalTextFile(...pathSegments)
143
+ .then((content) => parseJSONStrict<T>(content))
144
+ .catch((error) => {
145
+ if (error.code === "ENOENT") return null
382
146
 
383
- /**
384
- * List every entry under a directory, at any depth, WITH its type — `Dirent.parentPath` names the directory each was
385
- * found in, which a plain recursive read leaves the caller to reconstruct.
386
- */
387
- export function readDirectoryEntriesRecursive(path: PathBuilderLike | URL): Promise<Dirent[]> {
388
- return readdir(asTarget(path), { recursive: true, withFileTypes: true })
147
+ throw error
148
+ })
389
149
  }
390
150
 
391
151
  /**
392
- * List a directory's entry names, answering an empty list when the directory does not exist.
393
- *
394
- * The distinction is the caller's to make and this function makes ONE of the two available: an absent directory and an
395
- * empty one are the same answer here. Where absence means something — an unbuilt artifact, a missing extract — use
396
- * {@linkcode readDirectory} and let the ENOENT reach you.
152
+ * Read a local file's bytes.
397
153
  *
398
- * @category Node
399
154
  * @category Files
155
+ * @runtime node
400
156
  */
401
- export function tryReadDirectory(path: PathBuilderLike | URL): Promise<string[]> {
402
- return readdir(asTarget(path)).catch((error) => {
403
- if (error.code === "ENOENT") return []
157
+ export function readLocalBuffer<S extends Array<PathBuilderLike | URL>>(...pathSegments: S): Promise<Buffer> {
158
+ if (!pathSegments.length) {
159
+ throw new Error("No file path segments provided.")
160
+ }
404
161
 
405
- throw error
406
- })
162
+ return readFile(readTarget(pathSegments))
407
163
  }
408
164
 
409
165
  // #endregion
package/lib/fs/streams.ts CHANGED
@@ -15,6 +15,7 @@
15
15
 
16
16
  import { createReadStream, createWriteStream, type ReadStream, type WriteStream } from "node:fs"
17
17
 
18
+ import iconv from "iconv-lite"
18
19
  import type { PathBuilderLike } from "path-ts"
19
20
 
20
21
  /**
@@ -41,6 +42,63 @@ export function openReadStream(path: PathBuilderLike, options?: Parameters<typeo
41
42
  * first chunk rather than at open time reports the missing directory somewhere the caller is no longer looking. Call
42
43
  * `makeDirectories` first where the parent may be absent.
43
44
  */
45
+ /**
46
+ * Re-encode a byte stream from a legacy encoding into UTF-8, so a UTF-8 reader can consume it.
47
+ *
48
+ * The national registers this repository reads are not all UTF-8: Korea's address portal ships CP949, Japan's postcode
49
+ * file Shift_JIS. `spliterator` splits UTF-8 bytes, so the decode happens upstream of the split rather than after it —
50
+ * a line boundary found in CP949 bytes is not a line boundary.
51
+ *
52
+ * NOT `TextDecoder`, AND THE DIFFERENCE IS NOT SMALL. Node's WHATWG `euc-kr` implements EUC-KR proper (KS X 1001) and
53
+ * not the UHC extension CP949 adds in lead bytes 0x81–0xA0. Of the 17,048 two-byte sequences Python's `cp949` accepts,
54
+ * `TextDecoder('euc-kr')` reads 8,824 differently: 6,475 become U+FFFD and 2,349 become a DIFFERENT character with no
55
+ * error raised. `iconv-lite` disagrees with `cp949` on none of the 17,048.
56
+ *
57
+ * It is not a rare corner. One row in 48,000 of the Korean address register carries such a sequence — `더샾오피스텔`, bytes
58
+ * `b4 f5 98 de bf c0 c7 c7 bd ba c5 da`, which `TextDecoder` reads as `더乍의퓰뵀�`.
59
+ *
60
+ * The decoder is STREAMING for the same reason a `TextDecoder` would need `{ stream: true }`: a multi-byte character
61
+ * split across two chunks must be held until its tail arrives, where a per-chunk decode emits a replacement character
62
+ * and corrupts the row. `iconv-lite`'s stream decoder holds that state, and `end()` flushes what is left.
63
+ *
64
+ * @category Files
65
+ * @param encoding An `iconv-lite` label — `cp949`, `shift_jis`, `gbk`.
66
+ */
67
+ export async function* decodeByteStream(
68
+ source: AsyncIterable<Uint8Array>,
69
+ encoding: string
70
+ ): AsyncGenerator<Uint8Array> {
71
+ const decoder = iconv.getDecoder(encoding)
72
+ const encoder = new TextEncoder()
73
+
74
+ for await (const chunk of source) {
75
+ const text = decoder.write(Buffer.from(chunk))
76
+
77
+ if (text) {
78
+ yield encoder.encode(text)
79
+ }
80
+ }
81
+
82
+ const tail = decoder.end()
83
+
84
+ if (tail) {
85
+ yield encoder.encode(tail)
86
+ }
87
+ }
88
+
89
+ /**
90
+ * Decode bytes already in memory from a legacy encoding, the one-shot sibling of {@link decodeByteStream}.
91
+ *
92
+ * Same reasoning, same reason not to reach for `TextDecoder`, and it lives here so a reader that finds one finds the
93
+ * other. Use this when the whole file is a bounded size the publisher fixes; use the stream when it is not.
94
+ *
95
+ * @category Files
96
+ * @param encoding An `iconv-lite` label — `cp949`, `cp932`, `gbk`.
97
+ */
98
+ export function decodeBytes(bytes: Uint8Array, encoding: string): string {
99
+ return iconv.decode(Buffer.from(bytes), encoding)
100
+ }
101
+
44
102
  export function openWriteStream(path: PathBuilderLike, options?: Parameters<typeof createWriteStream>[1]): WriteStream {
45
103
  return createWriteStream(path.toString(), options)
46
104
  }
package/lib/fs/writers.ts CHANGED
@@ -59,8 +59,8 @@ export type BufferLike =
59
59
  /**
60
60
  * Write a local text file, creating its parent directory first.
61
61
  *
62
- * @category Node
63
62
  * @category Files
63
+ * @runtime node
64
64
  */
65
65
  export async function writeLocalTextFile<S extends PathBuilderLike[]>(
66
66
  content: string | Promise<string>,
@@ -82,8 +82,8 @@ export async function writeLocalTextFile<S extends PathBuilderLike[]>(
82
82
  /**
83
83
  * Write a local JSON file, tab-indented, creating its parent directory first.
84
84
  *
85
- * @category Node
86
85
  * @category Files
86
+ * @runtime node
87
87
  */
88
88
  export function writeLocalJSONFile<T = Record<string, unknown>, S extends PathBuilderLike[] = PathBuilderLike[]>(
89
89
  content: T,
@@ -97,8 +97,8 @@ export function writeLocalJSONFile<T = Record<string, unknown>, S extends PathBu
97
97
  /**
98
98
  * Write a local file's bytes, creating its parent directory first.
99
99
  *
100
- * @category Node
101
100
  * @category Files
101
+ * @runtime node
102
102
  */
103
103
  export async function writeLocalBuffer<S extends PathBuilderLike[]>(
104
104
  content: BufferLike,
@@ -122,8 +122,8 @@ export async function writeLocalBuffer<S extends PathBuilderLike[]>(
122
122
  * then says so, and a reader does not have to follow the value back to its producer. This overload exists for the sites
123
123
  * where it genuinely does not: a payload that is a string on one branch and bytes on another.
124
124
  *
125
- * @category Node
126
125
  * @category Files
126
+ * @runtime node
127
127
  */
128
128
  /**
129
129
  * Write a UTF-8 text file readable and writable by its owner alone (`0600`), creating the parent directory. The mode is
@@ -169,8 +169,8 @@ export async function writeLocalFile<S extends PathBuilderLike[]>(
169
169
  /**
170
170
  * Append text to a local file, creating it and its parent directory when neither exists.
171
171
  *
172
- * @category Node
173
172
  * @category Files
173
+ * @runtime node
174
174
  */
175
175
  export async function appendLocalTextFile<S extends PathBuilderLike[]>(
176
176
  content: string,
package/lib/fs/zip.ts CHANGED
@@ -20,11 +20,13 @@ import { pipeline } from "node:stream/promises"
20
20
  import { crc32 } from "node:zlib"
21
21
 
22
22
  import ADMZip from "adm-zip"
23
+ import iconv from "iconv-lite"
23
24
  import { resolvePath, dirname, basename, type PathBuilderLike } from "path-ts"
24
25
  import { open as openArchive, type Entry, type ZipFileOptions } from "yauzl-promise"
25
26
 
26
27
  import { tryStat } from "#fs/readers"
27
28
  import { makeDirectories } from "#fs/writers"
29
+ import { once } from "#utils/events"
28
30
 
29
31
  type StreamingArchive = Awaited<ReturnType<typeof openArchive>>
30
32
 
@@ -34,12 +36,52 @@ type EntryStream = Awaited<ReturnType<Entry["openReadStream"]>>
34
36
  * The one place this package touches yauzl's own lifecycle. Every reader below ends an archive by leaving scope, so
35
37
  * `close()` is called here and nowhere else.
36
38
  */
37
- async function openStreamingArchive(archivePath: PathBuilderLike): Promise<StreamingArchive & AsyncDisposable> {
38
- const archive = await openArchive(String(archivePath))
39
+ async function openStreamingArchive(
40
+ archivePath: PathBuilderLike,
41
+ options?: ZipNameOptions
42
+ ): Promise<StreamingArchive & AsyncDisposable> {
43
+ // `decodeStrings: false` hands back the central directory's raw name bytes, which is the only way to read a name the
44
+ // archive never said the encoding of. See {@link ZipNameOptions}.
45
+ const archive = await openArchive(String(archivePath), options?.filenameEncoding ? { decodeStrings: false } : {})
39
46
 
40
47
  return Object.assign(archive, { [Symbol.asyncDispose]: () => archive.close() })
41
48
  }
42
49
 
50
+ /**
51
+ * How to read member names that the archive does not declare an encoding for.
52
+ *
53
+ * A zip flags UTF-8 names with bit 11, and yauzl decodes those correctly. Without the flag the format says CP437, so a
54
+ * publisher writing CP949, Shift_JIS or GBK names produces bytes that decode to mojibake and match no selector —
55
+ * Korea's address portal writes `주소_서울특별시.txt` and the reader sees `┴╓╝╥_╝¡┐ïÆ╣▌╗π.txt`.
56
+ *
57
+ * Naming an encoding decodes the RAW bytes instead, which is not the same as recoding the mojibake back through CP437:
58
+ * that round trip needs a 256-entry table and silently mangles any byte CP437 maps to a character it cannot invert.
59
+ *
60
+ * @category Files
61
+ */
62
+ export interface ZipNameOptions {
63
+ /**
64
+ * An `iconv-lite` label — `cp949`, `shift_jis`, `gbk`. Omit when the archive's names are ASCII or properly flagged
65
+ * UTF-8, which is every other archive this repository reads.
66
+ */
67
+ filenameEncoding?: string
68
+ }
69
+
70
+ /**
71
+ * A member's name, decoded as {@link ZipNameOptions} asks.
72
+ *
73
+ * `iconv-lite` rather than `TextDecoder` for the reason `decodeByteStream` gives: Node's WHATWG `euc-kr` is EUC-KR
74
+ * proper and reads 8,824 of CP949's 17,048 two-byte sequences differently, so a member whose name uses the UHC
75
+ * extension would be looked for under a name that does not exist.
76
+ */
77
+ function entryName(entry: Entry, options?: ZipNameOptions): string {
78
+ const raw = entry.filename as unknown
79
+
80
+ if (typeof raw === "string") return raw
81
+
82
+ return iconv.decode(Buffer.from(raw as Uint8Array), options?.filenameEncoding ?? "utf8")
83
+ }
84
+
43
85
  /**
44
86
  * One member's decompressed byte stream, ended when the owning scope exits.
45
87
  *
@@ -52,7 +94,20 @@ async function openEntryStream(entry: Entry, options?: ZipFileOptions): Promise<
52
94
 
53
95
  return Object.assign(contents, {
54
96
  [Symbol.asyncDispose]: async () => {
97
+ // A member read to its end has already released yauzl's read, and its `close` has already been delivered — so
98
+ // waiting for that event here would wait forever. `readableEnded` is the test that separates the two paths:
99
+ // true after a full read, false after a `take` or a `break`. `closed` is NOT the test, because Node sets it when
100
+ // the close event is queued rather than delivered, so a guard on it skips the wait on the path that needs it.
101
+ if (contents.readableEnded) return
102
+
103
+ const closed = once(contents, "close").catch(() => undefined)
104
+
55
105
  contents.destroy()
106
+
107
+ // Wait for the teardown to finish, not merely to start. `destroy()` returns before yauzl has released its read,
108
+ // and the archive's own disposer runs next: it then raises `Cannot close while reading in progress` on the
109
+ // early-exit path this reader documents as supported.
110
+ await closed
56
111
  },
57
112
  })
58
113
  }
@@ -133,13 +188,13 @@ function selectorMatches(selector: ZipEntrySelector, name: string): boolean {
133
188
  *
134
189
  * @category Files
135
190
  */
136
- export async function listZipEntries(archivePath: PathBuilderLike): Promise<ZipEntryInfo[]> {
137
- await using archive = await openStreamingArchive(archivePath)
191
+ export async function listZipEntries(archivePath: PathBuilderLike, options?: ZipNameOptions): Promise<ZipEntryInfo[]> {
192
+ await using archive = await openStreamingArchive(archivePath, options)
138
193
  const entries: ZipEntryInfo[] = []
139
194
 
140
195
  for await (const entry of archive) {
141
196
  entries.push({
142
- name: entry.filename,
197
+ name: entryName(entry, options),
143
198
  compressedSize: entry.compressedSize,
144
199
  uncompressedSize: entry.uncompressedSize,
145
200
  })
@@ -160,12 +215,13 @@ export async function listZipEntries(archivePath: PathBuilderLike): Promise<ZipE
160
215
  */
161
216
  export async function* readZipEntry(
162
217
  archivePath: PathBuilderLike,
163
- selector: ZipEntrySelector
218
+ selector: ZipEntrySelector,
219
+ options?: ZipNameOptions
164
220
  ): AsyncGenerator<Uint8Array> {
165
- await using archive = await openStreamingArchive(archivePath)
221
+ await using archive = await openStreamingArchive(archivePath, options)
166
222
 
167
223
  for await (const entry of archive) {
168
- if (!selectorMatches(selector, entry.filename)) continue
224
+ if (!selectorMatches(selector, entryName(entry, options))) continue
169
225
 
170
226
  await using contents = await openEntryStream(entry)
171
227
 
@@ -10,8 +10,8 @@
10
10
  * every invocation.
11
11
  */
12
12
 
13
- import { verifyLicenseKey, type LicenseKeyVerification } from "#license/key"
14
- import { readConfiguredLicenseToken } from "#license/key-file"
13
+ import { readConfiguredLicenseToken } from "#license/key/file"
14
+ import { verifyLicenseKey, type LicenseKeyVerification } from "#license/key/index"
15
15
  import { trustedLicenseSigningKeys } from "#license/register"
16
16
 
17
17
  /**
@@ -11,8 +11,8 @@
11
11
 
12
12
  export * from "#license/configured"
13
13
  export * from "#license/docs-site"
14
- export * from "#license/key"
15
- export * from "#license/key-file"
14
+ export * from "#license/key/index"
15
+ export * from "#license/key/file"
16
16
  export * from "#license/obligations"
17
17
  export * from "#license/register"
18
18
  export * from "#license/stamp"
@@ -8,7 +8,7 @@
8
8
  * known to carry, and it says `recognized: false` for an identifier it does not know rather than guessing.
9
9
  */
10
10
 
11
- import type { LicenseKeyVerification } from "#license/key"
11
+ import type { LicenseKeyVerification } from "#license/key/index"
12
12
  import type { LicenseKeyPublication } from "#license/publication"
13
13
 
14
14
  /**
@@ -14,7 +14,7 @@
14
14
  */
15
15
 
16
16
  import { docsSiteURL } from "#license/docs-site"
17
- import type { LicenseKeyVerification } from "#license/key"
17
+ import type { LicenseKeyVerification } from "#license/key/index"
18
18
  import { appliedLicenseBranch } from "#license/obligations"
19
19
 
20
20
  /**
@@ -13,8 +13,9 @@
13
13
  * task-3 follow-up in DECISIONS.md).
14
14
  */
15
15
 
16
+ import type { ComponentTag } from "@mailwoman/codex/component"
17
+
16
18
  import type { ClassifierPolicy } from "#policy/policy"
17
- import type { ComponentTag } from "#types"
18
19
 
19
20
  export interface LocaleProfile {
20
21
  /**
@@ -9,8 +9,9 @@
9
9
  * §LocaleProfile validation rule).
10
10
  */
11
11
 
12
+ import { COMPONENT_TAGS, type ComponentTag } from "@mailwoman/codex/component"
13
+
12
14
  import type { LocaleProfile, LocaleRegistry } from "#locale/locale"
13
- import { COMPONENT_TAGS, type ComponentTag } from "#types"
14
15
 
15
16
  const COMPONENT_TAG_SET = new Set<ComponentTag>(COMPONENT_TAGS)
16
17