@draco-rust/decoder 0.1.0 → 0.1.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.
@@ -1,4 +1,119 @@
1
- let wasm;
1
+ /* @ts-self-types="./index.d.ts" */
2
+
3
+ /**
4
+ * Install the panic hook, so a panic reads as a message rather than a trap.
5
+ */
6
+ export function init() {
7
+ wasm.init();
8
+ }
9
+
10
+ /**
11
+ * Decode a standalone Draco payload.
12
+ * @param {Uint8Array} data
13
+ * @returns {any}
14
+ */
15
+ export function parse_drc_bytes(data) {
16
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export2);
17
+ const len0 = WASM_VECTOR_LEN;
18
+ const ret = wasm.parse_drc_bytes(ptr0, len0);
19
+ return takeObject(ret);
20
+ }
21
+
22
+ /**
23
+ * File extensions this module reads and writes.
24
+ * @returns {string[]}
25
+ */
26
+ export function supported_extensions() {
27
+ try {
28
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
29
+ wasm.supported_extensions(retptr);
30
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
31
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
32
+ var v1 = getArrayJsValueFromWasm0(r0, r1);
33
+ wasm.__wbindgen_export3(r0, r1 * 4, 4);
34
+ return v1;
35
+ } finally {
36
+ wasm.__wbindgen_add_to_stack_pointer(16);
37
+ }
38
+ }
39
+
40
+ /**
41
+ * The version of this WASM module.
42
+ * @returns {string}
43
+ */
44
+ export function version() {
45
+ let deferred1_0;
46
+ let deferred1_1;
47
+ try {
48
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
49
+ wasm.version(retptr);
50
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
51
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
52
+ deferred1_0 = r0;
53
+ deferred1_1 = r1;
54
+ return getStringFromWasm0(r0, r1);
55
+ } finally {
56
+ wasm.__wbindgen_add_to_stack_pointer(16);
57
+ wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
58
+ }
59
+ }
60
+ function __wbg_get_imports() {
61
+ const import0 = {
62
+ __proto__: null,
63
+ __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
64
+ throw new Error(getStringFromWasm0(arg0, arg1));
65
+ },
66
+ __wbg_new_617a8cdb8bb1130e: function() {
67
+ const ret = new Object();
68
+ return addHeapObject(ret);
69
+ },
70
+ __wbg_new_ee2291f50781bf1d: function() {
71
+ const ret = new Array();
72
+ return addHeapObject(ret);
73
+ },
74
+ __wbg_new_from_slice_37a3c3a194266cb8: function(arg0, arg1) {
75
+ const ret = new Uint32Array(getArrayU32FromWasm0(arg0, arg1));
76
+ return addHeapObject(ret);
77
+ },
78
+ __wbg_new_from_slice_9a868026ffa4208a: function(arg0, arg1) {
79
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
80
+ return addHeapObject(ret);
81
+ },
82
+ __wbg_new_from_slice_ca6ad97db1f4779a: function(arg0, arg1) {
83
+ const ret = new Float32Array(getArrayF32FromWasm0(arg0, arg1));
84
+ return addHeapObject(ret);
85
+ },
86
+ __wbg_new_from_slice_f545fd22ddc142b8: function(arg0, arg1) {
87
+ const ret = new Float64Array(getArrayF64FromWasm0(arg0, arg1));
88
+ return addHeapObject(ret);
89
+ },
90
+ __wbg_push_2baf45db356cf468: function(arg0, arg1) {
91
+ const ret = getObject(arg0).push(getObject(arg1));
92
+ return ret;
93
+ },
94
+ __wbg_set_145a351398b48c65: function() { return handleError(function (arg0, arg1, arg2) {
95
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
96
+ return ret;
97
+ }, arguments); },
98
+ __wbindgen_generic_0000000000000001: function(arg0) {
99
+ // Cast intrinsic for `F64 -> Externref`.
100
+ const ret = arg0;
101
+ return addHeapObject(ret);
102
+ },
103
+ __wbindgen_generic_0000000000000002: function(arg0, arg1) {
104
+ // Cast intrinsic for `Ref(String) -> Externref`.
105
+ const ret = getStringFromWasm0(arg0, arg1);
106
+ return addHeapObject(ret);
107
+ },
108
+ __wbindgen_object_drop_ref: function(arg0) {
109
+ takeObject(arg0);
110
+ },
111
+ };
112
+ return {
113
+ __proto__: null,
114
+ "./index_bg.js": import0,
115
+ };
116
+ }
2
117
 
3
118
  function addHeapObject(obj) {
4
119
  if (heap_next === heap.length) heap.push(heap.length + 1);
@@ -10,7 +125,7 @@ function addHeapObject(obj) {
10
125
  }
11
126
 
12
127
  function dropObject(idx) {
13
- if (idx < 132) return;
128
+ if (idx < 1028) return;
14
129
  heap[idx] = heap_next;
15
130
  heap_next = idx;
16
131
  }
@@ -70,8 +185,7 @@ function getFloat64ArrayMemory0() {
70
185
  }
71
186
 
72
187
  function getStringFromWasm0(ptr, len) {
73
- ptr = ptr >>> 0;
74
- return decodeText(ptr, len);
188
+ return decodeText(ptr >>> 0, len);
75
189
  }
76
190
 
77
191
  let cachedUint32ArrayMemory0 = null;
@@ -100,7 +214,7 @@ function handleError(f, args) {
100
214
  }
101
215
  }
102
216
 
103
- let heap = new Array(128).fill(undefined);
217
+ let heap = new Array(1024).fill(undefined);
104
218
  heap.push(undefined, null, true, false);
105
219
 
106
220
  let heap_next = heap.length;
@@ -134,80 +248,36 @@ function decodeText(ptr, len) {
134
248
 
135
249
  let WASM_VECTOR_LEN = 0;
136
250
 
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);
154
- }
155
-
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
- }
173
-
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
- }
251
+ let wasmModule, wasmInstance, wasm;
252
+ function __wbg_finalize_init(instance, module) {
253
+ wasmInstance = instance;
254
+ wasm = instance.exports;
255
+ wasmModule = module;
256
+ cachedDataViewMemory0 = null;
257
+ cachedFloat32ArrayMemory0 = null;
258
+ cachedFloat64ArrayMemory0 = null;
259
+ cachedUint32ArrayMemory0 = null;
260
+ cachedUint8ArrayMemory0 = null;
261
+ wasm.__wbindgen_start();
262
+ return wasm;
193
263
  }
194
264
 
195
- const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
196
-
197
265
  async function __wbg_load(module, imports) {
198
266
  if (typeof Response === 'function' && module instanceof Response) {
267
+ if (!module.ok) {
268
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
269
+ }
270
+
199
271
  if (typeof WebAssembly.instantiateStreaming === 'function') {
200
272
  try {
201
273
  return await WebAssembly.instantiateStreaming(module, imports);
202
274
  } catch (e) {
203
- const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
275
+ const validResponse = expectedResponseType(module.type);
204
276
 
205
277
  if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
206
278
  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
279
 
208
- } else {
209
- throw e;
210
- }
280
+ } else { throw e; }
211
281
  }
212
282
  }
213
283
 
@@ -222,82 +292,20 @@ async function __wbg_load(module, imports) {
222
292
  return instance;
223
293
  }
224
294
  }
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
295
 
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;
296
+ function expectedResponseType(type) {
297
+ switch (type) {
298
+ case 'basic': case 'cors': case 'default': return true;
299
+ }
300
+ return false;
301
+ }
294
302
  }
295
303
 
296
304
  function initSync(module) {
297
305
  if (wasm !== undefined) return wasm;
298
306
 
299
307
 
300
- if (typeof module !== 'undefined') {
308
+ if (module !== undefined) {
301
309
  if (Object.getPrototypeOf(module) === Object.prototype) {
302
310
  ({module} = module)
303
311
  } else {
@@ -317,7 +325,7 @@ async function __wbg_init(module_or_path) {
317
325
  if (wasm !== undefined) return wasm;
318
326
 
319
327
 
320
- if (typeof module_or_path !== 'undefined') {
328
+ if (module_or_path !== undefined) {
321
329
  if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
322
330
  ({module_or_path} = module_or_path)
323
331
  } else {
@@ -325,7 +333,7 @@ async function __wbg_init(module_or_path) {
325
333
  }
326
334
  }
327
335
 
328
- if (typeof module_or_path === 'undefined') {
336
+ if (module_or_path === undefined) {
329
337
  module_or_path = new URL('index_bg.wasm', import.meta.url);
330
338
  }
331
339
  const imports = __wbg_get_imports();
@@ -339,5 +347,4 @@ async function __wbg_init(module_or_path) {
339
347
  return __wbg_finalize_init(instance, module);
340
348
  }
341
349
 
342
- export { initSync };
343
- export default __wbg_init;
350
+ export { initSync, __wbg_init as default };
Binary file
@@ -1,12 +1,12 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
+ export const init: () => void;
4
5
  export const parse_drc_bytes: (a: number, b: number) => number;
5
6
  export const supported_extensions: (a: number) => void;
6
7
  export const version: (a: number) => void;
7
- export const init: () => void;
8
8
  export const __wbindgen_export: (a: number) => void;
9
+ export const __wbindgen_export2: (a: number, b: number) => number;
9
10
  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;
11
+ export const __wbindgen_export3: (a: number, b: number, c: number) => void;
12
12
  export const __wbindgen_start: () => void;