@guanmingchiu/sqlparser-ts 0.60.0-rc3

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.
@@ -0,0 +1,19 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const format_sql: (a: number, b: number, c: number, d: number) => [number, number, number, number];
5
+ export const get_supported_dialects: () => any;
6
+ export const init: () => void;
7
+ export const parse_sql: (a: number, b: number, c: number, d: number) => [number, number, number];
8
+ export const parse_sql_to_json_string: (a: number, b: number, c: number, d: number) => [number, number, number, number];
9
+ export const parse_sql_to_string: (a: number, b: number, c: number, d: number) => [number, number, number, number];
10
+ export const parse_sql_with_options: (a: number, b: number, c: number, d: number, e: any) => [number, number, number];
11
+ export const validate_sql: (a: number, b: number, c: number, d: number) => [number, number, number];
12
+ export const __wbindgen_malloc: (a: number, b: number) => number;
13
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
14
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
15
+ export const __wbindgen_exn_store: (a: number) => void;
16
+ export const __externref_table_alloc: () => number;
17
+ export const __wbindgen_externrefs: WebAssembly.Table;
18
+ export const __externref_table_dealloc: (a: number) => void;
19
+ export const __wbindgen_start: () => void;
@@ -0,0 +1,628 @@
1
+ /* @ts-self-types="./sqlparser_rs_wasm.d.ts" */
2
+
3
+ /**
4
+ * Format SQL by parsing and regenerating it (round-trip)
5
+ * @param {string} dialect
6
+ * @param {string} sql
7
+ * @returns {string}
8
+ */
9
+ export function format_sql(dialect, sql) {
10
+ let deferred4_0;
11
+ let deferred4_1;
12
+ try {
13
+ const ptr0 = passStringToWasm0(dialect, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
14
+ const len0 = WASM_VECTOR_LEN;
15
+ const ptr1 = passStringToWasm0(sql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
16
+ const len1 = WASM_VECTOR_LEN;
17
+ const ret = wasm.format_sql(ptr0, len0, ptr1, len1);
18
+ var ptr3 = ret[0];
19
+ var len3 = ret[1];
20
+ if (ret[3]) {
21
+ ptr3 = 0; len3 = 0;
22
+ throw takeFromExternrefTable0(ret[2]);
23
+ }
24
+ deferred4_0 = ptr3;
25
+ deferred4_1 = len3;
26
+ return getStringFromWasm0(ptr3, len3);
27
+ } finally {
28
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
29
+ }
30
+ }
31
+
32
+ /**
33
+ * Get a list of all supported dialect names
34
+ * @returns {any}
35
+ */
36
+ export function get_supported_dialects() {
37
+ const ret = wasm.get_supported_dialects();
38
+ return ret;
39
+ }
40
+
41
+ export function init() {
42
+ wasm.init();
43
+ }
44
+
45
+ /**
46
+ * Parse SQL and return the AST as a JSON value
47
+ * @param {string} dialect
48
+ * @param {string} sql
49
+ * @returns {any}
50
+ */
51
+ export function parse_sql(dialect, sql) {
52
+ const ptr0 = passStringToWasm0(dialect, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
53
+ const len0 = WASM_VECTOR_LEN;
54
+ const ptr1 = passStringToWasm0(sql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
55
+ const len1 = WASM_VECTOR_LEN;
56
+ const ret = wasm.parse_sql(ptr0, len0, ptr1, len1);
57
+ if (ret[2]) {
58
+ throw takeFromExternrefTable0(ret[1]);
59
+ }
60
+ return takeFromExternrefTable0(ret[0]);
61
+ }
62
+
63
+ /**
64
+ * Parse SQL and return the AST as a JSON string
65
+ * @param {string} dialect
66
+ * @param {string} sql
67
+ * @returns {string}
68
+ */
69
+ export function parse_sql_to_json_string(dialect, sql) {
70
+ let deferred4_0;
71
+ let deferred4_1;
72
+ try {
73
+ const ptr0 = passStringToWasm0(dialect, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
74
+ const len0 = WASM_VECTOR_LEN;
75
+ const ptr1 = passStringToWasm0(sql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
76
+ const len1 = WASM_VECTOR_LEN;
77
+ const ret = wasm.parse_sql_to_json_string(ptr0, len0, ptr1, len1);
78
+ var ptr3 = ret[0];
79
+ var len3 = ret[1];
80
+ if (ret[3]) {
81
+ ptr3 = 0; len3 = 0;
82
+ throw takeFromExternrefTable0(ret[2]);
83
+ }
84
+ deferred4_0 = ptr3;
85
+ deferred4_1 = len3;
86
+ return getStringFromWasm0(ptr3, len3);
87
+ } finally {
88
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Parse SQL and return a string representation of the AST
94
+ * @param {string} dialect
95
+ * @param {string} sql
96
+ * @returns {string}
97
+ */
98
+ export function parse_sql_to_string(dialect, sql) {
99
+ let deferred4_0;
100
+ let deferred4_1;
101
+ try {
102
+ const ptr0 = passStringToWasm0(dialect, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
103
+ const len0 = WASM_VECTOR_LEN;
104
+ const ptr1 = passStringToWasm0(sql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
105
+ const len1 = WASM_VECTOR_LEN;
106
+ const ret = wasm.parse_sql_to_string(ptr0, len0, ptr1, len1);
107
+ var ptr3 = ret[0];
108
+ var len3 = ret[1];
109
+ if (ret[3]) {
110
+ ptr3 = 0; len3 = 0;
111
+ throw takeFromExternrefTable0(ret[2]);
112
+ }
113
+ deferred4_0 = ptr3;
114
+ deferred4_1 = len3;
115
+ return getStringFromWasm0(ptr3, len3);
116
+ } finally {
117
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
118
+ }
119
+ }
120
+
121
+ /**
122
+ * Parse SQL with options and return the AST as a JSON value
123
+ * @param {string} dialect
124
+ * @param {string} sql
125
+ * @param {any} options
126
+ * @returns {any}
127
+ */
128
+ export function parse_sql_with_options(dialect, sql, options) {
129
+ const ptr0 = passStringToWasm0(dialect, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
130
+ const len0 = WASM_VECTOR_LEN;
131
+ const ptr1 = passStringToWasm0(sql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
132
+ const len1 = WASM_VECTOR_LEN;
133
+ const ret = wasm.parse_sql_with_options(ptr0, len0, ptr1, len1, options);
134
+ if (ret[2]) {
135
+ throw takeFromExternrefTable0(ret[1]);
136
+ }
137
+ return takeFromExternrefTable0(ret[0]);
138
+ }
139
+
140
+ /**
141
+ * Validate SQL syntax without returning the full AST
142
+ * @param {string} dialect
143
+ * @param {string} sql
144
+ * @returns {boolean}
145
+ */
146
+ export function validate_sql(dialect, sql) {
147
+ const ptr0 = passStringToWasm0(dialect, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
148
+ const len0 = WASM_VECTOR_LEN;
149
+ const ptr1 = passStringToWasm0(sql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
150
+ const len1 = WASM_VECTOR_LEN;
151
+ const ret = wasm.validate_sql(ptr0, len0, ptr1, len1);
152
+ if (ret[2]) {
153
+ throw takeFromExternrefTable0(ret[1]);
154
+ }
155
+ return ret[0] !== 0;
156
+ }
157
+
158
+ function __wbg_get_imports() {
159
+ const import0 = {
160
+ __proto__: null,
161
+ __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
162
+ const ret = Error(getStringFromWasm0(arg0, arg1));
163
+ return ret;
164
+ },
165
+ __wbg_Number_04624de7d0e8332d: function(arg0) {
166
+ const ret = Number(arg0);
167
+ return ret;
168
+ },
169
+ __wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {
170
+ const ret = String(arg1);
171
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
172
+ const len1 = WASM_VECTOR_LEN;
173
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
174
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
175
+ },
176
+ __wbg___wbindgen_bigint_get_as_i64_8fcf4ce7f1ca72a2: function(arg0, arg1) {
177
+ const v = arg1;
178
+ const ret = typeof(v) === 'bigint' ? v : undefined;
179
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
180
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
181
+ },
182
+ __wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25: function(arg0) {
183
+ const v = arg0;
184
+ const ret = typeof(v) === 'boolean' ? v : undefined;
185
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
186
+ },
187
+ __wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
188
+ const ret = debugString(arg1);
189
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
190
+ const len1 = WASM_VECTOR_LEN;
191
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
192
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
193
+ },
194
+ __wbg___wbindgen_in_47fa6863be6f2f25: function(arg0, arg1) {
195
+ const ret = arg0 in arg1;
196
+ return ret;
197
+ },
198
+ __wbg___wbindgen_is_bigint_31b12575b56f32fc: function(arg0) {
199
+ const ret = typeof(arg0) === 'bigint';
200
+ return ret;
201
+ },
202
+ __wbg___wbindgen_is_null_ac34f5003991759a: function(arg0) {
203
+ const ret = arg0 === null;
204
+ return ret;
205
+ },
206
+ __wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
207
+ const val = arg0;
208
+ const ret = typeof(val) === 'object' && val !== null;
209
+ return ret;
210
+ },
211
+ __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
212
+ const ret = arg0 === undefined;
213
+ return ret;
214
+ },
215
+ __wbg___wbindgen_jsval_eq_11888390b0186270: function(arg0, arg1) {
216
+ const ret = arg0 === arg1;
217
+ return ret;
218
+ },
219
+ __wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811: function(arg0, arg1) {
220
+ const ret = arg0 == arg1;
221
+ return ret;
222
+ },
223
+ __wbg___wbindgen_number_get_8ff4255516ccad3e: function(arg0, arg1) {
224
+ const obj = arg1;
225
+ const ret = typeof(obj) === 'number' ? obj : undefined;
226
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
227
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
228
+ },
229
+ __wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
230
+ const obj = arg1;
231
+ const ret = typeof(obj) === 'string' ? obj : undefined;
232
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
233
+ var len1 = WASM_VECTOR_LEN;
234
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
235
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
236
+ },
237
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
238
+ throw new Error(getStringFromWasm0(arg0, arg1));
239
+ },
240
+ __wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
241
+ let deferred0_0;
242
+ let deferred0_1;
243
+ try {
244
+ deferred0_0 = arg0;
245
+ deferred0_1 = arg1;
246
+ console.error(getStringFromWasm0(arg0, arg1));
247
+ } finally {
248
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
249
+ }
250
+ },
251
+ __wbg_fromCodePoint_22365db7b7d6ac39: function() { return handleError(function (arg0) {
252
+ const ret = String.fromCodePoint(arg0 >>> 0);
253
+ return ret;
254
+ }, arguments); },
255
+ __wbg_get_with_ref_key_1dc361bd10053bfe: function(arg0, arg1) {
256
+ const ret = arg0[arg1];
257
+ return ret;
258
+ },
259
+ __wbg_instanceof_ArrayBuffer_c367199e2fa2aa04: function(arg0) {
260
+ let result;
261
+ try {
262
+ result = arg0 instanceof ArrayBuffer;
263
+ } catch (_) {
264
+ result = false;
265
+ }
266
+ const ret = result;
267
+ return ret;
268
+ },
269
+ __wbg_instanceof_Uint8Array_9b9075935c74707c: function(arg0) {
270
+ let result;
271
+ try {
272
+ result = arg0 instanceof Uint8Array;
273
+ } catch (_) {
274
+ result = false;
275
+ }
276
+ const ret = result;
277
+ return ret;
278
+ },
279
+ __wbg_isSafeInteger_bfbc7332a9768d2a: function(arg0) {
280
+ const ret = Number.isSafeInteger(arg0);
281
+ return ret;
282
+ },
283
+ __wbg_length_32ed9a279acd054c: function(arg0) {
284
+ const ret = arg0.length;
285
+ return ret;
286
+ },
287
+ __wbg_new_361308b2356cecd0: function() {
288
+ const ret = new Object();
289
+ return ret;
290
+ },
291
+ __wbg_new_3eb36ae241fe6f44: function() {
292
+ const ret = new Array();
293
+ return ret;
294
+ },
295
+ __wbg_new_8a6f238a6ece86ea: function() {
296
+ const ret = new Error();
297
+ return ret;
298
+ },
299
+ __wbg_new_dd2b680c8bf6ae29: function(arg0) {
300
+ const ret = new Uint8Array(arg0);
301
+ return ret;
302
+ },
303
+ __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
304
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
305
+ },
306
+ __wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
307
+ arg0[arg1] = arg2;
308
+ },
309
+ __wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
310
+ arg0[arg1 >>> 0] = arg2;
311
+ },
312
+ __wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
313
+ const ret = arg1.stack;
314
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
315
+ const len1 = WASM_VECTOR_LEN;
316
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
317
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
318
+ },
319
+ __wbindgen_cast_0000000000000001: function(arg0) {
320
+ // Cast intrinsic for `F64 -> Externref`.
321
+ const ret = arg0;
322
+ return ret;
323
+ },
324
+ __wbindgen_cast_0000000000000002: function(arg0) {
325
+ // Cast intrinsic for `I64 -> Externref`.
326
+ const ret = arg0;
327
+ return ret;
328
+ },
329
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
330
+ // Cast intrinsic for `Ref(String) -> Externref`.
331
+ const ret = getStringFromWasm0(arg0, arg1);
332
+ return ret;
333
+ },
334
+ __wbindgen_cast_0000000000000004: function(arg0) {
335
+ // Cast intrinsic for `U64 -> Externref`.
336
+ const ret = BigInt.asUintN(64, arg0);
337
+ return ret;
338
+ },
339
+ __wbindgen_init_externref_table: function() {
340
+ const table = wasm.__wbindgen_externrefs;
341
+ const offset = table.grow(4);
342
+ table.set(0, undefined);
343
+ table.set(offset + 0, undefined);
344
+ table.set(offset + 1, null);
345
+ table.set(offset + 2, true);
346
+ table.set(offset + 3, false);
347
+ },
348
+ };
349
+ return {
350
+ __proto__: null,
351
+ "./sqlparser_rs_wasm_bg.js": import0,
352
+ };
353
+ }
354
+
355
+ function addToExternrefTable0(obj) {
356
+ const idx = wasm.__externref_table_alloc();
357
+ wasm.__wbindgen_externrefs.set(idx, obj);
358
+ return idx;
359
+ }
360
+
361
+ function debugString(val) {
362
+ // primitive types
363
+ const type = typeof val;
364
+ if (type == 'number' || type == 'boolean' || val == null) {
365
+ return `${val}`;
366
+ }
367
+ if (type == 'string') {
368
+ return `"${val}"`;
369
+ }
370
+ if (type == 'symbol') {
371
+ const description = val.description;
372
+ if (description == null) {
373
+ return 'Symbol';
374
+ } else {
375
+ return `Symbol(${description})`;
376
+ }
377
+ }
378
+ if (type == 'function') {
379
+ const name = val.name;
380
+ if (typeof name == 'string' && name.length > 0) {
381
+ return `Function(${name})`;
382
+ } else {
383
+ return 'Function';
384
+ }
385
+ }
386
+ // objects
387
+ if (Array.isArray(val)) {
388
+ const length = val.length;
389
+ let debug = '[';
390
+ if (length > 0) {
391
+ debug += debugString(val[0]);
392
+ }
393
+ for(let i = 1; i < length; i++) {
394
+ debug += ', ' + debugString(val[i]);
395
+ }
396
+ debug += ']';
397
+ return debug;
398
+ }
399
+ // Test for built-in
400
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
401
+ let className;
402
+ if (builtInMatches && builtInMatches.length > 1) {
403
+ className = builtInMatches[1];
404
+ } else {
405
+ // Failed to match the standard '[object ClassName]'
406
+ return toString.call(val);
407
+ }
408
+ if (className == 'Object') {
409
+ // we're a user defined class or Object
410
+ // JSON.stringify avoids problems with cycles, and is generally much
411
+ // easier than looping through ownProperties of `val`.
412
+ try {
413
+ return 'Object(' + JSON.stringify(val) + ')';
414
+ } catch (_) {
415
+ return 'Object';
416
+ }
417
+ }
418
+ // errors
419
+ if (val instanceof Error) {
420
+ return `${val.name}: ${val.message}\n${val.stack}`;
421
+ }
422
+ // TODO we could test for more things here, like `Set`s and `Map`s.
423
+ return className;
424
+ }
425
+
426
+ function getArrayU8FromWasm0(ptr, len) {
427
+ ptr = ptr >>> 0;
428
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
429
+ }
430
+
431
+ let cachedDataViewMemory0 = null;
432
+ function getDataViewMemory0() {
433
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
434
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
435
+ }
436
+ return cachedDataViewMemory0;
437
+ }
438
+
439
+ function getStringFromWasm0(ptr, len) {
440
+ ptr = ptr >>> 0;
441
+ return decodeText(ptr, len);
442
+ }
443
+
444
+ let cachedUint8ArrayMemory0 = null;
445
+ function getUint8ArrayMemory0() {
446
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
447
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
448
+ }
449
+ return cachedUint8ArrayMemory0;
450
+ }
451
+
452
+ function handleError(f, args) {
453
+ try {
454
+ return f.apply(this, args);
455
+ } catch (e) {
456
+ const idx = addToExternrefTable0(e);
457
+ wasm.__wbindgen_exn_store(idx);
458
+ }
459
+ }
460
+
461
+ function isLikeNone(x) {
462
+ return x === undefined || x === null;
463
+ }
464
+
465
+ function passStringToWasm0(arg, malloc, realloc) {
466
+ if (realloc === undefined) {
467
+ const buf = cachedTextEncoder.encode(arg);
468
+ const ptr = malloc(buf.length, 1) >>> 0;
469
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
470
+ WASM_VECTOR_LEN = buf.length;
471
+ return ptr;
472
+ }
473
+
474
+ let len = arg.length;
475
+ let ptr = malloc(len, 1) >>> 0;
476
+
477
+ const mem = getUint8ArrayMemory0();
478
+
479
+ let offset = 0;
480
+
481
+ for (; offset < len; offset++) {
482
+ const code = arg.charCodeAt(offset);
483
+ if (code > 0x7F) break;
484
+ mem[ptr + offset] = code;
485
+ }
486
+ if (offset !== len) {
487
+ if (offset !== 0) {
488
+ arg = arg.slice(offset);
489
+ }
490
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
491
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
492
+ const ret = cachedTextEncoder.encodeInto(arg, view);
493
+
494
+ offset += ret.written;
495
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
496
+ }
497
+
498
+ WASM_VECTOR_LEN = offset;
499
+ return ptr;
500
+ }
501
+
502
+ function takeFromExternrefTable0(idx) {
503
+ const value = wasm.__wbindgen_externrefs.get(idx);
504
+ wasm.__externref_table_dealloc(idx);
505
+ return value;
506
+ }
507
+
508
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
509
+ cachedTextDecoder.decode();
510
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
511
+ let numBytesDecoded = 0;
512
+ function decodeText(ptr, len) {
513
+ numBytesDecoded += len;
514
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
515
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
516
+ cachedTextDecoder.decode();
517
+ numBytesDecoded = len;
518
+ }
519
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
520
+ }
521
+
522
+ const cachedTextEncoder = new TextEncoder();
523
+
524
+ if (!('encodeInto' in cachedTextEncoder)) {
525
+ cachedTextEncoder.encodeInto = function (arg, view) {
526
+ const buf = cachedTextEncoder.encode(arg);
527
+ view.set(buf);
528
+ return {
529
+ read: arg.length,
530
+ written: buf.length
531
+ };
532
+ };
533
+ }
534
+
535
+ let WASM_VECTOR_LEN = 0;
536
+
537
+ let wasmModule, wasm;
538
+ function __wbg_finalize_init(instance, module) {
539
+ wasm = instance.exports;
540
+ wasmModule = module;
541
+ cachedDataViewMemory0 = null;
542
+ cachedUint8ArrayMemory0 = null;
543
+ wasm.__wbindgen_start();
544
+ return wasm;
545
+ }
546
+
547
+ async function __wbg_load(module, imports) {
548
+ if (typeof Response === 'function' && module instanceof Response) {
549
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
550
+ try {
551
+ return await WebAssembly.instantiateStreaming(module, imports);
552
+ } catch (e) {
553
+ const validResponse = module.ok && expectedResponseType(module.type);
554
+
555
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
556
+ 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);
557
+
558
+ } else { throw e; }
559
+ }
560
+ }
561
+
562
+ const bytes = await module.arrayBuffer();
563
+ return await WebAssembly.instantiate(bytes, imports);
564
+ } else {
565
+ const instance = await WebAssembly.instantiate(module, imports);
566
+
567
+ if (instance instanceof WebAssembly.Instance) {
568
+ return { instance, module };
569
+ } else {
570
+ return instance;
571
+ }
572
+ }
573
+
574
+ function expectedResponseType(type) {
575
+ switch (type) {
576
+ case 'basic': case 'cors': case 'default': return true;
577
+ }
578
+ return false;
579
+ }
580
+ }
581
+
582
+ function initSync(module) {
583
+ if (wasm !== undefined) return wasm;
584
+
585
+
586
+ if (module !== undefined) {
587
+ if (Object.getPrototypeOf(module) === Object.prototype) {
588
+ ({module} = module)
589
+ } else {
590
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
591
+ }
592
+ }
593
+
594
+ const imports = __wbg_get_imports();
595
+ if (!(module instanceof WebAssembly.Module)) {
596
+ module = new WebAssembly.Module(module);
597
+ }
598
+ const instance = new WebAssembly.Instance(module, imports);
599
+ return __wbg_finalize_init(instance, module);
600
+ }
601
+
602
+ async function __wbg_init(module_or_path) {
603
+ if (wasm !== undefined) return wasm;
604
+
605
+
606
+ if (module_or_path !== undefined) {
607
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
608
+ ({module_or_path} = module_or_path)
609
+ } else {
610
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
611
+ }
612
+ }
613
+
614
+ if (module_or_path === undefined) {
615
+ module_or_path = new URL('sqlparser_rs_wasm_bg.wasm', import.meta.url);
616
+ }
617
+ const imports = __wbg_get_imports();
618
+
619
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
620
+ module_or_path = fetch(module_or_path);
621
+ }
622
+
623
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
624
+
625
+ return __wbg_finalize_init(instance, module);
626
+ }
627
+
628
+ export { initSync, __wbg_init as default };