@spglib/moyo-wasm 0.6.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.js CHANGED
@@ -1,7 +1,5 @@
1
1
  let wasm;
2
2
 
3
- let WASM_VECTOR_LEN = 0;
4
-
5
3
  let cachedUint8ArrayMemory0 = null;
6
4
 
7
5
  function getUint8ArrayMemory0() {
@@ -11,20 +9,41 @@ function getUint8ArrayMemory0() {
11
9
  return cachedUint8ArrayMemory0;
12
10
  }
13
11
 
14
- const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
12
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
13
+
14
+ cachedTextDecoder.decode();
15
15
 
16
- const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
17
- ? function (arg, view) {
18
- return cachedTextEncoder.encodeInto(arg, view);
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
+
28
+ function getStringFromWasm0(ptr, len) {
29
+ ptr = ptr >>> 0;
30
+ return decodeText(ptr, len);
31
+ }
32
+
33
+ let WASM_VECTOR_LEN = 0;
34
+
35
+ const cachedTextEncoder = new TextEncoder();
36
+
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
+ }
19
46
  }
20
- : function (arg, view) {
21
- const buf = cachedTextEncoder.encode(arg);
22
- view.set(buf);
23
- return {
24
- read: arg.length,
25
- written: buf.length
26
- };
27
- });
28
47
 
29
48
  function passStringToWasm0(arg, malloc, realloc) {
30
49
 
@@ -55,7 +74,7 @@ function passStringToWasm0(arg, malloc, realloc) {
55
74
  }
56
75
  ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
57
76
  const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
58
- const ret = encodeString(arg, view);
77
+ const ret = cachedTextEncoder.encodeInto(arg, view);
59
78
 
60
79
  offset += ret.written;
61
80
  ptr = realloc(ptr, len, offset, 1) >>> 0;
@@ -74,15 +93,6 @@ function getDataViewMemory0() {
74
93
  return cachedDataViewMemory0;
75
94
  }
76
95
 
77
- const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
78
-
79
- if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
80
-
81
- function getStringFromWasm0(ptr, len) {
82
- ptr = ptr >>> 0;
83
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
84
- }
85
-
86
96
  function takeFromExternrefTable0(idx) {
87
97
  const value = wasm.__wbindgen_export_2.get(idx);
88
98
  wasm.__externref_table_dealloc(idx);
@@ -107,6 +117,8 @@ export function analyze_cell(cell_json, symprec, setting) {
107
117
  return takeFromExternrefTable0(ret[0]);
108
118
  }
109
119
 
120
+ const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
121
+
110
122
  async function __wbg_load(module, imports) {
111
123
  if (typeof Response === 'function' && module instanceof Response) {
112
124
  if (typeof WebAssembly.instantiateStreaming === 'function') {
@@ -114,7 +126,9 @@ async function __wbg_load(module, imports) {
114
126
  return await WebAssembly.instantiateStreaming(module, imports);
115
127
 
116
128
  } catch (e) {
117
- 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') {
118
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);
119
133
 
120
134
  } else {
@@ -141,6 +155,10 @@ async function __wbg_load(module, imports) {
141
155
  function __wbg_get_imports() {
142
156
  const imports = {};
143
157
  imports.wbg = {};
158
+ imports.wbg.__wbg_Error_e17e777aac105295 = function(arg0, arg1) {
159
+ const ret = Error(getStringFromWasm0(arg0, arg1));
160
+ return ret;
161
+ };
144
162
  imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
145
163
  const ret = String(arg1);
146
164
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -148,26 +166,36 @@ function __wbg_get_imports() {
148
166
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
149
167
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
150
168
  };
151
- imports.wbg.__wbg_new_405e22f390576ce2 = function() {
169
+ imports.wbg.__wbg_new_19c25a3f2fa63a02 = function() {
152
170
  const ret = new Object();
153
171
  return ret;
154
172
  };
155
- imports.wbg.__wbg_new_78feb108b6472713 = function() {
173
+ imports.wbg.__wbg_new_1f3a344cf3123716 = function() {
156
174
  const ret = new Array();
157
175
  return ret;
158
176
  };
159
- imports.wbg.__wbg_set_37837023f3d740e8 = function(arg0, arg1, arg2) {
160
- arg0[arg1 >>> 0] = arg2;
161
- };
162
177
  imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
163
178
  arg0[arg1] = arg2;
164
179
  };
165
- imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
180
+ imports.wbg.__wbg_set_90f6c0f7bd8c0415 = function(arg0, arg1, arg2) {
181
+ arg0[arg1 >>> 0] = arg2;
182
+ };
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;
190
+ };
191
+ imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
192
+ // Cast intrinsic for `U64 -> Externref`.
166
193
  const ret = BigInt.asUintN(64, arg0);
167
194
  return ret;
168
195
  };
169
- imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
170
- 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;
171
199
  return ret;
172
200
  };
173
201
  imports.wbg.__wbindgen_init_externref_table = function() {
@@ -180,17 +208,6 @@ function __wbg_get_imports() {
180
208
  table.set(offset + 3, false);
181
209
  ;
182
210
  };
183
- imports.wbg.__wbindgen_number_new = function(arg0) {
184
- const ret = arg0;
185
- return ret;
186
- };
187
- imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
188
- const ret = getStringFromWasm0(arg0, arg1);
189
- return ret;
190
- };
191
- imports.wbg.__wbindgen_throw = function(arg0, arg1) {
192
- throw new Error(getStringFromWasm0(arg0, arg1));
193
- };
194
211
 
195
212
  return imports;
196
213
  }
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.6.0",
5
+ "version": "0.6.1",
6
6
  "license": "MIT OR Apache-2.0",
7
7
  "repository": {
8
8
  "type": "git",