lucivy-wasm 0.2.0 → 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.
@@ -1,29 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
- export const memory: WebAssembly.Memory;
4
- export const __wbg_index_free: (a: number, b: number) => void;
5
- export const index_create: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
6
- export const index_open: (a: number, b: number, c: any) => [number, number, number];
7
- export const index_add: (a: number, b: number, c: number, d: number) => [number, number];
8
- export const index_addMany: (a: number, b: number, c: number) => [number, number];
9
- export const index_remove: (a: number, b: number) => [number, number];
10
- export const index_update: (a: number, b: number, c: number, d: number) => [number, number];
11
- export const index_commit: (a: number) => [number, number];
12
- export const index_rollback: (a: number) => [number, number];
13
- export const index_exportDirtyFiles: (a: number) => [number, number, number];
14
- export const index_exportAllFiles: (a: number) => [number, number, number];
15
- export const index_exportSnapshot: (a: number) => [number, number, number, number];
16
- export const index_importSnapshot: (a: number, b: number, c: number, d: number) => [number, number, number];
17
- export const index_search: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
18
- export const index_searchFiltered: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number, number];
19
- export const index_numDocs: (a: number) => number;
20
- export const index_path: (a: number) => [number, number];
21
- export const index_schemaJson: (a: number) => [number, number];
22
- export const __wbindgen_malloc: (a: number, b: number) => number;
23
- export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
24
- export const __wbindgen_exn_store: (a: number) => void;
25
- export const __externref_table_alloc: () => number;
26
- export const __wbindgen_externrefs: WebAssembly.Table;
27
- export const __externref_table_dealloc: (a: number) => void;
28
- export const __wbindgen_free: (a: number, b: number, c: number) => void;
29
- export const __wbindgen_start: () => void;
@@ -1,107 +0,0 @@
1
- /*
2
- * Copyright 2022 Google Inc. All Rights Reserved.
3
- * Licensed under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License.
5
- * You may obtain a copy of the License at
6
- * http://www.apache.org/licenses/LICENSE-2.0
7
- * Unless required by applicable law or agreed to in writing, software
8
- * distributed under the License is distributed on an "AS IS" BASIS,
9
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
- * See the License for the specific language governing permissions and
11
- * limitations under the License.
12
- */
13
-
14
- // Note: we use `wasm_bindgen_worker_`-prefixed message types to make sure
15
- // we can handle bundling into other files, which might happen to have their
16
- // own `postMessage`/`onmessage` communication channels.
17
- //
18
- // If we didn't take that into the account, we could send much simpler signals
19
- // like just `0` or whatever, but the code would be less resilient.
20
-
21
- function waitForMsgType(target, type) {
22
- return new Promise(resolve => {
23
- target.addEventListener('message', function onMsg({ data }) {
24
- if (data?.type !== type) return;
25
- target.removeEventListener('message', onMsg);
26
- resolve(data);
27
- });
28
- });
29
- }
30
-
31
- waitForMsgType(self, 'wasm_bindgen_worker_init').then(async ({ init, receiver }) => {
32
- // # Note 1
33
- // Our JS should have been generated in
34
- // `[out-dir]/snippets/wasm-bindgen-rayon-[hash]/workerHelpers.js`,
35
- // resolve the main module via `../../..`.
36
- //
37
- // This might need updating if the generated structure changes on wasm-bindgen
38
- // side ever in the future, but works well with bundlers today. The whole
39
- // point of this crate, after all, is to abstract away unstable features
40
- // and temporary bugs so that you don't need to deal with them in your code.
41
- //
42
- // # Note 2
43
- // This could be a regular import, but then some bundlers complain about
44
- // circular deps.
45
- //
46
- // Dynamic import could be cheap if this file was inlined into the parent,
47
- // which would require us just using `../../..` in `new Worker` below,
48
- // but that doesn't work because wasm-pack unconditionally adds
49
- // "sideEffects":false (see below).
50
- //
51
- // OTOH, even though it can't be inlined, it should be still reasonably
52
- // cheap since the requested file is already in cache (it was loaded by
53
- // the main thread).
54
- const pkg = await import('../../..');
55
- await pkg.default(init);
56
- postMessage({ type: 'wasm_bindgen_worker_ready' });
57
- pkg.wbg_rayon_start_worker(receiver);
58
- });
59
-
60
- // Note: this is never used, but necessary to prevent a bug in Firefox
61
- // (https://bugzilla.mozilla.org/show_bug.cgi?id=1702191) where it collects
62
- // Web Workers that have a shared WebAssembly memory with the main thread,
63
- // but are not explicitly rooted via a `Worker` instance.
64
- //
65
- // By storing them in a variable, we can keep `Worker` objects around and
66
- // prevent them from getting GC-d.
67
- let _workers;
68
-
69
- export async function startWorkers(module, memory, builder) {
70
- if (builder.numThreads() === 0) {
71
- throw new Error(`num_threads must be > 0.`);
72
- }
73
-
74
- const workerInit = {
75
- type: 'wasm_bindgen_worker_init',
76
- init: { module_or_path: module, memory },
77
- receiver: builder.receiver()
78
- };
79
-
80
- _workers = await Promise.all(
81
- Array.from({ length: builder.numThreads() }, async () => {
82
- // Self-spawn into a new Worker.
83
- //
84
- // TODO: while `new URL('...', import.meta.url) becomes a semi-standard
85
- // way to get asset URLs relative to the module across various bundlers
86
- // and browser, ideally we should switch to `import.meta.resolve`
87
- // once it becomes a standard.
88
- //
89
- // Note: we could use `../../..` as the URL here to inline workerHelpers.js
90
- // into the parent entry instead of creating another split point -
91
- // this would be preferable from optimization perspective -
92
- // however, Webpack then eliminates all message handler code
93
- // because wasm-pack produces "sideEffects":false in package.json
94
- // unconditionally.
95
- //
96
- // The only way to work around that is to have side effect code
97
- // in an entry point such as Worker file itself.
98
- const worker = new Worker(new URL('./workerHelpers.js', import.meta.url), {
99
- type: 'module'
100
- });
101
- worker.postMessage(workerInit);
102
- await waitForMsgType(worker, 'wasm_bindgen_worker_ready');
103
- return worker;
104
- })
105
- );
106
- builder.build();
107
- }