@spglib/moyo-wasm 0.5.0 → 0.6.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/moyo_wasm.d.ts CHANGED
@@ -48,9 +48,9 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
48
48
  export interface InitOutput {
49
49
  readonly memory: WebAssembly.Memory;
50
50
  readonly analyze_cell: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
51
- readonly __wbindgen_export_0: WebAssembly.Table;
52
51
  readonly __wbindgen_malloc: (a: number, b: number) => number;
53
52
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
53
+ readonly __wbindgen_export_2: WebAssembly.Table;
54
54
  readonly __externref_table_dealloc: (a: number) => void;
55
55
  readonly __wbindgen_start: () => void;
56
56
  }
package/moyo_wasm.js CHANGED
@@ -1,9 +1,5 @@
1
1
  let wasm;
2
2
 
3
- const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
4
-
5
- if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
6
-
7
3
  let cachedUint8ArrayMemory0 = null;
8
4
 
9
5
  function getUint8ArrayMemory0() {
@@ -13,27 +9,41 @@ function getUint8ArrayMemory0() {
13
9
  return cachedUint8ArrayMemory0;
14
10
  }
15
11
 
12
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
13
+
14
+ cachedTextDecoder.decode();
15
+
16
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
17
+ let numBytesDecoded = 0;
18
+ function decodeText(ptr, len) {
19
+ numBytesDecoded += len;
20
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
21
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
22
+ cachedTextDecoder.decode();
23
+ numBytesDecoded = len;
24
+ }
25
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
26
+ }
27
+
16
28
  function getStringFromWasm0(ptr, len) {
17
29
  ptr = ptr >>> 0;
18
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
30
+ return decodeText(ptr, len);
19
31
  }
20
32
 
21
33
  let WASM_VECTOR_LEN = 0;
22
34
 
23
- const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
35
+ const cachedTextEncoder = new TextEncoder();
24
36
 
25
- const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
26
- ? function (arg, view) {
27
- return cachedTextEncoder.encodeInto(arg, view);
37
+ if (!('encodeInto' in cachedTextEncoder)) {
38
+ cachedTextEncoder.encodeInto = function (arg, view) {
39
+ const buf = cachedTextEncoder.encode(arg);
40
+ view.set(buf);
41
+ return {
42
+ read: arg.length,
43
+ written: buf.length
44
+ };
45
+ }
28
46
  }
29
- : function (arg, view) {
30
- const buf = cachedTextEncoder.encode(arg);
31
- view.set(buf);
32
- return {
33
- read: arg.length,
34
- written: buf.length
35
- };
36
- });
37
47
 
38
48
  function passStringToWasm0(arg, malloc, realloc) {
39
49
 
@@ -64,7 +74,7 @@ function passStringToWasm0(arg, malloc, realloc) {
64
74
  }
65
75
  ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
66
76
  const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
67
- const ret = encodeString(arg, view);
77
+ const ret = cachedTextEncoder.encodeInto(arg, view);
68
78
 
69
79
  offset += ret.written;
70
80
  ptr = realloc(ptr, len, offset, 1) >>> 0;
@@ -74,8 +84,17 @@ function passStringToWasm0(arg, malloc, realloc) {
74
84
  return ptr;
75
85
  }
76
86
 
87
+ let cachedDataViewMemory0 = null;
88
+
89
+ function getDataViewMemory0() {
90
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
91
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
92
+ }
93
+ return cachedDataViewMemory0;
94
+ }
95
+
77
96
  function takeFromExternrefTable0(idx) {
78
- const value = wasm.__wbindgen_export_0.get(idx);
97
+ const value = wasm.__wbindgen_export_2.get(idx);
79
98
  wasm.__externref_table_dealloc(idx);
80
99
  return value;
81
100
  }
@@ -98,6 +117,8 @@ export function analyze_cell(cell_json, symprec, setting) {
98
117
  return takeFromExternrefTable0(ret[0]);
99
118
  }
100
119
 
120
+ const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
121
+
101
122
  async function __wbg_load(module, imports) {
102
123
  if (typeof Response === 'function' && module instanceof Response) {
103
124
  if (typeof WebAssembly.instantiateStreaming === 'function') {
@@ -105,7 +126,9 @@ async function __wbg_load(module, imports) {
105
126
  return await WebAssembly.instantiateStreaming(module, imports);
106
127
 
107
128
  } catch (e) {
108
- if (module.headers.get('Content-Type') != 'application/wasm') {
129
+ const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
130
+
131
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
109
132
  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);
110
133
 
111
134
  } else {
@@ -132,30 +155,51 @@ async function __wbg_load(module, imports) {
132
155
  function __wbg_get_imports() {
133
156
  const imports = {};
134
157
  imports.wbg = {};
135
- imports.wbg.__wbg_new_405e22f390576ce2 = function() {
158
+ imports.wbg.__wbg_Error_e17e777aac105295 = function(arg0, arg1) {
159
+ const ret = Error(getStringFromWasm0(arg0, arg1));
160
+ return ret;
161
+ };
162
+ imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
163
+ const ret = String(arg1);
164
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
165
+ const len1 = WASM_VECTOR_LEN;
166
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
167
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
168
+ };
169
+ imports.wbg.__wbg_new_19c25a3f2fa63a02 = function() {
136
170
  const ret = new Object();
137
171
  return ret;
138
172
  };
139
- imports.wbg.__wbg_new_78feb108b6472713 = function() {
173
+ imports.wbg.__wbg_new_1f3a344cf3123716 = function() {
140
174
  const ret = new Array();
141
175
  return ret;
142
176
  };
143
- imports.wbg.__wbg_set_37837023f3d740e8 = function(arg0, arg1, arg2) {
177
+ imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
178
+ arg0[arg1] = arg2;
179
+ };
180
+ imports.wbg.__wbg_set_90f6c0f7bd8c0415 = function(arg0, arg1, arg2) {
144
181
  arg0[arg1 >>> 0] = arg2;
145
182
  };
146
- imports.wbg.__wbg_set_3807d5f0bfc24aa7 = function(arg0, arg1, arg2) {
147
- arg0[arg1] = arg2;
183
+ imports.wbg.__wbg_wbindgenthrow_451ec1a8469d7eb6 = function(arg0, arg1) {
184
+ throw new Error(getStringFromWasm0(arg0, arg1));
185
+ };
186
+ imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
187
+ // Cast intrinsic for `Ref(String) -> Externref`.
188
+ const ret = getStringFromWasm0(arg0, arg1);
189
+ return ret;
148
190
  };
149
- imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
191
+ imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
192
+ // Cast intrinsic for `U64 -> Externref`.
150
193
  const ret = BigInt.asUintN(64, arg0);
151
194
  return ret;
152
195
  };
153
- imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
154
- const ret = new Error(getStringFromWasm0(arg0, arg1));
196
+ imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
197
+ // Cast intrinsic for `F64 -> Externref`.
198
+ const ret = arg0;
155
199
  return ret;
156
200
  };
157
201
  imports.wbg.__wbindgen_init_externref_table = function() {
158
- const table = wasm.__wbindgen_export_0;
202
+ const table = wasm.__wbindgen_export_2;
159
203
  const offset = table.grow(4);
160
204
  table.set(0, undefined);
161
205
  table.set(offset + 0, undefined);
@@ -164,17 +208,6 @@ function __wbg_get_imports() {
164
208
  table.set(offset + 3, false);
165
209
  ;
166
210
  };
167
- imports.wbg.__wbindgen_number_new = function(arg0) {
168
- const ret = arg0;
169
- return ret;
170
- };
171
- imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
172
- const ret = getStringFromWasm0(arg0, arg1);
173
- return ret;
174
- };
175
- imports.wbg.__wbindgen_throw = function(arg0, arg1) {
176
- throw new Error(getStringFromWasm0(arg0, arg1));
177
- };
178
211
 
179
212
  return imports;
180
213
  }
@@ -186,6 +219,7 @@ function __wbg_init_memory(imports, memory) {
186
219
  function __wbg_finalize_init(instance, module) {
187
220
  wasm = instance.exports;
188
221
  __wbg_init.__wbindgen_wasm_module = module;
222
+ cachedDataViewMemory0 = null;
189
223
  cachedUint8ArrayMemory0 = null;
190
224
 
191
225
 
package/moyo_wasm_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@spglib/moyo-wasm",
3
3
  "type": "module",
4
4
  "description": "WebAssembly bindings for moyo crystal symmetry analysis",
5
- "version": "0.5.0",
5
+ "version": "0.6.1",
6
6
  "license": "MIT OR Apache-2.0",
7
7
  "repository": {
8
8
  "type": "git",