@atlaspack/rust 2.13.2-canary.3656 → 2.13.2-canary.3658

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/index.d.ts CHANGED
@@ -38,46 +38,20 @@ export declare function hashString(s: string): string
38
38
  export declare function hashBuffer(buf: Buffer): string
39
39
  export declare function optimizeImage(kind: string, buf: Buffer): Buffer
40
40
  export declare function createAssetId(params: unknown): string
41
- export interface AtlaspackNapiBuildOptions {
42
- registerWorker: (...args: any[]) => any
43
- }
44
- export interface AtlaspackNapiBuildResult {
45
-
46
- }
47
41
  export interface AtlaspackNapiOptions {
48
42
  fs?: object
49
- nodeWorkers?: number
50
43
  options: object
51
44
  packageManager?: object
52
45
  threads?: number
46
+ napiWorkerPool: object
53
47
  }
54
48
  export declare function createDependencyId(params: unknown): string
55
49
  export declare function createEnvironmentId(params: unknown): string
50
+ export declare function getAvailableThreads(): number
56
51
  export declare function initializeMonitoring(): void
57
52
  export declare function closeMonitoring(): void
58
- /**
59
- * This function is run in the Nodejs worker context upon initialization
60
- * to notify the main thread that a Nodejs worker thread has started
61
- *
62
- * A Rust channel is transferred to the worker via JavaScript `worker.postMessage`.
63
- * The worker then calls `register_worker`, supplying it with an object containing
64
- * callbacks.
65
- *
66
- * The callbacks are later called from the main thread to send work to the worker.
67
- *
68
- * |-------------| --- Init channel ----> |-------------------|
69
- * | Main Thread | | Worker Thread (n) |
70
- * |-------------| <-- Worker wrapper --- |-------------------|
71
- *
72
- * **Later During Build**
73
- *
74
- * -- Resolver.resolve -->
75
- * <- DependencyResult ---
76
- *
77
- * -- Transf.transform -->
78
- * <--- Array<Asset> -----
79
- */
80
- export declare function registerWorker(channel: JsTransferable, worker: object): void
53
+ /** Called on the worker thread to create a reference to the NodeJs worker */
54
+ export declare function newNodejsWorker(worker: object): JsTransferable
81
55
  export interface InlineRequiresOptimizerInput {
82
56
  code: string
83
57
  sourceMaps: boolean
@@ -183,9 +157,9 @@ export class AtlaspackTracer {
183
157
  exit(id: SpanId): void
184
158
  }
185
159
  export class AtlaspackNapi {
186
- nodeWorkerCount: number
187
160
  static create(napiOptions: AtlaspackNapiOptions, lmdb: LMDB): AtlaspackNapi
188
- buildAssetGraph(options: AtlaspackNapiBuildOptions): object
161
+ buildAssetGraph(): object
162
+ respondToFsEvents(options: object): object
189
163
  }
190
164
  export class Resolver {
191
165
  constructor(projectRoot: string, options: FileSystem)
package/index.js CHANGED
@@ -310,7 +310,7 @@ if (!nativeBinding) {
310
310
  throw new Error(`Failed to load native binding`)
311
311
  }
312
312
 
313
- const { initTracingSubscriber, Lmdb, findAncestorFile, findFirstFile, findNodeModule, hashString, hashBuffer, Hash, optimizeImage, AtlaspackTracer, createAssetId, AtlaspackNapi, createDependencyId, createEnvironmentId, initializeMonitoring, closeMonitoring, registerWorker, runInlineRequiresOptimizer, Resolver, transform, transformAsync, getVcsStateSnapshot, getEventsSince } = nativeBinding
313
+ const { initTracingSubscriber, Lmdb, findAncestorFile, findFirstFile, findNodeModule, hashString, hashBuffer, Hash, optimizeImage, AtlaspackTracer, createAssetId, AtlaspackNapi, createDependencyId, createEnvironmentId, getAvailableThreads, initializeMonitoring, closeMonitoring, newNodejsWorker, runInlineRequiresOptimizer, Resolver, transform, transformAsync, getVcsStateSnapshot, getEventsSince } = nativeBinding
314
314
 
315
315
  module.exports.initTracingSubscriber = initTracingSubscriber
316
316
  module.exports.Lmdb = Lmdb
@@ -326,9 +326,10 @@ module.exports.createAssetId = createAssetId
326
326
  module.exports.AtlaspackNapi = AtlaspackNapi
327
327
  module.exports.createDependencyId = createDependencyId
328
328
  module.exports.createEnvironmentId = createEnvironmentId
329
+ module.exports.getAvailableThreads = getAvailableThreads
329
330
  module.exports.initializeMonitoring = initializeMonitoring
330
331
  module.exports.closeMonitoring = closeMonitoring
331
- module.exports.registerWorker = registerWorker
332
+ module.exports.newNodejsWorker = newNodejsWorker
332
333
  module.exports.runInlineRequiresOptimizer = runInlineRequiresOptimizer
333
334
  module.exports.Resolver = Resolver
334
335
  module.exports.transform = transform
package/index.js.flow CHANGED
@@ -9,6 +9,15 @@ import type {
9
9
 
10
10
  declare export var init: void | (() => void);
11
11
 
12
+ export type WatchEventType = 'create' | 'update' | 'delete';
13
+
14
+ export interface WatchEvent {
15
+ path: string,
16
+ type: WatchEventType,
17
+ }
18
+
19
+ export type WatchEvents = Array<WatchEvent>;
20
+
12
21
  export type Transferable = {||};
13
22
 
14
23
  export type JsCallable<Args: $ReadOnlyArray<mixed>, Return> = (
@@ -40,6 +49,7 @@ export interface FileSystem {
40
49
  export type AtlaspackNapiOptions = {|
41
50
  fs?: FileSystem,
42
51
  nodeWorkers?: number,
52
+ napiWorkerPool: any,
43
53
  options: {|
44
54
  featureFlags?: { [string]: string | boolean },
45
55
  corePath?: string,
@@ -57,15 +67,11 @@ export type AtlaspackNapiOptions = {|
57
67
  threads?: number,
58
68
  |};
59
69
 
60
- export type AtlaspackBuildOptions = {|
61
- registerWorker: (channel: Transferable) => void | Promise<void>,
62
- |};
63
-
64
70
  declare export class AtlaspackNapi {
65
71
  static create(options: AtlaspackNapiOptions, lmdb: mixed): AtlaspackNapi;
66
72
  nodeWorkerCount: number;
67
- build(options: AtlaspackBuildOptions): Promise<void>;
68
- buildAssetGraph(options: AtlaspackBuildOptions): Promise<any>;
73
+ buildAssetGraph(): Promise<any>;
74
+ respondToFsEvents(events: WatchEvents): boolean;
69
75
  static defaultThreadCount(): number;
70
76
  testingTempFsReadToString(path: string): string;
71
77
  testingTempFsIsDir(path: string): boolean;
@@ -73,11 +79,17 @@ declare export class AtlaspackNapi {
73
79
  testingRpcPing(): void;
74
80
  }
75
81
 
82
+ declare export function getAvailableThreads(): number;
83
+
76
84
  declare export function registerWorker(
77
85
  channel: Transferable,
78
86
  worker: any,
79
87
  ): void;
80
88
 
89
+ declare export function newNodejsWorker(
90
+ delegate: any,
91
+ ): Transferable;
92
+
81
93
  declare export function initializeMonitoring(): void;
82
94
  declare export function closeMonitoring(): void;
83
95
  declare export function napiRunConfigRequest(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/rust",
3
- "version": "2.13.2-canary.3656+104a46a5e",
3
+ "version": "2.13.2-canary.3658+4812d0f74",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -37,5 +37,5 @@
37
37
  "wasm:build": "cargo build -p atlaspack-node-bindings --target wasm32-unknown-unknown && cp ../../../target/wasm32-unknown-unknown/debug/atlaspack_node_bindings.wasm .",
38
38
  "wasm:build-release": "CARGO_PROFILE_RELEASE_LTO=true cargo build -p atlaspack-node-bindings --target wasm32-unknown-unknown --release && wasm-opt --strip-debug -O ../../../target/wasm32-unknown-unknown/release/atlaspack_node_bindings.wasm -o atlaspack_node_bindings.wasm"
39
39
  },
40
- "gitHead": "104a46a5ee1fae176d29fcc6420d6bd9c01b35b1"
40
+ "gitHead": "4812d0f7400af0f8416f1b7175ecb87700860a68"
41
41
  }