@imferno/wasm 3.0.2-beta.5af77ef → 3.0.2-beta.67b6b7d

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
@@ -17,28 +17,29 @@ The package ships a prebuilt `.wasm` binary -- no build step required.
17
17
  ## Usage
18
18
 
19
19
  ```javascript
20
- import { buildReport, formatReport, codes, getVersion } from '@imferno/wasm';
20
+ import { validate, formatReport, codes, getVersion } from '@imferno/wasm';
21
21
 
22
22
  // Validate a full IMF package (pass all XML files as a map)
23
- const report = await buildReport({
23
+ const result = await validate({
24
24
  'ASSETMAP.xml': assetmapXml,
25
25
  'PKL_abc.xml': pklXml,
26
26
  'CPL_def.xml': cplXml,
27
27
  });
28
28
 
29
- // Pretty-print the report
30
- console.log(await formatReport(report));
29
+ // Pretty-print the result
30
+ console.log(await formatReport(result));
31
31
 
32
32
  // Check compliance programmatically
33
- if (!report.validation.is_compliant) {
34
- for (const err of report.validation.errors) {
33
+ if (!result.validation.is_compliant) {
34
+ for (const err of result.validation.errors) {
35
35
  console.error(err.code, err.message);
36
36
  }
37
37
  }
38
38
 
39
39
  // Inspect package metadata
40
- console.log('CPL count:', report.package.cplCount);
41
- console.log('CPLs:', report.cpls);
40
+ const cpls = Object.values(result.package.compositionPlaylists);
41
+ console.log('CPL count:', cpls.length);
42
+ console.log('Titles:', cpls.map((cpl) => cpl.contentTitle));
42
43
 
43
44
  // Get library version
44
45
  console.log(await getVersion());
@@ -59,8 +60,8 @@ const report = await buildReport(
59
60
  coreSpec: 'v2020',
60
61
  app2eSpec: 'v2023',
61
62
  rules: {
62
- [codes.ST2067_2_2020.FileNotFound]: 'critical',
63
- [codes.ST2067_2_2020.ChecksumMismatch]: 'off',
63
+ [codes.ST2067_2.FileNotFound]: 'critical',
64
+ [codes.ST2067_2.ChecksumMismatch]: 'off',
64
65
  },
65
66
  },
66
67
  );
@@ -72,10 +73,15 @@ WASM initialization is handled automatically on first call.
72
73
 
73
74
  | Export | Description |
74
75
  |--------|-------------|
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
+ | `validate(files, options?)` | Parse and validate an IMF package, returns `{ package, validation }` (`ValidationResult`) |
77
+ | `parsePackage(files)` | Parse without validating, returns the full package (`Imferno`) |
78
+ | `buildReport(files, options?)` | Legacy: parse and validate, returns an `ImfReport` summary |
79
+ | `formatReport(result)` | Render a `ValidationResult` (or legacy `ImfReport`) as a human-readable string |
77
80
  | `codes` | Typed validation code constants for use in `rules` config |
78
81
  | `getVersion()` | Get library version |
82
+ | `init(wasmBytes?)` | Optional explicit initialisation |
83
+
84
+ All value types (`ValidationResult`, `ValidationIssue`, `ValidateOptions`, ...) are exported for TypeScript.
79
85
 
80
86
  All exports are **async** (WASM must be initialized before use).
81
87
 
@@ -118,7 +124,7 @@ All exports are **async** (WASM must be initialized before use).
118
124
  | Field | Values | Default |
119
125
  |-------|--------|---------|
120
126
  | `coreSpec` | `"auto"`, `"v2013"`, `"v2016"`, `"v2020"` | auto-detect |
121
- | `app2eSpec` | `"auto"`, `"none"`, `"v2020"`, `"v2021"`, `"v2023"` | auto-detect |
127
+ | `app2eSpec` | `"auto"`, `"none"`, `"v2014"`, `"v2016"`, `"v2020"`, `"v2023"`, `"v2026"` | auto-detect |
122
128
  | `rules` | ESLint-style rules object (`{ [code]: severity }`) | all enabled |
123
129
 
124
130
  Rule severities: `"critical"`, `"error"`, `"warning"`, `"info"`, `"off"`.