@parcel/rust 2.12.1-dev.3151 → 2.12.1-dev.3238

Sign up to get free protection for your applications and to get access to all the features.
package/index.d.ts CHANGED
@@ -7,6 +7,9 @@ export interface JsMacroError {
7
7
  kind: number
8
8
  message: string
9
9
  }
10
+ export interface SerializedParcelDb {
11
+ id: bigint
12
+ }
10
13
  export function findAncestorFile(filenames: Array<string>, from: string, root: string): string | null
11
14
  export function findFirstFile(names: Array<string>): string | null
12
15
  export function findNodeModule(module: string, from: string): string | null
@@ -18,11 +21,11 @@ export interface JsFileSystemOptions {
18
21
  read: (...args: any[]) => any
19
22
  isFile: (...args: any[]) => any
20
23
  isDir: (...args: any[]) => any
21
- includeNodeModules?: NapiSideEffectsVariants
24
+ includeNodeModules?: boolean | Array<string> | Record<string, boolean>
22
25
  }
23
26
  export interface FileSystem {
24
27
  fs?: JsFileSystemOptions
25
- includeNodeModules?: NapiSideEffectsVariants
28
+ includeNodeModules?: boolean | Array<string> | Record<string, boolean>
26
29
  conditions?: number
27
30
  moduleDirResolver?: (...args: any[]) => any
28
31
  mode: number
@@ -61,8 +64,26 @@ export interface JsInvalidations {
61
64
  invalidateOnFileCreate: Array<FilePathCreateInvalidation | FileNameCreateInvalidation | GlobCreateInvalidation>
62
65
  invalidateOnStartup: boolean
63
66
  }
64
- export function transform(opts: object): unknown
65
- export function transformAsync(opts: object): object
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
+ }
66
87
  export class Hash {
67
88
  constructor()
68
89
  writeString(s: string): void
package/index.js CHANGED
@@ -295,8 +295,9 @@ if (!nativeBinding) {
295
295
  throw new Error(`Failed to load native binding`)
296
296
  }
297
297
 
298
- const { findAncestorFile, findFirstFile, findNodeModule, hashString, hashBuffer, Hash, optimizeImage, Resolver, transform, transformAsync } = nativeBinding
298
+ const { ParcelDb, findAncestorFile, findFirstFile, findNodeModule, hashString, hashBuffer, Hash, optimizeImage, Resolver, transform, transformAsync } = nativeBinding
299
299
 
300
+ module.exports.ParcelDb = ParcelDb
300
301
  module.exports.findAncestorFile = findAncestorFile
301
302
  module.exports.findFirstFile = findFirstFile
302
303
  module.exports.findNodeModule = findNodeModule
package/index.js.flow CHANGED
@@ -1,5 +1,6 @@
1
1
  // @flow
2
2
  import type {FileCreateInvalidation} from '@parcel/types';
3
+ import type {EnvironmentAddr, TargetAddr} from './src/db';
3
4
 
4
5
  declare export var init: void | (() => void);
5
6
 
@@ -53,13 +54,46 @@ export interface JsInvalidations {
53
54
  invalidateOnFileCreate: Array<FileCreateInvalidation>;
54
55
  invalidateOnStartup: boolean;
55
56
  }
56
- declare export function transform(opts: any): any;
57
- declare export function transformAsync(opts: any): Promise<any>;
57
+ declare export function transform(db: ParcelDb, opts: any): any;
58
+ declare export function transformAsync(db: ParcelDb, opts: any): Promise<any>;
58
59
  declare export class Hash {
59
60
  writeString(s: string): void;
60
61
  writeBuffer(b: Buffer): void;
61
62
  finish(): string;
62
63
  }
64
+ // $FlowFixMe
65
+ type TmpBigInt = bigint;
66
+ export type SerializedParcelDb = {|
67
+ id: TmpBigInt
68
+ |};
69
+ type Options = {|
70
+ mode: string,
71
+ env: {[string]: string | void},
72
+ log_level: string,
73
+ project_root: string
74
+ |};
75
+ declare export class ParcelDb {
76
+ constructor(options: Options): ParcelDb;
77
+ serialize(): SerializedParcelDb;
78
+ static create(options: Options): ParcelDb;
79
+ static read(filename: string, options: Options): ParcelDb;
80
+ static fromBuffer(buf: Buffer, options: Options): ParcelDb;
81
+ static deserialize(value: SerializedParcelDb): ParcelDb;
82
+ write(filename: string): void;
83
+ toBuffer(): Buffer;
84
+ getPage(page: number): Buffer;
85
+ alloc(typeId: number): number;
86
+ dealloc(typeId: number, addr: number): void;
87
+ readString(addr: number): string;
88
+ getStringId(s: string): number;
89
+ extendVec(typeId: number, addr: number, count: number): void;
90
+ createEnvironment(addr: EnvironmentAddr): EnvironmentAddr;
91
+ createTarget(addr: TargetAddr): TargetAddr;
92
+
93
+ starSymbol: number;
94
+ defaultSymbol: number;
95
+ [symbol]: any;
96
+ }
63
97
  export interface ResolverOptions {
64
98
  fs?: JsFileSystemOptions;
65
99
  includeNodeModules?: boolean | Array<string> | {|[string]: boolean|};
package/lib/index.js ADDED
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _index = require("../index");
7
+ Object.keys(_index).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _index[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _index[key];
14
+ }
15
+ });
16
+ });
17
+ var _db = require("./db");
18
+ Object.keys(_db).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _db[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _db[key];
25
+ }
26
+ });
27
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcel/rust",
3
- "version": "2.12.1-dev.3151+70889ca07",
3
+ "version": "2.12.1-dev.3238+7f6b4dbbc",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -13,8 +13,9 @@
13
13
  "type": "git",
14
14
  "url": "https://github.com/parcel-bundler/parcel.git"
15
15
  },
16
- "main": "index.js",
16
+ "main": "lib/index.js",
17
17
  "browser": "browser.js",
18
+ "source": "src/index.js",
18
19
  "napi": {
19
20
  "name": "parcel-node-bindings"
20
21
  },
@@ -34,10 +35,11 @@
34
35
  "napi-wasm": "^1.0.1"
35
36
  },
36
37
  "scripts": {
37
- "build": "napi build --platform --cargo-cwd ../../../crates/node-bindings",
38
- "build-release": "napi build --platform --release --cargo-cwd ../../../crates/node-bindings",
38
+ "build": "napi build --platform --cargo-cwd ../../../crates/node-bindings && yarn build-db",
39
+ "build-release": "napi build --platform --release --cargo-cwd ../../../crates/node-bindings && yarn build-db",
40
+ "build-db": "cargo run -p parcel-db && prettier --write src/db.js",
39
41
  "wasm:build": "cargo build -p parcel-node-bindings --target wasm32-unknown-unknown && cp ../../../target/wasm32-unknown-unknown/debug/parcel_node_bindings.wasm .",
40
42
  "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"
41
43
  },
42
- "gitHead": "70889ca07dccb95e21e4c6a2844d632e3723faf4"
44
+ "gitHead": "7f6b4dbbc56a203e0fce8794856c03598c4f6708"
43
45
  }