@draco-rust/decoder 0.1.0 → 0.1.2

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/legacy/index.js CHANGED
@@ -1,4 +1,213 @@
1
- let wasm;
1
+ /* @ts-self-types="./index.d.ts" */
2
+
3
+ /**
4
+ * Decodes a Draco stream and returns its attributes as typed arrays.
5
+ *
6
+ * `attributes` is `undefined` for every attribute in its own component type,
7
+ * or an array of requests `{ name, id, semantic, type }`:
8
+ *
9
+ * - `id`, a unique id, finds that attribute, as glTF's
10
+ * `KHR_draco_mesh_compression` names them; a missing one is an error.
11
+ * - `semantic` (`"POSITION"`, `"NORMAL"`, `"COLOR"`, `"TEX_COORD"` or
12
+ * `"GENERIC"`) finds the first attribute of that type instead, as a `.drc`
13
+ * file is read; a missing one is left out.
14
+ * - `type`, a typed array's name such as `"Float32Array"` or
15
+ * `"Uint16Array"`, converts the values the way upstream's
16
+ * `GetAttributeDataArrayForAllPoints` does; without it the values keep
17
+ * their own type. A value the type cannot hold is an error.
18
+ *
19
+ * The result is `{ success, error, warnings, geometry, index, attributes }`,
20
+ * where `geometry` is `"mesh"` or `"point_cloud"` as the stream's header says,
21
+ * `index` a `Uint32Array` of triangle corners for a mesh and `null` for a
22
+ * point cloud, and each attribute `{ name, uniqueId, semantic, array,
23
+ * itemSize, normalized }`.
24
+ * @param {Uint8Array} data
25
+ * @param {DracoAttributeRequest[] | undefined} attributes
26
+ * @returns {DracoDecodeResult}
27
+ */
28
+ export function decode_draco(data, attributes) {
29
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
30
+ const len0 = WASM_VECTOR_LEN;
31
+ const ret = wasm.decode_draco(ptr0, len0, addHeapObject(attributes));
32
+ return takeObject(ret);
33
+ }
34
+
35
+ /**
36
+ * Install the panic hook, so a panic reads as a message rather than a trap.
37
+ */
38
+ export function init() {
39
+ wasm.init();
40
+ }
41
+
42
+ /**
43
+ * Decode a standalone Draco payload.
44
+ * @param {Uint8Array} data
45
+ * @returns {any}
46
+ */
47
+ export function parse_drc_bytes(data) {
48
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
49
+ const len0 = WASM_VECTOR_LEN;
50
+ const ret = wasm.parse_drc_bytes(ptr0, len0);
51
+ return takeObject(ret);
52
+ }
53
+
54
+ /**
55
+ * File extensions this module reads and writes.
56
+ * @returns {string[]}
57
+ */
58
+ export function supported_extensions() {
59
+ try {
60
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
61
+ wasm.supported_extensions(retptr);
62
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
63
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
64
+ var v1 = getArrayJsValueFromWasm0(r0, r1);
65
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
66
+ return v1;
67
+ } finally {
68
+ wasm.__wbindgen_add_to_stack_pointer(16);
69
+ }
70
+ }
71
+
72
+ /**
73
+ * The version of this WASM module.
74
+ * @returns {string}
75
+ */
76
+ export function version() {
77
+ let deferred1_0;
78
+ let deferred1_1;
79
+ try {
80
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
81
+ wasm.version(retptr);
82
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
83
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
84
+ deferred1_0 = r0;
85
+ deferred1_1 = r1;
86
+ return getStringFromWasm0(r0, r1);
87
+ } finally {
88
+ wasm.__wbindgen_add_to_stack_pointer(16);
89
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
90
+ }
91
+ }
92
+ function __wbg_get_imports() {
93
+ const import0 = {
94
+ __proto__: null,
95
+ __wbg___wbindgen_is_null_e343b7d08827ba72: function(arg0) {
96
+ const ret = getObject(arg0) === null;
97
+ return ret;
98
+ },
99
+ __wbg___wbindgen_is_undefined_8865fb403f8fe9d8: function(arg0) {
100
+ const ret = getObject(arg0) === undefined;
101
+ return ret;
102
+ },
103
+ __wbg___wbindgen_number_get_2e0e7dee9f701a71: function(arg0, arg1) {
104
+ const obj = getObject(arg1);
105
+ const ret = typeof(obj) === 'number' ? obj : undefined;
106
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
107
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
108
+ },
109
+ __wbg___wbindgen_string_get_0380ccaa2f57f0d9: function(arg0, arg1) {
110
+ const obj = getObject(arg1);
111
+ const ret = typeof(obj) === 'string' ? obj : undefined;
112
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
113
+ var len1 = WASM_VECTOR_LEN;
114
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
115
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
116
+ },
117
+ __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
118
+ throw new Error(getStringFromWasm0(arg0, arg1));
119
+ },
120
+ __wbg_get_31af05bd4842a84f: function() { return handleError(function (arg0, arg1) {
121
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
122
+ return addHeapObject(ret);
123
+ }, arguments); },
124
+ __wbg_get_unchecked_288889d017702237: function(arg0, arg1) {
125
+ const ret = getObject(arg0)[arg1 >>> 0];
126
+ return addHeapObject(ret);
127
+ },
128
+ __wbg_isArray_e15a2ff68ffdbef2: function(arg0) {
129
+ const ret = Array.isArray(getObject(arg0));
130
+ return ret;
131
+ },
132
+ __wbg_length_d4bdea10311bd9cf: function(arg0) {
133
+ const ret = getObject(arg0).length;
134
+ return ret;
135
+ },
136
+ __wbg_new_617a8cdb8bb1130e: function() {
137
+ const ret = new Object();
138
+ return addHeapObject(ret);
139
+ },
140
+ __wbg_new_ee2291f50781bf1d: function() {
141
+ const ret = new Array();
142
+ return addHeapObject(ret);
143
+ },
144
+ __wbg_new_from_slice_23f60f47cde8d664: function(arg0, arg1) {
145
+ const ret = new Uint16Array(getArrayU16FromWasm0(arg0, arg1));
146
+ return addHeapObject(ret);
147
+ },
148
+ __wbg_new_from_slice_2443ca2017fac0fd: function(arg0, arg1) {
149
+ const ret = new Int16Array(getArrayI16FromWasm0(arg0, arg1));
150
+ return addHeapObject(ret);
151
+ },
152
+ __wbg_new_from_slice_36f6b4e63daa7f59: function(arg0, arg1) {
153
+ const ret = new Int8Array(getArrayI8FromWasm0(arg0, arg1));
154
+ return addHeapObject(ret);
155
+ },
156
+ __wbg_new_from_slice_37a3c3a194266cb8: function(arg0, arg1) {
157
+ const ret = new Uint32Array(getArrayU32FromWasm0(arg0, arg1));
158
+ return addHeapObject(ret);
159
+ },
160
+ __wbg_new_from_slice_911f717853b222c7: function(arg0, arg1) {
161
+ const ret = new Int32Array(getArrayI32FromWasm0(arg0, arg1));
162
+ return addHeapObject(ret);
163
+ },
164
+ __wbg_new_from_slice_9a868026ffa4208a: function(arg0, arg1) {
165
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
166
+ return addHeapObject(ret);
167
+ },
168
+ __wbg_new_from_slice_aa8f37bd5e72dcc7: function(arg0, arg1) {
169
+ const ret = new BigInt64Array(getArrayI64FromWasm0(arg0, arg1));
170
+ return addHeapObject(ret);
171
+ },
172
+ __wbg_new_from_slice_ca6ad97db1f4779a: function(arg0, arg1) {
173
+ const ret = new Float32Array(getArrayF32FromWasm0(arg0, arg1));
174
+ return addHeapObject(ret);
175
+ },
176
+ __wbg_new_from_slice_f545fd22ddc142b8: function(arg0, arg1) {
177
+ const ret = new Float64Array(getArrayF64FromWasm0(arg0, arg1));
178
+ return addHeapObject(ret);
179
+ },
180
+ __wbg_new_from_slice_f6cd96ab370a57b3: function(arg0, arg1) {
181
+ const ret = new BigUint64Array(getArrayU64FromWasm0(arg0, arg1));
182
+ return addHeapObject(ret);
183
+ },
184
+ __wbg_push_2baf45db356cf468: function(arg0, arg1) {
185
+ const ret = getObject(arg0).push(getObject(arg1));
186
+ return ret;
187
+ },
188
+ __wbg_set_145a351398b48c65: function() { return handleError(function (arg0, arg1, arg2) {
189
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
190
+ return ret;
191
+ }, arguments); },
192
+ __wbindgen_generic_0000000000000001: function(arg0) {
193
+ // Cast intrinsic for `F64 -> Externref`.
194
+ const ret = arg0;
195
+ return addHeapObject(ret);
196
+ },
197
+ __wbindgen_generic_0000000000000002: function(arg0, arg1) {
198
+ // Cast intrinsic for `Ref(String) -> Externref`.
199
+ const ret = getStringFromWasm0(arg0, arg1);
200
+ return addHeapObject(ret);
201
+ },
202
+ __wbindgen_object_drop_ref: function(arg0) {
203
+ takeObject(arg0);
204
+ },
205
+ };
206
+ return {
207
+ __proto__: null,
208
+ "./index_bg.js": import0,
209
+ };
210
+ }
2
211
 
3
212
  function addHeapObject(obj) {
4
213
  if (heap_next === heap.length) heap.push(heap.length + 1);
@@ -10,7 +219,7 @@ function addHeapObject(obj) {
10
219
  }
11
220
 
12
221
  function dropObject(idx) {
13
- if (idx < 132) return;
222
+ if (idx < 1028) return;
14
223
  heap[idx] = heap_next;
15
224
  heap_next = idx;
16
225
  }
@@ -25,6 +234,26 @@ function getArrayF64FromWasm0(ptr, len) {
25
234
  return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
26
235
  }
27
236
 
237
+ function getArrayI16FromWasm0(ptr, len) {
238
+ ptr = ptr >>> 0;
239
+ return getInt16ArrayMemory0().subarray(ptr / 2, ptr / 2 + len);
240
+ }
241
+
242
+ function getArrayI32FromWasm0(ptr, len) {
243
+ ptr = ptr >>> 0;
244
+ return getInt32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
245
+ }
246
+
247
+ function getArrayI64FromWasm0(ptr, len) {
248
+ ptr = ptr >>> 0;
249
+ return getBigInt64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
250
+ }
251
+
252
+ function getArrayI8FromWasm0(ptr, len) {
253
+ ptr = ptr >>> 0;
254
+ return getInt8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
255
+ }
256
+
28
257
  function getArrayJsValueFromWasm0(ptr, len) {
29
258
  ptr = ptr >>> 0;
30
259
  const mem = getDataViewMemory0();
@@ -35,16 +264,42 @@ function getArrayJsValueFromWasm0(ptr, len) {
35
264
  return result;
36
265
  }
37
266
 
267
+ function getArrayU16FromWasm0(ptr, len) {
268
+ ptr = ptr >>> 0;
269
+ return getUint16ArrayMemory0().subarray(ptr / 2, ptr / 2 + len);
270
+ }
271
+
38
272
  function getArrayU32FromWasm0(ptr, len) {
39
273
  ptr = ptr >>> 0;
40
274
  return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
41
275
  }
42
276
 
277
+ function getArrayU64FromWasm0(ptr, len) {
278
+ ptr = ptr >>> 0;
279
+ return getBigUint64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
280
+ }
281
+
43
282
  function getArrayU8FromWasm0(ptr, len) {
44
283
  ptr = ptr >>> 0;
45
284
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
46
285
  }
47
286
 
287
+ let cachedBigInt64ArrayMemory0 = null;
288
+ function getBigInt64ArrayMemory0() {
289
+ if (cachedBigInt64ArrayMemory0 === null || cachedBigInt64ArrayMemory0.byteLength === 0) {
290
+ cachedBigInt64ArrayMemory0 = new BigInt64Array(wasm.memory.buffer);
291
+ }
292
+ return cachedBigInt64ArrayMemory0;
293
+ }
294
+
295
+ let cachedBigUint64ArrayMemory0 = null;
296
+ function getBigUint64ArrayMemory0() {
297
+ if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
298
+ cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
299
+ }
300
+ return cachedBigUint64ArrayMemory0;
301
+ }
302
+
48
303
  let cachedDataViewMemory0 = null;
49
304
  function getDataViewMemory0() {
50
305
  if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
@@ -69,9 +324,40 @@ function getFloat64ArrayMemory0() {
69
324
  return cachedFloat64ArrayMemory0;
70
325
  }
71
326
 
327
+ let cachedInt16ArrayMemory0 = null;
328
+ function getInt16ArrayMemory0() {
329
+ if (cachedInt16ArrayMemory0 === null || cachedInt16ArrayMemory0.byteLength === 0) {
330
+ cachedInt16ArrayMemory0 = new Int16Array(wasm.memory.buffer);
331
+ }
332
+ return cachedInt16ArrayMemory0;
333
+ }
334
+
335
+ let cachedInt32ArrayMemory0 = null;
336
+ function getInt32ArrayMemory0() {
337
+ if (cachedInt32ArrayMemory0 === null || cachedInt32ArrayMemory0.byteLength === 0) {
338
+ cachedInt32ArrayMemory0 = new Int32Array(wasm.memory.buffer);
339
+ }
340
+ return cachedInt32ArrayMemory0;
341
+ }
342
+
343
+ let cachedInt8ArrayMemory0 = null;
344
+ function getInt8ArrayMemory0() {
345
+ if (cachedInt8ArrayMemory0 === null || cachedInt8ArrayMemory0.byteLength === 0) {
346
+ cachedInt8ArrayMemory0 = new Int8Array(wasm.memory.buffer);
347
+ }
348
+ return cachedInt8ArrayMemory0;
349
+ }
350
+
72
351
  function getStringFromWasm0(ptr, len) {
73
- ptr = ptr >>> 0;
74
- return decodeText(ptr, len);
352
+ return decodeText(ptr >>> 0, len);
353
+ }
354
+
355
+ let cachedUint16ArrayMemory0 = null;
356
+ function getUint16ArrayMemory0() {
357
+ if (cachedUint16ArrayMemory0 === null || cachedUint16ArrayMemory0.byteLength === 0) {
358
+ cachedUint16ArrayMemory0 = new Uint16Array(wasm.memory.buffer);
359
+ }
360
+ return cachedUint16ArrayMemory0;
75
361
  }
76
362
 
77
363
  let cachedUint32ArrayMemory0 = null;
@@ -96,15 +382,19 @@ function handleError(f, args) {
96
382
  try {
97
383
  return f.apply(this, args);
98
384
  } catch (e) {
99
- wasm.__wbindgen_export(addHeapObject(e));
385
+ wasm.__wbindgen_export3(addHeapObject(e));
100
386
  }
101
387
  }
102
388
 
103
- let heap = new Array(128).fill(undefined);
389
+ let heap = new Array(1024).fill(undefined);
104
390
  heap.push(undefined, null, true, false);
105
391
 
106
392
  let heap_next = heap.length;
107
393
 
394
+ function isLikeNone(x) {
395
+ return x === undefined || x === null;
396
+ }
397
+
108
398
  function passArray8ToWasm0(arg, malloc) {
109
399
  const ptr = malloc(arg.length * 1, 1) >>> 0;
110
400
  getUint8ArrayMemory0().set(arg, ptr / 1);
@@ -112,6 +402,43 @@ function passArray8ToWasm0(arg, malloc) {
112
402
  return ptr;
113
403
  }
114
404
 
405
+ function passStringToWasm0(arg, malloc, realloc) {
406
+ if (realloc === undefined) {
407
+ const buf = cachedTextEncoder.encode(arg);
408
+ const ptr = malloc(buf.length, 1) >>> 0;
409
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
410
+ WASM_VECTOR_LEN = buf.length;
411
+ return ptr;
412
+ }
413
+
414
+ let len = arg.length;
415
+ let ptr = malloc(len, 1) >>> 0;
416
+
417
+ const mem = getUint8ArrayMemory0();
418
+
419
+ let offset = 0;
420
+
421
+ for (; offset < len; offset++) {
422
+ const code = arg.charCodeAt(offset);
423
+ if (code > 0x7F) break;
424
+ mem[ptr + offset] = code;
425
+ }
426
+ if (offset !== len) {
427
+ if (offset !== 0) {
428
+ arg = arg.slice(offset);
429
+ }
430
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
431
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
432
+ const ret = cachedTextEncoder.encodeInto(arg, view);
433
+
434
+ offset += ret.written;
435
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
436
+ }
437
+
438
+ WASM_VECTOR_LEN = offset;
439
+ return ptr;
440
+ }
441
+
115
442
  function takeObject(idx) {
116
443
  const ret = getObject(idx);
117
444
  dropObject(idx);
@@ -132,82 +459,57 @@ function decodeText(ptr, len) {
132
459
  return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
133
460
  }
134
461
 
135
- let WASM_VECTOR_LEN = 0;
462
+ const cachedTextEncoder = new TextEncoder();
136
463
 
137
- /**
138
- * Install the panic hook, so a panic reads as a message rather than a trap.
139
- */
140
- export function init() {
141
- wasm.init();
142
- }
143
-
144
- /**
145
- * Decode a standalone Draco payload.
146
- * @param {Uint8Array} data
147
- * @returns {any}
148
- */
149
- export function parse_drc_bytes(data) {
150
- const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export3);
151
- const len0 = WASM_VECTOR_LEN;
152
- const ret = wasm.parse_drc_bytes(ptr0, len0);
153
- return takeObject(ret);
464
+ if (!('encodeInto' in cachedTextEncoder)) {
465
+ cachedTextEncoder.encodeInto = function (arg, view) {
466
+ const buf = cachedTextEncoder.encode(arg);
467
+ view.set(buf);
468
+ return {
469
+ read: arg.length,
470
+ written: buf.length
471
+ };
472
+ };
154
473
  }
155
474
 
156
- /**
157
- * File extensions this module reads and writes.
158
- * @returns {string[]}
159
- */
160
- export function supported_extensions() {
161
- try {
162
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
163
- wasm.supported_extensions(retptr);
164
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
165
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
166
- var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
167
- wasm.__wbindgen_export2(r0, r1 * 4, 4);
168
- return v1;
169
- } finally {
170
- wasm.__wbindgen_add_to_stack_pointer(16);
171
- }
172
- }
475
+ let WASM_VECTOR_LEN = 0;
173
476
 
174
- /**
175
- * The version of this WASM module.
176
- * @returns {string}
177
- */
178
- export function version() {
179
- let deferred1_0;
180
- let deferred1_1;
181
- try {
182
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
183
- wasm.version(retptr);
184
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
185
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
186
- deferred1_0 = r0;
187
- deferred1_1 = r1;
188
- return getStringFromWasm0(r0, r1);
189
- } finally {
190
- wasm.__wbindgen_add_to_stack_pointer(16);
191
- wasm.__wbindgen_export2(deferred1_0, deferred1_1, 1);
192
- }
477
+ let wasmModule, wasmInstance, wasm;
478
+ function __wbg_finalize_init(instance, module) {
479
+ wasmInstance = instance;
480
+ wasm = instance.exports;
481
+ wasmModule = module;
482
+ cachedBigInt64ArrayMemory0 = null;
483
+ cachedBigUint64ArrayMemory0 = null;
484
+ cachedDataViewMemory0 = null;
485
+ cachedFloat32ArrayMemory0 = null;
486
+ cachedFloat64ArrayMemory0 = null;
487
+ cachedInt16ArrayMemory0 = null;
488
+ cachedInt32ArrayMemory0 = null;
489
+ cachedInt8ArrayMemory0 = null;
490
+ cachedUint16ArrayMemory0 = null;
491
+ cachedUint32ArrayMemory0 = null;
492
+ cachedUint8ArrayMemory0 = null;
493
+ wasm.__wbindgen_start();
494
+ return wasm;
193
495
  }
194
496
 
195
- const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
196
-
197
497
  async function __wbg_load(module, imports) {
198
498
  if (typeof Response === 'function' && module instanceof Response) {
499
+ if (!module.ok) {
500
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
501
+ }
502
+
199
503
  if (typeof WebAssembly.instantiateStreaming === 'function') {
200
504
  try {
201
505
  return await WebAssembly.instantiateStreaming(module, imports);
202
506
  } catch (e) {
203
- const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
507
+ const validResponse = expectedResponseType(module.type);
204
508
 
205
509
  if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
206
510
  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);
207
511
 
208
- } else {
209
- throw e;
210
- }
512
+ } else { throw e; }
211
513
  }
212
514
  }
213
515
 
@@ -222,82 +524,20 @@ async function __wbg_load(module, imports) {
222
524
  return instance;
223
525
  }
224
526
  }
225
- }
226
-
227
- function __wbg_get_imports() {
228
- const imports = {};
229
- imports.wbg = {};
230
- imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
231
- throw new Error(getStringFromWasm0(arg0, arg1));
232
- };
233
- imports.wbg.__wbg_new_1ba21ce319a06297 = function() {
234
- const ret = new Object();
235
- return addHeapObject(ret);
236
- };
237
- imports.wbg.__wbg_new_25f239778d6112b9 = function() {
238
- const ret = new Array();
239
- return addHeapObject(ret);
240
- };
241
- imports.wbg.__wbg_new_from_slice_41e2764a343e3cb1 = function(arg0, arg1) {
242
- const ret = new Float32Array(getArrayF32FromWasm0(arg0, arg1));
243
- return addHeapObject(ret);
244
- };
245
- imports.wbg.__wbg_new_from_slice_9a48ef80d2a51f94 = function(arg0, arg1) {
246
- const ret = new Float64Array(getArrayF64FromWasm0(arg0, arg1));
247
- return addHeapObject(ret);
248
- };
249
- imports.wbg.__wbg_new_from_slice_db0691b69e9d3891 = function(arg0, arg1) {
250
- const ret = new Uint32Array(getArrayU32FromWasm0(arg0, arg1));
251
- return addHeapObject(ret);
252
- };
253
- imports.wbg.__wbg_new_from_slice_f9c22b9153b26992 = function(arg0, arg1) {
254
- const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
255
- return addHeapObject(ret);
256
- };
257
- imports.wbg.__wbg_push_7d9be8f38fc13975 = function(arg0, arg1) {
258
- const ret = getObject(arg0).push(getObject(arg1));
259
- return ret;
260
- };
261
- imports.wbg.__wbg_set_781438a03c0c3c81 = function() { return handleError(function (arg0, arg1, arg2) {
262
- const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
263
- return ret;
264
- }, arguments) };
265
- imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
266
- // Cast intrinsic for `Ref(String) -> Externref`.
267
- const ret = getStringFromWasm0(arg0, arg1);
268
- return addHeapObject(ret);
269
- };
270
- imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
271
- // Cast intrinsic for `F64 -> Externref`.
272
- const ret = arg0;
273
- return addHeapObject(ret);
274
- };
275
- imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
276
- takeObject(arg0);
277
- };
278
-
279
- return imports;
280
- }
281
527
 
282
- function __wbg_finalize_init(instance, module) {
283
- wasm = instance.exports;
284
- __wbg_init.__wbindgen_wasm_module = module;
285
- cachedDataViewMemory0 = null;
286
- cachedFloat32ArrayMemory0 = null;
287
- cachedFloat64ArrayMemory0 = null;
288
- cachedUint32ArrayMemory0 = null;
289
- cachedUint8ArrayMemory0 = null;
290
-
291
-
292
- wasm.__wbindgen_start();
293
- return wasm;
528
+ function expectedResponseType(type) {
529
+ switch (type) {
530
+ case 'basic': case 'cors': case 'default': return true;
531
+ }
532
+ return false;
533
+ }
294
534
  }
295
535
 
296
536
  function initSync(module) {
297
537
  if (wasm !== undefined) return wasm;
298
538
 
299
539
 
300
- if (typeof module !== 'undefined') {
540
+ if (module !== undefined) {
301
541
  if (Object.getPrototypeOf(module) === Object.prototype) {
302
542
  ({module} = module)
303
543
  } else {
@@ -317,7 +557,7 @@ async function __wbg_init(module_or_path) {
317
557
  if (wasm !== undefined) return wasm;
318
558
 
319
559
 
320
- if (typeof module_or_path !== 'undefined') {
560
+ if (module_or_path !== undefined) {
321
561
  if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
322
562
  ({module_or_path} = module_or_path)
323
563
  } else {
@@ -325,7 +565,7 @@ async function __wbg_init(module_or_path) {
325
565
  }
326
566
  }
327
567
 
328
- if (typeof module_or_path === 'undefined') {
568
+ if (module_or_path === undefined) {
329
569
  module_or_path = new URL('index_bg.wasm', import.meta.url);
330
570
  }
331
571
  const imports = __wbg_get_imports();
@@ -339,5 +579,4 @@ async function __wbg_init(module_or_path) {
339
579
  return __wbg_finalize_init(instance, module);
340
580
  }
341
581
 
342
- export { initSync };
343
- export default __wbg_init;
582
+ export { initSync, __wbg_init as default };
Binary file
@@ -1,12 +1,14 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
+ export const decode_draco: (a: number, b: number, c: number) => number;
5
+ export const init: () => void;
4
6
  export const parse_drc_bytes: (a: number, b: number) => number;
5
7
  export const supported_extensions: (a: number) => void;
6
8
  export const version: (a: number) => void;
7
- export const init: () => void;
8
- export const __wbindgen_export: (a: number) => void;
9
+ export const __wbindgen_export: (a: number, b: number) => number;
10
+ export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
11
+ export const __wbindgen_export3: (a: number) => void;
9
12
  export const __wbindgen_add_to_stack_pointer: (a: number) => number;
10
- export const __wbindgen_export2: (a: number, b: number, c: number) => void;
11
- export const __wbindgen_export3: (a: number, b: number) => number;
13
+ export const __wbindgen_export4: (a: number, b: number, c: number) => void;
12
14
  export const __wbindgen_start: () => void;
@@ -0,0 +1,45 @@
1
+ import type { DracoAttributeRequest, DracoDecodeResult } from './index.js';
2
+
3
+ export interface DecoderPoolOptions {
4
+ /**
5
+ * How many workers to run at most; they start as work arrives. Defaults to
6
+ * one less than the cores, between one and four. `0` decodes on the calling
7
+ * thread, as does an environment without workers.
8
+ */
9
+ workers?: number;
10
+ /**
11
+ * The entry's wasm, when it is not next to this module where the pool looks
12
+ * for it: a URL, a `Response`, the bytes, or a compiled module.
13
+ */
14
+ wasm?: string | URL | Response | BufferSource | WebAssembly.Module;
15
+ }
16
+
17
+ export interface DecodeOptions {
18
+ /**
19
+ * Hand the stream's buffer to the worker instead of copying it, leaving it
20
+ * detached here. For a buffer nothing else reads afterwards.
21
+ */
22
+ transfer?: boolean;
23
+ }
24
+
25
+ export interface DecoderPool {
26
+ /**
27
+ * `decode_draco` on a worker. A stream that does not decode resolves with
28
+ * `success: false`, as `decode_draco` returns it; a worker that fails rejects
29
+ * the tasks it held.
30
+ */
31
+ decode(
32
+ data: ArrayBuffer | ArrayBufferView,
33
+ attributes?: DracoAttributeRequest[],
34
+ options?: DecodeOptions,
35
+ ): Promise<DracoDecodeResult>;
36
+ /** Compiles the wasm and starts one worker ahead of the first decode. */
37
+ preload(): Promise<void>;
38
+ /** Changes the worker limit; idle workers past it stop now, busy ones when done. */
39
+ setWorkerLimit(workers: number): void;
40
+ readonly workerLimit: number;
41
+ /** Stops every worker and rejects what they held. */
42
+ dispose(): void;
43
+ }
44
+
45
+ export function createDecoderPool(options?: DecoderPoolOptions): DecoderPool;