@pubid/pubid 0.1.69 → 0.1.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +123 -1
  2. package/dist/flavors/bsi/index.d.ts +3 -2
  3. package/dist/flavors/bsi/index.js +43 -42
  4. package/dist/flavors/bsi/worker.d.ts +3 -0
  5. package/dist/flavors/bsi/worker.js +18 -0
  6. package/dist/flavors/cen_cenelec/index.d.ts +3 -2
  7. package/dist/flavors/cen_cenelec/index.js +14 -8
  8. package/dist/flavors/cen_cenelec/worker.d.ts +3 -0
  9. package/dist/flavors/cen_cenelec/worker.js +17 -0
  10. package/dist/flavors/csa/index.d.ts +2 -1
  11. package/dist/flavors/csa/index.js +27 -28
  12. package/dist/flavors/csa/worker.d.ts +3 -0
  13. package/dist/flavors/csa/worker.js +17 -0
  14. package/dist/flavors/evs/index.d.ts +2 -1
  15. package/dist/flavors/evs/index.js +4 -4
  16. package/dist/flavors/evs/worker.d.ts +3 -0
  17. package/dist/flavors/evs/worker.js +18 -0
  18. package/dist/flavors/foreign-resolver.d.ts +6 -0
  19. package/dist/flavors/foreign-resolver.js +9 -0
  20. package/dist/flavors/gost/index.d.ts +2 -1
  21. package/dist/flavors/gost/index.js +19 -20
  22. package/dist/flavors/gost/worker.d.ts +3 -0
  23. package/dist/flavors/gost/worker.js +21 -0
  24. package/dist/flavors/ieee/artifact_tree.js +1 -1
  25. package/dist/flavors/ieee/implementation.d.ts +16 -0
  26. package/dist/flavors/ieee/implementation.js +2195 -0
  27. package/dist/flavors/ieee/index.js +18 -2181
  28. package/dist/flavors/ieee/worker.d.ts +7 -0
  29. package/dist/flavors/ieee/worker.js +31 -0
  30. package/dist/flavors/index.js +6 -6
  31. package/dist/flavors/nist/implementation.d.ts +5 -0
  32. package/dist/flavors/nist/implementation.js +1326 -0
  33. package/dist/flavors/nist/index.js +14 -1330
  34. package/dist/flavors/nist/worker.d.ts +3 -0
  35. package/dist/flavors/nist/worker.js +24 -0
  36. package/dist/flavors/oiml/implementation.d.ts +2 -1
  37. package/dist/flavors/oiml/implementation.js +2 -3
  38. package/dist/flavors/oiml/index.d.ts +2 -0
  39. package/dist/flavors/oiml/index.js +10 -0
  40. package/dist/flavors/oiml/worker.d.ts +2 -0
  41. package/dist/flavors/oiml/worker.js +14 -0
  42. package/dist/flavors/worker-registry.d.ts +13 -0
  43. package/dist/flavors/worker-registry.js +120 -0
  44. package/dist/parg/artifacts/ieee.d.ts +2 -0
  45. package/dist/parg/artifacts/ieee.js +5 -0
  46. package/dist/parg/artifacts/nist.d.ts +2 -0
  47. package/dist/parg/artifacts/nist.js +5 -0
  48. package/dist/parg/runtime.d.ts +1 -13
  49. package/dist/parg/runtime.js +4 -36
  50. package/dist/parg/shape.d.ts +13 -0
  51. package/dist/parg/shape.js +39 -0
  52. package/dist/parg/worker.d.ts +9 -0
  53. package/dist/parg/worker.js +32 -0
  54. package/dist/register-types.d.ts +7 -1
  55. package/dist/register-types.js +7 -1
  56. package/package.json +7 -2
@@ -1,5 +1,4 @@
1
1
  import { parseGrammar } from "../../grammar/engine.js";
2
- import { grammarImplementation } from "../index.js";
3
2
  import { csaGrammar, normalizeCsa, csaPublisherPrefix } from "./grammar.js";
4
3
  import { BundledClass, CanadianAdoptedClass, CecClass, CombinedClass, CsaAdoptedClass, CsaSingleIdentifier, PackageClass, SeriesClass, StandardClass, } from "./model.js";
5
4
  /**
@@ -23,8 +22,8 @@ function flatten(data) {
23
22
  return Array.isArray(data) ? Object.assign({}, ...data) : data;
24
23
  }
25
24
  const ctor = (klass) => klass;
26
- function tryForeign(flavor, raw) {
27
- const impl = grammarImplementation(flavor);
25
+ function tryForeign(flavor, raw, resolveForeign) {
26
+ const impl = resolveForeign(flavor);
28
27
  if (impl === undefined)
29
28
  return undefined;
30
29
  try {
@@ -186,14 +185,14 @@ function buildCec(dataIn) {
186
185
  return cec;
187
186
  }
188
187
  // --- The builder dispatch ---------------------------------------------------------------
189
- function buildTree(parsed) {
188
+ function buildTree(parsed, resolveForeign) {
190
189
  const data = parsed;
191
190
  if (data["publisher_prefix"] !== undefined
192
191
  && ["CAN/CSA-", "CAN3-"].includes(strv(data["publisher_prefix"]) ?? "")) {
193
192
  return buildCanadianAdopted(data);
194
193
  }
195
194
  if ("adoption_number" in data)
196
- return buildAdoption(data);
195
+ return buildAdoption(data, resolveForeign);
197
196
  if ("series_type" in data)
198
197
  return buildSeries(parsed);
199
198
  if ("cec_part" in data)
@@ -216,16 +215,16 @@ function buildPackage(data) {
216
215
  : {}),
217
216
  });
218
217
  }
219
- function parseAdoptionBase(adoptionOrg, baseStr) {
218
+ function parseAdoptionBase(adoptionOrg, baseStr, resolveForeign) {
220
219
  if (adoptionOrg.startsWith("ISO") || adoptionOrg.startsWith("CEI")) {
221
- return tryForeign("iso", baseStr);
220
+ return tryForeign("iso", baseStr, resolveForeign);
222
221
  }
223
222
  if (adoptionOrg.startsWith("IEC")) {
224
- return tryForeign("iec", baseStr);
223
+ return tryForeign("iec", baseStr, resolveForeign);
225
224
  }
226
- return tryForeign("iso", baseStr) ?? tryForeign("iec", baseStr);
225
+ return tryForeign("iso", baseStr, resolveForeign) ?? tryForeign("iec", baseStr, resolveForeign);
227
226
  }
228
- function buildAdoption(data) {
227
+ function buildAdoption(data, resolveForeign) {
229
228
  let adoptionOrg = strv(data["adoption_org"]) ?? "";
230
229
  const adoptionNumber = strv(data["adoption_number"]) ?? "";
231
230
  const adoptionYear = strv(data["adoption_year"]) ?? "";
@@ -239,14 +238,14 @@ function buildAdoption(data) {
239
238
  const amendmentYear = strv(data["adoption_amendment_year"]) ?? "";
240
239
  const wrappedAmendmentYear = amendmentYear.length === 2 ? `20${amendmentYear}` : amendmentYear;
241
240
  const amendmentStr = `${baseStr}/Amd ${strv(data["adoption_amendment"])}:${wrappedAmendmentYear}`;
242
- base = parseAdoptionBase(adoptionOrg, amendmentStr);
241
+ base = parseAdoptionBase(adoptionOrg, amendmentStr, resolveForeign);
243
242
  }
244
243
  else {
245
244
  let wrappedIdStr = `${adoptionOrg} ${adoptionNumber}${yearSep}${wrappedYear}`;
246
245
  if (adoptionOrg === "CEI/IEC") {
247
246
  wrappedIdStr = wrappedIdStr.replace("CEI/IEC", "IEC");
248
247
  }
249
- base = parseAdoptionBase(adoptionOrg, wrappedIdStr);
248
+ base = parseAdoptionBase(adoptionOrg, wrappedIdStr, resolveForeign);
250
249
  }
251
250
  const self = { base };
252
251
  if (data["reaffirmation_4digit"] !== undefined) {
@@ -378,9 +377,9 @@ function parseTree(input) {
378
377
  return hash;
379
378
  }
380
379
  // --- Identifier.parse (identifier.rb) ------------------------------------------------------
381
- function tryParse(input) {
380
+ function tryParse(input, resolveForeign) {
382
381
  try {
383
- return parseCsa(input);
382
+ return parseCsa(input, resolveForeign);
384
383
  }
385
384
  catch {
386
385
  return undefined;
@@ -415,22 +414,22 @@ function setPublisherPrefix(obj, prefix) {
415
414
  setPublisherPrefix(base, prefix);
416
415
  }
417
416
  }
418
- function parseExternalStandard(input) {
417
+ function parseExternalStandard(input, resolveForeign) {
419
418
  if (/^(ISO\/IEC|ISO|IEC|CEI|CEI\/IEC)\s/.test(input)) {
420
- return tryForeign("iso", input.replace(/^CEI\/IEC/, "IEC"));
419
+ return tryForeign("iso", input.replace(/^CEI\/IEC/, "IEC"), resolveForeign);
421
420
  }
422
421
  // The catalogue also prints the IWA designation without the ISO
423
422
  // keyword ("CAN/CSA-IWA 18:17" beside "CAN/CSA-ISO IWA 18:17"); the
424
423
  // ISO parser wants the ISO/ prefix.
425
424
  if (/^IWA\s/.test(input)) {
426
- return tryForeign("iso", input.replace(/^IWA\s/, "ISO/IWA "));
425
+ return tryForeign("iso", input.replace(/^IWA\s/, "ISO/IWA "), resolveForeign);
427
426
  }
428
427
  if (/^CISPR\s/.test(input)) {
429
- return tryForeign("iec", input);
428
+ return tryForeign("iec", input, resolveForeign);
430
429
  }
431
430
  return undefined;
432
431
  }
433
- function parseCsa(input) {
432
+ function parseCsa(input, resolveForeign) {
434
433
  if (input.startsWith("#")) {
435
434
  throw new Error(`Not a CSA identifier (comment): ${input}`);
436
435
  }
@@ -447,7 +446,7 @@ function parseCsa(input) {
447
446
  let normalized = wrappedInput0.replace(/^CSA-/, "CSA ");
448
447
  normalized = normalized.replaceAll("CAN/CSA-", "CSA ").replaceAll("CAN3-", "CSA ");
449
448
  normalized = normalized.replaceAll(/\s+/g, " ").trim();
450
- const result = buildTree(parseTree(normalized));
449
+ const result = buildTree(parseTree(normalized), resolveForeign);
451
450
  setPublisherPrefix(result, "CAN/CSA-");
452
451
  const rMatch = /\(R(\d{4})\)/.exec(wrappedInput0);
453
452
  if (rMatch !== null) {
@@ -462,7 +461,7 @@ function parseCsa(input) {
462
461
  ? "CSA"
463
462
  : undefined;
464
463
  const normalized = stripped.replace(/^CSA-/, "CSA ");
465
- const base = parseCsa(normalized);
464
+ const base = parseCsa(normalized, resolveForeign);
466
465
  const baseSelf = base;
467
466
  // Only the single-document types and CsaAdopted declare
468
467
  // publisher_prefix; the containers (Combined/Bundled/Package) keep
@@ -489,7 +488,7 @@ function parseCsa(input) {
489
488
  const wrapped0 = input.replace(/^CAN3-/, "CSA ");
490
489
  const hasDashYear = /-\d{2}\b/.test(wrapped0);
491
490
  const { year: reaffirmYear, was4digit, rest: stripped } = extractReaffirmation(wrapped0);
492
- const base = parseCsa(stripped);
491
+ const base = parseCsa(stripped, resolveForeign);
493
492
  const baseSelf = base;
494
493
  if (hasDashYear) {
495
494
  baseSelf["year_format"] = "dash";
@@ -531,7 +530,7 @@ function parseCsa(input) {
531
530
  : year;
532
531
  return `/Amd ${num}${sep}${full}`;
533
532
  });
534
- const base = parseExternalStandard(wrapped);
533
+ const base = parseExternalStandard(wrapped, resolveForeign);
535
534
  if (base === undefined) {
536
535
  throw new Error(`Unparseable adopted standard: ${input}`);
537
536
  }
@@ -592,7 +591,7 @@ function parseCsa(input) {
592
591
  if (/^PACKAGE$/i.test(token))
593
592
  break;
594
593
  const testInput = acc === "" ? token : `${acc} ${token}`;
595
- if (tryParse(testInput) === undefined)
594
+ if (tryParse(testInput, resolveForeign) === undefined)
596
595
  break;
597
596
  acc = testInput;
598
597
  }
@@ -606,7 +605,7 @@ function parseCsa(input) {
606
605
  if (baseInput === undefined || baseInput === "") {
607
606
  throw new Error(`Unparseable package base: ${input}`);
608
607
  }
609
- const base = parseCsa(baseInput);
608
+ const base = parseCsa(baseInput, resolveForeign);
610
609
  return new (ctor(PackageClass))({
611
610
  base,
612
611
  package_keyword: "PACKAGE",
@@ -618,17 +617,17 @@ function parseCsa(input) {
618
617
  }
619
618
  // Plain path with parser-level normalization and prefix injection.
620
619
  const hasDashYear = /-\d{2}\b/.test(input);
621
- const result = buildTree(parseTree(input));
620
+ const result = buildTree(parseTree(input), resolveForeign);
622
621
  const self = result;
623
622
  if (hasDashYear && self["year_format"] === undefined) {
624
623
  self["year_format"] = "dash";
625
624
  }
626
625
  return result;
627
626
  }
628
- export function csaGrammarImplementation() {
627
+ export function csaGrammarImplementation(resolveForeign) {
629
628
  return {
630
629
  parse(input) {
631
- return parseCsa(input);
630
+ return parseCsa(input, resolveForeign);
632
631
  },
633
632
  };
634
633
  }
@@ -0,0 +1,3 @@
1
+ import type { FlavorImplementation } from "../../conformance/implementation.js";
2
+ import type { ForeignResolver } from "../foreign-resolver.js";
3
+ export declare function csaWorkerGrammarImplementation(foreign?: ForeignResolver): FlavorImplementation;
@@ -0,0 +1,17 @@
1
+ //! The worker entry for the csa flavor (pubid/pubid-ts#236): the same
2
+ //! implementation the node entry runs, with the adopted ISO/IEC
3
+ //! resolution wired to the worker-safe registry instead of the node
4
+ //! barrel. No `node:*` module appears in this graph and no wasm loads
5
+ //! — the csa grammar is the pure-TS parslet port, so the entry is
6
+ //! synchronous.
7
+ //!
8
+ //! import { csaWorkerGrammarImplementation } from "@pubid/pubid/dist/flavors/csa/worker.js";
9
+ //! const csa = csaWorkerGrammarImplementation();
10
+ //! csa.parse("CSA ISO/IEC 8824-1:22"); // adopted routing → worker iso/iec
11
+ //!
12
+ //! Pass a resolver to widen or narrow the foreign set.
13
+ import { workerForeignResolver } from "../worker-registry.js";
14
+ import { csaGrammarImplementation } from "./index.js";
15
+ export function csaWorkerGrammarImplementation(foreign) {
16
+ return csaGrammarImplementation(foreign ?? workerForeignResolver());
17
+ }
@@ -1,2 +1,3 @@
1
1
  import type { FlavorImplementation } from "../../conformance/implementation.js";
2
- export declare function evsGrammarImplementation(): FlavorImplementation;
2
+ import type { ForeignResolver } from "../foreign-resolver.js";
3
+ export declare function evsGrammarImplementation(resolveForeign: ForeignResolver): FlavorImplementation;
@@ -10,7 +10,7 @@ import { EstonianStandard, InternationalAdoption, NationalAdoption } from "./mod
10
10
  * is greedy over plain text and would swallow it).
11
11
  */
12
12
  const LANGUAGE_TAIL = / (et-en|et|en)$/;
13
- function buildIdentifier(tree, language) {
13
+ function buildIdentifier(tree, language, resolveForeign) {
14
14
  const d = Array.isArray(tree)
15
15
  ? Object.assign({}, ...tree)
16
16
  : tree;
@@ -28,7 +28,7 @@ function buildIdentifier(tree, language) {
28
28
  ? Object.fromEntries(Object.entries(adoptedData).filter(([k]) => k !== "type"))
29
29
  : adoptedData;
30
30
  id = new NationalAdoption({
31
- base: buildCenIdentifier(cenTree),
31
+ base: buildCenIdentifier(cenTree, resolveForeign),
32
32
  separator, draft_prefix: draft,
33
33
  });
34
34
  }
@@ -79,13 +79,13 @@ function attachSupplement(id, d) {
79
79
  id["cor_year"] = cor["cor_year"] !== undefined ? String(cor["cor_year"]) : undefined;
80
80
  }
81
81
  }
82
- export function evsGrammarImplementation() {
82
+ export function evsGrammarImplementation(resolveForeign) {
83
83
  return {
84
84
  parse(input) {
85
85
  const language = LANGUAGE_TAIL.exec(input)?.[1];
86
86
  const body = language !== undefined ? input.slice(0, input.length - language.length - 1) : input;
87
87
  const tree = parseGrammar(evsGrammar, body);
88
- return buildIdentifier(tree, language);
88
+ return buildIdentifier(tree, language, resolveForeign);
89
89
  },
90
90
  };
91
91
  }
@@ -0,0 +1,3 @@
1
+ import type { FlavorImplementation } from "../../conformance/implementation.js";
2
+ import type { ForeignResolver } from "../foreign-resolver.js";
3
+ export declare function evsWorkerGrammarImplementation(foreign?: ForeignResolver): FlavorImplementation;
@@ -0,0 +1,18 @@
1
+ //! The worker entry for the evs flavor (pubid/pubid-ts#236): the same
2
+ //! implementation the node entry runs — the EVS builder composes the
3
+ //! CEN/CENELEC one for the national adoptions — with the foreign
4
+ //! resolution wired to the worker-safe registry instead of the node
5
+ //! barrel. No `node:*` module appears in this graph and no wasm loads
6
+ //! — the evs grammar is the pure-TS parslet port, so the entry is
7
+ //! synchronous.
8
+ //!
9
+ //! import { evsWorkerGrammarImplementation } from "@pubid/pubid/dist/flavors/evs/worker.js";
10
+ //! const evs = evsWorkerGrammarImplementation();
11
+ //! evs.parse("EVS-EN ISO 14001:2026"); // adoption → worker cen → worker iso
12
+ //!
13
+ //! Pass a resolver to widen or narrow the foreign set.
14
+ import { workerForeignResolver } from "../worker-registry.js";
15
+ import { evsGrammarImplementation } from "./index.js";
16
+ export function evsWorkerGrammarImplementation(foreign) {
17
+ return evsGrammarImplementation(foreign ?? workerForeignResolver());
18
+ }
@@ -0,0 +1,6 @@
1
+ import type { FlavorImplementation } from "../conformance/implementation.js";
2
+ /** Resolve another flavor's grammar implementation, or undefined when
3
+ * the resolver's flavor set does not cover it (a worker resolver over
4
+ * the worker-available subset answers undefined for the parg-backed
5
+ * flavors it does not carry). */
6
+ export type ForeignResolver = (flavor: string) => FlavorImplementation | undefined;
@@ -0,0 +1,9 @@
1
+ //! The foreign-flavor resolution seam for the shared-builder flavors
2
+ //! (pubid/pubid-ts#236): bsi, cen_cenelec, csa, gost and evs route
3
+ //! adopted identifiers to other flavors' implementations. The node
4
+ //! barrel (src/flavors/index.ts) supplies the full central registry;
5
+ //! the worker entries supply the worker-safe subset
6
+ //! (src/flavors/worker-registry.ts). The type is dependency-free so
7
+ //! both sides — and the flavor modules themselves — can name it
8
+ //! without dragging either graph.
9
+ export {};
@@ -1,2 +1,3 @@
1
1
  import type { FlavorImplementation } from "../../conformance/implementation.js";
2
- export declare function gostGrammarImplementation(): FlavorImplementation;
2
+ import type { ForeignResolver } from "../foreign-resolver.js";
3
+ export declare function gostGrammarImplementation(resolveForeign: ForeignResolver): FlavorImplementation;
@@ -1,5 +1,4 @@
1
1
  import { parseGrammar } from "../../grammar/engine.js";
2
- import { grammarImplementation } from "../index.js";
3
2
  import { gostGrammar } from "./grammar.js";
4
3
  import { PREFIX_ROUTES } from "./prefix_routes.js";
5
4
  import { ForeignReference, Harmonized, IdenticalAdoption, InterstateStandard, NationalStandard, } from "./model.js";
@@ -37,10 +36,10 @@ const str = (v) => {
37
36
  function flatten(tree) {
38
37
  return Array.isArray(tree) ? Object.assign({}, ...tree) : tree;
39
38
  }
40
- function buildIdentifier(tree) {
41
- return buildFrom(flatten(tree));
39
+ function buildIdentifier(tree, resolveForeign) {
40
+ return buildFrom(flatten(tree), resolveForeign);
42
41
  }
43
- function buildFrom(d) {
42
+ function buildFrom(d, resolveForeign) {
44
43
  const russian = d["scope_r"] !== undefined;
45
44
  const [copublisher, subtype] = splitPrefix(str(d["prefix_text"]));
46
45
  const [number, year] = splitNumberYear(str(d["raw"]));
@@ -51,20 +50,20 @@ function buildFrom(d) {
51
50
  ...(number !== undefined ? { number } : {}),
52
51
  ...(year !== undefined ? { year } : {}),
53
52
  });
54
- return withForeignAdoption(base, d);
53
+ return withForeignAdoption(base, d, resolveForeign);
55
54
  }
56
- function withForeignAdoption(base, d) {
57
- return wrapHarmonized(wrapIdenticalAdoption(base, d), d);
55
+ function withForeignAdoption(base, d, resolveForeign) {
56
+ return wrapHarmonized(wrapIdenticalAdoption(base, d, resolveForeign), d, resolveForeign);
58
57
  }
59
- function wrapIdenticalAdoption(base, d) {
58
+ function wrapIdenticalAdoption(base, d, resolveForeign) {
60
59
  const adoptedRaw = str(d["adopted_raw"]);
61
60
  if (adoptedRaw === undefined)
62
61
  return base;
63
- const adopted = parseForeign(adoptedRaw);
62
+ const adopted = parseForeign(adoptedRaw, resolveForeign);
64
63
  const klass = IdenticalAdoption;
65
64
  return new klass({ base, adopted });
66
65
  }
67
- function wrapHarmonized(base, d) {
66
+ function wrapHarmonized(base, d, resolveForeign) {
68
67
  const referenceRaw = str(d["adopted_reference_raw"]);
69
68
  if (referenceRaw === undefined)
70
69
  return base;
@@ -72,12 +71,12 @@ function wrapHarmonized(base, d) {
72
71
  .split(",")
73
72
  .map((s) => s.trim())
74
73
  .map(normalizeForeign)
75
- .map(adoptIdentifier);
74
+ .map((raw) => adoptIdentifier(raw, resolveForeign));
76
75
  const klass = Harmonized;
77
76
  return new klass({ base, adoptedIdentifiers: adopted });
78
77
  }
79
- function adoptIdentifier(raw) {
80
- return parseForeign(raw) ?? new ForeignReference({ raw });
78
+ function adoptIdentifier(raw, resolveForeign) {
79
+ return parseForeign(raw, resolveForeign) ?? new ForeignReference({ raw });
81
80
  }
82
81
  function splitPrefix(text) {
83
82
  if (text === undefined)
@@ -130,8 +129,8 @@ function prefixOwner(raw) {
130
129
  const owners = PREFIX_ROUTES[match] ?? [];
131
130
  return owners.length === 1 ? owners[0] : undefined;
132
131
  }
133
- function tryParse(flavor, raw) {
134
- const impl = grammarImplementation(flavor);
132
+ function tryParse(flavor, raw, resolveForeign) {
133
+ const impl = resolveForeign(flavor);
135
134
  if (impl === undefined)
136
135
  return undefined;
137
136
  try {
@@ -141,25 +140,25 @@ function tryParse(flavor, raw) {
141
140
  return undefined;
142
141
  }
143
142
  }
144
- function parseForeign(raw) {
143
+ function parseForeign(raw, resolveForeign) {
145
144
  const owner = prefixOwner(raw);
146
145
  if (owner !== undefined) {
147
- const parsed = tryParse(owner, raw);
146
+ const parsed = tryParse(owner, raw, resolveForeign);
148
147
  if (parsed !== undefined)
149
148
  return parsed;
150
149
  }
151
150
  for (const flavor of FOREIGN_FALLBACK_ORDER) {
152
- const parsed = tryParse(flavor, raw);
151
+ const parsed = tryParse(flavor, raw, resolveForeign);
153
152
  if (parsed !== undefined)
154
153
  return parsed;
155
154
  }
156
155
  return undefined;
157
156
  }
158
- export function gostGrammarImplementation() {
157
+ export function gostGrammarImplementation(resolveForeign) {
159
158
  return {
160
159
  parse(input) {
161
160
  const tree = parseGrammar(gostGrammar, input.trim());
162
- return buildIdentifier(tree);
161
+ return buildIdentifier(tree, resolveForeign);
163
162
  },
164
163
  };
165
164
  }
@@ -0,0 +1,3 @@
1
+ import type { FlavorImplementation } from "../../conformance/implementation.js";
2
+ import type { ForeignResolver } from "../foreign-resolver.js";
3
+ export declare function gostWorkerGrammarImplementation(foreign?: ForeignResolver): FlavorImplementation;
@@ -0,0 +1,21 @@
1
+ //! The worker entry for the gost flavor (pubid/pubid-ts#236): the same
2
+ //! implementation the node entry runs, with the adopted-identifier
3
+ //! resolution wired to the worker-safe registry instead of the node
4
+ //! barrel. No `node:*` module appears in this graph and no wasm loads
5
+ //! — the gost grammar is the pure-TS parslet port, so the entry is
6
+ //! synchronous.
7
+ //!
8
+ //! import { gostWorkerGrammarImplementation } from "@pubid/pubid/dist/flavors/gost/worker.js";
9
+ //! const gost = gostWorkerGrammarImplementation();
10
+ //! gost.parse("GOST 31425.2-2025/ISO 9902-2:2001"); // adoption → worker iso
11
+ //!
12
+ //! The FOREIGN_FALLBACK_ORDER walk runs over the worker-available
13
+ //! flavors only — the honest answer in a worker, where the parg-backed
14
+ //! flavors have no worker implementation. Widen it by merging the parg
15
+ //! worker entries in: `workerForeignResolverWith({ ieee: await
16
+ //! ieeeWorkerGrammarImplementation(wasm) })` passed as the resolver.
17
+ import { workerForeignResolver } from "../worker-registry.js";
18
+ import { gostGrammarImplementation } from "./index.js";
19
+ export function gostWorkerGrammarImplementation(foreign) {
20
+ return gostGrammarImplementation(foreign ?? workerForeignResolver());
21
+ }
@@ -1,4 +1,4 @@
1
- import { normalizeShape } from "../../parg/runtime.js";
1
+ import { normalizeShape } from "../../parg/shape.js";
2
2
  /**
3
3
  * The baked PARG artifact's parse shape → the builder tree. The
4
4
  * artifact (the gem's own runtime grammar) differs from the hand
@@ -0,0 +1,16 @@
1
+ import type { Tree } from "../../grammar/engine.js";
2
+ import type { FlavorImplementation, Identifier } from "../../conformance/implementation.js";
3
+ export interface IeeeParseDeps {
4
+ /** The artifact engine's bound-parse (the parseAndBind contract). */
5
+ parseAndBind(input: string): unknown;
6
+ /** The co-published side resolver ("iec", "ansi"); undefined when
7
+ * the flavor is unavailable in the current environment. */
8
+ coPublished(flavor: string): FlavorImplementation | undefined;
9
+ }
10
+ export interface IeeeParseEngine {
11
+ parseSource(input: string): Tree;
12
+ coPublished(flavor: string): FlavorImplementation | undefined;
13
+ }
14
+ export declare function makeIeeeParseEngine(deps: IeeeParseDeps): IeeeParseEngine;
15
+ export declare function ieeeParseImpl(env: IeeeParseEngine, input: string): Identifier;
16
+ export declare function makeIeeeGrammarImplementation(env: IeeeParseEngine): FlavorImplementation;