@parcel/rust 2.12.1-canary.3319 → 2.12.1-canary.3322

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
@@ -91,6 +113,7 @@ export class ParcelNapi {
91
113
  nodeWorkerCount: number
92
114
  constructor(napiOptions: ParcelNapiOptions)
93
115
  build(options: ParcelNapiBuildOptions): object
116
+ buildAssetGraph(options: ParcelNapiBuildOptions): object
94
117
  }
95
118
  export class Resolver {
96
119
  constructor(projectRoot: string, options: FileSystem)
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,15 @@ 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>;
71
+ buildAssetGraph(options: ParcelBuildOptions): Promise<any>;
65
72
  static defaultThreadCount(): number;
66
73
  testingTempFsReadToString(path: string): string;
67
74
  testingTempFsIsDir(path: string): boolean;
@@ -69,7 +76,10 @@ declare export class ParcelNapi {
69
76
  testingRpcPing(): void;
70
77
  }
71
78
 
72
- declare export function registerWorker(worker: any): void;
79
+ declare export function registerWorker(
80
+ channel: Transferable,
81
+ worker: any,
82
+ ): void;
73
83
 
74
84
  declare export function initSentry(): void;
75
85
  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.3319+7fd97e461",
3
+ "version": "2.12.1-canary.3322+2aac813a6",
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": "7fd97e461582aa2cf22ed6cc7f3f788da63edd09"
43
+ "gitHead": "2aac813a6d19fd5f508dffcd1e63bd2c19c8f5f8"
44
44
  }