@parcel/rust 2.12.1-canary.3318 → 2.12.1-canary.3320

Sign up to get free protection for your applications and to get access to all the features.
package/index.d.ts CHANGED
@@ -16,7 +16,7 @@ export function hashString(s: string): string
16
16
  export function hashBuffer(buf: Buffer): string
17
17
  export function optimizeImage(kind: string, buf: Buffer): Buffer
18
18
  export interface ParcelNapiBuildOptions {
19
-
19
+ registerWorker: (...args: any[]) => any
20
20
  }
21
21
  export interface ParcelNapiBuildResult {
22
22
 
@@ -29,7 +29,29 @@ export interface ParcelNapiOptions {
29
29
  threads?: number
30
30
  tracerOptions?: object
31
31
  }
32
- export function registerWorker(worker: object): void
32
+ /**
33
+ * This function is run in the Nodejs worker context upon initialization
34
+ * to notify the main thread that a Nodejs worker thread has started
35
+ *
36
+ * A Rust channel is transferred to the worker via JavaScript `worker.postMessage`.
37
+ * The worker then calls `register_worker`, supplying it with an object containing
38
+ * callbacks.
39
+ *
40
+ * The callbacks are later called from the main thread to send work to the worker.
41
+ *
42
+ * |-------------| --- Init channel ----> |-------------------|
43
+ * | Main Thread | | Worker Thread (n) |
44
+ * |-------------| <-- Worker wrapper --- |-------------------|
45
+ *
46
+ * **Later During Build**
47
+ *
48
+ * -- Resolver.resolve -->
49
+ * <- DependencyResult ---
50
+ *
51
+ * -- Transf.transform -->
52
+ * <--- Array<Asset> -----
53
+ */
54
+ export function registerWorker(channel: JsTransferable, worker: object): void
33
55
  export interface JsFileSystemOptions {
34
56
  canonicalize: (...args: any[]) => any
35
57
  read: (...args: any[]) => any
package/index.js.flow CHANGED
@@ -9,6 +9,8 @@ import type {
9
9
 
10
10
  declare export var init: void | (() => void);
11
11
 
12
+ export type Transferable = {||};
13
+
12
14
  export type ProjectPath = any;
13
15
  export interface ConfigRequest {
14
16
  id: string;
@@ -58,10 +60,14 @@ export type ParcelNapiOptions = {|
58
60
  |},
59
61
  |};
60
62
 
63
+ export type ParcelBuildOptions = {|
64
+ registerWorker: (channel: Transferable) => void | Promise<void>,
65
+ |};
66
+
61
67
  declare export class ParcelNapi {
62
68
  nodeWorkerCount: number;
63
69
  constructor(options: ParcelNapiOptions): ParcelNapi;
64
- build(): Promise<void>;
70
+ build(options: ParcelBuildOptions): Promise<void>;
65
71
  static defaultThreadCount(): number;
66
72
  testingTempFsReadToString(path: string): string;
67
73
  testingTempFsIsDir(path: string): boolean;
@@ -69,7 +75,10 @@ declare export class ParcelNapi {
69
75
  testingRpcPing(): void;
70
76
  }
71
77
 
72
- declare export function registerWorker(worker: any): void;
78
+ declare export function registerWorker(
79
+ channel: Transferable,
80
+ worker: any,
81
+ ): void;
73
82
 
74
83
  declare export function initSentry(): void;
75
84
  declare export function closeSentry(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcel/rust",
3
- "version": "2.12.1-canary.3318+7068dd69b",
3
+ "version": "2.12.1-canary.3320+8cc5c8f48",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -40,5 +40,5 @@
40
40
  "wasm:build": "cargo build -p parcel-node-bindings --target wasm32-unknown-unknown && cp ../../../target/wasm32-unknown-unknown/debug/parcel_node_bindings.wasm .",
41
41
  "wasm:build-release": "CARGO_PROFILE_RELEASE_LTO=true cargo build -p parcel-node-bindings --target wasm32-unknown-unknown --release && wasm-opt --strip-debug -O ../../../target/wasm32-unknown-unknown/release/parcel_node_bindings.wasm -o parcel_node_bindings.wasm"
42
42
  },
43
- "gitHead": "7068dd69b916d001c2551ceadff778aa032dff14"
43
+ "gitHead": "8cc5c8f4826882f8f066b3efff751324c3b9986c"
44
44
  }