@imferno/wasm 2.0.0 → 2.0.1-beta.2379acf

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
@@ -12,40 +12,44 @@ npm install @imferno/wasm
12
12
 
13
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
14
 
15
- The package ships a prebuilt `.wasm` binary no build step required.
15
+ The package ships a prebuilt `.wasm` binary -- no build step required.
16
16
 
17
17
  ## Usage
18
18
 
19
19
  ```javascript
20
- import {
21
- parseAssetmapTyped,
22
- parseCplTyped,
23
- parsePklTyped,
24
- parseVolindexTyped,
25
- validate,
26
- codes,
27
- getVersion,
28
- } from '@imferno/wasm';
29
-
30
- // Parse individual XML files
31
- const assetMap = await parseAssetmapTyped(assetmapXml);
32
- const cpl = await parseCplTyped(cplXml);
33
- const pkl = await parsePklTyped(pklXml);
34
- const volindex = await parseVolindexTyped(volindexXml);
20
+ import { buildReport, formatReport, codes, getVersion } from '@imferno/wasm';
35
21
 
36
22
  // Validate a full IMF package (pass all XML files as a map)
37
- const result = await validate({
23
+ const report = await buildReport({
38
24
  'ASSETMAP.xml': assetmapXml,
39
25
  'PKL_abc.xml': pklXml,
40
26
  'CPL_def.xml': cplXml,
41
27
  });
42
- console.log(result.report.errors);
43
- console.log(result.report.warnings);
44
- console.log(result.cpls);
45
- console.log(result.unreferencedAssets);
46
28
 
47
- // Validate with custom rules (typed codes give autocomplete + typo protection)
48
- const result2 = await validate(
29
+ // Pretty-print the report
30
+ console.log(await formatReport(report));
31
+
32
+ // Check compliance programmatically
33
+ if (!report.validation.is_compliant) {
34
+ for (const err of report.validation.errors) {
35
+ console.error(err.code, err.message);
36
+ }
37
+ }
38
+
39
+ // Inspect package metadata
40
+ console.log('CPL count:', report.package.cplCount);
41
+ console.log('CPLs:', report.cpls);
42
+
43
+ // Get library version
44
+ console.log(await getVersion());
45
+ ```
46
+
47
+ ### Validate with options
48
+
49
+ ```javascript
50
+ import { buildReport, codes } from '@imferno/wasm';
51
+
52
+ const report = await buildReport(
49
53
  {
50
54
  'ASSETMAP.xml': assetmapXml,
51
55
  'PKL_abc.xml': pklXml,
@@ -68,18 +72,56 @@ WASM initialization is handled automatically on first call.
68
72
 
69
73
  | Export | Description |
70
74
  |--------|-------------|
71
- | `validate(files, options?)` | Validate a full IMF package, returns report + parsed data |
72
- | `parseCplTyped(xml)` | Parse CPL XML |
73
- | `parseAssetmapTyped(xml)` | Parse ASSETMAP.xml |
74
- | `parsePklTyped(xml)` | Parse PKL XML |
75
- | `parseVolindexTyped(xml)` | Parse VOLINDEX.xml |
75
+ | `buildReport(files, options?)` | Parse and validate an IMF package, returns an `ImfReport` |
76
+ | `formatReport(report)` | Render an `ImfReport` as a human-readable string |
76
77
  | `codes` | Typed validation code constants for use in `rules` config |
77
78
  | `getVersion()` | Get library version |
78
79
 
79
- ### Spec selection values
80
+ All exports are **async** (WASM must be initialized before use).
81
+
82
+ ### ImfReport shape
83
+
84
+ ```json
85
+ {
86
+ "package": {
87
+ "assetMapId": "...",
88
+ "cplCount": 1,
89
+ "pklCount": 1,
90
+ "assetCount": 5,
91
+ "unreferencedAssets": []
92
+ },
93
+ "cpls": [
94
+ {
95
+ "id": "...",
96
+ "title": "...",
97
+ "applicationProfile": "App2E_2023",
98
+ "editRate": "24000/1001",
99
+ "segmentCount": 1,
100
+ "isSupplemental": false,
101
+ "sequences": [],
102
+ "markers": []
103
+ }
104
+ ],
105
+ "validation": {
106
+ "is_compliant": true,
107
+ "is_playable": true,
108
+ "critical": [],
109
+ "errors": [],
110
+ "warnings": [],
111
+ "info": []
112
+ }
113
+ }
114
+ ```
115
+
116
+ ### Options
117
+
118
+ | Field | Values | Default |
119
+ |-------|--------|---------|
120
+ | `coreSpec` | `"auto"`, `"v2013"`, `"v2016"`, `"v2020"` | auto-detect |
121
+ | `app2eSpec` | `"auto"`, `"none"`, `"v2020"`, `"v2021"`, `"v2023"` | auto-detect |
122
+ | `rules` | ESLint-style rules object (`{ [code]: severity }`) | all enabled |
80
123
 
81
- - `coreSpec`: `"auto"` | `"v2013"` | `"v2016"` | `"v2020"`
82
- - `app2eSpec`: `"auto"` | `"none"` | `"v2020"` | `"v2021"` | `"v2023"`
124
+ Rule severities: `"critical"`, `"error"`, `"warning"`, `"info"`, `"off"`.
83
125
 
84
126
  ## License
85
127
 
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imferno/wasm",
3
- "version": "2.0.0",
3
+ "version": "2.0.1-beta.2379acf",
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",