@pubid/pubid 0.1.71 → 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.
- package/artifact/corpus.json.gz +0 -0
- package/dist/flavors/ansi/generated/substrate.d.ts +78 -0
- package/dist/flavors/ansi/generated/substrate.js +105 -0
- package/dist/flavors/ansi/implementation.d.ts +5 -0
- package/dist/flavors/ansi/implementation.js +125 -0
- package/dist/flavors/ansi/index.js +14 -117
- package/dist/flavors/api/generated/substrate.d.ts +78 -0
- package/dist/flavors/api/generated/substrate.js +105 -0
- package/dist/flavors/api/grammar.worker.d.ts +6 -0
- package/dist/flavors/api/{grammar.js → grammar.worker.js} +60 -16
- package/dist/flavors/api/implementation.d.ts +11 -0
- package/dist/flavors/api/implementation.js +106 -0
- package/dist/flavors/api/index.d.ts +1 -3
- package/dist/flavors/api/index.js +14 -98
- package/dist/flavors/arxiv/generated/substrate.d.ts +75 -0
- package/dist/flavors/arxiv/generated/substrate.js +102 -0
- package/dist/flavors/arxiv/index.js +17 -11
- package/dist/flavors/ashrae/generated/substrate.d.ts +78 -0
- package/dist/flavors/ashrae/generated/substrate.js +105 -0
- package/dist/flavors/ashrae/grammar.worker.d.ts +6 -0
- package/dist/flavors/ashrae/{grammar.js → grammar.worker.js} +76 -39
- package/dist/flavors/ashrae/implementation.d.ts +7 -0
- package/dist/flavors/ashrae/implementation.js +316 -0
- package/dist/flavors/ashrae/index.d.ts +1 -3
- package/dist/flavors/ashrae/index.js +14 -304
- package/dist/flavors/asme/generated/substrate.d.ts +78 -0
- package/dist/flavors/asme/generated/substrate.js +105 -0
- package/dist/flavors/asme/grammar.worker.d.ts +6 -0
- package/dist/flavors/asme/{grammar.js → grammar.worker.js} +41 -2
- package/dist/flavors/asme/implementation.d.ts +7 -0
- package/dist/flavors/asme/implementation.js +152 -0
- package/dist/flavors/asme/index.d.ts +1 -3
- package/dist/flavors/asme/index.js +14 -136
- package/dist/flavors/astm/generated/substrate.d.ts +78 -0
- package/dist/flavors/astm/generated/substrate.js +105 -0
- package/dist/flavors/astm/grammar.worker.d.ts +6 -0
- package/dist/flavors/astm/{grammar.js → grammar.worker.js} +39 -5
- package/dist/flavors/astm/implementation.d.ts +6 -0
- package/dist/flavors/astm/implementation.js +135 -0
- package/dist/flavors/astm/index.js +14 -125
- package/dist/flavors/bipm/generated/substrate.d.ts +78 -0
- package/dist/flavors/bipm/generated/substrate.js +105 -0
- package/dist/flavors/bipm/grammar.worker.d.ts +6 -0
- package/dist/flavors/bipm/grammar.worker.js +180 -0
- package/dist/flavors/bipm/implementation.d.ts +6 -0
- package/dist/flavors/bipm/implementation.js +244 -0
- package/dist/flavors/bipm/index.d.ts +1 -28
- package/dist/flavors/bipm/index.js +16 -650
- package/dist/flavors/bipm/model.d.ts +80 -0
- package/dist/flavors/bipm/model.js +271 -0
- package/dist/flavors/bipm/worker.d.ts +2 -0
- package/dist/flavors/bipm/worker.js +19 -0
- package/dist/flavors/bsi/generated/substrate.d.ts +78 -0
- package/dist/flavors/bsi/generated/substrate.js +105 -0
- package/dist/flavors/bsi/grammar.worker.d.ts +6 -0
- package/dist/flavors/bsi/{grammar.js → grammar.worker.js} +36 -7
- package/dist/flavors/bsi/implementation.d.ts +12 -0
- package/dist/flavors/bsi/implementation.js +967 -0
- package/dist/flavors/bsi/index.d.ts +1 -3
- package/dist/flavors/bsi/index.js +15 -940
- package/dist/flavors/bsi/model.js +16 -0
- package/dist/flavors/bsi/worker.js +11 -4
- package/dist/flavors/bsi_pfs/index.d.ts +25 -0
- package/dist/flavors/bsi_pfs/index.js +73 -10
- package/dist/flavors/calconnect/generated/substrate.d.ts +75 -0
- package/dist/flavors/calconnect/generated/substrate.js +102 -0
- package/dist/flavors/calconnect/grammar.worker.d.ts +6 -0
- package/dist/flavors/calconnect/grammar.worker.js +60 -0
- package/dist/flavors/calconnect/implementation.d.ts +6 -0
- package/dist/flavors/calconnect/implementation.js +69 -0
- package/dist/flavors/calconnect/index.d.ts +1 -19
- package/dist/flavors/calconnect/index.js +15 -111
- package/dist/flavors/calconnect/model.d.ts +26 -0
- package/dist/flavors/calconnect/model.js +52 -0
- package/dist/flavors/ccsds/generated/substrate.d.ts +75 -0
- package/dist/flavors/ccsds/generated/substrate.js +102 -0
- package/dist/flavors/ccsds/implementation.d.ts +5 -0
- package/dist/flavors/ccsds/implementation.js +67 -0
- package/dist/flavors/ccsds/index.js +13 -57
- package/dist/flavors/cen_cenelec/generated/substrate.d.ts +78 -0
- package/dist/flavors/cen_cenelec/generated/substrate.js +105 -0
- package/dist/flavors/cen_cenelec/grammar.worker.d.ts +6 -0
- package/dist/flavors/cen_cenelec/{grammar.js → grammar.worker.js} +41 -13
- package/dist/flavors/cen_cenelec/implementation.d.ts +15 -0
- package/dist/flavors/cen_cenelec/implementation.js +322 -0
- package/dist/flavors/cen_cenelec/index.d.ts +2 -4
- package/dist/flavors/cen_cenelec/index.js +16 -286
- package/dist/flavors/cen_cenelec/model.js +16 -1
- package/dist/flavors/cen_cenelec/worker.js +10 -4
- package/dist/flavors/cen_pfs/index.d.ts +5 -0
- package/dist/flavors/cen_pfs/index.js +28 -2
- package/dist/flavors/cie/generated/substrate.d.ts +78 -0
- package/dist/flavors/cie/generated/substrate.js +105 -0
- package/dist/flavors/cie/grammar.worker.d.ts +6 -0
- package/dist/flavors/cie/{grammar.js → grammar.worker.js} +71 -18
- package/dist/flavors/cie/implementation.d.ts +9 -0
- package/dist/flavors/cie/implementation.js +331 -0
- package/dist/flavors/cie/index.js +14 -309
- package/dist/flavors/csa/generated/substrate.d.ts +78 -0
- package/dist/flavors/csa/generated/substrate.js +105 -0
- package/dist/flavors/csa/grammar.worker.d.ts +12 -0
- package/dist/flavors/csa/{grammar.js → grammar.worker.js} +143 -27
- package/dist/flavors/csa/implementation.d.ts +9 -0
- package/dist/flavors/csa/implementation.js +661 -0
- package/dist/flavors/csa/index.js +14 -631
- package/dist/flavors/csa/worker.js +10 -4
- package/dist/flavors/easc/generated/substrate.d.ts +75 -0
- package/dist/flavors/easc/generated/substrate.js +102 -0
- package/dist/flavors/easc/grammar.worker.d.ts +6 -0
- package/dist/flavors/easc/grammar.worker.js +66 -0
- package/dist/flavors/easc/implementation.d.ts +6 -0
- package/dist/flavors/easc/implementation.js +58 -0
- package/dist/flavors/easc/index.d.ts +1 -2
- package/dist/flavors/easc/index.js +15 -105
- package/dist/flavors/easc/model.d.ts +10 -0
- package/dist/flavors/easc/model.js +43 -0
- package/dist/flavors/ecma/generated/substrate.d.ts +75 -0
- package/dist/flavors/ecma/generated/substrate.js +102 -0
- package/dist/flavors/ecma/grammar.worker.d.ts +6 -0
- package/dist/flavors/ecma/grammar.worker.js +63 -0
- package/dist/flavors/ecma/implementation.d.ts +6 -0
- package/dist/flavors/ecma/implementation.js +95 -0
- package/dist/flavors/ecma/index.d.ts +1 -2
- package/dist/flavors/ecma/index.js +15 -152
- package/dist/flavors/ecma/model.d.ts +10 -0
- package/dist/flavors/ecma/model.js +61 -0
- package/dist/flavors/etsi/generated/substrate.d.ts +75 -0
- package/dist/flavors/etsi/generated/substrate.js +102 -0
- package/dist/flavors/etsi/grammar.worker.d.ts +6 -0
- package/dist/flavors/etsi/grammar.worker.js +86 -0
- package/dist/flavors/etsi/implementation.d.ts +6 -0
- package/dist/flavors/etsi/implementation.js +110 -0
- package/dist/flavors/etsi/index.d.ts +2 -12
- package/dist/flavors/etsi/index.js +16 -305
- package/dist/flavors/etsi/model.d.ts +37 -0
- package/dist/flavors/etsi/model.js +169 -0
- package/dist/flavors/eu/generated/substrate.d.ts +75 -0
- package/dist/flavors/eu/generated/substrate.js +102 -0
- package/dist/flavors/eu/implementation.d.ts +7 -0
- package/dist/flavors/eu/implementation.js +150 -0
- package/dist/flavors/eu/index.js +14 -141
- package/dist/flavors/evs/generated/substrate.d.ts +78 -0
- package/dist/flavors/evs/generated/substrate.js +105 -0
- package/dist/flavors/evs/grammar.worker.d.ts +6 -0
- package/dist/flavors/evs/grammar.worker.js +98 -0
- package/dist/flavors/evs/implementation.d.ts +7 -0
- package/dist/flavors/evs/implementation.js +114 -0
- package/dist/flavors/evs/index.d.ts +1 -1
- package/dist/flavors/evs/index.js +14 -89
- package/dist/flavors/evs/worker.js +10 -4
- package/dist/flavors/gb/generated/substrate.d.ts +75 -0
- package/dist/flavors/gb/generated/substrate.js +102 -0
- package/dist/flavors/gb/grammar.worker.d.ts +6 -0
- package/dist/flavors/gb/grammar.worker.js +73 -0
- package/dist/flavors/gb/implementation.d.ts +6 -0
- package/dist/flavors/gb/implementation.js +87 -0
- package/dist/flavors/gb/index.d.ts +1 -29
- package/dist/flavors/gb/index.js +15 -157
- package/dist/flavors/gb/model.d.ts +36 -0
- package/dist/flavors/gb/model.js +79 -0
- package/dist/flavors/gost/generated/substrate.d.ts +78 -0
- package/dist/flavors/gost/generated/substrate.js +105 -0
- package/dist/flavors/gost/grammar.worker.d.ts +6 -0
- package/dist/flavors/gost/grammar.worker.js +82 -0
- package/dist/flavors/gost/implementation.d.ts +7 -0
- package/dist/flavors/gost/implementation.js +177 -0
- package/dist/flavors/gost/index.js +14 -162
- package/dist/flavors/gost/worker.js +12 -5
- package/dist/flavors/iala/generated/substrate.d.ts +78 -0
- package/dist/flavors/iala/generated/substrate.js +105 -0
- package/dist/flavors/iala/grammar.worker.d.ts +6 -0
- package/dist/flavors/iala/grammar.worker.js +127 -0
- package/dist/flavors/iala/implementation.d.ts +6 -0
- package/dist/flavors/iala/implementation.js +250 -0
- package/dist/flavors/iala/index.d.ts +1 -56
- package/dist/flavors/iala/index.js +17 -484
- package/dist/flavors/iala/model.d.ts +93 -0
- package/dist/flavors/iala/model.js +194 -0
- package/dist/flavors/iana/generated/substrate.d.ts +75 -0
- package/dist/flavors/iana/generated/substrate.js +102 -0
- package/dist/flavors/iana/grammar.worker.d.ts +6 -0
- package/dist/flavors/iana/grammar.worker.js +51 -0
- package/dist/flavors/iana/implementation.d.ts +6 -0
- package/dist/flavors/iana/implementation.js +47 -0
- package/dist/flavors/iana/index.d.ts +1 -17
- package/dist/flavors/iana/index.js +15 -69
- package/dist/flavors/iana/model.d.ts +22 -0
- package/dist/flavors/iana/model.js +33 -0
- package/dist/flavors/idf/generated/substrate.d.ts +78 -0
- package/dist/flavors/idf/generated/substrate.js +105 -0
- package/dist/flavors/idf/grammar.worker.d.ts +6 -0
- package/dist/flavors/idf/{grammar.js → grammar.worker.js} +58 -2
- package/dist/flavors/idf/implementation.d.ts +6 -0
- package/dist/flavors/idf/implementation.js +129 -0
- package/dist/flavors/idf/index.js +14 -98
- package/dist/flavors/iec/generated/substrate.d.ts +78 -0
- package/dist/flavors/iec/generated/substrate.js +105 -0
- package/dist/flavors/iec/grammar.worker.d.ts +6 -0
- package/dist/flavors/iec/grammar.worker.js +231 -0
- package/dist/flavors/iec/implementation.d.ts +15 -0
- package/dist/flavors/iec/implementation.js +956 -0
- package/dist/flavors/iec/index.d.ts +1 -2
- package/dist/flavors/iec/index.js +16 -869
- package/dist/flavors/iec/model.js +13 -1
- package/dist/flavors/iec/worker.d.ts +2 -0
- package/dist/flavors/iec/worker.js +19 -0
- package/dist/flavors/ieee/generated/substrate.d.ts +78 -0
- package/dist/flavors/ieee/generated/substrate.js +105 -0
- package/dist/flavors/ieee/implementation.d.ts +4 -0
- package/dist/flavors/ieee/implementation.js +48 -10
- package/dist/flavors/ieee/index.d.ts +3 -2
- package/dist/flavors/ieee/index.js +30 -12
- package/dist/flavors/ieee/model.js +3 -0
- package/dist/flavors/ieee/preprocessor.js +10 -10
- package/dist/flavors/ieee/worker.js +33 -11
- package/dist/flavors/ietf/generated/substrate.d.ts +75 -0
- package/dist/flavors/ietf/generated/substrate.js +102 -0
- package/dist/flavors/ietf/grammar.worker.d.ts +6 -0
- package/dist/flavors/ietf/grammar.worker.js +63 -0
- package/dist/flavors/ietf/implementation.d.ts +6 -0
- package/dist/flavors/ietf/implementation.js +60 -0
- package/dist/flavors/ietf/index.d.ts +1 -28
- package/dist/flavors/ietf/index.js +15 -149
- package/dist/flavors/ietf/model.d.ts +47 -0
- package/dist/flavors/ietf/model.js +92 -0
- package/dist/flavors/iho/generated/substrate.d.ts +78 -0
- package/dist/flavors/iho/generated/substrate.js +105 -0
- package/dist/flavors/iho/grammar.worker.d.ts +6 -0
- package/dist/flavors/iho/grammar.worker.js +150 -0
- package/dist/flavors/iho/implementation.d.ts +6 -0
- package/dist/flavors/iho/implementation.js +221 -0
- package/dist/flavors/iho/index.d.ts +1 -2
- package/dist/flavors/iho/index.js +15 -619
- package/dist/flavors/iho/model.d.ts +11 -0
- package/dist/flavors/iho/model.js +315 -0
- package/dist/flavors/index.js +3 -0
- package/dist/flavors/iso/generated/substrate.d.ts +93 -0
- package/dist/flavors/iso/generated/substrate.js +133 -0
- package/dist/flavors/iso/grammar.worker.d.ts +7 -0
- package/dist/flavors/iso/grammar.worker.js +406 -0
- package/dist/flavors/iso/implementation.d.ts +4 -0
- package/dist/flavors/iso/implementation.js +880 -0
- package/dist/flavors/iso/index.js +16 -706
- package/dist/flavors/iso/model.js +21 -2
- package/dist/flavors/iso/worker.d.ts +2 -0
- package/dist/flavors/iso/worker.js +19 -0
- package/dist/flavors/itu/generated/substrate.d.ts +78 -0
- package/dist/flavors/itu/generated/substrate.js +105 -0
- package/dist/flavors/itu/grammar.worker.d.ts +6 -0
- package/dist/flavors/itu/grammar.worker.js +306 -0
- package/dist/flavors/itu/implementation.d.ts +10 -0
- package/dist/flavors/itu/implementation.js +285 -0
- package/dist/flavors/itu/index.js +15 -246
- package/dist/flavors/itu/worker.d.ts +2 -0
- package/dist/flavors/itu/worker.js +19 -0
- package/dist/flavors/jcgm/generated/substrate.d.ts +78 -0
- package/dist/flavors/jcgm/generated/substrate.js +105 -0
- package/dist/flavors/jcgm/grammar.worker.d.ts +6 -0
- package/dist/flavors/jcgm/grammar.worker.js +98 -0
- package/dist/flavors/jcgm/implementation.d.ts +6 -0
- package/dist/flavors/jcgm/implementation.js +187 -0
- package/dist/flavors/jcgm/index.d.ts +1 -5
- package/dist/flavors/jcgm/index.js +16 -364
- package/dist/flavors/jcgm/model.d.ts +43 -0
- package/dist/flavors/jcgm/model.js +168 -0
- package/dist/flavors/jis/generated/substrate.d.ts +78 -0
- package/dist/flavors/jis/generated/substrate.js +105 -0
- package/dist/flavors/jis/grammar.worker.d.ts +6 -0
- package/dist/flavors/jis/grammar.worker.js +132 -0
- package/dist/flavors/jis/implementation.d.ts +6 -0
- package/dist/flavors/jis/implementation.js +129 -0
- package/dist/flavors/jis/index.d.ts +0 -2
- package/dist/flavors/jis/index.js +15 -390
- package/dist/flavors/jis/model.d.ts +30 -0
- package/dist/flavors/jis/model.js +205 -0
- package/dist/flavors/jis/worker.d.ts +2 -0
- package/dist/flavors/jis/worker.js +19 -0
- package/dist/flavors/nist/generated/substrate.d.ts +78 -0
- package/dist/flavors/nist/generated/substrate.js +105 -0
- package/dist/flavors/nist/index.js +18 -11
- package/dist/flavors/nist/worker.js +8 -4
- package/dist/flavors/oasis/generated/substrate.d.ts +75 -0
- package/dist/flavors/oasis/generated/substrate.js +102 -0
- package/dist/flavors/oasis/grammar.worker.d.ts +6 -0
- package/dist/flavors/oasis/grammar.worker.js +50 -0
- package/dist/flavors/oasis/implementation.d.ts +6 -0
- package/dist/flavors/oasis/implementation.js +80 -0
- package/dist/flavors/oasis/index.d.ts +1 -21
- package/dist/flavors/oasis/index.js +16 -108
- package/dist/flavors/oasis/model.d.ts +27 -0
- package/dist/flavors/oasis/model.js +34 -0
- package/dist/flavors/ogc/generated/substrate.d.ts +75 -0
- package/dist/flavors/ogc/generated/substrate.js +102 -0
- package/dist/flavors/ogc/grammar.worker.d.ts +6 -0
- package/dist/flavors/ogc/grammar.worker.js +55 -0
- package/dist/flavors/ogc/implementation.d.ts +6 -0
- package/dist/flavors/ogc/implementation.js +49 -0
- package/dist/flavors/ogc/index.d.ts +1 -18
- package/dist/flavors/ogc/index.js +15 -73
- package/dist/flavors/ogc/model.d.ts +23 -0
- package/dist/flavors/ogc/model.js +32 -0
- package/dist/flavors/oiml/generated/substrate.d.ts +78 -0
- package/dist/flavors/oiml/generated/substrate.js +105 -0
- package/dist/flavors/oiml/grammar.worker.d.ts +6 -0
- package/dist/flavors/oiml/grammar.worker.js +239 -0
- package/dist/flavors/oiml/implementation.d.ts +2 -1
- package/dist/flavors/oiml/implementation.js +16 -7
- package/dist/flavors/oiml/index.js +15 -6
- package/dist/flavors/oiml/model.js +19 -19
- package/dist/flavors/oiml/worker.js +14 -6
- package/dist/flavors/omg/generated/substrate.d.ts +78 -0
- package/dist/flavors/omg/generated/substrate.js +105 -0
- package/dist/flavors/omg/grammar.worker.d.ts +6 -0
- package/dist/flavors/omg/grammar.worker.js +64 -0
- package/dist/flavors/omg/implementation.d.ts +7 -0
- package/dist/flavors/omg/implementation.js +33 -0
- package/dist/flavors/omg/index.d.ts +1 -12
- package/dist/flavors/omg/index.js +15 -71
- package/dist/flavors/omg/model.d.ts +16 -0
- package/dist/flavors/omg/model.js +26 -0
- package/dist/flavors/plateau/generated/substrate.d.ts +78 -0
- package/dist/flavors/plateau/generated/substrate.js +105 -0
- package/dist/flavors/plateau/grammar.worker.d.ts +6 -0
- package/dist/flavors/plateau/grammar.worker.js +78 -0
- package/dist/flavors/plateau/implementation.d.ts +6 -0
- package/dist/flavors/plateau/implementation.js +74 -0
- package/dist/flavors/plateau/index.d.ts +1 -2
- package/dist/flavors/plateau/index.js +18 -114
- package/dist/flavors/plateau/model.d.ts +11 -0
- package/dist/flavors/plateau/model.js +51 -0
- package/dist/flavors/register-types.d.ts +20 -19
- package/dist/flavors/register-types.js +44 -19
- package/dist/flavors/sae/generated/substrate.d.ts +75 -0
- package/dist/flavors/sae/generated/substrate.js +102 -0
- package/dist/flavors/sae/grammar.worker.d.ts +6 -0
- package/dist/flavors/sae/grammar.worker.js +84 -0
- package/dist/flavors/sae/implementation.d.ts +11 -0
- package/dist/flavors/sae/implementation.js +109 -0
- package/dist/flavors/sae/index.d.ts +3 -0
- package/dist/flavors/sae/index.js +19 -0
- package/dist/flavors/sae/model.d.ts +86 -0
- package/dist/flavors/sae/model.js +185 -0
- package/dist/flavors/tgpp/generated/substrate.d.ts +78 -0
- package/dist/flavors/tgpp/generated/substrate.js +105 -0
- package/dist/flavors/tgpp/grammar.worker.d.ts +6 -0
- package/dist/flavors/tgpp/grammar.worker.js +69 -0
- package/dist/flavors/tgpp/implementation.d.ts +8 -0
- package/dist/flavors/tgpp/implementation.js +56 -0
- package/dist/flavors/tgpp/index.d.ts +1 -2
- package/dist/flavors/tgpp/index.js +15 -120
- package/dist/flavors/tgpp/model.d.ts +13 -0
- package/dist/flavors/tgpp/model.js +52 -0
- package/dist/flavors/w3c/generated/substrate.d.ts +78 -0
- package/dist/flavors/w3c/generated/substrate.js +105 -0
- package/dist/flavors/w3c/grammar.worker.d.ts +6 -0
- package/dist/flavors/w3c/grammar.worker.js +55 -0
- package/dist/flavors/w3c/implementation.d.ts +7 -0
- package/dist/flavors/w3c/implementation.js +49 -0
- package/dist/flavors/w3c/index.d.ts +1 -12
- package/dist/flavors/w3c/index.js +15 -146
- package/dist/flavors/w3c/model.d.ts +15 -0
- package/dist/flavors/w3c/model.js +103 -0
- package/dist/flavors/wmo/generated/substrate.d.ts +78 -0
- package/dist/flavors/wmo/generated/substrate.js +105 -0
- package/dist/flavors/wmo/implementation.d.ts +5 -0
- package/dist/flavors/wmo/implementation.js +79 -0
- package/dist/flavors/wmo/index.js +14 -68
- package/dist/flavors/worker-registry.js +246 -68
- package/dist/flavors/xsf/generated/substrate.d.ts +75 -0
- package/dist/flavors/xsf/generated/substrate.js +102 -0
- package/dist/flavors/xsf/grammar.worker.d.ts +6 -0
- package/dist/flavors/xsf/grammar.worker.js +53 -0
- package/dist/flavors/xsf/implementation.d.ts +6 -0
- package/dist/flavors/xsf/implementation.js +34 -0
- package/dist/flavors/xsf/index.d.ts +1 -16
- package/dist/flavors/xsf/index.js +16 -63
- package/dist/flavors/xsf/model.d.ts +20 -0
- package/dist/flavors/xsf/model.js +26 -0
- package/dist/model/identifier.d.ts +13 -1
- package/dist/model/identifier.js +71 -9
- package/dist/model/relation.d.ts +36 -0
- package/dist/model/relation.js +93 -0
- package/dist/parg/artifacts/ieee.d.ts +1 -1
- package/dist/parg/artifacts/ieee.js +1 -1
- package/dist/parg/worker.d.ts +4 -2
- package/dist/parg/worker.js +5 -3
- package/dist/parse-surface.js +4 -2
- package/dist/pubid-urn/decoder.d.ts +8 -0
- package/dist/pubid-urn/decoder.js +43 -0
- package/dist/pubid-urn/encoder.js +31 -0
- package/dist/pubid-urn/schema.d.ts +1 -1
- package/dist/pubid-urn/schema.js +1 -1
- package/dist/pubid-urn/schemas/bsi.js +1 -0
- package/dist/pubid-urn/schemas/bsi_pfs.js +9 -7
- package/dist/pubid-urn/schemas/cen_pfs.js +1 -0
- package/dist/pubid-urn/schemas/cencenelec.js +1 -0
- package/dist/pubid-urn/schemas/iec.js +1 -0
- package/dist/pubid-urn/schemas/ieee.js +1 -0
- package/dist/pubid-urn/schemas/iso.js +1 -0
- package/package.json +1 -1
- package/vendor/parg/bsi_pfs.json +1 -1
- package/vendor/parg/calconnect_pfs.json +1 -1
- package/vendor/parg/cen_pfs.json +1 -1
- package/vendor/parg/doi_pfs.json +1 -1
- package/vendor/parg/etsi_pfs.json +1 -1
- package/vendor/parg/ieee.json +1 -1
- package/vendor/parg/iho.json +1 -1
- package/vendor/parg/plateau.json +1 -1
- package/dist/flavors/api/grammar.d.ts +0 -4
- package/dist/flavors/ashrae/grammar.d.ts +0 -2
- package/dist/flavors/asme/grammar.d.ts +0 -2
- package/dist/flavors/astm/grammar.d.ts +0 -2
- package/dist/flavors/bsi/grammar.d.ts +0 -4
- package/dist/flavors/cen_cenelec/grammar.d.ts +0 -4
- package/dist/flavors/cie/grammar.d.ts +0 -5
- package/dist/flavors/csa/grammar.d.ts +0 -6
- package/dist/flavors/evs/grammar.d.ts +0 -2
- package/dist/flavors/evs/grammar.js +0 -68
- package/dist/flavors/gost/grammar.d.ts +0 -2
- package/dist/flavors/gost/grammar.js +0 -46
- package/dist/flavors/idf/grammar.d.ts +0 -2
- package/dist/flavors/iec/grammar.d.ts +0 -3
- package/dist/flavors/iec/grammar.js +0 -234
- package/dist/flavors/ieee/grammar.d.ts +0 -2
- package/dist/flavors/ieee/grammar.js +0 -777
- package/dist/flavors/iso/grammar.d.ts +0 -7
- package/dist/flavors/iso/grammar.js +0 -282
- package/dist/flavors/itu/grammar.d.ts +0 -4
- package/dist/flavors/itu/grammar.js +0 -276
- package/dist/flavors/nist/grammar.d.ts +0 -2
- package/dist/flavors/nist/grammar.js +0 -342
- package/dist/flavors/oiml/grammar.d.ts +0 -2
- package/dist/flavors/oiml/grammar.js +0 -206
- package/vendor/parg/csv.json +0 -1
- package/vendor/parg/ini.json +0 -1
- package/vendor/parg/json.json +0 -1
- package/vendor/parg/lua.json +0 -1
- package/vendor/parg/toml.json +0 -1
|
@@ -1,871 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (raw === undefined)
|
|
16
|
-
return {};
|
|
17
|
-
const out = { number: raw };
|
|
18
|
-
const part = obj === undefined ? undefined : s(obj["part"]);
|
|
19
|
-
const subpart = obj === undefined ? undefined : s(obj["subpart"]);
|
|
20
|
-
if (part !== undefined)
|
|
21
|
-
out["part"] = part;
|
|
22
|
-
if (subpart !== undefined)
|
|
23
|
-
out["subpart"] = subpart;
|
|
24
|
-
return out;
|
|
25
|
-
}
|
|
26
|
-
function buildDate(tree) {
|
|
27
|
-
const dateStr = s(flatten(tree));
|
|
28
|
-
if (dateStr === undefined)
|
|
29
|
-
return undefined;
|
|
30
|
-
const parts = dateStr.split("-");
|
|
31
|
-
return new PubidDate({ year: parts[0], month: parts[1], day: parts[2] });
|
|
32
|
-
}
|
|
33
|
-
function parseLanguages(tree) {
|
|
34
|
-
const raw = s(tree);
|
|
35
|
-
if (raw === undefined)
|
|
36
|
-
return [];
|
|
37
|
-
const tokens = raw.split(",").flatMap((chunk) => chunk.split("/"));
|
|
38
|
-
return tokens
|
|
39
|
-
.map((token) => token.trim())
|
|
40
|
-
.filter((token) => token !== "")
|
|
41
|
-
.map((original) => {
|
|
42
|
-
const code = original.length === 1
|
|
43
|
-
? (Language.CHAR_MAP[original] ?? original.toLowerCase())
|
|
44
|
-
: original;
|
|
45
|
-
return new Language({ code, originalCode: original });
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
class IecBuilder {
|
|
49
|
-
build(data) {
|
|
50
|
-
return this.buildInner(data);
|
|
51
|
-
}
|
|
52
|
-
buildInner(data) {
|
|
53
|
-
const tree = flatten(data);
|
|
54
|
-
// Ruby's bound hash is flat and vap_suffix is never a SUPP key, so
|
|
55
|
-
// the capture lands on the base build no matter which layer's
|
|
56
|
-
// second part carried it — the Vap wrapper nests INSIDE every
|
|
57
|
-
// supplement layer ("…+AMD1:1999 CSV/COR1:2003"). Push the capture
|
|
58
|
-
// down before dispatching; the recursion re-applies it until it
|
|
59
|
-
// reaches the base designation.
|
|
60
|
-
const vapSuffix = s(tree["vap_suffix"]);
|
|
61
|
-
if (vapSuffix !== undefined && isObj(tree["base"])) {
|
|
62
|
-
delete tree["vap_suffix"];
|
|
63
|
-
tree["base"]["vap_suffix"] = vapSuffix;
|
|
64
|
-
}
|
|
65
|
-
// The third_part language rides the BASE document on every
|
|
66
|
-
// attached-supplement layer: the ruby grammar binds the layers'
|
|
67
|
-
// language unprefixed, the supplement field set keeps none
|
|
68
|
-
// (SUPP_KEYS), and the wire carries base.languages — the ruby
|
|
69
|
-
// render prints it inside the base portion
|
|
70
|
-
// ("ISO/IEC 19772:2009(en)/DAM1:2019"). Push it down before
|
|
71
|
-
// dispatching; the recursion re-applies it until it reaches the
|
|
72
|
-
// base. A standalone supplement (no base tree) keeps its own
|
|
73
|
-
// languages, like ruby's standalone slice.
|
|
74
|
-
const languages = tree["languages"];
|
|
75
|
-
if (languages !== undefined && isObj(tree["base"])) {
|
|
76
|
-
delete tree["languages"];
|
|
77
|
-
tree["base"]["languages"] = languages;
|
|
78
|
-
}
|
|
79
|
-
// --- working programme / working document ---
|
|
80
|
-
if (tree["wp_stage"] !== undefined)
|
|
81
|
-
return this.buildWorkingProgramme(tree);
|
|
82
|
-
if (tree["technical_committee"] !== undefined && tree["wd_number"] !== undefined) {
|
|
83
|
-
return this.buildWorkingDocument(tree);
|
|
84
|
-
}
|
|
85
|
-
if (tree["technical_committee"] !== undefined) {
|
|
86
|
-
throw new ParseFailed("IEC: technical groups are not corpus-covered", 0);
|
|
87
|
-
}
|
|
88
|
-
// --- the legacy DAM-family prefix face (decode-to-modern) ---
|
|
89
|
-
if (tree["legacy_stage"] !== undefined) {
|
|
90
|
-
return this.buildLegacySupplement(tree);
|
|
91
|
-
}
|
|
92
|
-
// --- fragment of an amendment/corrigendum (third_part notation) ---
|
|
93
|
-
if (tree["fragment_type"] !== undefined && tree["base"] !== undefined) {
|
|
94
|
-
return this.buildFragment(tree);
|
|
95
|
-
}
|
|
96
|
-
// --- sheets ---
|
|
97
|
-
if (tree["base"] !== undefined && (tree["sheet_number"] !== undefined || tree["sheet_year"] !== undefined)) {
|
|
98
|
-
return this.buildSheet(tree);
|
|
99
|
-
}
|
|
100
|
-
// --- supplements (incl. supplement-of-supplement) ---
|
|
101
|
-
if (tree["base"] !== undefined)
|
|
102
|
-
return this.buildSupplement(tree);
|
|
103
|
-
return this.buildSingle(tree);
|
|
104
|
-
}
|
|
105
|
-
commonAttrs(tree, attrs) {
|
|
106
|
-
Object.assign(attrs, numberComponents(tree["number_with_part"]));
|
|
107
|
-
// Letters-prefixed numbers (IECEE "CAB", "AD") only take digit-first
|
|
108
|
-
// parts — "CAB-G01" rejects (Ruby parity; digit numbers like 61158-X
|
|
109
|
-
// keep letter parts). "DIR" is the exception: the Directives number
|
|
110
|
-
// is its own grammar branch and takes letter parts ("DIR-IEC-SUP").
|
|
111
|
-
const number = attrs["number"];
|
|
112
|
-
const part = attrs["part"];
|
|
113
|
-
if (number !== undefined && /^[A-Z]{2,4}$/.test(number) && number !== "DIR" &&
|
|
114
|
-
part !== undefined && /^[A-Za-z]/.test(part)) {
|
|
115
|
-
throw new ParseFailed(`IEC: letter part ${part} after letters number ${number}`, 0);
|
|
116
|
-
}
|
|
117
|
-
const dateTree = tree["date"];
|
|
118
|
-
if (dateTree !== undefined) {
|
|
119
|
-
const date = buildDate(dateTree);
|
|
120
|
-
if (date)
|
|
121
|
-
attrs["date"] = date;
|
|
122
|
-
}
|
|
123
|
-
// The designation's dotted sub-number ("60038-2.3", "/DAM 2.3:2022" —
|
|
124
|
-
// pubid#725): the shared second_part token binds it next to the
|
|
125
|
-
// number, and every layer that carries a designation holds it as the
|
|
126
|
-
// Iteration facet — the way the ISO flavor does.
|
|
127
|
-
const stageIteration = s(tree["stage_iteration"]);
|
|
128
|
-
if (stageIteration !== undefined) {
|
|
129
|
-
attrs["stage_iteration"] = new Iteration({ string: stageIteration });
|
|
130
|
-
}
|
|
131
|
-
if (tree["undated_marker"] !== undefined)
|
|
132
|
-
attrs["date"] = new PubidDate({ undated: true });
|
|
133
|
-
const edition = s(tree["edition"]);
|
|
134
|
-
if (edition !== undefined)
|
|
135
|
-
attrs["edition"] = edition;
|
|
136
|
-
if (tree["languages"] !== undefined) {
|
|
137
|
-
attrs["languages"] = parseLanguages(tree["languages"]);
|
|
138
|
-
}
|
|
139
|
-
const publisher = s(tree["publisher"]);
|
|
140
|
-
if (publisher !== undefined)
|
|
141
|
-
attrs["publisher"] = publisher;
|
|
142
|
-
const copubTree = tree["copublishers"];
|
|
143
|
-
if (copubTree !== undefined && copubTree !== null && copubTree !== "") {
|
|
144
|
-
const list = Array.isArray(copubTree) ? copubTree : [copubTree];
|
|
145
|
-
const bodies = list
|
|
146
|
-
.map((c) => (isObj(c) ? String(c["copublisher"]) : String(c)))
|
|
147
|
-
.filter((b) => b !== "" && b !== "null" && b !== "undefined");
|
|
148
|
-
if (bodies.length > 0)
|
|
149
|
-
attrs["copublishers"] = bodies;
|
|
150
|
-
}
|
|
151
|
-
if (tree["all_parts"] !== undefined)
|
|
152
|
-
attrs["all_parts"] = true;
|
|
153
|
-
if (tree["database"] !== undefined)
|
|
154
|
-
attrs["database"] = true;
|
|
155
|
-
}
|
|
156
|
-
buildSingle(tree) {
|
|
157
|
-
const stageAbbr = s(tree["type_with_stage"]) ?? s(tree["type_with_stage_fr"]) ?? "";
|
|
158
|
-
const typedStage = locateStage(stageAbbr) ?? locateStage("IS");
|
|
159
|
-
// The kind IS the type code: every IecTypeCode slot carries its own
|
|
160
|
-
// class now, including "wp" — the White Paper deliverable
|
|
161
|
-
// (pubid-ts#195), not the working document (which the work-programme
|
|
162
|
-
// and working-document builders construct through
|
|
163
|
-
// WORKING_DOCUMENT_CLASS directly).
|
|
164
|
-
const kind = typedStage.typeCode;
|
|
165
|
-
const attrs = {};
|
|
166
|
-
this.commonAttrs(tree, attrs);
|
|
167
|
-
// TRF with an embedded CISPR document: the form itself has no number
|
|
168
|
-
// — the document it reports on is built as the nested identifier and
|
|
169
|
-
// serializes under `cispr_identifier` (pubid#687). The runtime
|
|
170
|
-
// columns stay for the renderer and the official-URN slot.
|
|
171
|
-
if (tree["trf_org"] !== undefined) {
|
|
172
|
-
const cisprComponents = numberComponents(tree["number_with_part"]);
|
|
173
|
-
attrs["cispr_number"] = cisprComponents["number"];
|
|
174
|
-
attrs["cispr_part"] = cisprComponents["part"];
|
|
175
|
-
const cispr = new IEC_CLASSES.KIND_CLASSES["is"]({ publisher: "CISPR", ...cisprComponents });
|
|
176
|
-
attrs["cispr_identifier"] = cispr;
|
|
177
|
-
delete attrs["number"];
|
|
178
|
-
delete attrs["part"];
|
|
179
|
-
delete attrs["subpart"];
|
|
180
|
-
}
|
|
181
|
-
// The supplement-of-supplement path stores the base separately.
|
|
182
|
-
const parsed = {
|
|
183
|
-
typedStage,
|
|
184
|
-
kind: kind,
|
|
185
|
-
attrs,
|
|
186
|
-
};
|
|
187
|
-
// The ensure_base decode (ruby SupplementIdentifier#ensure_base;
|
|
188
|
-
// the 2026-11-12 owner ruling reversing #693): a standalone draft
|
|
189
|
-
// face whose designation is designation-shaped ("IEC/DCOR 60038-1",
|
|
190
|
-
// "IEC CDISH 60050-191") moves the designation WHOLE onto a
|
|
191
|
-
// concrete InternationalStandard base — number, part, subpart and
|
|
192
|
-
// the date (old notation prints the base's year) — while the
|
|
193
|
-
// supplement keeps a number of its own, defaulting to 1 (the
|
|
194
|
-
// no-number rule: an unnumbered DCOR/DISH/CDISH means
|
|
195
|
-
// Corrigendum/Interpretation-Sheet 1). The concrete base is what
|
|
196
|
-
// makes the decode hash-match (and equal) the modern on-base parse
|
|
197
|
-
// of the same document. A supplement with no part (a true
|
|
198
|
-
// standalone like "IEC/AMD 1:2017") keeps its own number below.
|
|
199
|
-
if ((kind === "amd" || kind === "cor" || kind === "ish") &&
|
|
200
|
-
tree["base"] === undefined &&
|
|
201
|
-
attrs["part"] !== undefined) {
|
|
202
|
-
const baseAttrs = {};
|
|
203
|
-
// The designation's dotted sub-part moves with it (pubid#725):
|
|
204
|
-
// "IEC/DCOR 60038-2.3" is base 60038-2 with stage iteration 3 —
|
|
205
|
-
// the same identity the plain on-base parse holds — not a facet of
|
|
206
|
-
// the implied supplement. Only the designation-shaped layout (a
|
|
207
|
-
// part present) carries it; a true standalone's own iteration
|
|
208
|
-
// ("IEC/AMD 1.2:2017", no part) stays where it is.
|
|
209
|
-
for (const key of ["publisher", "copublishers", "number", "part", "subpart", "date", "stage_iteration"]) {
|
|
210
|
-
if (attrs[key] !== undefined)
|
|
211
|
-
baseAttrs[key] = attrs[key];
|
|
212
|
-
}
|
|
213
|
-
const base = new IEC_CLASSES.KIND_CLASSES["is"](baseAttrs);
|
|
214
|
-
const suppAttrs = { base, number: "1" };
|
|
215
|
-
// Supplements copy the delegated publisher/copublishers level
|
|
216
|
-
// (ruby reads them through the base; the stored wire copies the
|
|
217
|
-
// non-default level).
|
|
218
|
-
if (attrs["publisher"] !== undefined && attrs["publisher"] !== "IEC") {
|
|
219
|
-
suppAttrs["publisher"] = attrs["publisher"];
|
|
220
|
-
}
|
|
221
|
-
if (Array.isArray(attrs["copublishers"]) && attrs["copublishers"].length > 0) {
|
|
222
|
-
suppAttrs["copublishers"] = attrs["copublishers"];
|
|
223
|
-
}
|
|
224
|
-
const supplement = this.construct({ kind: kind, attrs: suppAttrs, typedStage }, suppAttrs);
|
|
225
|
-
supplement["base"] = base;
|
|
226
|
-
return supplement;
|
|
227
|
-
}
|
|
228
|
-
// Consolidated supplements (+AMD…+AMD…)
|
|
229
|
-
const consolidated = tree["consolidated_supplements"];
|
|
230
|
-
let identifier = this.construct(parsed, attrs);
|
|
231
|
-
if (consolidated !== undefined) {
|
|
232
|
-
identifier = this.wrapConsolidated(identifier, consolidated);
|
|
233
|
-
}
|
|
234
|
-
const vapSuffix = s(tree["vap_suffix"]);
|
|
235
|
-
if (vapSuffix !== undefined) {
|
|
236
|
-
identifier = this.wrapVap(identifier, vapSuffix);
|
|
237
|
-
}
|
|
238
|
-
return identifier;
|
|
239
|
-
}
|
|
240
|
-
construct(parsed, attrs) {
|
|
241
|
-
const klass = IEC_CLASSES.KIND_CLASSES[parsed.kind];
|
|
242
|
-
if (klass === undefined)
|
|
243
|
-
throw new ParseFailed(`IEC: unknown kind ${String(parsed.kind)}`, 0);
|
|
244
|
-
const identifier = new klass(attrs);
|
|
245
|
-
identifier.typedStage = parsed.typedStage;
|
|
246
|
-
// The wire "stage" is the draft stage code (published stages drop).
|
|
247
|
-
const ts = parsed.typedStage;
|
|
248
|
-
if (ts !== undefined && ts.stageCode !== "published") {
|
|
249
|
-
identifier["stage"] = ts.code;
|
|
250
|
-
}
|
|
251
|
-
return identifier;
|
|
252
|
-
}
|
|
253
|
-
wrapConsolidated(base, data) {
|
|
254
|
-
const list = Array.isArray(data) ? data : [data];
|
|
255
|
-
const members = [base];
|
|
256
|
-
for (const raw of list) {
|
|
257
|
-
if (!isObj(raw))
|
|
258
|
-
continue;
|
|
259
|
-
const type = s(raw["supplement_type"]);
|
|
260
|
-
const number = s(raw["supplement_number"]);
|
|
261
|
-
if (type === undefined || number === undefined)
|
|
262
|
-
continue;
|
|
263
|
-
const date = s(raw["supplement_year"]);
|
|
264
|
-
const attrs = {
|
|
265
|
-
number,
|
|
266
|
-
...(date !== undefined ? { date: new PubidDate({ year: date }) } : {}),
|
|
267
|
-
};
|
|
268
|
-
const kind = type === "AMD" ? "amd" : "cor";
|
|
269
|
-
const member = this.construct({ kind: kind, attrs, typedStage: locateStage(type) }, attrs);
|
|
270
|
-
members.push(member);
|
|
271
|
-
}
|
|
272
|
-
return new IEC_CLASSES.CONSOLIDATED_CLASS({
|
|
273
|
-
identifiers: members,
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
wrapVap(base, vapSuffix) {
|
|
277
|
-
const vap = vapSuffix.split("-");
|
|
278
|
-
let edition;
|
|
279
|
-
// A consolidated base carries the edition on its FIRST member (Ruby).
|
|
280
|
-
const kind = base.constructor.polymorphicName.slice("pubid:iec:".length);
|
|
281
|
-
const holder = kind === "consolidated-identifier"
|
|
282
|
-
? base.identifiers[0]
|
|
283
|
-
: base;
|
|
284
|
-
if (holder["edition"] !== undefined) {
|
|
285
|
-
edition = String(holder["edition"]);
|
|
286
|
-
delete holder["edition"];
|
|
287
|
-
}
|
|
288
|
-
return new IEC_CLASSES.VAP_CLASS({
|
|
289
|
-
base,
|
|
290
|
-
vap,
|
|
291
|
-
...(edition !== undefined ? { edition } : {}),
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* The legacy DAM-family prefix face (IEC/FDAM 60038-1, ISO/IEC PDAM
|
|
296
|
-
* 2 10646:2012, ISO/IEC FPDAM 9075/1): the JTC1 ballot spelling puts
|
|
297
|
-
* the stage token before the base designation. Decode onto the
|
|
298
|
-
* modern identity (owner ruling 2026-11-12): the designation is the
|
|
299
|
-
* BASE's, kept whole — the old slash-part spelling "9075/1" is base
|
|
300
|
-
* 9075 part 1 — and the supplement's number is the captured N,
|
|
301
|
-
* defaulting to 1 (the no-number rule). The date rides with the
|
|
302
|
-
* designation (old notation prints the base's year); a draft
|
|
303
|
-
* supplement carries none of its own. The base builds through the
|
|
304
|
-
* ordinary single-document path, so it is the same
|
|
305
|
-
* InternationalStandard the modern on-base parse holds and
|
|
306
|
-
* parse(legacy) == parse(modern).
|
|
307
|
-
*/
|
|
308
|
-
buildLegacySupplement(tree) {
|
|
309
|
-
const baseTree = {};
|
|
310
|
-
if (tree["publisher"] !== undefined)
|
|
311
|
-
baseTree["publisher"] = tree["publisher"];
|
|
312
|
-
if (tree["legacy_copublisher"] !== undefined) {
|
|
313
|
-
baseTree["copublishers"] = [s(tree["legacy_copublisher"])];
|
|
314
|
-
}
|
|
315
|
-
if (tree["legacy_base_number"] !== undefined) {
|
|
316
|
-
// The slash-part designation ("9075/1") captured number and part
|
|
317
|
-
// separately; they go on straight as the plain strings the
|
|
318
|
-
// retyped attributes are.
|
|
319
|
-
baseTree["number_with_part"] = {
|
|
320
|
-
number: s(tree["legacy_base_number"]),
|
|
321
|
-
...(s(tree["legacy_base_part"]) !== undefined ? { part: s(tree["legacy_base_part"]) } : {}),
|
|
322
|
-
};
|
|
323
|
-
}
|
|
324
|
-
else if (tree["legacy_base_number_with_part"] !== undefined) {
|
|
325
|
-
const designation = tree["legacy_base_number_with_part"];
|
|
326
|
-
baseTree["number_with_part"] = isObj(designation)
|
|
327
|
-
? flatten(designation)["number_with_part"]
|
|
328
|
-
: designation;
|
|
329
|
-
}
|
|
330
|
-
if (tree["date"] !== undefined)
|
|
331
|
-
baseTree["date"] = tree["date"];
|
|
332
|
-
if (tree["undated_marker"] !== undefined)
|
|
333
|
-
baseTree["undated_marker"] = tree["undated_marker"];
|
|
334
|
-
if (tree["edition"] !== undefined)
|
|
335
|
-
baseTree["edition"] = tree["edition"];
|
|
336
|
-
if (tree["languages"] !== undefined)
|
|
337
|
-
baseTree["languages"] = tree["languages"];
|
|
338
|
-
// The designation's dotted sub-number is the BASE's ("IEC/FDAM
|
|
339
|
-
// 60038-2.3" — base 60038-2, stage iteration 3; pubid#725), the same
|
|
340
|
-
// facet the plain on-base parse carries: the base builds through the
|
|
341
|
-
// ordinary single-document path, which binds it like any designation.
|
|
342
|
-
// The supplement layer keeps none — the dot moves with the
|
|
343
|
-
// designation it rode in on.
|
|
344
|
-
if (tree["stage_iteration"] !== undefined)
|
|
345
|
-
baseTree["stage_iteration"] = tree["stage_iteration"];
|
|
346
|
-
// The wrap: one amendment/corrigendum layer over the whole base;
|
|
347
|
-
// third_part's fragment notation rides the outermost layer.
|
|
348
|
-
const suppTree = {
|
|
349
|
-
base: baseTree,
|
|
350
|
-
type_with_stage: s(tree["legacy_stage"]),
|
|
351
|
-
number_with_part: { number: s(tree["legacy_supplement_number"]) ?? "1" },
|
|
352
|
-
};
|
|
353
|
-
if (tree["fragment_type"] !== undefined) {
|
|
354
|
-
suppTree["fragment_type"] = tree["fragment_type"];
|
|
355
|
-
suppTree["fragment_number"] = tree["fragment_number"];
|
|
356
|
-
}
|
|
357
|
-
return this.buildInner(suppTree);
|
|
358
|
-
}
|
|
359
|
-
buildSupplement(tree) {
|
|
360
|
-
const base = this.buildInner(tree["base"]);
|
|
361
|
-
const stageAbbr = s(tree["type_with_stage"]) ?? "";
|
|
362
|
-
const typedStage = locateStage(stageAbbr) ?? locateStage("AMD");
|
|
363
|
-
let kind;
|
|
364
|
-
if (typedStage.typeCode === "cor")
|
|
365
|
-
kind = "cor";
|
|
366
|
-
else if (typedStage.typeCode === "ish")
|
|
367
|
-
kind = "ish";
|
|
368
|
-
else if (typedStage.typeCode === "frag") {
|
|
369
|
-
// FRAG parses as a supplement stage; the class is the fragment.
|
|
370
|
-
const innerAttrs = {};
|
|
371
|
-
this.commonAttrs(tree, innerAttrs);
|
|
372
|
-
const number = innerAttrs["number"];
|
|
373
|
-
delete innerAttrs["number"];
|
|
374
|
-
const baseRec2 = base;
|
|
375
|
-
if (baseRec2["publisher"] !== undefined && baseRec2["publisher"] !== "IEC")
|
|
376
|
-
innerAttrs["publisher"] = baseRec2["publisher"];
|
|
377
|
-
const fragment = new IEC_CLASSES.FRAGMENT_CLASS({
|
|
378
|
-
base,
|
|
379
|
-
...(number !== undefined ? { fragment_number: number } : {}),
|
|
380
|
-
...innerAttrs,
|
|
381
|
-
});
|
|
382
|
-
return fragment;
|
|
383
|
-
}
|
|
384
|
-
else
|
|
385
|
-
kind = "amd";
|
|
386
|
-
const attrs = {};
|
|
387
|
-
this.commonAttrs(tree, attrs);
|
|
388
|
-
// Supplements copy the delegated publisher/copublishers level.
|
|
389
|
-
const baseRec = base;
|
|
390
|
-
if (attrs["publisher"] === undefined && baseRec["publisher"] !== undefined && baseRec["publisher"] !== "IEC") {
|
|
391
|
-
attrs["publisher"] = baseRec["publisher"];
|
|
392
|
-
}
|
|
393
|
-
if (attrs["copublishers"] === undefined && Array.isArray(baseRec["copublishers"]) && baseRec["copublishers"].length > 0) {
|
|
394
|
-
attrs["copublishers"] = baseRec["copublishers"];
|
|
395
|
-
}
|
|
396
|
-
const supplement = this.construct({ kind: kind, attrs, typedStage }, attrs);
|
|
397
|
-
supplement["base"] = base;
|
|
398
|
-
return supplement;
|
|
399
|
-
}
|
|
400
|
-
buildSheet(tree) {
|
|
401
|
-
let base = this.buildInner(tree["base"]);
|
|
402
|
-
const sheet_number = s(tree["sheet_number"]);
|
|
403
|
-
const sheet_year = s(tree["sheet_year"]);
|
|
404
|
-
base = new IEC_CLASSES.SHEET_CLASS({
|
|
405
|
-
base,
|
|
406
|
-
...(sheet_number !== undefined ? { sheet_number } : {}),
|
|
407
|
-
...(sheet_year !== undefined ? { sheet_year } : {}),
|
|
408
|
-
});
|
|
409
|
-
// A supplement wrapping the sheet: IEC 60695-2-1/1:1994/COR1:1995.
|
|
410
|
-
if (tree["type_with_stage"] !== undefined) {
|
|
411
|
-
const stageAbbr = s(tree["type_with_stage"]) ?? "";
|
|
412
|
-
const typedStage = locateStage(stageAbbr) ?? locateStage("COR");
|
|
413
|
-
const kind = typedStage.typeCode === "cor" ? "cor" : "amd";
|
|
414
|
-
const attrs = {};
|
|
415
|
-
const numberObj = numberComponents(tree["number_with_part"]);
|
|
416
|
-
Object.assign(attrs, numberObj);
|
|
417
|
-
const dateTree = tree["date"];
|
|
418
|
-
if (dateTree !== undefined) {
|
|
419
|
-
const date = buildDate(dateTree);
|
|
420
|
-
if (date)
|
|
421
|
-
attrs["date"] = date;
|
|
422
|
-
}
|
|
423
|
-
const supplement = this.construct({ kind: kind, attrs, typedStage }, attrs);
|
|
424
|
-
supplement["base"] = base;
|
|
425
|
-
return supplement;
|
|
426
|
-
}
|
|
427
|
-
return base;
|
|
428
|
-
}
|
|
429
|
-
buildFragment(tree) {
|
|
430
|
-
// fragment_notation on the outer identifier (third_part)
|
|
431
|
-
const innerTree = { ...tree };
|
|
432
|
-
delete innerTree["fragment_type"];
|
|
433
|
-
delete innerTree["fragment_number"];
|
|
434
|
-
const base = this.buildInner(innerTree);
|
|
435
|
-
const fragment_number = s(tree["fragment_number"]);
|
|
436
|
-
const edition = s(tree["edition"]);
|
|
437
|
-
return new IEC_CLASSES.FRAGMENT_CLASS({
|
|
438
|
-
base,
|
|
439
|
-
...(fragment_number !== undefined ? { fragment_number } : {}),
|
|
440
|
-
...(edition !== undefined ? { edition } : {}),
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
buildWorkingProgramme(tree) {
|
|
444
|
-
// The grammar captures a trailing space on wp_type ("PWI TR 100-36"
|
|
445
|
-
// -> "TR "); ruby strips it at the construction site (its builder's
|
|
446
|
-
// :wp_type cast) so the stored value — and the hash and URN — is the
|
|
447
|
-
// stripped form, an all-space value dropping out entirely.
|
|
448
|
-
const wpTypeRaw = s(tree["wp_type"])?.replace(/\s+$/, "");
|
|
449
|
-
const attrs = {
|
|
450
|
-
wp_stage: s(tree["wp_stage"]),
|
|
451
|
-
wp_type: wpTypeRaw === "" ? undefined : wpTypeRaw,
|
|
452
|
-
};
|
|
453
|
-
if (tree["wp_raw"] !== undefined) {
|
|
454
|
-
// TC-style name ("SyCCOMM-1"): split the trailing number as the part.
|
|
455
|
-
const raw = String(tree["wp_raw"]).replaceAll("‑", "-").replaceAll("‐", "-");
|
|
456
|
-
const segments = raw.split("-").filter((seg) => seg !== "");
|
|
457
|
-
attrs["number"] = segments.shift();
|
|
458
|
-
if (segments.length > 0)
|
|
459
|
-
attrs["part"] = segments.shift();
|
|
460
|
-
if (segments.length > 0)
|
|
461
|
-
attrs["subpart"] = segments.join("-");
|
|
462
|
-
}
|
|
463
|
-
Object.assign(attrs, numberComponents(tree["number_with_part"]));
|
|
464
|
-
const edition = s(tree["edition"]);
|
|
465
|
-
if (edition !== undefined)
|
|
466
|
-
attrs["edition"] = edition;
|
|
467
|
-
const identifier = new IEC_CLASSES.WORKING_DOCUMENT_CLASS(attrs);
|
|
468
|
-
const ts = locateStage(s(tree["wp_stage"]) === "PNW" ? "PNW" : "PWI");
|
|
469
|
-
identifier.typedStage = ts;
|
|
470
|
-
if (ts !== undefined && ts.stageCode !== "published") {
|
|
471
|
-
identifier["stage"] = ts.code;
|
|
472
|
-
}
|
|
473
|
-
return identifier;
|
|
474
|
-
}
|
|
475
|
-
buildWorkingDocument(tree) {
|
|
476
|
-
const attrs = {
|
|
477
|
-
technical_committee: s(tree["technical_committee"]),
|
|
478
|
-
// The document number is the inherited `number` (pubid#687: the
|
|
479
|
-
// parallel wd_number slot used to serialize nowhere).
|
|
480
|
-
number: s(tree["wd_number"]),
|
|
481
|
-
wd_language: s(tree["wd_language"]),
|
|
482
|
-
wd_stage: s(tree["wd_stage"]),
|
|
483
|
-
};
|
|
484
|
-
return new IEC_CLASSES.WORKING_DOCUMENT_CLASS(attrs);
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
/** --- URN: the positional-slot machine (lib/pubid/iec/urn_generator.rb) --- */
|
|
488
|
-
const TYPE_SLOT_CODES = new Set(["tr", "ts", "pas", "srd", "guide", "tec", "wp"]);
|
|
489
|
-
const DELIVERABLES = new Set(["cmv", "csv", "exv", "prv", "rlv", "ser"]);
|
|
490
|
-
const ADJUNCT_TOKENS = {
|
|
491
|
-
amendment: "amd",
|
|
492
|
-
corrigendum: "cor",
|
|
493
|
-
"interpretation-sheet": "ish",
|
|
494
|
-
};
|
|
495
|
-
function idKind(id) {
|
|
496
|
-
return id.constructor.polymorphicName.slice("pubid:iec:".length);
|
|
497
|
-
}
|
|
498
|
-
function maybeOf(id, attr) {
|
|
499
|
-
return id[attr];
|
|
500
|
-
}
|
|
501
|
-
function findDown(id, attr) {
|
|
502
|
-
let current = id;
|
|
503
|
-
while (current !== undefined) {
|
|
504
|
-
const value = maybeOf(current, attr);
|
|
505
|
-
if (value !== undefined && !(Array.isArray(value) && value.length === 0) && value !== "") {
|
|
506
|
-
return value;
|
|
507
|
-
}
|
|
508
|
-
current =
|
|
509
|
-
maybeOf(current, "base") ??
|
|
510
|
-
maybeOf(current, "identifiers")?.[0];
|
|
511
|
-
}
|
|
512
|
-
return undefined;
|
|
513
|
-
}
|
|
514
|
-
function rootOf(id) {
|
|
515
|
-
let current = id;
|
|
516
|
-
while (true) {
|
|
517
|
-
const base = maybeOf(current, "base");
|
|
518
|
-
if (base !== undefined) {
|
|
519
|
-
current = base;
|
|
520
|
-
continue;
|
|
521
|
-
}
|
|
522
|
-
const ids = maybeOf(current, "identifiers");
|
|
523
|
-
if (ids !== undefined && ids.length > 0 && ids[0] !== current) {
|
|
524
|
-
current = ids[0];
|
|
525
|
-
continue;
|
|
526
|
-
}
|
|
527
|
-
return current;
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
function adjunctFields(id, plus) {
|
|
531
|
-
const kind = idKind(id);
|
|
532
|
-
const token = ADJUNCT_TOKENS[kind];
|
|
533
|
-
if (token === undefined)
|
|
534
|
-
return [];
|
|
535
|
-
const date = maybeOf(id, "date");
|
|
536
|
-
// The supplement's dotted sub-number rides its number slot
|
|
537
|
-
// ("amd:2.3:2022"; pubid#725): ISO's official URN keeps the facet
|
|
538
|
-
// through its version atom, and this scheme has no version slot, so
|
|
539
|
-
// the number slot carries the designation as printed. The parser
|
|
540
|
-
// rebuilds "/AMD2.3:2022" from the slot, which re-parses losslessly.
|
|
541
|
-
const iteration = maybeOf(id, "stage_iteration");
|
|
542
|
-
const number = String(maybeOf(id, "number") ?? "") +
|
|
543
|
-
(iteration !== undefined ? `.${iteration.render()}` : "");
|
|
544
|
-
return [
|
|
545
|
-
plus ? "plus" : "",
|
|
546
|
-
token,
|
|
547
|
-
number,
|
|
548
|
-
date !== undefined ? (date.render() ?? "") : "",
|
|
549
|
-
];
|
|
550
|
-
}
|
|
551
|
-
function adjunctSlots(id) {
|
|
552
|
-
if (id === undefined)
|
|
553
|
-
return [];
|
|
554
|
-
const kind = idKind(id);
|
|
555
|
-
if (kind === "consolidated-identifier") {
|
|
556
|
-
const members = maybeOf(id, "identifiers") ?? [];
|
|
557
|
-
return [
|
|
558
|
-
...adjunctSlots(members[0]),
|
|
559
|
-
...members.slice(1).flatMap((m) => adjunctFields(m, true)),
|
|
560
|
-
];
|
|
561
|
-
}
|
|
562
|
-
const recursed = adjunctSlots(maybeOf(id, "base"));
|
|
563
|
-
if (ADJUNCT_TOKENS[kind] !== undefined) {
|
|
564
|
-
return [...recursed, ...adjunctFields(id, false)];
|
|
565
|
-
}
|
|
566
|
-
return recursed;
|
|
567
|
-
}
|
|
568
|
-
export function iecToUrn(identifier) {
|
|
569
|
-
// The document the URN names: the origin standard with wrappers peeled.
|
|
570
|
-
const doc = rootOf(identifier);
|
|
571
|
-
const trf = doc;
|
|
572
|
-
let docWithNumber;
|
|
573
|
-
if (maybeOf(trf, "number") === undefined && maybeOf(trf, "cispr_number") !== undefined) {
|
|
574
|
-
// TRF: read number/part from the runtime CISPR columns.
|
|
575
|
-
docWithNumber = {
|
|
576
|
-
get number() { return maybeOf(trf, "cispr_number"); },
|
|
577
|
-
get part() { return maybeOf(trf, "cispr_part"); },
|
|
578
|
-
get subpart() { return undefined; },
|
|
579
|
-
get publisher() { return "CISPR"; },
|
|
580
|
-
get copublishers() { return []; },
|
|
581
|
-
get date() { return undefined; },
|
|
582
|
-
get typedStage() { return trf.typedStage; },
|
|
583
|
-
};
|
|
584
|
-
}
|
|
585
|
-
else {
|
|
586
|
-
docWithNumber = maybeOf(doc, "number") !== undefined
|
|
587
|
-
? doc
|
|
588
|
-
: maybeOf(doc, "cispr_identifier") ?? doc;
|
|
589
|
-
}
|
|
590
|
-
const number = maybeOf(docWithNumber, "number");
|
|
591
|
-
if (number === undefined)
|
|
592
|
-
return "urn:iec:std:";
|
|
593
|
-
const numSegment = [number, maybeOf(docWithNumber, "part"), maybeOf(docWithNumber, "subpart")]
|
|
594
|
-
.filter((v) => v !== undefined && v !== "")
|
|
595
|
-
.join("-")
|
|
596
|
-
.replace(/\s+/g, "-");
|
|
597
|
-
if (numSegment === "")
|
|
598
|
-
return "urn:iec:std:";
|
|
599
|
-
const publishers = [
|
|
600
|
-
maybeOf(docWithNumber, "publisher") ?? "IEC",
|
|
601
|
-
...(maybeOf(docWithNumber, "copublishers") ?? []),
|
|
602
|
-
]
|
|
603
|
-
.filter((p) => p !== undefined && p !== "")
|
|
604
|
-
.map((p) => p.split(/\s+/).at(-1))
|
|
605
|
-
.filter((p) => p !== "");
|
|
606
|
-
const authority = publishers.join("-");
|
|
607
|
-
const date = maybeOf(docWithNumber, "date");
|
|
608
|
-
const dateSlot = date !== undefined ? (date.render() ?? "") : "";
|
|
609
|
-
const ts = docWithNumber.typedStage;
|
|
610
|
-
const typeToken = ts !== undefined && TYPE_SLOT_CODES.has(ts.typeCode) ? ts.typeCode : "";
|
|
611
|
-
// The gem's stage_token (urn_generator.rb): nil when the stage is
|
|
612
|
-
// published OR when the typed stage carries no harmonized code — there
|
|
613
|
-
// is NO stage-code fallback, so a harmonized-less draft row (BPUB,
|
|
614
|
-
// the draft-supplement rows) leaves the slot empty (#187).
|
|
615
|
-
const stageToken = ts !== undefined && ts.stageCode !== "published" && ts.harmonized !== undefined
|
|
616
|
-
? `stage-${ts.harmonized}`
|
|
617
|
-
: "";
|
|
618
|
-
const stageOrType = [typeToken, stageToken].filter((t) => t !== "").join("-");
|
|
619
|
-
const vap = findDown(identifier, "vap");
|
|
620
|
-
const vapCodes = (vap ?? [])
|
|
621
|
-
.map((c) => c.toLowerCase())
|
|
622
|
-
.filter((c) => DELIVERABLES.has(c));
|
|
623
|
-
let deliverable = vapCodes.join("-");
|
|
624
|
-
if (deliverable === "") {
|
|
625
|
-
const edition = findDown(identifier, "edition");
|
|
626
|
-
deliverable = edition !== undefined ? `ed-${edition}` : "";
|
|
627
|
-
}
|
|
628
|
-
const langs = maybeOf(identifier, "languages") ?? [];
|
|
629
|
-
const language = langs.map((l) => l.code).join("-");
|
|
630
|
-
const slots = ["urn", "iec", "std", authority, numSegment, dateSlot, stageOrType, deliverable];
|
|
631
|
-
const adjuncts = adjunctSlots(identifier);
|
|
632
|
-
const bareSeries = slots.at(-1) === "ser" &&
|
|
633
|
-
slots.slice(5, 7).every((x) => x === "") &&
|
|
634
|
-
adjuncts.length === 0 &&
|
|
635
|
-
language === "";
|
|
636
|
-
if (!bareSeries)
|
|
637
|
-
slots.push(language);
|
|
638
|
-
return [...slots, ...adjuncts].join(":").toLowerCase();
|
|
639
|
-
}
|
|
640
|
-
// Attach the URN generator to every registered IEC class (the base
|
|
641
|
-
// toUrn resolves constructor.urnGenerator).
|
|
642
|
-
class IecUrnGenerator {
|
|
643
|
-
identifier;
|
|
644
|
-
constructor(identifier) {
|
|
645
|
-
this.identifier = identifier;
|
|
646
|
-
}
|
|
647
|
-
generate() {
|
|
648
|
-
return iecToUrn(this.identifier);
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
for (const klass of [
|
|
652
|
-
...Object.values(IEC_CLASSES.KIND_CLASSES),
|
|
653
|
-
IEC_CLASSES.WORKING_DOCUMENT_CLASS,
|
|
654
|
-
IEC_CLASSES.SHEET_CLASS,
|
|
655
|
-
IEC_CLASSES.VAP_CLASS,
|
|
656
|
-
IEC_CLASSES.CONSOLIDATED_CLASS,
|
|
657
|
-
IEC_CLASSES.FRAGMENT_CLASS,
|
|
658
|
-
]) {
|
|
659
|
-
if (klass !== undefined) {
|
|
660
|
-
klass.urnGenerator = IecUrnGenerator;
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
// --- the standalone no-part dotted face reject (pubid#727) --------------
|
|
664
|
-
// A supplement's OWN dotted sub-number has nowhere to print on the
|
|
665
|
-
// standalone (no-part, self-base) face: the standalone renderer prints
|
|
666
|
-
// the base number and the supplement number only, so the parsed dot was
|
|
667
|
-
// dropped at render and parse(render) != parse. No IEC source prints a
|
|
668
|
-
// no-part standalone face with a dotted number — the facet is attested
|
|
669
|
-
// only on the on-base draft faces ("IEC 60038-2/DAM 2.3:2022") — so the
|
|
670
|
-
// shape is rejected at parse instead of being built unrenderable (the
|
|
671
|
-
// #726 ruling for unattested dotted shapes; the TS mirror of the gem's
|
|
672
|
-
// reject_standalone_dotted_supplement walk over the built base chain).
|
|
673
|
-
// The check is the SHAPE, not a grammar route: one condition covers the
|
|
674
|
-
// standalone branch ("IEC/AMD 1.2:2017"), the publisher-less plain route
|
|
675
|
-
// ("AMD 1.2:2017") and a dotted layer under an undotted second
|
|
676
|
-
// supplement ("IEC/AMD 1.2:2017/COR 1:2018"). The single-document draft
|
|
677
|
-
// faces ("IEC CD 1.2:2017"), the DAM-family decodes ("IEC/DAM 1.2") and
|
|
678
|
-
// the on-base faces (a real base) keep their dot on a printable layer
|
|
679
|
-
// and pass. from_hash deliberately still deserializes the shape (no
|
|
680
|
-
// stored row carries it; residue pinned).
|
|
681
|
-
const STANDALONE_DOTTED_SUPPLEMENT_MESSAGE = 'the standalone no-part supplement face carries a dotted sub-number ' +
|
|
682
|
-
'(e.g. "IEC/AMD 1.2:2017"): no IEC source prints one, and the ' +
|
|
683
|
-
"standalone face has no layer to print the dot on, so the stored " +
|
|
684
|
-
"sub-number would be dropped at render — the dotted sub-number is " +
|
|
685
|
-
"attested only on the on-base draft forms";
|
|
686
|
-
const SUPPLEMENT_POLYMORPHIC_NAMES = new Set([
|
|
687
|
-
"pubid:iec:amendment",
|
|
688
|
-
"pubid:iec:corrigendum",
|
|
689
|
-
"pubid:iec:interpretation-sheet",
|
|
690
|
-
]);
|
|
691
|
-
function rejectStandaloneDottedSupplement(id) {
|
|
692
|
-
let node = id;
|
|
693
|
-
while (node !== undefined && SUPPLEMENT_POLYMORPHIC_NAMES.has(node.constructor.polymorphicName)) {
|
|
694
|
-
const layer = node;
|
|
695
|
-
const iteration = layer["stage_iteration"];
|
|
696
|
-
const base = layer["base"];
|
|
697
|
-
if (iteration !== undefined && (base === undefined || layer["synthetic_base"] === true)) {
|
|
698
|
-
throw new ParseFailed(STANDALONE_DOTTED_SUPPLEMENT_MESSAGE, 0);
|
|
699
|
-
}
|
|
700
|
-
node = base;
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
// --- the un-renderable trailing-edition chain reject (pubid#788) --------
|
|
704
|
-
// The bare consolidated chain with a trailing edition
|
|
705
|
-
// ("IEC 60068:2005+AMD1:2012 ED2") parses, and then cannot render: the
|
|
706
|
-
// edition rides the base member, so the composition prints it onto the
|
|
707
|
-
// base designation ("IEC 60068:2005 ED2+AMD1:2012") — a face no IEC
|
|
708
|
-
// source prints (0 of the 33,070 primary docidentifiers in
|
|
709
|
-
// relaton-data-iec carry an edition facet on a chain) and the grammar
|
|
710
|
-
// rejects, so parse(render) raises. The consolidated edition IS the CSV
|
|
711
|
-
// product ("IEC 60034-18-41:2014+AMD1:2019 CSV", the OBP PDF named
|
|
712
|
-
// {ed1.1}); where the printed edition appears at all it is the CSV
|
|
713
|
-
// face's own facet ("IEC 60068:2005+AMD1:2012 CSV ED1" — the Vap carries
|
|
714
|
-
// the edition after the deliverable code and renders back parseably).
|
|
715
|
-
// So the shape is rejected at parse — the #727 ruling for unattested,
|
|
716
|
-
// un-renderable faces — rather than built unrenderable. The check is the
|
|
717
|
-
// SHAPE on the built object, not a grammar route (the same ruling as
|
|
718
|
-
// rejectStandaloneDottedSupplement): a bare ConsolidatedIdentifier with
|
|
719
|
-
// an edition on any member, found by the gem's descend_wrapper walk (a
|
|
720
|
-
// node with a `base` attribute descends to it, a node with `identifiers`
|
|
721
|
-
// to its first member). from_hash stays open (stored-data
|
|
722
|
-
// compatibility): parse can no longer produce the shape and no stored
|
|
723
|
-
// row carries it. The edition-bearing face that DOES round-trip is the
|
|
724
|
-
// CSV one ("IEC 60068:2005+AMD1:2012 CSV ED1" — the edition rides the
|
|
725
|
-
// Vap after the deliverable code).
|
|
726
|
-
const CONSOLIDATED_EDITION_MESSAGE = 'the bare consolidated chain carries a trailing edition ' +
|
|
727
|
-
'(e.g. "IEC 60068:2005+AMD1:2012 ED2"): no IEC source prints one — ' +
|
|
728
|
-
"0 of the 33,070 primary docidentifiers in relaton-data-iec carry an " +
|
|
729
|
-
"edition facet on a chain — and the canonical render prints the " +
|
|
730
|
-
'edition onto the base designation ("IEC 60068:2005 ED2+AMD1:2012"), ' +
|
|
731
|
-
"which cannot be re-parsed. The consolidated edition is the CSV face " +
|
|
732
|
-
'("IEC 60034-18-41:2014+AMD1:2019 CSV", the OBP PDF named {ed1.1}); ' +
|
|
733
|
-
'where the printed edition appears it rides the CSV face ("IEC ' +
|
|
734
|
-
'60068:2005+AMD1:2012 CSV ED1"), which parses and round-trips';
|
|
735
|
-
function rejectUnrenderableConsolidatedEdition(id) {
|
|
736
|
-
let node = id;
|
|
737
|
-
while (node !== undefined) {
|
|
738
|
-
if (node.constructor.polymorphicName === "pubid:iec:consolidated-identifier") {
|
|
739
|
-
const members = node.identifiers ?? [];
|
|
740
|
-
if (members.some((member) => member["edition"] !== undefined &&
|
|
741
|
-
member["edition"] !== null)) {
|
|
742
|
-
throw new ParseFailed(CONSOLIDATED_EDITION_MESSAGE, 0);
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
// Ruby descend_wrapper: a node whose class declares a `base`
|
|
746
|
-
// attribute descends to it; a node with `identifiers` to its first
|
|
747
|
-
// member; a leaf ends the walk.
|
|
748
|
-
const attrs = node.constructor
|
|
749
|
-
.attributes;
|
|
750
|
-
if (attrs !== undefined && "base" in attrs) {
|
|
751
|
-
node = node["base"];
|
|
752
|
-
}
|
|
753
|
-
else if (attrs !== undefined && "identifiers" in attrs) {
|
|
754
|
-
node = node.identifiers?.[0];
|
|
755
|
-
}
|
|
756
|
-
else {
|
|
757
|
-
node = undefined;
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
}
|
|
1
|
+
//! The iec node entry: the parse lane is the GENERATED substrate
|
|
2
|
+
//! (pubid/pubid-grammar#164) driving the wasm artifact runtime - the
|
|
3
|
+
//! baked iec.json is the only parsing input. The hand grammar.ts
|
|
4
|
+
//! re-transcription retired from this lane. The semantic delta lives in
|
|
5
|
+
//! implementation.ts (the flat-hash builder, the URN machine, the
|
|
6
|
+
//! parse-shape rejects), shared byte for byte with the worker entry.
|
|
7
|
+
import { PubidRuntime } from "../../parg/runtime.js";
|
|
8
|
+
import * as substrate from "./generated/substrate.js";
|
|
9
|
+
import { makeIecGrammarImplementation } from "./implementation.js";
|
|
10
|
+
// The generated substrate drives the wasm artifact runtime - registered
|
|
11
|
+
// once at module init. Node-only (the runtime walks to the artifacts
|
|
12
|
+
// through node:fs); the worker entry registers the pure-TS worker
|
|
13
|
+
// engine instead.
|
|
14
|
+
substrate.registerRuntime(() => PubidRuntime.load(substrate.FLAVOR, substrate.ENTRY));
|
|
761
15
|
export function iecGrammarImplementation() {
|
|
762
|
-
|
|
763
|
-
return {
|
|
764
|
-
// Inverse of the IEC UrnGenerator (lib/pubid/iec/urn_parser.rb):
|
|
765
|
-
// reassemble the positional URN fields into a text code, parse it, then
|
|
766
|
-
// attach languages and the all-parts wrap.
|
|
767
|
-
parseUrn(urn) {
|
|
768
|
-
const parsed = urnToCode(urn);
|
|
769
|
-
if (!parsed)
|
|
770
|
-
throw new Error(`Invalid IEC URN: ${urn}`);
|
|
771
|
-
let [code, lang, allParts] = parsed;
|
|
772
|
-
// The "ser" slot names every part of the document: the reference
|
|
773
|
-
// wraps via to_all_parts, which strips the part and the date (a
|
|
774
|
-
// series names the document across editions, "IEC 60034 (all
|
|
775
|
-
// parts)"). The part rides dash-joined on the number, the date in
|
|
776
|
-
// its own slot.
|
|
777
|
-
if (allParts) {
|
|
778
|
-
code = code
|
|
779
|
-
.replace(/:[^:]*$/, "")
|
|
780
|
-
.replace(/\s(19|20)\d\d(-\d\d)?$/, "")
|
|
781
|
-
.replace(/-[^\s:-]+$/, "");
|
|
782
|
-
}
|
|
783
|
-
// The reference parses the unprefixed rebuild and its grammar
|
|
784
|
-
// defaults the IEC publisher; the ts grammar needs it explicit.
|
|
785
|
-
const id = this.parse(code);
|
|
786
|
-
if (lang && lang !== "" && "languages" in id) {
|
|
787
|
-
id.languages = lang
|
|
788
|
-
.split("-")
|
|
789
|
-
.map((c) => new Language({ code: c }));
|
|
790
|
-
}
|
|
791
|
-
if (allParts) {
|
|
792
|
-
id.all_parts = true;
|
|
793
|
-
}
|
|
794
|
-
return id;
|
|
795
|
-
},
|
|
796
|
-
parse(input) {
|
|
797
|
-
let tree;
|
|
798
|
-
try {
|
|
799
|
-
tree = parseGrammar(iecGrammar, preprocessIec(input));
|
|
800
|
-
}
|
|
801
|
-
catch {
|
|
802
|
-
throw new ParseFailed("IEC: parse failed", 0);
|
|
803
|
-
}
|
|
804
|
-
const built = builder.build(tree);
|
|
805
|
-
// The shape check runs on the BUILT object (ruby Identifier.parse
|
|
806
|
-
// walks the base chain after ensure_base) — BSI's delegation and
|
|
807
|
-
// every parse route raise through this entry; from_hash stays open.
|
|
808
|
-
rejectStandaloneDottedSupplement(built);
|
|
809
|
-
rejectUnrenderableConsolidatedEdition(built);
|
|
810
|
-
return built;
|
|
811
|
-
},
|
|
812
|
-
};
|
|
813
|
-
}
|
|
814
|
-
// Port of Relaton::Iec.urn_to_code + the slot helpers
|
|
815
|
-
// (lib/pubid/iec/urn_parser.rb): reassemble the positional URN fields into
|
|
816
|
-
// a text code. Returns [code, language, allParts].
|
|
817
|
-
function urnToCode(urn) {
|
|
818
|
-
const fields = urn.toUpperCase().split(":");
|
|
819
|
-
if (fields.length < 5)
|
|
820
|
-
return undefined;
|
|
821
|
-
const [head, num, date, type, deliv, lang] = fields.slice(3, 9);
|
|
822
|
-
let allParts = false;
|
|
823
|
-
let code = head.replaceAll("-", "/");
|
|
824
|
-
const typeCode = typeSlotToCode(type);
|
|
825
|
-
if (typeCode !== "")
|
|
826
|
-
code += ` ${typeCode}`;
|
|
827
|
-
code += ` ${num}`;
|
|
828
|
-
if (date !== undefined && date !== "")
|
|
829
|
-
code += `:${date}`;
|
|
830
|
-
code += adjunctToCode(fields.slice(9));
|
|
831
|
-
if ((deliv ?? "").toLowerCase() === "ser") {
|
|
832
|
-
allParts = true;
|
|
833
|
-
}
|
|
834
|
-
else if (deliv !== undefined) {
|
|
835
|
-
const edition = editionSlotToCode(deliv);
|
|
836
|
-
if (edition)
|
|
837
|
-
code += ` ${edition}`;
|
|
838
|
-
else if (deliv !== "")
|
|
839
|
-
code += ` ${deliv}`;
|
|
840
|
-
}
|
|
841
|
-
return [code, lang?.toLowerCase(), allParts];
|
|
842
|
-
}
|
|
843
|
-
// The type slot holds a legacy type token ("TS"), a stage
|
|
844
|
-
// ("STAGE-10.20"), or both ("TS-STAGE-50.00"); a stage is written back as
|
|
845
|
-
// the abbreviation resolved from the typed-stage registry.
|
|
846
|
-
function typeSlotToCode(type) {
|
|
847
|
-
if (type === undefined || type === "")
|
|
848
|
-
return "";
|
|
849
|
-
const match = type.match(/^([A-Z]+-)?STAGE-([\d.]+)$/);
|
|
850
|
-
if (!match)
|
|
851
|
-
return type;
|
|
852
|
-
const stageType = (match[1] ?? "IS-").replace("-", "").toLowerCase();
|
|
853
|
-
const stage = TYPED_STAGES.find((t) => t.typeCode === stageType && (t.harmonized ?? "") === match[2]);
|
|
854
|
-
return stage ? stage.abbr : "";
|
|
855
|
-
}
|
|
856
|
-
// "ED-7" in the deliverable slot is an edition, not a deliverable code.
|
|
857
|
-
function editionSlotToCode(deliv) {
|
|
858
|
-
const match = deliv?.match(/^ED-(.+)$/);
|
|
859
|
-
return match ? `ED${match[1]}` : undefined;
|
|
860
|
-
}
|
|
861
|
-
// Adjuncts are (relation, type, number, date) quartets; a "PLUS" relation
|
|
862
|
-
// yields "+", otherwise "/".
|
|
863
|
-
function adjunctToCode(fields) {
|
|
864
|
-
if (!fields.length)
|
|
865
|
-
return "";
|
|
866
|
-
const [rel = "", type = "", num = "", date = ""] = fields.slice(0, 4);
|
|
867
|
-
let code = (rel === "" ? "/" : "+") + type + num;
|
|
868
|
-
if (date !== "")
|
|
869
|
-
code += `:${date}`;
|
|
870
|
-
return code + adjunctToCode(fields.slice(4));
|
|
16
|
+
return makeIecGrammarImplementation((body) => substrate.boundToWire(substrate.parseBound(body)));
|
|
871
17
|
}
|
|
18
|
+
export { preprocessIec, iecToUrn, rejectStandaloneDottedSupplement, rejectUnrenderableConsolidatedEdition, } from "./implementation.js";
|