mini-yaml-rs 0.1.5 → 0.2.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
@@ -7,9 +7,43 @@ A minimalist, zero-copy YAML parser for Rust. Supports sequences, mappings, and
7
7
  - Zero-copy parsing (returns references to input)
8
8
  - Sequences and mappings (flow and block styles)
9
9
  - Custom tag support: `!tagname` becomes `__type: "tagname"`
10
+ - Works in both Rust backend (Tauri) and WebAssembly
11
+
12
+ ## Installation
13
+
14
+ ### Rust (Cargo)
15
+
16
+ ```toml
17
+ [dependencies]
18
+ mini-yaml-rs = "0.1"
19
+ ```
20
+
21
+ ### JavaScript/TypeScript (npm)
22
+
23
+ ```bash
24
+ npm install mini-yaml-rs
25
+ ```
26
+
27
+ ## Building
28
+
29
+ ```bash
30
+ # Build Rust library (for Tauri/backend)
31
+ make build-rust
32
+
33
+ # Build WASM for bundlers (Vite, webpack)
34
+ make build
35
+
36
+ # Build WASM for direct browser use
37
+ make build-web
38
+
39
+ # Build WASM for Node.js
40
+ make build-node
41
+ ```
10
42
 
11
43
  ## Usage
12
44
 
45
+ ### Rust
46
+
13
47
  ```rust
14
48
  use mini_yaml_rs::parse;
15
49
 
@@ -118,6 +152,50 @@ on/off # → true/false (as boolean)
118
152
  'true' # → "true" (string, quotes stripped)
119
153
  ```
120
154
 
155
+ ### JavaScript/TypeScript (WASM)
156
+
157
+ ```typescript
158
+ import init, { parseYaml, parseYamlToMx, printYaml } from 'mini-yaml-rs';
159
+
160
+ // Initialize WASM module
161
+ await init();
162
+
163
+ // Parse YAML → JavaScript object (no JSON.parse needed)
164
+ const obj = parseYaml(`
165
+ name: hello
166
+ value: 42
167
+ items:
168
+ - one
169
+ - two
170
+ `);
171
+ console.log(obj.name); // "hello"
172
+ console.log(obj.value); // 42
173
+ console.log(obj.items); // ["one", "two"]
174
+
175
+ // Convert JavaScript object → YAML string
176
+ const yaml = printYaml({
177
+ title: "My Config",
178
+ enabled: true,
179
+ settings: {
180
+ theme: "dark",
181
+ fontSize: 14
182
+ }
183
+ });
184
+ console.log(yaml);
185
+ // title: My Config
186
+ // enabled: true
187
+ // settings:
188
+ // theme: dark
189
+ // fontSize: 14
190
+
191
+ // Parse with mx transformation
192
+ const mx = parseYamlToMx(`
193
+ +setup[Settings](db://settings):
194
+ title: Settings
195
+ `);
196
+ console.log(mx["+setup"].__name); // "Settings"
197
+ console.log(mx["+setup"].__value); // "db://settings"
198
+ ```
121
199
 
122
200
  ## License
123
201
 
package/mini_yaml_rs.d.ts CHANGED
@@ -2,49 +2,19 @@
2
2
  /* eslint-disable */
3
3
 
4
4
  /**
5
- * Parse YAML string and return JSON string.
6
- * Returns a JSON string on success, or throws an error on parse failure.
5
+ * Parse YAML string and return JSON object directly.
6
+ * Returns a JavaScript object/array on success, or throws an error on parse failure.
7
7
  */
8
- export function parseYaml(input: string): string;
8
+ export function parseYaml(input: string): any;
9
9
 
10
10
  /**
11
- * Parse YAML string and return mx-formatted JSON string.
12
- * Returns a JSON string with mx transformation on success, or throws an error on parse failure.
11
+ * Parse YAML string and return mx-formatted JSON object directly.
12
+ * Returns a JavaScript object with mx transformation on success, or throws an error on parse failure.
13
13
  */
14
- export function parseYamlToMx(input: string): string;
15
-
16
- export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
17
-
18
- export interface InitOutput {
19
- readonly memory: WebAssembly.Memory;
20
- readonly parseYaml: (a: number, b: number) => [number, number, number, number];
21
- readonly parseYamlToMx: (a: number, b: number) => [number, number, number, number];
22
- readonly __wbindgen_externrefs: WebAssembly.Table;
23
- readonly __wbindgen_malloc: (a: number, b: number) => number;
24
- readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
25
- readonly __externref_table_dealloc: (a: number) => void;
26
- readonly __wbindgen_free: (a: number, b: number, c: number) => void;
27
- readonly __wbindgen_start: () => void;
28
- }
29
-
30
- export type SyncInitInput = BufferSource | WebAssembly.Module;
31
-
32
- /**
33
- * Instantiates the given `module`, which can either be bytes or
34
- * a precompiled `WebAssembly.Module`.
35
- *
36
- * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
37
- *
38
- * @returns {InitOutput}
39
- */
40
- export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
14
+ export function parseYamlToMx(input: string): any;
41
15
 
42
16
  /**
43
- * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
44
- * for everything else, calls `WebAssembly.instantiate` directly.
45
- *
46
- * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
47
- *
48
- * @returns {Promise<InitOutput>}
17
+ * Convert JSON to YAML string.
18
+ * Takes a JavaScript object/array and returns a YAML string representation.
49
19
  */
50
- export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
20
+ export function printYaml(input: any): string;
package/mini_yaml_rs.js CHANGED
@@ -1,255 +1,9 @@
1
1
  /* @ts-self-types="./mini_yaml_rs.d.ts" */
2
2
 
3
- /**
4
- * Parse YAML string and return JSON string.
5
- * Returns a JSON string on success, or throws an error on parse failure.
6
- * @param {string} input
7
- * @returns {string}
8
- */
9
- export function parseYaml(input) {
10
- let deferred3_0;
11
- let deferred3_1;
12
- try {
13
- const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
14
- const len0 = WASM_VECTOR_LEN;
15
- const ret = wasm.parseYaml(ptr0, len0);
16
- var ptr2 = ret[0];
17
- var len2 = ret[1];
18
- if (ret[3]) {
19
- ptr2 = 0; len2 = 0;
20
- throw takeFromExternrefTable0(ret[2]);
21
- }
22
- deferred3_0 = ptr2;
23
- deferred3_1 = len2;
24
- return getStringFromWasm0(ptr2, len2);
25
- } finally {
26
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
27
- }
28
- }
29
-
30
- /**
31
- * Parse YAML string and return mx-formatted JSON string.
32
- * Returns a JSON string with mx transformation on success, or throws an error on parse failure.
33
- * @param {string} input
34
- * @returns {string}
35
- */
36
- export function parseYamlToMx(input) {
37
- let deferred3_0;
38
- let deferred3_1;
39
- try {
40
- const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
41
- const len0 = WASM_VECTOR_LEN;
42
- const ret = wasm.parseYamlToMx(ptr0, len0);
43
- var ptr2 = ret[0];
44
- var len2 = ret[1];
45
- if (ret[3]) {
46
- ptr2 = 0; len2 = 0;
47
- throw takeFromExternrefTable0(ret[2]);
48
- }
49
- deferred3_0 = ptr2;
50
- deferred3_1 = len2;
51
- return getStringFromWasm0(ptr2, len2);
52
- } finally {
53
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
54
- }
55
- }
56
-
57
- function __wbg_get_imports() {
58
- const import0 = {
59
- __proto__: null,
60
- __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
61
- const ret = Error(getStringFromWasm0(arg0, arg1));
62
- return ret;
63
- },
64
- __wbindgen_init_externref_table: function() {
65
- const table = wasm.__wbindgen_externrefs;
66
- const offset = table.grow(4);
67
- table.set(0, undefined);
68
- table.set(offset + 0, undefined);
69
- table.set(offset + 1, null);
70
- table.set(offset + 2, true);
71
- table.set(offset + 3, false);
72
- },
73
- };
74
- return {
75
- __proto__: null,
76
- "./mini_yaml_rs_bg.js": import0,
77
- };
78
- }
79
-
80
- function getStringFromWasm0(ptr, len) {
81
- ptr = ptr >>> 0;
82
- return decodeText(ptr, len);
83
- }
84
-
85
- let cachedUint8ArrayMemory0 = null;
86
- function getUint8ArrayMemory0() {
87
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
88
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
89
- }
90
- return cachedUint8ArrayMemory0;
91
- }
92
-
93
- function passStringToWasm0(arg, malloc, realloc) {
94
- if (realloc === undefined) {
95
- const buf = cachedTextEncoder.encode(arg);
96
- const ptr = malloc(buf.length, 1) >>> 0;
97
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
98
- WASM_VECTOR_LEN = buf.length;
99
- return ptr;
100
- }
101
-
102
- let len = arg.length;
103
- let ptr = malloc(len, 1) >>> 0;
104
-
105
- const mem = getUint8ArrayMemory0();
106
-
107
- let offset = 0;
108
-
109
- for (; offset < len; offset++) {
110
- const code = arg.charCodeAt(offset);
111
- if (code > 0x7F) break;
112
- mem[ptr + offset] = code;
113
- }
114
- if (offset !== len) {
115
- if (offset !== 0) {
116
- arg = arg.slice(offset);
117
- }
118
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
119
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
120
- const ret = cachedTextEncoder.encodeInto(arg, view);
121
-
122
- offset += ret.written;
123
- ptr = realloc(ptr, len, offset, 1) >>> 0;
124
- }
125
-
126
- WASM_VECTOR_LEN = offset;
127
- return ptr;
128
- }
129
-
130
- function takeFromExternrefTable0(idx) {
131
- const value = wasm.__wbindgen_externrefs.get(idx);
132
- wasm.__externref_table_dealloc(idx);
133
- return value;
134
- }
135
-
136
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
137
- cachedTextDecoder.decode();
138
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
139
- let numBytesDecoded = 0;
140
- function decodeText(ptr, len) {
141
- numBytesDecoded += len;
142
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
143
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
144
- cachedTextDecoder.decode();
145
- numBytesDecoded = len;
146
- }
147
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
148
- }
149
-
150
- const cachedTextEncoder = new TextEncoder();
151
-
152
- if (!('encodeInto' in cachedTextEncoder)) {
153
- cachedTextEncoder.encodeInto = function (arg, view) {
154
- const buf = cachedTextEncoder.encode(arg);
155
- view.set(buf);
156
- return {
157
- read: arg.length,
158
- written: buf.length
159
- };
160
- };
161
- }
162
-
163
- let WASM_VECTOR_LEN = 0;
164
-
165
- let wasmModule, wasm;
166
- function __wbg_finalize_init(instance, module) {
167
- wasm = instance.exports;
168
- wasmModule = module;
169
- cachedUint8ArrayMemory0 = null;
170
- wasm.__wbindgen_start();
171
- return wasm;
172
- }
173
-
174
- async function __wbg_load(module, imports) {
175
- if (typeof Response === 'function' && module instanceof Response) {
176
- if (typeof WebAssembly.instantiateStreaming === 'function') {
177
- try {
178
- return await WebAssembly.instantiateStreaming(module, imports);
179
- } catch (e) {
180
- const validResponse = module.ok && expectedResponseType(module.type);
181
-
182
- if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
183
- console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
184
-
185
- } else { throw e; }
186
- }
187
- }
188
-
189
- const bytes = await module.arrayBuffer();
190
- return await WebAssembly.instantiate(bytes, imports);
191
- } else {
192
- const instance = await WebAssembly.instantiate(module, imports);
193
-
194
- if (instance instanceof WebAssembly.Instance) {
195
- return { instance, module };
196
- } else {
197
- return instance;
198
- }
199
- }
200
-
201
- function expectedResponseType(type) {
202
- switch (type) {
203
- case 'basic': case 'cors': case 'default': return true;
204
- }
205
- return false;
206
- }
207
- }
208
-
209
- function initSync(module) {
210
- if (wasm !== undefined) return wasm;
211
-
212
-
213
- if (module !== undefined) {
214
- if (Object.getPrototypeOf(module) === Object.prototype) {
215
- ({module} = module)
216
- } else {
217
- console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
218
- }
219
- }
220
-
221
- const imports = __wbg_get_imports();
222
- if (!(module instanceof WebAssembly.Module)) {
223
- module = new WebAssembly.Module(module);
224
- }
225
- const instance = new WebAssembly.Instance(module, imports);
226
- return __wbg_finalize_init(instance, module);
227
- }
228
-
229
- async function __wbg_init(module_or_path) {
230
- if (wasm !== undefined) return wasm;
231
-
232
-
233
- if (module_or_path !== undefined) {
234
- if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
235
- ({module_or_path} = module_or_path)
236
- } else {
237
- console.warn('using deprecated parameters for the initialization function; pass a single object instead')
238
- }
239
- }
240
-
241
- if (module_or_path === undefined) {
242
- module_or_path = new URL('mini_yaml_rs_bg.wasm', import.meta.url);
243
- }
244
- const imports = __wbg_get_imports();
245
-
246
- if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
247
- module_or_path = fetch(module_or_path);
248
- }
249
-
250
- const { instance, module } = await __wbg_load(await module_or_path, imports);
251
-
252
- return __wbg_finalize_init(instance, module);
253
- }
254
-
255
- export { initSync, __wbg_init as default };
3
+ import * as wasm from "./mini_yaml_rs_bg.wasm";
4
+ import { __wbg_set_wasm } from "./mini_yaml_rs_bg.js";
5
+ __wbg_set_wasm(wasm);
6
+ wasm.__wbindgen_start();
7
+ export {
8
+ parseYaml, parseYamlToMx, printYaml
9
+ } from "./mini_yaml_rs_bg.js";
@@ -0,0 +1,458 @@
1
+ /**
2
+ * Parse YAML string and return JSON object directly.
3
+ * Returns a JavaScript object/array on success, or throws an error on parse failure.
4
+ * @param {string} input
5
+ * @returns {any}
6
+ */
7
+ export function parseYaml(input) {
8
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
9
+ const len0 = WASM_VECTOR_LEN;
10
+ const ret = wasm.parseYaml(ptr0, len0);
11
+ if (ret[2]) {
12
+ throw takeFromExternrefTable0(ret[1]);
13
+ }
14
+ return takeFromExternrefTable0(ret[0]);
15
+ }
16
+
17
+ /**
18
+ * Parse YAML string and return mx-formatted JSON object directly.
19
+ * Returns a JavaScript object with mx transformation on success, or throws an error on parse failure.
20
+ * @param {string} input
21
+ * @returns {any}
22
+ */
23
+ export function parseYamlToMx(input) {
24
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
25
+ const len0 = WASM_VECTOR_LEN;
26
+ const ret = wasm.parseYamlToMx(ptr0, len0);
27
+ if (ret[2]) {
28
+ throw takeFromExternrefTable0(ret[1]);
29
+ }
30
+ return takeFromExternrefTable0(ret[0]);
31
+ }
32
+
33
+ /**
34
+ * Convert JSON to YAML string.
35
+ * Takes a JavaScript object/array and returns a YAML string representation.
36
+ * @param {any} input
37
+ * @returns {string}
38
+ */
39
+ export function printYaml(input) {
40
+ let deferred2_0;
41
+ let deferred2_1;
42
+ try {
43
+ const ret = wasm.printYaml(input);
44
+ var ptr1 = ret[0];
45
+ var len1 = ret[1];
46
+ if (ret[3]) {
47
+ ptr1 = 0; len1 = 0;
48
+ throw takeFromExternrefTable0(ret[2]);
49
+ }
50
+ deferred2_0 = ptr1;
51
+ deferred2_1 = len1;
52
+ return getStringFromWasm0(ptr1, len1);
53
+ } finally {
54
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
55
+ }
56
+ }
57
+ export function __wbg_Error_8c4e43fe74559d73(arg0, arg1) {
58
+ const ret = Error(getStringFromWasm0(arg0, arg1));
59
+ return ret;
60
+ }
61
+ export function __wbg_String_8f0eb39a4a4c2f66(arg0, arg1) {
62
+ const ret = String(arg1);
63
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
64
+ const len1 = WASM_VECTOR_LEN;
65
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
66
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
67
+ }
68
+ export function __wbg___wbindgen_bigint_get_as_i64_8fcf4ce7f1ca72a2(arg0, arg1) {
69
+ const v = arg1;
70
+ const ret = typeof(v) === 'bigint' ? v : undefined;
71
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
72
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
73
+ }
74
+ export function __wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25(arg0) {
75
+ const v = arg0;
76
+ const ret = typeof(v) === 'boolean' ? v : undefined;
77
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
78
+ }
79
+ export function __wbg___wbindgen_debug_string_0bc8482c6e3508ae(arg0, arg1) {
80
+ const ret = debugString(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_in_47fa6863be6f2f25(arg0, arg1) {
87
+ const ret = arg0 in arg1;
88
+ return ret;
89
+ }
90
+ export function __wbg___wbindgen_is_bigint_31b12575b56f32fc(arg0) {
91
+ const ret = typeof(arg0) === 'bigint';
92
+ return ret;
93
+ }
94
+ export function __wbg___wbindgen_is_function_0095a73b8b156f76(arg0) {
95
+ const ret = typeof(arg0) === 'function';
96
+ return ret;
97
+ }
98
+ export function __wbg___wbindgen_is_object_5ae8e5880f2c1fbd(arg0) {
99
+ const val = arg0;
100
+ const ret = typeof(val) === 'object' && val !== null;
101
+ return ret;
102
+ }
103
+ export function __wbg___wbindgen_is_string_cd444516edc5b180(arg0) {
104
+ const ret = typeof(arg0) === 'string';
105
+ return ret;
106
+ }
107
+ export function __wbg___wbindgen_jsval_eq_11888390b0186270(arg0, arg1) {
108
+ const ret = arg0 === arg1;
109
+ return ret;
110
+ }
111
+ export function __wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811(arg0, arg1) {
112
+ const ret = arg0 == arg1;
113
+ return ret;
114
+ }
115
+ export function __wbg___wbindgen_number_get_8ff4255516ccad3e(arg0, arg1) {
116
+ const obj = arg1;
117
+ const ret = typeof(obj) === 'number' ? obj : undefined;
118
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
119
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
120
+ }
121
+ export function __wbg___wbindgen_string_get_72fb696202c56729(arg0, arg1) {
122
+ const obj = arg1;
123
+ const ret = typeof(obj) === 'string' ? obj : undefined;
124
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
125
+ var len1 = WASM_VECTOR_LEN;
126
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
127
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
128
+ }
129
+ export function __wbg___wbindgen_throw_be289d5034ed271b(arg0, arg1) {
130
+ throw new Error(getStringFromWasm0(arg0, arg1));
131
+ }
132
+ export function __wbg_call_389efe28435a9388() { return handleError(function (arg0, arg1) {
133
+ const ret = arg0.call(arg1);
134
+ return ret;
135
+ }, arguments); }
136
+ export function __wbg_done_57b39ecd9addfe81(arg0) {
137
+ const ret = arg0.done;
138
+ return ret;
139
+ }
140
+ export function __wbg_entries_58c7934c745daac7(arg0) {
141
+ const ret = Object.entries(arg0);
142
+ return ret;
143
+ }
144
+ export function __wbg_get_9b94d73e6221f75c(arg0, arg1) {
145
+ const ret = arg0[arg1 >>> 0];
146
+ return ret;
147
+ }
148
+ export function __wbg_get_b3ed3ad4be2bc8ac() { return handleError(function (arg0, arg1) {
149
+ const ret = Reflect.get(arg0, arg1);
150
+ return ret;
151
+ }, arguments); }
152
+ export function __wbg_instanceof_ArrayBuffer_c367199e2fa2aa04(arg0) {
153
+ let result;
154
+ try {
155
+ result = arg0 instanceof ArrayBuffer;
156
+ } catch (_) {
157
+ result = false;
158
+ }
159
+ const ret = result;
160
+ return ret;
161
+ }
162
+ export function __wbg_instanceof_Map_53af74335dec57f4(arg0) {
163
+ let result;
164
+ try {
165
+ result = arg0 instanceof Map;
166
+ } catch (_) {
167
+ result = false;
168
+ }
169
+ const ret = result;
170
+ return ret;
171
+ }
172
+ export function __wbg_instanceof_Uint8Array_9b9075935c74707c(arg0) {
173
+ let result;
174
+ try {
175
+ result = arg0 instanceof Uint8Array;
176
+ } catch (_) {
177
+ result = false;
178
+ }
179
+ const ret = result;
180
+ return ret;
181
+ }
182
+ export function __wbg_isArray_d314bb98fcf08331(arg0) {
183
+ const ret = Array.isArray(arg0);
184
+ return ret;
185
+ }
186
+ export function __wbg_isSafeInteger_bfbc7332a9768d2a(arg0) {
187
+ const ret = Number.isSafeInteger(arg0);
188
+ return ret;
189
+ }
190
+ export function __wbg_iterator_6ff6560ca1568e55() {
191
+ const ret = Symbol.iterator;
192
+ return ret;
193
+ }
194
+ export function __wbg_length_32ed9a279acd054c(arg0) {
195
+ const ret = arg0.length;
196
+ return ret;
197
+ }
198
+ export function __wbg_length_35a7bace40f36eac(arg0) {
199
+ const ret = arg0.length;
200
+ return ret;
201
+ }
202
+ export function __wbg_new_361308b2356cecd0() {
203
+ const ret = new Object();
204
+ return ret;
205
+ }
206
+ export function __wbg_new_3eb36ae241fe6f44() {
207
+ const ret = new Array();
208
+ return ret;
209
+ }
210
+ export function __wbg_new_dca287b076112a51() {
211
+ const ret = new Map();
212
+ return ret;
213
+ }
214
+ export function __wbg_new_dd2b680c8bf6ae29(arg0) {
215
+ const ret = new Uint8Array(arg0);
216
+ return ret;
217
+ }
218
+ export function __wbg_next_3482f54c49e8af19() { return handleError(function (arg0) {
219
+ const ret = arg0.next();
220
+ return ret;
221
+ }, arguments); }
222
+ export function __wbg_next_418f80d8f5303233(arg0) {
223
+ const ret = arg0.next;
224
+ return ret;
225
+ }
226
+ export function __wbg_prototypesetcall_bdcdcc5842e4d77d(arg0, arg1, arg2) {
227
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
228
+ }
229
+ export function __wbg_set_1eb0999cf5d27fc8(arg0, arg1, arg2) {
230
+ const ret = arg0.set(arg1, arg2);
231
+ return ret;
232
+ }
233
+ export function __wbg_set_3f1d0b984ed272ed(arg0, arg1, arg2) {
234
+ arg0[arg1] = arg2;
235
+ }
236
+ export function __wbg_set_f43e577aea94465b(arg0, arg1, arg2) {
237
+ arg0[arg1 >>> 0] = arg2;
238
+ }
239
+ export function __wbg_value_0546255b415e96c1(arg0) {
240
+ const ret = arg0.value;
241
+ return ret;
242
+ }
243
+ export function __wbindgen_cast_0000000000000001(arg0) {
244
+ // Cast intrinsic for `F64 -> Externref`.
245
+ const ret = arg0;
246
+ return ret;
247
+ }
248
+ export function __wbindgen_cast_0000000000000002(arg0) {
249
+ // Cast intrinsic for `I64 -> Externref`.
250
+ const ret = arg0;
251
+ return ret;
252
+ }
253
+ export function __wbindgen_cast_0000000000000003(arg0, arg1) {
254
+ // Cast intrinsic for `Ref(String) -> Externref`.
255
+ const ret = getStringFromWasm0(arg0, arg1);
256
+ return ret;
257
+ }
258
+ export function __wbindgen_cast_0000000000000004(arg0) {
259
+ // Cast intrinsic for `U64 -> Externref`.
260
+ const ret = BigInt.asUintN(64, arg0);
261
+ return ret;
262
+ }
263
+ export function __wbindgen_init_externref_table() {
264
+ const table = wasm.__wbindgen_externrefs;
265
+ const offset = table.grow(4);
266
+ table.set(0, undefined);
267
+ table.set(offset + 0, undefined);
268
+ table.set(offset + 1, null);
269
+ table.set(offset + 2, true);
270
+ table.set(offset + 3, false);
271
+ }
272
+ function addToExternrefTable0(obj) {
273
+ const idx = wasm.__externref_table_alloc();
274
+ wasm.__wbindgen_externrefs.set(idx, obj);
275
+ return idx;
276
+ }
277
+
278
+ function debugString(val) {
279
+ // primitive types
280
+ const type = typeof val;
281
+ if (type == 'number' || type == 'boolean' || val == null) {
282
+ return `${val}`;
283
+ }
284
+ if (type == 'string') {
285
+ return `"${val}"`;
286
+ }
287
+ if (type == 'symbol') {
288
+ const description = val.description;
289
+ if (description == null) {
290
+ return 'Symbol';
291
+ } else {
292
+ return `Symbol(${description})`;
293
+ }
294
+ }
295
+ if (type == 'function') {
296
+ const name = val.name;
297
+ if (typeof name == 'string' && name.length > 0) {
298
+ return `Function(${name})`;
299
+ } else {
300
+ return 'Function';
301
+ }
302
+ }
303
+ // objects
304
+ if (Array.isArray(val)) {
305
+ const length = val.length;
306
+ let debug = '[';
307
+ if (length > 0) {
308
+ debug += debugString(val[0]);
309
+ }
310
+ for(let i = 1; i < length; i++) {
311
+ debug += ', ' + debugString(val[i]);
312
+ }
313
+ debug += ']';
314
+ return debug;
315
+ }
316
+ // Test for built-in
317
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
318
+ let className;
319
+ if (builtInMatches && builtInMatches.length > 1) {
320
+ className = builtInMatches[1];
321
+ } else {
322
+ // Failed to match the standard '[object ClassName]'
323
+ return toString.call(val);
324
+ }
325
+ if (className == 'Object') {
326
+ // we're a user defined class or Object
327
+ // JSON.stringify avoids problems with cycles, and is generally much
328
+ // easier than looping through ownProperties of `val`.
329
+ try {
330
+ return 'Object(' + JSON.stringify(val) + ')';
331
+ } catch (_) {
332
+ return 'Object';
333
+ }
334
+ }
335
+ // errors
336
+ if (val instanceof Error) {
337
+ return `${val.name}: ${val.message}\n${val.stack}`;
338
+ }
339
+ // TODO we could test for more things here, like `Set`s and `Map`s.
340
+ return className;
341
+ }
342
+
343
+ function getArrayU8FromWasm0(ptr, len) {
344
+ ptr = ptr >>> 0;
345
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
346
+ }
347
+
348
+ let cachedDataViewMemory0 = null;
349
+ function getDataViewMemory0() {
350
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
351
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
352
+ }
353
+ return cachedDataViewMemory0;
354
+ }
355
+
356
+ function getStringFromWasm0(ptr, len) {
357
+ ptr = ptr >>> 0;
358
+ return decodeText(ptr, len);
359
+ }
360
+
361
+ let cachedUint8ArrayMemory0 = null;
362
+ function getUint8ArrayMemory0() {
363
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
364
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
365
+ }
366
+ return cachedUint8ArrayMemory0;
367
+ }
368
+
369
+ function handleError(f, args) {
370
+ try {
371
+ return f.apply(this, args);
372
+ } catch (e) {
373
+ const idx = addToExternrefTable0(e);
374
+ wasm.__wbindgen_exn_store(idx);
375
+ }
376
+ }
377
+
378
+ function isLikeNone(x) {
379
+ return x === undefined || x === null;
380
+ }
381
+
382
+ function passStringToWasm0(arg, malloc, realloc) {
383
+ if (realloc === undefined) {
384
+ const buf = cachedTextEncoder.encode(arg);
385
+ const ptr = malloc(buf.length, 1) >>> 0;
386
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
387
+ WASM_VECTOR_LEN = buf.length;
388
+ return ptr;
389
+ }
390
+
391
+ let len = arg.length;
392
+ let ptr = malloc(len, 1) >>> 0;
393
+
394
+ const mem = getUint8ArrayMemory0();
395
+
396
+ let offset = 0;
397
+
398
+ for (; offset < len; offset++) {
399
+ const code = arg.charCodeAt(offset);
400
+ if (code > 0x7F) break;
401
+ mem[ptr + offset] = code;
402
+ }
403
+ if (offset !== len) {
404
+ if (offset !== 0) {
405
+ arg = arg.slice(offset);
406
+ }
407
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
408
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
409
+ const ret = cachedTextEncoder.encodeInto(arg, view);
410
+
411
+ offset += ret.written;
412
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
413
+ }
414
+
415
+ WASM_VECTOR_LEN = offset;
416
+ return ptr;
417
+ }
418
+
419
+ function takeFromExternrefTable0(idx) {
420
+ const value = wasm.__wbindgen_externrefs.get(idx);
421
+ wasm.__externref_table_dealloc(idx);
422
+ return value;
423
+ }
424
+
425
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
426
+ cachedTextDecoder.decode();
427
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
428
+ let numBytesDecoded = 0;
429
+ function decodeText(ptr, len) {
430
+ numBytesDecoded += len;
431
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
432
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
433
+ cachedTextDecoder.decode();
434
+ numBytesDecoded = len;
435
+ }
436
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
437
+ }
438
+
439
+ const cachedTextEncoder = new TextEncoder();
440
+
441
+ if (!('encodeInto' in cachedTextEncoder)) {
442
+ cachedTextEncoder.encodeInto = function (arg, view) {
443
+ const buf = cachedTextEncoder.encode(arg);
444
+ view.set(buf);
445
+ return {
446
+ read: arg.length,
447
+ written: buf.length
448
+ };
449
+ };
450
+ }
451
+
452
+ let WASM_VECTOR_LEN = 0;
453
+
454
+
455
+ let wasm;
456
+ export function __wbg_set_wasm(val) {
457
+ wasm = val;
458
+ }
Binary file
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "Shawn Xiang <xiang.elec@domain.com>"
6
6
  ],
7
7
  "description": "A minimalist, zero-copy parser for a strict subset of the YAML specification.",
8
- "version": "0.1.5",
8
+ "version": "0.2.0",
9
9
  "license": "Apache-2.0",
10
10
  "repository": {
11
11
  "type": "git",
@@ -14,12 +14,14 @@
14
14
  "files": [
15
15
  "mini_yaml_rs_bg.wasm",
16
16
  "mini_yaml_rs.js",
17
+ "mini_yaml_rs_bg.js",
17
18
  "mini_yaml_rs.d.ts"
18
19
  ],
19
20
  "main": "mini_yaml_rs.js",
20
21
  "homepage": "https://github.com/hecmay/mini-yaml-rs",
21
22
  "types": "mini_yaml_rs.d.ts",
22
23
  "sideEffects": [
24
+ "./mini_yaml_rs.js",
23
25
  "./snippets/*"
24
26
  ]
25
27
  }