windmill-parser-wasm-regex 1.512.0 → 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.512.0",
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,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 });
69
67
 
70
- if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
68
+ cachedTextDecoder.decode();
69
+
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
@@ -298,6 +308,8 @@ export function parse_assets_sql(code) {
298
308
  }
299
309
  }
300
310
 
311
+ const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
312
+
301
313
  async function __wbg_load(module, imports) {
302
314
  if (typeof Response === 'function' && module instanceof Response) {
303
315
  if (typeof WebAssembly.instantiateStreaming === 'function') {
@@ -305,7 +317,9 @@ async function __wbg_load(module, imports) {
305
317
  return await WebAssembly.instantiateStreaming(module, imports);
306
318
 
307
319
  } catch (e) {
308
- 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') {
309
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);
310
324
 
311
325
  } else {
Binary file