@goliapkg/tiktoken-wasm 4.1.2 → 5.0.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/tiktoken_wasm.js CHANGED
@@ -24,45 +24,45 @@ export class Encoding {
24
24
  wasm.__wbg_encoding_free(ptr, 0);
25
25
  }
26
26
  /**
27
- * Count tokens without building the full token id array.
27
+ * Count tokens, recognizing special tokens.
28
28
  *
29
- * Faster than `encode(text).length` for cases where you only need the count.
29
+ * Like `count()` but special tokens (e.g. `<|endoftext|>`) are counted
30
+ * as single tokens instead of being split into sub-word pieces.
30
31
  * @param {string} text
31
32
  * @returns {number}
32
33
  */
33
- count(text) {
34
- const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
34
+ countWithSpecialTokens(text) {
35
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
35
36
  const len0 = WASM_VECTOR_LEN;
36
- const ret = wasm.encoding_count(this.__wbg_ptr, ptr0, len0);
37
+ const ret = wasm.encoding_countWithSpecialTokens(this.__wbg_ptr, ptr0, len0);
37
38
  return ret >>> 0;
38
39
  }
39
40
  /**
40
- * Count tokens, recognizing special tokens.
41
+ * Count tokens without building the full token id array.
41
42
  *
42
- * Like `count()` but special tokens (e.g. `<|endoftext|>`) are counted
43
- * as single tokens instead of being split into sub-word pieces.
43
+ * Faster than `encode(text).length` for cases where you only need the count.
44
44
  * @param {string} text
45
45
  * @returns {number}
46
46
  */
47
- countWithSpecialTokens(text) {
48
- const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
47
+ count(text) {
48
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
49
49
  const len0 = WASM_VECTOR_LEN;
50
- const ret = wasm.encoding_countWithSpecialTokens(this.__wbg_ptr, ptr0, len0);
50
+ const ret = wasm.encoding_count(this.__wbg_ptr, ptr0, len0);
51
51
  return ret >>> 0;
52
52
  }
53
53
  /**
54
54
  * Decode token ids back to a UTF-8 string.
55
55
  *
56
56
  * Uses lossy UTF-8 conversion — invalid byte sequences are replaced with U+FFFD.
57
- * @param {Uint32Array} tokens
57
+ * @param {Uint32Array | number[]} tokens
58
58
  * @returns {string}
59
59
  */
60
60
  decode(tokens) {
61
61
  let deferred2_0;
62
62
  let deferred2_1;
63
63
  try {
64
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
65
- const ptr0 = passArray32ToWasm0(tokens, wasm.__wbindgen_export2);
64
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
65
+ const ptr0 = passArray32ToWasm0(tokens, wasm.__wbindgen_export3);
66
66
  const len0 = WASM_VECTOR_LEN;
67
67
  wasm.encoding_decode(retptr, this.__wbg_ptr, ptr0, len0);
68
68
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
@@ -72,50 +72,50 @@ export class Encoding {
72
72
  return getStringFromWasm0(r0, r1);
73
73
  } finally {
74
74
  wasm.__wbindgen_add_to_stack_pointer(16);
75
- wasm.__wbindgen_export(deferred2_0, deferred2_1, 1);
75
+ wasm.__wbindgen_export2(deferred2_0, deferred2_1, 1);
76
76
  }
77
77
  }
78
78
  /**
79
- * Encode text into token ids (returns `Uint32Array` in JS).
79
+ * Encode text into token ids, recognizing special tokens.
80
80
  *
81
- * Special tokens like `<|endoftext|>` are treated as ordinary text.
82
- * Use `encodeWithSpecialTokens()` to recognize them.
81
+ * Special tokens (e.g. `<|endoftext|>`) are encoded as their designated ids
82
+ * instead of being split into sub-word pieces.
83
83
  * @param {string} text
84
84
  * @returns {Uint32Array}
85
85
  */
86
- encode(text) {
86
+ encodeWithSpecialTokens(text) {
87
87
  try {
88
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
89
- const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
88
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
89
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
90
90
  const len0 = WASM_VECTOR_LEN;
91
- wasm.encoding_encode(retptr, this.__wbg_ptr, ptr0, len0);
91
+ wasm.encoding_encodeWithSpecialTokens(retptr, this.__wbg_ptr, ptr0, len0);
92
92
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
93
93
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
94
94
  var v2 = getArrayU32FromWasm0(r0, r1).slice();
95
- wasm.__wbindgen_export(r0, r1 * 4, 4);
95
+ wasm.__wbindgen_export2(r0, r1 * 4, 4);
96
96
  return v2;
97
97
  } finally {
98
98
  wasm.__wbindgen_add_to_stack_pointer(16);
99
99
  }
100
100
  }
101
101
  /**
102
- * Encode text into token ids, recognizing special tokens.
102
+ * Encode text into token ids (returns `Uint32Array` in JS).
103
103
  *
104
- * Special tokens (e.g. `<|endoftext|>`) are encoded as their designated ids
105
- * instead of being split into sub-word pieces.
104
+ * Special tokens like `<|endoftext|>` are treated as ordinary text.
105
+ * Use `encodeWithSpecialTokens()` to recognize them.
106
106
  * @param {string} text
107
107
  * @returns {Uint32Array}
108
108
  */
109
- encodeWithSpecialTokens(text) {
109
+ encode(text) {
110
110
  try {
111
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
112
- const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
111
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
112
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
113
113
  const len0 = WASM_VECTOR_LEN;
114
- wasm.encoding_encodeWithSpecialTokens(retptr, this.__wbg_ptr, ptr0, len0);
114
+ wasm.encoding_encode(retptr, this.__wbg_ptr, ptr0, len0);
115
115
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
116
116
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
117
117
  var v2 = getArrayU32FromWasm0(r0, r1).slice();
118
- wasm.__wbindgen_export(r0, r1 * 4, 4);
118
+ wasm.__wbindgen_export2(r0, r1 * 4, 4);
119
119
  return v2;
120
120
  } finally {
121
121
  wasm.__wbindgen_add_to_stack_pointer(16);
@@ -129,7 +129,7 @@ export class Encoding {
129
129
  let deferred1_0;
130
130
  let deferred1_1;
131
131
  try {
132
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
132
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
133
133
  wasm.encoding_name(retptr, this.__wbg_ptr);
134
134
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
135
135
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
@@ -138,7 +138,7 @@ export class Encoding {
138
138
  return getStringFromWasm0(r0, r1);
139
139
  } finally {
140
140
  wasm.__wbindgen_add_to_stack_pointer(16);
141
- wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
141
+ wasm.__wbindgen_export2(deferred1_0, deferred1_1, 1);
142
142
  }
143
143
  }
144
144
  /**
@@ -185,7 +185,7 @@ export class ModelInfo {
185
185
  */
186
186
  get cachedInputPer1m() {
187
187
  try {
188
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
188
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
189
189
  wasm.modelinfo_cachedInputPer1m(retptr, this.__wbg_ptr);
190
190
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
191
191
  var r2 = getDataViewMemory0().getFloat64(retptr + 8 * 1, true);
@@ -208,7 +208,7 @@ export class ModelInfo {
208
208
  let deferred1_0;
209
209
  let deferred1_1;
210
210
  try {
211
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
211
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
212
212
  wasm.modelinfo_id(retptr, this.__wbg_ptr);
213
213
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
214
214
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
@@ -217,7 +217,7 @@ export class ModelInfo {
217
217
  return getStringFromWasm0(r0, r1);
218
218
  } finally {
219
219
  wasm.__wbindgen_add_to_stack_pointer(16);
220
- wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
220
+ wasm.__wbindgen_export2(deferred1_0, deferred1_1, 1);
221
221
  }
222
222
  }
223
223
  /**
@@ -248,7 +248,7 @@ export class ModelInfo {
248
248
  let deferred1_0;
249
249
  let deferred1_1;
250
250
  try {
251
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
251
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
252
252
  wasm.modelinfo_provider(retptr, this.__wbg_ptr);
253
253
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
254
254
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
@@ -257,7 +257,7 @@ export class ModelInfo {
257
257
  return getStringFromWasm0(r0, r1);
258
258
  } finally {
259
259
  wasm.__wbindgen_add_to_stack_pointer(16);
260
- wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
260
+ wasm.__wbindgen_export2(deferred1_0, deferred1_1, 1);
261
261
  }
262
262
  }
263
263
  }
@@ -271,12 +271,12 @@ if (Symbol.dispose) ModelInfo.prototype[Symbol.dispose] = ModelInfo.prototype.fr
271
271
  */
272
272
  export function allModels() {
273
273
  try {
274
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
274
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
275
275
  wasm.allModels(retptr);
276
276
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
277
277
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
278
278
  var v1 = getArrayJsValueFromWasm0(r0, r1);
279
- wasm.__wbindgen_export(r0, r1 * 4, 4);
279
+ wasm.__wbindgen_export2(r0, r1 * 4, 4);
280
280
  return v1;
281
281
  } finally {
282
282
  wasm.__wbindgen_add_to_stack_pointer(16);
@@ -294,15 +294,15 @@ export function allModels() {
294
294
  */
295
295
  export function encodingForModel(model) {
296
296
  try {
297
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
298
- const ptr0 = passStringToWasm0(model, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
297
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
298
+ const ptr0 = passStringToWasm0(model, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
299
299
  const len0 = WASM_VECTOR_LEN;
300
300
  wasm.encodingForModel(retptr, ptr0, len0);
301
301
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
302
302
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
303
303
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
304
304
  if (r2) {
305
- throw takeObject(r1);
305
+ throw takeFromExternrefTable0(r1);
306
306
  }
307
307
  return Encoding.__wrap(r0);
308
308
  } finally {
@@ -322,15 +322,17 @@ export function encodingForModel(model) {
322
322
  */
323
323
  export function estimateCost(model_id, input_tokens, output_tokens) {
324
324
  try {
325
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
326
- const ptr0 = passStringToWasm0(model_id, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
325
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
326
+ const val2 = +input_tokens;
327
+ const val3 = +output_tokens;
328
+ const ptr0 = passStringToWasm0(model_id, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
327
329
  const len0 = WASM_VECTOR_LEN;
328
- wasm.estimateCost(retptr, ptr0, len0, input_tokens, output_tokens);
330
+ wasm.estimateCost(retptr, ptr0, len0, val2, val3);
329
331
  var r0 = getDataViewMemory0().getFloat64(retptr + 8 * 0, true);
330
332
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
331
333
  var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
332
334
  if (r3) {
333
- throw takeObject(r2);
335
+ throw takeFromExternrefTable0(r2);
334
336
  }
335
337
  return r0;
336
338
  } finally {
@@ -343,16 +345,20 @@ export function estimateCost(model_id, input_tokens, output_tokens) {
343
345
  *
344
346
  * Supported encodings:
345
347
  * - `"cl100k_base"` — GPT-4, GPT-3.5-turbo
346
- * - `"o200k_base"` — GPT-4o, GPT-4.1, o1, o3
348
+ * - `"o200k_base"` — GPT-4o, GPT-4.1, GPT-5.x, GPT-6.x, o1, o3
347
349
  * - `"o200k_harmony"` — gpt-oss (harmony chat format)
348
350
  * - `"p50k_base"` — text-davinci-002/003
349
351
  * - `"p50k_edit"` — text-davinci-edit
350
352
  * - `"r50k_base"` — GPT-3 (davinci, curie, etc.)
351
353
  * - `"gpt2"` — GPT-2 (alias for r50k_base)
352
- * - `"llama3"` — Meta Llama 3/4
354
+ * - `"llama3"` — Meta Llama 3.x
355
+ * - `"llama4"` — Meta Llama 4, Muse
353
356
  * - `"deepseek_v3"` — DeepSeek V3/R1
354
357
  * - `"qwen2"` — Qwen 2/2.5/3
358
+ * - `"qwen3_5"` — Qwen 3.5–3.8
355
359
  * - `"mistral_v3"` — Mistral/Codestral/Pixtral
360
+ * - `"mistral_v15"` — Mistral Large 4
361
+ * - `"deepseek_v4"`, `"kimi_k2"`, `"kimi_k3"`, `"glm4"`, `"glm5"`, `"minimax_m2"`
356
362
  *
357
363
  * Throws `Error` for unknown encoding names.
358
364
  * @param {string} name
@@ -360,15 +366,15 @@ export function estimateCost(model_id, input_tokens, output_tokens) {
360
366
  */
361
367
  export function getEncoding(name) {
362
368
  try {
363
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
364
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
369
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
370
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
365
371
  const len0 = WASM_VECTOR_LEN;
366
372
  wasm.getEncoding(retptr, ptr0, len0);
367
373
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
368
374
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
369
375
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
370
376
  if (r2) {
371
- throw takeObject(r1);
377
+ throw takeFromExternrefTable0(r1);
372
378
  }
373
379
  return Encoding.__wrap(r0);
374
380
  } finally {
@@ -393,15 +399,15 @@ export function getEncoding(name) {
393
399
  */
394
400
  export function getModelInfo(model_id) {
395
401
  try {
396
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
397
- const ptr0 = passStringToWasm0(model_id, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
402
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
403
+ const ptr0 = passStringToWasm0(model_id, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
398
404
  const len0 = WASM_VECTOR_LEN;
399
405
  wasm.getModelInfo(retptr, ptr0, len0);
400
406
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
401
407
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
402
408
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
403
409
  if (r2) {
404
- throw takeObject(r1);
410
+ throw takeFromExternrefTable0(r1);
405
411
  }
406
412
  return ModelInfo.__wrap(r0);
407
413
  } finally {
@@ -417,12 +423,12 @@ export function getModelInfo(model_id) {
417
423
  */
418
424
  export function listEncodings() {
419
425
  try {
420
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
426
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
421
427
  wasm.listEncodings(retptr);
422
428
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
423
429
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
424
430
  var v1 = getArrayJsValueFromWasm0(r0, r1);
425
- wasm.__wbindgen_export(r0, r1 * 4, 4);
431
+ wasm.__wbindgen_export2(r0, r1 * 4, 4);
426
432
  return v1;
427
433
  } finally {
428
434
  wasm.__wbindgen_add_to_stack_pointer(16);
@@ -438,8 +444,8 @@ export function listEncodings() {
438
444
  */
439
445
  export function modelToEncoding(model) {
440
446
  try {
441
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
442
- const ptr0 = passStringToWasm0(model, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
447
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
448
+ const ptr0 = passStringToWasm0(model, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
443
449
  const len0 = WASM_VECTOR_LEN;
444
450
  wasm.modelToEncoding(retptr, ptr0, len0);
445
451
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
@@ -447,7 +453,7 @@ export function modelToEncoding(model) {
447
453
  let v2;
448
454
  if (r0 !== 0) {
449
455
  v2 = getStringFromWasm0(r0, r1);
450
- wasm.__wbindgen_export(r0, r1 * 1, 1);
456
+ wasm.__wbindgen_export2(r0, r1 * 1, 1);
451
457
  }
452
458
  return v2;
453
459
  } finally {
@@ -466,14 +472,14 @@ export function modelToEncoding(model) {
466
472
  */
467
473
  export function modelsByProvider(provider) {
468
474
  try {
469
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
470
- const ptr0 = passStringToWasm0(provider, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
475
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
476
+ const ptr0 = passStringToWasm0(provider, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
471
477
  const len0 = WASM_VECTOR_LEN;
472
478
  wasm.modelsByProvider(retptr, ptr0, len0);
473
479
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
474
480
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
475
481
  var v2 = getArrayJsValueFromWasm0(r0, r1);
476
- wasm.__wbindgen_export(r0, r1 * 4, 4);
482
+ wasm.__wbindgen_export2(r0, r1 * 4, 4);
477
483
  return v2;
478
484
  } finally {
479
485
  wasm.__wbindgen_add_to_stack_pointer(16);
@@ -482,21 +488,29 @@ export function modelsByProvider(provider) {
482
488
  function __wbg_get_imports() {
483
489
  const import0 = {
484
490
  __proto__: null,
485
- __wbg_Error_408e67f47ca7b58b: function(arg0, arg1) {
491
+ __wbg_Error_208446807d0d1e30: function(arg0, arg1) {
486
492
  const ret = Error(getStringFromWasm0(arg0, arg1));
487
- return addHeapObject(ret);
493
+ return ret;
488
494
  },
489
- __wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
495
+ __wbg___wbindgen_throw_4c88d8bf264fd984: function(arg0, arg1) {
490
496
  throw new Error(getStringFromWasm0(arg0, arg1));
491
497
  },
492
498
  __wbg_modelinfo_new: function(arg0) {
493
499
  const ret = ModelInfo.__wrap(arg0);
494
- return addHeapObject(ret);
500
+ return ret;
495
501
  },
496
- __wbindgen_cast_0000000000000001: function(arg0, arg1) {
502
+ __wbindgen_generic_0000000000000001: function(arg0, arg1) {
497
503
  // Cast intrinsic for `Ref(String) -> Externref`.
498
504
  const ret = getStringFromWasm0(arg0, arg1);
499
- return addHeapObject(ret);
505
+ return ret;
506
+ },
507
+ __wbindgen_init_externref_table: function() {
508
+ const table = wasm.__wbindgen_externrefs;
509
+ table.set(0, undefined);
510
+ table.set(1024, undefined);
511
+ table.set(1025, null);
512
+ table.set(1026, true);
513
+ table.set(1027, false);
500
514
  },
501
515
  };
502
516
  return {
@@ -512,28 +526,14 @@ const ModelInfoFinalization = (typeof FinalizationRegistry === 'undefined')
512
526
  ? { register: () => {}, unregister: () => {} }
513
527
  : new FinalizationRegistry(ptr => wasm.__wbg_modelinfo_free(ptr, 1));
514
528
 
515
- function addHeapObject(obj) {
516
- if (heap_next === heap.length) heap.push(heap.length + 1);
517
- const idx = heap_next;
518
- heap_next = heap[idx];
519
-
520
- heap[idx] = obj;
521
- return idx;
522
- }
523
-
524
- function dropObject(idx) {
525
- if (idx < 1028) return;
526
- heap[idx] = heap_next;
527
- heap_next = idx;
528
- }
529
-
530
529
  function getArrayJsValueFromWasm0(ptr, len) {
531
530
  ptr = ptr >>> 0;
532
531
  const mem = getDataViewMemory0();
533
532
  const result = [];
534
533
  for (let i = ptr; i < ptr + 4 * len; i += 4) {
535
- result.push(takeObject(mem.getUint32(i, true)));
534
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
536
535
  }
536
+ wasm.__wbindgen_export(ptr, len);
537
537
  return result;
538
538
  }
539
539
 
@@ -551,7 +551,8 @@ function getDataViewMemory0() {
551
551
  }
552
552
 
553
553
  function getStringFromWasm0(ptr, len) {
554
- return decodeText(ptr >>> 0, len);
554
+ ptr = ptr >>> 0;
555
+ return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
555
556
  }
556
557
 
557
558
  let cachedUint32ArrayMemory0 = null;
@@ -570,13 +571,6 @@ function getUint8ArrayMemory0() {
570
571
  return cachedUint8ArrayMemory0;
571
572
  }
572
573
 
573
- function getObject(idx) { return heap[idx]; }
574
-
575
- let heap = new Array(1024).fill(undefined);
576
- heap.push(undefined, null, true, false);
577
-
578
- let heap_next = heap.length;
579
-
580
574
  function passArray32ToWasm0(arg, malloc) {
581
575
  const ptr = malloc(arg.length * 4, 4) >>> 0;
582
576
  getUint32ArrayMemory0().set(arg, ptr / 4);
@@ -621,24 +615,24 @@ function passStringToWasm0(arg, malloc, realloc) {
621
615
  return ptr;
622
616
  }
623
617
 
624
- function takeObject(idx) {
625
- const ret = getObject(idx);
626
- dropObject(idx);
627
- return ret;
618
+ function takeFromExternrefTable0(idx) {
619
+ const value = wasm.__wbindgen_externrefs.get(idx);
620
+ wasm.__wbindgen_export5(idx);
621
+ return value;
628
622
  }
629
623
 
630
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
624
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
631
625
  cachedTextDecoder.decode();
632
626
  const MAX_SAFARI_DECODE_BYTES = 2146435072;
633
627
  let numBytesDecoded = 0;
634
- function decodeText(ptr, len) {
635
- numBytesDecoded += len;
628
+ function decodeText(bytes) {
629
+ numBytesDecoded += bytes.length;
636
630
  if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
637
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
631
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
638
632
  cachedTextDecoder.decode();
639
- numBytesDecoded = len;
633
+ numBytesDecoded = bytes.length;
640
634
  }
641
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
635
+ return cachedTextDecoder.decode(bytes);
642
636
  }
643
637
 
644
638
  const cachedTextEncoder = new TextEncoder();
@@ -664,6 +658,7 @@ function __wbg_finalize_init(instance, module) {
664
658
  cachedDataViewMemory0 = null;
665
659
  cachedUint32ArrayMemory0 = null;
666
660
  cachedUint8ArrayMemory0 = null;
661
+ wasm.__wbindgen_start();
667
662
  return wasm;
668
663
  }
669
664
 
@@ -726,9 +721,17 @@ function initSync(module) {
726
721
  return __wbg_finalize_init(instance, module);
727
722
  }
728
723
 
724
+ let __wbg_init_promise;
729
725
  async function __wbg_init(module_or_path) {
730
726
  if (wasm !== undefined) return wasm;
727
+ if (__wbg_init_promise === undefined) {
728
+ __wbg_init_promise = __wbg_init_once(module_or_path);
729
+ __wbg_init_promise.catch(() => { __wbg_init_promise = undefined; });
730
+ }
731
+ return __wbg_init_promise;
732
+ }
731
733
 
734
+ async function __wbg_init_once(module_or_path) {
732
735
 
733
736
  if (module_or_path !== undefined) {
734
737
  if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
Binary file