@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
@@ -7,118 +7,10 @@
7
7
  * `node:fs` is reached from this directory alone, and every reader answers a promise: no executable repository
8
8
  * code makes a blocking filesystem call, and the `debt` check in `packages/repo-health` counts any that appears.
9
9
  */
10
- import type { Dirent, Mode, Stats } from "node:fs";
11
- import { type FileHandle } from "node:fs/promises";
12
10
  import { type PathBuilderLike } from "path-ts";
13
- import { type ByteFormatterOptions } from "#fs/formatters";
11
+ export * from "#fs/readers/stat";
14
12
  export type { Dirent, PathLike, Stats } from "node:fs";
15
13
  export type { FileHandle } from "node:fs/promises";
16
- /**
17
- * Attempts to stat a file or directory.
18
- *
19
- * A `URL` is passed through rather than stringified: `node:fs` accepts a `file:` URL object, and rejects the string it
20
- * prints — `stat("file:///etc/hostname")` is ENOENT, which this function reports as absence. Every caller that looks a
21
- * file up by URL therefore read "not there" for everything, and `cli-native/command-router.ts` answered `Unknown
22
- * command` for every command it has.
23
- *
24
- * @throws If the path exists but cannot be statted for some reason other than non-existence.
25
- */
26
- export declare function tryStat(pathBuilderLike: PathBuilderLike | URL): Promise<Stats | null>;
27
- /**
28
- * Stat a file or directory, raising ENOENT when nothing is there.
29
- *
30
- * The throwing counterpart to {@linkcode tryStat}. Reach for this one where absence is a defect the caller wants
31
- * reported, and for {@linkcode tryStat} where absence is an answer.
32
- */
33
- export declare function statPath(path: PathBuilderLike | URL): Promise<Stats>;
34
- /**
35
- * Stat a path without following a symbolic link, so the answer describes the link itself.
36
- */
37
- export declare function statLink(path: PathBuilderLike | URL): Promise<Stats>;
38
- /**
39
- * Stat a path without following a symbolic link, answering `null` when nothing is there.
40
- *
41
- * The link-level counterpart to {@linkcode tryStat}.
42
- */
43
- export declare function tryStatLink(path: PathBuilderLike | URL): Promise<Stats | null>;
44
- /**
45
- * Whether a path exists, whatever it is.
46
- *
47
- * The asynchronous answer to `existsSync`, which is the single most-called synchronous builtin in the repository.
48
- * Prefer {@linkcode isFile} or {@linkcode isDirectory} where the caller goes on to assume one or the other: a directory
49
- * where a file was expected passes this check and fails the next line.
50
- */
51
- export declare function pathExists(path: PathBuilderLike | URL): Promise<boolean>;
52
- /**
53
- * Whether a path exists and is a directory.
54
- */
55
- export declare function isDirectory(path: PathBuilderLike | URL): Promise<boolean>;
56
- /**
57
- * Whether a path exists and is a file.
58
- */
59
- export declare function isFile(path: PathBuilderLike | URL): Promise<boolean>;
60
- /**
61
- * Whether a path exists and is a symbolic link.
62
- */
63
- export declare function isSymbolicLink(path: PathBuilderLike | URL): Promise<boolean>;
64
- /**
65
- * Whether a directory entry leads to a directory, symbolic links included.
66
- *
67
- * `Dirent.isDirectory()` is FALSE for a symbolic link to a directory, so a walk keyed on it alone skips every linked
68
- * tree — while a glob with `followSymbolicLinks` (the default) descends into them, and the two then describe different
69
- * trees. A link is resolved through `stat`, which also answers `false` for a dangling one.
70
- */
71
- export declare function entryLeadsToDirectory(entry: Dirent): Promise<boolean>;
72
- /**
73
- * The size of a file in bytes.
74
- *
75
- * @throws ENOENT when the file does not exist.
76
- */
77
- export declare function readFileSize(path: PathBuilderLike | URL): Promise<number>;
78
- /**
79
- * The size of a file, rendered in IEC units (`12.3 MiB`) — the unit for anything a machine measured.
80
- *
81
- * @throws ENOENT when the file does not exist.
82
- */
83
- export declare function formatFileSize(path: PathBuilderLike | URL, options?: ByteFormatterOptions): Promise<string>;
84
- /**
85
- * Resolve a path to its canonical location, following every symbolic link.
86
- *
87
- * @throws ENOENT when nothing is there. {@linkcode tryRealPath} answers `null` instead.
88
- */
89
- export declare function realPath(path: PathBuilderLike): Promise<string>;
90
- /**
91
- * Resolve a path to its canonical location, following every symbolic link.
92
- *
93
- * @returns The canonical path, or `null` when nothing is there.
94
- */
95
- export declare function tryRealPath(path: PathBuilderLike): Promise<string | null>;
96
- export declare function open(path: PathBuilderLike | URL, flags?: string | number, mode?: Mode): Promise<FileHandle>;
97
- /**
98
- * The target a symbolic link points at, verbatim — relative if it was written relative.
99
- *
100
- * @throws EINVAL when the path is not a link, ENOENT when nothing is there.
101
- */
102
- export declare function readLink(path: PathBuilderLike): Promise<string>;
103
- /**
104
- * Whether the process may WRITE to a path.
105
- *
106
- * A permission question, not an existence one: `access` answers about the caller's credentials against the file as it
107
- * stands, where a stat answers about the file. Absence reads as `false` here, which is what a caller checking "can I
108
- * write here" means by it.
109
- */
110
- export declare function isWritable(path: PathBuilderLike): Promise<boolean>;
111
- /**
112
- * Whether the process may EXECUTE a path.
113
- */
114
- export declare function isExecutable(path: PathBuilderLike): Promise<boolean>;
115
- /**
116
- * Every path matching a glob pattern.
117
- *
118
- * Sorted, because `glob` answers in directory order and a build that names its inputs in a receipt should name them the
119
- * same way twice.
120
- */
121
- export declare function globPaths(pattern: string | string[]): Promise<string[]>;
122
14
  /**
123
15
  * Read the first `byteSize` bytes of a file, or the whole file if it is smaller.
124
16
  *
@@ -144,12 +36,12 @@ export declare function readFileRange(path: PathBuilderLike, offset: number, len
144
36
  /**
145
37
  * Read a local text file.
146
38
  *
147
- * @category Node
148
39
  * @category Files
40
+ * @runtime node
149
41
  */
150
42
  export declare function readLocalTextFile<S extends Array<PathBuilderLike | URL>>(...pathSegments: S): Promise<string>;
151
43
  /**
152
- * @deprecated Use `readLocalJSONFile` instead
44
+ * @deprecated Use `readPackageJSONFile` instead
153
45
  */
154
46
  export declare function readLocalJSONFile<_T = Record<string, unknown>>(path: `${string}/package.json`): Promise<never>;
155
47
  /**
@@ -157,59 +49,28 @@ export declare function readLocalJSONFile<_T = Record<string, unknown>>(path: `$
157
49
  *
158
50
  * Parsing is strict: a file that is not JSON throws here rather than answering `undefined` several frames later.
159
51
  *
160
- * @category Node
161
52
  * @category Files
53
+ * @runtime node
162
54
  * @see `readPackageJSON` in `#module/resolve-from` for a `package.json`, which answers the manifest shape and takes a
163
55
  * package name as readily as a path.
164
56
  */
165
57
  export declare function readLocalJSONFile<T = Record<string, unknown>, S extends Array<PathBuilderLike | URL> = Array<PathBuilderLike | URL>>(...pathSegments: S): Promise<T>;
166
58
  /**
167
- * Read a local file's bytes.
168
- *
169
- * @category Node
170
- * @category Files
171
- */
172
- export declare function readLocalBuffer<S extends Array<PathBuilderLike | URL>>(...pathSegments: S): Promise<Buffer>;
173
- /**
174
- * List the entry names directly inside a directory.
59
+ * Read a local JSON file, answering `null` when the file does not exist.
175
60
  *
176
- * @category Node
177
- * @category Files
178
- */
179
- export declare function readDirectory(path: PathBuilderLike | URL): Promise<string[]>;
180
- /**
181
- * List a directory's entries with their types, so a caller can tell a file from a directory without a stat apiece.
61
+ * Parsing is strict: a file that is not JSON throws here rather than answering `null` several frames later.
182
62
  *
183
- * @category Node
184
63
  * @category Files
64
+ * @runtime node
185
65
  */
186
- export declare function readDirectoryEntries(path: PathBuilderLike | URL): Promise<Dirent[]>;
66
+ export declare function tryReadLocalJSONFile<T = Record<string, unknown>, S extends Array<PathBuilderLike | URL> = Array<PathBuilderLike | URL>>(...pathSegments: S): Promise<T | null>;
187
67
  /**
188
- * List every entry under a directory, at any depth, as paths relative to it.
189
- *
190
- * The recursive counterpart to {@linkcode readDirectory}. It walks the whole tree before answering, so it is the wrong
191
- * reader for a directory whose size is unknown — reach for it where the tree is a build artifact you produced.
192
- *
193
- * @category Node
194
- * @category Files
195
- */
196
- export declare function readDirectoryRecursive(path: PathBuilderLike | URL): Promise<string[]>;
197
- /**
198
- * List every entry under a directory, at any depth, WITH its type — `Dirent.parentPath` names the directory each was
199
- * found in, which a plain recursive read leaves the caller to reconstruct.
200
- */
201
- export declare function readDirectoryEntriesRecursive(path: PathBuilderLike | URL): Promise<Dirent[]>;
202
- /**
203
- * List a directory's entry names, answering an empty list when the directory does not exist.
204
- *
205
- * The distinction is the caller's to make and this function makes ONE of the two available: an absent directory and an
206
- * empty one are the same answer here. Where absence means something — an unbuilt artifact, a missing extract — use
207
- * {@linkcode readDirectory} and let the ENOENT reach you.
68
+ * Read a local file's bytes.
208
69
  *
209
- * @category Node
210
70
  * @category Files
71
+ * @runtime node
211
72
  */
212
- export declare function tryReadDirectory(path: PathBuilderLike | URL): Promise<string[]>;
73
+ export declare function readLocalBuffer<S extends Array<PathBuilderLike | URL>>(...pathSegments: S): Promise<Buffer>;
213
74
  /**
214
75
  * Drain standard input.
215
76
  *
@@ -1 +1 @@
1
- {"version":3,"file":"readers.d.ts","sourceRoot":"","sources":["../../lib/fs/readers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM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AM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,MAAM,eAAe,GAAG,OAAO,CAAC,KAAK,CAAC,CAAA;AAE/G;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAChC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3B,CAAC,SAAS,KAAK,CAAC,eAAe,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,eAAe,GAAG,GAAG,CAAC,EACpE,GAAG,YAAY,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;AASjC;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CACnC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3B,CAAC,SAAS,KAAK,CAAC,eAAe,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,eAAe,GAAG,GAAG,CAAC,EACpE,GAAG,YAAY,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAQvC;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,KAAK,CAAC,eAAe,GAAG,GAAG,CAAC,EAAE,GAAG,YAAY,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAM3G;AAMD;;;;;;GAMG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,CAEzD;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAErF"}
package/out/fs/readers.js CHANGED
@@ -7,177 +7,11 @@
7
7
  * `node:fs` is reached from this directory alone, and every reader answers a promise: no executable repository
8
8
  * code makes a blocking filesystem call, and the `debt` check in `packages/repo-health` counts any that appears.
9
9
  */
10
- import { open as openNative, access, constants, glob, lstat, readFile, readdir, readlink, realpath, stat, } from "node:fs/promises";
10
+ import { readFile } from "node:fs/promises";
11
11
  import { resolvePath } from "path-ts";
12
- import { ByteFormatter } from "#fs/formatters";
12
+ import { open } from "#fs/readers/stat";
13
13
  import { parseJSONStrict } from "#json";
14
- // #region Stat utils
15
- /**
16
- * Attempts to stat a file or directory.
17
- *
18
- * A `URL` is passed through rather than stringified: `node:fs` accepts a `file:` URL object, and rejects the string it
19
- * prints — `stat("file:///etc/hostname")` is ENOENT, which this function reports as absence. Every caller that looks a
20
- * file up by URL therefore read "not there" for everything, and `cli-native/command-router.ts` answered `Unknown
21
- * command` for every command it has.
22
- *
23
- * @throws If the path exists but cannot be statted for some reason other than non-existence.
24
- */
25
- export function tryStat(pathBuilderLike) {
26
- const target = pathBuilderLike instanceof URL ? pathBuilderLike : pathBuilderLike.toString();
27
- return stat(target).catch((error) => {
28
- if (error.code === "ENOENT")
29
- return null;
30
- throw error;
31
- });
32
- }
33
- /**
34
- * Stat a file or directory, raising ENOENT when nothing is there.
35
- *
36
- * The throwing counterpart to {@linkcode tryStat}. Reach for this one where absence is a defect the caller wants
37
- * reported, and for {@linkcode tryStat} where absence is an answer.
38
- */
39
- export function statPath(path) {
40
- return stat(path instanceof URL ? path : path.toString());
41
- }
42
- /**
43
- * Stat a path without following a symbolic link, so the answer describes the link itself.
44
- */
45
- export function statLink(path) {
46
- return lstat(path instanceof URL ? path : path.toString());
47
- }
48
- /**
49
- * Stat a path without following a symbolic link, answering `null` when nothing is there.
50
- *
51
- * The link-level counterpart to {@linkcode tryStat}.
52
- */
53
- export function tryStatLink(path) {
54
- return lstat(path instanceof URL ? path : path.toString()).catch((error) => {
55
- if (error.code === "ENOENT")
56
- return null;
57
- throw error;
58
- });
59
- }
60
- /**
61
- * Whether a path exists, whatever it is.
62
- *
63
- * The asynchronous answer to `existsSync`, which is the single most-called synchronous builtin in the repository.
64
- * Prefer {@linkcode isFile} or {@linkcode isDirectory} where the caller goes on to assume one or the other: a directory
65
- * where a file was expected passes this check and fails the next line.
66
- */
67
- export function pathExists(path) {
68
- return tryStat(path).then((stats) => stats !== null);
69
- }
70
- /**
71
- * Whether a path exists and is a directory.
72
- */
73
- export function isDirectory(path) {
74
- return tryStat(path).then((stats) => stats?.isDirectory() ?? false);
75
- }
76
- /**
77
- * Whether a path exists and is a file.
78
- */
79
- export function isFile(path) {
80
- return tryStat(path).then((stats) => stats?.isFile() ?? false);
81
- }
82
- /**
83
- * Whether a path exists and is a symbolic link.
84
- */
85
- export function isSymbolicLink(path) {
86
- return tryStatLink(path).then((stats) => stats?.isSymbolicLink() ?? false);
87
- }
88
- /**
89
- * Whether a directory entry leads to a directory, symbolic links included.
90
- *
91
- * `Dirent.isDirectory()` is FALSE for a symbolic link to a directory, so a walk keyed on it alone skips every linked
92
- * tree — while a glob with `followSymbolicLinks` (the default) descends into them, and the two then describe different
93
- * trees. A link is resolved through `stat`, which also answers `false` for a dangling one.
94
- */
95
- export function entryLeadsToDirectory(entry) {
96
- if (entry.isDirectory())
97
- return Promise.resolve(true);
98
- if (!entry.isSymbolicLink())
99
- return Promise.resolve(false);
100
- return isDirectory(resolvePath(entry.parentPath, entry.name));
101
- }
102
- /**
103
- * The size of a file in bytes.
104
- *
105
- * @throws ENOENT when the file does not exist.
106
- */
107
- export function readFileSize(path) {
108
- return statPath(path).then((stats) => stats.size);
109
- }
110
- /**
111
- * The size of a file, rendered in IEC units (`12.3 MiB`) — the unit for anything a machine measured.
112
- *
113
- * @throws ENOENT when the file does not exist.
114
- */
115
- export async function formatFileSize(path, options) {
116
- return ByteFormatter.formatIEC(await readFileSize(path), options);
117
- }
118
- /**
119
- * Resolve a path to its canonical location, following every symbolic link.
120
- *
121
- * @throws ENOENT when nothing is there. {@linkcode tryRealPath} answers `null` instead.
122
- */
123
- export function realPath(path) {
124
- return realpath(path.toString());
125
- }
126
- /**
127
- * Resolve a path to its canonical location, following every symbolic link.
128
- *
129
- * @returns The canonical path, or `null` when nothing is there.
130
- */
131
- export function tryRealPath(path) {
132
- return realpath(path.toString()).catch((error) => {
133
- if (error.code === "ENOENT")
134
- return null;
135
- throw error;
136
- });
137
- }
138
- export function open(path, flags, mode) {
139
- return openNative(path instanceof URL ? path : path.toString(), flags, mode);
140
- }
141
- /**
142
- * The target a symbolic link points at, verbatim — relative if it was written relative.
143
- *
144
- * @throws EINVAL when the path is not a link, ENOENT when nothing is there.
145
- */
146
- export function readLink(path) {
147
- return readlink(path.toString());
148
- }
149
- /**
150
- * Whether the process may WRITE to a path.
151
- *
152
- * A permission question, not an existence one: `access` answers about the caller's credentials against the file as it
153
- * stands, where a stat answers about the file. Absence reads as `false` here, which is what a caller checking "can I
154
- * write here" means by it.
155
- */
156
- export function isWritable(path) {
157
- return access(path.toString(), constants.W_OK).then(() => true, () => false);
158
- }
159
- /**
160
- * Whether the process may EXECUTE a path.
161
- */
162
- export function isExecutable(path) {
163
- return access(path.toString(), constants.X_OK).then(() => true, () => false);
164
- }
165
- /**
166
- * Every path matching a glob pattern.
167
- *
168
- * Sorted, because `glob` answers in directory order and a build that names its inputs in a receipt should name them the
169
- * same way twice.
170
- */
171
- export async function globPaths(pattern) {
172
- return (await Array.fromAsync(glob(pattern))).toSorted();
173
- }
174
- /**
175
- * A `file:` URL is passed through whole: `node:fs` accepts the object and rejects the string it prints.
176
- */
177
- function asTarget(path) {
178
- return path instanceof URL ? path : path.toString();
179
- }
180
- // #endregion
14
+ export * from "#fs/readers/stat";
181
15
  // #region File Readers
182
16
  /**
183
17
  * Read the first `byteSize` bytes of a file, or the whole file if it is smaller.
@@ -239,8 +73,8 @@ function readTarget(pathSegments) {
239
73
  /**
240
74
  * Read a local text file.
241
75
  *
242
- * @category Node
243
76
  * @category Files
77
+ * @runtime node
244
78
  */
245
79
  export function readLocalTextFile(...pathSegments) {
246
80
  if (!pathSegments.length) {
@@ -252,70 +86,33 @@ export function readLocalJSONFile(...pathSegments) {
252
86
  return readLocalTextFile(...pathSegments).then((content) => parseJSONStrict(content));
253
87
  }
254
88
  /**
255
- * Read a local file's bytes.
256
- *
257
- * @category Node
258
- * @category Files
259
- */
260
- export function readLocalBuffer(...pathSegments) {
261
- if (!pathSegments.length) {
262
- throw new Error("No file path segments provided.");
263
- }
264
- return readFile(readTarget(pathSegments));
265
- }
266
- /**
267
- * List the entry names directly inside a directory.
89
+ * Read a local JSON file, answering `null` when the file does not exist.
268
90
  *
269
- * @category Node
270
- * @category Files
271
- */
272
- export function readDirectory(path) {
273
- return readdir(asTarget(path));
274
- }
275
- /**
276
- * List a directory's entries with their types, so a caller can tell a file from a directory without a stat apiece.
91
+ * Parsing is strict: a file that is not JSON throws here rather than answering `null` several frames later.
277
92
  *
278
- * @category Node
279
93
  * @category Files
94
+ * @runtime node
280
95
  */
281
- export function readDirectoryEntries(path) {
282
- return readdir(asTarget(path), { withFileTypes: true });
283
- }
284
- /**
285
- * List every entry under a directory, at any depth, as paths relative to it.
286
- *
287
- * The recursive counterpart to {@linkcode readDirectory}. It walks the whole tree before answering, so it is the wrong
288
- * reader for a directory whose size is unknown — reach for it where the tree is a build artifact you produced.
289
- *
290
- * @category Node
291
- * @category Files
292
- */
293
- export function readDirectoryRecursive(path) {
294
- return readdir(asTarget(path), { recursive: true });
295
- }
296
- /**
297
- * List every entry under a directory, at any depth, WITH its type — `Dirent.parentPath` names the directory each was
298
- * found in, which a plain recursive read leaves the caller to reconstruct.
299
- */
300
- export function readDirectoryEntriesRecursive(path) {
301
- return readdir(asTarget(path), { recursive: true, withFileTypes: true });
96
+ export function tryReadLocalJSONFile(...pathSegments) {
97
+ return readLocalTextFile(...pathSegments)
98
+ .then((content) => parseJSONStrict(content))
99
+ .catch((error) => {
100
+ if (error.code === "ENOENT")
101
+ return null;
102
+ throw error;
103
+ });
302
104
  }
303
105
  /**
304
- * List a directory's entry names, answering an empty list when the directory does not exist.
305
- *
306
- * The distinction is the caller's to make and this function makes ONE of the two available: an absent directory and an
307
- * empty one are the same answer here. Where absence means something — an unbuilt artifact, a missing extract — use
308
- * {@linkcode readDirectory} and let the ENOENT reach you.
106
+ * Read a local file's bytes.
309
107
  *
310
- * @category Node
311
108
  * @category Files
109
+ * @runtime node
312
110
  */
313
- export function tryReadDirectory(path) {
314
- return readdir(asTarget(path)).catch((error) => {
315
- if (error.code === "ENOENT")
316
- return [];
317
- throw error;
318
- });
111
+ export function readLocalBuffer(...pathSegments) {
112
+ if (!pathSegments.length) {
113
+ throw new Error("No file path segments provided.");
114
+ }
115
+ return readFile(readTarget(pathSegments));
319
116
  }
320
117
  // #endregion
321
118
  // #region Standard input
@@ -1 +1 @@
1
- {"version":3,"file":"readers.js","sourceRoot":"","sources":["../../lib/fs/readers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EACN,IAAI,IAAI,UAAU,EAClB,MAAM,EACN,SAAS,EACT,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,IAAI,GAEJ,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAwB,WAAW,EAAE,MAAM,SAAS,CAAA;AAE3D,OAAO,EAAE,aAAa,EAA6B,MAAM,gBAAgB,CAAA;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAA;AAKvC,qBAAqB;AAErB;;;;;;;;;GASG;AACH,MAAM,UAAU,OAAO,CAAC,eAAsC;IAC7D,MAAM,MAAM,GAAG,eAAe,YAAY,GAAG,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAA;IAE5F,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACnC,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAA;QAExC,MAAM,KAAK,CAAA;IACZ,CAAC,CAAC,CAAA;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,IAA2B;IACnD,OAAO,IAAI,CAAC,IAAI,YAAY,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CA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C,CAAC;AAED,aAAa;AAEb,yBAAyB;AAEzB;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB;IACtC,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AAC5E,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB;IAC1C,OAAO,eAAe,CAAI,MAAM,iBAAiB,EAAE,CAAC,CAAA;AACrD,CAAC;AAED,aAAa"}
@@ -34,5 +34,38 @@ export declare function openReadStream(path: PathBuilderLike, options?: Paramete
34
34
  * first chunk rather than at open time reports the missing directory somewhere the caller is no longer looking. Call
35
35
  * `makeDirectories` first where the parent may be absent.
36
36
  */
37
+ /**
38
+ * Re-encode a byte stream from a legacy encoding into UTF-8, so a UTF-8 reader can consume it.
39
+ *
40
+ * The national registers this repository reads are not all UTF-8: Korea's address portal ships CP949, Japan's postcode
41
+ * file Shift_JIS. `spliterator` splits UTF-8 bytes, so the decode happens upstream of the split rather than after it —
42
+ * a line boundary found in CP949 bytes is not a line boundary.
43
+ *
44
+ * NOT `TextDecoder`, AND THE DIFFERENCE IS NOT SMALL. Node's WHATWG `euc-kr` implements EUC-KR proper (KS X 1001) and
45
+ * not the UHC extension CP949 adds in lead bytes 0x81–0xA0. Of the 17,048 two-byte sequences Python's `cp949` accepts,
46
+ * `TextDecoder('euc-kr')` reads 8,824 differently: 6,475 become U+FFFD and 2,349 become a DIFFERENT character with no
47
+ * error raised. `iconv-lite` disagrees with `cp949` on none of the 17,048.
48
+ *
49
+ * It is not a rare corner. One row in 48,000 of the Korean address register carries such a sequence — `더샾오피스텔`, bytes
50
+ * `b4 f5 98 de bf c0 c7 c7 bd ba c5 da`, which `TextDecoder` reads as `더乍의퓰뵀�`.
51
+ *
52
+ * The decoder is STREAMING for the same reason a `TextDecoder` would need `{ stream: true }`: a multi-byte character
53
+ * split across two chunks must be held until its tail arrives, where a per-chunk decode emits a replacement character
54
+ * and corrupts the row. `iconv-lite`'s stream decoder holds that state, and `end()` flushes what is left.
55
+ *
56
+ * @category Files
57
+ * @param encoding An `iconv-lite` label — `cp949`, `shift_jis`, `gbk`.
58
+ */
59
+ export declare function decodeByteStream(source: AsyncIterable<Uint8Array>, encoding: string): AsyncGenerator<Uint8Array>;
60
+ /**
61
+ * Decode bytes already in memory from a legacy encoding, the one-shot sibling of {@link decodeByteStream}.
62
+ *
63
+ * Same reasoning, same reason not to reach for `TextDecoder`, and it lives here so a reader that finds one finds the
64
+ * other. Use this when the whole file is a bounded size the publisher fixes; use the stream when it is not.
65
+ *
66
+ * @category Files
67
+ * @param encoding An `iconv-lite` label — `cp949`, `cp932`, `gbk`.
68
+ */
69
+ export declare function decodeBytes(bytes: Uint8Array, encoding: string): string;
37
70
  export declare function openWriteStream(path: PathBuilderLike, options?: Parameters<typeof createWriteStream>[1]): WriteStream;
38
71
  //# sourceMappingURL=streams.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"streams.d.ts","sourceRoot":"","sources":["../../lib/fs/streams.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,SAAS,CAAA;AAEhG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C;;GAEG;AACH,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAEzD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,UAAU,CAAC,OA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AAC,CAAC,CAAC,GAAG,WAAW,CAErH"}
package/out/fs/streams.js CHANGED
@@ -13,6 +13,7 @@
13
13
  * does not reach past them for a stream.
14
14
  */
15
15
  import { createReadStream, createWriteStream } from "node:fs";
16
+ import iconv from "iconv-lite";
16
17
  export { Duplex, Readable, Transform, Writable } from "node:stream";
17
18
  export { finished, pipeline } from "node:stream/promises";
18
19
  /**
@@ -31,6 +32,54 @@ export function openReadStream(path, options) {
31
32
  * first chunk rather than at open time reports the missing directory somewhere the caller is no longer looking. Call
32
33
  * `makeDirectories` first where the parent may be absent.
33
34
  */
35
+ /**
36
+ * Re-encode a byte stream from a legacy encoding into UTF-8, so a UTF-8 reader can consume it.
37
+ *
38
+ * The national registers this repository reads are not all UTF-8: Korea's address portal ships CP949, Japan's postcode
39
+ * file Shift_JIS. `spliterator` splits UTF-8 bytes, so the decode happens upstream of the split rather than after it —
40
+ * a line boundary found in CP949 bytes is not a line boundary.
41
+ *
42
+ * NOT `TextDecoder`, AND THE DIFFERENCE IS NOT SMALL. Node's WHATWG `euc-kr` implements EUC-KR proper (KS X 1001) and
43
+ * not the UHC extension CP949 adds in lead bytes 0x81–0xA0. Of the 17,048 two-byte sequences Python's `cp949` accepts,
44
+ * `TextDecoder('euc-kr')` reads 8,824 differently: 6,475 become U+FFFD and 2,349 become a DIFFERENT character with no
45
+ * error raised. `iconv-lite` disagrees with `cp949` on none of the 17,048.
46
+ *
47
+ * It is not a rare corner. One row in 48,000 of the Korean address register carries such a sequence — `더샾오피스텔`, bytes
48
+ * `b4 f5 98 de bf c0 c7 c7 bd ba c5 da`, which `TextDecoder` reads as `더乍의퓰뵀�`.
49
+ *
50
+ * The decoder is STREAMING for the same reason a `TextDecoder` would need `{ stream: true }`: a multi-byte character
51
+ * split across two chunks must be held until its tail arrives, where a per-chunk decode emits a replacement character
52
+ * and corrupts the row. `iconv-lite`'s stream decoder holds that state, and `end()` flushes what is left.
53
+ *
54
+ * @category Files
55
+ * @param encoding An `iconv-lite` label — `cp949`, `shift_jis`, `gbk`.
56
+ */
57
+ export async function* decodeByteStream(source, encoding) {
58
+ const decoder = iconv.getDecoder(encoding);
59
+ const encoder = new TextEncoder();
60
+ for await (const chunk of source) {
61
+ const text = decoder.write(Buffer.from(chunk));
62
+ if (text) {
63
+ yield encoder.encode(text);
64
+ }
65
+ }
66
+ const tail = decoder.end();
67
+ if (tail) {
68
+ yield encoder.encode(tail);
69
+ }
70
+ }
71
+ /**
72
+ * Decode bytes already in memory from a legacy encoding, the one-shot sibling of {@link decodeByteStream}.
73
+ *
74
+ * Same reasoning, same reason not to reach for `TextDecoder`, and it lives here so a reader that finds one finds the
75
+ * other. Use this when the whole file is a bounded size the publisher fixes; use the stream when it is not.
76
+ *
77
+ * @category Files
78
+ * @param encoding An `iconv-lite` label — `cp949`, `cp932`, `gbk`.
79
+ */
80
+ export function decodeBytes(bytes, encoding) {
81
+ return iconv.decode(Buffer.from(bytes), encoding);
82
+ }
34
83
  export function openWriteStream(path, options) {
35
84
  return createWriteStream(path.toString(), options);
36
85
  }
@@ -1 +1 @@
1
- {"version":3,"file":"streams.js","sourceRoot":"","sources":["../../lib/fs/streams.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAqC,MAAM,SAAS,CAAA;AAQhG,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAEzD;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,IAAqB,EAAE,OAAgD;IACrG,OAAO,gBAAgB,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAA;AAClD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,IAAqB,EAAE,OAAiD;IACvG,OAAO,iBAAiB,CAAC,IAAI,CA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