@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
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** The part of a runtime that parses and binds one input. */
|
|
2
|
+
export interface BindingRuntime {
|
|
3
|
+
parseAndBind(input: string): Record<string, unknown> | null | undefined;
|
|
4
|
+
}
|
|
5
|
+
/** Parse and bind through the given runtime, with the generated
|
|
6
|
+
* substrate's reject contract. */
|
|
7
|
+
export declare function parseBoundWith(runtime: BindingRuntime, flavor: string, input: string): Record<string, unknown>;
|
|
8
|
+
/** A runtime that the load builds on the first parse, not before. */
|
|
9
|
+
export declare function lazyRuntime(load: () => BindingRuntime): BindingRuntime;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//! The substrate reject contract over a runtime the caller owns. The
|
|
2
|
+
//! worker entries and the worker registry parse through their own
|
|
3
|
+
//! runtime instance and never register it in the shared generated
|
|
4
|
+
//! substrate: the substrate caches the first runtime it builds, so a
|
|
5
|
+
//! registered worker engine would answer for the node entry too, or
|
|
6
|
+
//! the reverse (relaton-api-js#188). This module imports nothing, so
|
|
7
|
+
//! the pure-TS worker graphs stay relative-only.
|
|
8
|
+
/** Parse and bind through the given runtime, with the generated
|
|
9
|
+
* substrate's reject contract. */
|
|
10
|
+
export function parseBoundWith(runtime, flavor, input) {
|
|
11
|
+
const bound = runtime.parseAndBind(input);
|
|
12
|
+
if (bound === null || bound === undefined) {
|
|
13
|
+
throw new Error(`${flavor}: cannot parse ${JSON.stringify(input)}`);
|
|
14
|
+
}
|
|
15
|
+
return bound;
|
|
16
|
+
}
|
|
17
|
+
/** A runtime that the load builds on the first parse, not before. */
|
|
18
|
+
export function lazyRuntime(load) {
|
|
19
|
+
let runtime;
|
|
20
|
+
return {
|
|
21
|
+
parseAndBind: (input) => (runtime ??= load()).parseAndBind(input),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { initialize, PargRuntime } from "parsanol/browser";
|
|
2
|
+
export { parseBoundWith, type BindingRuntime } from "./bound.js";
|
|
2
3
|
export type WorkerWasmInput = Parameters<typeof initialize>[0];
|
|
3
4
|
/** Initialize the browser engine once per isolate (the lazy ~2.7 MB wasm).
|
|
4
5
|
* A failed init is not kept, so a later call can retry with other wasm. */
|
|
5
6
|
export declare function initWorkerEngine(wasm?: WorkerWasmInput): Promise<void>;
|
|
6
7
|
/** The runtime over one bundled artifact on the browser engine. */
|
|
7
8
|
export declare function workerArtifactRuntime(artifact: string, wasm?: WorkerWasmInput, entry?: string): Promise<PargRuntime>;
|
|
8
|
-
/** Parse and bind through the given runtime, with the generated
|
|
9
|
-
* substrate's reject contract. The worker entries call this instead of
|
|
10
|
-
* the substrate's `parseBound`, whose runtime is cached on first use:
|
|
11
|
-
* a runtime registered before this entry would otherwise answer for it. */
|
|
12
|
-
export declare function parseBoundWith(runtime: PargRuntime, flavor: string, input: string): Record<string, unknown>;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
//! entry bundles only its own (relaton-api-js#188). The wasm loads
|
|
5
5
|
//! lazily on the first runtime request.
|
|
6
6
|
import { initialize, PargRuntime } from "parsanol/browser";
|
|
7
|
+
export { parseBoundWith } from "./bound.js";
|
|
7
8
|
let enginePromise;
|
|
8
9
|
/** Initialize the browser engine once per isolate (the lazy ~2.7 MB wasm).
|
|
9
10
|
* A failed init is not kept, so a later call can retry with other wasm. */
|
|
@@ -19,14 +20,3 @@ export async function workerArtifactRuntime(artifact, wasm, entry) {
|
|
|
19
20
|
await initWorkerEngine(wasm);
|
|
20
21
|
return new PargRuntime(artifact, entry);
|
|
21
22
|
}
|
|
22
|
-
/** Parse and bind through the given runtime, with the generated
|
|
23
|
-
* substrate's reject contract. The worker entries call this instead of
|
|
24
|
-
* the substrate's `parseBound`, whose runtime is cached on first use:
|
|
25
|
-
* a runtime registered before this entry would otherwise answer for it. */
|
|
26
|
-
export function parseBoundWith(runtime, flavor, input) {
|
|
27
|
-
const bound = runtime.parseAndBind(input);
|
|
28
|
-
if (bound === null || bound === undefined) {
|
|
29
|
-
throw new Error(`${flavor}: cannot parse ${JSON.stringify(input)}`);
|
|
30
|
-
}
|
|
31
|
-
return bound;
|
|
32
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pubid/pubid",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.76",
|
|
4
4
|
"description": "TypeScript PubID identifiers: resolution, normalization and canonical hashes for every identifier in the pubid-testsuite corpus (41 standards bodies), with a conformance runner mirroring the Ruby reference",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"doc:api": "node scripts/api-reference.mjs"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"parsanol": "1.5.
|
|
24
|
+
"parsanol": "1.5.45",
|
|
25
25
|
"yaml": "^2.5.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|