@nirs4all/io-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 +94 -0
- package/nirs4all_io_wasm.d.ts +69 -0
- package/nirs4all_io_wasm.js +590 -0
- package/nirs4all_io_wasm_bg.wasm +0 -0
- package/package.json +25 -0
package/README.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<!-- SPDX-License-Identifier: CeCILL-2.1 OR AGPL-3.0-or-later -->
|
|
2
|
+
# WASM binding (EPIC 11.4)
|
|
3
|
+
|
|
4
|
+
`wasm-bindgen` binding built with `wasm-pack`, backed directly by
|
|
5
|
+
`nirs4all-io-core` (the pure core, **not** the native filesystem facade). WASM
|
|
6
|
+
has no filesystem (D-R7), so this binding exposes the fs-free JSON surface and a
|
|
7
|
+
browser-oriented in-memory inference entry point.
|
|
8
|
+
|
|
9
|
+
A thin wrapper: every function just translates strings to/from the single Rust
|
|
10
|
+
core, identical to the other bindings.
|
|
11
|
+
|
|
12
|
+
## Exposed functions
|
|
13
|
+
|
|
14
|
+
```js
|
|
15
|
+
to_spec(spec_json) // String -> canonical DatasetSpec JSON string
|
|
16
|
+
validate(spec_json) // String -> undefined; throws when the spec is invalid
|
|
17
|
+
inferFiles(files, options) // [{name, bytes: Uint8Array}], {conventions?} -> DatasetPlan object
|
|
18
|
+
inferRecords(recordSets) // decoded nirs4all-formats records -> DatasetPlan object
|
|
19
|
+
inferDataset(files, recordSets, options) // browser raw files + decoded records -> DatasetPlan object
|
|
20
|
+
proposeDataset(files, recordSets, options) // iterative builder: -> {plan, proposals, spec, valid, validation_errors}
|
|
21
|
+
assembleDataset(files, recordSets, specJson) // materialize a DatasetSpec -> AssembledDataset object
|
|
22
|
+
version() // () -> crate version string (semver)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`to_spec` normalizes a spec/config JSON string into the canonical `DatasetSpec`
|
|
26
|
+
JSON. `validate` parses a `DatasetSpec` JSON string and throws on an invalid
|
|
27
|
+
spec. `inferFiles` runs the same convention / column-role / signal / task
|
|
28
|
+
inference over named byte buffers and returns a `DatasetPlan` with an editable
|
|
29
|
+
`resolved_spec`. `inferRecords` infers from the decoded spectral record shape
|
|
30
|
+
emitted by `nirs4all-formats`. `inferDataset` is the one-shot browser entry
|
|
31
|
+
point: it combines raw files and decoded records in Rust, keeping the page as a
|
|
32
|
+
thin UI.
|
|
33
|
+
|
|
34
|
+
`proposeDataset` is the **iterative** builder entry point. It post-processes
|
|
35
|
+
`inferDataset`: it synthesises a *provisional* source for each un-sourced tabular
|
|
36
|
+
file, applies the user's `options.confirmed` decisions (an array of
|
|
37
|
+
`{kind, target, value, status?}` *locks* over
|
|
38
|
+
structure/role/partition/identity/pairing/signal_type/task_type/folds — rewriting
|
|
39
|
+
the spec fields the assembler reads; `structure` is advisory), and returns the
|
|
40
|
+
still-open decisions as confirmable
|
|
41
|
+
`proposals` (each with `alternatives`, `evidence`, `score`, `ambiguous`),
|
|
42
|
+
including a pairing-by-row-count heuristic. Feed an accepted proposal back as a
|
|
43
|
+
`confirmed` lock and call it again to refine. `assembleDataset` materializes the
|
|
44
|
+
resulting `spec` into per-partition X/y/metadata blocks for a preview.
|
|
45
|
+
|
|
46
|
+
## Build & install
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
wasm-pack build bindings/wasm --target nodejs --out-dir pkg
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
This emits `bindings/wasm/pkg/` (the `nirs4all_io_wasm.js` module + the `.wasm`).
|
|
53
|
+
Require it from Node:
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
const wasm = require("./bindings/wasm/pkg/nirs4all_io_wasm.js");
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Usage
|
|
60
|
+
|
|
61
|
+
```js
|
|
62
|
+
const wasm = require("./pkg/nirs4all_io_wasm.js");
|
|
63
|
+
|
|
64
|
+
const specJson = wasm.to_spec(JSON.stringify({
|
|
65
|
+
name: "wasm-smoke",
|
|
66
|
+
sources: [{ id: "x", role: "features", input: "x.csv" }],
|
|
67
|
+
}));
|
|
68
|
+
|
|
69
|
+
wasm.validate(specJson); // ok; throws on an invalid spec
|
|
70
|
+
const plan = wasm.inferFiles([
|
|
71
|
+
{ name: "dataset.csv", bytes: new TextEncoder().encode("id;1000;1005;y\ns1;0.1;0.2;1\n") },
|
|
72
|
+
], {});
|
|
73
|
+
const browserPlan = wasm.inferDataset(
|
|
74
|
+
[{ name: "scan.asd", bytes: new Uint8Array([0, 1, 2, 3]) }],
|
|
75
|
+
[{
|
|
76
|
+
source: "scan.asd",
|
|
77
|
+
format: "asd-fieldspec",
|
|
78
|
+
records: [{
|
|
79
|
+
signals: { absorbance: { values: [0.1, 0.2], axis: { values: [1000, 1005], unit: "nm" } } },
|
|
80
|
+
targets: { protein: 12.4 },
|
|
81
|
+
metadata: { sample_id: "s1" },
|
|
82
|
+
}],
|
|
83
|
+
}],
|
|
84
|
+
{}
|
|
85
|
+
);
|
|
86
|
+
console.log(wasm.version());
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Test
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
wasm-pack build bindings/wasm --target nodejs --out-dir pkg
|
|
93
|
+
node bindings/wasm/tests/node_smoke.cjs
|
|
94
|
+
```
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Assemble a `DatasetSpec` into a materialized, target-agnostic dataset, fs-free.
|
|
6
|
+
*
|
|
7
|
+
* `files` = array of `{name, bytes}` — CSV/tabular bytes the formats layer won't
|
|
8
|
+
* decode (y / metadata tables). `recordSets` = array of `{source, format?,
|
|
9
|
+
* records}` — pre-decoded `nirs4all-formats` records (signals → X, targets,
|
|
10
|
+
* metadata). `spec` = a `DatasetSpec` JSON string (typically `plan.resolved_spec`);
|
|
11
|
+
* its source `input` strings must match the `name`/`source` of the supplied
|
|
12
|
+
* sources (exact, then file-stem, then glob). Returns `AssembledDataset` as a
|
|
13
|
+
* plain JS object (per-partition `blocks` with `x`/`y`/headers/metadata + `folds`).
|
|
14
|
+
*
|
|
15
|
+
* `index_file`/`folds.file` partitions are not browser-reachable here (no fs) and
|
|
16
|
+
* raise an error — column/inline partitions and folds work.
|
|
17
|
+
*/
|
|
18
|
+
export function assembleDataset(files: any, record_sets: any, spec: string): any;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Infer a browser dataset plan from raw files and decoded spectral records.
|
|
22
|
+
*
|
|
23
|
+
* `files` must be an array of `{name, bytes}`. `recordSets` must be an array
|
|
24
|
+
* of `{source, format?, records}` where records follow `nirs4all-formats`.
|
|
25
|
+
*/
|
|
26
|
+
export function inferDataset(files: any, record_sets: any, options: any): any;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Infer a dataset plan from browser-provided files.
|
|
30
|
+
*
|
|
31
|
+
* `files` must be an array of `{name, bytes}` where `bytes` is a
|
|
32
|
+
* `Uint8Array`. `options.conventions` can override the default
|
|
33
|
+
* `nirs4all-classic` convention list.
|
|
34
|
+
*/
|
|
35
|
+
export function inferFiles(files: any, options: any): any;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Infer a dataset plan from decoded spectral records.
|
|
39
|
+
*
|
|
40
|
+
* `recordSets` must be an array of `{source, format?, records}` where
|
|
41
|
+
* `records` follows the JSON shape emitted by `nirs4all-formats`.
|
|
42
|
+
*/
|
|
43
|
+
export function inferRecords(record_sets: any): any;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Iterative, user-validatable dataset inference.
|
|
47
|
+
*
|
|
48
|
+
* Inputs mirror [`infer_dataset`] plus `options.confirmed` — an array of
|
|
49
|
+
* `{kind, target, value, status?}` locks the user has accepted/overridden,
|
|
50
|
+
* fed back so re-inference honours them. Returns a plain JS object
|
|
51
|
+
* `{plan, proposals, spec, valid, validation_errors}` where `proposals` is the
|
|
52
|
+
* list of still-open (and echoed confirmed) decisions to validate.
|
|
53
|
+
*/
|
|
54
|
+
export function proposeDataset(files: any, record_sets: any, options: any): any;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Normalize a spec/config JSON string into the canonical `DatasetSpec` JSON.
|
|
58
|
+
*/
|
|
59
|
+
export function to_spec(spec_json: string): string;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Validate a `DatasetSpec` JSON string; throws (rejects) when invalid.
|
|
63
|
+
*/
|
|
64
|
+
export function validate(spec_json: string): void;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The wire-contract (crate) version string.
|
|
68
|
+
*/
|
|
69
|
+
export function version(): string;
|
|
@@ -0,0 +1,590 @@
|
|
|
1
|
+
/* @ts-self-types="./nirs4all_io_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Assemble a `DatasetSpec` into a materialized, target-agnostic dataset, fs-free.
|
|
5
|
+
*
|
|
6
|
+
* `files` = array of `{name, bytes}` — CSV/tabular bytes the formats layer won't
|
|
7
|
+
* decode (y / metadata tables). `recordSets` = array of `{source, format?,
|
|
8
|
+
* records}` — pre-decoded `nirs4all-formats` records (signals → X, targets,
|
|
9
|
+
* metadata). `spec` = a `DatasetSpec` JSON string (typically `plan.resolved_spec`);
|
|
10
|
+
* its source `input` strings must match the `name`/`source` of the supplied
|
|
11
|
+
* sources (exact, then file-stem, then glob). Returns `AssembledDataset` as a
|
|
12
|
+
* plain JS object (per-partition `blocks` with `x`/`y`/headers/metadata + `folds`).
|
|
13
|
+
*
|
|
14
|
+
* `index_file`/`folds.file` partitions are not browser-reachable here (no fs) and
|
|
15
|
+
* raise an error — column/inline partitions and folds work.
|
|
16
|
+
* @param {any} files
|
|
17
|
+
* @param {any} record_sets
|
|
18
|
+
* @param {string} spec
|
|
19
|
+
* @returns {any}
|
|
20
|
+
*/
|
|
21
|
+
function assembleDataset(files, record_sets, spec) {
|
|
22
|
+
const ptr0 = passStringToWasm0(spec, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
23
|
+
const len0 = WASM_VECTOR_LEN;
|
|
24
|
+
const ret = wasm.assembleDataset(files, record_sets, ptr0, len0);
|
|
25
|
+
if (ret[2]) {
|
|
26
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
27
|
+
}
|
|
28
|
+
return takeFromExternrefTable0(ret[0]);
|
|
29
|
+
}
|
|
30
|
+
exports.assembleDataset = assembleDataset;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Infer a browser dataset plan from raw files and decoded spectral records.
|
|
34
|
+
*
|
|
35
|
+
* `files` must be an array of `{name, bytes}`. `recordSets` must be an array
|
|
36
|
+
* of `{source, format?, records}` where records follow `nirs4all-formats`.
|
|
37
|
+
* @param {any} files
|
|
38
|
+
* @param {any} record_sets
|
|
39
|
+
* @param {any} options
|
|
40
|
+
* @returns {any}
|
|
41
|
+
*/
|
|
42
|
+
function inferDataset(files, record_sets, options) {
|
|
43
|
+
const ret = wasm.inferDataset(files, record_sets, options);
|
|
44
|
+
if (ret[2]) {
|
|
45
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
46
|
+
}
|
|
47
|
+
return takeFromExternrefTable0(ret[0]);
|
|
48
|
+
}
|
|
49
|
+
exports.inferDataset = inferDataset;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Infer a dataset plan from browser-provided files.
|
|
53
|
+
*
|
|
54
|
+
* `files` must be an array of `{name, bytes}` where `bytes` is a
|
|
55
|
+
* `Uint8Array`. `options.conventions` can override the default
|
|
56
|
+
* `nirs4all-classic` convention list.
|
|
57
|
+
* @param {any} files
|
|
58
|
+
* @param {any} options
|
|
59
|
+
* @returns {any}
|
|
60
|
+
*/
|
|
61
|
+
function inferFiles(files, options) {
|
|
62
|
+
const ret = wasm.inferFiles(files, options);
|
|
63
|
+
if (ret[2]) {
|
|
64
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
65
|
+
}
|
|
66
|
+
return takeFromExternrefTable0(ret[0]);
|
|
67
|
+
}
|
|
68
|
+
exports.inferFiles = inferFiles;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Infer a dataset plan from decoded spectral records.
|
|
72
|
+
*
|
|
73
|
+
* `recordSets` must be an array of `{source, format?, records}` where
|
|
74
|
+
* `records` follows the JSON shape emitted by `nirs4all-formats`.
|
|
75
|
+
* @param {any} record_sets
|
|
76
|
+
* @returns {any}
|
|
77
|
+
*/
|
|
78
|
+
function inferRecords(record_sets) {
|
|
79
|
+
const ret = wasm.inferRecords(record_sets);
|
|
80
|
+
if (ret[2]) {
|
|
81
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
82
|
+
}
|
|
83
|
+
return takeFromExternrefTable0(ret[0]);
|
|
84
|
+
}
|
|
85
|
+
exports.inferRecords = inferRecords;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Iterative, user-validatable dataset inference.
|
|
89
|
+
*
|
|
90
|
+
* Inputs mirror [`infer_dataset`] plus `options.confirmed` — an array of
|
|
91
|
+
* `{kind, target, value, status?}` locks the user has accepted/overridden,
|
|
92
|
+
* fed back so re-inference honours them. Returns a plain JS object
|
|
93
|
+
* `{plan, proposals, spec, valid, validation_errors}` where `proposals` is the
|
|
94
|
+
* list of still-open (and echoed confirmed) decisions to validate.
|
|
95
|
+
* @param {any} files
|
|
96
|
+
* @param {any} record_sets
|
|
97
|
+
* @param {any} options
|
|
98
|
+
* @returns {any}
|
|
99
|
+
*/
|
|
100
|
+
function proposeDataset(files, record_sets, options) {
|
|
101
|
+
const ret = wasm.proposeDataset(files, record_sets, options);
|
|
102
|
+
if (ret[2]) {
|
|
103
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
104
|
+
}
|
|
105
|
+
return takeFromExternrefTable0(ret[0]);
|
|
106
|
+
}
|
|
107
|
+
exports.proposeDataset = proposeDataset;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Normalize a spec/config JSON string into the canonical `DatasetSpec` JSON.
|
|
111
|
+
* @param {string} spec_json
|
|
112
|
+
* @returns {string}
|
|
113
|
+
*/
|
|
114
|
+
function to_spec(spec_json) {
|
|
115
|
+
let deferred3_0;
|
|
116
|
+
let deferred3_1;
|
|
117
|
+
try {
|
|
118
|
+
const ptr0 = passStringToWasm0(spec_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
119
|
+
const len0 = WASM_VECTOR_LEN;
|
|
120
|
+
const ret = wasm.to_spec(ptr0, len0);
|
|
121
|
+
var ptr2 = ret[0];
|
|
122
|
+
var len2 = ret[1];
|
|
123
|
+
if (ret[3]) {
|
|
124
|
+
ptr2 = 0; len2 = 0;
|
|
125
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
126
|
+
}
|
|
127
|
+
deferred3_0 = ptr2;
|
|
128
|
+
deferred3_1 = len2;
|
|
129
|
+
return getStringFromWasm0(ptr2, len2);
|
|
130
|
+
} finally {
|
|
131
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
exports.to_spec = to_spec;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Validate a `DatasetSpec` JSON string; throws (rejects) when invalid.
|
|
138
|
+
* @param {string} spec_json
|
|
139
|
+
*/
|
|
140
|
+
function validate(spec_json) {
|
|
141
|
+
const ptr0 = passStringToWasm0(spec_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
142
|
+
const len0 = WASM_VECTOR_LEN;
|
|
143
|
+
const ret = wasm.validate(ptr0, len0);
|
|
144
|
+
if (ret[1]) {
|
|
145
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
exports.validate = validate;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* The wire-contract (crate) version string.
|
|
152
|
+
* @returns {string}
|
|
153
|
+
*/
|
|
154
|
+
function version() {
|
|
155
|
+
let deferred1_0;
|
|
156
|
+
let deferred1_1;
|
|
157
|
+
try {
|
|
158
|
+
const ret = wasm.version();
|
|
159
|
+
deferred1_0 = ret[0];
|
|
160
|
+
deferred1_1 = ret[1];
|
|
161
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
162
|
+
} finally {
|
|
163
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
exports.version = version;
|
|
167
|
+
function __wbg_get_imports() {
|
|
168
|
+
const import0 = {
|
|
169
|
+
__proto__: null,
|
|
170
|
+
__wbg_Error_ef53bc310eb298a0: function(arg0, arg1) {
|
|
171
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
172
|
+
return ret;
|
|
173
|
+
},
|
|
174
|
+
__wbg_Number_6b506e6536831eaa: function(arg0) {
|
|
175
|
+
const ret = Number(arg0);
|
|
176
|
+
return ret;
|
|
177
|
+
},
|
|
178
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
179
|
+
const ret = String(arg1);
|
|
180
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
181
|
+
const len1 = WASM_VECTOR_LEN;
|
|
182
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
183
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
184
|
+
},
|
|
185
|
+
__wbg___wbindgen_bigint_get_as_i64_38130e98eecd467d: function(arg0, arg1) {
|
|
186
|
+
const v = arg1;
|
|
187
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
188
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
189
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
190
|
+
},
|
|
191
|
+
__wbg___wbindgen_boolean_get_1a45e2c38d4d41b9: function(arg0) {
|
|
192
|
+
const v = arg0;
|
|
193
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
194
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
195
|
+
},
|
|
196
|
+
__wbg___wbindgen_debug_string_0accd80f45e5faa2: function(arg0, arg1) {
|
|
197
|
+
const ret = debugString(arg1);
|
|
198
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
199
|
+
const len1 = WASM_VECTOR_LEN;
|
|
200
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
201
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
202
|
+
},
|
|
203
|
+
__wbg___wbindgen_in_70a403a56e771704: function(arg0, arg1) {
|
|
204
|
+
const ret = arg0 in arg1;
|
|
205
|
+
return ret;
|
|
206
|
+
},
|
|
207
|
+
__wbg___wbindgen_is_bigint_6ffd6468a9bc44b9: function(arg0) {
|
|
208
|
+
const ret = typeof(arg0) === 'bigint';
|
|
209
|
+
return ret;
|
|
210
|
+
},
|
|
211
|
+
__wbg___wbindgen_is_function_754e9f305ff6029e: function(arg0) {
|
|
212
|
+
const ret = typeof(arg0) === 'function';
|
|
213
|
+
return ret;
|
|
214
|
+
},
|
|
215
|
+
__wbg___wbindgen_is_null_87c3bfe968c6a5ad: function(arg0) {
|
|
216
|
+
const ret = arg0 === null;
|
|
217
|
+
return ret;
|
|
218
|
+
},
|
|
219
|
+
__wbg___wbindgen_is_object_56732c2bc353f41d: function(arg0) {
|
|
220
|
+
const val = arg0;
|
|
221
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
222
|
+
return ret;
|
|
223
|
+
},
|
|
224
|
+
__wbg___wbindgen_is_string_c236cabd84a4d769: function(arg0) {
|
|
225
|
+
const ret = typeof(arg0) === 'string';
|
|
226
|
+
return ret;
|
|
227
|
+
},
|
|
228
|
+
__wbg___wbindgen_is_undefined_67b456be8673d3d7: function(arg0) {
|
|
229
|
+
const ret = arg0 === undefined;
|
|
230
|
+
return ret;
|
|
231
|
+
},
|
|
232
|
+
__wbg___wbindgen_jsval_eq_1068e624fa87f6ab: function(arg0, arg1) {
|
|
233
|
+
const ret = arg0 === arg1;
|
|
234
|
+
return ret;
|
|
235
|
+
},
|
|
236
|
+
__wbg___wbindgen_jsval_loose_eq_2c56564c75129511: function(arg0, arg1) {
|
|
237
|
+
const ret = arg0 == arg1;
|
|
238
|
+
return ret;
|
|
239
|
+
},
|
|
240
|
+
__wbg___wbindgen_number_get_9bb1761122181af2: function(arg0, arg1) {
|
|
241
|
+
const obj = arg1;
|
|
242
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
243
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
244
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
245
|
+
},
|
|
246
|
+
__wbg___wbindgen_string_get_72bdf95d3ae505b1: function(arg0, arg1) {
|
|
247
|
+
const obj = arg1;
|
|
248
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
249
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
250
|
+
var len1 = WASM_VECTOR_LEN;
|
|
251
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
252
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
253
|
+
},
|
|
254
|
+
__wbg___wbindgen_throw_1506f2235d1bdba0: function(arg0, arg1) {
|
|
255
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
256
|
+
},
|
|
257
|
+
__wbg_call_8a89609d89f6608a: function() { return handleError(function (arg0, arg1) {
|
|
258
|
+
const ret = arg0.call(arg1);
|
|
259
|
+
return ret;
|
|
260
|
+
}, arguments); },
|
|
261
|
+
__wbg_done_60cf307fcc680536: function(arg0) {
|
|
262
|
+
const ret = arg0.done;
|
|
263
|
+
return ret;
|
|
264
|
+
},
|
|
265
|
+
__wbg_entries_04b37a02507f1713: function(arg0) {
|
|
266
|
+
const ret = Object.entries(arg0);
|
|
267
|
+
return ret;
|
|
268
|
+
},
|
|
269
|
+
__wbg_get_1f8f054ddbaa7db2: function() { return handleError(function (arg0, arg1) {
|
|
270
|
+
const ret = Reflect.get(arg0, arg1);
|
|
271
|
+
return ret;
|
|
272
|
+
}, arguments); },
|
|
273
|
+
__wbg_get_2b48c7d0d006a781: function(arg0, arg1) {
|
|
274
|
+
const ret = arg0[arg1 >>> 0];
|
|
275
|
+
return ret;
|
|
276
|
+
},
|
|
277
|
+
__wbg_get_unchecked_33f6e5c9e2f2d6b2: function(arg0, arg1) {
|
|
278
|
+
const ret = arg0[arg1 >>> 0];
|
|
279
|
+
return ret;
|
|
280
|
+
},
|
|
281
|
+
__wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
|
|
282
|
+
const ret = arg0[arg1];
|
|
283
|
+
return ret;
|
|
284
|
+
},
|
|
285
|
+
__wbg_instanceof_ArrayBuffer_8f49811467741499: function(arg0) {
|
|
286
|
+
let result;
|
|
287
|
+
try {
|
|
288
|
+
result = arg0 instanceof ArrayBuffer;
|
|
289
|
+
} catch (_) {
|
|
290
|
+
result = false;
|
|
291
|
+
}
|
|
292
|
+
const ret = result;
|
|
293
|
+
return ret;
|
|
294
|
+
},
|
|
295
|
+
__wbg_instanceof_Map_9fc06d9a951bcee6: function(arg0) {
|
|
296
|
+
let result;
|
|
297
|
+
try {
|
|
298
|
+
result = arg0 instanceof Map;
|
|
299
|
+
} catch (_) {
|
|
300
|
+
result = false;
|
|
301
|
+
}
|
|
302
|
+
const ret = result;
|
|
303
|
+
return ret;
|
|
304
|
+
},
|
|
305
|
+
__wbg_instanceof_Uint8Array_86f30649f63ef9c2: function(arg0) {
|
|
306
|
+
let result;
|
|
307
|
+
try {
|
|
308
|
+
result = arg0 instanceof Uint8Array;
|
|
309
|
+
} catch (_) {
|
|
310
|
+
result = false;
|
|
311
|
+
}
|
|
312
|
+
const ret = result;
|
|
313
|
+
return ret;
|
|
314
|
+
},
|
|
315
|
+
__wbg_isArray_67c2c9c4313f4448: function(arg0) {
|
|
316
|
+
const ret = Array.isArray(arg0);
|
|
317
|
+
return ret;
|
|
318
|
+
},
|
|
319
|
+
__wbg_isSafeInteger_66acec27e09e99a7: function(arg0) {
|
|
320
|
+
const ret = Number.isSafeInteger(arg0);
|
|
321
|
+
return ret;
|
|
322
|
+
},
|
|
323
|
+
__wbg_iterator_8732428d309e270e: function() {
|
|
324
|
+
const ret = Symbol.iterator;
|
|
325
|
+
return ret;
|
|
326
|
+
},
|
|
327
|
+
__wbg_length_4a591ecaa01354d9: function(arg0) {
|
|
328
|
+
const ret = arg0.length;
|
|
329
|
+
return ret;
|
|
330
|
+
},
|
|
331
|
+
__wbg_length_66f1a4b2e9026940: function(arg0) {
|
|
332
|
+
const ret = arg0.length;
|
|
333
|
+
return ret;
|
|
334
|
+
},
|
|
335
|
+
__wbg_new_578aeef4b6b94378: function(arg0) {
|
|
336
|
+
const ret = new Uint8Array(arg0);
|
|
337
|
+
return ret;
|
|
338
|
+
},
|
|
339
|
+
__wbg_new_622fc80556be2e26: function() {
|
|
340
|
+
const ret = new Map();
|
|
341
|
+
return ret;
|
|
342
|
+
},
|
|
343
|
+
__wbg_new_ce1ab61c1c2b300d: function() {
|
|
344
|
+
const ret = new Object();
|
|
345
|
+
return ret;
|
|
346
|
+
},
|
|
347
|
+
__wbg_new_d90091b82fdf5b91: function() {
|
|
348
|
+
const ret = new Array();
|
|
349
|
+
return ret;
|
|
350
|
+
},
|
|
351
|
+
__wbg_next_9e03acdf51c4960d: function(arg0) {
|
|
352
|
+
const ret = arg0.next;
|
|
353
|
+
return ret;
|
|
354
|
+
},
|
|
355
|
+
__wbg_next_eb8ca7351fa27906: function() { return handleError(function (arg0) {
|
|
356
|
+
const ret = arg0.next();
|
|
357
|
+
return ret;
|
|
358
|
+
}, arguments); },
|
|
359
|
+
__wbg_prototypesetcall_3249fc62a0fafa30: function(arg0, arg1, arg2) {
|
|
360
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
361
|
+
},
|
|
362
|
+
__wbg_set_52b1e1eb5bed906a: function(arg0, arg1, arg2) {
|
|
363
|
+
const ret = arg0.set(arg1, arg2);
|
|
364
|
+
return ret;
|
|
365
|
+
},
|
|
366
|
+
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
367
|
+
arg0[arg1] = arg2;
|
|
368
|
+
},
|
|
369
|
+
__wbg_set_dca99999bba88a9a: function(arg0, arg1, arg2) {
|
|
370
|
+
arg0[arg1 >>> 0] = arg2;
|
|
371
|
+
},
|
|
372
|
+
__wbg_value_f3625092ee4b37f4: function(arg0) {
|
|
373
|
+
const ret = arg0.value;
|
|
374
|
+
return ret;
|
|
375
|
+
},
|
|
376
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
377
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
378
|
+
const ret = arg0;
|
|
379
|
+
return ret;
|
|
380
|
+
},
|
|
381
|
+
__wbindgen_cast_0000000000000002: function(arg0) {
|
|
382
|
+
// Cast intrinsic for `I64 -> Externref`.
|
|
383
|
+
const ret = arg0;
|
|
384
|
+
return ret;
|
|
385
|
+
},
|
|
386
|
+
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
387
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
388
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
389
|
+
return ret;
|
|
390
|
+
},
|
|
391
|
+
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
392
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
393
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
394
|
+
return ret;
|
|
395
|
+
},
|
|
396
|
+
__wbindgen_init_externref_table: function() {
|
|
397
|
+
const table = wasm.__wbindgen_externrefs;
|
|
398
|
+
const offset = table.grow(4);
|
|
399
|
+
table.set(0, undefined);
|
|
400
|
+
table.set(offset + 0, undefined);
|
|
401
|
+
table.set(offset + 1, null);
|
|
402
|
+
table.set(offset + 2, true);
|
|
403
|
+
table.set(offset + 3, false);
|
|
404
|
+
},
|
|
405
|
+
};
|
|
406
|
+
return {
|
|
407
|
+
__proto__: null,
|
|
408
|
+
"./nirs4all_io_wasm_bg.js": import0,
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
function addToExternrefTable0(obj) {
|
|
413
|
+
const idx = wasm.__externref_table_alloc();
|
|
414
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
415
|
+
return idx;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
function debugString(val) {
|
|
419
|
+
// primitive types
|
|
420
|
+
const type = typeof val;
|
|
421
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
422
|
+
return `${val}`;
|
|
423
|
+
}
|
|
424
|
+
if (type == 'string') {
|
|
425
|
+
return `"${val}"`;
|
|
426
|
+
}
|
|
427
|
+
if (type == 'symbol') {
|
|
428
|
+
const description = val.description;
|
|
429
|
+
if (description == null) {
|
|
430
|
+
return 'Symbol';
|
|
431
|
+
} else {
|
|
432
|
+
return `Symbol(${description})`;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
if (type == 'function') {
|
|
436
|
+
const name = val.name;
|
|
437
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
438
|
+
return `Function(${name})`;
|
|
439
|
+
} else {
|
|
440
|
+
return 'Function';
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
// objects
|
|
444
|
+
if (Array.isArray(val)) {
|
|
445
|
+
const length = val.length;
|
|
446
|
+
let debug = '[';
|
|
447
|
+
if (length > 0) {
|
|
448
|
+
debug += debugString(val[0]);
|
|
449
|
+
}
|
|
450
|
+
for(let i = 1; i < length; i++) {
|
|
451
|
+
debug += ', ' + debugString(val[i]);
|
|
452
|
+
}
|
|
453
|
+
debug += ']';
|
|
454
|
+
return debug;
|
|
455
|
+
}
|
|
456
|
+
// Test for built-in
|
|
457
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
458
|
+
let className;
|
|
459
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
460
|
+
className = builtInMatches[1];
|
|
461
|
+
} else {
|
|
462
|
+
// Failed to match the standard '[object ClassName]'
|
|
463
|
+
return toString.call(val);
|
|
464
|
+
}
|
|
465
|
+
if (className == 'Object') {
|
|
466
|
+
// we're a user defined class or Object
|
|
467
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
468
|
+
// easier than looping through ownProperties of `val`.
|
|
469
|
+
try {
|
|
470
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
471
|
+
} catch (_) {
|
|
472
|
+
return 'Object';
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
// errors
|
|
476
|
+
if (val instanceof Error) {
|
|
477
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
478
|
+
}
|
|
479
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
480
|
+
return className;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
484
|
+
ptr = ptr >>> 0;
|
|
485
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
let cachedDataViewMemory0 = null;
|
|
489
|
+
function getDataViewMemory0() {
|
|
490
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
491
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
492
|
+
}
|
|
493
|
+
return cachedDataViewMemory0;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
function getStringFromWasm0(ptr, len) {
|
|
497
|
+
return decodeText(ptr >>> 0, len);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
let cachedUint8ArrayMemory0 = null;
|
|
501
|
+
function getUint8ArrayMemory0() {
|
|
502
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
503
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
504
|
+
}
|
|
505
|
+
return cachedUint8ArrayMemory0;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
function handleError(f, args) {
|
|
509
|
+
try {
|
|
510
|
+
return f.apply(this, args);
|
|
511
|
+
} catch (e) {
|
|
512
|
+
const idx = addToExternrefTable0(e);
|
|
513
|
+
wasm.__wbindgen_exn_store(idx);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
function isLikeNone(x) {
|
|
518
|
+
return x === undefined || x === null;
|
|
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_io_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/io-wasm",
|
|
3
|
+
"collaborators": [
|
|
4
|
+
"Gregory Beurier <gregory.beurier@cirad.fr>"
|
|
5
|
+
],
|
|
6
|
+
"description": "wasm-bindgen binding for nirs4all-io: the fs-free JSON surface (to_spec / validate over a spec dict). Excluded from the cargo workspace; built with wasm-pack.",
|
|
7
|
+
"version": "0.1.0",
|
|
8
|
+
"license": "CeCILL-2.1 OR AGPL-3.0-or-later",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/GBeurier/nirs4all-io.git",
|
|
12
|
+
"directory": "bindings/wasm"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"nirs4all_io_wasm_bg.wasm",
|
|
16
|
+
"nirs4all_io_wasm.js",
|
|
17
|
+
"nirs4all_io_wasm.d.ts"
|
|
18
|
+
],
|
|
19
|
+
"main": "nirs4all_io_wasm.js",
|
|
20
|
+
"types": "nirs4all_io_wasm.d.ts",
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public",
|
|
23
|
+
"provenance": true
|
|
24
|
+
}
|
|
25
|
+
}
|