@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
@@ -0,0 +1,3 @@
1
+ import { type WorkerWasmInput } from "../../parg/worker.js";
2
+ import type { FlavorImplementation } from "../../conformance/implementation.js";
3
+ export declare function nistWorkerGrammarImplementation(wasm?: WorkerWasmInput): Promise<FlavorImplementation>;
@@ -0,0 +1,24 @@
1
+ //! The worker entry for the nist flavor (pubid/pubid-ts#232): the same
2
+ //! implementation the node entry runs, over the bundled artifact and
3
+ //! parsanol's browser engine. No node:* module appears in this graph.
4
+ //! The wasm engine loads lazily — the first `nistWorkerGrammarImplementation()`
5
+ //! call pays the ~2.7 MB fetch/instantiate; the parse calls stay
6
+ //! synchronous after the await.
7
+ //!
8
+ //! import { nistWorkerGrammarImplementation } from "@pubid/pubid/dist/flavors/nist/worker.js";
9
+ //! const nist = await nistWorkerGrammarImplementation(wasmOrUrl);
10
+ //! nist.parse("NIST SP 800-53r5");
11
+ //!
12
+ //! The wasm argument is whatever `parsanol/browser`'s `initialize()`
13
+ //! takes: an R2/CDN URL (the lazy fetch path), a CompiledWasm module
14
+ //! (wrangler `rules = [{ type = "CompiledWasm", ... }]`), or raw bytes.
15
+ import { workerPargRuntime } from "../../parg/worker.js";
16
+ import { makeNistGrammarImplementation } from "./implementation.js";
17
+ export async function nistWorkerGrammarImplementation(wasm) {
18
+ const runtime = await workerPargRuntime("nist", wasm);
19
+ return makeNistGrammarImplementation({
20
+ parseShape(input) {
21
+ return runtime.parseShape(input);
22
+ },
23
+ });
24
+ }
@@ -1,9 +1,10 @@
1
1
  import type { FlavorImplementation } from "../../conformance/implementation.js";
2
2
  import { ParseFailed } from "../../grammar/engine.js";
3
+ export type OimlCoPublisherRouter = (flavor: string) => FlavorImplementation | undefined;
3
4
  /**
4
5
  * Grammar-backed OIML on the unified model: the model classes are
5
6
  * BaseIdentifier subclasses, so they satisfy the Identifier adapter
6
7
  * directly (toHash/toHuman/toUrn/fromHash come from the model).
7
8
  */
8
- export declare function oimlGrammarImplementation(): FlavorImplementation;
9
+ export declare function makeOimlGrammarImplementation(router: OimlCoPublisherRouter): FlavorImplementation;
9
10
  export { ParseFailed };
@@ -1,7 +1,6 @@
1
1
  import { ParseFailed, parseGrammar } from "../../grammar/engine.js";
2
2
  import { oimlGrammar } from "./grammar.js";
3
3
  import { buildOimlIdentifier, OimlDualPublished } from "./model.js";
4
- import { grammarImplementation } from "../index.js";
5
4
  // The co-publisher prefix (only ISO confirmed so far; the gem routes via
6
5
  // Pubid.parse's prefix table).
7
6
  function flavorOf(input) {
@@ -12,7 +11,7 @@ function flavorOf(input) {
12
11
  * BaseIdentifier subclasses, so they satisfy the Identifier adapter
13
12
  * directly (toHash/toHuman/toUrn/fromHash come from the model).
14
13
  */
15
- export function oimlGrammarImplementation() {
14
+ export function makeOimlGrammarImplementation(router) {
16
15
  return {
17
16
  // Inverse of OimlUrnGenerator (lib/pubid/oiml/urn_parser.rb): strip the
18
17
  // "urn:oiml:" namespace, rebuild the human head "OIML <TYPE> <locator>",
@@ -45,7 +44,7 @@ export function oimlGrammarImplementation() {
45
44
  if (s.toUpperCase().startsWith("OIML")) {
46
45
  return buildOimlIdentifier(parseGrammar(oimlGrammar, s));
47
46
  }
48
- const impl = grammarImplementation(flavorOf(s));
47
+ const impl = router(flavorOf(s));
49
48
  if (impl === undefined)
50
49
  throw new ParseFailed(`OIML: no flavor for ${s}`, 0);
51
50
  return impl.parse(s);
@@ -0,0 +1,2 @@
1
+ import type { FlavorImplementation } from "../../conformance/implementation.js";
2
+ export declare function oimlGrammarImplementation(): FlavorImplementation;
@@ -0,0 +1,10 @@
1
+ //! The flavor index for oiml (pubid/pubid-ts#232): the co-published
2
+ //! side routes through the grammar barrel, exactly as the barrel's
3
+ //! oiml entry always has. The implementation (./implementation.js) is
4
+ //! environment-agnostic; the worker entry (./worker.js) composes the
5
+ //! same code over the parg-free iso implementation.
6
+ import { grammarImplementation } from "../index.js";
7
+ import { makeOimlGrammarImplementation } from "./implementation.js";
8
+ export function oimlGrammarImplementation() {
9
+ return makeOimlGrammarImplementation((flavor) => grammarImplementation(flavor));
10
+ }
@@ -0,0 +1,2 @@
1
+ import type { FlavorImplementation } from "../../conformance/implementation.js";
2
+ export declare function oimlWorkerGrammarImplementation(): FlavorImplementation;
@@ -0,0 +1,14 @@
1
+ //! The worker entry for the oiml flavor (pubid/pubid-ts#232): the same
2
+ //! implementation the node entry runs. The oiml grammar is the pure-TS
3
+ //! parslet engine (no artifact, no wasm), so this entry is synchronous
4
+ //! and its only dependency is the parg-free iso implementation for the
5
+ //! co-published side. No node:* module appears in this graph.
6
+ //!
7
+ //! import { oimlWorkerGrammarImplementation } from "@pubid/pubid/dist/flavors/oiml/worker.js";
8
+ //! const oiml = oimlWorkerGrammarImplementation();
9
+ //! oiml.parse("OIML R 49-1:2024");
10
+ import { isoGrammarImplementation } from "../iso/index.js";
11
+ import { makeOimlGrammarImplementation } from "./implementation.js";
12
+ export function oimlWorkerGrammarImplementation() {
13
+ return makeOimlGrammarImplementation((flavor) => flavor === "iso" ? isoGrammarImplementation() : undefined);
14
+ }
@@ -0,0 +1,13 @@
1
+ import type { FlavorImplementation } from "../conformance/implementation.js";
2
+ import type { ForeignResolver } from "./foreign-resolver.js";
3
+ /** The worker-available flavor implementations, wired to each other:
4
+ * every member's foreign lookups run over this same set (so bsi's
5
+ * adopted ISO routing, cen_cenelec's implicit IEC adoption and gost's
6
+ * fallback walk all resolve within the subset). */
7
+ export declare function workerForeignResolver(): ForeignResolver;
8
+ /** A resolver over an extended flavor set: the worker subset with the
9
+ * caller's additions merged over it (e.g. the parg-backed flavors via
10
+ * the worker entries #232 shipped — `nistWorkerGrammarImplementation` /
11
+ * `ieeeWorkerGrammarImplementation` — once the caller has awaited
12
+ * them). */
13
+ export declare function workerForeignResolverWith(extra: Record<string, FlavorImplementation>): ForeignResolver;
@@ -0,0 +1,120 @@
1
+ //! The worker-safe grammar registry for the shared-builder flavors
2
+ //! (pubid/pubid-ts#236): a `ForeignResolver` over the flavors whose
3
+ //! implementations carry no `node:*` module — the pure-TS parslet
4
+ //! ports plus the worker entries #232 shipped (oiml rides its worker
5
+ //! entry; iso and iec are parg-free node entries). This is what the
6
+ //! central barrel (`flavors/index.js`) CANNOT be in a worker: it
7
+ //! statically imports the parg-backed flavors (nist, ieee, ansi,
8
+ //! arxiv, doi_pfs, …), whose implementations reach
9
+ //! `parg/runtime.js` — a module scope that walks to a package.json
10
+ //! through `node:fs`.
11
+ //!
12
+ //! The five shared builders (bsi, cen_cenelec, csa, gost, evs) take a
13
+ //! `ForeignResolver` parameter for exactly this: the node barrel wires
14
+ //! the full central registry, the per-flavor worker entries wire this
15
+ //! subset. The gost-style fallback walks then run over the
16
+ //! worker-available flavors only — the honest answer for a worker,
17
+ //! where the parg-backed flavors have no worker implementation yet
18
+ //! (a consumer can inject them via their `*/worker.js` entries with
19
+ //! `workerForeignResolverWith`).
20
+ //!
21
+ //! No `node:*` module and nothing beyond relative imports appears in
22
+ //! this graph — pinned by `test/worker-graph.test.ts`.
23
+ import { oimlWorkerGrammarImplementation } from "./oiml/worker.js";
24
+ import { xsfGrammarImplementation } from "./xsf/index.js";
25
+ import { doiGrammarImplementation } from "./doi/index.js";
26
+ import { ianaGrammarImplementation } from "./iana/index.js";
27
+ import { unGrammarImplementation } from "./un/index.js";
28
+ import { plateauGrammarImplementation } from "./plateau/index.js";
29
+ import { w3cGrammarImplementation } from "./w3c/index.js";
30
+ import { omgGrammarImplementation } from "./omg/index.js";
31
+ import { ogcGrammarImplementation } from "./ogc/index.js";
32
+ import { isbnGrammarImplementation } from "./isbn/index.js";
33
+ import { eascGrammarImplementation } from "./easc/index.js";
34
+ import { ecmaGrammarImplementation } from "./ecma/index.js";
35
+ import { tgppGrammarImplementation } from "./tgpp/index.js";
36
+ import { oasisGrammarImplementation } from "./oasis/index.js";
37
+ import { ihoGrammarImplementation } from "./iho/index.js";
38
+ import { calconnectGrammarImplementation } from "./calconnect/index.js";
39
+ import { gbGrammarImplementation } from "./gb/index.js";
40
+ import { jcgmGrammarImplementation } from "./jcgm/index.js";
41
+ import { etsiGrammarImplementation } from "./etsi/index.js";
42
+ import { jisGrammarImplementation } from "./jis/index.js";
43
+ import { iecGrammarImplementation } from "./iec/index.js";
44
+ import { cieGrammarImplementation } from "./cie/index.js";
45
+ import { bipmGrammarImplementation } from "./bipm/index.js";
46
+ import { isoGrammarImplementation } from "./iso/index.js";
47
+ import { cenCenelecGrammarImplementation } from "./cen_cenelec/index.js";
48
+ import { astmGrammarImplementation } from "./astm/index.js";
49
+ import { idfGrammarImplementation } from "./idf/index.js";
50
+ import { gostGrammarImplementation } from "./gost/index.js";
51
+ import { evsGrammarImplementation } from "./evs/index.js";
52
+ import { ashraeGrammarImplementation } from "./ashrae/index.js";
53
+ import { bsiGrammarImplementation } from "./bsi/index.js";
54
+ import { csaGrammarImplementation } from "./csa/index.js";
55
+ import { asmeGrammarImplementation } from "./asme/index.js";
56
+ import { amcaGrammarImplementation } from "./amca/index.js";
57
+ import { apiGrammarImplementation } from "./api/index.js";
58
+ import { ituGrammarImplementation } from "./itu/index.js";
59
+ import { ietfGrammarImplementation } from "./ietf/index.js";
60
+ import { ialaGrammarImplementation } from "./iala/index.js";
61
+ /** The worker-available flavor implementations, wired to each other:
62
+ * every member's foreign lookups run over this same set (so bsi's
63
+ * adopted ISO routing, cen_cenelec's implicit IEC adoption and gost's
64
+ * fallback walk all resolve within the subset). */
65
+ export function workerForeignResolver() {
66
+ // The self-referencing wire: the resolver closes over the map, the
67
+ // shared builders receive the resolver, resolution happens at parse
68
+ // time.
69
+ const resolve = (flavor) => map[flavor];
70
+ const map = {
71
+ oiml: oimlWorkerGrammarImplementation(),
72
+ xsf: xsfGrammarImplementation(),
73
+ doi: doiGrammarImplementation(),
74
+ iana: ianaGrammarImplementation(),
75
+ un: unGrammarImplementation(),
76
+ plateau: plateauGrammarImplementation(),
77
+ w3c: w3cGrammarImplementation(),
78
+ omg: omgGrammarImplementation(),
79
+ ogc: ogcGrammarImplementation(),
80
+ isbn: isbnGrammarImplementation(),
81
+ easc: eascGrammarImplementation(),
82
+ ecma: ecmaGrammarImplementation(),
83
+ tgpp: tgppGrammarImplementation(),
84
+ oasis: oasisGrammarImplementation(),
85
+ iho: ihoGrammarImplementation(),
86
+ calconnect: calconnectGrammarImplementation(),
87
+ gb: gbGrammarImplementation(),
88
+ jcgm: jcgmGrammarImplementation(),
89
+ etsi: etsiGrammarImplementation(),
90
+ jis: jisGrammarImplementation(),
91
+ iec: iecGrammarImplementation(),
92
+ cie: cieGrammarImplementation(),
93
+ bipm: bipmGrammarImplementation(),
94
+ iso: isoGrammarImplementation(),
95
+ cen_cenelec: cenCenelecGrammarImplementation(resolve),
96
+ astm: astmGrammarImplementation(),
97
+ idf: idfGrammarImplementation(),
98
+ gost: gostGrammarImplementation(resolve),
99
+ evs: evsGrammarImplementation(resolve),
100
+ ashrae: ashraeGrammarImplementation(),
101
+ bsi: bsiGrammarImplementation(resolve),
102
+ csa: csaGrammarImplementation(resolve),
103
+ asme: asmeGrammarImplementation(),
104
+ amca: amcaGrammarImplementation(),
105
+ api: apiGrammarImplementation(),
106
+ itu: ituGrammarImplementation(),
107
+ ietf: ietfGrammarImplementation(),
108
+ iala: ialaGrammarImplementation(),
109
+ };
110
+ return resolve;
111
+ }
112
+ /** A resolver over an extended flavor set: the worker subset with the
113
+ * caller's additions merged over it (e.g. the parg-backed flavors via
114
+ * the worker entries #232 shipped — `nistWorkerGrammarImplementation` /
115
+ * `ieeeWorkerGrammarImplementation` — once the caller has awaited
116
+ * them). */
117
+ export function workerForeignResolverWith(extra) {
118
+ const base = workerForeignResolver();
119
+ return (flavor) => extra[flavor] ?? base(flavor);
120
+ }