@imferno/wasm 0.1.3 → 1.1.0

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 CHANGED
@@ -1,13 +1,17 @@
1
- # imferno-wasm
1
+ # @imferno/wasm
2
2
 
3
3
  SMPTE ST 2067 IMF parser and validator for JavaScript and TypeScript, powered by WebAssembly.
4
4
 
5
+ Part of the [`imferno`](https://github.com/jpwesselink/imferno) ecosystem. See also [`@imferno/schema`](https://www.npmjs.com/package/@imferno/schema) for JSON Schema validation of imferno output.
6
+
5
7
  ## Install
6
8
 
7
9
  ```bash
8
- npm install imferno-wasm
10
+ npm install @imferno/wasm
9
11
  ```
10
12
 
13
+ > **Note:** For Node.js with filesystem access (path-based validation, hash verification), use [`@imferno/node`](https://www.npmjs.com/package/@imferno/node) instead.
14
+
11
15
  The package ships a prebuilt `.wasm` binary — no build step required.
12
16
 
13
17
  ## Usage
@@ -18,13 +22,9 @@ import {
18
22
  parseCplTyped,
19
23
  parsePklTyped,
20
24
  parseVolindexTyped,
21
- validatePackage,
22
- validateCplWithSpecSelection,
23
- inspectPackage,
24
- extractSourceAsset,
25
- compareDelivery,
25
+ validate,
26
26
  getVersion,
27
- } from 'imferno-wasm';
27
+ } from '@imferno/wasm';
28
28
 
29
29
  // Parse individual XML files
30
30
  const assetMap = await parseAssetmapTyped(assetmapXml);
@@ -33,49 +33,39 @@ const pkl = await parsePklTyped(pklXml);
33
33
  const volindex = await parseVolindexTyped(volindexXml);
34
34
 
35
35
  // Validate a full IMF package (pass all XML files as a map)
36
- const report = await validatePackage({
37
- 'ASSETMAP.xml': assetmapXml,
38
- 'PKL_abc.xml': pklXml,
39
- 'CPL_def.xml': cplXml,
40
- });
41
- console.log(report.errors);
42
- console.log(report.warnings);
43
-
44
- // Validate a single CPL with spec selection
45
- const cplReport = await validateCplWithSpecSelection(cplXml, 'v2020', 'v2023');
46
-
47
- // Inspect package structure
48
- const info = await inspectPackage({
36
+ const result = await validate({
49
37
  'ASSETMAP.xml': assetmapXml,
50
38
  'PKL_abc.xml': pklXml,
51
39
  'CPL_def.xml': cplXml,
52
40
  });
53
- console.log(info.cplCount);
54
- console.log(info.unreferencedAssets);
55
-
56
- // Extract source asset from a CPL
57
- const sourceAsset = await extractSourceAsset(cplXml);
58
-
59
- // Compare against a delivery spec
60
- const comparison = await compareDelivery(sourceAsset, deliverySpec);
41
+ console.log(result.report.errors);
42
+ console.log(result.report.warnings);
43
+ console.log(result.cpls);
44
+ console.log(result.unreferencedAssets);
45
+
46
+ // Validate with spec selection and custom rules
47
+ const result2 = await validate(
48
+ {
49
+ 'ASSETMAP.xml': assetmapXml,
50
+ 'PKL_abc.xml': pklXml,
51
+ 'CPL_def.xml': cplXml,
52
+ },
53
+ { coreSpec: 'v2020', app2eSpec: 'v2023' },
54
+ );
61
55
  ```
62
56
 
63
57
  WASM initialization is handled automatically on first call.
64
58
 
65
59
  ## API
66
60
 
67
- | Function | Input | Output |
68
- |---|---|---|
69
- | `parseAssetmapTyped(xml)` | ASSETMAP XML | `AssetMap` |
70
- | `parseCplTyped(xml)` | CPL XML | `CompositionPlaylist` |
71
- | `parsePklTyped(xml)` | PKL XML | `PackingList` |
72
- | `parseVolindexTyped(xml)` | VOLINDEX XML | `VolumeIndex` |
73
- | `validatePackage(files, rules?)` | `{ filename: xml }` map | `ValidationReport` |
74
- | `validateCplWithSpecSelection(xml, core?, app?)` | CPL XML + spec pins | `ValidationReport` |
75
- | `inspectPackage(files)` | `{ filename: xml }` map | package metadata |
76
- | `extractSourceAsset(xml)` | CPL XML | `SourceAsset` |
77
- | `compareDelivery(asset, spec)` | `SourceAsset` + `DeliveryRequest` | `DeliveryComparison` |
78
- | `getVersion()` | — | version string |
61
+ | Function | Description |
62
+ |----------|-------------|
63
+ | `validate(files, options?)` | Validate a full IMF package, returns report + parsed data |
64
+ | `parseCplTyped(xml)` | Parse CPL XML |
65
+ | `parseAssetmapTyped(xml)` | Parse ASSETMAP.xml |
66
+ | `parsePklTyped(xml)` | Parse PKL XML |
67
+ | `parseVolindexTyped(xml)` | Parse VOLINDEX.xml |
68
+ | `getVersion()` | Get library version |
79
69
 
80
70
  ### Spec selection values
81
71
 
package/imferno_wasm.d.ts CHANGED
@@ -471,16 +471,6 @@ export type TransferCharacteristic = "Linear" | "Bt709" | "Smpte240M" | "XvYcc70
471
471
  export type VideoCodec = "Jpeg2000" | "Jpeg2000Imf2k" | "Jpeg2000Imf4k" | "Jpeg2000Broadcast" | "Jpeg2000Ht" | "Vc5" | "Mpeg2" | "H264" | "H265" | "ProRes" | "Av1" | { Unknown: string };
472
472
 
473
473
 
474
- /**
475
- * Compare a SourceAsset against a delivery spec
476
- */
477
- export function compareDelivery(sourceAssetJson: any, deliverySpecJson: any): any;
478
-
479
- /**
480
- * Extract a SourceAsset from CPL XML
481
- */
482
- export function extractSourceAsset(cplXml: string): any;
483
-
484
474
  /**
485
475
  * Get library version
486
476
  */
@@ -491,15 +481,6 @@ export function getVersion(): string;
491
481
  */
492
482
  export function init(): void;
493
483
 
494
- /**
495
- * Inspect an IMF package and return structural metadata including unreferenced assets.
496
- *
497
- * Returns `{ cplCount, scmCount, declaredSidecars, unreferencedAssets }` where
498
- * `unreferencedAssets` are assets in the AssetMap with no CPL Virtual Track reference
499
- * and no SCM declaration — likely sidecar essences delivered without an SCM.
500
- */
501
- export function inspectPackage(files: any): any;
502
-
503
484
  /**
504
485
  * Parse ASSETMAP.xml and return a typed AssetMap object
505
486
  */
@@ -521,40 +502,33 @@ export function parsePklTyped(xmlContent: string): any;
521
502
  export function parseVolindexTyped(xmlContent: string): VolumeIndex;
522
503
 
523
504
  /**
524
- * Validate a CPL with configurable built-in spec selection (ST 2067-2/App2E).
525
- *
526
- * `coreSpec`: "auto" | "v2013" | "v2016" | "v2020"
527
- * `app2eSpec`: "auto" | "none" | "v2020" | "v2021" | "v2023"
528
- */
529
- export function validateCplWithSpecSelection(cplXml: string, coreSpec?: string | null, app2eSpec?: string | null): any;
530
-
531
- /**
532
- * Validate a full IMF package from an in-memory map of filename → XML string.
505
+ * Validate a full IMF package and return both the validation report and parsed data.
533
506
  *
534
507
  * Pass all XML files from the package as a plain JS object where each key is
535
508
  * the filename and each value is the file's text content. ASSETMAP.xml is
536
509
  * required; VOLINDEX.xml, PKL files, and CPL files are resolved automatically
537
510
  * from the AssetMap.
538
511
  *
539
- * Returns a `ValidationReport` serialized to JS.
512
+ * Options (all optional):
513
+ * - `coreSpec`: `"auto"` | `"v2013"` | `"v2016"` | `"v2020"` — core constraints version
514
+ * - `app2eSpec`: `"auto"` | `"none"` | `"v2020"` | `"v2021"` | `"v2023"` — app profile version
515
+ * - `rules`: ESLint-style rules configuration object
516
+ *
517
+ * Returns `{ report, cpls, assetMap, packingLists, volumeIndex, unreferencedAssets, declaredSidecars }`
540
518
  */
541
- export function validatePackage(files: any, rules: any): any;
519
+ export function validate(files: any, options: any): any;
542
520
 
543
521
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
544
522
 
545
523
  export interface InitOutput {
546
524
  readonly memory: WebAssembly.Memory;
547
- readonly compareDelivery: (a: any, b: any) => [number, number, number];
548
- readonly extractSourceAsset: (a: number, b: number) => [number, number, number];
549
525
  readonly getVersion: () => [number, number];
550
526
  readonly init: () => void;
551
- readonly inspectPackage: (a: any) => [number, number, number];
552
527
  readonly parseAssetmapTyped: (a: number, b: number) => [number, number, number];
553
528
  readonly parseCplTyped: (a: number, b: number) => [number, number, number];
554
529
  readonly parsePklTyped: (a: number, b: number) => [number, number, number];
555
530
  readonly parseVolindexTyped: (a: number, b: number) => [number, number, number];
556
- readonly validateCplWithSpecSelection: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
557
- readonly validatePackage: (a: any, b: any) => [number, number, number];
531
+ readonly validate: (a: any, b: any) => [number, number, number];
558
532
  readonly __wbindgen_malloc: (a: number, b: number) => number;
559
533
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
560
534
  readonly __wbindgen_exn_store: (a: number) => void;
package/imferno_wasm.js CHANGED
@@ -1,34 +1,5 @@
1
1
  /* @ts-self-types="./imferno_wasm.d.ts" */
2
2
 
3
- /**
4
- * Compare a SourceAsset against a delivery spec
5
- * @param {any} sourceAssetJson
6
- * @param {any} deliverySpecJson
7
- * @returns {any}
8
- */
9
- export function compareDelivery(sourceAssetJson, deliverySpecJson) {
10
- const ret = wasm.compareDelivery(sourceAssetJson, deliverySpecJson);
11
- if (ret[2]) {
12
- throw takeFromExternrefTable0(ret[1]);
13
- }
14
- return takeFromExternrefTable0(ret[0]);
15
- }
16
-
17
- /**
18
- * Extract a SourceAsset from CPL XML
19
- * @param {string} cplXml
20
- * @returns {any}
21
- */
22
- export function extractSourceAsset(cplXml) {
23
- const ptr0 = passStringToWasm0(cplXml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
24
- const len0 = WASM_VECTOR_LEN;
25
- const ret = wasm.extractSourceAsset(ptr0, len0);
26
- if (ret[2]) {
27
- throw takeFromExternrefTable0(ret[1]);
28
- }
29
- return takeFromExternrefTable0(ret[0]);
30
- }
31
-
32
3
  /**
33
4
  * Get library version
34
5
  * @returns {string}
@@ -53,23 +24,6 @@ export function init() {
53
24
  wasm.init();
54
25
  }
55
26
 
56
- /**
57
- * Inspect an IMF package and return structural metadata including unreferenced assets.
58
- *
59
- * Returns `{ cplCount, scmCount, declaredSidecars, unreferencedAssets }` where
60
- * `unreferencedAssets` are assets in the AssetMap with no CPL Virtual Track reference
61
- * and no SCM declaration — likely sidecar essences delivered without an SCM.
62
- * @param {any} files
63
- * @returns {any}
64
- */
65
- export function inspectPackage(files) {
66
- const ret = wasm.inspectPackage(files);
67
- if (ret[2]) {
68
- throw takeFromExternrefTable0(ret[1]);
69
- }
70
- return takeFromExternrefTable0(ret[0]);
71
- }
72
-
73
27
  /**
74
28
  * Parse ASSETMAP.xml and return a typed AssetMap object
75
29
  * @param {string} xmlContent
@@ -131,44 +85,25 @@ export function parseVolindexTyped(xmlContent) {
131
85
  }
132
86
 
133
87
  /**
134
- * Validate a CPL with configurable built-in spec selection (ST 2067-2/App2E).
135
- *
136
- * `coreSpec`: "auto" | "v2013" | "v2016" | "v2020"
137
- * `app2eSpec`: "auto" | "none" | "v2020" | "v2021" | "v2023"
138
- * @param {string} cplXml
139
- * @param {string | null} [coreSpec]
140
- * @param {string | null} [app2eSpec]
141
- * @returns {any}
142
- */
143
- export function validateCplWithSpecSelection(cplXml, coreSpec, app2eSpec) {
144
- const ptr0 = passStringToWasm0(cplXml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
145
- const len0 = WASM_VECTOR_LEN;
146
- var ptr1 = isLikeNone(coreSpec) ? 0 : passStringToWasm0(coreSpec, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
147
- var len1 = WASM_VECTOR_LEN;
148
- var ptr2 = isLikeNone(app2eSpec) ? 0 : passStringToWasm0(app2eSpec, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
149
- var len2 = WASM_VECTOR_LEN;
150
- const ret = wasm.validateCplWithSpecSelection(ptr0, len0, ptr1, len1, ptr2, len2);
151
- if (ret[2]) {
152
- throw takeFromExternrefTable0(ret[1]);
153
- }
154
- return takeFromExternrefTable0(ret[0]);
155
- }
156
-
157
- /**
158
- * Validate a full IMF package from an in-memory map of filename → XML string.
88
+ * Validate a full IMF package and return both the validation report and parsed data.
159
89
  *
160
90
  * Pass all XML files from the package as a plain JS object where each key is
161
91
  * the filename and each value is the file's text content. ASSETMAP.xml is
162
92
  * required; VOLINDEX.xml, PKL files, and CPL files are resolved automatically
163
93
  * from the AssetMap.
164
94
  *
165
- * Returns a `ValidationReport` serialized to JS.
95
+ * Options (all optional):
96
+ * - `coreSpec`: `"auto"` | `"v2013"` | `"v2016"` | `"v2020"` — core constraints version
97
+ * - `app2eSpec`: `"auto"` | `"none"` | `"v2020"` | `"v2021"` | `"v2023"` — app profile version
98
+ * - `rules`: ESLint-style rules configuration object
99
+ *
100
+ * Returns `{ report, cpls, assetMap, packingLists, volumeIndex, unreferencedAssets, declaredSidecars }`
166
101
  * @param {any} files
167
- * @param {any} rules
102
+ * @param {any} options
168
103
  * @returns {any}
169
104
  */
170
- export function validatePackage(files, rules) {
171
- const ret = wasm.validatePackage(files, rules);
105
+ export function validate(files, options) {
106
+ const ret = wasm.validate(files, options);
172
107
  if (ret[2]) {
173
108
  throw takeFromExternrefTable0(ret[1]);
174
109
  }
@@ -178,14 +113,10 @@ export function validatePackage(files, rules) {
178
113
  function __wbg_get_imports() {
179
114
  const import0 = {
180
115
  __proto__: null,
181
- __wbg_Error_4577686b3a6d9b3a: function(arg0, arg1) {
116
+ __wbg_Error_83742b46f01ce22d: function(arg0, arg1) {
182
117
  const ret = Error(getStringFromWasm0(arg0, arg1));
183
118
  return ret;
184
119
  },
185
- __wbg_Number_e89e48a2fe1a6355: function(arg0) {
186
- const ret = Number(arg0);
187
- return ret;
188
- },
189
120
  __wbg_String_8564e559799eccda: function(arg0, arg1) {
190
121
  const ret = String(arg1);
191
122
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -193,68 +124,68 @@ function __wbg_get_imports() {
193
124
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
194
125
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
195
126
  },
196
- __wbg___wbindgen_bigint_get_as_i64_578010f8442e0319: function(arg0, arg1) {
127
+ __wbg___wbindgen_bigint_get_as_i64_447a76b5c6ef7bda: function(arg0, arg1) {
197
128
  const v = arg1;
198
129
  const ret = typeof(v) === 'bigint' ? v : undefined;
199
130
  getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
200
131
  getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
201
132
  },
202
- __wbg___wbindgen_boolean_get_18c4ed9422296fff: function(arg0) {
133
+ __wbg___wbindgen_boolean_get_c0f3f60bac5a78d1: function(arg0) {
203
134
  const v = arg0;
204
135
  const ret = typeof(v) === 'boolean' ? v : undefined;
205
136
  return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
206
137
  },
207
- __wbg___wbindgen_debug_string_ddde1867f49c2442: function(arg0, arg1) {
138
+ __wbg___wbindgen_debug_string_5398f5bb970e0daa: function(arg0, arg1) {
208
139
  const ret = debugString(arg1);
209
140
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
210
141
  const len1 = WASM_VECTOR_LEN;
211
142
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
212
143
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
213
144
  },
214
- __wbg___wbindgen_in_1064a108f4d18b9e: function(arg0, arg1) {
145
+ __wbg___wbindgen_in_41dbb8413020e076: function(arg0, arg1) {
215
146
  const ret = arg0 in arg1;
216
147
  return ret;
217
148
  },
218
- __wbg___wbindgen_is_bigint_a157f0734ca85901: function(arg0) {
149
+ __wbg___wbindgen_is_bigint_e2141d4f045b7eda: function(arg0) {
219
150
  const ret = typeof(arg0) === 'bigint';
220
151
  return ret;
221
152
  },
222
- __wbg___wbindgen_is_function_d633e708baf0d146: function(arg0) {
153
+ __wbg___wbindgen_is_function_3c846841762788c1: function(arg0) {
223
154
  const ret = typeof(arg0) === 'function';
224
155
  return ret;
225
156
  },
226
- __wbg___wbindgen_is_null_a2a19127c13e7126: function(arg0) {
157
+ __wbg___wbindgen_is_null_0b605fc6b167c56f: function(arg0) {
227
158
  const ret = arg0 === null;
228
159
  return ret;
229
160
  },
230
- __wbg___wbindgen_is_object_4b3de556756ee8a8: function(arg0) {
161
+ __wbg___wbindgen_is_object_781bc9f159099513: function(arg0) {
231
162
  const val = arg0;
232
163
  const ret = typeof(val) === 'object' && val !== null;
233
164
  return ret;
234
165
  },
235
- __wbg___wbindgen_is_string_7debe47dc1e045c2: function(arg0) {
166
+ __wbg___wbindgen_is_string_7ef6b97b02428fae: function(arg0) {
236
167
  const ret = typeof(arg0) === 'string';
237
168
  return ret;
238
169
  },
239
- __wbg___wbindgen_is_undefined_c18285b9fc34cb7d: function(arg0) {
170
+ __wbg___wbindgen_is_undefined_52709e72fb9f179c: function(arg0) {
240
171
  const ret = arg0 === undefined;
241
172
  return ret;
242
173
  },
243
- __wbg___wbindgen_jsval_eq_a6afb59d8c5e78d6: function(arg0, arg1) {
174
+ __wbg___wbindgen_jsval_eq_ee31bfad3e536463: function(arg0, arg1) {
244
175
  const ret = arg0 === arg1;
245
176
  return ret;
246
177
  },
247
- __wbg___wbindgen_jsval_loose_eq_1562ceb9af84e990: function(arg0, arg1) {
178
+ __wbg___wbindgen_jsval_loose_eq_5bcc3bed3c69e72b: function(arg0, arg1) {
248
179
  const ret = arg0 == arg1;
249
180
  return ret;
250
181
  },
251
- __wbg___wbindgen_number_get_5854912275df1894: function(arg0, arg1) {
182
+ __wbg___wbindgen_number_get_34bb9d9dcfa21373: function(arg0, arg1) {
252
183
  const obj = arg1;
253
184
  const ret = typeof(obj) === 'number' ? obj : undefined;
254
185
  getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
255
186
  getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
256
187
  },
257
- __wbg___wbindgen_string_get_3e5751597f39a112: function(arg0, arg1) {
188
+ __wbg___wbindgen_string_get_395e606bd0ee4427: function(arg0, arg1) {
258
189
  const obj = arg1;
259
190
  const ret = typeof(obj) === 'string' ? obj : undefined;
260
191
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -262,52 +193,58 @@ function __wbg_get_imports() {
262
193
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
263
194
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
264
195
  },
265
- __wbg___wbindgen_throw_39bc967c0e5a9b58: function(arg0, arg1) {
196
+ __wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
266
197
  throw new Error(getStringFromWasm0(arg0, arg1));
267
198
  },
268
- __wbg_call_73af281463ec8b58: function() { return handleError(function (arg0, arg1) {
199
+ __wbg_call_e133b57c9155d22c: function() { return handleError(function (arg0, arg1) {
269
200
  const ret = arg0.call(arg1);
270
201
  return ret;
271
202
  }, arguments); },
272
- __wbg_done_5aad55ec6b1954b1: function(arg0) {
203
+ __wbg_done_08ce71ee07e3bd17: function(arg0) {
273
204
  const ret = arg0.done;
274
205
  return ret;
275
206
  },
276
- __wbg_entries_28d32ba4cd93f5fc: function(arg0) {
207
+ __wbg_entries_e8a20ff8c9757101: function(arg0) {
277
208
  const ret = Object.entries(arg0);
278
209
  return ret;
279
210
  },
280
- __wbg_getTime_9429d05129287418: function(arg0) {
211
+ __wbg_getTime_1dad7b5386ddd2d9: function(arg0) {
281
212
  const ret = arg0.getTime();
282
213
  return ret;
283
214
  },
284
- __wbg_get_4920fefd3451364b: function() { return handleError(function (arg0, arg1) {
215
+ __wbg_get_326e41e095fb2575: function() { return handleError(function (arg0, arg1) {
285
216
  const ret = Reflect.get(arg0, arg1);
286
217
  return ret;
287
218
  }, arguments); },
288
- __wbg_get_f09c3a16f8848381: function(arg0, arg1) {
219
+ __wbg_get_a8ee5c45dabc1b3b: function(arg0, arg1) {
289
220
  const ret = arg0[arg1 >>> 0];
290
221
  return ret;
291
222
  },
292
- __wbg_get_unchecked_3d0f4b91c8eca4f0: function(arg0, arg1) {
223
+ __wbg_get_unchecked_329cfe50afab7352: function(arg0, arg1) {
293
224
  const ret = arg0[arg1 >>> 0];
294
225
  return ret;
295
226
  },
296
- __wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
297
- const ret = arg0[arg1];
227
+ __wbg_instanceof_ArrayBuffer_101e2bf31071a9f6: function(arg0) {
228
+ let result;
229
+ try {
230
+ result = arg0 instanceof ArrayBuffer;
231
+ } catch (_) {
232
+ result = false;
233
+ }
234
+ const ret = result;
298
235
  return ret;
299
236
  },
300
- __wbg_instanceof_ArrayBuffer_15859862b80b732d: function(arg0) {
237
+ __wbg_instanceof_Map_f194b366846aca0c: function(arg0) {
301
238
  let result;
302
239
  try {
303
- result = arg0 instanceof ArrayBuffer;
240
+ result = arg0 instanceof Map;
304
241
  } catch (_) {
305
242
  result = false;
306
243
  }
307
244
  const ret = result;
308
245
  return ret;
309
246
  },
310
- __wbg_instanceof_Uint8Array_2240b7046ac16f05: function(arg0) {
247
+ __wbg_instanceof_Uint8Array_740438561a5b956d: function(arg0) {
311
248
  let result;
312
249
  try {
313
250
  result = arg0 instanceof Uint8Array;
@@ -317,58 +254,58 @@ function __wbg_get_imports() {
317
254
  const ret = result;
318
255
  return ret;
319
256
  },
320
- __wbg_isArray_fad08a0d12828686: function(arg0) {
257
+ __wbg_isArray_33b91feb269ff46e: function(arg0) {
321
258
  const ret = Array.isArray(arg0);
322
259
  return ret;
323
260
  },
324
- __wbg_isSafeInteger_10e4151eb694e42a: function(arg0) {
261
+ __wbg_isSafeInteger_ecd6a7f9c3e053cd: function(arg0) {
325
262
  const ret = Number.isSafeInteger(arg0);
326
263
  return ret;
327
264
  },
328
- __wbg_iterator_fc7ad8d33bab9e26: function() {
265
+ __wbg_iterator_d8f549ec8fb061b1: function() {
329
266
  const ret = Symbol.iterator;
330
267
  return ret;
331
268
  },
332
- __wbg_length_5855c1f289dfffc1: function(arg0) {
269
+ __wbg_length_b3416cf66a5452c8: function(arg0) {
333
270
  const ret = arg0.length;
334
271
  return ret;
335
272
  },
336
- __wbg_length_a31e05262e09b7f8: function(arg0) {
273
+ __wbg_length_ea16607d7b61445b: function(arg0) {
337
274
  const ret = arg0.length;
338
275
  return ret;
339
276
  },
340
- __wbg_log_b6373503dce9c42b: function(arg0, arg1) {
277
+ __wbg_log_f9966a5536153c86: function(arg0, arg1) {
341
278
  console.log(getStringFromWasm0(arg0, arg1));
342
279
  },
343
- __wbg_new_09959f7b4c92c246: function(arg0) {
344
- const ret = new Uint8Array(arg0);
345
- return ret;
346
- },
347
- __wbg_new_0_a719938e6f92ddf4: function() {
280
+ __wbg_new_0_1dcafdf5e786e876: function() {
348
281
  const ret = new Date();
349
282
  return ret;
350
283
  },
351
- __wbg_new_92df58a8ec3bfb6b: function() {
284
+ __wbg_new_49d5571bd3f0c4d4: function() {
352
285
  const ret = new Map();
353
286
  return ret;
354
287
  },
355
- __wbg_new_cbee8c0d5c479eac: function() {
356
- const ret = new Array();
288
+ __wbg_new_5f486cdf45a04d78: function(arg0) {
289
+ const ret = new Uint8Array(arg0);
357
290
  return ret;
358
291
  },
359
- __wbg_new_ed69e637b553a997: function() {
360
- const ret = new Object();
292
+ __wbg_new_a70fbab9066b301f: function() {
293
+ const ret = new Array();
361
294
  return ret;
362
295
  },
363
- __wbg_next_a5fe6f328f7affc2: function(arg0) {
364
- const ret = arg0.next;
296
+ __wbg_new_ab79df5bd7c26067: function() {
297
+ const ret = new Object();
365
298
  return ret;
366
299
  },
367
- __wbg_next_e592122bb4ed4c67: function() { return handleError(function (arg0) {
300
+ __wbg_next_11b99ee6237339e3: function() { return handleError(function (arg0) {
368
301
  const ret = arg0.next();
369
302
  return ret;
370
303
  }, arguments); },
371
- __wbg_parse_59ff569636b34ff5: function(arg0, arg1) {
304
+ __wbg_next_e01a967809d1aa68: function(arg0) {
305
+ const ret = arg0.next;
306
+ return ret;
307
+ },
308
+ __wbg_parse_d8e59ac01c35b18b: function(arg0, arg1) {
372
309
  let deferred0_0;
373
310
  let deferred0_1;
374
311
  try {
@@ -380,20 +317,20 @@ function __wbg_get_imports() {
380
317
  wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
381
318
  }
382
319
  },
383
- __wbg_prototypesetcall_f034d444741426c3: function(arg0, arg1, arg2) {
320
+ __wbg_prototypesetcall_d62e5099504357e6: function(arg0, arg1, arg2) {
384
321
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
385
322
  },
386
- __wbg_set_4c81cfb5dc3a333c: function(arg0, arg1, arg2) {
323
+ __wbg_set_282384002438957f: function(arg0, arg1, arg2) {
387
324
  arg0[arg1 >>> 0] = arg2;
388
325
  },
389
326
  __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
390
327
  arg0[arg1] = arg2;
391
328
  },
392
- __wbg_set_cfc6de03f990decf: function(arg0, arg1, arg2) {
329
+ __wbg_set_bf7251625df30a02: function(arg0, arg1, arg2) {
393
330
  const ret = arg0.set(arg1, arg2);
394
331
  return ret;
395
332
  },
396
- __wbg_value_667dcb90597486a6: function(arg0) {
333
+ __wbg_value_21fc78aab0322612: function(arg0) {
397
334
  const ret = arg0.value;
398
335
  return ret;
399
336
  },
Binary file
@@ -1,17 +1,13 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
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
4
  export const getVersion: () => [number, number];
7
5
  export const init: () => void;
8
- export const inspectPackage: (a: any) => [number, number, number];
9
6
  export const parseAssetmapTyped: (a: number, b: number) => [number, number, number];
10
7
  export const parseCplTyped: (a: number, b: number) => [number, number, number];
11
8
  export const parsePklTyped: (a: number, b: number) => [number, number, number];
12
9
  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];
10
+ export const validate: (a: any, b: any) => [number, number, number];
15
11
  export const __wbindgen_malloc: (a: number, b: number) => number;
16
12
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
17
13
  export const __wbindgen_exn_store: (a: number) => void;
package/index.d.ts CHANGED
@@ -16,44 +16,44 @@ export function parsePklTyped(xmlContent: string): Promise<any>;
16
16
  /** Parse VOLINDEX.xml content */
17
17
  export function parseVolindexTyped(xmlContent: string): Promise<any>;
18
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>;
19
+ /** Options for the validate function */
20
+ export interface ValidateOptions {
21
+ /** Core constraints spec version: "auto" | "v2013" | "v2016" | "v2020" */
22
+ coreSpec?: "auto" | "v2013" | "v2016" | "v2020";
23
+ /** Application profile version: "auto" | "none" | "v2020" | "v2021" | "v2023" */
24
+ app2eSpec?: "auto" | "none" | "v2020" | "v2021" | "v2023";
25
+ /** ESLint-style rules configuration */
26
+ rules?: Record<string, string>;
27
+ }
31
28
 
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>;
29
+ /** Result returned by the validate function */
30
+ export interface ValidateResult {
31
+ /** Validation report with issues, compliance status, and profile */
32
+ report: any;
33
+ /** Parsed Composition Playlists */
34
+ cpls: any[];
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
+ }
42
46
 
43
47
  /**
44
- * Inspect an IMF package and return structural metadata.
48
+ * Validate a full IMF package and return both validation report and parsed data.
45
49
  * @param files Object mapping filenames to XML string content
46
- * @returns { cplCount, scmCount, declaredSidecars, unreferencedAssets }
50
+ * @param options Optional validation options (spec selection, rules)
51
+ * @returns Validation report + parsed package data
47
52
  */
48
- export function inspectPackage(
53
+ export function validate(
49
54
  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>;
55
+ options?: ValidateOptions,
56
+ ): Promise<ValidateResult>;
57
57
 
58
58
  /** Get the library version */
59
59
  export function getVersion(): Promise<string>;
package/index.js CHANGED
@@ -51,32 +51,10 @@ export async function parseVolindexTyped(xmlContent) {
51
51
  return wasm.parseVolindexTyped(xmlContent);
52
52
  }
53
53
 
54
- // Validation
55
- export async function validateCplWithSpecSelection(cplXml, coreSpec, app2eSpec) {
54
+ // Validation — the unified function
55
+ export async function validate(files, options) {
56
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);
57
+ return wasm.validate(files, options);
80
58
  }
81
59
 
82
60
  // Utility
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imferno/wasm",
3
- "version": "0.1.3",
3
+ "version": "1.1.0",
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",
@@ -55,6 +55,7 @@
55
55
  "access": "public"
56
56
  },
57
57
  "devDependencies": {
58
+ "ajv": "^8.18.0",
58
59
  "vitest": "^4.0.18"
59
60
  }
60
61
  }