@imferno/wasm 3.0.2-beta.1b73397 → 3.0.2-beta.2427eb9
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 +16 -10
- package/codes.d.ts +10 -0
- package/codes.js +10 -0
- package/imferno_wasm.d.ts +2 -479
- package/imferno_wasm.js +2 -7
- package/imferno_wasm_bg.wasm +0 -0
- package/index.d.ts +41 -48
- package/index.js +11 -4
- package/package.json +4 -1
- package/types.d.ts +1337 -0
package/index.d.ts
CHANGED
|
@@ -1,68 +1,61 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Auto-initializing
|
|
2
|
+
* Auto-initializing imferno WASM bindings.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Every function initialises the WASM module on first use, so all of them
|
|
5
|
+
* return Promises. Value types (`ValidationResult`, `Imferno`, `ImfReport`,
|
|
6
|
+
* `ValidateOptions`, ...) live in ./types.d.ts, generated from the Rust types
|
|
7
|
+
* by `cargo xtask generate-types-ts` and shared verbatim with @imferno/node.
|
|
5
8
|
*/
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
export function parseAssetmapTyped(xmlContent: string): Promise<any>;
|
|
10
|
+
import type { ImfReport, Imferno, ValidateOptions, ValidationResult } from './types.js';
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
export function parseCplTyped(xmlContent: string): Promise<any>;
|
|
12
|
+
export * from './types.js';
|
|
12
13
|
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
/** ESLint-style rules configuration */
|
|
26
|
-
rules?: Record<string, string>;
|
|
27
|
-
}
|
|
14
|
+
/**
|
|
15
|
+
* Parse and validate an IMF package. This is the recommended entry point.
|
|
16
|
+
*
|
|
17
|
+
* Parse failures are reported as findings in `validation`, not thrown.
|
|
18
|
+
* @param files Object mapping filenames to XML string content
|
|
19
|
+
* @param options Optional validation options (spec selection, rules)
|
|
20
|
+
* @returns `{ package, validation }` — the full parsed package and all findings.
|
|
21
|
+
*/
|
|
22
|
+
export function validate(
|
|
23
|
+
files: Record<string, string>,
|
|
24
|
+
options?: ValidateOptions | null,
|
|
25
|
+
): Promise<ValidationResult>;
|
|
28
26
|
|
|
29
|
-
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
/** Parsed AssetMap (null if parsing failed) */
|
|
36
|
-
assetMap: any | null;
|
|
37
|
-
/** Parsed Packing Lists */
|
|
38
|
-
packingLists: any[];
|
|
39
|
-
/** Parsed Volume Index (null if parsing failed) */
|
|
40
|
-
volumeIndex: any | null;
|
|
41
|
-
/** Assets in the AssetMap with no CPL or SCM reference */
|
|
42
|
-
unreferencedAssets: { id: string; path: string }[];
|
|
43
|
-
/** Sidecar assets declared in SCMs */
|
|
44
|
-
declaredSidecars: { id: string; cplIds: string[] }[];
|
|
45
|
-
}
|
|
27
|
+
/**
|
|
28
|
+
* Parse an IMF package without validating it.
|
|
29
|
+
* @param files Object mapping filenames to XML string content
|
|
30
|
+
* @returns The full parsed package. Rejects if the package cannot be parsed.
|
|
31
|
+
*/
|
|
32
|
+
export function parsePackage(files: Record<string, string>): Promise<Imferno>;
|
|
46
33
|
|
|
47
34
|
/**
|
|
48
|
-
*
|
|
35
|
+
* Legacy: validate and return the lossy `ImfReport` summary. Prefer `validate`.
|
|
49
36
|
* @param files Object mapping filenames to XML string content
|
|
50
37
|
* @param options Optional validation options (spec selection, rules)
|
|
51
|
-
* @returns
|
|
38
|
+
* @returns Rejects if the package cannot be parsed.
|
|
52
39
|
*/
|
|
53
|
-
export function
|
|
40
|
+
export function buildReport(
|
|
54
41
|
files: Record<string, string>,
|
|
55
|
-
options?: ValidateOptions,
|
|
56
|
-
): Promise<
|
|
42
|
+
options?: ValidateOptions | null,
|
|
43
|
+
): Promise<ImfReport>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Pretty-print a validation result as a human-readable string.
|
|
47
|
+
* @param report The object `validate()` returned, or (legacy) `buildReport()`'s.
|
|
48
|
+
*/
|
|
49
|
+
export function formatReport(report: ValidationResult | ImfReport): Promise<string>;
|
|
57
50
|
|
|
58
51
|
/** Get the library version */
|
|
59
52
|
export function getVersion(): Promise<string>;
|
|
60
53
|
|
|
61
|
-
/**
|
|
62
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Initialise the WASM module explicitly. Optional: every function initialises
|
|
56
|
+
* on first use. Pass the `.wasm` bytes to avoid fetching them.
|
|
57
|
+
*/
|
|
58
|
+
export function init(wasmBytes?: ArrayBuffer | ArrayBufferView): Promise<void>;
|
|
63
59
|
|
|
64
60
|
/** Typed validation code constants for use in rules config */
|
|
65
61
|
export { codes } from './codes.js';
|
|
66
|
-
|
|
67
|
-
/** Raw WASM bindings (for advanced use) */
|
|
68
|
-
export declare const wasm: typeof import('./imferno_wasm.js');
|
package/index.js
CHANGED
|
@@ -18,7 +18,7 @@ function ensureInit() {
|
|
|
18
18
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
19
19
|
const wasmPath = path.join(__dirname, 'imferno_wasm_bg.wasm');
|
|
20
20
|
const wasmBuffer = readFileSync(wasmPath);
|
|
21
|
-
initPromise = wasmInit(wasmBuffer);
|
|
21
|
+
initPromise = wasmInit({ module_or_path: wasmBuffer });
|
|
22
22
|
} catch (error) {
|
|
23
23
|
console.error('Failed to load WASM in Node.js:', error);
|
|
24
24
|
throw error;
|
|
@@ -63,6 +63,13 @@ export async function getVersion() {
|
|
|
63
63
|
// Typed validation codes
|
|
64
64
|
export { codes } from './codes.js';
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Initialise the WASM module explicitly (optional — every function does it on
|
|
68
|
+
* first use). Pass the `.wasm` bytes or a compiled module to skip fetching.
|
|
69
|
+
*/
|
|
70
|
+
export function init(wasmBytes) {
|
|
71
|
+
if (!initPromise) {
|
|
72
|
+
initPromise = wasmInit(wasmBytes === undefined ? undefined : { module_or_path: wasmBytes });
|
|
73
|
+
}
|
|
74
|
+
return initPromise.then(() => undefined);
|
|
75
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imferno/wasm",
|
|
3
|
-
"version": "3.0.2-beta.
|
|
3
|
+
"version": "3.0.2-beta.2427eb9",
|
|
4
4
|
"description": "Fast, type-safe SMPTE ST 2067 IMF parser for JavaScript and TypeScript",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"codes.d.ts",
|
|
15
15
|
"index.js",
|
|
16
16
|
"index.d.ts",
|
|
17
|
+
"types.d.ts",
|
|
17
18
|
"README.md",
|
|
18
19
|
"LICENSE"
|
|
19
20
|
],
|
|
@@ -58,6 +59,8 @@
|
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
61
|
"ajv": "^8.18.0",
|
|
62
|
+
"ts-json-schema-generator": "2.9.0",
|
|
63
|
+
"typescript": "^5.9.3",
|
|
61
64
|
"vitest": "^4.0.18"
|
|
62
65
|
}
|
|
63
66
|
}
|