@imferno/wasm 0.1.3

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.
@@ -0,0 +1,22 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const compareDelivery: (a: any, b: any) => [number, number, number];
5
+ export const extractSourceAsset: (a: number, b: number) => [number, number, number];
6
+ export const getVersion: () => [number, number];
7
+ export const init: () => void;
8
+ export const inspectPackage: (a: any) => [number, number, number];
9
+ export const parseAssetmapTyped: (a: number, b: number) => [number, number, number];
10
+ export const parseCplTyped: (a: number, b: number) => [number, number, number];
11
+ export const parsePklTyped: (a: number, b: number) => [number, number, number];
12
+ export const parseVolindexTyped: (a: number, b: number) => [number, number, number];
13
+ export const validateCplWithSpecSelection: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
14
+ export const validatePackage: (a: any, b: any) => [number, number, number];
15
+ export const __wbindgen_malloc: (a: number, b: number) => number;
16
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
17
+ export const __wbindgen_exn_store: (a: number) => void;
18
+ export const __externref_table_alloc: () => number;
19
+ export const __wbindgen_externrefs: WebAssembly.Table;
20
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
21
+ export const __externref_table_dealloc: (a: number) => void;
22
+ export const __wbindgen_start: () => void;
package/index.d.ts ADDED
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Auto-initializing IMF Parser TypeScript Definitions
3
+ *
4
+ * All functions automatically handle WASM initialization.
5
+ */
6
+
7
+ /** Parse ASSETMAP.xml content */
8
+ export function parseAssetmapTyped(xmlContent: string): Promise<any>;
9
+
10
+ /** Parse CPL XML content */
11
+ export function parseCplTyped(xmlContent: string): Promise<any>;
12
+
13
+ /** Parse PKL XML content */
14
+ export function parsePklTyped(xmlContent: string): Promise<any>;
15
+
16
+ /** Parse VOLINDEX.xml content */
17
+ export function parseVolindexTyped(xmlContent: string): Promise<any>;
18
+
19
+ /**
20
+ * Validate a CPL with configurable spec selection.
21
+ * @param cplXml CPL XML content
22
+ * @param coreSpec "auto" | "v2013" | "v2016" | "v2020"
23
+ * @param app2eSpec "auto" | "none" | "v2020" | "v2021" | "v2023"
24
+ * @returns ValidationReport
25
+ */
26
+ export function validateCplWithSpecSelection(
27
+ cplXml: string,
28
+ coreSpec?: string,
29
+ app2eSpec?: string,
30
+ ): Promise<any>;
31
+
32
+ /**
33
+ * Validate a full IMF package from an in-memory map of filename to XML content.
34
+ * @param files Object mapping filenames to XML string content
35
+ * @param rules Optional ESLint-style rules configuration
36
+ * @returns ValidationReport
37
+ */
38
+ export function validatePackage(
39
+ files: Record<string, string>,
40
+ rules?: any,
41
+ ): Promise<any>;
42
+
43
+ /**
44
+ * Inspect an IMF package and return structural metadata.
45
+ * @param files Object mapping filenames to XML string content
46
+ * @returns { cplCount, scmCount, declaredSidecars, unreferencedAssets }
47
+ */
48
+ export function inspectPackage(
49
+ files: Record<string, string>,
50
+ ): Promise<any>;
51
+
52
+ /** Extract a SourceAsset from CPL XML */
53
+ export function extractSourceAsset(cplXml: string): Promise<any>;
54
+
55
+ /** Compare a SourceAsset against a delivery spec */
56
+ export function compareDelivery(sourceAssetJson: any, deliverySpecJson: any): Promise<any>;
57
+
58
+ /** Get the library version */
59
+ export function getVersion(): Promise<string>;
60
+
61
+ /** Manual WASM initialization (for advanced use) */
62
+ export function init(wasmBuffer?: ArrayBuffer): Promise<void>;
63
+
64
+ /** Raw WASM bindings (for advanced use) */
65
+ export declare const wasm: typeof import('./imferno_wasm.js');
package/index.js ADDED
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Auto-initializing IMF Parser
3
+ *
4
+ * Automatically handles WASM initialization so developers
5
+ * don't have to deal with init() functions or WASM buffers.
6
+ */
7
+ import wasmInit, * as wasm from './imferno_wasm.js';
8
+ import { readFileSync } from 'fs';
9
+ import { fileURLToPath } from 'url';
10
+ import path from 'path';
11
+
12
+ let initPromise = null;
13
+
14
+ function ensureInit() {
15
+ if (!initPromise) {
16
+ if (typeof process !== 'undefined' && process.versions && process.versions.node) {
17
+ try {
18
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
19
+ const wasmPath = path.join(__dirname, 'imferno_wasm_bg.wasm');
20
+ const wasmBuffer = readFileSync(wasmPath);
21
+ initPromise = wasmInit(wasmBuffer);
22
+ } catch (error) {
23
+ console.error('Failed to load WASM in Node.js:', error);
24
+ throw error;
25
+ }
26
+ } else {
27
+ initPromise = wasmInit();
28
+ }
29
+ }
30
+ return initPromise;
31
+ }
32
+
33
+ // Parsing
34
+ export async function parseAssetmapTyped(xmlContent) {
35
+ await ensureInit();
36
+ return wasm.parseAssetmapTyped(xmlContent);
37
+ }
38
+
39
+ export async function parseCplTyped(xmlContent) {
40
+ await ensureInit();
41
+ return wasm.parseCplTyped(xmlContent);
42
+ }
43
+
44
+ export async function parsePklTyped(xmlContent) {
45
+ await ensureInit();
46
+ return wasm.parsePklTyped(xmlContent);
47
+ }
48
+
49
+ export async function parseVolindexTyped(xmlContent) {
50
+ await ensureInit();
51
+ return wasm.parseVolindexTyped(xmlContent);
52
+ }
53
+
54
+ // Validation
55
+ export async function validateCplWithSpecSelection(cplXml, coreSpec, app2eSpec) {
56
+ await ensureInit();
57
+ return wasm.validateCplWithSpecSelection(cplXml, coreSpec, app2eSpec);
58
+ }
59
+
60
+ export async function validatePackage(files, rules) {
61
+ await ensureInit();
62
+ return wasm.validatePackage(files, rules);
63
+ }
64
+
65
+ // Inspection
66
+ export async function inspectPackage(files) {
67
+ await ensureInit();
68
+ return wasm.inspectPackage(files);
69
+ }
70
+
71
+ // Source asset / delivery
72
+ export async function extractSourceAsset(cplXml) {
73
+ await ensureInit();
74
+ return wasm.extractSourceAsset(cplXml);
75
+ }
76
+
77
+ export async function compareDelivery(sourceAssetJson, deliverySpecJson) {
78
+ await ensureInit();
79
+ return wasm.compareDelivery(sourceAssetJson, deliverySpecJson);
80
+ }
81
+
82
+ // Utility
83
+ export async function getVersion() {
84
+ await ensureInit();
85
+ return wasm.getVersion();
86
+ }
87
+
88
+ // For users who want manual control
89
+ export { wasmInit as init };
90
+ export { wasm };
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@imferno/wasm",
3
+ "version": "0.1.3",
4
+ "description": "Fast, type-safe SMPTE ST 2067 IMF parser for JavaScript and TypeScript",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "type": "module",
8
+ "files": [
9
+ "imferno_wasm.js",
10
+ "imferno_wasm.d.ts",
11
+ "imferno_wasm_bg.wasm",
12
+ "imferno_wasm_bg.wasm.d.ts",
13
+ "index.js",
14
+ "index.d.ts",
15
+ "README.md",
16
+ "LICENSE"
17
+ ],
18
+ "scripts": {
19
+ "build": "./build.sh",
20
+ "test": "vitest run",
21
+ "prepublishOnly": "npm run build && npm test"
22
+ },
23
+ "keywords": [
24
+ "imf",
25
+ "imferno",
26
+ "smpte",
27
+ "st2067",
28
+ "media",
29
+ "cinema",
30
+ "wasm",
31
+ "webassembly",
32
+ "typescript",
33
+ "composition-playlist",
34
+ "asset-map",
35
+ "parsing"
36
+ ],
37
+ "author": {
38
+ "name": "JP Wesselink",
39
+ "email": "jp@wesselink.dev"
40
+ },
41
+ "license": "MIT",
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "https://github.com/jpwesselink/imferno.git",
45
+ "directory": "crates/imferno-wasm"
46
+ },
47
+ "bugs": {
48
+ "url": "https://github.com/jpwesselink/imferno/issues"
49
+ },
50
+ "homepage": "https://github.com/jpwesselink/imferno",
51
+ "engines": {
52
+ "node": ">=16.0.0"
53
+ },
54
+ "publishConfig": {
55
+ "access": "public"
56
+ },
57
+ "devDependencies": {
58
+ "vitest": "^4.0.18"
59
+ }
60
+ }