@nirs4all/formats-wasm 0.1.0
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/README.md +80 -0
- package/nirs4all_formats_wasm.d.ts +66 -0
- package/nirs4all_formats_wasm.js +590 -0
- package/nirs4all_formats_wasm_bg.wasm +0 -0
- package/package.json +25 -0
package/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# nirs4all-formats (WebAssembly / JS)
|
|
2
|
+
|
|
3
|
+
Browser- and Node-friendly bridge to the `nirs4all-formats` Rust core. It runs the
|
|
4
|
+
format sniffers **and** the decoders entirely in WebAssembly, from in-memory
|
|
5
|
+
bytes — no filesystem required.
|
|
6
|
+
|
|
7
|
+
## Build
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Browser (ES modules)
|
|
11
|
+
wasm-pack build bindings/wasm --target web --release
|
|
12
|
+
# Node.js / Bun
|
|
13
|
+
wasm-pack build bindings/wasm --target nodejs --release --out-dir pkg-node
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
This emits the `nirs4all-formats-wasm` package (JS glue + `.wasm` + TypeScript
|
|
17
|
+
typings) under `pkg/` (or `pkg-node/`).
|
|
18
|
+
|
|
19
|
+
## Surface
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import init, {
|
|
23
|
+
version, features, readerCatalog, probeBytes, openBytes, openWithSidecars,
|
|
24
|
+
} from "./pkg/nirs4all_formats_wasm.js";
|
|
25
|
+
|
|
26
|
+
await init();
|
|
27
|
+
|
|
28
|
+
version(); // "0.1.0-alpha.1"
|
|
29
|
+
features(); // { hdf5: true, matlab: true, parquet: true }
|
|
30
|
+
readerCatalog(); // [{ reader: "nirs4all_formats::readers::jcamp" }, ...]
|
|
31
|
+
|
|
32
|
+
const bytes = new Uint8Array(await file.arrayBuffer());
|
|
33
|
+
|
|
34
|
+
// Sniff: ordered candidate readers, best first
|
|
35
|
+
probeBytes(file.name, bytes);
|
|
36
|
+
// [{ format: "jcamp-dx", reader: "...", confidence: "definite", reason: "..." }]
|
|
37
|
+
|
|
38
|
+
// Decode: SpectralRecord[] (same JSON shape as `nirs4all-formats read-json`)
|
|
39
|
+
const records = openBytes(file.name, bytes);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`openBytes` / `probeBytes` take the file **name** (several sniffers
|
|
43
|
+
disambiguate by extension) plus the bytes. The returned records match the
|
|
44
|
+
[data model](../../docs/DATA_MODEL.md): `signals`, `signal_type`, `targets`,
|
|
45
|
+
`metadata`, `provenance`, `quality_flags`.
|
|
46
|
+
|
|
47
|
+
### Sidecar formats
|
|
48
|
+
|
|
49
|
+
Multi-file formats (ENVI Standard `.img`+`.hdr`, ENVI SLI, AVIRIS/ERDAS LAN,
|
|
50
|
+
FGI XML+HDF5, NetCDF MFRSR) return an `UnsupportedSidecar` error from
|
|
51
|
+
`openBytes`. Supply the companions as a `{ name: Uint8Array }` map instead:
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
const records = openWithSidecars("cube.img", imgBytes, { "cube.hdr": hdrBytes });
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Scope & feature flags
|
|
58
|
+
|
|
59
|
+
The default WASM build compiles `fmt-hdf5`, `fmt-matlab`, and `fmt-parquet`
|
|
60
|
+
**on**. HDF5/NetCDF-backed readers, MATLAB MAT/RData readers, and Parquet table
|
|
61
|
+
readers are available in the browser, including snappy, uncompressed, and
|
|
62
|
+
zstd-compressed Parquet pages. Call `features()` to check the active bundle at
|
|
63
|
+
runtime.
|
|
64
|
+
|
|
65
|
+
## Smoke test
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
node bindings/wasm/tests/smoke.js
|
|
69
|
+
node bindings/wasm/tests/sidecars.test.js
|
|
70
|
+
node bindings/wasm/tests/fixture_matrix.js
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
`smoke.js` loads committed fixtures (CSV, JCAMP-DX, ASD binary, a non-data PDF)
|
|
74
|
+
and asserts the probe routes each to the expected reader; `sidecars.test.js`
|
|
75
|
+
exercises `openWithSidecars`. `fixture_matrix.js` opens a wider set of committed
|
|
76
|
+
single-file and sidecar fixtures through the WASM package, checks expected
|
|
77
|
+
non-NIRS/refusal paths, and compares the exercised readers to
|
|
78
|
+
`readerCatalog()`. The committed matrix covers every compiled reader except
|
|
79
|
+
Allotrope ADF, whose sample is local-only/non-redistributable; see
|
|
80
|
+
`samples/allotrope_adf/README.md`.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export function _start(): void;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Feature flags the WASM build was compiled with. Useful for runtime checks
|
|
8
|
+
* from JS ("does this WASM bundle have HDF5 support?").
|
|
9
|
+
*
|
|
10
|
+
* The default browser build enables `fmt-hdf5`, `fmt-matlab`, and
|
|
11
|
+
* `fmt-parquet`, including snappy, uncompressed, and zstd Parquet pages.
|
|
12
|
+
*/
|
|
13
|
+
export function features(): any;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Decode a file by name + bytes. Returns the spectral records as a JS array
|
|
17
|
+
* matching the JSON shape produced by `nirs4all-formats read-json`.
|
|
18
|
+
*
|
|
19
|
+
* Sidecar formats (ENVI Standard, AVIRIS LAN, FGI HDF5+XML, ...) return an
|
|
20
|
+
* `UnsupportedSidecar` error here; use `openWithSidecars` instead.
|
|
21
|
+
* Single-file HDF5 / NetCDF payloads decode directly through this entry
|
|
22
|
+
* point now that `fmt-hdf5` is on.
|
|
23
|
+
*/
|
|
24
|
+
export function openBytes(filename: string, bytes: Uint8Array): any;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Decode a file by name + bytes plus a map of sidecar names → byte
|
|
28
|
+
* payloads. Keys are relative path names (e.g. `"foo.hdr"` next to the
|
|
29
|
+
* primary file). For the WASM build this powers ENVI Standard, ENVI SLI,
|
|
30
|
+
* AVIRIS/ERDAS LAN and the HDF5-backed sidecar formats (FGI XML+HDF5,
|
|
31
|
+
* NetCDF MFRSR with its QC YAML) now that `fmt-hdf5` is on.
|
|
32
|
+
*/
|
|
33
|
+
export function openWithSidecars(filename: string, bytes: Uint8Array, sidecars: any): any;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Probe a file by name + bytes. Returns the ordered candidate readers.
|
|
37
|
+
*
|
|
38
|
+
* The file name is required because several sniffers disambiguate by
|
|
39
|
+
* extension (`.lan`, `.spc`, `.hdr`, ...). The first 8 KB of `bytes` is
|
|
40
|
+
* inspected; pass the entire buffer or just the head — the implementation is
|
|
41
|
+
* the same.
|
|
42
|
+
*/
|
|
43
|
+
export function probeBytes(filename: string, bytes: Uint8Array): any;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Readers compiled into this WASM bundle.
|
|
47
|
+
*
|
|
48
|
+
* This is intentionally generated by the Rust registry rather than duplicated
|
|
49
|
+
* in JavaScript, so browser UIs can show the real format coverage of the
|
|
50
|
+
* loaded bundle.
|
|
51
|
+
*/
|
|
52
|
+
export function readerCatalog(): any;
|
|
53
|
+
|
|
54
|
+
export function recommended_chunk_size_mb(): number;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Return the sidecars declared by the matching format reader for this named
|
|
58
|
+
* payload. The rules live inside each format module; this binding only
|
|
59
|
+
* serializes them for browser UIs.
|
|
60
|
+
*/
|
|
61
|
+
export function sidecarRequirements(filename: string, bytes: Uint8Array): any;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Crate version exposed to JS.
|
|
65
|
+
*/
|
|
66
|
+
export function version(): string;
|
|
@@ -0,0 +1,590 @@
|
|
|
1
|
+
/* @ts-self-types="./nirs4all_formats_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
function _start() {
|
|
4
|
+
wasm._start();
|
|
5
|
+
}
|
|
6
|
+
exports._start = _start;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Feature flags the WASM build was compiled with. Useful for runtime checks
|
|
10
|
+
* from JS ("does this WASM bundle have HDF5 support?").
|
|
11
|
+
*
|
|
12
|
+
* The default browser build enables `fmt-hdf5`, `fmt-matlab`, and
|
|
13
|
+
* `fmt-parquet`, including snappy, uncompressed, and zstd Parquet pages.
|
|
14
|
+
* @returns {any}
|
|
15
|
+
*/
|
|
16
|
+
function features() {
|
|
17
|
+
const ret = wasm.features();
|
|
18
|
+
if (ret[2]) {
|
|
19
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
20
|
+
}
|
|
21
|
+
return takeFromExternrefTable0(ret[0]);
|
|
22
|
+
}
|
|
23
|
+
exports.features = features;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Decode a file by name + bytes. Returns the spectral records as a JS array
|
|
27
|
+
* matching the JSON shape produced by `nirs4all-formats read-json`.
|
|
28
|
+
*
|
|
29
|
+
* Sidecar formats (ENVI Standard, AVIRIS LAN, FGI HDF5+XML, ...) return an
|
|
30
|
+
* `UnsupportedSidecar` error here; use `openWithSidecars` instead.
|
|
31
|
+
* Single-file HDF5 / NetCDF payloads decode directly through this entry
|
|
32
|
+
* point now that `fmt-hdf5` is on.
|
|
33
|
+
* @param {string} filename
|
|
34
|
+
* @param {Uint8Array} bytes
|
|
35
|
+
* @returns {any}
|
|
36
|
+
*/
|
|
37
|
+
function openBytes(filename, bytes) {
|
|
38
|
+
const ptr0 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
39
|
+
const len0 = WASM_VECTOR_LEN;
|
|
40
|
+
const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
41
|
+
const len1 = WASM_VECTOR_LEN;
|
|
42
|
+
const ret = wasm.openBytes(ptr0, len0, ptr1, len1);
|
|
43
|
+
if (ret[2]) {
|
|
44
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
45
|
+
}
|
|
46
|
+
return takeFromExternrefTable0(ret[0]);
|
|
47
|
+
}
|
|
48
|
+
exports.openBytes = openBytes;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Decode a file by name + bytes plus a map of sidecar names → byte
|
|
52
|
+
* payloads. Keys are relative path names (e.g. `"foo.hdr"` next to the
|
|
53
|
+
* primary file). For the WASM build this powers ENVI Standard, ENVI SLI,
|
|
54
|
+
* AVIRIS/ERDAS LAN and the HDF5-backed sidecar formats (FGI XML+HDF5,
|
|
55
|
+
* NetCDF MFRSR with its QC YAML) now that `fmt-hdf5` is on.
|
|
56
|
+
* @param {string} filename
|
|
57
|
+
* @param {Uint8Array} bytes
|
|
58
|
+
* @param {any} sidecars
|
|
59
|
+
* @returns {any}
|
|
60
|
+
*/
|
|
61
|
+
function openWithSidecars(filename, bytes, sidecars) {
|
|
62
|
+
const ptr0 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
63
|
+
const len0 = WASM_VECTOR_LEN;
|
|
64
|
+
const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
65
|
+
const len1 = WASM_VECTOR_LEN;
|
|
66
|
+
const ret = wasm.openWithSidecars(ptr0, len0, ptr1, len1, sidecars);
|
|
67
|
+
if (ret[2]) {
|
|
68
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
69
|
+
}
|
|
70
|
+
return takeFromExternrefTable0(ret[0]);
|
|
71
|
+
}
|
|
72
|
+
exports.openWithSidecars = openWithSidecars;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Probe a file by name + bytes. Returns the ordered candidate readers.
|
|
76
|
+
*
|
|
77
|
+
* The file name is required because several sniffers disambiguate by
|
|
78
|
+
* extension (`.lan`, `.spc`, `.hdr`, ...). The first 8 KB of `bytes` is
|
|
79
|
+
* inspected; pass the entire buffer or just the head — the implementation is
|
|
80
|
+
* the same.
|
|
81
|
+
* @param {string} filename
|
|
82
|
+
* @param {Uint8Array} bytes
|
|
83
|
+
* @returns {any}
|
|
84
|
+
*/
|
|
85
|
+
function probeBytes(filename, bytes) {
|
|
86
|
+
const ptr0 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
87
|
+
const len0 = WASM_VECTOR_LEN;
|
|
88
|
+
const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
89
|
+
const len1 = WASM_VECTOR_LEN;
|
|
90
|
+
const ret = wasm.probeBytes(ptr0, len0, ptr1, len1);
|
|
91
|
+
if (ret[2]) {
|
|
92
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
93
|
+
}
|
|
94
|
+
return takeFromExternrefTable0(ret[0]);
|
|
95
|
+
}
|
|
96
|
+
exports.probeBytes = probeBytes;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Readers compiled into this WASM bundle.
|
|
100
|
+
*
|
|
101
|
+
* This is intentionally generated by the Rust registry rather than duplicated
|
|
102
|
+
* in JavaScript, so browser UIs can show the real format coverage of the
|
|
103
|
+
* loaded bundle.
|
|
104
|
+
* @returns {any}
|
|
105
|
+
*/
|
|
106
|
+
function readerCatalog() {
|
|
107
|
+
const ret = wasm.readerCatalog();
|
|
108
|
+
if (ret[2]) {
|
|
109
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
110
|
+
}
|
|
111
|
+
return takeFromExternrefTable0(ret[0]);
|
|
112
|
+
}
|
|
113
|
+
exports.readerCatalog = readerCatalog;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @returns {number}
|
|
117
|
+
*/
|
|
118
|
+
function recommended_chunk_size_mb() {
|
|
119
|
+
const ret = wasm.recommended_chunk_size_mb();
|
|
120
|
+
return ret >>> 0;
|
|
121
|
+
}
|
|
122
|
+
exports.recommended_chunk_size_mb = recommended_chunk_size_mb;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Return the sidecars declared by the matching format reader for this named
|
|
126
|
+
* payload. The rules live inside each format module; this binding only
|
|
127
|
+
* serializes them for browser UIs.
|
|
128
|
+
* @param {string} filename
|
|
129
|
+
* @param {Uint8Array} bytes
|
|
130
|
+
* @returns {any}
|
|
131
|
+
*/
|
|
132
|
+
function sidecarRequirements(filename, bytes) {
|
|
133
|
+
const ptr0 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
134
|
+
const len0 = WASM_VECTOR_LEN;
|
|
135
|
+
const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
136
|
+
const len1 = WASM_VECTOR_LEN;
|
|
137
|
+
const ret = wasm.sidecarRequirements(ptr0, len0, ptr1, len1);
|
|
138
|
+
if (ret[2]) {
|
|
139
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
140
|
+
}
|
|
141
|
+
return takeFromExternrefTable0(ret[0]);
|
|
142
|
+
}
|
|
143
|
+
exports.sidecarRequirements = sidecarRequirements;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Crate version exposed to JS.
|
|
147
|
+
* @returns {string}
|
|
148
|
+
*/
|
|
149
|
+
function version() {
|
|
150
|
+
let deferred1_0;
|
|
151
|
+
let deferred1_1;
|
|
152
|
+
try {
|
|
153
|
+
const ret = wasm.version();
|
|
154
|
+
deferred1_0 = ret[0];
|
|
155
|
+
deferred1_1 = ret[1];
|
|
156
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
157
|
+
} finally {
|
|
158
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
exports.version = version;
|
|
162
|
+
function __wbg_get_imports() {
|
|
163
|
+
const import0 = {
|
|
164
|
+
__proto__: null,
|
|
165
|
+
__wbg_Error_9dc85fe1bc224456: function(arg0, arg1) {
|
|
166
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
167
|
+
return ret;
|
|
168
|
+
},
|
|
169
|
+
__wbg_Number_4779d427bae39753: function(arg0) {
|
|
170
|
+
const ret = Number(arg0);
|
|
171
|
+
return ret;
|
|
172
|
+
},
|
|
173
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
174
|
+
const ret = String(arg1);
|
|
175
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
176
|
+
const len1 = WASM_VECTOR_LEN;
|
|
177
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
178
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
179
|
+
},
|
|
180
|
+
__wbg___wbindgen_boolean_get_b131b2f36d6b2f55: function(arg0) {
|
|
181
|
+
const v = arg0;
|
|
182
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
183
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
184
|
+
},
|
|
185
|
+
__wbg___wbindgen_debug_string_56c147eb1a51f0c4: function(arg0, arg1) {
|
|
186
|
+
const ret = debugString(arg1);
|
|
187
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
188
|
+
const len1 = WASM_VECTOR_LEN;
|
|
189
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
190
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
191
|
+
},
|
|
192
|
+
__wbg___wbindgen_is_function_147961669f068cd4: function(arg0) {
|
|
193
|
+
const ret = typeof(arg0) === 'function';
|
|
194
|
+
return ret;
|
|
195
|
+
},
|
|
196
|
+
__wbg___wbindgen_is_object_3a2c414391dbf751: function(arg0) {
|
|
197
|
+
const val = arg0;
|
|
198
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
199
|
+
return ret;
|
|
200
|
+
},
|
|
201
|
+
__wbg___wbindgen_is_string_6541b0f6ecd4e8e5: function(arg0) {
|
|
202
|
+
const ret = typeof(arg0) === 'string';
|
|
203
|
+
return ret;
|
|
204
|
+
},
|
|
205
|
+
__wbg___wbindgen_is_undefined_4410e3c20a99fa97: function(arg0) {
|
|
206
|
+
const ret = arg0 === undefined;
|
|
207
|
+
return ret;
|
|
208
|
+
},
|
|
209
|
+
__wbg___wbindgen_jsval_loose_eq_e07e3b1f5db6da6c: function(arg0, arg1) {
|
|
210
|
+
const ret = arg0 == arg1;
|
|
211
|
+
return ret;
|
|
212
|
+
},
|
|
213
|
+
__wbg___wbindgen_number_get_588ed6b97f0d7e14: function(arg0, arg1) {
|
|
214
|
+
const obj = arg1;
|
|
215
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
216
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
217
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
218
|
+
},
|
|
219
|
+
__wbg___wbindgen_string_get_fa2687d531ed17a5: function(arg0, arg1) {
|
|
220
|
+
const obj = arg1;
|
|
221
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
222
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
223
|
+
var len1 = WASM_VECTOR_LEN;
|
|
224
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
225
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
226
|
+
},
|
|
227
|
+
__wbg___wbindgen_throw_bbadd78c1bac3a77: function(arg0, arg1) {
|
|
228
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
229
|
+
},
|
|
230
|
+
__wbg_call_91f00ddc43e01490: function() { return handleError(function (arg0, arg1) {
|
|
231
|
+
const ret = arg0.call(arg1);
|
|
232
|
+
return ret;
|
|
233
|
+
}, arguments); },
|
|
234
|
+
__wbg_done_6a8439e544ec6206: function(arg0) {
|
|
235
|
+
const ret = arg0.done;
|
|
236
|
+
return ret;
|
|
237
|
+
},
|
|
238
|
+
__wbg_entries_5a6a7e7e0df09fe5: function(arg0) {
|
|
239
|
+
const ret = Object.entries(arg0);
|
|
240
|
+
return ret;
|
|
241
|
+
},
|
|
242
|
+
__wbg_get_44e98e27bda25b5b: function() { return handleError(function (arg0, arg1) {
|
|
243
|
+
const ret = Reflect.get(arg0, arg1);
|
|
244
|
+
return ret;
|
|
245
|
+
}, arguments); },
|
|
246
|
+
__wbg_get_4b90d6d8c5deb5d5: function(arg0, arg1) {
|
|
247
|
+
const ret = arg0[arg1 >>> 0];
|
|
248
|
+
return ret;
|
|
249
|
+
},
|
|
250
|
+
__wbg_get_52a8a619f7b88df6: function() { return handleError(function (arg0, arg1) {
|
|
251
|
+
const ret = Reflect.get(arg0, arg1);
|
|
252
|
+
return ret;
|
|
253
|
+
}, arguments); },
|
|
254
|
+
__wbg_get_unchecked_46e778e3cec74b5e: function(arg0, arg1) {
|
|
255
|
+
const ret = arg0[arg1 >>> 0];
|
|
256
|
+
return ret;
|
|
257
|
+
},
|
|
258
|
+
__wbg_instanceof_ArrayBuffer_a581da923203f29f: function(arg0) {
|
|
259
|
+
let result;
|
|
260
|
+
try {
|
|
261
|
+
result = arg0 instanceof ArrayBuffer;
|
|
262
|
+
} catch (_) {
|
|
263
|
+
result = false;
|
|
264
|
+
}
|
|
265
|
+
const ret = result;
|
|
266
|
+
return ret;
|
|
267
|
+
},
|
|
268
|
+
__wbg_instanceof_Uint8Array_b6fe1ac89eba107e: function(arg0) {
|
|
269
|
+
let result;
|
|
270
|
+
try {
|
|
271
|
+
result = arg0 instanceof Uint8Array;
|
|
272
|
+
} catch (_) {
|
|
273
|
+
result = false;
|
|
274
|
+
}
|
|
275
|
+
const ret = result;
|
|
276
|
+
return ret;
|
|
277
|
+
},
|
|
278
|
+
__wbg_instanceof_Window_9e0fe7d3d1ff4342: function(arg0) {
|
|
279
|
+
let result;
|
|
280
|
+
try {
|
|
281
|
+
result = arg0 instanceof Window;
|
|
282
|
+
} catch (_) {
|
|
283
|
+
result = false;
|
|
284
|
+
}
|
|
285
|
+
const ret = result;
|
|
286
|
+
return ret;
|
|
287
|
+
},
|
|
288
|
+
__wbg_isArray_139f48e3c057ede8: function(arg0) {
|
|
289
|
+
const ret = Array.isArray(arg0);
|
|
290
|
+
return ret;
|
|
291
|
+
},
|
|
292
|
+
__wbg_isSafeInteger_c22ccb4af2201fe9: function(arg0) {
|
|
293
|
+
const ret = Number.isSafeInteger(arg0);
|
|
294
|
+
return ret;
|
|
295
|
+
},
|
|
296
|
+
__wbg_iterator_9b36cebf3be7b7cd: function() {
|
|
297
|
+
const ret = Symbol.iterator;
|
|
298
|
+
return ret;
|
|
299
|
+
},
|
|
300
|
+
__wbg_length_68a9d5278d084f4f: function(arg0) {
|
|
301
|
+
const ret = arg0.length;
|
|
302
|
+
return ret;
|
|
303
|
+
},
|
|
304
|
+
__wbg_length_fb04d16d7bdf6d4c: function(arg0) {
|
|
305
|
+
const ret = arg0.length;
|
|
306
|
+
return ret;
|
|
307
|
+
},
|
|
308
|
+
__wbg_navigator_e8073f0771c8d619: function(arg0) {
|
|
309
|
+
const ret = arg0.navigator;
|
|
310
|
+
return ret;
|
|
311
|
+
},
|
|
312
|
+
__wbg_new_0b303268aa395a38: function() {
|
|
313
|
+
const ret = new Array();
|
|
314
|
+
return ret;
|
|
315
|
+
},
|
|
316
|
+
__wbg_new_20b778a4c5c691c3: function() {
|
|
317
|
+
const ret = new Object();
|
|
318
|
+
return ret;
|
|
319
|
+
},
|
|
320
|
+
__wbg_new_883c0db065f06efd: function() {
|
|
321
|
+
const ret = new Map();
|
|
322
|
+
return ret;
|
|
323
|
+
},
|
|
324
|
+
__wbg_new_b06772b280cc6e52: function(arg0) {
|
|
325
|
+
const ret = new Uint8Array(arg0);
|
|
326
|
+
return ret;
|
|
327
|
+
},
|
|
328
|
+
__wbg_next_8cb028b6ba50743f: function() { return handleError(function (arg0) {
|
|
329
|
+
const ret = arg0.next();
|
|
330
|
+
return ret;
|
|
331
|
+
}, arguments); },
|
|
332
|
+
__wbg_next_cfd0b146c9538df8: function(arg0) {
|
|
333
|
+
const ret = arg0.next;
|
|
334
|
+
return ret;
|
|
335
|
+
},
|
|
336
|
+
__wbg_prototypesetcall_956c7493c68e29b4: function(arg0, arg1, arg2) {
|
|
337
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
338
|
+
},
|
|
339
|
+
__wbg_set_5f806304fb633ab3: function(arg0, arg1, arg2) {
|
|
340
|
+
const ret = arg0.set(arg1, arg2);
|
|
341
|
+
return ret;
|
|
342
|
+
},
|
|
343
|
+
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
344
|
+
arg0[arg1] = arg2;
|
|
345
|
+
},
|
|
346
|
+
__wbg_set_da33c120a6584674: function(arg0, arg1, arg2) {
|
|
347
|
+
arg0[arg1 >>> 0] = arg2;
|
|
348
|
+
},
|
|
349
|
+
__wbg_static_accessor_GLOBAL_60a4124bab7dcc9a: function() {
|
|
350
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
351
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
352
|
+
},
|
|
353
|
+
__wbg_static_accessor_GLOBAL_THIS_95ca6460658b5d13: function() {
|
|
354
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
355
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
356
|
+
},
|
|
357
|
+
__wbg_static_accessor_SELF_4c95f759a91e9aae: function() {
|
|
358
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
359
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
360
|
+
},
|
|
361
|
+
__wbg_static_accessor_WINDOW_44b435597f9e9ee7: function() {
|
|
362
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
363
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
364
|
+
},
|
|
365
|
+
__wbg_value_3d3defe09fb1ffca: function(arg0) {
|
|
366
|
+
const ret = arg0.value;
|
|
367
|
+
return ret;
|
|
368
|
+
},
|
|
369
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
370
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
371
|
+
const ret = arg0;
|
|
372
|
+
return ret;
|
|
373
|
+
},
|
|
374
|
+
__wbindgen_cast_0000000000000002: function(arg0) {
|
|
375
|
+
// Cast intrinsic for `I64 -> Externref`.
|
|
376
|
+
const ret = arg0;
|
|
377
|
+
return ret;
|
|
378
|
+
},
|
|
379
|
+
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
380
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
381
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
382
|
+
return ret;
|
|
383
|
+
},
|
|
384
|
+
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
385
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
386
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
387
|
+
return ret;
|
|
388
|
+
},
|
|
389
|
+
__wbindgen_init_externref_table: function() {
|
|
390
|
+
const table = wasm.__wbindgen_externrefs;
|
|
391
|
+
const offset = table.grow(4);
|
|
392
|
+
table.set(0, undefined);
|
|
393
|
+
table.set(offset + 0, undefined);
|
|
394
|
+
table.set(offset + 1, null);
|
|
395
|
+
table.set(offset + 2, true);
|
|
396
|
+
table.set(offset + 3, false);
|
|
397
|
+
},
|
|
398
|
+
};
|
|
399
|
+
return {
|
|
400
|
+
__proto__: null,
|
|
401
|
+
"./nirs4all_formats_wasm_bg.js": import0,
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
function addToExternrefTable0(obj) {
|
|
406
|
+
const idx = wasm.__externref_table_alloc();
|
|
407
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
408
|
+
return idx;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function debugString(val) {
|
|
412
|
+
// primitive types
|
|
413
|
+
const type = typeof val;
|
|
414
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
415
|
+
return `${val}`;
|
|
416
|
+
}
|
|
417
|
+
if (type == 'string') {
|
|
418
|
+
return `"${val}"`;
|
|
419
|
+
}
|
|
420
|
+
if (type == 'symbol') {
|
|
421
|
+
const description = val.description;
|
|
422
|
+
if (description == null) {
|
|
423
|
+
return 'Symbol';
|
|
424
|
+
} else {
|
|
425
|
+
return `Symbol(${description})`;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
if (type == 'function') {
|
|
429
|
+
const name = val.name;
|
|
430
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
431
|
+
return `Function(${name})`;
|
|
432
|
+
} else {
|
|
433
|
+
return 'Function';
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
// objects
|
|
437
|
+
if (Array.isArray(val)) {
|
|
438
|
+
const length = val.length;
|
|
439
|
+
let debug = '[';
|
|
440
|
+
if (length > 0) {
|
|
441
|
+
debug += debugString(val[0]);
|
|
442
|
+
}
|
|
443
|
+
for(let i = 1; i < length; i++) {
|
|
444
|
+
debug += ', ' + debugString(val[i]);
|
|
445
|
+
}
|
|
446
|
+
debug += ']';
|
|
447
|
+
return debug;
|
|
448
|
+
}
|
|
449
|
+
// Test for built-in
|
|
450
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
451
|
+
let className;
|
|
452
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
453
|
+
className = builtInMatches[1];
|
|
454
|
+
} else {
|
|
455
|
+
// Failed to match the standard '[object ClassName]'
|
|
456
|
+
return toString.call(val);
|
|
457
|
+
}
|
|
458
|
+
if (className == 'Object') {
|
|
459
|
+
// we're a user defined class or Object
|
|
460
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
461
|
+
// easier than looping through ownProperties of `val`.
|
|
462
|
+
try {
|
|
463
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
464
|
+
} catch (_) {
|
|
465
|
+
return 'Object';
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
// errors
|
|
469
|
+
if (val instanceof Error) {
|
|
470
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
471
|
+
}
|
|
472
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
473
|
+
return className;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
477
|
+
ptr = ptr >>> 0;
|
|
478
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
let cachedDataViewMemory0 = null;
|
|
482
|
+
function getDataViewMemory0() {
|
|
483
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
484
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
485
|
+
}
|
|
486
|
+
return cachedDataViewMemory0;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function getStringFromWasm0(ptr, len) {
|
|
490
|
+
return decodeText(ptr >>> 0, len);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
let cachedUint8ArrayMemory0 = null;
|
|
494
|
+
function getUint8ArrayMemory0() {
|
|
495
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
496
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
497
|
+
}
|
|
498
|
+
return cachedUint8ArrayMemory0;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
function handleError(f, args) {
|
|
502
|
+
try {
|
|
503
|
+
return f.apply(this, args);
|
|
504
|
+
} catch (e) {
|
|
505
|
+
const idx = addToExternrefTable0(e);
|
|
506
|
+
wasm.__wbindgen_exn_store(idx);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
function isLikeNone(x) {
|
|
511
|
+
return x === undefined || x === null;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
515
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
516
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
517
|
+
WASM_VECTOR_LEN = arg.length;
|
|
518
|
+
return ptr;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
522
|
+
if (realloc === undefined) {
|
|
523
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
524
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
525
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
526
|
+
WASM_VECTOR_LEN = buf.length;
|
|
527
|
+
return ptr;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
let len = arg.length;
|
|
531
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
532
|
+
|
|
533
|
+
const mem = getUint8ArrayMemory0();
|
|
534
|
+
|
|
535
|
+
let offset = 0;
|
|
536
|
+
|
|
537
|
+
for (; offset < len; offset++) {
|
|
538
|
+
const code = arg.charCodeAt(offset);
|
|
539
|
+
if (code > 0x7F) break;
|
|
540
|
+
mem[ptr + offset] = code;
|
|
541
|
+
}
|
|
542
|
+
if (offset !== len) {
|
|
543
|
+
if (offset !== 0) {
|
|
544
|
+
arg = arg.slice(offset);
|
|
545
|
+
}
|
|
546
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
547
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
548
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
549
|
+
|
|
550
|
+
offset += ret.written;
|
|
551
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
WASM_VECTOR_LEN = offset;
|
|
555
|
+
return ptr;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
function takeFromExternrefTable0(idx) {
|
|
559
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
560
|
+
wasm.__externref_table_dealloc(idx);
|
|
561
|
+
return value;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
565
|
+
cachedTextDecoder.decode();
|
|
566
|
+
function decodeText(ptr, len) {
|
|
567
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
const cachedTextEncoder = new TextEncoder();
|
|
571
|
+
|
|
572
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
573
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
574
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
575
|
+
view.set(buf);
|
|
576
|
+
return {
|
|
577
|
+
read: arg.length,
|
|
578
|
+
written: buf.length
|
|
579
|
+
};
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
let WASM_VECTOR_LEN = 0;
|
|
584
|
+
|
|
585
|
+
const wasmPath = `${__dirname}/nirs4all_formats_wasm_bg.wasm`;
|
|
586
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
587
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
588
|
+
let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
|
|
589
|
+
let wasm = wasmInstance.exports;
|
|
590
|
+
wasm.__wbindgen_start();
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nirs4all/formats-wasm",
|
|
3
|
+
"collaborators": [
|
|
4
|
+
"G. Beurier <beurier@cirad.fr>"
|
|
5
|
+
],
|
|
6
|
+
"description": "WebAssembly bindings for nirs4all-formats.",
|
|
7
|
+
"version": "0.1.0",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/GBeurier/nirs4all-formats.git",
|
|
12
|
+
"directory": "bindings/wasm"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"nirs4all_formats_wasm_bg.wasm",
|
|
16
|
+
"nirs4all_formats_wasm.js",
|
|
17
|
+
"nirs4all_formats_wasm.d.ts"
|
|
18
|
+
],
|
|
19
|
+
"main": "nirs4all_formats_wasm.js",
|
|
20
|
+
"types": "nirs4all_formats_wasm.d.ts",
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public",
|
|
23
|
+
"provenance": true
|
|
24
|
+
}
|
|
25
|
+
}
|