windmill-parser-wasm-regex 1.515.1 → 1.552.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "collaborators": [
5
5
  "Ruben Fiszel <ruben@windmill.dev>"
6
6
  ],
7
- "version": "1.515.1",
7
+ "version": "1.552.1",
8
8
  "files": [
9
9
  "windmill_parser_wasm_bg.wasm",
10
10
  "windmill_parser_wasm.js",
@@ -15,4 +15,4 @@
15
15
  "sideEffects": [
16
16
  "./snippets/*"
17
17
  ]
18
- }
18
+ }
@@ -11,6 +11,7 @@ export function parse_snowflake(code: string): string;
11
11
  export function parse_mssql(code: string): string;
12
12
  export function parse_db_resource(code: string): string | undefined;
13
13
  export function parse_graphql(code: string): string;
14
+ export function parse_assets_sql(code: string): string;
14
15
 
15
16
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
16
17
 
@@ -27,6 +28,7 @@ export interface InitOutput {
27
28
  readonly parse_mssql: (a: number, b: number) => [number, number];
28
29
  readonly parse_db_resource: (a: number, b: number) => [number, number];
29
30
  readonly parse_graphql: (a: number, b: number) => [number, number];
31
+ readonly parse_assets_sql: (a: number, b: number) => [number, number];
30
32
  readonly __wbindgen_export_0: WebAssembly.Table;
31
33
  readonly __wbindgen_malloc: (a: number, b: number) => number;
32
34
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
@@ -11,20 +11,18 @@ function getUint8ArrayMemory0() {
11
11
  return cachedUint8ArrayMemory0;
12
12
  }
13
13
 
14
- const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
14
+ const cachedTextEncoder = new TextEncoder();
15
15
 
16
- const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
17
- ? function (arg, view) {
18
- return cachedTextEncoder.encodeInto(arg, view);
16
+ if (!('encodeInto' in cachedTextEncoder)) {
17
+ cachedTextEncoder.encodeInto = function (arg, view) {
18
+ const buf = cachedTextEncoder.encode(arg);
19
+ view.set(buf);
20
+ return {
21
+ read: arg.length,
22
+ written: buf.length
23
+ };
24
+ }
19
25
  }
20
- : function (arg, view) {
21
- const buf = cachedTextEncoder.encode(arg);
22
- view.set(buf);
23
- return {
24
- read: arg.length,
25
- written: buf.length
26
- };
27
- });
28
26
 
29
27
  function passStringToWasm0(arg, malloc, realloc) {
30
28
 
@@ -55,7 +53,7 @@ function passStringToWasm0(arg, malloc, realloc) {
55
53
  }
56
54
  ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
57
55
  const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
58
- const ret = encodeString(arg, view);
56
+ const ret = cachedTextEncoder.encodeInto(arg, view);
59
57
 
60
58
  offset += ret.written;
61
59
  ptr = realloc(ptr, len, offset, 1) >>> 0;
@@ -65,13 +63,25 @@ function passStringToWasm0(arg, malloc, realloc) {
65
63
  return ptr;
66
64
  }
67
65
 
68
- const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
66
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
67
+
68
+ cachedTextDecoder.decode();
69
69
 
70
- if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
70
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
71
+ let numBytesDecoded = 0;
72
+ function decodeText(ptr, len) {
73
+ numBytesDecoded += len;
74
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
75
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
76
+ cachedTextDecoder.decode();
77
+ numBytesDecoded = len;
78
+ }
79
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
80
+ }
71
81
 
72
82
  function getStringFromWasm0(ptr, len) {
73
83
  ptr = ptr >>> 0;
74
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
84
+ return decodeText(ptr, len);
75
85
  }
76
86
  /**
77
87
  * @param {string} code
@@ -279,6 +289,27 @@ export function parse_graphql(code) {
279
289
  }
280
290
  }
281
291
 
292
+ /**
293
+ * @param {string} code
294
+ * @returns {string}
295
+ */
296
+ export function parse_assets_sql(code) {
297
+ let deferred2_0;
298
+ let deferred2_1;
299
+ try {
300
+ const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
301
+ const len0 = WASM_VECTOR_LEN;
302
+ const ret = wasm.parse_assets_sql(ptr0, len0);
303
+ deferred2_0 = ret[0];
304
+ deferred2_1 = ret[1];
305
+ return getStringFromWasm0(ret[0], ret[1]);
306
+ } finally {
307
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
308
+ }
309
+ }
310
+
311
+ const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
312
+
282
313
  async function __wbg_load(module, imports) {
283
314
  if (typeof Response === 'function' && module instanceof Response) {
284
315
  if (typeof WebAssembly.instantiateStreaming === 'function') {
@@ -286,7 +317,9 @@ async function __wbg_load(module, imports) {
286
317
  return await WebAssembly.instantiateStreaming(module, imports);
287
318
 
288
319
  } catch (e) {
289
- if (module.headers.get('Content-Type') != 'application/wasm') {
320
+ const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
321
+
322
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
290
323
  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);
291
324
 
292
325
  } else {
Binary file