@pubid/pubid 0.1.74 → 0.1.76
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/README.md +24 -10
- package/artifact/corpus.json.gz +0 -0
- package/dist/flavors/bipm/worker.js +4 -8
- package/dist/flavors/bsi/worker.js +4 -7
- package/dist/flavors/cen_cenelec/worker.js +4 -7
- package/dist/flavors/csa/worker.js +4 -7
- package/dist/flavors/evs/worker.js +4 -7
- package/dist/flavors/gost/worker.js +4 -7
- package/dist/flavors/iec/worker.js +4 -8
- package/dist/flavors/ieee/worker.js +1 -4
- package/dist/flavors/iso/worker.js +4 -8
- package/dist/flavors/itu/grammar.worker.js +1 -8
- package/dist/flavors/itu/implementation.js +1 -3
- package/dist/flavors/itu/worker.d.ts +2 -1
- package/dist/flavors/itu/worker.js +18 -14
- package/dist/flavors/jis/worker.js +4 -8
- package/dist/flavors/nist/generated/substrate.d.ts +3 -3
- package/dist/flavors/nist/generated/substrate.js +4 -4
- package/dist/flavors/nist/implementation.js +14 -2
- package/dist/flavors/nist/model.js +10 -1
- package/dist/flavors/nist/worker.js +1 -5
- package/dist/flavors/oiml/worker.js +4 -8
- package/dist/flavors/worker-registry.js +68 -67
- package/dist/lane-keys.d.ts +15 -7
- package/dist/lane-keys.js +40 -7
- package/dist/parg/artifacts/itu.d.ts +2 -0
- package/dist/parg/artifacts/itu.js +5 -0
- package/dist/parg/artifacts/nist.d.ts +1 -1
- package/dist/parg/artifacts/nist.js +1 -1
- package/dist/parg/bound.d.ts +9 -0
- package/dist/parg/bound.js +23 -0
- package/dist/parg/worker-engine.d.ts +1 -5
- package/dist/parg/worker-engine.js +1 -11
- package/package.json +2 -2
- package/vendor/parg/nist.json +1 -1
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
//! The worker entry for the nist flavor (pubid/pubid-ts#232): the same
|
|
2
2
|
//! implementation the node entry runs, over the bundled artifact and
|
|
3
|
-
//! parsanol's browser engine
|
|
4
|
-
//! (pubid/pubid-grammar#164), so the checksum-pinned substrate owns the
|
|
5
|
-
//! engine handle on both legs. No node:* module appears in this graph.
|
|
3
|
+
//! parsanol's browser engine. No node:* module appears in this graph.
|
|
6
4
|
//! The wasm engine loads lazily — the first
|
|
7
5
|
//! `nistWorkerGrammarImplementation()` call pays the ~2.7 MB
|
|
8
6
|
//! fetch/instantiate; the parse calls stay synchronous after the await.
|
|
@@ -15,11 +13,9 @@
|
|
|
15
13
|
//! takes: an R2/CDN URL (the lazy fetch path), a CompiledWasm module
|
|
16
14
|
//! (wrangler `rules = [{ type = "CompiledWasm", ... }]`), or raw bytes.
|
|
17
15
|
import { workerPargRuntime } from "../../parg/worker.js";
|
|
18
|
-
import * as substrate from "./generated/substrate.js";
|
|
19
16
|
import { makeNistGrammarImplementation } from "./implementation.js";
|
|
20
17
|
export async function nistWorkerGrammarImplementation(wasm) {
|
|
21
18
|
const runtime = await workerPargRuntime("nist", wasm);
|
|
22
|
-
substrate.registerRuntime(() => runtime);
|
|
23
19
|
return makeNistGrammarImplementation({
|
|
24
20
|
parseShape(input) {
|
|
25
21
|
return runtime.parseShape(input);
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
//! The worker entry for the oiml flavor (pubid/pubid-ts#232): the same
|
|
2
2
|
//! implementation the node entry runs — over the pure-TS worker engine
|
|
3
|
-
//! (grammar.worker.ts),
|
|
4
|
-
//! pubid-grammar#164), so the node entry and this one share the delta
|
|
5
|
-
//! byte for byte. Synchronous, no `node:*` module, no wasm; its only
|
|
3
|
+
//! (grammar.worker.ts). Synchronous, no `node:*` module, no wasm; its only
|
|
6
4
|
//! dependency is the parg-free iso implementation for the co-published
|
|
7
5
|
//! side.
|
|
8
6
|
//!
|
|
@@ -13,10 +11,8 @@ import { isoWorkerGrammarImplementation } from "../iso/worker.js";
|
|
|
13
11
|
import * as substrate from "./generated/substrate.js";
|
|
14
12
|
import { oimlWorkerRuntime } from "./grammar.worker.js";
|
|
15
13
|
import { makeOimlGrammarImplementation } from "./implementation.js";
|
|
16
|
-
|
|
17
|
-
// worker entry must stay reentrant (no module-scope engine pin in the
|
|
18
|
-
// worker graph, where another flavor may register its own).
|
|
14
|
+
import { lazyRuntime, parseBoundWith } from "../../parg/bound.js";
|
|
19
15
|
export function oimlWorkerGrammarImplementation() {
|
|
20
|
-
|
|
21
|
-
return makeOimlGrammarImplementation((body) => substrate.boundToWire(substrate.
|
|
16
|
+
const runtime = lazyRuntime(oimlWorkerRuntime);
|
|
17
|
+
return makeOimlGrammarImplementation((body) => substrate.boundToWire(parseBoundWith(runtime, substrate.FLAVOR, body)), (flavor) => (flavor === "iso" ? isoWorkerGrammarImplementation() : undefined));
|
|
22
18
|
}
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
//!
|
|
22
22
|
//! The wave-2 substrate flavors (pubid/pubid-grammar#158) — api,
|
|
23
23
|
//! ashrae, asme, astm, cie, csa, gost, iala, like evs before them —
|
|
24
|
-
//!
|
|
24
|
+
//! use the pure-TS worker engine:
|
|
25
25
|
//! node-only modules never enter this graph. Waves 5 batch 1-3
|
|
26
26
|
//! (omg/w3c/tgpp, sae/jcgm/oasis/xsf, then easc/ecma/gb/iana/ietf/ogc)
|
|
27
27
|
//! and the wave 5 final batch (calconnect/iho/plateau) ride the same
|
|
@@ -134,6 +134,7 @@ import { makeW3cGrammarImplementation } from "./w3c/implementation.js";
|
|
|
134
134
|
import * as tgppSubstrate from "./tgpp/generated/substrate.js";
|
|
135
135
|
import { tgppWorkerRuntime } from "./tgpp/grammar.worker.js";
|
|
136
136
|
import { makeTgppGrammarImplementation } from "./tgpp/implementation.js";
|
|
137
|
+
import { lazyRuntime, parseBoundWith } from "../parg/bound.js";
|
|
137
138
|
/** The worker-available flavor implementations, wired to each other:
|
|
138
139
|
* every member's foreign lookups run over this same set (so bsi's
|
|
139
140
|
* adopted ISO routing, cen_cenelec's implicit IEC adoption and gost's
|
|
@@ -146,143 +147,143 @@ export function workerForeignResolver() {
|
|
|
146
147
|
const map = {
|
|
147
148
|
oiml: oimlWorkerGrammarImplementation(),
|
|
148
149
|
xsf: (() => {
|
|
149
|
-
|
|
150
|
-
return makeXsfGrammarImplementation((body) => xsfSubstrate.boundToWire(xsfSubstrate.
|
|
150
|
+
const runtime = lazyRuntime(xsfWorkerRuntime);
|
|
151
|
+
return makeXsfGrammarImplementation((body) => xsfSubstrate.boundToWire(parseBoundWith(runtime, xsfSubstrate.FLAVOR, body)));
|
|
151
152
|
})(),
|
|
152
153
|
doi: doiGrammarImplementation(),
|
|
153
154
|
iana: (() => {
|
|
154
|
-
|
|
155
|
-
return makeIanaGrammarImplementation((body) => ianaSubstrate.boundToWire(ianaSubstrate.
|
|
155
|
+
const runtime = lazyRuntime(ianaWorkerRuntime);
|
|
156
|
+
return makeIanaGrammarImplementation((body) => ianaSubstrate.boundToWire(parseBoundWith(runtime, ianaSubstrate.FLAVOR, body)));
|
|
156
157
|
})(),
|
|
157
158
|
un: unGrammarImplementation(),
|
|
158
159
|
plateau: (() => {
|
|
159
|
-
|
|
160
|
-
return makePlateauGrammarImplementation((body) => plateauSubstrate.boundToWire(plateauSubstrate.
|
|
160
|
+
const runtime = lazyRuntime(plateauWorkerRuntime);
|
|
161
|
+
return makePlateauGrammarImplementation((body) => plateauSubstrate.boundToWire(parseBoundWith(runtime, plateauSubstrate.FLAVOR, body)));
|
|
161
162
|
})(),
|
|
162
163
|
w3c: (() => {
|
|
163
|
-
|
|
164
|
-
return makeW3cGrammarImplementation((body) => w3cSubstrate.boundToWire(w3cSubstrate.
|
|
164
|
+
const runtime = lazyRuntime(w3cWorkerRuntime);
|
|
165
|
+
return makeW3cGrammarImplementation((body) => w3cSubstrate.boundToWire(parseBoundWith(runtime, w3cSubstrate.FLAVOR, body)));
|
|
165
166
|
})(),
|
|
166
167
|
omg: (() => {
|
|
167
|
-
|
|
168
|
-
return makeOmgGrammarImplementation((body) => omgSubstrate.boundToWire(omgSubstrate.
|
|
168
|
+
const runtime = lazyRuntime(omgWorkerRuntime);
|
|
169
|
+
return makeOmgGrammarImplementation((body) => omgSubstrate.boundToWire(parseBoundWith(runtime, omgSubstrate.FLAVOR, body)));
|
|
169
170
|
})(),
|
|
170
171
|
ogc: (() => {
|
|
171
|
-
|
|
172
|
-
return makeOgcGrammarImplementation((body) => ogcSubstrate.boundToWire(ogcSubstrate.
|
|
172
|
+
const runtime = lazyRuntime(ogcWorkerRuntime);
|
|
173
|
+
return makeOgcGrammarImplementation((body) => ogcSubstrate.boundToWire(parseBoundWith(runtime, ogcSubstrate.FLAVOR, body)));
|
|
173
174
|
})(),
|
|
174
175
|
isbn: isbnGrammarImplementation(),
|
|
175
176
|
easc: (() => {
|
|
176
|
-
|
|
177
|
-
return makeEascGrammarImplementation((body) => eascSubstrate.boundToWire(eascSubstrate.
|
|
177
|
+
const runtime = lazyRuntime(eascWorkerRuntime);
|
|
178
|
+
return makeEascGrammarImplementation((body) => eascSubstrate.boundToWire(parseBoundWith(runtime, eascSubstrate.FLAVOR, body)));
|
|
178
179
|
})(),
|
|
179
180
|
ecma: (() => {
|
|
180
|
-
|
|
181
|
-
return makeEcmaGrammarImplementation((body) => ecmaSubstrate.boundToWire(ecmaSubstrate.
|
|
181
|
+
const runtime = lazyRuntime(ecmaWorkerRuntime);
|
|
182
|
+
return makeEcmaGrammarImplementation((body) => ecmaSubstrate.boundToWire(parseBoundWith(runtime, ecmaSubstrate.FLAVOR, body)));
|
|
182
183
|
})(),
|
|
183
184
|
tgpp: (() => {
|
|
184
|
-
|
|
185
|
-
return makeTgppGrammarImplementation((body) => tgppSubstrate.boundToWire(tgppSubstrate.
|
|
185
|
+
const runtime = lazyRuntime(tgppWorkerRuntime);
|
|
186
|
+
return makeTgppGrammarImplementation((body) => tgppSubstrate.boundToWire(parseBoundWith(runtime, tgppSubstrate.FLAVOR, body)));
|
|
186
187
|
})(),
|
|
187
188
|
oasis: (() => {
|
|
188
|
-
|
|
189
|
-
return makeOasisGrammarImplementation((body) => oasisSubstrate.boundToWire(oasisSubstrate.
|
|
189
|
+
const runtime = lazyRuntime(oasisWorkerRuntime);
|
|
190
|
+
return makeOasisGrammarImplementation((body) => oasisSubstrate.boundToWire(parseBoundWith(runtime, oasisSubstrate.FLAVOR, body)));
|
|
190
191
|
})(),
|
|
191
192
|
iho: (() => {
|
|
192
|
-
|
|
193
|
-
return makeIhoGrammarImplementation((body) => ihoSubstrate.boundToWire(ihoSubstrate.
|
|
193
|
+
const runtime = lazyRuntime(ihoWorkerRuntime);
|
|
194
|
+
return makeIhoGrammarImplementation((body) => ihoSubstrate.boundToWire(parseBoundWith(runtime, ihoSubstrate.FLAVOR, body)));
|
|
194
195
|
})(),
|
|
195
196
|
calconnect: (() => {
|
|
196
|
-
|
|
197
|
-
return makeCalconnectGrammarImplementation((body) => calconnectSubstrate.boundToWire(calconnectSubstrate.
|
|
197
|
+
const runtime = lazyRuntime(calconnectWorkerRuntime);
|
|
198
|
+
return makeCalconnectGrammarImplementation((body) => calconnectSubstrate.boundToWire(parseBoundWith(runtime, calconnectSubstrate.FLAVOR, body)));
|
|
198
199
|
})(),
|
|
199
200
|
gb: (() => {
|
|
200
|
-
|
|
201
|
-
return makeGbGrammarImplementation((body) => gbSubstrate.boundToWire(gbSubstrate.
|
|
201
|
+
const runtime = lazyRuntime(gbWorkerRuntime);
|
|
202
|
+
return makeGbGrammarImplementation((body) => gbSubstrate.boundToWire(parseBoundWith(runtime, gbSubstrate.FLAVOR, body)));
|
|
202
203
|
})(),
|
|
203
204
|
jcgm: (() => {
|
|
204
|
-
|
|
205
|
-
return makeJcgmGrammarImplementation((body) => jcgmSubstrate.boundToWire(jcgmSubstrate.
|
|
205
|
+
const runtime = lazyRuntime(jcgmWorkerRuntime);
|
|
206
|
+
return makeJcgmGrammarImplementation((body) => jcgmSubstrate.boundToWire(parseBoundWith(runtime, jcgmSubstrate.FLAVOR, body)));
|
|
206
207
|
})(),
|
|
207
208
|
sae: (() => {
|
|
208
|
-
|
|
209
|
-
return makeSaeGrammarImplementation((body) => saeSubstrate.boundToWire(saeSubstrate.
|
|
209
|
+
const runtime = lazyRuntime(saeWorkerRuntime);
|
|
210
|
+
return makeSaeGrammarImplementation((body) => saeSubstrate.boundToWire(parseBoundWith(runtime, saeSubstrate.FLAVOR, body)));
|
|
210
211
|
})(),
|
|
211
212
|
etsi: (() => {
|
|
212
|
-
|
|
213
|
-
return makeEtsiGrammarImplementation((body) => etsiSubstrate.boundToWire(etsiSubstrate.
|
|
213
|
+
const runtime = lazyRuntime(etsiWorkerRuntime);
|
|
214
|
+
return makeEtsiGrammarImplementation((body) => etsiSubstrate.boundToWire(parseBoundWith(runtime, etsiSubstrate.FLAVOR, body)));
|
|
214
215
|
})(),
|
|
215
216
|
jis: (() => {
|
|
216
|
-
|
|
217
|
-
return makeJisGrammarImplementation((body) => jisSubstrate.boundToWire(jisSubstrate.
|
|
217
|
+
const runtime = lazyRuntime(jisWorkerRuntime);
|
|
218
|
+
return makeJisGrammarImplementation((body) => jisSubstrate.boundToWire(parseBoundWith(runtime, jisSubstrate.FLAVOR, body)));
|
|
218
219
|
})(),
|
|
219
220
|
iec: (() => {
|
|
220
|
-
|
|
221
|
-
return makeIecGrammarImplementation((body) => iecSubstrate.boundToWire(iecSubstrate.
|
|
221
|
+
const runtime = lazyRuntime(iecWorkerRuntime);
|
|
222
|
+
return makeIecGrammarImplementation((body) => iecSubstrate.boundToWire(parseBoundWith(runtime, iecSubstrate.FLAVOR, body)));
|
|
222
223
|
})(),
|
|
223
224
|
cie: (() => {
|
|
224
|
-
|
|
225
|
-
return makeCieGrammarImplementation((body) => cieSubstrate.boundToWire(cieSubstrate.
|
|
225
|
+
const runtime = lazyRuntime(cieWorkerRuntime);
|
|
226
|
+
return makeCieGrammarImplementation((body) => cieSubstrate.boundToWire(parseBoundWith(runtime, cieSubstrate.FLAVOR, body)));
|
|
226
227
|
})(),
|
|
227
228
|
bipm: (() => {
|
|
228
|
-
|
|
229
|
-
return makeBipmGrammarImplementation((body) => bipmSubstrate.boundToWire(bipmSubstrate.
|
|
229
|
+
const runtime = lazyRuntime(bipmWorkerRuntime);
|
|
230
|
+
return makeBipmGrammarImplementation((body) => bipmSubstrate.boundToWire(parseBoundWith(runtime, bipmSubstrate.FLAVOR, body)));
|
|
230
231
|
})(),
|
|
231
232
|
iso: isoWorkerGrammarImplementation(),
|
|
232
233
|
cen_cenelec: (() => {
|
|
233
|
-
|
|
234
|
-
return makeCenCenelecGrammarImplementation((body) => cenSubstrate.boundToWire(cenSubstrate.
|
|
234
|
+
const runtime = lazyRuntime(cenCenelecWorkerRuntime);
|
|
235
|
+
return makeCenCenelecGrammarImplementation((body) => cenSubstrate.boundToWire(parseBoundWith(runtime, cenSubstrate.FLAVOR, body)), resolve);
|
|
235
236
|
})(),
|
|
236
237
|
astm: (() => {
|
|
237
|
-
|
|
238
|
-
return makeAstmGrammarImplementation((body) => astmSubstrate.boundToWire(astmSubstrate.
|
|
238
|
+
const runtime = lazyRuntime(astmWorkerRuntime);
|
|
239
|
+
return makeAstmGrammarImplementation((body) => astmSubstrate.boundToWire(parseBoundWith(runtime, astmSubstrate.FLAVOR, body)));
|
|
239
240
|
})(),
|
|
240
241
|
idf: (() => {
|
|
241
|
-
|
|
242
|
-
return makeIdfGrammarImplementation((body) => idfSubstrate.boundToWire(idfSubstrate.
|
|
242
|
+
const runtime = lazyRuntime(idfWorkerRuntime);
|
|
243
|
+
return makeIdfGrammarImplementation((body) => idfSubstrate.boundToWire(parseBoundWith(runtime, idfSubstrate.FLAVOR, body)));
|
|
243
244
|
})(),
|
|
244
245
|
gost: (() => {
|
|
245
|
-
|
|
246
|
-
return makeGostGrammarImplementation((body) => gostSubstrate.boundToWire(gostSubstrate.
|
|
246
|
+
const runtime = lazyRuntime(gostWorkerRuntime);
|
|
247
|
+
return makeGostGrammarImplementation((body) => gostSubstrate.boundToWire(parseBoundWith(runtime, gostSubstrate.FLAVOR, body)), resolve);
|
|
247
248
|
})(),
|
|
248
249
|
evs: (() => {
|
|
249
250
|
// The substrate with the pure-TS worker engine (node-only modules
|
|
250
251
|
// never enter this graph); the delta is the shared implementation.
|
|
251
|
-
|
|
252
|
-
return makeEvsGrammarImplementation((body) => evsSubstrate.boundToWire(evsSubstrate.
|
|
252
|
+
const runtime = lazyRuntime(evsWorkerRuntime);
|
|
253
|
+
return makeEvsGrammarImplementation((body) => evsSubstrate.boundToWire(parseBoundWith(runtime, evsSubstrate.FLAVOR, body)), resolve);
|
|
253
254
|
})(),
|
|
254
255
|
ashrae: (() => {
|
|
255
|
-
|
|
256
|
-
return makeAshraeGrammarImplementation((body) => ashraeSubstrate.boundToWire(ashraeSubstrate.
|
|
256
|
+
const runtime = lazyRuntime(ashraeWorkerRuntime);
|
|
257
|
+
return makeAshraeGrammarImplementation((body) => ashraeSubstrate.boundToWire(parseBoundWith(runtime, ashraeSubstrate.FLAVOR, body)));
|
|
257
258
|
})(),
|
|
258
259
|
bsi: (() => {
|
|
259
|
-
|
|
260
|
-
return makeBsiGrammarImplementation((body) => bsiSubstrate.boundToWire(bsiSubstrate.
|
|
260
|
+
const runtime = lazyRuntime(bsiWorkerRuntime);
|
|
261
|
+
return makeBsiGrammarImplementation((body) => bsiSubstrate.boundToWire(parseBoundWith(runtime, bsiSubstrate.FLAVOR, body)), resolve);
|
|
261
262
|
})(),
|
|
262
263
|
csa: (() => {
|
|
263
|
-
|
|
264
|
-
return makeCsaGrammarImplementation((body) => csaSubstrate.boundToWire(csaSubstrate.
|
|
264
|
+
const runtime = lazyRuntime(csaWorkerRuntime);
|
|
265
|
+
return makeCsaGrammarImplementation((body) => csaSubstrate.boundToWire(parseBoundWith(runtime, csaSubstrate.FLAVOR, body)), resolve);
|
|
265
266
|
})(),
|
|
266
267
|
asme: (() => {
|
|
267
|
-
|
|
268
|
-
return makeAsmeGrammarImplementation((body) => asmeSubstrate.boundToWire(asmeSubstrate.
|
|
268
|
+
const runtime = lazyRuntime(asmeWorkerRuntime);
|
|
269
|
+
return makeAsmeGrammarImplementation((body) => asmeSubstrate.boundToWire(parseBoundWith(runtime, asmeSubstrate.FLAVOR, body)));
|
|
269
270
|
})(),
|
|
270
271
|
amca: amcaGrammarImplementation(),
|
|
271
272
|
api: (() => {
|
|
272
|
-
|
|
273
|
-
return makeApiGrammarImplementation((body) => apiSubstrate.boundToWire(apiSubstrate.
|
|
273
|
+
const runtime = lazyRuntime(apiWorkerRuntime);
|
|
274
|
+
return makeApiGrammarImplementation((body) => apiSubstrate.boundToWire(parseBoundWith(runtime, apiSubstrate.FLAVOR, body)));
|
|
274
275
|
})(),
|
|
275
276
|
itu: (() => {
|
|
276
|
-
|
|
277
|
-
return makeItuGrammarImplementation((body) => ituSubstrate.boundToWire(ituSubstrate.
|
|
277
|
+
const runtime = lazyRuntime(ituWorkerRuntime);
|
|
278
|
+
return makeItuGrammarImplementation((body) => ituSubstrate.boundToWire(parseBoundWith(runtime, ituSubstrate.FLAVOR, body)));
|
|
278
279
|
})(),
|
|
279
280
|
ietf: (() => {
|
|
280
|
-
|
|
281
|
-
return makeIetfGrammarImplementation((body) => ietfSubstrate.boundToWire(ietfSubstrate.
|
|
281
|
+
const runtime = lazyRuntime(ietfWorkerRuntime);
|
|
282
|
+
return makeIetfGrammarImplementation((body) => ietfSubstrate.boundToWire(parseBoundWith(runtime, ietfSubstrate.FLAVOR, body)));
|
|
282
283
|
})(),
|
|
283
284
|
iala: (() => {
|
|
284
|
-
|
|
285
|
-
return makeIalaGrammarImplementation((body) => ialaSubstrate.boundToWire(ialaSubstrate.
|
|
285
|
+
const runtime = lazyRuntime(ialaWorkerRuntime);
|
|
286
|
+
return makeIalaGrammarImplementation((body) => ialaSubstrate.boundToWire(parseBoundWith(runtime, ialaSubstrate.FLAVOR, body)));
|
|
286
287
|
})(),
|
|
287
288
|
};
|
|
288
289
|
return resolve;
|
package/dist/lane-keys.d.ts
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* the keys from any identifier that a worker flavor entry returns.
|
|
7
7
|
*
|
|
8
8
|
* `norm` uppercases the canonical render and deletes spaces; `undated`
|
|
9
|
-
* strips every colon-year
|
|
9
|
+
* strips every delimited year (a colon-year or a parenthesized date) not
|
|
10
|
+
* followed by a dash, plus every dash-year that the parse marks as a
|
|
11
|
+
* year — never the digits of a document number; `all_parts`
|
|
10
12
|
* additionally strips the parsed part (with its subpart) — structurally,
|
|
11
13
|
* never by guessing: a trailing "-05" that pubid did not parse as a part
|
|
12
14
|
* is a date day, not a part, and stays.
|
|
@@ -16,8 +18,10 @@
|
|
|
16
18
|
export interface LaneKeys {
|
|
17
19
|
/** The dated lane: the normalized canonical (uppercased, de-spaced). */
|
|
18
20
|
dated: string;
|
|
19
|
-
/** The undated lane: every colon-year
|
|
20
|
-
* (base and supplement alike — one rule, no
|
|
21
|
+
/** The undated lane: every colon-year and parenthesized date not
|
|
22
|
+
* followed by a dash is gone (base and supplement alike — one rule, no
|
|
23
|
+
* per-flavor casing), and so is every dash-year that the parse marks
|
|
24
|
+
* as a year. The digits of a document number always stay. */
|
|
21
25
|
undated: string;
|
|
22
26
|
/** The all-parts lane: the parsed part (and subpart) stripped from the
|
|
23
27
|
* undated lane. Structural only — an unparsed trailing "-N" is never a
|
|
@@ -38,9 +42,12 @@ export interface LaneKeySource {
|
|
|
38
42
|
*/
|
|
39
43
|
export declare function norm(canonical: string): string;
|
|
40
44
|
/**
|
|
41
|
-
* The undated lane from a norm key: every
|
|
42
|
-
* dash is stripped — globally, base and supplement years alike.
|
|
43
|
-
* `
|
|
45
|
+
* The undated lane from a norm key: every delimited year not followed by
|
|
46
|
+
* a dash is stripped — globally, base and supplement years alike. A year
|
|
47
|
+
* is delimited when a colon introduces it (`:2015`) or when it is a whole
|
|
48
|
+
* parenthesized date (`(2001)`, `(10/2019)`, the reaffirmation
|
|
49
|
+
* `(R2020)`). No digit continues the year, and a bare digit run is never
|
|
50
|
+
* a year: `ISO19115`, `RFC2045` and `IEC62019` stay whole.
|
|
44
51
|
*/
|
|
45
52
|
export declare function undatedNorm(normKey: string): string;
|
|
46
53
|
/**
|
|
@@ -60,7 +67,8 @@ export declare function allPartsNorm(undated: string, part?: string, subpart?: s
|
|
|
60
67
|
*/
|
|
61
68
|
export declare function structuralPart(components: Record<string, unknown>): string | undefined;
|
|
62
69
|
/** The lane keys for an already-canonical record: norm from the render,
|
|
63
|
-
* undated from the norm, all_parts from the parsed
|
|
70
|
+
* undated from the norm and the parsed year, all_parts from the parsed
|
|
71
|
+
* part and subpart. */
|
|
64
72
|
export declare function laneKeysFrom(canonical: string, components: Record<string, unknown>): LaneKeys;
|
|
65
73
|
/** The lane keys of a parsed identifier: `laneKeysFrom(id.toHuman(),
|
|
66
74
|
* id.toHash())`. Use it on the identifier that a worker flavor entry
|
package/dist/lane-keys.js
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* the keys from any identifier that a worker flavor entry returns.
|
|
7
7
|
*
|
|
8
8
|
* `norm` uppercases the canonical render and deletes spaces; `undated`
|
|
9
|
-
* strips every colon-year
|
|
9
|
+
* strips every delimited year (a colon-year or a parenthesized date) not
|
|
10
|
+
* followed by a dash, plus every dash-year that the parse marks as a
|
|
11
|
+
* year — never the digits of a document number; `all_parts`
|
|
10
12
|
* additionally strips the parsed part (with its subpart) — structurally,
|
|
11
13
|
* never by guessing: a trailing "-05" that pubid did not parse as a part
|
|
12
14
|
* is a date day, not a part, and stays.
|
|
@@ -23,13 +25,43 @@ function escapeRegExp(text) {
|
|
|
23
25
|
export function norm(canonical) {
|
|
24
26
|
return canonical.toUpperCase().replaceAll(" ", "");
|
|
25
27
|
}
|
|
28
|
+
const DELIMITED_YEAR = /(?::(?:19|20)\d{2}|\((?:\d{1,2}\/|R)?(?:19|20)\d{2}\))(?![0-9])(?=[^-]*$)/g;
|
|
29
|
+
const YEAR = /^(?:19|20)\d{2}$/;
|
|
26
30
|
/**
|
|
27
|
-
* The undated lane from a norm key: every
|
|
28
|
-
* dash is stripped — globally, base and supplement years alike.
|
|
29
|
-
* `
|
|
31
|
+
* The undated lane from a norm key: every delimited year not followed by
|
|
32
|
+
* a dash is stripped — globally, base and supplement years alike. A year
|
|
33
|
+
* is delimited when a colon introduces it (`:2015`) or when it is a whole
|
|
34
|
+
* parenthesized date (`(2001)`, `(10/2019)`, the reaffirmation
|
|
35
|
+
* `(R2020)`). No digit continues the year, and a bare digit run is never
|
|
36
|
+
* a year: `ISO19115`, `RFC2045` and `IEC62019` stay whole.
|
|
30
37
|
*/
|
|
31
38
|
export function undatedNorm(normKey) {
|
|
32
|
-
return normKey.replace(
|
|
39
|
+
return normKey.replace(DELIMITED_YEAR, "");
|
|
40
|
+
}
|
|
41
|
+
/** The years that the parse gives: the identifier's own, then each
|
|
42
|
+
* base's (a supplement keeps its base year on the base record). */
|
|
43
|
+
function parsedYears(components) {
|
|
44
|
+
const years = [];
|
|
45
|
+
let record = components;
|
|
46
|
+
while (record !== undefined && record !== null && typeof record === "object" && !Array.isArray(record)) {
|
|
47
|
+
const year = yearText(record["year"]);
|
|
48
|
+
if (year !== undefined && YEAR.test(year))
|
|
49
|
+
years.push(year);
|
|
50
|
+
record = record["base"];
|
|
51
|
+
}
|
|
52
|
+
return years;
|
|
53
|
+
}
|
|
54
|
+
/** Each parsed year's first `-<year>` (the IEEE `802.3-2015/COR.1-2017`
|
|
55
|
+
* form) stripped from the dated key. No digit and no colon continues
|
|
56
|
+
* the match, so `11073-20101` and a part equal to the year
|
|
57
|
+
* (`ISO 8000-2019:2019`) stay. */
|
|
58
|
+
function stripParsedDashYears(dated, years) {
|
|
59
|
+
return years.reduce((key, year) => key.replace(new RegExp(`-${year}(?![0-9:])`), ""), dated);
|
|
60
|
+
}
|
|
61
|
+
function yearText(raw) {
|
|
62
|
+
if (typeof raw === "number")
|
|
63
|
+
return String(raw);
|
|
64
|
+
return facetText(raw);
|
|
33
65
|
}
|
|
34
66
|
function stripTrailingSegment(undated, segment) {
|
|
35
67
|
const digitBoundary = /[0-9]$/.test(segment) ? "(?![0-9])" : "";
|
|
@@ -95,10 +127,11 @@ function structuralSubpart(components) {
|
|
|
95
127
|
return record === undefined ? undefined : facetText(record["subpart"]);
|
|
96
128
|
}
|
|
97
129
|
/** The lane keys for an already-canonical record: norm from the render,
|
|
98
|
-
* undated from the norm, all_parts from the parsed
|
|
130
|
+
* undated from the norm and the parsed year, all_parts from the parsed
|
|
131
|
+
* part and subpart. */
|
|
99
132
|
export function laneKeysFrom(canonical, components) {
|
|
100
133
|
const dated = norm(canonical);
|
|
101
|
-
const undated = undatedNorm(dated);
|
|
134
|
+
const undated = undatedNorm(stripParsedDashYears(dated, parsedYears(components)));
|
|
102
135
|
return {
|
|
103
136
|
dated,
|
|
104
137
|
undated,
|