vastlint 0.2.6 → 0.3.1
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/index.cjs +2 -0
- package/index.d.ts +38 -0
- package/index.js +1 -1
- package/package.json +1 -1
- package/vastlint_wasm.d.ts +33 -0
- package/vastlint_wasm.js +1 -1
- package/vastlint_wasm_bg.js +54 -0
- package/vastlint_wasm_bg.wasm +0 -0
- package/vastlint_wasm_bg.wasm.d.ts +2 -0
- package/vastlint_wasm_cjs.js +56 -0
package/index.cjs
CHANGED
|
@@ -13,6 +13,8 @@ module.exports = {
|
|
|
13
13
|
validate: wasm.validate,
|
|
14
14
|
validateWithOptions: wasm.validateWithOptions,
|
|
15
15
|
rules: wasm.rules,
|
|
16
|
+
fix: wasm.fix,
|
|
17
|
+
fixWithOptions: wasm.fixWithOptions,
|
|
16
18
|
validateFiltered(xml, minSeverity = 'error') {
|
|
17
19
|
const order = { error: 2, warning: 1, info: 0 };
|
|
18
20
|
const min = order[minSeverity] ?? 0;
|
package/index.d.ts
CHANGED
|
@@ -89,3 +89,41 @@ export declare function validateFiltered(
|
|
|
89
89
|
* Returns the full catalog of all known validation rules.
|
|
90
90
|
*/
|
|
91
91
|
export declare function rules(): RuleMeta[];
|
|
92
|
+
|
|
93
|
+
/** A single fix that was automatically applied to the document. */
|
|
94
|
+
export interface AppliedFix {
|
|
95
|
+
/** The rule ID this fix addresses, e.g. `"VAST-2.0-mediafile-https"`. */
|
|
96
|
+
rule_id: string;
|
|
97
|
+
/** Human-readable description of what was changed. */
|
|
98
|
+
description: string;
|
|
99
|
+
/** XPath-like path to the element that was modified. */
|
|
100
|
+
path: string;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface FixResult {
|
|
104
|
+
/** The repaired VAST XML string. */
|
|
105
|
+
xml: string;
|
|
106
|
+
/** All fixes that were successfully applied, in document order. */
|
|
107
|
+
applied: AppliedFix[];
|
|
108
|
+
/** Issues that remain after all fixes were applied (require manual intervention). */
|
|
109
|
+
remaining: Issue[];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Fix a VAST XML string using default settings.
|
|
114
|
+
* Upgrades http:// URLs to https:// and removes deprecated attributes.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* import { fix } from 'vastlint';
|
|
118
|
+
* const result = fix(xml);
|
|
119
|
+
* console.log(result.xml); // repaired XML
|
|
120
|
+
* console.log(result.applied); // what was changed
|
|
121
|
+
* console.log(result.remaining); // issues that need manual attention
|
|
122
|
+
*/
|
|
123
|
+
export declare function fix(xml: string): FixResult;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Fix a VAST XML string with caller-supplied options.
|
|
127
|
+
* Accepts the same options object as `validateWithOptions`.
|
|
128
|
+
*/
|
|
129
|
+
export declare function fixWithOptions(xml: string, options: ValidateOptions): FixResult;
|
package/index.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
// wasm-pack generates vastlint_wasm.js (ESM glue) and vastlint_wasm_bg.wasm.
|
|
18
18
|
// assemble.js copies both to the package root during the build.
|
|
19
19
|
import * as _wasm from './vastlint_wasm.js';
|
|
20
|
-
export const { validate, validateWithOptions, rules } = _wasm;
|
|
20
|
+
export const { validate, validateWithOptions, rules, fix, fixWithOptions } = _wasm;
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Validate a VAST XML string and return only issues at or above a minimum severity.
|
package/package.json
CHANGED
package/vastlint_wasm.d.ts
CHANGED
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Fix common VAST issues and return the repaired XML alongside a report.
|
|
6
|
+
*
|
|
7
|
+
* Returns a plain JavaScript object shaped like:
|
|
8
|
+
* ```ts
|
|
9
|
+
* {
|
|
10
|
+
* xml: string, // repaired VAST XML
|
|
11
|
+
* applied: Array<{
|
|
12
|
+
* rule_id: string,
|
|
13
|
+
* description: string,
|
|
14
|
+
* path: string,
|
|
15
|
+
* }>,
|
|
16
|
+
* remaining: Array<{ // issues that could not be auto-fixed
|
|
17
|
+
* id: string,
|
|
18
|
+
* severity: "error" | "warning" | "info",
|
|
19
|
+
* message: string,
|
|
20
|
+
* path: string | null,
|
|
21
|
+
* spec_ref: string,
|
|
22
|
+
* line: number | null,
|
|
23
|
+
* col: number | null,
|
|
24
|
+
* }>,
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function fix(xml: string): any;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Fix a VAST XML string with caller-supplied options.
|
|
32
|
+
*
|
|
33
|
+
* Accepts the same `options` object as `validateWithOptions`.
|
|
34
|
+
*/
|
|
35
|
+
export function fixWithOptions(xml: string, options: any): any;
|
|
36
|
+
|
|
4
37
|
/**
|
|
5
38
|
* Returns the full rule catalog as a JS array.
|
|
6
39
|
*
|
package/vastlint_wasm.js
CHANGED
package/vastlint_wasm_bg.js
CHANGED
|
@@ -1,3 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fix common VAST issues and return the repaired XML alongside a report.
|
|
3
|
+
*
|
|
4
|
+
* Returns a plain JavaScript object shaped like:
|
|
5
|
+
* ```ts
|
|
6
|
+
* {
|
|
7
|
+
* xml: string, // repaired VAST XML
|
|
8
|
+
* applied: Array<{
|
|
9
|
+
* rule_id: string,
|
|
10
|
+
* description: string,
|
|
11
|
+
* path: string,
|
|
12
|
+
* }>,
|
|
13
|
+
* remaining: Array<{ // issues that could not be auto-fixed
|
|
14
|
+
* id: string,
|
|
15
|
+
* severity: "error" | "warning" | "info",
|
|
16
|
+
* message: string,
|
|
17
|
+
* path: string | null,
|
|
18
|
+
* spec_ref: string,
|
|
19
|
+
* line: number | null,
|
|
20
|
+
* col: number | null,
|
|
21
|
+
* }>,
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
* @param {string} xml
|
|
25
|
+
* @returns {any}
|
|
26
|
+
*/
|
|
27
|
+
export function fix(xml) {
|
|
28
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
29
|
+
const len0 = WASM_VECTOR_LEN;
|
|
30
|
+
const ret = wasm.fix(ptr0, len0);
|
|
31
|
+
if (ret[2]) {
|
|
32
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
33
|
+
}
|
|
34
|
+
return takeFromExternrefTable0(ret[0]);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Fix a VAST XML string with caller-supplied options.
|
|
39
|
+
*
|
|
40
|
+
* Accepts the same `options` object as `validateWithOptions`.
|
|
41
|
+
* @param {string} xml
|
|
42
|
+
* @param {any} options
|
|
43
|
+
* @returns {any}
|
|
44
|
+
*/
|
|
45
|
+
export function fixWithOptions(xml, options) {
|
|
46
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
47
|
+
const len0 = WASM_VECTOR_LEN;
|
|
48
|
+
const ret = wasm.fixWithOptions(ptr0, len0, options);
|
|
49
|
+
if (ret[2]) {
|
|
50
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
51
|
+
}
|
|
52
|
+
return takeFromExternrefTable0(ret[0]);
|
|
53
|
+
}
|
|
54
|
+
|
|
1
55
|
/**
|
|
2
56
|
* Returns the full rule catalog as a JS array.
|
|
3
57
|
*
|
package/vastlint_wasm_bg.wasm
CHANGED
|
Binary file
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const fix: (a: number, b: number) => [number, number, number];
|
|
5
|
+
export const fixWithOptions: (a: number, b: number, c: any) => [number, number, number];
|
|
4
6
|
export const rules: () => [number, number, number];
|
|
5
7
|
export const validate: (a: number, b: number) => [number, number, number];
|
|
6
8
|
export const validateWithOptions: (a: number, b: number, c: any) => [number, number, number];
|
package/vastlint_wasm_cjs.js
CHANGED
|
@@ -1,5 +1,61 @@
|
|
|
1
1
|
/* @ts-self-types="./vastlint_wasm.d.ts" */
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Fix common VAST issues and return the repaired XML alongside a report.
|
|
5
|
+
*
|
|
6
|
+
* Returns a plain JavaScript object shaped like:
|
|
7
|
+
* ```ts
|
|
8
|
+
* {
|
|
9
|
+
* xml: string, // repaired VAST XML
|
|
10
|
+
* applied: Array<{
|
|
11
|
+
* rule_id: string,
|
|
12
|
+
* description: string,
|
|
13
|
+
* path: string,
|
|
14
|
+
* }>,
|
|
15
|
+
* remaining: Array<{ // issues that could not be auto-fixed
|
|
16
|
+
* id: string,
|
|
17
|
+
* severity: "error" | "warning" | "info",
|
|
18
|
+
* message: string,
|
|
19
|
+
* path: string | null,
|
|
20
|
+
* spec_ref: string,
|
|
21
|
+
* line: number | null,
|
|
22
|
+
* col: number | null,
|
|
23
|
+
* }>,
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
* @param {string} xml
|
|
27
|
+
* @returns {any}
|
|
28
|
+
*/
|
|
29
|
+
function fix(xml) {
|
|
30
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
31
|
+
const len0 = WASM_VECTOR_LEN;
|
|
32
|
+
const ret = wasm.fix(ptr0, len0);
|
|
33
|
+
if (ret[2]) {
|
|
34
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
35
|
+
}
|
|
36
|
+
return takeFromExternrefTable0(ret[0]);
|
|
37
|
+
}
|
|
38
|
+
exports.fix = fix;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Fix a VAST XML string with caller-supplied options.
|
|
42
|
+
*
|
|
43
|
+
* Accepts the same `options` object as `validateWithOptions`.
|
|
44
|
+
* @param {string} xml
|
|
45
|
+
* @param {any} options
|
|
46
|
+
* @returns {any}
|
|
47
|
+
*/
|
|
48
|
+
function fixWithOptions(xml, options) {
|
|
49
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
50
|
+
const len0 = WASM_VECTOR_LEN;
|
|
51
|
+
const ret = wasm.fixWithOptions(ptr0, len0, options);
|
|
52
|
+
if (ret[2]) {
|
|
53
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
54
|
+
}
|
|
55
|
+
return takeFromExternrefTable0(ret[0]);
|
|
56
|
+
}
|
|
57
|
+
exports.fixWithOptions = fixWithOptions;
|
|
58
|
+
|
|
3
59
|
/**
|
|
4
60
|
* Returns the full rule catalog as a JS array.
|
|
5
61
|
*
|