@esm.sh/oxide-wasm 0.1.2 → 0.1.3
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/package.json +1 -1
- package/pkg/oxide_wasm.js +38 -23
- package/pkg/oxide_wasm_bg.wasm +0 -0
package/package.json
CHANGED
package/pkg/oxide_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
|
|
30
|
+
return decodeText(ptr, len);
|
|
19
31
|
}
|
|
20
32
|
|
|
21
33
|
let WASM_VECTOR_LEN = 0;
|
|
22
34
|
|
|
23
|
-
const cachedTextEncoder =
|
|
35
|
+
const cachedTextEncoder = new TextEncoder();
|
|
24
36
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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 =
|
|
77
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
68
78
|
|
|
69
79
|
offset += ret.written;
|
|
70
80
|
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
@@ -106,6 +116,8 @@ export function extract(input) {
|
|
|
106
116
|
return v2;
|
|
107
117
|
}
|
|
108
118
|
|
|
119
|
+
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
|
|
120
|
+
|
|
109
121
|
async function __wbg_load(module, imports) {
|
|
110
122
|
if (typeof Response === 'function' && module instanceof Response) {
|
|
111
123
|
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
@@ -113,7 +125,9 @@ async function __wbg_load(module, imports) {
|
|
|
113
125
|
return await WebAssembly.instantiateStreaming(module, imports);
|
|
114
126
|
|
|
115
127
|
} catch (e) {
|
|
116
|
-
|
|
128
|
+
const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
|
|
129
|
+
|
|
130
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
117
131
|
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);
|
|
118
132
|
|
|
119
133
|
} else {
|
|
@@ -140,6 +154,11 @@ async function __wbg_load(module, imports) {
|
|
|
140
154
|
function __wbg_get_imports() {
|
|
141
155
|
const imports = {};
|
|
142
156
|
imports.wbg = {};
|
|
157
|
+
imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
158
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
159
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
160
|
+
return ret;
|
|
161
|
+
};
|
|
143
162
|
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
144
163
|
const table = wasm.__wbindgen_export_0;
|
|
145
164
|
const offset = table.grow(4);
|
|
@@ -150,10 +169,6 @@ function __wbg_get_imports() {
|
|
|
150
169
|
table.set(offset + 3, false);
|
|
151
170
|
;
|
|
152
171
|
};
|
|
153
|
-
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
|
|
154
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
155
|
-
return ret;
|
|
156
|
-
};
|
|
157
172
|
|
|
158
173
|
return imports;
|
|
159
174
|
}
|
package/pkg/oxide_wasm_bg.wasm
CHANGED
|
Binary file
|