@pubid/pubid 0.1.70 → 0.1.72

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 (449) hide show
  1. package/README.md +49 -1
  2. package/artifact/corpus.json.gz +0 -0
  3. package/dist/flavors/ansi/generated/substrate.d.ts +78 -0
  4. package/dist/flavors/ansi/generated/substrate.js +105 -0
  5. package/dist/flavors/ansi/implementation.d.ts +5 -0
  6. package/dist/flavors/ansi/implementation.js +125 -0
  7. package/dist/flavors/ansi/index.js +14 -117
  8. package/dist/flavors/api/generated/substrate.d.ts +78 -0
  9. package/dist/flavors/api/generated/substrate.js +105 -0
  10. package/dist/flavors/api/grammar.worker.d.ts +6 -0
  11. package/dist/flavors/api/{grammar.js → grammar.worker.js} +60 -16
  12. package/dist/flavors/api/implementation.d.ts +11 -0
  13. package/dist/flavors/api/implementation.js +106 -0
  14. package/dist/flavors/api/index.d.ts +1 -3
  15. package/dist/flavors/api/index.js +14 -98
  16. package/dist/flavors/arxiv/generated/substrate.d.ts +75 -0
  17. package/dist/flavors/arxiv/generated/substrate.js +102 -0
  18. package/dist/flavors/arxiv/index.js +17 -11
  19. package/dist/flavors/ashrae/generated/substrate.d.ts +78 -0
  20. package/dist/flavors/ashrae/generated/substrate.js +105 -0
  21. package/dist/flavors/ashrae/grammar.worker.d.ts +6 -0
  22. package/dist/flavors/ashrae/{grammar.js → grammar.worker.js} +76 -39
  23. package/dist/flavors/ashrae/implementation.d.ts +7 -0
  24. package/dist/flavors/ashrae/implementation.js +316 -0
  25. package/dist/flavors/ashrae/index.d.ts +1 -3
  26. package/dist/flavors/ashrae/index.js +14 -304
  27. package/dist/flavors/asme/generated/substrate.d.ts +78 -0
  28. package/dist/flavors/asme/generated/substrate.js +105 -0
  29. package/dist/flavors/asme/grammar.worker.d.ts +6 -0
  30. package/dist/flavors/asme/{grammar.js → grammar.worker.js} +41 -2
  31. package/dist/flavors/asme/implementation.d.ts +7 -0
  32. package/dist/flavors/asme/implementation.js +152 -0
  33. package/dist/flavors/asme/index.d.ts +1 -3
  34. package/dist/flavors/asme/index.js +14 -136
  35. package/dist/flavors/astm/generated/substrate.d.ts +78 -0
  36. package/dist/flavors/astm/generated/substrate.js +105 -0
  37. package/dist/flavors/astm/grammar.worker.d.ts +6 -0
  38. package/dist/flavors/astm/{grammar.js → grammar.worker.js} +39 -5
  39. package/dist/flavors/astm/implementation.d.ts +6 -0
  40. package/dist/flavors/astm/implementation.js +135 -0
  41. package/dist/flavors/astm/index.js +14 -125
  42. package/dist/flavors/bipm/generated/substrate.d.ts +78 -0
  43. package/dist/flavors/bipm/generated/substrate.js +105 -0
  44. package/dist/flavors/bipm/grammar.worker.d.ts +6 -0
  45. package/dist/flavors/bipm/grammar.worker.js +180 -0
  46. package/dist/flavors/bipm/implementation.d.ts +6 -0
  47. package/dist/flavors/bipm/implementation.js +244 -0
  48. package/dist/flavors/bipm/index.d.ts +1 -28
  49. package/dist/flavors/bipm/index.js +16 -650
  50. package/dist/flavors/bipm/model.d.ts +80 -0
  51. package/dist/flavors/bipm/model.js +271 -0
  52. package/dist/flavors/bipm/worker.d.ts +2 -0
  53. package/dist/flavors/bipm/worker.js +19 -0
  54. package/dist/flavors/bsi/generated/substrate.d.ts +78 -0
  55. package/dist/flavors/bsi/generated/substrate.js +105 -0
  56. package/dist/flavors/bsi/grammar.worker.d.ts +6 -0
  57. package/dist/flavors/bsi/{grammar.js → grammar.worker.js} +36 -7
  58. package/dist/flavors/bsi/implementation.d.ts +12 -0
  59. package/dist/flavors/bsi/implementation.js +967 -0
  60. package/dist/flavors/bsi/index.d.ts +3 -4
  61. package/dist/flavors/bsi/index.js +16 -940
  62. package/dist/flavors/bsi/model.js +16 -0
  63. package/dist/flavors/bsi/worker.d.ts +3 -0
  64. package/dist/flavors/bsi/worker.js +25 -0
  65. package/dist/flavors/bsi_pfs/index.d.ts +25 -0
  66. package/dist/flavors/bsi_pfs/index.js +73 -10
  67. package/dist/flavors/calconnect/generated/substrate.d.ts +75 -0
  68. package/dist/flavors/calconnect/generated/substrate.js +102 -0
  69. package/dist/flavors/calconnect/grammar.worker.d.ts +6 -0
  70. package/dist/flavors/calconnect/grammar.worker.js +60 -0
  71. package/dist/flavors/calconnect/implementation.d.ts +6 -0
  72. package/dist/flavors/calconnect/implementation.js +69 -0
  73. package/dist/flavors/calconnect/index.d.ts +1 -19
  74. package/dist/flavors/calconnect/index.js +15 -111
  75. package/dist/flavors/calconnect/model.d.ts +26 -0
  76. package/dist/flavors/calconnect/model.js +52 -0
  77. package/dist/flavors/ccsds/generated/substrate.d.ts +75 -0
  78. package/dist/flavors/ccsds/generated/substrate.js +102 -0
  79. package/dist/flavors/ccsds/implementation.d.ts +5 -0
  80. package/dist/flavors/ccsds/implementation.js +67 -0
  81. package/dist/flavors/ccsds/index.js +13 -57
  82. package/dist/flavors/cen_cenelec/generated/substrate.d.ts +78 -0
  83. package/dist/flavors/cen_cenelec/generated/substrate.js +105 -0
  84. package/dist/flavors/cen_cenelec/grammar.worker.d.ts +6 -0
  85. package/dist/flavors/cen_cenelec/{grammar.js → grammar.worker.js} +41 -13
  86. package/dist/flavors/cen_cenelec/implementation.d.ts +15 -0
  87. package/dist/flavors/cen_cenelec/implementation.js +322 -0
  88. package/dist/flavors/cen_cenelec/index.d.ts +4 -5
  89. package/dist/flavors/cen_cenelec/index.js +17 -281
  90. package/dist/flavors/cen_cenelec/model.js +16 -1
  91. package/dist/flavors/cen_cenelec/worker.d.ts +3 -0
  92. package/dist/flavors/cen_cenelec/worker.js +23 -0
  93. package/dist/flavors/cen_pfs/index.d.ts +5 -0
  94. package/dist/flavors/cen_pfs/index.js +28 -2
  95. package/dist/flavors/cie/generated/substrate.d.ts +78 -0
  96. package/dist/flavors/cie/generated/substrate.js +105 -0
  97. package/dist/flavors/cie/grammar.worker.d.ts +6 -0
  98. package/dist/flavors/cie/{grammar.js → grammar.worker.js} +71 -18
  99. package/dist/flavors/cie/implementation.d.ts +9 -0
  100. package/dist/flavors/cie/implementation.js +331 -0
  101. package/dist/flavors/cie/index.js +14 -309
  102. package/dist/flavors/csa/generated/substrate.d.ts +78 -0
  103. package/dist/flavors/csa/generated/substrate.js +105 -0
  104. package/dist/flavors/csa/grammar.worker.d.ts +12 -0
  105. package/dist/flavors/csa/{grammar.js → grammar.worker.js} +143 -27
  106. package/dist/flavors/csa/implementation.d.ts +9 -0
  107. package/dist/flavors/csa/implementation.js +661 -0
  108. package/dist/flavors/csa/index.d.ts +2 -1
  109. package/dist/flavors/csa/index.js +15 -633
  110. package/dist/flavors/csa/worker.d.ts +3 -0
  111. package/dist/flavors/csa/worker.js +23 -0
  112. package/dist/flavors/easc/generated/substrate.d.ts +75 -0
  113. package/dist/flavors/easc/generated/substrate.js +102 -0
  114. package/dist/flavors/easc/grammar.worker.d.ts +6 -0
  115. package/dist/flavors/easc/grammar.worker.js +66 -0
  116. package/dist/flavors/easc/implementation.d.ts +6 -0
  117. package/dist/flavors/easc/implementation.js +58 -0
  118. package/dist/flavors/easc/index.d.ts +1 -2
  119. package/dist/flavors/easc/index.js +15 -105
  120. package/dist/flavors/easc/model.d.ts +10 -0
  121. package/dist/flavors/easc/model.js +43 -0
  122. package/dist/flavors/ecma/generated/substrate.d.ts +75 -0
  123. package/dist/flavors/ecma/generated/substrate.js +102 -0
  124. package/dist/flavors/ecma/grammar.worker.d.ts +6 -0
  125. package/dist/flavors/ecma/grammar.worker.js +63 -0
  126. package/dist/flavors/ecma/implementation.d.ts +6 -0
  127. package/dist/flavors/ecma/implementation.js +95 -0
  128. package/dist/flavors/ecma/index.d.ts +1 -2
  129. package/dist/flavors/ecma/index.js +15 -152
  130. package/dist/flavors/ecma/model.d.ts +10 -0
  131. package/dist/flavors/ecma/model.js +61 -0
  132. package/dist/flavors/etsi/generated/substrate.d.ts +75 -0
  133. package/dist/flavors/etsi/generated/substrate.js +102 -0
  134. package/dist/flavors/etsi/grammar.worker.d.ts +6 -0
  135. package/dist/flavors/etsi/grammar.worker.js +86 -0
  136. package/dist/flavors/etsi/implementation.d.ts +6 -0
  137. package/dist/flavors/etsi/implementation.js +110 -0
  138. package/dist/flavors/etsi/index.d.ts +2 -12
  139. package/dist/flavors/etsi/index.js +16 -305
  140. package/dist/flavors/etsi/model.d.ts +37 -0
  141. package/dist/flavors/etsi/model.js +169 -0
  142. package/dist/flavors/eu/generated/substrate.d.ts +75 -0
  143. package/dist/flavors/eu/generated/substrate.js +102 -0
  144. package/dist/flavors/eu/implementation.d.ts +7 -0
  145. package/dist/flavors/eu/implementation.js +150 -0
  146. package/dist/flavors/eu/index.js +14 -141
  147. package/dist/flavors/evs/generated/substrate.d.ts +78 -0
  148. package/dist/flavors/evs/generated/substrate.js +105 -0
  149. package/dist/flavors/evs/grammar.worker.d.ts +6 -0
  150. package/dist/flavors/evs/grammar.worker.js +98 -0
  151. package/dist/flavors/evs/implementation.d.ts +7 -0
  152. package/dist/flavors/evs/implementation.js +114 -0
  153. package/dist/flavors/evs/index.d.ts +2 -1
  154. package/dist/flavors/evs/index.js +15 -90
  155. package/dist/flavors/evs/worker.d.ts +3 -0
  156. package/dist/flavors/evs/worker.js +24 -0
  157. package/dist/flavors/foreign-resolver.d.ts +6 -0
  158. package/dist/flavors/foreign-resolver.js +9 -0
  159. package/dist/flavors/gb/generated/substrate.d.ts +75 -0
  160. package/dist/flavors/gb/generated/substrate.js +102 -0
  161. package/dist/flavors/gb/grammar.worker.d.ts +6 -0
  162. package/dist/flavors/gb/grammar.worker.js +73 -0
  163. package/dist/flavors/gb/implementation.d.ts +6 -0
  164. package/dist/flavors/gb/implementation.js +87 -0
  165. package/dist/flavors/gb/index.d.ts +1 -29
  166. package/dist/flavors/gb/index.js +15 -157
  167. package/dist/flavors/gb/model.d.ts +36 -0
  168. package/dist/flavors/gb/model.js +79 -0
  169. package/dist/flavors/gost/generated/substrate.d.ts +78 -0
  170. package/dist/flavors/gost/generated/substrate.js +105 -0
  171. package/dist/flavors/gost/grammar.worker.d.ts +6 -0
  172. package/dist/flavors/gost/grammar.worker.js +82 -0
  173. package/dist/flavors/gost/implementation.d.ts +7 -0
  174. package/dist/flavors/gost/implementation.js +177 -0
  175. package/dist/flavors/gost/index.d.ts +2 -1
  176. package/dist/flavors/gost/index.js +15 -164
  177. package/dist/flavors/gost/worker.d.ts +3 -0
  178. package/dist/flavors/gost/worker.js +28 -0
  179. package/dist/flavors/iala/generated/substrate.d.ts +78 -0
  180. package/dist/flavors/iala/generated/substrate.js +105 -0
  181. package/dist/flavors/iala/grammar.worker.d.ts +6 -0
  182. package/dist/flavors/iala/grammar.worker.js +127 -0
  183. package/dist/flavors/iala/implementation.d.ts +6 -0
  184. package/dist/flavors/iala/implementation.js +250 -0
  185. package/dist/flavors/iala/index.d.ts +1 -56
  186. package/dist/flavors/iala/index.js +17 -484
  187. package/dist/flavors/iala/model.d.ts +93 -0
  188. package/dist/flavors/iala/model.js +194 -0
  189. package/dist/flavors/iana/generated/substrate.d.ts +75 -0
  190. package/dist/flavors/iana/generated/substrate.js +102 -0
  191. package/dist/flavors/iana/grammar.worker.d.ts +6 -0
  192. package/dist/flavors/iana/grammar.worker.js +51 -0
  193. package/dist/flavors/iana/implementation.d.ts +6 -0
  194. package/dist/flavors/iana/implementation.js +47 -0
  195. package/dist/flavors/iana/index.d.ts +1 -17
  196. package/dist/flavors/iana/index.js +15 -69
  197. package/dist/flavors/iana/model.d.ts +22 -0
  198. package/dist/flavors/iana/model.js +33 -0
  199. package/dist/flavors/idf/generated/substrate.d.ts +78 -0
  200. package/dist/flavors/idf/generated/substrate.js +105 -0
  201. package/dist/flavors/idf/grammar.worker.d.ts +6 -0
  202. package/dist/flavors/idf/{grammar.js → grammar.worker.js} +58 -2
  203. package/dist/flavors/idf/implementation.d.ts +6 -0
  204. package/dist/flavors/idf/implementation.js +129 -0
  205. package/dist/flavors/idf/index.js +14 -98
  206. package/dist/flavors/iec/generated/substrate.d.ts +78 -0
  207. package/dist/flavors/iec/generated/substrate.js +105 -0
  208. package/dist/flavors/iec/grammar.worker.d.ts +6 -0
  209. package/dist/flavors/iec/grammar.worker.js +231 -0
  210. package/dist/flavors/iec/implementation.d.ts +15 -0
  211. package/dist/flavors/iec/implementation.js +956 -0
  212. package/dist/flavors/iec/index.d.ts +1 -2
  213. package/dist/flavors/iec/index.js +16 -869
  214. package/dist/flavors/iec/model.js +13 -1
  215. package/dist/flavors/iec/worker.d.ts +2 -0
  216. package/dist/flavors/iec/worker.js +19 -0
  217. package/dist/flavors/ieee/generated/substrate.d.ts +78 -0
  218. package/dist/flavors/ieee/generated/substrate.js +105 -0
  219. package/dist/flavors/ieee/implementation.d.ts +4 -0
  220. package/dist/flavors/ieee/implementation.js +48 -10
  221. package/dist/flavors/ieee/index.d.ts +3 -2
  222. package/dist/flavors/ieee/index.js +30 -12
  223. package/dist/flavors/ieee/model.js +3 -0
  224. package/dist/flavors/ieee/preprocessor.js +10 -10
  225. package/dist/flavors/ieee/worker.js +33 -11
  226. package/dist/flavors/ietf/generated/substrate.d.ts +75 -0
  227. package/dist/flavors/ietf/generated/substrate.js +102 -0
  228. package/dist/flavors/ietf/grammar.worker.d.ts +6 -0
  229. package/dist/flavors/ietf/grammar.worker.js +63 -0
  230. package/dist/flavors/ietf/implementation.d.ts +6 -0
  231. package/dist/flavors/ietf/implementation.js +60 -0
  232. package/dist/flavors/ietf/index.d.ts +1 -28
  233. package/dist/flavors/ietf/index.js +15 -149
  234. package/dist/flavors/ietf/model.d.ts +47 -0
  235. package/dist/flavors/ietf/model.js +92 -0
  236. package/dist/flavors/iho/generated/substrate.d.ts +78 -0
  237. package/dist/flavors/iho/generated/substrate.js +105 -0
  238. package/dist/flavors/iho/grammar.worker.d.ts +6 -0
  239. package/dist/flavors/iho/grammar.worker.js +150 -0
  240. package/dist/flavors/iho/implementation.d.ts +6 -0
  241. package/dist/flavors/iho/implementation.js +221 -0
  242. package/dist/flavors/iho/index.d.ts +1 -2
  243. package/dist/flavors/iho/index.js +15 -619
  244. package/dist/flavors/iho/model.d.ts +11 -0
  245. package/dist/flavors/iho/model.js +315 -0
  246. package/dist/flavors/index.js +8 -5
  247. package/dist/flavors/iso/generated/substrate.d.ts +93 -0
  248. package/dist/flavors/iso/generated/substrate.js +133 -0
  249. package/dist/flavors/iso/grammar.worker.d.ts +7 -0
  250. package/dist/flavors/iso/grammar.worker.js +406 -0
  251. package/dist/flavors/iso/implementation.d.ts +4 -0
  252. package/dist/flavors/iso/implementation.js +880 -0
  253. package/dist/flavors/iso/index.js +16 -706
  254. package/dist/flavors/iso/model.js +21 -2
  255. package/dist/flavors/iso/worker.d.ts +2 -0
  256. package/dist/flavors/iso/worker.js +19 -0
  257. package/dist/flavors/itu/generated/substrate.d.ts +78 -0
  258. package/dist/flavors/itu/generated/substrate.js +105 -0
  259. package/dist/flavors/itu/grammar.worker.d.ts +6 -0
  260. package/dist/flavors/itu/grammar.worker.js +306 -0
  261. package/dist/flavors/itu/implementation.d.ts +10 -0
  262. package/dist/flavors/itu/implementation.js +285 -0
  263. package/dist/flavors/itu/index.js +15 -246
  264. package/dist/flavors/itu/worker.d.ts +2 -0
  265. package/dist/flavors/itu/worker.js +19 -0
  266. package/dist/flavors/jcgm/generated/substrate.d.ts +78 -0
  267. package/dist/flavors/jcgm/generated/substrate.js +105 -0
  268. package/dist/flavors/jcgm/grammar.worker.d.ts +6 -0
  269. package/dist/flavors/jcgm/grammar.worker.js +98 -0
  270. package/dist/flavors/jcgm/implementation.d.ts +6 -0
  271. package/dist/flavors/jcgm/implementation.js +187 -0
  272. package/dist/flavors/jcgm/index.d.ts +1 -5
  273. package/dist/flavors/jcgm/index.js +16 -364
  274. package/dist/flavors/jcgm/model.d.ts +43 -0
  275. package/dist/flavors/jcgm/model.js +168 -0
  276. package/dist/flavors/jis/generated/substrate.d.ts +78 -0
  277. package/dist/flavors/jis/generated/substrate.js +105 -0
  278. package/dist/flavors/jis/grammar.worker.d.ts +6 -0
  279. package/dist/flavors/jis/grammar.worker.js +132 -0
  280. package/dist/flavors/jis/implementation.d.ts +6 -0
  281. package/dist/flavors/jis/implementation.js +129 -0
  282. package/dist/flavors/jis/index.d.ts +0 -2
  283. package/dist/flavors/jis/index.js +15 -390
  284. package/dist/flavors/jis/model.d.ts +30 -0
  285. package/dist/flavors/jis/model.js +205 -0
  286. package/dist/flavors/jis/worker.d.ts +2 -0
  287. package/dist/flavors/jis/worker.js +19 -0
  288. package/dist/flavors/nist/generated/substrate.d.ts +78 -0
  289. package/dist/flavors/nist/generated/substrate.js +105 -0
  290. package/dist/flavors/nist/index.js +18 -11
  291. package/dist/flavors/nist/worker.js +8 -4
  292. package/dist/flavors/oasis/generated/substrate.d.ts +75 -0
  293. package/dist/flavors/oasis/generated/substrate.js +102 -0
  294. package/dist/flavors/oasis/grammar.worker.d.ts +6 -0
  295. package/dist/flavors/oasis/grammar.worker.js +50 -0
  296. package/dist/flavors/oasis/implementation.d.ts +6 -0
  297. package/dist/flavors/oasis/implementation.js +80 -0
  298. package/dist/flavors/oasis/index.d.ts +1 -21
  299. package/dist/flavors/oasis/index.js +16 -108
  300. package/dist/flavors/oasis/model.d.ts +27 -0
  301. package/dist/flavors/oasis/model.js +34 -0
  302. package/dist/flavors/ogc/generated/substrate.d.ts +75 -0
  303. package/dist/flavors/ogc/generated/substrate.js +102 -0
  304. package/dist/flavors/ogc/grammar.worker.d.ts +6 -0
  305. package/dist/flavors/ogc/grammar.worker.js +55 -0
  306. package/dist/flavors/ogc/implementation.d.ts +6 -0
  307. package/dist/flavors/ogc/implementation.js +49 -0
  308. package/dist/flavors/ogc/index.d.ts +1 -18
  309. package/dist/flavors/ogc/index.js +15 -73
  310. package/dist/flavors/ogc/model.d.ts +23 -0
  311. package/dist/flavors/ogc/model.js +32 -0
  312. package/dist/flavors/oiml/generated/substrate.d.ts +78 -0
  313. package/dist/flavors/oiml/generated/substrate.js +105 -0
  314. package/dist/flavors/oiml/grammar.worker.d.ts +6 -0
  315. package/dist/flavors/oiml/grammar.worker.js +239 -0
  316. package/dist/flavors/oiml/implementation.d.ts +2 -1
  317. package/dist/flavors/oiml/implementation.js +16 -7
  318. package/dist/flavors/oiml/index.js +15 -6
  319. package/dist/flavors/oiml/model.js +19 -19
  320. package/dist/flavors/oiml/worker.js +14 -6
  321. package/dist/flavors/omg/generated/substrate.d.ts +78 -0
  322. package/dist/flavors/omg/generated/substrate.js +105 -0
  323. package/dist/flavors/omg/grammar.worker.d.ts +6 -0
  324. package/dist/flavors/omg/grammar.worker.js +64 -0
  325. package/dist/flavors/omg/implementation.d.ts +7 -0
  326. package/dist/flavors/omg/implementation.js +33 -0
  327. package/dist/flavors/omg/index.d.ts +1 -12
  328. package/dist/flavors/omg/index.js +15 -71
  329. package/dist/flavors/omg/model.d.ts +16 -0
  330. package/dist/flavors/omg/model.js +26 -0
  331. package/dist/flavors/plateau/generated/substrate.d.ts +78 -0
  332. package/dist/flavors/plateau/generated/substrate.js +105 -0
  333. package/dist/flavors/plateau/grammar.worker.d.ts +6 -0
  334. package/dist/flavors/plateau/grammar.worker.js +78 -0
  335. package/dist/flavors/plateau/implementation.d.ts +6 -0
  336. package/dist/flavors/plateau/implementation.js +74 -0
  337. package/dist/flavors/plateau/index.d.ts +1 -2
  338. package/dist/flavors/plateau/index.js +18 -114
  339. package/dist/flavors/plateau/model.d.ts +11 -0
  340. package/dist/flavors/plateau/model.js +51 -0
  341. package/dist/flavors/register-types.d.ts +20 -19
  342. package/dist/flavors/register-types.js +44 -19
  343. package/dist/flavors/sae/generated/substrate.d.ts +75 -0
  344. package/dist/flavors/sae/generated/substrate.js +102 -0
  345. package/dist/flavors/sae/grammar.worker.d.ts +6 -0
  346. package/dist/flavors/sae/grammar.worker.js +84 -0
  347. package/dist/flavors/sae/implementation.d.ts +11 -0
  348. package/dist/flavors/sae/implementation.js +109 -0
  349. package/dist/flavors/sae/index.d.ts +3 -0
  350. package/dist/flavors/sae/index.js +19 -0
  351. package/dist/flavors/sae/model.d.ts +86 -0
  352. package/dist/flavors/sae/model.js +185 -0
  353. package/dist/flavors/tgpp/generated/substrate.d.ts +78 -0
  354. package/dist/flavors/tgpp/generated/substrate.js +105 -0
  355. package/dist/flavors/tgpp/grammar.worker.d.ts +6 -0
  356. package/dist/flavors/tgpp/grammar.worker.js +69 -0
  357. package/dist/flavors/tgpp/implementation.d.ts +8 -0
  358. package/dist/flavors/tgpp/implementation.js +56 -0
  359. package/dist/flavors/tgpp/index.d.ts +1 -2
  360. package/dist/flavors/tgpp/index.js +15 -120
  361. package/dist/flavors/tgpp/model.d.ts +13 -0
  362. package/dist/flavors/tgpp/model.js +52 -0
  363. package/dist/flavors/w3c/generated/substrate.d.ts +78 -0
  364. package/dist/flavors/w3c/generated/substrate.js +105 -0
  365. package/dist/flavors/w3c/grammar.worker.d.ts +6 -0
  366. package/dist/flavors/w3c/grammar.worker.js +55 -0
  367. package/dist/flavors/w3c/implementation.d.ts +7 -0
  368. package/dist/flavors/w3c/implementation.js +49 -0
  369. package/dist/flavors/w3c/index.d.ts +1 -12
  370. package/dist/flavors/w3c/index.js +15 -146
  371. package/dist/flavors/w3c/model.d.ts +15 -0
  372. package/dist/flavors/w3c/model.js +103 -0
  373. package/dist/flavors/wmo/generated/substrate.d.ts +78 -0
  374. package/dist/flavors/wmo/generated/substrate.js +105 -0
  375. package/dist/flavors/wmo/implementation.d.ts +5 -0
  376. package/dist/flavors/wmo/implementation.js +79 -0
  377. package/dist/flavors/wmo/index.js +14 -68
  378. package/dist/flavors/worker-registry.d.ts +13 -0
  379. package/dist/flavors/worker-registry.js +298 -0
  380. package/dist/flavors/xsf/generated/substrate.d.ts +75 -0
  381. package/dist/flavors/xsf/generated/substrate.js +102 -0
  382. package/dist/flavors/xsf/grammar.worker.d.ts +6 -0
  383. package/dist/flavors/xsf/grammar.worker.js +53 -0
  384. package/dist/flavors/xsf/implementation.d.ts +6 -0
  385. package/dist/flavors/xsf/implementation.js +34 -0
  386. package/dist/flavors/xsf/index.d.ts +1 -16
  387. package/dist/flavors/xsf/index.js +16 -63
  388. package/dist/flavors/xsf/model.d.ts +20 -0
  389. package/dist/flavors/xsf/model.js +26 -0
  390. package/dist/model/identifier.d.ts +13 -1
  391. package/dist/model/identifier.js +71 -9
  392. package/dist/model/relation.d.ts +36 -0
  393. package/dist/model/relation.js +93 -0
  394. package/dist/parg/artifacts/ieee.d.ts +1 -1
  395. package/dist/parg/artifacts/ieee.js +1 -1
  396. package/dist/parg/worker.d.ts +4 -2
  397. package/dist/parg/worker.js +5 -3
  398. package/dist/parse-surface.js +4 -2
  399. package/dist/pubid-urn/decoder.d.ts +8 -0
  400. package/dist/pubid-urn/decoder.js +43 -0
  401. package/dist/pubid-urn/encoder.js +31 -0
  402. package/dist/pubid-urn/schema.d.ts +1 -1
  403. package/dist/pubid-urn/schema.js +1 -1
  404. package/dist/pubid-urn/schemas/bsi.js +1 -0
  405. package/dist/pubid-urn/schemas/bsi_pfs.js +9 -7
  406. package/dist/pubid-urn/schemas/cen_pfs.js +1 -0
  407. package/dist/pubid-urn/schemas/cencenelec.js +1 -0
  408. package/dist/pubid-urn/schemas/iec.js +1 -0
  409. package/dist/pubid-urn/schemas/ieee.js +1 -0
  410. package/dist/pubid-urn/schemas/iso.js +1 -0
  411. package/package.json +1 -1
  412. package/vendor/parg/bsi_pfs.json +1 -1
  413. package/vendor/parg/calconnect_pfs.json +1 -1
  414. package/vendor/parg/cen_pfs.json +1 -1
  415. package/vendor/parg/doi_pfs.json +1 -1
  416. package/vendor/parg/etsi_pfs.json +1 -1
  417. package/vendor/parg/ieee.json +1 -1
  418. package/vendor/parg/iho.json +1 -1
  419. package/vendor/parg/plateau.json +1 -1
  420. package/dist/flavors/api/grammar.d.ts +0 -4
  421. package/dist/flavors/ashrae/grammar.d.ts +0 -2
  422. package/dist/flavors/asme/grammar.d.ts +0 -2
  423. package/dist/flavors/astm/grammar.d.ts +0 -2
  424. package/dist/flavors/bsi/grammar.d.ts +0 -4
  425. package/dist/flavors/cen_cenelec/grammar.d.ts +0 -4
  426. package/dist/flavors/cie/grammar.d.ts +0 -5
  427. package/dist/flavors/csa/grammar.d.ts +0 -6
  428. package/dist/flavors/evs/grammar.d.ts +0 -2
  429. package/dist/flavors/evs/grammar.js +0 -68
  430. package/dist/flavors/gost/grammar.d.ts +0 -2
  431. package/dist/flavors/gost/grammar.js +0 -46
  432. package/dist/flavors/idf/grammar.d.ts +0 -2
  433. package/dist/flavors/iec/grammar.d.ts +0 -3
  434. package/dist/flavors/iec/grammar.js +0 -234
  435. package/dist/flavors/ieee/grammar.d.ts +0 -2
  436. package/dist/flavors/ieee/grammar.js +0 -777
  437. package/dist/flavors/iso/grammar.d.ts +0 -7
  438. package/dist/flavors/iso/grammar.js +0 -282
  439. package/dist/flavors/itu/grammar.d.ts +0 -4
  440. package/dist/flavors/itu/grammar.js +0 -276
  441. package/dist/flavors/nist/grammar.d.ts +0 -2
  442. package/dist/flavors/nist/grammar.js +0 -342
  443. package/dist/flavors/oiml/grammar.d.ts +0 -2
  444. package/dist/flavors/oiml/grammar.js +0 -206
  445. package/vendor/parg/csv.json +0 -1
  446. package/vendor/parg/ini.json +0 -1
  447. package/vendor/parg/json.json +0 -1
  448. package/vendor/parg/lua.json +0 -1
  449. package/vendor/parg/toml.json +0 -1
@@ -1,708 +1,18 @@
1
- import { ParseFailed, parseGrammar } from "../../grammar/engine.js";
2
- import { PubidDate, Language, Iteration } from "../../model/component.js";
3
- import { isoGrammar, BALLOT_STAGE_CODES } from "./grammar.js";
4
- import { IsoBundledIdentifier, IsoDirectives, IsoDirectivesSupplement, IsoEdition, IsoPublisher, IsoSupplementIdentifier, IsoTcDocument, isoClassForType, locateStage, } from "./model.js";
5
- import { ISO_TYPED_STAGES } from "./stages.generated.js";
6
- /**
7
- * Port of lib/pubid/iso/{builder,normalizer}.rb. Class dispatch follows
8
- * the Ruby Builder: joint → Combined (unreachable by the corpus),
9
- * supplements-bundle → BundledIdentifier, tc_type → TcDocument, else
10
- * locate_type(typed_stage.type_code) with the DIR/SUP special cases.
11
- */
12
- const isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
13
- const s = (v) => {
14
- if (v === undefined || v === null)
15
- return undefined;
16
- const str = Array.isArray(v) ? v.join("") : String(v);
17
- return str.length > 0 ? str : undefined;
18
- };
19
- function flatten(data) {
20
- return Array.isArray(data) ? Object.assign({}, ...data) : data;
21
- }
22
- // --- Normalizer (lib/pubid/iso/normalizer.rb) --------------------------------
23
- const DAD_PATTERN = /^(.+?)\/(F?DAD)\s+(\d+)(?::(\d{4}))?$/;
24
- const UPDATE_CODE_LINES = {
25
- "ISO/R 657/IV": "ISO/R 657-4:1969",
26
- "ISO/IEC/IEEE 8802-22.2:2015/Amd.2:2017(E)": "ISO/IEC/IEEE 8802-22:2015/Amd.2:2017(E)",
27
- "ISO/TR 17716.2": "ISO/TR 17716",
28
- "ISO/TR 17716.2(E)": "ISO/TR 17716(E)",
29
- };
30
- const UPDATE_CODE_REGEXES = [
31
- [/^(ISO[\w/]*) DIS (TR|TS|PAS|ISP) /, "$1 D$2 "],
32
- [/^(ISO[\w/]*) FDIS (TR|TS|PAS|ISP) /, "$1 FD$2 "],
33
- [/DIS Amd /, "DAM "],
34
- [/FDIS Amd /, "FDAM "],
35
- [/DIS Cor /, "DCOR "],
36
- [/FDIS Cor /, "FDCOR "],
37
- [/DIS Suppl /, "DSuppl "],
38
- [/DIS Add /, "DAD "],
39
- ];
40
- const CYRILLIC_MAP = [
41
- ["Руководства", "GUIDE"],
42
- ["Руководство", "GUIDE"],
43
- ["ИСО/МЭК", "ISO/IEC"],
44
- ["ИСО/ОПМС", "ISO/FDIS"],
45
- ["ИСО/ПМС", "ISO/DIS"],
46
- ["ИСО/ТО", "ISO/TR"],
47
- ["ИСО/ТС", "ISO/TS"],
48
- ["ИСО", "ISO"],
49
- ["МЭК", "IEC"],
50
- ["ТО", "TR"],
51
- ["ТС", "TS"],
52
- ["ОПМС", "FDIS"],
53
- ["ПМС", "DIS"],
54
- ];
55
- function normalizeCyrillic(input) {
56
- if (!/[а-яА-Я]/.test(input))
57
- return input;
58
- let normalized = input.replace(/\s*#\s*.*$/, "");
59
- for (const [from, to] of CYRILLIC_MAP) {
60
- normalized = normalized.split(from).join(to);
61
- }
62
- return normalized.trim();
63
- }
64
- function applyUpdateCodes(input) {
65
- const line = UPDATE_CODE_LINES[input];
66
- if (line !== undefined)
67
- return line;
68
- let out = input;
69
- for (const [pattern, replacement] of UPDATE_CODE_REGEXES) {
70
- // The Ruby table keys the supplement-position regexes with a "//"
71
- // prefix marking "after the first /"; apply those only past a slash.
72
- out = out.replace(pattern, replacement);
73
- }
74
- return out;
75
- }
76
- // --- Builder -------------------------------------------------------------------
77
- function parseLanguages(raw) {
78
- const str = s(raw);
79
- if (str === undefined)
80
- return [];
81
- return str
82
- .split(",")
83
- .flatMap((chunk) => chunk.split("/"))
84
- .map((token) => token.trim())
85
- .filter((token) => token !== "")
86
- .map((original) => {
87
- const code = original.length === 1 ? (Language.CHAR_MAP[original] ?? original.toLowerCase()) : original;
88
- return new Language({ code, originalCode: original });
89
- });
90
- }
91
- /**
92
- * Builder#parse_number_with_part: em/en dashes, slashes and spaces
93
- * normalize to "-", then number[-part[-subpart]]; a 4-digit 1900-2099
94
- * part is a legacy year, not a part.
95
- */
96
- function parseNumberWithPart(raw) {
97
- const value = s(raw)?.replace(/[‑‐/]/g, "-").replace(/ /g, "-");
98
- if (value === undefined)
99
- return { number: undefined, part: undefined, subpart: undefined, date: undefined };
100
- const segments = value.split("-").filter((seg) => seg !== "");
101
- const [number, part, ...rest] = segments;
102
- const result = { number, part, subpart: rest.length > 0 ? rest.join("-") : undefined, date: undefined };
103
- if (part !== undefined && /^\d{4}$/.test(part)) {
104
- const yearValue = Number(part);
105
- if (yearValue >= 1900 && yearValue <= 2099 && rest.length === 0) {
106
- result.part = undefined;
107
- result.date = new PubidDate({ year: part });
108
- }
109
- }
110
- return result;
111
- }
112
- function parseDate(tree) {
113
- if (tree === undefined || !isObj(tree))
114
- return undefined;
115
- const flat = flatten(tree);
116
- const year = s(flat["year"]);
117
- if (year === undefined)
118
- return undefined;
119
- return new PubidDate({
120
- year,
121
- month: s(flat["month"]),
122
- day: s(flat["day"]),
123
- });
124
- }
125
- function parseEdition(raw) {
126
- const text = s(raw);
127
- if (text === undefined)
128
- return undefined;
129
- const number = /\d+/.exec(text)?.[0];
130
- return new IsoEdition({ ...(number !== undefined ? { number } : {}), original_text: text });
131
- }
132
- function typeStateFromToken(token, fallbackTypeKey) {
133
- const abbr = s(token);
134
- if (abbr === undefined)
135
- return undefined;
136
- const entry = locateStage(abbr);
137
- if (entry === undefined)
138
- return undefined;
139
- return { entry, originalAbbr: abbr };
140
- }
141
- class IsoBuilder {
142
- build(data) {
143
- const tree = flatten(data);
144
- if (tree["joint_identifier"] !== undefined) {
145
- // No corpus rows carry an IDF twin; fail rather than guess.
146
- throw new ParseFailed("ISO: joint IDF identifiers are not ported", 0);
147
- }
148
- if (tree["supplements"] !== undefined)
149
- return this.buildBundled(tree);
150
- // Bare TC reference (pubid-iso#285): tc_type is absent by
151
- // construction; sc_type is the route's required segment and cannot
152
- // appear on a standard identifier. Canonicalizes the publisher to ISO.
153
- if (tree["tc_type"] === undefined && tree["sc_type"] !== undefined && tree["tc_number"] !== undefined) {
154
- tree["tc_type"] = "TC";
155
- return this.buildTc(tree);
156
- }
157
- if (tree["tc_type"] !== undefined)
158
- return this.buildTc(tree);
159
- return this.buildStandard(tree);
160
- }
161
- publisherOf(tree) {
162
- const primary = s(tree["publisher"]);
163
- const copubTree = tree["copublishers"];
164
- const copublishers = [];
165
- if (Array.isArray(copubTree)) {
166
- for (const entry of copubTree) {
167
- if (isObj(entry)) {
168
- const cp = s(entry["copublisher"]);
169
- if (cp !== undefined)
170
- copublishers.push(cp);
171
- }
172
- }
173
- }
174
- else if (copubTree !== undefined) {
175
- const cp = s(flatten(copubTree)["copublisher"]);
176
- if (cp !== undefined)
177
- copublishers.push(cp);
178
- }
179
- if (primary === undefined && copublishers.length === 0)
180
- return undefined;
181
- return new IsoPublisher({ publisher: primary ?? "ISO", copublisher: copublishers });
182
- }
183
- baseAttrs(tree) {
184
- const attrs = {};
185
- const numberWithPart = tree["number_with_part"] !== undefined ? flatten(tree["number_with_part"]) : {};
186
- const rawNumber = s(numberWithPart["number"]) ?? s(tree["number"]);
187
- const parsed = parseNumberWithPart(s(tree["number_with_part"]) ?? s(tree["number"]));
188
- if (parsed.number !== undefined || rawNumber !== undefined) {
189
- if (parsed.number !== undefined)
190
- attrs["number"] = parsed.number;
191
- if (parsed.part !== undefined)
192
- attrs["part"] = parsed.part;
193
- if (parsed.subpart !== undefined)
194
- attrs["subpart"] = parsed.subpart;
195
- if (parsed.date !== undefined)
196
- attrs["date"] = parsed.date;
197
- }
198
- const date = parseDate(tree["date"]) ?? parseDate(tree["base"] !== undefined ? undefined : undefined);
199
- if (tree["date"] !== undefined) {
200
- if (isObj(tree["date"])) {
201
- const flat = flatten(tree["date"]);
202
- const year = s(flat["year"]);
203
- if (year !== undefined) {
204
- attrs["date"] = new PubidDate({ year, month: s(flat["month"]), day: s(flat["day"]) });
205
- }
206
- }
207
- else {
208
- const dateStr = s(tree["date"]);
209
- if (dateStr !== undefined) {
210
- const [year, month, day] = dateStr.split("-");
211
- if (year !== undefined && year !== "") {
212
- attrs["date"] = new PubidDate({ year, month, day });
213
- }
214
- }
215
- }
216
- }
217
- if (tree["undated_marker"] !== undefined) {
218
- attrs["date"] = new PubidDate({ undated: true });
219
- }
220
- const edition = parseEdition(tree["edition"]);
221
- if (edition !== undefined)
222
- attrs["edition"] = edition;
223
- const languages = parseLanguages(tree["languages"]);
224
- if (languages.length > 0)
225
- attrs["languages"] = languages;
226
- if (tree["all_parts"] !== undefined)
227
- attrs["all_parts"] = true;
228
- if (tree["stage_iteration"] !== undefined) {
229
- attrs["stage_iteration"] = new Iteration({ string: s(tree["stage_iteration"]) });
230
- }
231
- return attrs;
232
- }
233
- buildStandard(treeIn) {
234
- const tree = { ...treeIn };
235
- // Historic TYPE-first ballot face ("ISO/IEC FDAM 1 14496-12:2004",
236
- // "ISO/PDAM 19973-2", "ISO 15877-5:2009 FDAM 1"): the ballot_* keys
237
- // are one amendment layer over the whole base, never a second
238
- // supplement layer (the stored twins keep one level), so the layer
239
- // is assembled here, before the supplement branch could read the
240
- // ballot token as an outer wrapper.
241
- if (tree["ballot_type_with_stage"] !== undefined) {
242
- return this.buildBallotSupplement(tree);
243
- }
244
- // Legacy ISO/R: publisher ISO + type "R".
245
- if (tree["iso_r_prefix"] !== undefined) {
246
- tree["publisher"] = "ISO";
247
- tree["type_with_stage"] = "R";
248
- }
249
- // NSB stage prefixes map onto typed stages.
250
- if (tree["nsb_stage"] !== undefined) {
251
- tree["type_with_stage"] = s(tree["nsb_stage"]) === "Fpr" ? "PRF" : "WD";
252
- }
253
- // French Guide/GUIDE prefix.
254
- if (tree["type_with_stage_fr"] !== undefined) {
255
- tree["type_with_stage"] = s(tree["type_with_stage_fr"]);
256
- }
257
- // Directive supplement without its own SUP keyword.
258
- if (tree["type_with_stage"] === undefined && tree["base"] !== undefined && isObj(tree["base"])) {
259
- const baseTree = flatten(tree["base"]);
260
- const dirTokens = new Set(["DIR", "Directives Part", "Directives, Part", "Directives,", "Directives"]);
261
- if (dirTokens.has(s(baseTree["type_with_stage"]) ?? "")) {
262
- tree["type_with_stage"] = "SUP";
263
- }
264
- }
265
- const state = typeStateFromToken(s(tree["type_with_stage"]), "is");
266
- // The explicit URN type token pins the class: a stage's abbreviation
267
- // can overwrite type_with_stage with an IS-only stage ("WDA" for
268
- // 90.93), and the document must stay a TR/TS (the Ruby builder reads
269
- // the same document_type hint).
270
- const documentType = s(tree["document_type"]);
271
- const typeKey = documentType !== undefined
272
- ? documentType.toLowerCase()
273
- : state?.entry.typeCode ?? "is";
274
- if (typeKey === "dir-sup")
275
- return this.buildDirectivesSupplement(tree, state);
276
- if (typeKey === "dir")
277
- return this.buildDirectives(tree, state ?? { entry: locateStage("DIR"), originalAbbr: "DIR" });
278
- const klass = isoClassForType(typeKey);
279
- if (klass === undefined) {
280
- throw new ParseFailed(`ISO: unknown type key ${typeKey}`, 0);
281
- }
282
- const attrs = this.baseAttrs(tree);
283
- const publisher = this.publisherOf(tree);
284
- if (publisher !== undefined)
285
- attrs["publisher"] = publisher;
286
- if (state !== undefined)
287
- attrs["typedStageState"] = state;
288
- if ((tree["base"] !== undefined || klass.prototype instanceof IsoSupplementIdentifier) && tree["base"] !== undefined) {
289
- attrs["base"] = this.build(tree["base"]);
290
- }
291
- const identifier = new klass(attrs);
292
- // The owner's no-number rule, applied on every construction path
293
- // that routes through this builder (parse, URN, bundle members): a
294
- // DAM-family ballot-stage amendment token with no number anywhere
295
- // names Amendment 1 ("ISO 19973-2/PDAM", "ISO/IEC PDAM 12207"). The
296
- // number is identity-bearing, so the default lands at build time and
297
- // the wire hash serializes it — parse and fromHash(toHash) agree
298
- // because both carry the filled number. The ballot stages are
299
- // matched by the typed stage's code (the per-typed-stage key) —
300
- // PDAM's stageCode is "cd", the harmonized range it lives in.
301
- if (typeKey === "amd" && attrs["number"] === undefined &&
302
- BALLOT_STAGE_CODES.includes(attrs["typedStageState"]?.entry.code ?? "")) {
303
- identifier["number"] = "1";
304
- }
305
- return identifier;
306
- }
307
- /**
308
- * Historic TYPE-first ballot face (owner ruling 2026-11-12, Option B
309
- * decode-to-modern): "[P|F]?DAM [N] BASE [stamp]" decodes to ONE
310
- * amendment over the WHOLE base, rendered as the canonical on-base
311
- * slash face. The stage comes from the ballot token; the number from
312
- * the TYPE token, then the on-base stamp, then the owner's no-number
313
- * rule (a ballot face with no number anywhere names Amendment 1); the
314
- * stamp's date is the ballot supplement's date. The base keeps every
315
- * component it carried: a legacy slash-part stays a part of the base
316
- * number ("ISO/IEC FPDAM 9075/1" → base "9075-1"), and the base's own
317
- * type token stays the base's ("ISO/IEC PDAM TR 9573-11" → base
318
- * "TR 9573-11") — nothing migrates into the supplement slot. The
319
- * stamp's token letters (Amd/Am/…) are decode-away: the ballot's
320
- * stage is the TYPE token's.
321
- */
322
- buildBallotSupplement(tree) {
323
- const fields = {
324
- type_with_stage: s(tree["ballot_type_with_stage"]),
325
- };
326
- const number = s(tree["ballot_number"]) ??
327
- s(tree["ballot_stamp_number"]) ??
328
- s(tree["ballot_stamp_dot_number"]) ??
329
- "1";
330
- fields["number_with_part"] = number;
331
- // The on-base stamp: its date (or undated marker) is the ballot
332
- // supplement's; its number feeds the precedence above; its token
333
- // letters were matched uncaptured and decode away.
334
- const stampDate = s(tree["ballot_stamp_date"]);
335
- if (stampDate !== undefined) {
336
- const [year, month, day] = stampDate.split("-");
337
- fields["date"] = new PubidDate({ year, month, day });
338
- }
339
- else if (tree["ballot_stamp_undated_marker"] !== undefined) {
340
- fields["date"] = new PubidDate({ undated: true });
341
- }
342
- const rest = {};
343
- for (const [key, value] of Object.entries(tree)) {
344
- if (!key.startsWith("ballot_"))
345
- rest[key] = value;
346
- }
347
- return this.build({ ...fields, base: rest });
348
- }
349
- buildDirectives(tree, state) {
350
- const attrs = this.baseAttrs(tree);
351
- const publisher = this.publisherOf(tree);
352
- if (publisher !== undefined)
353
- attrs["publisher"] = publisher;
354
- attrs["typedStageState"] = state;
355
- if (tree["subgroup"] !== undefined)
356
- attrs["subgroup"] = s(tree["subgroup"]);
357
- return new IsoDirectives(attrs);
358
- }
359
- buildDirectivesSupplement(tree, state) {
360
- const attrs = this.baseAttrs(tree);
361
- attrs["typedStageState"] = state;
362
- if (tree["publisher"] !== undefined)
363
- attrs["supplement_publisher"] = s(tree["publisher"]);
364
- if (tree["base"] !== undefined)
365
- attrs["base"] = this.build(tree["base"]);
366
- return new IsoDirectivesSupplement(attrs);
367
- }
368
- buildTc(tree) {
369
- const attrs = {};
370
- const publisher = this.publisherOf(tree);
371
- if (publisher !== undefined)
372
- attrs["publisher"] = publisher;
373
- for (const key of ["tc_type", "tc_number", "sc_type", "sc_number", "wg_type", "wg_number", "number"]) {
374
- const value = s(tree[key]);
375
- if (value !== undefined)
376
- attrs[key] = value;
377
- }
378
- if (tree["year"] !== undefined) {
379
- attrs["date"] = new PubidDate({ year: s(tree["year"]) });
380
- }
381
- return new IsoTcDocument(attrs);
382
- }
383
- buildBundled(tree) {
384
- const baseDocument = this.build(tree["base_document"]);
385
- const supplements = Array.isArray(tree["supplements"])
386
- ? tree["supplements"].map((entry) => this.build(flatten(entry)["supplement"]))
387
- : [];
388
- return new IsoBundledIdentifier({ base_document: baseDocument, supplements });
389
- }
390
- }
391
- // --- Entry points ----------------------------------------------------------------
392
- function parseHuman(input) {
393
- const dad = DAD_PATTERN.exec(input);
394
- if (dad !== null) {
395
- // "ISO 2631/DAD 1[:1987]" — parsed manually; the grammar treats "/"
396
- // as a copublisher separator.
397
- const base = parseHuman(dad[1]);
398
- const builder = new IsoBuilder();
399
- const attrs = {
400
- base,
401
- number: dad[3],
402
- typedStageState: { entry: locateStage(dad[2]), originalAbbr: dad[2] },
403
- };
404
- if (dad[4] !== undefined)
405
- attrs["date"] = new PubidDate({ year: dad[4] });
406
- const klass = isoClassForType("add");
407
- return new klass(attrs);
408
- }
409
- const normalized = normalizeCyrillic(applyUpdateCodes(input));
410
- const tree = parseGrammar(isoGrammar, normalized);
411
- if (typeof tree !== "object" || tree === null) {
412
- throw new ParseFailed("ISO: unexpected parse tree", 0);
413
- }
414
- return new IsoBuilder().build(tree);
415
- }
416
- // --- URN ingestion (lib/pubid/iso/urn_parser.rb) ----------------------------
417
- // RFC 5141-bis typed-stage abbreviations → stage codes. "DIS"/"ADIS" are
418
- // ISO ladder stages the reference maps; everything else mirrors the gem's
419
- // TYPED_STAGE_REVERSE_MAP verbatim.
420
- const URN_STAGE_ABBRS = {
421
- WD: "wd", WDS: "wds", CD: "cd", CDV: "cdv", DIS: "dis", FDIS: "fdis",
422
- PDAM: "pdam", DAM: "dam", FDAM: "fdamd", DCOR: "dcor", FDCOR: "fdcor",
423
- CDTS: "cdts", DTS: "dts", FDTS: "fdts",
424
- };
425
- const URN_TYPE_TOKENS = new Set([
426
- "tr", "ts", "pas", "guide", "dir", "dir-sup", "iwa-sup", "isp", "iwa", "r", "data",
427
- ]);
428
- const URN_SUPP_TYPES = new Set(["amd", "cor", "sup", "add"]);
429
- // The URN type tokens are the gem's type keys; the ts leaf for ISO/R is
430
- // keyed "rec".
431
- const URN_TYPE_KEYS = { r: "rec" };
432
- function urnStageByHarmonized(code) {
433
- const candidates = ISO_TYPED_STAGES.filter((s) => s.harmonized?.includes(code));
434
- // The gem prefers the IS family when a code is shared across families
435
- // (pubid#570 — the registry order is load-order dependent there).
436
- return candidates.find((s) => s.typeCode === "is") ?? candidates[0];
437
- }
438
- // When the URN gives a harmonized code and no type token, the document is
439
- // an IS: prefer the non-published IS stages (PRF over the published IS for
440
- // 60.00), then the stage covering the most codes (WD over WDS).
441
- function urnIsStageByHarmonized(code) {
442
- const candidates = ISO_TYPED_STAGES.filter((s) => s.typeCode === "is" && s.harmonized?.includes(code));
443
- if (candidates.length === 0)
444
- return undefined;
445
- const nonPublished = candidates.filter((s) => s.stageCode !== "published");
446
- const pool = nonPublished.length > 0 ? nonPublished : candidates;
447
- let best = pool[0];
448
- for (const candidate of pool) {
449
- if ((candidate.harmonized?.length ?? 0) > (best.harmonized?.length ?? 0))
450
- best = candidate;
451
- }
452
- return best;
453
- }
454
- // The URN carries parts as "10164:-5-1-1" or "9001-1"; split into
455
- // number / part / subpart (a subpart keeps its dashes).
456
- function parseUrnNumberPart(raw) {
457
- if (raw === undefined)
458
- return [undefined, undefined, undefined];
459
- if (/^\w+:-/.test(raw)) {
460
- const segments = raw.split(":-");
461
- const tail = segments.slice(1).join("-").split("-");
462
- return [
463
- segments[0],
464
- tail[0],
465
- tail.length > 1 ? tail.slice(1).join("-") : undefined,
466
- ];
467
- }
468
- if (raw.includes("-")) {
469
- const segments = raw.split("-");
470
- return [
471
- segments[0],
472
- segments[1],
473
- segments.length > 2 ? segments.slice(2).join("-") : undefined,
474
- ];
475
- }
476
- return [raw, undefined, undefined];
477
- }
478
- function parseIsoUrn(urn) {
479
- if (!urn.startsWith("urn:iso:std:"))
480
- throw new Error(`Invalid ISO URN: ${urn}`);
481
- let parts = urn.slice("urn:iso:std:".length).split(":");
482
- // A trailing "ser" marks an all-parts identifier.
483
- let allParts = false;
484
- if (parts[parts.length - 1] === "ser") {
485
- parts = parts.slice(0, -1);
486
- allParts = true;
487
- }
488
- const publishers = (parts.shift() ?? "").split("-").map((p) => p.toUpperCase());
489
- let typeCode;
490
- if (parts[0] !== undefined && URN_TYPE_TOKENS.has(parts[0].toLowerCase())) {
491
- typeCode = parts.shift().toLowerCase();
492
- }
493
- // RFC 5141 requires docnumber -- "urn:iso:std:iso" is not a valid
494
- // NSS, and building it silently produced the identity-free "ISO "
495
- // (mirrors lib/pubid/iso/urn_parser.rb)
496
- if (parts.length === 0)
497
- throw new Error(`missing docnumber: ${urn}`);
498
- let [number, part, subpart] = parseUrnNumberPart(parts.shift());
499
- let year;
500
- if (/^\d{4}$/.test(parts[0] ?? ""))
501
- year = parts.shift();
502
- // URN-style part notation can trail the year (":10164:2019:-22").
503
- if ((parts[0] ?? "").startsWith("-")) {
504
- const partStr = parts.shift();
505
- [number, part, subpart] = parseUrnNumberPart(`${number}${partStr}`);
506
- }
507
- if (year === undefined && /^\d{4}$/.test(parts[0] ?? ""))
508
- year = parts.shift();
509
- let edition;
510
- if ((parts[0] ?? "").startsWith("ed-"))
511
- edition = parts.shift().slice(3);
512
- let languages;
513
- if (parts[0] !== undefined && !/^\d+$/.test(parts[0]) &&
514
- !/^(amd|cor|sup|add|v\d+|stage-|ed-)/i.test(parts[0]) &&
515
- !(parts[0].toUpperCase() in URN_STAGE_ABBRS) &&
516
- !/^[A-Za-z]+\.\d+$/.test(parts[0])) {
517
- languages = parts.shift().split(",").map((l) => l.toUpperCase()).join("/");
518
- }
519
- // Stage: either "stage-XX.XX[.vN]" (harmonized) or a typed abbreviation
520
- // ("WD", "CD.2").
521
- let stageCode;
522
- let stageFromAbbr;
523
- let stageIteration;
524
- if ((parts[0] ?? "").startsWith("stage-")) {
525
- const stageStr = parts.shift();
526
- stageCode = stageStr.slice(6).replace(/\.v\d+$/i, "");
527
- const iteration = /\.v(\d+)$/i.exec(stageStr);
528
- if (iteration !== null)
529
- stageIteration = iteration[1];
530
- }
531
- else if ((parts[0] !== undefined && parts[0].toUpperCase() in URN_STAGE_ABBRS) ||
532
- (parts[0] !== undefined && /^[A-Za-z]+\.\d+$/.test(parts[0]) &&
533
- (parts[0].toUpperCase().split(".")[0] ?? "") in URN_STAGE_ABBRS)) {
534
- const stageAbbr = parts[0].toUpperCase();
535
- // A supplement-family stage directly before its own supplement type
536
- // token ("...:FDAM:amd:1:v1") names the SUPPLEMENT's stage: consuming
537
- // it as the base's stage builds the base as a base-less supplement,
538
- // which cannot render (the gem guards the same way).
539
- const family = locateStage(stageAbbr.split(".")[0] ?? "")?.typeCode;
540
- const supplementFollows = (family !== undefined &&
541
- ["amd", "cor", "suppl", "add"].includes(family)) &&
542
- parts.slice(1).some((token) => URN_SUPP_TYPES.has(token.toLowerCase()) &&
543
- (URN_TYPE_KEYS[token.toLowerCase()] ?? token.toLowerCase()) === family);
544
- if (!supplementFollows) {
545
- parts.shift();
546
- if (stageAbbr.includes(".")) {
547
- const abbrPart = stageAbbr.split(".")[0];
548
- const iterationPart = stageAbbr.split(".")[1];
549
- stageCode = URN_STAGE_ABBRS[abbrPart];
550
- stageFromAbbr = abbrPart;
551
- stageIteration = iterationPart;
552
- }
553
- else {
554
- stageCode = URN_STAGE_ABBRS[stageAbbr];
555
- stageFromAbbr = stageAbbr;
556
- }
557
- }
558
- }
559
- // Supplements (amd, cor, sup, add), left-to-right: each wraps the previous.
560
- const supplements = [];
561
- while (parts.length > 0) {
562
- const supp = {};
563
- if ((parts[0] ?? "").startsWith("stage-")) {
564
- supp.stage = parts.shift().slice(6).replace(/\.v\d+$/i, "");
565
- }
566
- else if (parts[0] !== undefined && parts[0].toUpperCase() in URN_STAGE_ABBRS) {
567
- supp.stage = URN_STAGE_ABBRS[parts.shift().toUpperCase()];
568
- }
569
- if (parts[0] !== undefined && URN_SUPP_TYPES.has(parts[0].toLowerCase())) {
570
- supp.type = parts.shift().toLowerCase();
571
- }
572
- if (/^\d+$/.test(parts[0] ?? "")) {
573
- if (/^\d{4}$/.test(parts[0]))
574
- supp.year = parts.shift();
575
- else
576
- supp.number = parts.shift();
577
- }
578
- // The legacy year-overloaded wire ("amd:2007:v2" -- the number rode
579
- // the version slot): a v-token with no preceding number carries the
580
- // NUMBER. The RFC 5141-bis order ("amd:1:2007:v2") keeps the number
581
- // in its own slot, so a v-token after a number is the true
582
- // <supplversion>.
583
- const consumeV = () => {
584
- if ((parts[0] ?? "").startsWith("v")) {
585
- const value = parts.shift().slice(1).split(".")[0];
586
- if (supp.number === undefined)
587
- supp.number = value;
588
- else
589
- supp.version = value;
590
- }
591
- };
592
- consumeV();
593
- if (supp.year === undefined && /^\d{4}$/.test(parts[0] ?? ""))
594
- supp.year = parts.shift();
595
- // a v-token after the year would otherwise start a type-less wrap
596
- consumeV();
597
- if (parts[0] !== undefined && !/^\d+$/.test(parts[0]) &&
598
- !/^(amd|cor|sup|add|v\d+|stage-)/i.test(parts[0])) {
599
- supp.languages = parts.shift().split(",").map((l) => l.toUpperCase()).join("/");
600
- }
601
- supplements.push(supp);
602
- }
603
- // Builder tree, mirroring the gem's build_identifier.
604
- const base = {};
605
- if (publishers[0] !== undefined && publishers[0] !== "") {
606
- base["publisher"] = publishers[0];
607
- if (publishers.length > 1) {
608
- base["copublishers"] = publishers.slice(1).map((c) => ({ copublisher: c }));
609
- }
610
- }
611
- if (part !== undefined || subpart !== undefined) {
612
- base["number_with_part"] = [number, part, subpart].filter((p) => p !== undefined).join("-");
613
- }
614
- else if (number !== undefined) {
615
- base["number"] = number;
616
- }
617
- if (year !== undefined)
618
- base["date"] = year;
619
- if (edition !== undefined)
620
- base["edition"] = edition;
621
- if (typeCode !== undefined && typeCode !== "is") {
622
- base["type_with_stage"] = typeCode.toUpperCase();
623
- // Pin the document class against the stage block below overwriting
624
- // type_with_stage (the Ruby builder reads the same hint).
625
- base["document_type"] = (URN_TYPE_KEYS[typeCode] ?? typeCode).toUpperCase();
626
- }
627
- if (stageCode !== undefined) {
628
- let stage;
629
- if (stageFromAbbr !== undefined) {
630
- stage = locateStage(stageFromAbbr) ??
631
- ISO_TYPED_STAGES.find((s) => s.stageCode === stageCode);
632
- }
633
- else if (typeCode === undefined || typeCode === "is") {
634
- stage = urnIsStageByHarmonized(stageCode);
635
- // FCD is a legacy spelling of the DIS stage in URN form.
636
- if (stageCode === "40.00" && stage?.stageCode === "fcd") {
637
- stage = ISO_TYPED_STAGES.find((s) => s.stageCode === "dis" && s.harmonized?.includes("40.00")) ?? stage;
638
- }
639
- }
640
- stage ??= urnStageByHarmonized(stageCode);
641
- if (stage !== undefined)
642
- base["type_with_stage"] = stage.abbr[0] ?? "";
643
- else
644
- base["stage"] = stageCode;
645
- if (stageIteration !== undefined)
646
- base["stage_iteration"] = stageIteration;
647
- }
648
- if (languages !== undefined)
649
- base["languages"] = languages;
650
- let tree = base;
651
- for (const supp of supplements) {
652
- // A bare language token with no supplement identity names the BASE
653
- // document (the gem merges it the same way — a wrapper would drop it).
654
- if (supp.type === undefined && supp.stage === undefined &&
655
- supp.number === undefined && supp.year === undefined &&
656
- supp.languages !== undefined) {
657
- base["languages"] = supp.languages;
658
- continue;
659
- }
660
- const suppTree = {};
661
- if (supp.stage !== undefined) {
662
- // A harmonized code resolves within the supplement's own type
663
- // family -- the IS-family default would turn a staged Corrigendum
664
- // into a plain IS (mirrors the gem's build_identifier).
665
- const stage = /^\d\d\.\d\d$/.test(supp.stage)
666
- ? ISO_TYPED_STAGES.find((st) => st.harmonized?.includes(supp.stage) && st.typeKey === supp.type) ??
667
- ISO_TYPED_STAGES.find((st) => st.harmonized?.includes(supp.stage) && st.typeKey === "is")
668
- : ISO_TYPED_STAGES.find((st) => st.stageCode === supp.stage);
669
- suppTree["type_with_stage"] = stage !== undefined
670
- ? stage.abbr[0] ?? ""
671
- : supp.type?.toUpperCase() ?? supp.stage.toUpperCase();
672
- }
673
- if (supp.type !== undefined && suppTree["type_with_stage"] === undefined) {
674
- // "sup" is the generic Supplement (type key "suppl") -- the raw
675
- // "SUP" resolves the Directives Supplement row, whose render needs
676
- // the supplement_publisher a guide chain never has
677
- const typeToken = supp.type === "sup" ? "SUPPL" : supp.type.toUpperCase();
678
- suppTree["type_with_stage"] = typeToken;
679
- }
680
- if (supp.number !== undefined)
681
- suppTree["number"] = supp.number;
682
- if (supp.year !== undefined)
683
- suppTree["date"] = supp.year;
684
- if (supp.version !== undefined)
685
- suppTree["supplement_version"] = supp.version;
686
- if (supp.languages !== undefined)
687
- suppTree["languages"] = supp.languages;
688
- tree = { base: tree, ...suppTree };
689
- }
690
- const identifier = new IsoBuilder().build(tree);
691
- if (allParts) {
692
- identifier.all_parts = true;
693
- }
694
- return identifier;
695
- }
1
+ //! The iso node entry: the parse lane is the GENERATED substrate
2
+ //! (pubid/pubid-grammar#164, the terminal wave) driving the wasm
3
+ //! artifact runtime — the baked iso.json is the only parsing input. The
4
+ //! hand grammar.ts re-transcription retires from this lane. The
5
+ //! semantic delta lives in implementation.ts (the peels, the flat-wire
6
+ //! adapter, the builder dispatch and the URN ingestion), shared byte
7
+ //! for byte with the worker entry.
8
+ import { PubidRuntime } from "../../parg/runtime.js";
9
+ import * as substrate from "./generated/substrate.js";
10
+ import { makeIsoGrammarImplementation } from "./implementation.js";
11
+ // The generated substrate drives the wasm artifact runtime — registered
12
+ // once at module init. Node-only (the runtime walks to the artifacts
13
+ // through node:fs); the worker entry registers the pure-TS worker
14
+ // engine instead.
15
+ substrate.registerRuntime(() => PubidRuntime.load(substrate.FLAVOR, substrate.ENTRY));
696
16
  export function isoGrammarImplementation() {
697
- return {
698
- // Inverse of the ISO UrnGenerator (lib/pubid/iso/urn_parser.rb): the
699
- // reference rebuilds a builder hash straight from the positional URN
700
- // fields, so the port does the same against the shared IsoBuilder.
701
- parseUrn(urn) {
702
- return parseIsoUrn(urn);
703
- },
704
- parse(input) {
705
- return parseHuman(input);
706
- },
707
- };
17
+ return makeIsoGrammarImplementation((body) => substrate.boundToWire(substrate.parseBound(body)));
708
18
  }