@pubid/pubid 0.1.69 → 0.1.70
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 +75 -1
- package/dist/flavors/ieee/artifact_tree.js +1 -1
- package/dist/flavors/ieee/implementation.d.ts +16 -0
- package/dist/flavors/ieee/implementation.js +2195 -0
- package/dist/flavors/ieee/index.js +18 -2181
- package/dist/flavors/ieee/worker.d.ts +7 -0
- package/dist/flavors/ieee/worker.js +31 -0
- package/dist/flavors/index.js +1 -1
- package/dist/flavors/nist/implementation.d.ts +5 -0
- package/dist/flavors/nist/implementation.js +1326 -0
- package/dist/flavors/nist/index.js +14 -1330
- package/dist/flavors/nist/worker.d.ts +3 -0
- package/dist/flavors/nist/worker.js +24 -0
- package/dist/flavors/oiml/implementation.d.ts +2 -1
- package/dist/flavors/oiml/implementation.js +2 -3
- package/dist/flavors/oiml/index.d.ts +2 -0
- package/dist/flavors/oiml/index.js +10 -0
- package/dist/flavors/oiml/worker.d.ts +2 -0
- package/dist/flavors/oiml/worker.js +14 -0
- package/dist/parg/artifacts/ieee.d.ts +2 -0
- package/dist/parg/artifacts/ieee.js +5 -0
- package/dist/parg/artifacts/nist.d.ts +2 -0
- package/dist/parg/artifacts/nist.js +5 -0
- package/dist/parg/runtime.d.ts +1 -13
- package/dist/parg/runtime.js +4 -36
- package/dist/parg/shape.d.ts +13 -0
- package/dist/parg/shape.js +39 -0
- package/dist/parg/worker.d.ts +9 -0
- package/dist/parg/worker.js +32 -0
- package/dist/register-types.d.ts +7 -1
- package/dist/register-types.js +7 -1
- package/package.json +7 -2
|
@@ -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
|
|
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
|
|
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 =
|
|
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,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,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
|
+
}
|