@utoo/web 1.2.7 → 1.2.8

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.
Binary file
@@ -1,2 +1 @@
1
- import { Binding } from "../types";
2
- export declare const runLoaderWorkerPool: (binding: Binding, projectCwd: string, loaderWorkerUrl: string, loadersImportMap?: Record<string, string>) => Promise<void>;
1
+ export declare const runLoaderWorkerPool: (projectCwd: string, loaderWorkerUrl: string, loadersImportMap?: Record<string, string>) => Promise<void>;
@@ -1,7 +1,7 @@
1
- import initWasm, { registerWorkerScheduler, workerCreated, } from "../utoo";
1
+ import { getWasmMemory, getWasmModule, registerWorkerScheduler, workerCreated, } from "../utoo";
2
2
  let nextWorkerId = 0;
3
3
  const loaderWorkers = {};
4
- export const runLoaderWorkerPool = async (binding, projectCwd, loaderWorkerUrl, loadersImportMap) => {
4
+ export const runLoaderWorkerPool = async (projectCwd, loaderWorkerUrl, loadersImportMap) => {
5
5
  registerWorkerScheduler(async (creation) => {
6
6
  const { options: { filename, cwd }, } = creation;
7
7
  nextWorkerId += 1;
@@ -38,9 +38,8 @@ export const runLoaderWorkerPool = async (binding, projectCwd, loaderWorkerUrl,
38
38
  }
39
39
  }
40
40
  worker.postMessage([
41
- // @ts-ignore
42
- initWasm.__wbindgen_wasm_module,
43
- binding.memory,
41
+ getWasmModule(),
42
+ getWasmMemory(),
44
43
  {
45
44
  workerData: {
46
45
  cwd: finalCwd,
@@ -48,7 +47,7 @@ export const runLoaderWorkerPool = async (binding, projectCwd, loaderWorkerUrl,
48
47
  threadId: workerId,
49
48
  },
50
49
  loaderAssets: {
51
- importMaps: { ...loadersImportMap },
50
+ importMaps: loadersImportMap !== null && loadersImportMap !== void 0 ? loadersImportMap : {},
52
51
  entrypoint: finalFilename,
53
52
  },
54
53
  },
@@ -1,4 +1,4 @@
1
- import initWasm, { Project, recvTaskMessageInWorker, sendTaskMessage, workerCreated, } from "../utoo";
1
+ import initWasm, { Fs, recvTaskMessageInWorker, sendTaskMessage, workerCreated, } from "../utoo";
2
2
  import { cjs } from "./cjs";
3
3
  const binding = {
4
4
  recvTaskMessageInWorker,
@@ -12,16 +12,12 @@ export function startLoaderWorker() {
12
12
  console.log(err);
13
13
  throw err;
14
14
  });
15
- // Initialize the thread-local state (tokio runtime).
16
- // We don't need to pass threadWorkerUrl here because it's already stored in a global static in Rust.
17
- Project.init("");
18
- Project.setCwd(meta.workerData.cwd);
19
15
  self.workerData = {
20
16
  threadId: meta.workerData.threadId,
21
17
  cwd: meta.workerData.cwd,
22
18
  projectRoot: meta.workerData.projectRoot,
23
19
  binding,
24
- fs: Project,
20
+ fs: Fs,
25
21
  };
26
22
  self.process = {
27
23
  env: {},
package/esm/worker.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import * as comlink from "comlink";
2
+ import { WorkerMessageType } from "./message";
2
3
  import { internalEndpoint } from "./project/InternalProject";
3
- import { HandShake } from "./utils/message";
4
4
  const ConnectedPorts = new Set();
5
5
  self.addEventListener("message", (e) => {
6
6
  const port = e.ports[0];
7
- if (e.data === HandShake && !ConnectedPorts.has(port)) {
7
+ if (e.data === WorkerMessageType.InitConnection &&
8
+ !ConnectedPorts.has(port)) {
8
9
  comlink.expose(internalEndpoint, port);
9
10
  ConnectedPorts.add(port);
10
11
  }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@utoo/web",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "module": "esm/index.js",
5
5
  "types": "esm/index.d.ts",
6
6
  "files": [
7
7
  "esm"
8
8
  ],
9
9
  "scripts": {
10
- "install-toolchain": "cargo install wasm-bindgen-cli@0.2.106 && brew install binaryen llvm",
10
+ "install-toolchain": "cargo install wasm-bindgen-cli@0.2.108 && brew install binaryen llvm",
11
11
  "build-wasm": "cargo build -p utoo-wasm --target wasm32-unknown-unknown -Z build-std=panic_abort,std",
12
12
  "build-wasm:pm": "cargo build -p utoo-wasm --target wasm32-unknown-unknown --no-default-features -Z build-std=panic_abort,std",
13
13
  "bindgen-dev": "wasm-bindgen ../../target/wasm32-unknown-unknown/wasm-dev/utoo_wasm.wasm --out-dir src/utoo --out-name index --target web --debug --keep-debug --no-demangle",
@@ -1,3 +0,0 @@
1
- export declare const HandShake = "__handshake__";
2
- export declare const ServiceWorkerHandShake = "__service_worker_handshake__";
3
- export declare const Fork = "__fork__";
@@ -1,3 +0,0 @@
1
- export const HandShake = "__handshake__";
2
- export const ServiceWorkerHandShake = "__service_worker_handshake__";
3
- export const Fork = "__fork__";