@arborium/gleam 2.13.0 → 2.14.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.
Files changed (3) hide show
  1. package/grammar.js +190 -187
  2. package/grammar_bg.wasm +0 -0
  3. package/package.json +1 -1
package/grammar.js CHANGED
@@ -1,129 +1,4 @@
1
- let wasm;
2
-
3
- function addHeapObject(obj) {
4
- if (heap_next === heap.length) heap.push(heap.length + 1);
5
- const idx = heap_next;
6
- heap_next = heap[idx];
7
-
8
- heap[idx] = obj;
9
- return idx;
10
- }
11
-
12
- function dropObject(idx) {
13
- if (idx < 132) return;
14
- heap[idx] = heap_next;
15
- heap_next = idx;
16
- }
17
-
18
- function getArrayJsValueFromWasm0(ptr, len) {
19
- ptr = ptr >>> 0;
20
- const mem = getDataViewMemory0();
21
- const result = [];
22
- for (let i = ptr; i < ptr + 4 * len; i += 4) {
23
- result.push(takeObject(mem.getUint32(i, true)));
24
- }
25
- return result;
26
- }
27
-
28
- let cachedDataViewMemory0 = null;
29
- function getDataViewMemory0() {
30
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
31
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
32
- }
33
- return cachedDataViewMemory0;
34
- }
35
-
36
- function getStringFromWasm0(ptr, len) {
37
- ptr = ptr >>> 0;
38
- return decodeText(ptr, len);
39
- }
40
-
41
- let cachedUint8ArrayMemory0 = null;
42
- function getUint8ArrayMemory0() {
43
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
44
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
45
- }
46
- return cachedUint8ArrayMemory0;
47
- }
48
-
49
- function getObject(idx) { return heap[idx]; }
50
-
51
- let heap = new Array(128).fill(undefined);
52
- heap.push(undefined, null, true, false);
53
-
54
- let heap_next = heap.length;
55
-
56
- function passStringToWasm0(arg, malloc, realloc) {
57
- if (realloc === undefined) {
58
- const buf = cachedTextEncoder.encode(arg);
59
- const ptr = malloc(buf.length, 1) >>> 0;
60
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
61
- WASM_VECTOR_LEN = buf.length;
62
- return ptr;
63
- }
64
-
65
- let len = arg.length;
66
- let ptr = malloc(len, 1) >>> 0;
67
-
68
- const mem = getUint8ArrayMemory0();
69
-
70
- let offset = 0;
71
-
72
- for (; offset < len; offset++) {
73
- const code = arg.charCodeAt(offset);
74
- if (code > 0x7F) break;
75
- mem[ptr + offset] = code;
76
- }
77
- if (offset !== len) {
78
- if (offset !== 0) {
79
- arg = arg.slice(offset);
80
- }
81
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
82
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
83
- const ret = cachedTextEncoder.encodeInto(arg, view);
84
-
85
- offset += ret.written;
86
- ptr = realloc(ptr, len, offset, 1) >>> 0;
87
- }
88
-
89
- WASM_VECTOR_LEN = offset;
90
- return ptr;
91
- }
92
-
93
- function takeObject(idx) {
94
- const ret = getObject(idx);
95
- dropObject(idx);
96
- return ret;
97
- }
98
-
99
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
100
- cachedTextDecoder.decode();
101
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
102
- let numBytesDecoded = 0;
103
- function decodeText(ptr, len) {
104
- numBytesDecoded += len;
105
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
106
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
107
- cachedTextDecoder.decode();
108
- numBytesDecoded = len;
109
- }
110
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
111
- }
112
-
113
- const cachedTextEncoder = new TextEncoder();
114
-
115
- if (!('encodeInto' in cachedTextEncoder)) {
116
- cachedTextEncoder.encodeInto = function (arg, view) {
117
- const buf = cachedTextEncoder.encode(arg);
118
- view.set(buf);
119
- return {
120
- read: arg.length,
121
- written: buf.length
122
- };
123
- }
124
- }
125
-
126
- let WASM_VECTOR_LEN = 0;
1
+ /* @ts-self-types="./arborium_gleam_plugin.d.ts" */
127
2
 
128
3
  /**
129
4
  * Cancels an ongoing parse operation.
@@ -249,7 +124,183 @@ export function set_text(session, text) {
249
124
  wasm.set_text(session, ptr0, len0);
250
125
  }
251
126
 
252
- const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
127
+ function __wbg_get_imports() {
128
+ const import0 = {
129
+ __proto__: null,
130
+ __wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
131
+ throw new Error(getStringFromWasm0(arg0, arg1));
132
+ },
133
+ __wbg_new_a70fbab9066b301f: function() {
134
+ const ret = new Array();
135
+ return addHeapObject(ret);
136
+ },
137
+ __wbg_new_ab79df5bd7c26067: function() {
138
+ const ret = new Object();
139
+ return addHeapObject(ret);
140
+ },
141
+ __wbg_set_282384002438957f: function(arg0, arg1, arg2) {
142
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
143
+ },
144
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
145
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
146
+ },
147
+ __wbindgen_cast_0000000000000001: function(arg0) {
148
+ // Cast intrinsic for `F64 -> Externref`.
149
+ const ret = arg0;
150
+ return addHeapObject(ret);
151
+ },
152
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
153
+ // Cast intrinsic for `Ref(String) -> Externref`.
154
+ const ret = getStringFromWasm0(arg0, arg1);
155
+ return addHeapObject(ret);
156
+ },
157
+ __wbindgen_object_clone_ref: function(arg0) {
158
+ const ret = getObject(arg0);
159
+ return addHeapObject(ret);
160
+ },
161
+ __wbindgen_object_drop_ref: function(arg0) {
162
+ takeObject(arg0);
163
+ },
164
+ };
165
+ return {
166
+ __proto__: null,
167
+ "./arborium_gleam_plugin_bg.js": import0,
168
+ };
169
+ }
170
+
171
+ function addHeapObject(obj) {
172
+ if (heap_next === heap.length) heap.push(heap.length + 1);
173
+ const idx = heap_next;
174
+ heap_next = heap[idx];
175
+
176
+ heap[idx] = obj;
177
+ return idx;
178
+ }
179
+
180
+ function dropObject(idx) {
181
+ if (idx < 1028) return;
182
+ heap[idx] = heap_next;
183
+ heap_next = idx;
184
+ }
185
+
186
+ function getArrayJsValueFromWasm0(ptr, len) {
187
+ ptr = ptr >>> 0;
188
+ const mem = getDataViewMemory0();
189
+ const result = [];
190
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
191
+ result.push(takeObject(mem.getUint32(i, true)));
192
+ }
193
+ return result;
194
+ }
195
+
196
+ let cachedDataViewMemory0 = null;
197
+ function getDataViewMemory0() {
198
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
199
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
200
+ }
201
+ return cachedDataViewMemory0;
202
+ }
203
+
204
+ function getStringFromWasm0(ptr, len) {
205
+ ptr = ptr >>> 0;
206
+ return decodeText(ptr, len);
207
+ }
208
+
209
+ let cachedUint8ArrayMemory0 = null;
210
+ function getUint8ArrayMemory0() {
211
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
212
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
213
+ }
214
+ return cachedUint8ArrayMemory0;
215
+ }
216
+
217
+ function getObject(idx) { return heap[idx]; }
218
+
219
+ let heap = new Array(1024).fill(undefined);
220
+ heap.push(undefined, null, true, false);
221
+
222
+ let heap_next = heap.length;
223
+
224
+ function passStringToWasm0(arg, malloc, realloc) {
225
+ if (realloc === undefined) {
226
+ const buf = cachedTextEncoder.encode(arg);
227
+ const ptr = malloc(buf.length, 1) >>> 0;
228
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
229
+ WASM_VECTOR_LEN = buf.length;
230
+ return ptr;
231
+ }
232
+
233
+ let len = arg.length;
234
+ let ptr = malloc(len, 1) >>> 0;
235
+
236
+ const mem = getUint8ArrayMemory0();
237
+
238
+ let offset = 0;
239
+
240
+ for (; offset < len; offset++) {
241
+ const code = arg.charCodeAt(offset);
242
+ if (code > 0x7F) break;
243
+ mem[ptr + offset] = code;
244
+ }
245
+ if (offset !== len) {
246
+ if (offset !== 0) {
247
+ arg = arg.slice(offset);
248
+ }
249
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
250
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
251
+ const ret = cachedTextEncoder.encodeInto(arg, view);
252
+
253
+ offset += ret.written;
254
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
255
+ }
256
+
257
+ WASM_VECTOR_LEN = offset;
258
+ return ptr;
259
+ }
260
+
261
+ function takeObject(idx) {
262
+ const ret = getObject(idx);
263
+ dropObject(idx);
264
+ return ret;
265
+ }
266
+
267
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
268
+ cachedTextDecoder.decode();
269
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
270
+ let numBytesDecoded = 0;
271
+ function decodeText(ptr, len) {
272
+ numBytesDecoded += len;
273
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
274
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
275
+ cachedTextDecoder.decode();
276
+ numBytesDecoded = len;
277
+ }
278
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
279
+ }
280
+
281
+ const cachedTextEncoder = new TextEncoder();
282
+
283
+ if (!('encodeInto' in cachedTextEncoder)) {
284
+ cachedTextEncoder.encodeInto = function (arg, view) {
285
+ const buf = cachedTextEncoder.encode(arg);
286
+ view.set(buf);
287
+ return {
288
+ read: arg.length,
289
+ written: buf.length
290
+ };
291
+ };
292
+ }
293
+
294
+ let WASM_VECTOR_LEN = 0;
295
+
296
+ let wasmModule, wasm;
297
+ function __wbg_finalize_init(instance, module) {
298
+ wasm = instance.exports;
299
+ wasmModule = module;
300
+ cachedDataViewMemory0 = null;
301
+ cachedUint8ArrayMemory0 = null;
302
+ return wasm;
303
+ }
253
304
 
254
305
  async function __wbg_load(module, imports) {
255
306
  if (typeof Response === 'function' && module instanceof Response) {
@@ -257,14 +308,12 @@ async function __wbg_load(module, imports) {
257
308
  try {
258
309
  return await WebAssembly.instantiateStreaming(module, imports);
259
310
  } catch (e) {
260
- const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
311
+ const validResponse = module.ok && expectedResponseType(module.type);
261
312
 
262
313
  if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
263
314
  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);
264
315
 
265
- } else {
266
- throw e;
267
- }
316
+ } else { throw e; }
268
317
  }
269
318
  }
270
319
 
@@ -279,65 +328,20 @@ async function __wbg_load(module, imports) {
279
328
  return instance;
280
329
  }
281
330
  }
282
- }
283
331
 
284
- function __wbg_get_imports() {
285
- const imports = {};
286
- imports.wbg = {};
287
- imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
288
- throw new Error(getStringFromWasm0(arg0, arg1));
289
- };
290
- imports.wbg.__wbg_new_1ba21ce319a06297 = function() {
291
- const ret = new Object();
292
- return addHeapObject(ret);
293
- };
294
- imports.wbg.__wbg_new_25f239778d6112b9 = function() {
295
- const ret = new Array();
296
- return addHeapObject(ret);
297
- };
298
- imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
299
- getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
300
- };
301
- imports.wbg.__wbg_set_7df433eea03a5c14 = function(arg0, arg1, arg2) {
302
- getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
303
- };
304
- imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
305
- // Cast intrinsic for `Ref(String) -> Externref`.
306
- const ret = getStringFromWasm0(arg0, arg1);
307
- return addHeapObject(ret);
308
- };
309
- imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
310
- // Cast intrinsic for `F64 -> Externref`.
311
- const ret = arg0;
312
- return addHeapObject(ret);
313
- };
314
- imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
315
- const ret = getObject(arg0);
316
- return addHeapObject(ret);
317
- };
318
- imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
319
- takeObject(arg0);
320
- };
321
-
322
- return imports;
323
- }
324
-
325
- function __wbg_finalize_init(instance, module) {
326
- wasm = instance.exports;
327
- __wbg_init.__wbindgen_wasm_module = module;
328
- cachedDataViewMemory0 = null;
329
- cachedUint8ArrayMemory0 = null;
330
-
331
-
332
-
333
- return wasm;
332
+ function expectedResponseType(type) {
333
+ switch (type) {
334
+ case 'basic': case 'cors': case 'default': return true;
335
+ }
336
+ return false;
337
+ }
334
338
  }
335
339
 
336
340
  function initSync(module) {
337
341
  if (wasm !== undefined) return wasm;
338
342
 
339
343
 
340
- if (typeof module !== 'undefined') {
344
+ if (module !== undefined) {
341
345
  if (Object.getPrototypeOf(module) === Object.prototype) {
342
346
  ({module} = module)
343
347
  } else {
@@ -357,7 +361,7 @@ async function __wbg_init(module_or_path) {
357
361
  if (wasm !== undefined) return wasm;
358
362
 
359
363
 
360
- if (typeof module_or_path !== 'undefined') {
364
+ if (module_or_path !== undefined) {
361
365
  if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
362
366
  ({module_or_path} = module_or_path)
363
367
  } else {
@@ -365,7 +369,7 @@ async function __wbg_init(module_or_path) {
365
369
  }
366
370
  }
367
371
 
368
- if (typeof module_or_path === 'undefined') {
372
+ if (module_or_path === undefined) {
369
373
  module_or_path = new URL('arborium_gleam_plugin_bg.wasm', import.meta.url);
370
374
  }
371
375
  const imports = __wbg_get_imports();
@@ -379,5 +383,4 @@ async function __wbg_init(module_or_path) {
379
383
  return __wbg_finalize_init(instance, module);
380
384
  }
381
385
 
382
- export { initSync };
383
- export default __wbg_init;
386
+ export { initSync, __wbg_init as default };
package/grammar_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -42,5 +42,5 @@
42
42
  },
43
43
  "sideEffects": false,
44
44
  "type": "module",
45
- "version": "2.13.0"
45
+ "version": "2.14.0"
46
46
  }