@parcel/rust 2.12.1-dev.3268 → 2.12.1-dev.3275

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,25 +7,37 @@ export interface JsMacroError {
7
7
  kind: number
8
8
  message: string
9
9
  }
10
- export interface SerializedParcelDb {
11
- id: bigint
12
- }
10
+ export function initSentry(): void
11
+ export function closeSentry(): void
13
12
  export function findAncestorFile(filenames: Array<string>, from: string, root: string): string | null
14
13
  export function findFirstFile(names: Array<string>): string | null
15
14
  export function findNodeModule(module: string, from: string): string | null
16
15
  export function hashString(s: string): string
17
16
  export function hashBuffer(buf: Buffer): string
18
17
  export function optimizeImage(kind: string, buf: Buffer): Buffer
18
+ export interface ParcelNapiBuildOptions {
19
+
20
+ }
21
+ export interface ParcelNapiBuildResult {
22
+
23
+ }
24
+ export interface ParcelNapiOptions {
25
+ threads?: number
26
+ nodeWorkers?: number
27
+ fs?: object
28
+ rpc: (...args: any[]) => any
29
+ }
30
+ export function workerCallback(callback: (...args: any[]) => any): void
19
31
  export interface JsFileSystemOptions {
20
32
  canonicalize: (...args: any[]) => any
21
33
  read: (...args: any[]) => any
22
34
  isFile: (...args: any[]) => any
23
35
  isDir: (...args: any[]) => any
24
- includeNodeModules?: boolean | Array<string> | Record<string, boolean>
36
+ includeNodeModules?: NapiSideEffectsVariants
25
37
  }
26
38
  export interface FileSystem {
27
39
  fs?: JsFileSystemOptions
28
- includeNodeModules?: boolean | Array<string> | Record<string, boolean>
40
+ includeNodeModules?: NapiSideEffectsVariants
29
41
  conditions?: number
30
42
  moduleDirResolver?: (...args: any[]) => any
31
43
  mode: number
@@ -64,32 +76,23 @@ export interface JsInvalidations {
64
76
  invalidateOnFileCreate: Array<FilePathCreateInvalidation | FileNameCreateInvalidation | GlobCreateInvalidation>
65
77
  invalidateOnStartup: boolean
66
78
  }
67
- export function transform(db: ParcelDb, opts: object): unknown
68
- export function transformAsync(db: ParcelDb, opts: object): object
69
- export type JsParcelDb = ParcelDb
70
- export class ParcelDb {
71
- constructor(options: object)
72
- serialize(): SerializedParcelDb
73
- static deserializeNative(value: SerializedParcelDb): JsParcelDb
74
- getPage(page: number): Buffer
75
- alloc(typeId: number): number
76
- dealloc(typeId: number, addr: number): void
77
- readString(addr: number): string
78
- getStringId(s: string): number
79
- extendVec(typeId: number, addr: number, count: number): void
80
- createEnvironment(addr: number): number
81
- createTarget(addr: number): number
82
- write(filename: string): void
83
- toBuffer(): Buffer
84
- static _read(filename: string, options: object): JsParcelDb
85
- static _fromBuffer(buf: Buffer, options: object): JsParcelDb
86
- }
79
+ export function transform(opts: object): unknown
80
+ export function transformAsync(opts: object): object
87
81
  export class Hash {
88
82
  constructor()
89
83
  writeString(s: string): void
90
84
  writeBuffer(buf: Buffer): void
91
85
  finish(): string
92
86
  }
87
+ export class ParcelNapi {
88
+ nodeWorkerCount: number
89
+ constructor(options: ParcelNapiOptions)
90
+ build(options: ParcelNapiBuildOptions): object
91
+ testingTempFsReadToString(path: string): Promise<string>
92
+ testingTempFsIsFile(path: string): Promise<boolean>
93
+ testingTempFsIsDir(path: string): Promise<boolean>
94
+ testingRpcPing(): Promise<void>
95
+ }
93
96
  export class Resolver {
94
97
  constructor(projectRoot: string, options: FileSystem)
95
98
  resolve(options: ResolveOptions): ResolveResult
package/index.js CHANGED
@@ -224,17 +224,32 @@ switch (platform) {
224
224
  }
225
225
  break
226
226
  case 'arm':
227
- localFileExisted = existsSync(
228
- join(__dirname, 'parcel-node-bindings.linux-arm-gnueabihf.node')
229
- )
230
- try {
231
- if (localFileExisted) {
232
- nativeBinding = require('./parcel-node-bindings.linux-arm-gnueabihf.node')
233
- } else {
234
- nativeBinding = require('@parcel/rust-linux-arm-gnueabihf')
227
+ if (isMusl()) {
228
+ localFileExisted = existsSync(
229
+ join(__dirname, 'parcel-node-bindings.linux-arm-musleabihf.node')
230
+ )
231
+ try {
232
+ if (localFileExisted) {
233
+ nativeBinding = require('./parcel-node-bindings.linux-arm-musleabihf.node')
234
+ } else {
235
+ nativeBinding = require('@parcel/rust-linux-arm-musleabihf')
236
+ }
237
+ } catch (e) {
238
+ loadError = e
239
+ }
240
+ } else {
241
+ localFileExisted = existsSync(
242
+ join(__dirname, 'parcel-node-bindings.linux-arm-gnueabihf.node')
243
+ )
244
+ try {
245
+ if (localFileExisted) {
246
+ nativeBinding = require('./parcel-node-bindings.linux-arm-gnueabihf.node')
247
+ } else {
248
+ nativeBinding = require('@parcel/rust-linux-arm-gnueabihf')
249
+ }
250
+ } catch (e) {
251
+ loadError = e
235
252
  }
236
- } catch (e) {
237
- loadError = e
238
253
  }
239
254
  break
240
255
  case 'riscv64':
@@ -295,9 +310,10 @@ if (!nativeBinding) {
295
310
  throw new Error(`Failed to load native binding`)
296
311
  }
297
312
 
298
- const { ParcelDb, findAncestorFile, findFirstFile, findNodeModule, hashString, hashBuffer, Hash, optimizeImage, Resolver, transform, transformAsync } = nativeBinding
313
+ const { initSentry, closeSentry, findAncestorFile, findFirstFile, findNodeModule, hashString, hashBuffer, Hash, optimizeImage, ParcelNapi, workerCallback, Resolver, transform, transformAsync } = nativeBinding
299
314
 
300
- module.exports.ParcelDb = ParcelDb
315
+ module.exports.initSentry = initSentry
316
+ module.exports.closeSentry = closeSentry
301
317
  module.exports.findAncestorFile = findAncestorFile
302
318
  module.exports.findFirstFile = findFirstFile
303
319
  module.exports.findNodeModule = findNodeModule
@@ -305,6 +321,8 @@ module.exports.hashString = hashString
305
321
  module.exports.hashBuffer = hashBuffer
306
322
  module.exports.Hash = Hash
307
323
  module.exports.optimizeImage = optimizeImage
324
+ module.exports.ParcelNapi = ParcelNapi
325
+ module.exports.workerCallback = workerCallback
308
326
  module.exports.Resolver = Resolver
309
327
  module.exports.transform = transform
310
328
  module.exports.transformAsync = transformAsync
package/index.js.flow CHANGED
@@ -1,20 +1,62 @@
1
1
  // @flow
2
- import type {FileCreateInvalidation} from '@parcel/types';
3
- import type {EnvironmentAddr, TargetAddr} from './src/db';
4
-
5
- export type {
6
- EnvironmentAddr,
7
- TargetAddr,
8
- };
2
+ import type {FileCreateInvalidation, FileSystem as ParcelFileSystem} from '@parcel/types';
9
3
 
10
4
  declare export var init: void | (() => void);
11
5
 
12
- declare export function findAncestorFile(filenames: Array<string>, from: string, root: string): string | null
13
- declare export function findFirstFile(names: Array<string>): string | null
14
- declare export function findNodeModule(module: string, from: string): string | null
15
- declare export function hashString(s: string): string
16
- declare export function hashBuffer(buf: Buffer): string
17
- declare export function optimizeImage(kind: string, buf: Buffer): Buffer
6
+ export type ProjectPath = any;
7
+ export interface ConfigRequest {
8
+ id: string;
9
+ invalidateOnFileChange: Array<ProjectPath>;
10
+ invalidateOnConfigKeyChange: Array<any>;
11
+ invalidateOnFileCreate: Array<any>;
12
+ invalidateOnEnvChange: Array<string>;
13
+ invalidateOnOptionChange: Array<string>;
14
+ invalidateOnStartup: boolean;
15
+ invalidateOnBuild: boolean;
16
+ }
17
+ export interface RequestOptions {}
18
+
19
+ export type RpcCallback = (error: any, id: number, data: any, done: (value: {| Ok: any |} | {| Err: any |}) => any) => any | Promise<any>;
20
+
21
+ export interface ParcelNapiOptions {
22
+ fs?: ParcelFileSystem;
23
+ nodeWorkers?: number;
24
+ rpc?: RpcCallback;
25
+ }
26
+
27
+ declare export class ParcelNapi {
28
+ nodeWorkerCount: number,
29
+ constructor(options: ParcelNapiOptions): ParcelNapi;
30
+ build(options: {||}): Promise<void>;
31
+ static defaultThreadCount(): number;
32
+ testingTempFsReadToString(path: string): string;
33
+ testingTempFsIsDir(path: string): boolean;
34
+ testingTempFsIsFile(path: string): boolean;
35
+ testingRpcPing(): void;
36
+ }
37
+
38
+ declare export function workerCallback(callback: RpcCallback): void
39
+
40
+ declare export function initSentry(): void;
41
+ declare export function closeSentry(): void;
42
+ declare export function napiRunConfigRequest(
43
+ configRequest: ConfigRequest,
44
+ api: any,
45
+ options: any,
46
+ ): void;
47
+ declare export function findAncestorFile(
48
+ filenames: Array<string>,
49
+ from: string,
50
+ root: string,
51
+ ): string | null;
52
+ declare export function findFirstFile(names: Array<string>): string | null;
53
+ declare export function findNodeModule(
54
+ module: string,
55
+ from: string,
56
+ ): string | null;
57
+ declare export function hashString(s: string): string;
58
+ declare export function hashBuffer(buf: Buffer): string;
59
+ declare export function optimizeImage(kind: string, buf: Buffer): Buffer;
18
60
  export interface JsFileSystemOptions {
19
61
  canonicalize: string => string;
20
62
  read: string => Buffer;
@@ -23,14 +65,14 @@ export interface JsFileSystemOptions {
23
65
  includeNodeModules?: boolean | Array<string> | {|[string]: boolean|};
24
66
  }
25
67
  export interface FileSystem {
26
- fs?: JsFileSystemOptions,
68
+ fs?: JsFileSystemOptions;
27
69
  includeNodeModules?: boolean | Array<string> | {|[string]: boolean|};
28
- conditions?: number,
29
- moduleDirResolver?: (...args: any[]) => any,
30
- mode: number,
31
- entries?: number,
32
- extensions?: Array<string>,
33
- packageExports: boolean
70
+ conditions?: number;
71
+ moduleDirResolver?: (...args: any[]) => any;
72
+ mode: number;
73
+ entries?: number;
74
+ extensions?: Array<string>;
75
+ packageExports: boolean;
34
76
  }
35
77
  export interface ResolveOptions {
36
78
  filename: string;
@@ -59,46 +101,13 @@ export interface JsInvalidations {
59
101
  invalidateOnFileCreate: Array<FileCreateInvalidation>;
60
102
  invalidateOnStartup: boolean;
61
103
  }
62
- declare export function transform(db: ParcelDb, opts: any): any;
63
- declare export function transformAsync(db: ParcelDb, opts: any): Promise<any>;
104
+ declare export function transform(opts: any): any;
105
+ declare export function transformAsync(opts: any): Promise<any>;
64
106
  declare export class Hash {
65
107
  writeString(s: string): void;
66
108
  writeBuffer(b: Buffer): void;
67
109
  finish(): string;
68
110
  }
69
- // $FlowFixMe
70
- type TmpBigInt = bigint;
71
- export type SerializedParcelDb = {|
72
- id: TmpBigInt
73
- |};
74
- type Options = {|
75
- mode: string,
76
- env: {[string]: string | void},
77
- log_level: string,
78
- project_root: string
79
- |};
80
- declare export class ParcelDb {
81
- constructor(options: Options): ParcelDb;
82
- serialize(): SerializedParcelDb;
83
- static create(options: Options): ParcelDb;
84
- static read(filename: string, options: Options): ParcelDb;
85
- static fromBuffer(buf: Buffer, options: Options): ParcelDb;
86
- static deserialize(value: SerializedParcelDb): ParcelDb;
87
- write(filename: string): void;
88
- toBuffer(): Buffer;
89
- getPage(page: number): Buffer;
90
- alloc(typeId: number): number;
91
- dealloc(typeId: number, addr: number): void;
92
- readString(addr: number): string;
93
- getStringId(s: string): number;
94
- extendVec(typeId: number, addr: number, count: number): void;
95
- createEnvironment(addr: EnvironmentAddr): EnvironmentAddr;
96
- createTarget(addr: TargetAddr): TargetAddr;
97
-
98
- starSymbol: number;
99
- defaultSymbol: number;
100
- [symbol]: any;
101
- }
102
111
  export interface ResolverOptions {
103
112
  fs?: JsFileSystemOptions;
104
113
  includeNodeModules?: boolean | Array<string> | {|[string]: boolean|};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcel/rust",
3
- "version": "2.12.1-dev.3268+10d19ff8a",
3
+ "version": "2.12.1-dev.3275+8b017703f",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -13,21 +13,19 @@
13
13
  "type": "git",
14
14
  "url": "https://github.com/parcel-bundler/parcel.git"
15
15
  },
16
- "main": "lib/index.js",
16
+ "main": "index.js",
17
17
  "browser": "browser.js",
18
- "source": "src/index.js",
19
18
  "napi": {
20
19
  "name": "parcel-node-bindings"
21
20
  },
22
21
  "engines": {
23
- "node": ">= 12.0.0"
22
+ "node": ">= 16.0.0"
24
23
  },
25
24
  "files": [
26
25
  "browser.js",
27
26
  "index.d.ts",
28
27
  "index.js",
29
28
  "index.js.flow",
30
- "lib",
31
29
  "*.node",
32
30
  "*.wasm"
33
31
  ],
@@ -36,11 +34,11 @@
36
34
  "napi-wasm": "^1.0.1"
37
35
  },
38
36
  "scripts": {
39
- "build": "napi build --platform --cargo-cwd ../../../crates/node-bindings && yarn build-db",
40
- "build-release": "napi build --platform --release --cargo-cwd ../../../crates/node-bindings && yarn build-db",
41
- "build-db": "cargo run -p parcel-db && prettier --write src/db.js",
37
+ "build": "napi build --platform --cargo-cwd ../../../crates/node-bindings",
38
+ "build-canary": "napi build --platform --profile canary --features canary --cargo-cwd ../../../crates/node-bindings",
39
+ "build-release": "napi build --platform --release --cargo-cwd ../../../crates/node-bindings",
42
40
  "wasm:build": "cargo build -p parcel-node-bindings --target wasm32-unknown-unknown && cp ../../../target/wasm32-unknown-unknown/debug/parcel_node_bindings.wasm .",
43
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"
44
42
  },
45
- "gitHead": "10d19ff8a34dd8f479847aadf9865be48a8fad84"
43
+ "gitHead": "8b017703fdf4a90a643ce0190cdd7482060dc86b"
46
44
  }