@parcel/rust 2.12.1-dev.3303 → 2.12.1-dev.3335

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
@@ -7,52 +7,50 @@ export interface JsMacroError {
7
7
  kind: number
8
8
  message: string
9
9
  }
10
- export function initSentry(): void
11
- export function closeSentry(): void
12
10
  export function findAncestorFile(filenames: Array<string>, from: string, root: string): string | null
13
11
  export function findFirstFile(names: Array<string>): string | null
14
12
  export function findNodeModule(module: string, from: string): string | null
15
13
  export function hashString(s: string): string
16
14
  export function hashBuffer(buf: Buffer): string
17
15
  export function optimizeImage(kind: string, buf: Buffer): Buffer
18
- /**
19
- * JavaScript provided options to configure the `tracing_subscriber` rust logs into a file or the
20
- * console.
21
- */
22
- export interface ParcelTracingOptions {
23
- /** Enable tracing */
24
- enabled: boolean
25
- /**
26
- * If set to some, will trace to a file with the given options, otherwise the console will be
27
- * used.
28
- */
29
- outputFileOptions?: ParcelTracingOutputFileOptions
30
- }
31
- /**
32
- * Output file configuration.
33
- * Tracing log files will be rotated hourly on the provided directory.
34
- */
35
- export interface ParcelTracingOutputFileOptions {
36
- /** The directory where the log files will be written. */
37
- directory: string
38
- /** A prefix for the log file names. */
39
- prefix: string
40
- /** The maximum number of rotated files to keep. */
41
- maxFiles: number
42
- }
16
+ export function initializeMonitoring(): void
17
+ export function closeMonitoring(): void
43
18
  export interface ParcelNapiBuildOptions {
44
-
19
+ registerWorker: (...args: any[]) => any
45
20
  }
46
21
  export interface ParcelNapiBuildResult {
47
22
 
48
23
  }
49
24
  export interface ParcelNapiOptions {
50
- threads?: number
51
- nodeWorkers?: number
52
25
  fs?: object
53
- tracingOptions?: ParcelTracingOptions
26
+ nodeWorkers?: number
27
+ options: object
28
+ packageManager?: object
29
+ threads?: number
54
30
  }
55
- export function registerWorker(worker: object): void
31
+ /**
32
+ * This function is run in the Nodejs worker context upon initialization
33
+ * to notify the main thread that a Nodejs worker thread has started
34
+ *
35
+ * A Rust channel is transferred to the worker via JavaScript `worker.postMessage`.
36
+ * The worker then calls `register_worker`, supplying it with an object containing
37
+ * callbacks.
38
+ *
39
+ * The callbacks are later called from the main thread to send work to the worker.
40
+ *
41
+ * |-------------| --- Init channel ----> |-------------------|
42
+ * | Main Thread | | Worker Thread (n) |
43
+ * |-------------| <-- Worker wrapper --- |-------------------|
44
+ *
45
+ * **Later During Build**
46
+ *
47
+ * -- Resolver.resolve -->
48
+ * <- DependencyResult ---
49
+ *
50
+ * -- Transf.transform -->
51
+ * <--- Array<Asset> -----
52
+ */
53
+ export function registerWorker(channel: JsTransferable, worker: object): void
56
54
  export interface JsFileSystemOptions {
57
55
  canonicalize: (...args: any[]) => any
58
56
  read: (...args: any[]) => any
@@ -101,6 +99,54 @@ export interface JsInvalidations {
101
99
  invalidateOnFileCreate: Array<FilePathCreateInvalidation | FileNameCreateInvalidation | GlobCreateInvalidation>
102
100
  invalidateOnStartup: boolean
103
101
  }
102
+ export interface JsFileSystemOptionsOld {
103
+ canonicalize: (...args: any[]) => any
104
+ read: (...args: any[]) => any
105
+ isFile: (...args: any[]) => any
106
+ isDir: (...args: any[]) => any
107
+ includeNodeModules?: NapiSideEffectsVariants
108
+ }
109
+ export interface FileSystemOld {
110
+ fs?: JsFileSystemOptionsOld
111
+ includeNodeModules?: NapiSideEffectsVariants
112
+ conditions?: number
113
+ moduleDirResolver?: (...args: any[]) => any
114
+ mode: number
115
+ entries?: number
116
+ extensions?: Array<string>
117
+ packageExports: boolean
118
+ typescript?: boolean
119
+ }
120
+ export interface ResolveOptionsOld {
121
+ filename: string
122
+ specifierType: string
123
+ parent: string
124
+ packageConditions?: Array<string>
125
+ }
126
+ export interface FilePathCreateInvalidationOld {
127
+ filePath: string
128
+ }
129
+ export interface FileNameCreateInvalidationOld {
130
+ fileName: string
131
+ aboveFilePath: string
132
+ }
133
+ export interface GlobCreateInvalidationOld {
134
+ glob: string
135
+ }
136
+ export interface ResolveResultOld {
137
+ resolution: unknown
138
+ invalidateOnFileChange: Array<string>
139
+ invalidateOnFileCreate: Array<FilePathCreateInvalidationOld | FileNameCreateInvalidationOld | GlobCreateInvalidationOld>
140
+ query?: string
141
+ sideEffects: boolean
142
+ error: unknown
143
+ moduleType: number
144
+ }
145
+ export interface JsInvalidationsOld {
146
+ invalidateOnFileChange: Array<string>
147
+ invalidateOnFileCreate: Array<FilePathCreateInvalidationOld | FileNameCreateInvalidationOld | GlobCreateInvalidationOld>
148
+ invalidateOnStartup: boolean
149
+ }
104
150
  export function testingRunParcelJsTransformerPlugin(targetPath: string): unknown
105
151
  export function transform(opts: object): unknown
106
152
  export function transformAsync(opts: object): object
@@ -112,11 +158,9 @@ export class Hash {
112
158
  }
113
159
  export class ParcelNapi {
114
160
  nodeWorkerCount: number
115
- constructor(options: ParcelNapiOptions)
161
+ constructor(napiOptions: ParcelNapiOptions)
116
162
  build(options: ParcelNapiBuildOptions): object
117
- testingTempFsReadToString(path: string): Promise<string>
118
- testingTempFsIsFile(path: string): Promise<boolean>
119
- testingTempFsIsDir(path: string): Promise<boolean>
163
+ buildAssetGraph(options: ParcelNapiBuildOptions): object
120
164
  }
121
165
  export class Resolver {
122
166
  constructor(projectRoot: string, options: FileSystem)
@@ -126,3 +170,11 @@ export class Resolver {
126
170
  getInvalidations(path: string): JsInvalidations
127
171
  getInvalidations(path: string): JsInvalidations
128
172
  }
173
+ export class ResolverOld {
174
+ constructor(projectRoot: string, options: FileSystemOld)
175
+ resolve(options: ResolveOptionsOld): ResolveResultOld
176
+ resolveAsync(): object
177
+ resolveAsync(options: ResolveOptionsOld): object
178
+ getInvalidations(path: string): JsInvalidationsOld
179
+ getInvalidations(path: string): JsInvalidationsOld
180
+ }
package/index.js CHANGED
@@ -310,10 +310,8 @@ if (!nativeBinding) {
310
310
  throw new Error(`Failed to load native binding`)
311
311
  }
312
312
 
313
- const { initSentry, closeSentry, findAncestorFile, findFirstFile, findNodeModule, hashString, hashBuffer, Hash, optimizeImage, ParcelNapi, registerWorker, Resolver, testingRunParcelJsTransformerPlugin, transform, transformAsync } = nativeBinding
313
+ const { findAncestorFile, findFirstFile, findNodeModule, hashString, hashBuffer, Hash, optimizeImage, initializeMonitoring, closeMonitoring, ParcelNapi, registerWorker, Resolver, ResolverOld, testingRunParcelJsTransformerPlugin, transform, transformAsync } = nativeBinding
314
314
 
315
- module.exports.initSentry = initSentry
316
- module.exports.closeSentry = closeSentry
317
315
  module.exports.findAncestorFile = findAncestorFile
318
316
  module.exports.findFirstFile = findFirstFile
319
317
  module.exports.findNodeModule = findNodeModule
@@ -321,9 +319,12 @@ module.exports.hashString = hashString
321
319
  module.exports.hashBuffer = hashBuffer
322
320
  module.exports.Hash = Hash
323
321
  module.exports.optimizeImage = optimizeImage
322
+ module.exports.initializeMonitoring = initializeMonitoring
323
+ module.exports.closeMonitoring = closeMonitoring
324
324
  module.exports.ParcelNapi = ParcelNapi
325
325
  module.exports.registerWorker = registerWorker
326
326
  module.exports.Resolver = Resolver
327
+ module.exports.ResolverOld = ResolverOld
327
328
  module.exports.testingRunParcelJsTransformerPlugin = testingRunParcelJsTransformerPlugin
328
329
  module.exports.transform = transform
329
330
  module.exports.transformAsync = transformAsync
package/index.js.flow CHANGED
@@ -1,8 +1,16 @@
1
1
  // @flow
2
- import type {FileCreateInvalidation, FileSystem as ParcelFileSystem} from '@parcel/types';
2
+ import type {
3
+ Encoding,
4
+ FileCreateInvalidation,
5
+ FilePath,
6
+ InitialParcelOptions,
7
+ PackageManager,
8
+ } from '@parcel/types';
3
9
 
4
10
  declare export var init: void | (() => void);
5
11
 
12
+ export type Transferable = {||};
13
+
6
14
  export type ProjectPath = any;
7
15
  export interface ConfigRequest {
8
16
  id: string;
@@ -16,16 +24,42 @@ export interface ConfigRequest {
16
24
  }
17
25
  export interface RequestOptions {}
18
26
 
19
- export interface ParcelNapiOptions {
20
- threads?: number;
21
- nodeWorkers?: number;
22
- fs?: ParcelFileSystem;
27
+ export interface FileSystem {
28
+ canonicalize(path: FilePath): FilePath;
29
+ cwd(): FilePath;
30
+ isDir(path: FilePath): boolean;
31
+ isFile(path: FilePath): boolean;
32
+ readFile(path: FilePath, encoding?: Encoding): string;
23
33
  }
24
34
 
35
+ export type ParcelNapiOptions = {|
36
+ fs?: FileSystem,
37
+ nodeWorkers?: number,
38
+ options: {|
39
+ corePath?: string,
40
+ // TODO Use Omit when available in flow >0.210.0
41
+ ...$Diff<
42
+ InitialParcelOptions,
43
+ {|
44
+ inputFS: InitialParcelOptions['inputFS'],
45
+ outputFS: InitialParcelOptions['outputFS'],
46
+ packageManager: InitialParcelOptions['packageManager'],
47
+ |},
48
+ >,
49
+ |},
50
+ packageManager?: PackageManager,
51
+ threads?: number,
52
+ |};
53
+
54
+ export type ParcelBuildOptions = {|
55
+ registerWorker: (channel: Transferable) => void | Promise<void>,
56
+ |};
57
+
25
58
  declare export class ParcelNapi {
26
- nodeWorkerCount: number,
59
+ nodeWorkerCount: number;
27
60
  constructor(options: ParcelNapiOptions): ParcelNapi;
28
- build(options: {||}): Promise<void>;
61
+ build(options: ParcelBuildOptions): Promise<void>;
62
+ buildAssetGraph(options: ParcelBuildOptions): Promise<any>;
29
63
  static defaultThreadCount(): number;
30
64
  testingTempFsReadToString(path: string): string;
31
65
  testingTempFsIsDir(path: string): boolean;
@@ -33,10 +67,13 @@ declare export class ParcelNapi {
33
67
  testingRpcPing(): void;
34
68
  }
35
69
 
36
- declare export function registerWorker(worker: any): void
70
+ declare export function registerWorker(
71
+ channel: Transferable,
72
+ worker: any,
73
+ ): void;
37
74
 
38
- declare export function initSentry(): void;
39
- declare export function closeSentry(): void;
75
+ declare export function initializeMonitoring(): void;
76
+ declare export function closeMonitoring(): void;
40
77
  declare export function napiRunConfigRequest(
41
78
  configRequest: ConfigRequest,
42
79
  api: any,
@@ -62,16 +99,6 @@ export interface JsFileSystemOptions {
62
99
  isDir: string => boolean;
63
100
  includeNodeModules?: boolean | Array<string> | {|[string]: boolean|};
64
101
  }
65
- export interface FileSystem {
66
- fs?: JsFileSystemOptions;
67
- includeNodeModules?: boolean | Array<string> | {|[string]: boolean|};
68
- conditions?: number;
69
- moduleDirResolver?: (...args: any[]) => any;
70
- mode: number;
71
- entries?: number;
72
- extensions?: Array<string>;
73
- packageExports: boolean;
74
- }
75
102
  export interface ResolveOptions {
76
103
  filename: string;
77
104
  specifierType: string;
@@ -121,3 +148,9 @@ declare export class Resolver {
121
148
  resolveAsync(options: ResolveOptions): Promise<ResolveResult>;
122
149
  getInvalidations(path: string): JsInvalidations;
123
150
  }
151
+ declare export class ResolverOld {
152
+ constructor(projectRoot: string, options: ResolverOptions): Resolver;
153
+ resolve(options: ResolveOptions): ResolveResult;
154
+ resolveAsync(options: ResolveOptions): Promise<ResolveResult>;
155
+ getInvalidations(path: string): JsInvalidations;
156
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcel/rust",
3
- "version": "2.12.1-dev.3303+3edb0d741",
3
+ "version": "2.12.1-dev.3335+c6bc8e411",
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": "3edb0d7419831e49cfa7ea8c52b4f7127a16ae52"
43
+ "gitHead": "c6bc8e41105247c437089ec3cb91e53f12ac5519"
44
44
  }