@esm.sh/oxide-wasm 0.1.3 → 0.1.4
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/index.mjs +3 -3
- package/package.json +1 -1
- package/pkg/oxide_wasm.js +43 -63
- package/pkg/oxide_wasm_bg.wasm +0 -0
package/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import initWasm, {
|
|
1
|
+
import initWasm, { extract as wasmExtract, initSync as initWasmSync } from "./pkg/oxide_wasm.js";
|
|
2
2
|
|
|
3
3
|
export function extract(input) {
|
|
4
|
-
if (typeof input !== "string"
|
|
5
|
-
throw new
|
|
4
|
+
if (typeof input !== "string") {
|
|
5
|
+
throw new TypeError("input must be a non-empty string");
|
|
6
6
|
}
|
|
7
7
|
return wasmExtract(input);
|
|
8
8
|
}
|
package/package.json
CHANGED
package/pkg/oxide_wasm.js
CHANGED
|
@@ -1,28 +1,22 @@
|
|
|
1
1
|
let wasm;
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
4
|
+
ptr = ptr >>> 0;
|
|
5
|
+
const mem = getDataViewMemory0();
|
|
6
|
+
const result = [];
|
|
7
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
8
|
+
result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
11
|
+
return result;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
|
-
let
|
|
13
|
-
|
|
14
|
-
|
|
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;
|
|
14
|
+
let cachedDataViewMemory0 = null;
|
|
15
|
+
function getDataViewMemory0() {
|
|
16
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
17
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
24
18
|
}
|
|
25
|
-
return
|
|
19
|
+
return cachedDataViewMemory0;
|
|
26
20
|
}
|
|
27
21
|
|
|
28
22
|
function getStringFromWasm0(ptr, len) {
|
|
@@ -30,23 +24,15 @@ function getStringFromWasm0(ptr, len) {
|
|
|
30
24
|
return decodeText(ptr, len);
|
|
31
25
|
}
|
|
32
26
|
|
|
33
|
-
let
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
};
|
|
27
|
+
let cachedUint8ArrayMemory0 = null;
|
|
28
|
+
function getUint8ArrayMemory0() {
|
|
29
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
30
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
45
31
|
}
|
|
32
|
+
return cachedUint8ArrayMemory0;
|
|
46
33
|
}
|
|
47
34
|
|
|
48
35
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
49
|
-
|
|
50
36
|
if (realloc === undefined) {
|
|
51
37
|
const buf = cachedTextEncoder.encode(arg);
|
|
52
38
|
const ptr = malloc(buf.length, 1) >>> 0;
|
|
@@ -67,7 +53,6 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
67
53
|
if (code > 0x7F) break;
|
|
68
54
|
mem[ptr + offset] = code;
|
|
69
55
|
}
|
|
70
|
-
|
|
71
56
|
if (offset !== len) {
|
|
72
57
|
if (offset !== 0) {
|
|
73
58
|
arg = arg.slice(offset);
|
|
@@ -84,25 +69,35 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
84
69
|
return ptr;
|
|
85
70
|
}
|
|
86
71
|
|
|
87
|
-
let
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
72
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
73
|
+
cachedTextDecoder.decode();
|
|
74
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
75
|
+
let numBytesDecoded = 0;
|
|
76
|
+
function decodeText(ptr, len) {
|
|
77
|
+
numBytesDecoded += len;
|
|
78
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
79
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
80
|
+
cachedTextDecoder.decode();
|
|
81
|
+
numBytesDecoded = len;
|
|
92
82
|
}
|
|
93
|
-
return
|
|
83
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
94
84
|
}
|
|
95
85
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
86
|
+
const cachedTextEncoder = new TextEncoder();
|
|
87
|
+
|
|
88
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
89
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
90
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
91
|
+
view.set(buf);
|
|
92
|
+
return {
|
|
93
|
+
read: arg.length,
|
|
94
|
+
written: buf.length
|
|
95
|
+
};
|
|
102
96
|
}
|
|
103
|
-
wasm.__externref_drop_slice(ptr, len);
|
|
104
|
-
return result;
|
|
105
97
|
}
|
|
98
|
+
|
|
99
|
+
let WASM_VECTOR_LEN = 0;
|
|
100
|
+
|
|
106
101
|
/**
|
|
107
102
|
* @param {string} input
|
|
108
103
|
* @returns {any[]}
|
|
@@ -123,7 +118,6 @@ async function __wbg_load(module, imports) {
|
|
|
123
118
|
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
124
119
|
try {
|
|
125
120
|
return await WebAssembly.instantiateStreaming(module, imports);
|
|
126
|
-
|
|
127
121
|
} catch (e) {
|
|
128
122
|
const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
|
|
129
123
|
|
|
@@ -138,13 +132,11 @@ async function __wbg_load(module, imports) {
|
|
|
138
132
|
|
|
139
133
|
const bytes = await module.arrayBuffer();
|
|
140
134
|
return await WebAssembly.instantiate(bytes, imports);
|
|
141
|
-
|
|
142
135
|
} else {
|
|
143
136
|
const instance = await WebAssembly.instantiate(module, imports);
|
|
144
137
|
|
|
145
138
|
if (instance instanceof WebAssembly.Instance) {
|
|
146
139
|
return { instance, module };
|
|
147
|
-
|
|
148
140
|
} else {
|
|
149
141
|
return instance;
|
|
150
142
|
}
|
|
@@ -160,23 +152,18 @@ function __wbg_get_imports() {
|
|
|
160
152
|
return ret;
|
|
161
153
|
};
|
|
162
154
|
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
163
|
-
const table = wasm.
|
|
155
|
+
const table = wasm.__wbindgen_externrefs;
|
|
164
156
|
const offset = table.grow(4);
|
|
165
157
|
table.set(0, undefined);
|
|
166
158
|
table.set(offset + 0, undefined);
|
|
167
159
|
table.set(offset + 1, null);
|
|
168
160
|
table.set(offset + 2, true);
|
|
169
161
|
table.set(offset + 3, false);
|
|
170
|
-
;
|
|
171
162
|
};
|
|
172
163
|
|
|
173
164
|
return imports;
|
|
174
165
|
}
|
|
175
166
|
|
|
176
|
-
function __wbg_init_memory(imports, memory) {
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
|
|
180
167
|
function __wbg_finalize_init(instance, module) {
|
|
181
168
|
wasm = instance.exports;
|
|
182
169
|
__wbg_init.__wbindgen_wasm_module = module;
|
|
@@ -201,15 +188,10 @@ function initSync(module) {
|
|
|
201
188
|
}
|
|
202
189
|
|
|
203
190
|
const imports = __wbg_get_imports();
|
|
204
|
-
|
|
205
|
-
__wbg_init_memory(imports);
|
|
206
|
-
|
|
207
191
|
if (!(module instanceof WebAssembly.Module)) {
|
|
208
192
|
module = new WebAssembly.Module(module);
|
|
209
193
|
}
|
|
210
|
-
|
|
211
194
|
const instance = new WebAssembly.Instance(module, imports);
|
|
212
|
-
|
|
213
195
|
return __wbg_finalize_init(instance, module);
|
|
214
196
|
}
|
|
215
197
|
|
|
@@ -234,8 +216,6 @@ async function __wbg_init(module_or_path) {
|
|
|
234
216
|
module_or_path = fetch(module_or_path);
|
|
235
217
|
}
|
|
236
218
|
|
|
237
|
-
__wbg_init_memory(imports);
|
|
238
|
-
|
|
239
219
|
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
240
220
|
|
|
241
221
|
return __wbg_finalize_init(instance, module);
|
package/pkg/oxide_wasm_bg.wasm
CHANGED
|
Binary file
|