@flywheel-io/fw-file-rs 0.2.1 → 0.3.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 CHANGED
@@ -6,48 +6,45 @@ This package lets you work with DICOM files directly in the browser.
6
6
  ## Usage
7
7
 
8
8
  ```js
9
- import init, { get_dcm_meta, WasmDeidProfile } from "fw-file-rs";
9
+ import init, { Context, read_until_pixels } from "fw-file-rs/dcm";
10
10
 
11
11
  // initialize the WASM module (required before use)
12
12
  await init();
13
-
14
- const headerBytes = await read_until_pixel_data(file);
15
- // extract metadata from a DICOM file
16
- const tags = [
17
- "StudyInstanceUID",
18
- "SeriesInstanceUID",
19
- // tags below are needed for splitting localizer
20
- "InstanceNumber",
21
- "ImagePositionPatient",
22
- "ImageOrientationPatient",
23
- "Rows",
24
- "Columns",
25
- ];
26
- const meta = get_dcm_meta(headerBytes, tags);
27
- // group DICOM files by StudyInstanceUID and SeriesInstanceUID and split localizer
28
- const metas = [["1.dcm", meta]]; // list of (filename, meta data) tuples
29
- const groups = group_dcm_meta(metas, ["StudyInstanceUID", "SeriesInstanceUID"], true);
30
-
31
- // de-identify a DICOM file using a YAML profile
32
- const yaml = `
33
- version: 1
34
- name: profile
35
- dicom:
36
- fields:
37
- - name: PatientName
38
- replace-with: REDACTED
39
- `;
40
- const profile = WasmDeidProfile.from_yaml(yaml);
41
- const deidHeaderBytes = profile.deid_dcm(headerBytes);
42
- const chunks: Blob[] = []
43
- // make the deidentified header the first chunk
13
+ // Create a configured context using the builder pattern
14
+ const ctx = new Context()
15
+ .parse_include([
16
+ "InstitutionAddress",
17
+ "InstitutionName",
18
+ ])
19
+ .group_by(["StudyInstanceUID", "SeriesInstanceUID"])
20
+ .split_localizer(true)
21
+ .deid_profile(`
22
+ version: 1
23
+ name: profile
24
+ dicom:
25
+ fields:
26
+ - name: PatientName
27
+ replace-with: REDACTED
28
+ `);
29
+ // Read DICOM header bytes from file
30
+ const headerBytes = await ctx.read_until_pixels(file);
31
+ // Extract metadata using the configured context
32
+ const meta = ctx.parse_header(headerBytes);
33
+ // Get Flywheel-specific metadata
34
+ const fwMeta = ctx.get_fw_meta(meta);
35
+ // Group DICOM files by configured tags with localizer splitting
36
+ const path_meta_pairs = [["1.dcm", meta]];
37
+ const groups = ctx.group_series(path_meta_pairs);
38
+ // De-identify the DICOM header using the configured profile
39
+ const deidHeaderBytes = ctx.deid_header(headerBytes);
40
+ // Prepare chunks for upload
41
+ const chunks = [];
44
42
  chunks.push(new Blob([deidHeaderBytes]));
45
- // then slice the rest of the file after the header
46
43
  let start = headerBytes.length;
47
44
  while (start < file.size) {
48
- const chunkSize = Math.min(file.size - start, CHUNK_SIZE)
49
- chunks.push(file.slice(start, start + chunkSize))
50
- start += chunkSize
45
+ const chunkSize = Math.min(file.size - start, CHUNK_SIZE);
46
+ chunks.push(file.slice(start, start + chunkSize));
47
+ start += chunkSize;
51
48
  }
52
49
  // chunks are ready to be uploaded
53
50
  ```
package/package.json CHANGED
@@ -5,21 +5,20 @@
5
5
  "Flywheel <support@flywheel.io>"
6
6
  ],
7
7
  "description": "JavaScript/WebAssembly bindings for fw-file rust crate",
8
- "version": "0.2.1",
8
+ "version": "0.3.0",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "https://gitlab.com/flywheel-io/tools/lib/fw-file-rs"
13
13
  },
14
+ "homepage": "https://gitlab.com/flywheel-io/tools/lib/fw-file-rs",
14
15
  "files": [
15
- "fw_file_rs_bg.wasm",
16
- "fw_file_rs.js",
17
- "fw_file_rs.d.ts"
16
+ "dcm/"
18
17
  ],
19
- "main": "fw_file_rs.js",
20
- "homepage": "https://gitlab.com/flywheel-io/tools/lib/fw-file-rs",
21
- "types": "fw_file_rs.d.ts",
18
+ "exports": {
19
+ "./dcm": "./dcm/index.js"
20
+ },
22
21
  "sideEffects": [
23
22
  "./snippets/*"
24
23
  ]
25
- }
24
+ }
package/fw_file_rs.d.ts DELETED
@@ -1,62 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
- export function get_dcm_meta(bytes: Uint8Array, tags: string[]): any;
4
- export function read_until_pixel_data(file: File): Promise<Uint8Array>;
5
- export function group_dcm_meta(metas: any, group_by_tags: any, split_localizer: boolean): any;
6
- export function create_dcm_as_bytes(tags_js: any): Uint8Array;
7
- export class WasmDCMGroup {
8
- private constructor();
9
- free(): void;
10
- }
11
- export class WasmDeidProfile {
12
- private constructor();
13
- free(): void;
14
- static from_yaml(yaml: string): WasmDeidProfile;
15
- deid_dcm(dcm_bytes: Uint8Array): Uint8Array;
16
- }
17
-
18
- export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
19
-
20
- export interface InitOutput {
21
- readonly memory: WebAssembly.Memory;
22
- readonly get_dcm_meta: (a: number, b: number, c: number, d: number) => [number, number, number];
23
- readonly __wbg_wasmdeidprofile_free: (a: number, b: number) => void;
24
- readonly wasmdeidprofile_from_yaml: (a: number, b: number) => [number, number, number];
25
- readonly wasmdeidprofile_deid_dcm: (a: number, b: number, c: number) => [number, number, number, number];
26
- readonly read_until_pixel_data: (a: any) => any;
27
- readonly __wbg_wasmdcmgroup_free: (a: number, b: number) => void;
28
- readonly group_dcm_meta: (a: any, b: any, c: number) => any;
29
- readonly create_dcm_as_bytes: (a: any) => [number, number, number, number];
30
- readonly __wbindgen_malloc: (a: number, b: number) => number;
31
- readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
32
- readonly __wbindgen_exn_store: (a: number) => void;
33
- readonly __externref_table_alloc: () => number;
34
- readonly __wbindgen_export_4: WebAssembly.Table;
35
- readonly __wbindgen_export_5: WebAssembly.Table;
36
- readonly __externref_table_dealloc: (a: number) => void;
37
- readonly __wbindgen_free: (a: number, b: number, c: number) => void;
38
- readonly closure46_externref_shim: (a: number, b: number, c: any) => void;
39
- readonly closure1153_externref_shim: (a: number, b: number, c: any, d: any) => void;
40
- readonly __wbindgen_start: () => void;
41
- }
42
-
43
- export type SyncInitInput = BufferSource | WebAssembly.Module;
44
- /**
45
- * Instantiates the given `module`, which can either be bytes or
46
- * a precompiled `WebAssembly.Module`.
47
- *
48
- * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
49
- *
50
- * @returns {InitOutput}
51
- */
52
- export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
53
-
54
- /**
55
- * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
56
- * for everything else, calls `WebAssembly.instantiate` directly.
57
- *
58
- * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
59
- *
60
- * @returns {Promise<InitOutput>}
61
- */
62
- export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
package/fw_file_rs.js DELETED
@@ -1,805 +0,0 @@
1
- let wasm;
2
-
3
- let cachedUint8ArrayMemory0 = null;
4
-
5
- function getUint8ArrayMemory0() {
6
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
7
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
8
- }
9
- return cachedUint8ArrayMemory0;
10
- }
11
-
12
- let cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
13
-
14
- if (typeof TextDecoder !== 'undefined') { 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 = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
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 = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
36
-
37
- const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
38
- ? function (arg, view) {
39
- return cachedTextEncoder.encodeInto(arg, view);
40
- }
41
- : function (arg, view) {
42
- const buf = cachedTextEncoder.encode(arg);
43
- view.set(buf);
44
- return {
45
- read: arg.length,
46
- written: buf.length
47
- };
48
- });
49
-
50
- function passStringToWasm0(arg, malloc, realloc) {
51
-
52
- if (realloc === undefined) {
53
- const buf = cachedTextEncoder.encode(arg);
54
- const ptr = malloc(buf.length, 1) >>> 0;
55
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
56
- WASM_VECTOR_LEN = buf.length;
57
- return ptr;
58
- }
59
-
60
- let len = arg.length;
61
- let ptr = malloc(len, 1) >>> 0;
62
-
63
- const mem = getUint8ArrayMemory0();
64
-
65
- let offset = 0;
66
-
67
- for (; offset < len; offset++) {
68
- const code = arg.charCodeAt(offset);
69
- if (code > 0x7F) break;
70
- mem[ptr + offset] = code;
71
- }
72
-
73
- if (offset !== len) {
74
- if (offset !== 0) {
75
- arg = arg.slice(offset);
76
- }
77
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
78
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
79
- const ret = encodeString(arg, view);
80
-
81
- offset += ret.written;
82
- ptr = realloc(ptr, len, offset, 1) >>> 0;
83
- }
84
-
85
- WASM_VECTOR_LEN = offset;
86
- return ptr;
87
- }
88
-
89
- let cachedDataViewMemory0 = null;
90
-
91
- function getDataViewMemory0() {
92
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
93
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
94
- }
95
- return cachedDataViewMemory0;
96
- }
97
-
98
- function addToExternrefTable0(obj) {
99
- const idx = wasm.__externref_table_alloc();
100
- wasm.__wbindgen_export_4.set(idx, obj);
101
- return idx;
102
- }
103
-
104
- function handleError(f, args) {
105
- try {
106
- return f.apply(this, args);
107
- } catch (e) {
108
- const idx = addToExternrefTable0(e);
109
- wasm.__wbindgen_exn_store(idx);
110
- }
111
- }
112
-
113
- function getArrayU8FromWasm0(ptr, len) {
114
- ptr = ptr >>> 0;
115
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
116
- }
117
-
118
- function isLikeNone(x) {
119
- return x === undefined || x === null;
120
- }
121
-
122
- function debugString(val) {
123
- // primitive types
124
- const type = typeof val;
125
- if (type == 'number' || type == 'boolean' || val == null) {
126
- return `${val}`;
127
- }
128
- if (type == 'string') {
129
- return `"${val}"`;
130
- }
131
- if (type == 'symbol') {
132
- const description = val.description;
133
- if (description == null) {
134
- return 'Symbol';
135
- } else {
136
- return `Symbol(${description})`;
137
- }
138
- }
139
- if (type == 'function') {
140
- const name = val.name;
141
- if (typeof name == 'string' && name.length > 0) {
142
- return `Function(${name})`;
143
- } else {
144
- return 'Function';
145
- }
146
- }
147
- // objects
148
- if (Array.isArray(val)) {
149
- const length = val.length;
150
- let debug = '[';
151
- if (length > 0) {
152
- debug += debugString(val[0]);
153
- }
154
- for(let i = 1; i < length; i++) {
155
- debug += ', ' + debugString(val[i]);
156
- }
157
- debug += ']';
158
- return debug;
159
- }
160
- // Test for built-in
161
- const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
162
- let className;
163
- if (builtInMatches && builtInMatches.length > 1) {
164
- className = builtInMatches[1];
165
- } else {
166
- // Failed to match the standard '[object ClassName]'
167
- return toString.call(val);
168
- }
169
- if (className == 'Object') {
170
- // we're a user defined class or Object
171
- // JSON.stringify avoids problems with cycles, and is generally much
172
- // easier than looping through ownProperties of `val`.
173
- try {
174
- return 'Object(' + JSON.stringify(val) + ')';
175
- } catch (_) {
176
- return 'Object';
177
- }
178
- }
179
- // errors
180
- if (val instanceof Error) {
181
- return `${val.name}: ${val.message}\n${val.stack}`;
182
- }
183
- // TODO we could test for more things here, like `Set`s and `Map`s.
184
- return className;
185
- }
186
-
187
- const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
188
- ? { register: () => {}, unregister: () => {} }
189
- : new FinalizationRegistry(
190
- state => {
191
- wasm.__wbindgen_export_5.get(state.dtor)(state.a, state.b);
192
- }
193
- );
194
-
195
- function makeMutClosure(arg0, arg1, dtor, f) {
196
- const state = { a: arg0, b: arg1, cnt: 1, dtor };
197
- const real = (...args) => {
198
-
199
- // First up with a closure we increment the internal reference
200
- // count. This ensures that the Rust closure environment won't
201
- // be deallocated while we're invoking it.
202
- state.cnt++;
203
- const a = state.a;
204
- state.a = 0;
205
- try {
206
- return f(a, state.b, ...args);
207
- } finally {
208
- if (--state.cnt === 0) {
209
- wasm.__wbindgen_export_5.get(state.dtor)(a, state.b);
210
- CLOSURE_DTORS.unregister(state);
211
- } else {
212
- state.a = a;
213
- }
214
- }
215
- };
216
- real.original = state;
217
- CLOSURE_DTORS.register(real, state, state);
218
- return real;
219
- }
220
-
221
- function passArray8ToWasm0(arg, malloc) {
222
- const ptr = malloc(arg.length * 1, 1) >>> 0;
223
- getUint8ArrayMemory0().set(arg, ptr / 1);
224
- WASM_VECTOR_LEN = arg.length;
225
- return ptr;
226
- }
227
-
228
- function passArrayJsValueToWasm0(array, malloc) {
229
- const ptr = malloc(array.length * 4, 4) >>> 0;
230
- for (let i = 0; i < array.length; i++) {
231
- const add = addToExternrefTable0(array[i]);
232
- getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
233
- }
234
- WASM_VECTOR_LEN = array.length;
235
- return ptr;
236
- }
237
-
238
- function takeFromExternrefTable0(idx) {
239
- const value = wasm.__wbindgen_export_4.get(idx);
240
- wasm.__externref_table_dealloc(idx);
241
- return value;
242
- }
243
- /**
244
- * @param {Uint8Array} bytes
245
- * @param {string[]} tags
246
- * @returns {any}
247
- */
248
- export function get_dcm_meta(bytes, tags) {
249
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
250
- const len0 = WASM_VECTOR_LEN;
251
- const ptr1 = passArrayJsValueToWasm0(tags, wasm.__wbindgen_malloc);
252
- const len1 = WASM_VECTOR_LEN;
253
- const ret = wasm.get_dcm_meta(ptr0, len0, ptr1, len1);
254
- if (ret[2]) {
255
- throw takeFromExternrefTable0(ret[1]);
256
- }
257
- return takeFromExternrefTable0(ret[0]);
258
- }
259
-
260
- /**
261
- * @param {File} file
262
- * @returns {Promise<Uint8Array>}
263
- */
264
- export function read_until_pixel_data(file) {
265
- const ret = wasm.read_until_pixel_data(file);
266
- return ret;
267
- }
268
-
269
- /**
270
- * @param {any} metas
271
- * @param {any} group_by_tags
272
- * @param {boolean} split_localizer
273
- * @returns {any}
274
- */
275
- export function group_dcm_meta(metas, group_by_tags, split_localizer) {
276
- const ret = wasm.group_dcm_meta(metas, group_by_tags, split_localizer);
277
- return ret;
278
- }
279
-
280
- /**
281
- * @param {any} tags_js
282
- * @returns {Uint8Array}
283
- */
284
- export function create_dcm_as_bytes(tags_js) {
285
- const ret = wasm.create_dcm_as_bytes(tags_js);
286
- if (ret[3]) {
287
- throw takeFromExternrefTable0(ret[2]);
288
- }
289
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
290
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
291
- return v1;
292
- }
293
-
294
- function __wbg_adapter_12(arg0, arg1, arg2) {
295
- wasm.closure46_externref_shim(arg0, arg1, arg2);
296
- }
297
-
298
- function __wbg_adapter_79(arg0, arg1, arg2, arg3) {
299
- wasm.closure1153_externref_shim(arg0, arg1, arg2, arg3);
300
- }
301
-
302
- const WasmDCMGroupFinalization = (typeof FinalizationRegistry === 'undefined')
303
- ? { register: () => {}, unregister: () => {} }
304
- : new FinalizationRegistry(ptr => wasm.__wbg_wasmdcmgroup_free(ptr >>> 0, 1));
305
-
306
- export class WasmDCMGroup {
307
-
308
- __destroy_into_raw() {
309
- const ptr = this.__wbg_ptr;
310
- this.__wbg_ptr = 0;
311
- WasmDCMGroupFinalization.unregister(this);
312
- return ptr;
313
- }
314
-
315
- free() {
316
- const ptr = this.__destroy_into_raw();
317
- wasm.__wbg_wasmdcmgroup_free(ptr, 0);
318
- }
319
- }
320
-
321
- const WasmDeidProfileFinalization = (typeof FinalizationRegistry === 'undefined')
322
- ? { register: () => {}, unregister: () => {} }
323
- : new FinalizationRegistry(ptr => wasm.__wbg_wasmdeidprofile_free(ptr >>> 0, 1));
324
-
325
- export class WasmDeidProfile {
326
-
327
- static __wrap(ptr) {
328
- ptr = ptr >>> 0;
329
- const obj = Object.create(WasmDeidProfile.prototype);
330
- obj.__wbg_ptr = ptr;
331
- WasmDeidProfileFinalization.register(obj, obj.__wbg_ptr, obj);
332
- return obj;
333
- }
334
-
335
- __destroy_into_raw() {
336
- const ptr = this.__wbg_ptr;
337
- this.__wbg_ptr = 0;
338
- WasmDeidProfileFinalization.unregister(this);
339
- return ptr;
340
- }
341
-
342
- free() {
343
- const ptr = this.__destroy_into_raw();
344
- wasm.__wbg_wasmdeidprofile_free(ptr, 0);
345
- }
346
- /**
347
- * @param {string} yaml
348
- * @returns {WasmDeidProfile}
349
- */
350
- static from_yaml(yaml) {
351
- const ptr0 = passStringToWasm0(yaml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
352
- const len0 = WASM_VECTOR_LEN;
353
- const ret = wasm.wasmdeidprofile_from_yaml(ptr0, len0);
354
- if (ret[2]) {
355
- throw takeFromExternrefTable0(ret[1]);
356
- }
357
- return WasmDeidProfile.__wrap(ret[0]);
358
- }
359
- /**
360
- * @param {Uint8Array} dcm_bytes
361
- * @returns {Uint8Array}
362
- */
363
- deid_dcm(dcm_bytes) {
364
- const ptr0 = passArray8ToWasm0(dcm_bytes, wasm.__wbindgen_malloc);
365
- const len0 = WASM_VECTOR_LEN;
366
- const ret = wasm.wasmdeidprofile_deid_dcm(this.__wbg_ptr, ptr0, len0);
367
- if (ret[3]) {
368
- throw takeFromExternrefTable0(ret[2]);
369
- }
370
- var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
371
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
372
- return v2;
373
- }
374
- }
375
-
376
- const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
377
-
378
- async function __wbg_load(module, imports) {
379
- if (typeof Response === 'function' && module instanceof Response) {
380
- if (typeof WebAssembly.instantiateStreaming === 'function') {
381
- try {
382
- return await WebAssembly.instantiateStreaming(module, imports);
383
-
384
- } catch (e) {
385
- const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
386
-
387
- if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
388
- 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);
389
-
390
- } else {
391
- throw e;
392
- }
393
- }
394
- }
395
-
396
- const bytes = await module.arrayBuffer();
397
- return await WebAssembly.instantiate(bytes, imports);
398
-
399
- } else {
400
- const instance = await WebAssembly.instantiate(module, imports);
401
-
402
- if (instance instanceof WebAssembly.Instance) {
403
- return { instance, module };
404
-
405
- } else {
406
- return instance;
407
- }
408
- }
409
- }
410
-
411
- function __wbg_get_imports() {
412
- const imports = {};
413
- imports.wbg = {};
414
- imports.wbg.__wbg_Error_1f3748b298f99708 = function(arg0, arg1) {
415
- const ret = Error(getStringFromWasm0(arg0, arg1));
416
- return ret;
417
- };
418
- imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
419
- const ret = String(arg1);
420
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
421
- const len1 = WASM_VECTOR_LEN;
422
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
423
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
424
- };
425
- imports.wbg.__wbg_arrayBuffer_4a3158e85510825e = function(arg0) {
426
- const ret = arg0.arrayBuffer();
427
- return ret;
428
- };
429
- imports.wbg.__wbg_call_2f8d426a20a307fe = function() { return handleError(function (arg0, arg1) {
430
- const ret = arg0.call(arg1);
431
- return ret;
432
- }, arguments) };
433
- imports.wbg.__wbg_call_f53f0647ceb9c567 = function() { return handleError(function (arg0, arg1, arg2) {
434
- const ret = arg0.call(arg1, arg2);
435
- return ret;
436
- }, arguments) };
437
- imports.wbg.__wbg_done_4a7743b6f942c9f3 = function(arg0) {
438
- const ret = arg0.done;
439
- return ret;
440
- };
441
- imports.wbg.__wbg_entries_17f7acbc2d691c0d = function(arg0) {
442
- const ret = Object.entries(arg0);
443
- return ret;
444
- };
445
- imports.wbg.__wbg_getRandomValues_3c9c0d586e575a16 = function() { return handleError(function (arg0, arg1) {
446
- globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
447
- }, arguments) };
448
- imports.wbg.__wbg_get_27b4bcbec57323ca = function() { return handleError(function (arg0, arg1) {
449
- const ret = Reflect.get(arg0, arg1);
450
- return ret;
451
- }, arguments) };
452
- imports.wbg.__wbg_get_59c6316d15f9f1d0 = function(arg0, arg1) {
453
- const ret = arg0[arg1 >>> 0];
454
- return ret;
455
- };
456
- imports.wbg.__wbg_instanceof_ArrayBuffer_59339a3a6f0c10ea = function(arg0) {
457
- let result;
458
- try {
459
- result = arg0 instanceof ArrayBuffer;
460
- } catch (_) {
461
- result = false;
462
- }
463
- const ret = result;
464
- return ret;
465
- };
466
- imports.wbg.__wbg_instanceof_Map_dd89a82d76d1b25f = function(arg0) {
467
- let result;
468
- try {
469
- result = arg0 instanceof Map;
470
- } catch (_) {
471
- result = false;
472
- }
473
- const ret = result;
474
- return ret;
475
- };
476
- imports.wbg.__wbg_instanceof_Uint8Array_91f3c5adee7e6672 = function(arg0) {
477
- let result;
478
- try {
479
- result = arg0 instanceof Uint8Array;
480
- } catch (_) {
481
- result = false;
482
- }
483
- const ret = result;
484
- return ret;
485
- };
486
- imports.wbg.__wbg_isArray_bc2498eba6fcb71f = function(arg0) {
487
- const ret = Array.isArray(arg0);
488
- return ret;
489
- };
490
- imports.wbg.__wbg_isSafeInteger_6091d6e3ee1b65fd = function(arg0) {
491
- const ret = Number.isSafeInteger(arg0);
492
- return ret;
493
- };
494
- imports.wbg.__wbg_iterator_96378c3c9a17347c = function() {
495
- const ret = Symbol.iterator;
496
- return ret;
497
- };
498
- imports.wbg.__wbg_length_246fa1f85a0dea5b = function(arg0) {
499
- const ret = arg0.length;
500
- return ret;
501
- };
502
- imports.wbg.__wbg_length_904c0910ed998bf3 = function(arg0) {
503
- const ret = arg0.length;
504
- return ret;
505
- };
506
- imports.wbg.__wbg_new_1930cbb8d9ffc31b = function() {
507
- const ret = new Object();
508
- return ret;
509
- };
510
- imports.wbg.__wbg_new_56407f99198feff7 = function() {
511
- const ret = new Map();
512
- return ret;
513
- };
514
- imports.wbg.__wbg_new_9190433fb67ed635 = function(arg0) {
515
- const ret = new Uint8Array(arg0);
516
- return ret;
517
- };
518
- imports.wbg.__wbg_new_d5e3800b120e37e1 = function(arg0, arg1) {
519
- try {
520
- var state0 = {a: arg0, b: arg1};
521
- var cb0 = (arg0, arg1) => {
522
- const a = state0.a;
523
- state0.a = 0;
524
- try {
525
- return __wbg_adapter_79(a, state0.b, arg0, arg1);
526
- } finally {
527
- state0.a = a;
528
- }
529
- };
530
- const ret = new Promise(cb0);
531
- return ret;
532
- } finally {
533
- state0.a = state0.b = 0;
534
- }
535
- };
536
- imports.wbg.__wbg_new_e969dc3f68d25093 = function() {
537
- const ret = new Array();
538
- return ret;
539
- };
540
- imports.wbg.__wbg_newfromslice_d0d56929c6d9c842 = function(arg0, arg1) {
541
- const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
542
- return ret;
543
- };
544
- imports.wbg.__wbg_newnoargs_a81330f6e05d8aca = function(arg0, arg1) {
545
- const ret = new Function(getStringFromWasm0(arg0, arg1));
546
- return ret;
547
- };
548
- imports.wbg.__wbg_newwithlength_ed0ee6c1edca86fc = function(arg0) {
549
- const ret = new Uint8Array(arg0 >>> 0);
550
- return ret;
551
- };
552
- imports.wbg.__wbg_next_2e6b37020ac5fe58 = function() { return handleError(function (arg0) {
553
- const ret = arg0.next();
554
- return ret;
555
- }, arguments) };
556
- imports.wbg.__wbg_next_3de8f2669431a3ff = function(arg0) {
557
- const ret = arg0.next;
558
- return ret;
559
- };
560
- imports.wbg.__wbg_prototypesetcall_c5f74efd31aea86b = function(arg0, arg1, arg2) {
561
- Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
562
- };
563
- imports.wbg.__wbg_queueMicrotask_bcc6e26d899696db = function(arg0) {
564
- const ret = arg0.queueMicrotask;
565
- return ret;
566
- };
567
- imports.wbg.__wbg_queueMicrotask_f24a794d09c42640 = function(arg0) {
568
- queueMicrotask(arg0);
569
- };
570
- imports.wbg.__wbg_resolve_5775c0ef9222f556 = function(arg0) {
571
- const ret = Promise.resolve(arg0);
572
- return ret;
573
- };
574
- imports.wbg.__wbg_set_31197016f65a6a19 = function(arg0, arg1, arg2) {
575
- const ret = arg0.set(arg1, arg2);
576
- return ret;
577
- };
578
- imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
579
- arg0[arg1] = arg2;
580
- };
581
- imports.wbg.__wbg_set_d636a0463acf1dbc = function(arg0, arg1, arg2) {
582
- arg0[arg1 >>> 0] = arg2;
583
- };
584
- imports.wbg.__wbg_size_4181b899cbfa6483 = function(arg0) {
585
- const ret = arg0.size;
586
- return ret;
587
- };
588
- imports.wbg.__wbg_slice_dc41c7f2c4886814 = function() { return handleError(function (arg0, arg1, arg2) {
589
- const ret = arg0.slice(arg1, arg2);
590
- return ret;
591
- }, arguments) };
592
- imports.wbg.__wbg_static_accessor_GLOBAL_1f13249cc3acc96d = function() {
593
- const ret = typeof global === 'undefined' ? null : global;
594
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
595
- };
596
- imports.wbg.__wbg_static_accessor_GLOBAL_THIS_df7ae94b1e0ed6a3 = function() {
597
- const ret = typeof globalThis === 'undefined' ? null : globalThis;
598
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
599
- };
600
- imports.wbg.__wbg_static_accessor_SELF_6265471db3b3c228 = function() {
601
- const ret = typeof self === 'undefined' ? null : self;
602
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
603
- };
604
- imports.wbg.__wbg_static_accessor_WINDOW_16fb482f8ec52863 = function() {
605
- const ret = typeof window === 'undefined' ? null : window;
606
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
607
- };
608
- imports.wbg.__wbg_then_8d2fcccde5380a03 = function(arg0, arg1, arg2) {
609
- const ret = arg0.then(arg1, arg2);
610
- return ret;
611
- };
612
- imports.wbg.__wbg_then_9cc266be2bf537b6 = function(arg0, arg1) {
613
- const ret = arg0.then(arg1);
614
- return ret;
615
- };
616
- imports.wbg.__wbg_value_09d0b4eaab48b91d = function(arg0) {
617
- const ret = arg0.value;
618
- return ret;
619
- };
620
- imports.wbg.__wbg_wbindgenbigintgetasi64_7637cb1a7fb9a81e = function(arg0, arg1) {
621
- const v = arg1;
622
- const ret = typeof(v) === 'bigint' ? v : undefined;
623
- getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
624
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
625
- };
626
- imports.wbg.__wbg_wbindgenbooleanget_59f830b1a70d2530 = function(arg0) {
627
- const v = arg0;
628
- const ret = typeof(v) === 'boolean' ? v : undefined;
629
- return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
630
- };
631
- imports.wbg.__wbg_wbindgencbdrop_a85ed476c6a370b9 = function(arg0) {
632
- const obj = arg0.original;
633
- if (obj.cnt-- == 1) {
634
- obj.a = 0;
635
- return true;
636
- }
637
- const ret = false;
638
- return ret;
639
- };
640
- imports.wbg.__wbg_wbindgendebugstring_bb652b1bc2061b6d = function(arg0, arg1) {
641
- const ret = debugString(arg1);
642
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
643
- const len1 = WASM_VECTOR_LEN;
644
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
645
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
646
- };
647
- imports.wbg.__wbg_wbindgenin_192b210aa1c401e9 = function(arg0, arg1) {
648
- const ret = arg0 in arg1;
649
- return ret;
650
- };
651
- imports.wbg.__wbg_wbindgenisbigint_7d76a1ca6454e439 = function(arg0) {
652
- const ret = typeof(arg0) === 'bigint';
653
- return ret;
654
- };
655
- imports.wbg.__wbg_wbindgenisfunction_ea72b9d66a0e1705 = function(arg0) {
656
- const ret = typeof(arg0) === 'function';
657
- return ret;
658
- };
659
- imports.wbg.__wbg_wbindgenisobject_dfe064a121d87553 = function(arg0) {
660
- const val = arg0;
661
- const ret = typeof(val) === 'object' && val !== null;
662
- return ret;
663
- };
664
- imports.wbg.__wbg_wbindgenisstring_4b74e4111ba029e6 = function(arg0) {
665
- const ret = typeof(arg0) === 'string';
666
- return ret;
667
- };
668
- imports.wbg.__wbg_wbindgenisundefined_71f08a6ade4354e7 = function(arg0) {
669
- const ret = arg0 === undefined;
670
- return ret;
671
- };
672
- imports.wbg.__wbg_wbindgenjsvaleq_f27272c0a890df7f = function(arg0, arg1) {
673
- const ret = arg0 === arg1;
674
- return ret;
675
- };
676
- imports.wbg.__wbg_wbindgenjsvallooseeq_9dd7bb4b95ac195c = function(arg0, arg1) {
677
- const ret = arg0 == arg1;
678
- return ret;
679
- };
680
- imports.wbg.__wbg_wbindgennumberget_d855f947247a3fbc = function(arg0, arg1) {
681
- const obj = arg1;
682
- const ret = typeof(obj) === 'number' ? obj : undefined;
683
- getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
684
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
685
- };
686
- imports.wbg.__wbg_wbindgenstringget_43fe05afe34b0cb1 = function(arg0, arg1) {
687
- const obj = arg1;
688
- const ret = typeof(obj) === 'string' ? obj : undefined;
689
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
690
- var len1 = WASM_VECTOR_LEN;
691
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
692
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
693
- };
694
- imports.wbg.__wbg_wbindgenthrow_4c11a24fca429ccf = function(arg0, arg1) {
695
- throw new Error(getStringFromWasm0(arg0, arg1));
696
- };
697
- imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
698
- // Cast intrinsic for `Ref(String) -> Externref`.
699
- const ret = getStringFromWasm0(arg0, arg1);
700
- return ret;
701
- };
702
- imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
703
- // Cast intrinsic for `U64 -> Externref`.
704
- const ret = BigInt.asUintN(64, arg0);
705
- return ret;
706
- };
707
- imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
708
- // Cast intrinsic for `I64 -> Externref`.
709
- const ret = arg0;
710
- return ret;
711
- };
712
- imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
713
- // Cast intrinsic for `F64 -> Externref`.
714
- const ret = arg0;
715
- return ret;
716
- };
717
- imports.wbg.__wbindgen_cast_f4d44e7fde62b12a = function(arg0, arg1) {
718
- // Cast intrinsic for `Closure(Closure { dtor_idx: 45, function: Function { arguments: [Externref], shim_idx: 46, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
719
- const ret = makeMutClosure(arg0, arg1, 45, __wbg_adapter_12);
720
- return ret;
721
- };
722
- imports.wbg.__wbindgen_init_externref_table = function() {
723
- const table = wasm.__wbindgen_export_4;
724
- const offset = table.grow(4);
725
- table.set(0, undefined);
726
- table.set(offset + 0, undefined);
727
- table.set(offset + 1, null);
728
- table.set(offset + 2, true);
729
- table.set(offset + 3, false);
730
- ;
731
- };
732
-
733
- return imports;
734
- }
735
-
736
- function __wbg_init_memory(imports, memory) {
737
-
738
- }
739
-
740
- function __wbg_finalize_init(instance, module) {
741
- wasm = instance.exports;
742
- __wbg_init.__wbindgen_wasm_module = module;
743
- cachedDataViewMemory0 = null;
744
- cachedUint8ArrayMemory0 = null;
745
-
746
-
747
- wasm.__wbindgen_start();
748
- return wasm;
749
- }
750
-
751
- function initSync(module) {
752
- if (wasm !== undefined) return wasm;
753
-
754
-
755
- if (typeof module !== 'undefined') {
756
- if (Object.getPrototypeOf(module) === Object.prototype) {
757
- ({module} = module)
758
- } else {
759
- console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
760
- }
761
- }
762
-
763
- const imports = __wbg_get_imports();
764
-
765
- __wbg_init_memory(imports);
766
-
767
- if (!(module instanceof WebAssembly.Module)) {
768
- module = new WebAssembly.Module(module);
769
- }
770
-
771
- const instance = new WebAssembly.Instance(module, imports);
772
-
773
- return __wbg_finalize_init(instance, module);
774
- }
775
-
776
- async function __wbg_init(module_or_path) {
777
- if (wasm !== undefined) return wasm;
778
-
779
-
780
- if (typeof module_or_path !== 'undefined') {
781
- if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
782
- ({module_or_path} = module_or_path)
783
- } else {
784
- console.warn('using deprecated parameters for the initialization function; pass a single object instead')
785
- }
786
- }
787
-
788
- if (typeof module_or_path === 'undefined') {
789
- module_or_path = new URL('fw_file_js_bg.wasm', import.meta.url);
790
- }
791
- const imports = __wbg_get_imports();
792
-
793
- if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
794
- module_or_path = fetch(module_or_path);
795
- }
796
-
797
- __wbg_init_memory(imports);
798
-
799
- const { instance, module } = await __wbg_load(await module_or_path, imports);
800
-
801
- return __wbg_finalize_init(instance, module);
802
- }
803
-
804
- export { initSync };
805
- export default __wbg_init;
Binary file