vastlint 0.1.2

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 ADDED
@@ -0,0 +1,101 @@
1
+ # vastlint
2
+
3
+ VAST XML validator for JavaScript and TypeScript. Checks ad tags against IAB Tech Lab VAST 2.0 through 4.3. Runs in the browser, Node.js, Deno, and edge workers. Powered by a Rust/WASM core.
4
+
5
+ [![npm](https://img.shields.io/npm/v/vastlint)](https://www.npmjs.com/package/vastlint)
6
+ [![License](https://img.shields.io/badge/license-Apache--2.0-blue)](../vastlint/LICENSE)
7
+
8
+ ---
9
+
10
+ ## Install
11
+
12
+ ```sh
13
+ npm install vastlint
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ ```ts
19
+ import { validate } from 'vastlint';
20
+
21
+ const result = validate(xmlString);
22
+
23
+ if (!result.summary.valid) {
24
+ for (const issue of result.issues) {
25
+ console.error(`[${issue.severity}] ${issue.id}: ${issue.message}`);
26
+ if (issue.path) console.error(` at ${issue.path}`);
27
+ }
28
+ }
29
+ ```
30
+
31
+ ### With options
32
+
33
+ ```ts
34
+ import { validateWithOptions } from 'vastlint';
35
+
36
+ const result = validateWithOptions(xml, {
37
+ wrapper_depth: 2,
38
+ max_wrapper_depth: 5,
39
+ rule_overrides: {
40
+ 'VAST-2.0-mediafile-https': 'off', // silence HTTP advisory
41
+ 'VAST-2.0-root-version': 'error', // treat missing version as hard error
42
+ },
43
+ });
44
+ ```
45
+
46
+ ### Filter by severity
47
+
48
+ ```ts
49
+ import { validateFiltered } from 'vastlint';
50
+
51
+ // Only return errors, ignore warnings and infos
52
+ const result = validateFiltered(xml, 'error');
53
+ ```
54
+
55
+ ### List all rules
56
+
57
+ ```ts
58
+ import { rules } from 'vastlint';
59
+
60
+ for (const rule of rules()) {
61
+ console.log(rule.id, rule.default_severity, rule.description);
62
+ }
63
+ ```
64
+
65
+ ---
66
+
67
+ ## Result shape
68
+
69
+ ```ts
70
+ {
71
+ version: string | null, // detected VAST version, e.g. "4.2"
72
+ summary: {
73
+ errors: number,
74
+ warnings: number,
75
+ infos: number,
76
+ valid: boolean, // true when errors === 0
77
+ },
78
+ issues: Array<{
79
+ id: string, // stable rule ID, e.g. "VAST-4.1-universal-ad-id"
80
+ severity: "error" | "warning" | "info",
81
+ message: string,
82
+ path: string | null, // XPath-like location
83
+ spec_ref: string, // e.g. "IAB VAST 4.1 §3.8.1"
84
+ }>,
85
+ }
86
+ ```
87
+
88
+ ---
89
+
90
+ ## CommonJS
91
+
92
+ ```js
93
+ const { validate } = require('vastlint');
94
+ const result = validate(xml);
95
+ ```
96
+
97
+ ---
98
+
99
+ ## Source
100
+
101
+ The Rust source and CLI tool live at [github.com/aleksUIX/vastlint](https://github.com/aleksUIX/vastlint).
package/index.cjs ADDED
@@ -0,0 +1,25 @@
1
+ /**
2
+ * vastlint — CommonJS shim
3
+ *
4
+ * Node.js consumers using `require('vastlint')` land here.
5
+ * The actual implementation is the wasm-pack --target nodejs output.
6
+ */
7
+
8
+ // wasm-pack --target nodejs produces CJS. assemble.js copies it to vastlint_wasm_cjs.js
9
+ // at the package root during the build.
10
+ const wasm = require('./vastlint_wasm_cjs.js');
11
+
12
+ module.exports = {
13
+ validate: wasm.validate,
14
+ validateWithOptions: wasm.validateWithOptions,
15
+ rules: wasm.rules,
16
+ validateFiltered(xml, minSeverity = 'error') {
17
+ const order = { error: 2, warning: 1, info: 0 };
18
+ const min = order[minSeverity] ?? 0;
19
+ const result = wasm.validate(xml);
20
+ return {
21
+ ...result,
22
+ issues: result.issues.filter(i => (order[i.severity] ?? 0) >= min),
23
+ };
24
+ },
25
+ };
package/index.d.ts ADDED
@@ -0,0 +1,87 @@
1
+ // vastlint — TypeScript definitions
2
+ // These types describe the plain objects returned from the WASM module.
3
+
4
+ export interface Issue {
5
+ /** Stable rule identifier, e.g. "VAST-2.0-root-version". */
6
+ id: string;
7
+ severity: 'error' | 'warning' | 'info';
8
+ message: string;
9
+ /** XPath-like location, e.g. "/VAST/Ad[0]/InLine/AdSystem". Null for document-level issues. */
10
+ path: string | null;
11
+ /** Short spec reference, e.g. "IAB VAST 4.1 §3.4.1". */
12
+ spec_ref: string;
13
+ }
14
+
15
+ export interface Summary {
16
+ errors: number;
17
+ warnings: number;
18
+ infos: number;
19
+ /** True when errors === 0. */
20
+ valid: boolean;
21
+ }
22
+
23
+ export interface ValidationResult {
24
+ /** Detected VAST version string (e.g. "4.2"), or null if unknown. */
25
+ version: string | null;
26
+ issues: Issue[];
27
+ summary: Summary;
28
+ }
29
+
30
+ export interface RuleMeta {
31
+ id: string;
32
+ default_severity: 'error' | 'warning' | 'info';
33
+ description: string;
34
+ }
35
+
36
+ export interface ValidateOptions {
37
+ /** Current wrapper chain depth. Default: 0. */
38
+ wrapper_depth?: number;
39
+ /** Maximum allowed wrapper chain depth. Default: 5. */
40
+ max_wrapper_depth?: number;
41
+ /**
42
+ * Per-rule severity overrides. Keys are rule IDs (see `rules()`).
43
+ * Use "off" to silence a rule entirely.
44
+ */
45
+ rule_overrides?: Record<string, 'error' | 'warning' | 'info' | 'off'>;
46
+ }
47
+
48
+ /**
49
+ * Validate a VAST XML string using default settings.
50
+ *
51
+ * @example
52
+ * import { validate } from 'vastlint';
53
+ * const result = validate(xml);
54
+ * if (!result.summary.valid) { ... }
55
+ */
56
+ export declare function validate(xml: string): ValidationResult;
57
+
58
+ /**
59
+ * Validate a VAST XML string with caller-supplied options.
60
+ *
61
+ * @example
62
+ * import { validateWithOptions } from 'vastlint';
63
+ * const result = validateWithOptions(xml, {
64
+ * wrapper_depth: 2,
65
+ * rule_overrides: { 'VAST-2.0-mediafile-https': 'off' },
66
+ * });
67
+ */
68
+ export declare function validateWithOptions(
69
+ xml: string,
70
+ options: ValidateOptions
71
+ ): ValidationResult;
72
+
73
+ /**
74
+ * Like `validate`, but filters the returned issues to those at or above
75
+ * `minSeverity`. Useful when you only care about hard errors.
76
+ *
77
+ * @param minSeverity Defaults to "error".
78
+ */
79
+ export declare function validateFiltered(
80
+ xml: string,
81
+ minSeverity?: 'error' | 'warning' | 'info'
82
+ ): ValidationResult;
83
+
84
+ /**
85
+ * Returns the full catalog of all known validation rules.
86
+ */
87
+ export declare function rules(): RuleMeta[];
package/index.js ADDED
@@ -0,0 +1,37 @@
1
+ /**
2
+ * vastlint — VAST XML validator
3
+ *
4
+ * ESM entry point. Loads the WASM module lazily on first call.
5
+ *
6
+ * @example
7
+ * import { validate } from 'vastlint';
8
+ *
9
+ * const result = validate(xmlString);
10
+ * if (!result.summary.valid) {
11
+ * result.issues
12
+ * .filter(i => i.severity === 'error')
13
+ * .forEach(i => console.error(`[${i.id}] ${i.message} at ${i.path}`));
14
+ * }
15
+ */
16
+
17
+ // wasm-pack generates vastlint_wasm.js (ESM glue) and vastlint_wasm_bg.wasm.
18
+ // assemble.js copies both to the package root during the build.
19
+ import * as _wasm from './vastlint_wasm.js';
20
+ export const { validate, validateWithOptions, rules } = _wasm;
21
+
22
+ /**
23
+ * Validate a VAST XML string and return only issues at or above a minimum severity.
24
+ *
25
+ * @param {string} xml
26
+ * @param {"error"|"warning"|"info"} [minSeverity="error"]
27
+ * @returns {import('./index.d.ts').ValidationResult}
28
+ */
29
+ export function validateFiltered(xml, minSeverity = 'error') {
30
+ const order = { error: 2, warning: 1, info: 0 };
31
+ const min = order[minSeverity] ?? 0;
32
+ const result = _wasm.validate(xml);
33
+ return {
34
+ ...result,
35
+ issues: result.issues.filter(i => (order[i.severity] ?? 0) >= min),
36
+ };
37
+ }
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "vastlint",
3
+ "version": "0.1.2",
4
+ "description": "VAST XML validator — checks ad tags against IAB VAST 2.0 through 4.3",
5
+ "license": "Apache-2.0",
6
+ "author": "Alex Sekowski <alex@vastlint.org>",
7
+ "homepage": "https://github.com/aleksUIX/vastlint",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/aleksUIX/vastlint"
11
+ },
12
+ "keywords": ["vast", "xml", "validator", "adtech", "iab", "ctv", "wasm"],
13
+ "type": "module",
14
+ "main": "./index.cjs",
15
+ "module": "./index.js",
16
+ "types": "./index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "import": "./index.js",
20
+ "require": "./index.cjs",
21
+ "types": "./index.d.ts"
22
+ }
23
+ },
24
+ "files": [
25
+ "index.js",
26
+ "index.cjs",
27
+ "index.d.ts",
28
+ "vastlint_wasm.js",
29
+ "vastlint_wasm.d.ts",
30
+ "vastlint_wasm_bg.js",
31
+ "vastlint_wasm_bg.wasm",
32
+ "vastlint_wasm_bg.wasm.d.ts",
33
+ "vastlint_wasm_cjs.js",
34
+ "README.md"
35
+ ],
36
+ "scripts": {
37
+ "build": "wasm-pack build ../crates/vastlint-wasm --target bundler --out-dir pkg && wasm-pack build ../crates/vastlint-wasm --target nodejs --out-dir pkg-node && node scripts/assemble.js"
38
+ },
39
+ "engines": {
40
+ "node": ">=18"
41
+ }
42
+ }
@@ -0,0 +1,45 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Returns the full rule catalog as a JS array.
6
+ *
7
+ * Each element: `{ id: string, default_severity: string, description: string }`.
8
+ */
9
+ export function rules(): any;
10
+
11
+ /**
12
+ * Validate a VAST XML string.
13
+ *
14
+ * Returns a plain JavaScript object shaped like:
15
+ * ```ts
16
+ * {
17
+ * version: string | null,
18
+ * issues: Array<{
19
+ * id: string,
20
+ * severity: "error" | "warning" | "info",
21
+ * message: string,
22
+ * path: string | null,
23
+ * spec_ref: string,
24
+ * }>,
25
+ * summary: { errors: number, warnings: number, infos: number, valid: boolean },
26
+ * }
27
+ * ```
28
+ *
29
+ * Throws a JS `Error` if the argument is not a string.
30
+ */
31
+ export function validate(xml: string): any;
32
+
33
+ /**
34
+ * Validate a VAST XML string with caller-supplied options.
35
+ *
36
+ * `options` is a plain JS object with optional fields:
37
+ * ```ts
38
+ * {
39
+ * wrapper_depth?: number,
40
+ * max_wrapper_depth?: number,
41
+ * rule_overrides?: Record<string, "error" | "warning" | "info" | "off">,
42
+ * }
43
+ * ```
44
+ */
45
+ export function validateWithOptions(xml: string, options: any): any;
@@ -0,0 +1,9 @@
1
+ /* @ts-self-types="./vastlint_wasm.d.ts" */
2
+
3
+ import * as wasm from "./vastlint_wasm_bg.wasm";
4
+ import { __wbg_set_wasm } from "./vastlint_wasm_bg.js";
5
+ __wbg_set_wasm(wasm);
6
+ wasm.__wbindgen_start();
7
+ export {
8
+ rules, validate, validateWithOptions
9
+ } from "./vastlint_wasm_bg.js";
@@ -0,0 +1,447 @@
1
+ /**
2
+ * Returns the full rule catalog as a JS array.
3
+ *
4
+ * Each element: `{ id: string, default_severity: string, description: string }`.
5
+ * @returns {any}
6
+ */
7
+ export function rules() {
8
+ const ret = wasm.rules();
9
+ if (ret[2]) {
10
+ throw takeFromExternrefTable0(ret[1]);
11
+ }
12
+ return takeFromExternrefTable0(ret[0]);
13
+ }
14
+
15
+ /**
16
+ * Validate a VAST XML string.
17
+ *
18
+ * Returns a plain JavaScript object shaped like:
19
+ * ```ts
20
+ * {
21
+ * version: string | null,
22
+ * issues: Array<{
23
+ * id: string,
24
+ * severity: "error" | "warning" | "info",
25
+ * message: string,
26
+ * path: string | null,
27
+ * spec_ref: string,
28
+ * }>,
29
+ * summary: { errors: number, warnings: number, infos: number, valid: boolean },
30
+ * }
31
+ * ```
32
+ *
33
+ * Throws a JS `Error` if the argument is not a string.
34
+ * @param {string} xml
35
+ * @returns {any}
36
+ */
37
+ export function validate(xml) {
38
+ const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
39
+ const len0 = WASM_VECTOR_LEN;
40
+ const ret = wasm.validate(ptr0, len0);
41
+ if (ret[2]) {
42
+ throw takeFromExternrefTable0(ret[1]);
43
+ }
44
+ return takeFromExternrefTable0(ret[0]);
45
+ }
46
+
47
+ /**
48
+ * Validate a VAST XML string with caller-supplied options.
49
+ *
50
+ * `options` is a plain JS object with optional fields:
51
+ * ```ts
52
+ * {
53
+ * wrapper_depth?: number,
54
+ * max_wrapper_depth?: number,
55
+ * rule_overrides?: Record<string, "error" | "warning" | "info" | "off">,
56
+ * }
57
+ * ```
58
+ * @param {string} xml
59
+ * @param {any} options
60
+ * @returns {any}
61
+ */
62
+ export function validateWithOptions(xml, options) {
63
+ const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
64
+ const len0 = WASM_VECTOR_LEN;
65
+ const ret = wasm.validateWithOptions(ptr0, len0, options);
66
+ if (ret[2]) {
67
+ throw takeFromExternrefTable0(ret[1]);
68
+ }
69
+ return takeFromExternrefTable0(ret[0]);
70
+ }
71
+ export function __wbg_Error_2e59b1b37a9a34c3(arg0, arg1) {
72
+ const ret = Error(getStringFromWasm0(arg0, arg1));
73
+ return ret;
74
+ }
75
+ export function __wbg_Number_e6ffdb596c888833(arg0) {
76
+ const ret = Number(arg0);
77
+ return ret;
78
+ }
79
+ export function __wbg_String_8564e559799eccda(arg0, arg1) {
80
+ const ret = String(arg1);
81
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
82
+ const len1 = WASM_VECTOR_LEN;
83
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
84
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
85
+ }
86
+ export function __wbg___wbindgen_boolean_get_a86c216575a75c30(arg0) {
87
+ const v = arg0;
88
+ const ret = typeof(v) === 'boolean' ? v : undefined;
89
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
90
+ }
91
+ export function __wbg___wbindgen_debug_string_dd5d2d07ce9e6c57(arg0, arg1) {
92
+ const ret = debugString(arg1);
93
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
94
+ const len1 = WASM_VECTOR_LEN;
95
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
96
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
97
+ }
98
+ export function __wbg___wbindgen_in_4bd7a57e54337366(arg0, arg1) {
99
+ const ret = arg0 in arg1;
100
+ return ret;
101
+ }
102
+ export function __wbg___wbindgen_is_function_49868bde5eb1e745(arg0) {
103
+ const ret = typeof(arg0) === 'function';
104
+ return ret;
105
+ }
106
+ export function __wbg___wbindgen_is_null_344c8750a8525473(arg0) {
107
+ const ret = arg0 === null;
108
+ return ret;
109
+ }
110
+ export function __wbg___wbindgen_is_object_40c5a80572e8f9d3(arg0) {
111
+ const val = arg0;
112
+ const ret = typeof(val) === 'object' && val !== null;
113
+ return ret;
114
+ }
115
+ export function __wbg___wbindgen_is_undefined_c0cca72b82b86f4d(arg0) {
116
+ const ret = arg0 === undefined;
117
+ return ret;
118
+ }
119
+ export function __wbg___wbindgen_jsval_loose_eq_3a72ae764d46d944(arg0, arg1) {
120
+ const ret = arg0 == arg1;
121
+ return ret;
122
+ }
123
+ export function __wbg___wbindgen_number_get_7579aab02a8a620c(arg0, arg1) {
124
+ const obj = arg1;
125
+ const ret = typeof(obj) === 'number' ? obj : undefined;
126
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
127
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
128
+ }
129
+ export function __wbg___wbindgen_string_get_914df97fcfa788f2(arg0, arg1) {
130
+ const obj = arg1;
131
+ const ret = typeof(obj) === 'string' ? obj : undefined;
132
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
133
+ var len1 = WASM_VECTOR_LEN;
134
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
135
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
136
+ }
137
+ export function __wbg___wbindgen_throw_81fc77679af83bc6(arg0, arg1) {
138
+ throw new Error(getStringFromWasm0(arg0, arg1));
139
+ }
140
+ export function __wbg_call_7f2987183bb62793() { return handleError(function (arg0, arg1) {
141
+ const ret = arg0.call(arg1);
142
+ return ret;
143
+ }, arguments); }
144
+ export function __wbg_done_547d467e97529006(arg0) {
145
+ const ret = arg0.done;
146
+ return ret;
147
+ }
148
+ export function __wbg_entries_616b1a459b85be0b(arg0) {
149
+ const ret = Object.entries(arg0);
150
+ return ret;
151
+ }
152
+ export function __wbg_get_4848e350b40afc16(arg0, arg1) {
153
+ const ret = arg0[arg1 >>> 0];
154
+ return ret;
155
+ }
156
+ export function __wbg_get_ed0642c4b9d31ddf() { return handleError(function (arg0, arg1) {
157
+ const ret = Reflect.get(arg0, arg1);
158
+ return ret;
159
+ }, arguments); }
160
+ export function __wbg_get_unchecked_7d7babe32e9e6a54(arg0, arg1) {
161
+ const ret = arg0[arg1 >>> 0];
162
+ return ret;
163
+ }
164
+ export function __wbg_get_with_ref_key_6412cf3094599694(arg0, arg1) {
165
+ const ret = arg0[arg1];
166
+ return ret;
167
+ }
168
+ export function __wbg_instanceof_ArrayBuffer_ff7c1337a5e3b33a(arg0) {
169
+ let result;
170
+ try {
171
+ result = arg0 instanceof ArrayBuffer;
172
+ } catch (_) {
173
+ result = false;
174
+ }
175
+ const ret = result;
176
+ return ret;
177
+ }
178
+ export function __wbg_instanceof_Uint8Array_4b8da683deb25d72(arg0) {
179
+ let result;
180
+ try {
181
+ result = arg0 instanceof Uint8Array;
182
+ } catch (_) {
183
+ result = false;
184
+ }
185
+ const ret = result;
186
+ return ret;
187
+ }
188
+ export function __wbg_isSafeInteger_ea83862ba994770c(arg0) {
189
+ const ret = Number.isSafeInteger(arg0);
190
+ return ret;
191
+ }
192
+ export function __wbg_iterator_de403ef31815a3e6() {
193
+ const ret = Symbol.iterator;
194
+ return ret;
195
+ }
196
+ export function __wbg_length_0c32cb8543c8e4c8(arg0) {
197
+ const ret = arg0.length;
198
+ return ret;
199
+ }
200
+ export function __wbg_length_6e821edde497a532(arg0) {
201
+ const ret = arg0.length;
202
+ return ret;
203
+ }
204
+ export function __wbg_new_4f9fafbb3909af72() {
205
+ const ret = new Object();
206
+ return ret;
207
+ }
208
+ export function __wbg_new_a560378ea1240b14(arg0) {
209
+ const ret = new Uint8Array(arg0);
210
+ return ret;
211
+ }
212
+ export function __wbg_new_f3c9df4f38f3f798() {
213
+ const ret = new Array();
214
+ return ret;
215
+ }
216
+ export function __wbg_next_01132ed6134b8ef5(arg0) {
217
+ const ret = arg0.next;
218
+ return ret;
219
+ }
220
+ export function __wbg_next_b3713ec761a9dbfd() { return handleError(function (arg0) {
221
+ const ret = arg0.next();
222
+ return ret;
223
+ }, arguments); }
224
+ export function __wbg_prototypesetcall_3e05eb9545565046(arg0, arg1, arg2) {
225
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
226
+ }
227
+ export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
228
+ arg0[arg1] = arg2;
229
+ }
230
+ export function __wbg_set_6c60b2e8ad0e9383(arg0, arg1, arg2) {
231
+ arg0[arg1 >>> 0] = arg2;
232
+ }
233
+ export function __wbg_value_7f6052747ccf940f(arg0) {
234
+ const ret = arg0.value;
235
+ return ret;
236
+ }
237
+ export function __wbindgen_cast_0000000000000001(arg0) {
238
+ // Cast intrinsic for `F64 -> Externref`.
239
+ const ret = arg0;
240
+ return ret;
241
+ }
242
+ export function __wbindgen_cast_0000000000000002(arg0, arg1) {
243
+ // Cast intrinsic for `Ref(String) -> Externref`.
244
+ const ret = getStringFromWasm0(arg0, arg1);
245
+ return ret;
246
+ }
247
+ export function __wbindgen_cast_0000000000000003(arg0) {
248
+ // Cast intrinsic for `U64 -> Externref`.
249
+ const ret = BigInt.asUintN(64, arg0);
250
+ return ret;
251
+ }
252
+ export function __wbindgen_init_externref_table() {
253
+ const table = wasm.__wbindgen_externrefs;
254
+ const offset = table.grow(4);
255
+ table.set(0, undefined);
256
+ table.set(offset + 0, undefined);
257
+ table.set(offset + 1, null);
258
+ table.set(offset + 2, true);
259
+ table.set(offset + 3, false);
260
+ }
261
+ function addToExternrefTable0(obj) {
262
+ const idx = wasm.__externref_table_alloc();
263
+ wasm.__wbindgen_externrefs.set(idx, obj);
264
+ return idx;
265
+ }
266
+
267
+ function debugString(val) {
268
+ // primitive types
269
+ const type = typeof val;
270
+ if (type == 'number' || type == 'boolean' || val == null) {
271
+ return `${val}`;
272
+ }
273
+ if (type == 'string') {
274
+ return `"${val}"`;
275
+ }
276
+ if (type == 'symbol') {
277
+ const description = val.description;
278
+ if (description == null) {
279
+ return 'Symbol';
280
+ } else {
281
+ return `Symbol(${description})`;
282
+ }
283
+ }
284
+ if (type == 'function') {
285
+ const name = val.name;
286
+ if (typeof name == 'string' && name.length > 0) {
287
+ return `Function(${name})`;
288
+ } else {
289
+ return 'Function';
290
+ }
291
+ }
292
+ // objects
293
+ if (Array.isArray(val)) {
294
+ const length = val.length;
295
+ let debug = '[';
296
+ if (length > 0) {
297
+ debug += debugString(val[0]);
298
+ }
299
+ for(let i = 1; i < length; i++) {
300
+ debug += ', ' + debugString(val[i]);
301
+ }
302
+ debug += ']';
303
+ return debug;
304
+ }
305
+ // Test for built-in
306
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
307
+ let className;
308
+ if (builtInMatches && builtInMatches.length > 1) {
309
+ className = builtInMatches[1];
310
+ } else {
311
+ // Failed to match the standard '[object ClassName]'
312
+ return toString.call(val);
313
+ }
314
+ if (className == 'Object') {
315
+ // we're a user defined class or Object
316
+ // JSON.stringify avoids problems with cycles, and is generally much
317
+ // easier than looping through ownProperties of `val`.
318
+ try {
319
+ return 'Object(' + JSON.stringify(val) + ')';
320
+ } catch (_) {
321
+ return 'Object';
322
+ }
323
+ }
324
+ // errors
325
+ if (val instanceof Error) {
326
+ return `${val.name}: ${val.message}\n${val.stack}`;
327
+ }
328
+ // TODO we could test for more things here, like `Set`s and `Map`s.
329
+ return className;
330
+ }
331
+
332
+ function getArrayU8FromWasm0(ptr, len) {
333
+ ptr = ptr >>> 0;
334
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
335
+ }
336
+
337
+ let cachedDataViewMemory0 = null;
338
+ function getDataViewMemory0() {
339
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
340
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
341
+ }
342
+ return cachedDataViewMemory0;
343
+ }
344
+
345
+ function getStringFromWasm0(ptr, len) {
346
+ ptr = ptr >>> 0;
347
+ return decodeText(ptr, len);
348
+ }
349
+
350
+ let cachedUint8ArrayMemory0 = null;
351
+ function getUint8ArrayMemory0() {
352
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
353
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
354
+ }
355
+ return cachedUint8ArrayMemory0;
356
+ }
357
+
358
+ function handleError(f, args) {
359
+ try {
360
+ return f.apply(this, args);
361
+ } catch (e) {
362
+ const idx = addToExternrefTable0(e);
363
+ wasm.__wbindgen_exn_store(idx);
364
+ }
365
+ }
366
+
367
+ function isLikeNone(x) {
368
+ return x === undefined || x === null;
369
+ }
370
+
371
+ function passStringToWasm0(arg, malloc, realloc) {
372
+ if (realloc === undefined) {
373
+ const buf = cachedTextEncoder.encode(arg);
374
+ const ptr = malloc(buf.length, 1) >>> 0;
375
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
376
+ WASM_VECTOR_LEN = buf.length;
377
+ return ptr;
378
+ }
379
+
380
+ let len = arg.length;
381
+ let ptr = malloc(len, 1) >>> 0;
382
+
383
+ const mem = getUint8ArrayMemory0();
384
+
385
+ let offset = 0;
386
+
387
+ for (; offset < len; offset++) {
388
+ const code = arg.charCodeAt(offset);
389
+ if (code > 0x7F) break;
390
+ mem[ptr + offset] = code;
391
+ }
392
+ if (offset !== len) {
393
+ if (offset !== 0) {
394
+ arg = arg.slice(offset);
395
+ }
396
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
397
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
398
+ const ret = cachedTextEncoder.encodeInto(arg, view);
399
+
400
+ offset += ret.written;
401
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
402
+ }
403
+
404
+ WASM_VECTOR_LEN = offset;
405
+ return ptr;
406
+ }
407
+
408
+ function takeFromExternrefTable0(idx) {
409
+ const value = wasm.__wbindgen_externrefs.get(idx);
410
+ wasm.__externref_table_dealloc(idx);
411
+ return value;
412
+ }
413
+
414
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
415
+ cachedTextDecoder.decode();
416
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
417
+ let numBytesDecoded = 0;
418
+ function decodeText(ptr, len) {
419
+ numBytesDecoded += len;
420
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
421
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
422
+ cachedTextDecoder.decode();
423
+ numBytesDecoded = len;
424
+ }
425
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
426
+ }
427
+
428
+ const cachedTextEncoder = new TextEncoder();
429
+
430
+ if (!('encodeInto' in cachedTextEncoder)) {
431
+ cachedTextEncoder.encodeInto = function (arg, view) {
432
+ const buf = cachedTextEncoder.encode(arg);
433
+ view.set(buf);
434
+ return {
435
+ read: arg.length,
436
+ written: buf.length
437
+ };
438
+ };
439
+ }
440
+
441
+ let WASM_VECTOR_LEN = 0;
442
+
443
+
444
+ let wasm;
445
+ export function __wbg_set_wasm(val) {
446
+ wasm = val;
447
+ }
Binary file
@@ -0,0 +1,13 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const rules: () => [number, number, number];
5
+ export const validate: (a: number, b: number) => [number, number, number];
6
+ export const validateWithOptions: (a: number, b: number, c: any) => [number, number, number];
7
+ export const __wbindgen_malloc: (a: number, b: number) => number;
8
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
9
+ export const __wbindgen_exn_store: (a: number) => void;
10
+ export const __externref_table_alloc: () => number;
11
+ export const __wbindgen_externrefs: WebAssembly.Table;
12
+ export const __externref_table_dealloc: (a: number) => void;
13
+ export const __wbindgen_start: () => void;
@@ -0,0 +1,455 @@
1
+ /* @ts-self-types="./vastlint_wasm.d.ts" */
2
+
3
+ /**
4
+ * Returns the full rule catalog as a JS array.
5
+ *
6
+ * Each element: `{ id: string, default_severity: string, description: string }`.
7
+ * @returns {any}
8
+ */
9
+ function rules() {
10
+ const ret = wasm.rules();
11
+ if (ret[2]) {
12
+ throw takeFromExternrefTable0(ret[1]);
13
+ }
14
+ return takeFromExternrefTable0(ret[0]);
15
+ }
16
+ exports.rules = rules;
17
+
18
+ /**
19
+ * Validate a VAST XML string.
20
+ *
21
+ * Returns a plain JavaScript object shaped like:
22
+ * ```ts
23
+ * {
24
+ * version: string | null,
25
+ * issues: Array<{
26
+ * id: string,
27
+ * severity: "error" | "warning" | "info",
28
+ * message: string,
29
+ * path: string | null,
30
+ * spec_ref: string,
31
+ * }>,
32
+ * summary: { errors: number, warnings: number, infos: number, valid: boolean },
33
+ * }
34
+ * ```
35
+ *
36
+ * Throws a JS `Error` if the argument is not a string.
37
+ * @param {string} xml
38
+ * @returns {any}
39
+ */
40
+ function validate(xml) {
41
+ const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
42
+ const len0 = WASM_VECTOR_LEN;
43
+ const ret = wasm.validate(ptr0, len0);
44
+ if (ret[2]) {
45
+ throw takeFromExternrefTable0(ret[1]);
46
+ }
47
+ return takeFromExternrefTable0(ret[0]);
48
+ }
49
+ exports.validate = validate;
50
+
51
+ /**
52
+ * Validate a VAST XML string with caller-supplied options.
53
+ *
54
+ * `options` is a plain JS object with optional fields:
55
+ * ```ts
56
+ * {
57
+ * wrapper_depth?: number,
58
+ * max_wrapper_depth?: number,
59
+ * rule_overrides?: Record<string, "error" | "warning" | "info" | "off">,
60
+ * }
61
+ * ```
62
+ * @param {string} xml
63
+ * @param {any} options
64
+ * @returns {any}
65
+ */
66
+ function validateWithOptions(xml, options) {
67
+ const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
68
+ const len0 = WASM_VECTOR_LEN;
69
+ const ret = wasm.validateWithOptions(ptr0, len0, options);
70
+ if (ret[2]) {
71
+ throw takeFromExternrefTable0(ret[1]);
72
+ }
73
+ return takeFromExternrefTable0(ret[0]);
74
+ }
75
+ exports.validateWithOptions = validateWithOptions;
76
+
77
+ function __wbg_get_imports() {
78
+ const import0 = {
79
+ __proto__: null,
80
+ __wbg_Error_2e59b1b37a9a34c3: function(arg0, arg1) {
81
+ const ret = Error(getStringFromWasm0(arg0, arg1));
82
+ return ret;
83
+ },
84
+ __wbg_Number_e6ffdb596c888833: function(arg0) {
85
+ const ret = Number(arg0);
86
+ return ret;
87
+ },
88
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
89
+ const ret = String(arg1);
90
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
91
+ const len1 = WASM_VECTOR_LEN;
92
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
93
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
94
+ },
95
+ __wbg___wbindgen_boolean_get_a86c216575a75c30: function(arg0) {
96
+ const v = arg0;
97
+ const ret = typeof(v) === 'boolean' ? v : undefined;
98
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
99
+ },
100
+ __wbg___wbindgen_debug_string_dd5d2d07ce9e6c57: function(arg0, arg1) {
101
+ const ret = debugString(arg1);
102
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
103
+ const len1 = WASM_VECTOR_LEN;
104
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
105
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
106
+ },
107
+ __wbg___wbindgen_in_4bd7a57e54337366: function(arg0, arg1) {
108
+ const ret = arg0 in arg1;
109
+ return ret;
110
+ },
111
+ __wbg___wbindgen_is_function_49868bde5eb1e745: function(arg0) {
112
+ const ret = typeof(arg0) === 'function';
113
+ return ret;
114
+ },
115
+ __wbg___wbindgen_is_null_344c8750a8525473: function(arg0) {
116
+ const ret = arg0 === null;
117
+ return ret;
118
+ },
119
+ __wbg___wbindgen_is_object_40c5a80572e8f9d3: function(arg0) {
120
+ const val = arg0;
121
+ const ret = typeof(val) === 'object' && val !== null;
122
+ return ret;
123
+ },
124
+ __wbg___wbindgen_is_undefined_c0cca72b82b86f4d: function(arg0) {
125
+ const ret = arg0 === undefined;
126
+ return ret;
127
+ },
128
+ __wbg___wbindgen_jsval_loose_eq_3a72ae764d46d944: function(arg0, arg1) {
129
+ const ret = arg0 == arg1;
130
+ return ret;
131
+ },
132
+ __wbg___wbindgen_number_get_7579aab02a8a620c: function(arg0, arg1) {
133
+ const obj = arg1;
134
+ const ret = typeof(obj) === 'number' ? obj : undefined;
135
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
136
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
137
+ },
138
+ __wbg___wbindgen_string_get_914df97fcfa788f2: function(arg0, arg1) {
139
+ const obj = arg1;
140
+ const ret = typeof(obj) === 'string' ? obj : undefined;
141
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
142
+ var len1 = WASM_VECTOR_LEN;
143
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
144
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
145
+ },
146
+ __wbg___wbindgen_throw_81fc77679af83bc6: function(arg0, arg1) {
147
+ throw new Error(getStringFromWasm0(arg0, arg1));
148
+ },
149
+ __wbg_call_7f2987183bb62793: function() { return handleError(function (arg0, arg1) {
150
+ const ret = arg0.call(arg1);
151
+ return ret;
152
+ }, arguments); },
153
+ __wbg_done_547d467e97529006: function(arg0) {
154
+ const ret = arg0.done;
155
+ return ret;
156
+ },
157
+ __wbg_entries_616b1a459b85be0b: function(arg0) {
158
+ const ret = Object.entries(arg0);
159
+ return ret;
160
+ },
161
+ __wbg_get_4848e350b40afc16: function(arg0, arg1) {
162
+ const ret = arg0[arg1 >>> 0];
163
+ return ret;
164
+ },
165
+ __wbg_get_ed0642c4b9d31ddf: function() { return handleError(function (arg0, arg1) {
166
+ const ret = Reflect.get(arg0, arg1);
167
+ return ret;
168
+ }, arguments); },
169
+ __wbg_get_unchecked_7d7babe32e9e6a54: function(arg0, arg1) {
170
+ const ret = arg0[arg1 >>> 0];
171
+ return ret;
172
+ },
173
+ __wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
174
+ const ret = arg0[arg1];
175
+ return ret;
176
+ },
177
+ __wbg_instanceof_ArrayBuffer_ff7c1337a5e3b33a: function(arg0) {
178
+ let result;
179
+ try {
180
+ result = arg0 instanceof ArrayBuffer;
181
+ } catch (_) {
182
+ result = false;
183
+ }
184
+ const ret = result;
185
+ return ret;
186
+ },
187
+ __wbg_instanceof_Uint8Array_4b8da683deb25d72: function(arg0) {
188
+ let result;
189
+ try {
190
+ result = arg0 instanceof Uint8Array;
191
+ } catch (_) {
192
+ result = false;
193
+ }
194
+ const ret = result;
195
+ return ret;
196
+ },
197
+ __wbg_isSafeInteger_ea83862ba994770c: function(arg0) {
198
+ const ret = Number.isSafeInteger(arg0);
199
+ return ret;
200
+ },
201
+ __wbg_iterator_de403ef31815a3e6: function() {
202
+ const ret = Symbol.iterator;
203
+ return ret;
204
+ },
205
+ __wbg_length_0c32cb8543c8e4c8: function(arg0) {
206
+ const ret = arg0.length;
207
+ return ret;
208
+ },
209
+ __wbg_length_6e821edde497a532: function(arg0) {
210
+ const ret = arg0.length;
211
+ return ret;
212
+ },
213
+ __wbg_new_4f9fafbb3909af72: function() {
214
+ const ret = new Object();
215
+ return ret;
216
+ },
217
+ __wbg_new_a560378ea1240b14: function(arg0) {
218
+ const ret = new Uint8Array(arg0);
219
+ return ret;
220
+ },
221
+ __wbg_new_f3c9df4f38f3f798: function() {
222
+ const ret = new Array();
223
+ return ret;
224
+ },
225
+ __wbg_next_01132ed6134b8ef5: function(arg0) {
226
+ const ret = arg0.next;
227
+ return ret;
228
+ },
229
+ __wbg_next_b3713ec761a9dbfd: function() { return handleError(function (arg0) {
230
+ const ret = arg0.next();
231
+ return ret;
232
+ }, arguments); },
233
+ __wbg_prototypesetcall_3e05eb9545565046: function(arg0, arg1, arg2) {
234
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
235
+ },
236
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
237
+ arg0[arg1] = arg2;
238
+ },
239
+ __wbg_set_6c60b2e8ad0e9383: function(arg0, arg1, arg2) {
240
+ arg0[arg1 >>> 0] = arg2;
241
+ },
242
+ __wbg_value_7f6052747ccf940f: function(arg0) {
243
+ const ret = arg0.value;
244
+ return ret;
245
+ },
246
+ __wbindgen_cast_0000000000000001: function(arg0) {
247
+ // Cast intrinsic for `F64 -> Externref`.
248
+ const ret = arg0;
249
+ return ret;
250
+ },
251
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
252
+ // Cast intrinsic for `Ref(String) -> Externref`.
253
+ const ret = getStringFromWasm0(arg0, arg1);
254
+ return ret;
255
+ },
256
+ __wbindgen_cast_0000000000000003: function(arg0) {
257
+ // Cast intrinsic for `U64 -> Externref`.
258
+ const ret = BigInt.asUintN(64, arg0);
259
+ return ret;
260
+ },
261
+ __wbindgen_init_externref_table: function() {
262
+ const table = wasm.__wbindgen_externrefs;
263
+ const offset = table.grow(4);
264
+ table.set(0, undefined);
265
+ table.set(offset + 0, undefined);
266
+ table.set(offset + 1, null);
267
+ table.set(offset + 2, true);
268
+ table.set(offset + 3, false);
269
+ },
270
+ };
271
+ return {
272
+ __proto__: null,
273
+ "./vastlint_wasm_bg.js": import0,
274
+ };
275
+ }
276
+
277
+ function addToExternrefTable0(obj) {
278
+ const idx = wasm.__externref_table_alloc();
279
+ wasm.__wbindgen_externrefs.set(idx, obj);
280
+ return idx;
281
+ }
282
+
283
+ function debugString(val) {
284
+ // primitive types
285
+ const type = typeof val;
286
+ if (type == 'number' || type == 'boolean' || val == null) {
287
+ return `${val}`;
288
+ }
289
+ if (type == 'string') {
290
+ return `"${val}"`;
291
+ }
292
+ if (type == 'symbol') {
293
+ const description = val.description;
294
+ if (description == null) {
295
+ return 'Symbol';
296
+ } else {
297
+ return `Symbol(${description})`;
298
+ }
299
+ }
300
+ if (type == 'function') {
301
+ const name = val.name;
302
+ if (typeof name == 'string' && name.length > 0) {
303
+ return `Function(${name})`;
304
+ } else {
305
+ return 'Function';
306
+ }
307
+ }
308
+ // objects
309
+ if (Array.isArray(val)) {
310
+ const length = val.length;
311
+ let debug = '[';
312
+ if (length > 0) {
313
+ debug += debugString(val[0]);
314
+ }
315
+ for(let i = 1; i < length; i++) {
316
+ debug += ', ' + debugString(val[i]);
317
+ }
318
+ debug += ']';
319
+ return debug;
320
+ }
321
+ // Test for built-in
322
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
323
+ let className;
324
+ if (builtInMatches && builtInMatches.length > 1) {
325
+ className = builtInMatches[1];
326
+ } else {
327
+ // Failed to match the standard '[object ClassName]'
328
+ return toString.call(val);
329
+ }
330
+ if (className == 'Object') {
331
+ // we're a user defined class or Object
332
+ // JSON.stringify avoids problems with cycles, and is generally much
333
+ // easier than looping through ownProperties of `val`.
334
+ try {
335
+ return 'Object(' + JSON.stringify(val) + ')';
336
+ } catch (_) {
337
+ return 'Object';
338
+ }
339
+ }
340
+ // errors
341
+ if (val instanceof Error) {
342
+ return `${val.name}: ${val.message}\n${val.stack}`;
343
+ }
344
+ // TODO we could test for more things here, like `Set`s and `Map`s.
345
+ return className;
346
+ }
347
+
348
+ function getArrayU8FromWasm0(ptr, len) {
349
+ ptr = ptr >>> 0;
350
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
351
+ }
352
+
353
+ let cachedDataViewMemory0 = null;
354
+ function getDataViewMemory0() {
355
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
356
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
357
+ }
358
+ return cachedDataViewMemory0;
359
+ }
360
+
361
+ function getStringFromWasm0(ptr, len) {
362
+ ptr = ptr >>> 0;
363
+ return decodeText(ptr, len);
364
+ }
365
+
366
+ let cachedUint8ArrayMemory0 = null;
367
+ function getUint8ArrayMemory0() {
368
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
369
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
370
+ }
371
+ return cachedUint8ArrayMemory0;
372
+ }
373
+
374
+ function handleError(f, args) {
375
+ try {
376
+ return f.apply(this, args);
377
+ } catch (e) {
378
+ const idx = addToExternrefTable0(e);
379
+ wasm.__wbindgen_exn_store(idx);
380
+ }
381
+ }
382
+
383
+ function isLikeNone(x) {
384
+ return x === undefined || x === null;
385
+ }
386
+
387
+ function passStringToWasm0(arg, malloc, realloc) {
388
+ if (realloc === undefined) {
389
+ const buf = cachedTextEncoder.encode(arg);
390
+ const ptr = malloc(buf.length, 1) >>> 0;
391
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
392
+ WASM_VECTOR_LEN = buf.length;
393
+ return ptr;
394
+ }
395
+
396
+ let len = arg.length;
397
+ let ptr = malloc(len, 1) >>> 0;
398
+
399
+ const mem = getUint8ArrayMemory0();
400
+
401
+ let offset = 0;
402
+
403
+ for (; offset < len; offset++) {
404
+ const code = arg.charCodeAt(offset);
405
+ if (code > 0x7F) break;
406
+ mem[ptr + offset] = code;
407
+ }
408
+ if (offset !== len) {
409
+ if (offset !== 0) {
410
+ arg = arg.slice(offset);
411
+ }
412
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
413
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
414
+ const ret = cachedTextEncoder.encodeInto(arg, view);
415
+
416
+ offset += ret.written;
417
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
418
+ }
419
+
420
+ WASM_VECTOR_LEN = offset;
421
+ return ptr;
422
+ }
423
+
424
+ function takeFromExternrefTable0(idx) {
425
+ const value = wasm.__wbindgen_externrefs.get(idx);
426
+ wasm.__externref_table_dealloc(idx);
427
+ return value;
428
+ }
429
+
430
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
431
+ cachedTextDecoder.decode();
432
+ function decodeText(ptr, len) {
433
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
434
+ }
435
+
436
+ const cachedTextEncoder = new TextEncoder();
437
+
438
+ if (!('encodeInto' in cachedTextEncoder)) {
439
+ cachedTextEncoder.encodeInto = function (arg, view) {
440
+ const buf = cachedTextEncoder.encode(arg);
441
+ view.set(buf);
442
+ return {
443
+ read: arg.length,
444
+ written: buf.length
445
+ };
446
+ };
447
+ }
448
+
449
+ let WASM_VECTOR_LEN = 0;
450
+
451
+ const wasmPath = `${__dirname}/vastlint_wasm_bg.wasm`;
452
+ const wasmBytes = require('fs').readFileSync(wasmPath);
453
+ const wasmModule = new WebAssembly.Module(wasmBytes);
454
+ let wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
455
+ wasm.__wbindgen_start();