@atlaspack/rust 3.2.1-canary.30 → 3.2.1-canary.300

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
@@ -46,9 +46,20 @@ export declare function atlaspackNapiBuildAssetGraph(atlaspackNapi: AtlaspackNap
46
46
  export declare function atlaspackNapiRespondToFsEvents(atlaspackNapi: AtlaspackNapi, options: object): object
47
47
  export declare function createDependencyId(params: unknown): string
48
48
  export declare function createEnvironmentId(params: unknown): string
49
+ /** Overwrite all environments with a new set of environments */
50
+ export declare function setAllEnvironments(environments: unknown): void
51
+ /** Get an array of all environments */
52
+ export declare function getAllEnvironments(): Array<unknown>
53
+ /** Get environment by ID */
54
+ export declare function getEnvironment(id: string): unknown
55
+ /** Add an environment to the global manager */
56
+ export declare function addEnvironment(environment: unknown): void
49
57
  export declare function getAvailableThreads(): number
50
58
  export declare function initializeMonitoring(): void
51
59
  export declare function closeMonitoring(): void
60
+ export declare function getNativeMemoryStats(): NativeMemoryStats | null
61
+ export declare function resetMemoryTracking(): void
62
+ export declare function sampleNativeMemory(): void
52
63
  /** Called on the worker thread to create a reference to the NodeJs worker */
53
64
  export declare function newNodejsWorker(worker: object): JsTransferable
54
65
  export interface InlineRequiresOptimizerInput {
@@ -61,7 +72,36 @@ export interface InlineRequiresOptimizerResult {
61
72
  sourceMap?: string
62
73
  }
63
74
  export declare function runInlineRequiresOptimizer(input: InlineRequiresOptimizerInput): InlineRequiresOptimizerResult
75
+ /** Runs in the rayon thread pool */
64
76
  export declare function runInlineRequiresOptimizerAsync(input: InlineRequiresOptimizerInput): object
77
+ export interface CompiledCssInJsTransformConfig {
78
+ importReact?: boolean
79
+ nonce?: string
80
+ importSources?: Array<string>
81
+ optimizeCss?: boolean
82
+ extensions?: Array<string>
83
+ addComponentName?: boolean
84
+ processXcss?: boolean
85
+ increaseSpecificity?: boolean
86
+ sortAtRules?: boolean
87
+ classHashPrefix?: string
88
+ flattenMultipleSelectors?: boolean
89
+ extract?: boolean
90
+ ssr?: boolean
91
+ }
92
+ export interface CompiledCssInJsPluginInput {
93
+ filename: string
94
+ projectRoot: string
95
+ isSource: boolean
96
+ sourceMaps: boolean
97
+ config: CompiledCssInJsTransformConfig
98
+ }
99
+ export interface CompiledCssInJsPluginResult {
100
+ code: string
101
+ map?: string
102
+ styleRules: Array<string>
103
+ }
104
+ export declare function applyCompiledCssInJsPlugin(rawCode: Buffer, input: CompiledCssInJsPluginInput): object
65
105
  export interface JsFileSystemOptions {
66
106
  canonicalize: (...args: any[]) => any
67
107
  read: (...args: any[]) => any
@@ -120,6 +160,26 @@ export declare function transform(opts: object): unknown
120
160
  export declare function transformAsync(opts: object): object
121
161
  export declare function getVcsStateSnapshot(path: string, excludePatterns: Array<string>): object
122
162
  export declare function getEventsSince(repoPath: string, vcsStateSnapshot: unknown, newRev?: string | undefined | null): object
163
+ export interface TokensPluginOptions {
164
+ tokenDataPath: string
165
+ shouldUseAutoFallback: boolean
166
+ shouldForceAutoFallback: boolean
167
+ forceAutoFallbackExemptions: Array<string>
168
+ defaultTheme: string
169
+ }
170
+ export interface TokensConfig {
171
+ filename: string
172
+ projectRoot: string
173
+ isSource: boolean
174
+ sourceMaps: boolean
175
+ tokensOptions: TokensPluginOptions
176
+ }
177
+ export interface TokensPluginResult {
178
+ code: string
179
+ map?: string
180
+ }
181
+ /** Apply the tokens transformation plugin to the given code asynchronously */
182
+ export declare function applyTokensPlugin(rawCode: Buffer, config: TokensConfig): object
123
183
  export type LMDB = Lmdb
124
184
  export class Lmdb {
125
185
  constructor(options: LmdbOptions)
@@ -136,7 +196,6 @@ export class Lmdb {
136
196
  commitReadTransaction(): void
137
197
  startWriteTransaction(): Promise<void>
138
198
  commitWriteTransaction(): Promise<void>
139
- close(): void
140
199
  /** Compact the database to the target path */
141
200
  compact(targetPath: string): void
142
201
  constructor(options: LMDBOptions)
@@ -153,7 +212,6 @@ export class Lmdb {
153
212
  commitReadTransaction(): void
154
213
  startWriteTransaction(): Promise<void>
155
214
  commitWriteTransaction(): Promise<void>
156
- close(): void
157
215
  compact(targetPath: string): void
158
216
  }
159
217
  export class Hash {
@@ -175,3 +233,30 @@ export class Resolver {
175
233
  getInvalidations(path: string): JsInvalidations
176
234
  getInvalidations(path: string): JsInvalidations
177
235
  }
236
+ export type JsSourceMap = SourceMap
237
+ export class SourceMap {
238
+ constructor(projectRoot: string, buffer?: Buffer | undefined | null)
239
+ addSource(source: string): number
240
+ getSource(sourceIndex: number): string
241
+ getSources(): Array<string>
242
+ getSourcesContent(): Array<string>
243
+ getSourceIndex(source: string): number
244
+ setSourceContentBySource(source: string, sourceContent: string): void
245
+ getSourceContentBySource(source: string): string
246
+ addName(name: string): number
247
+ getName(nameIndex: number): string
248
+ getNames(): Array<string>
249
+ getNameIndex(name: string): number
250
+ getMappings(): unknown[]
251
+ toBuffer(): Buffer
252
+ addSourceMap(sourcemapObject: SourceMap, lineOffset: number): void
253
+ addVLQMap(vlqMappings: string, sources: Array<string>, sourcesContent: Array<string>, names: Array<string>, lineOffset: number, columnOffset: number): void
254
+ toVLQ(): object
255
+ addIndexedMappings(mappings: JsTypedArray): void
256
+ offsetLines(generatedLine: number, generatedLineOffset: number): void
257
+ offsetColumns(generatedLine: number, generatedColumn: number, generatedColumnOffset: number): void
258
+ addEmptyMap(source: string, sourceContent: string, lineOffset: number): void
259
+ extends(originalSourcemap: SourceMap): void
260
+ findClosestMapping(generatedLine: number, generatedColumn: number): object | null
261
+ getProjectRoot(): string
262
+ }
Binary file
Binary file
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, atlaspackNapiCreate, atlaspackNapiBuildAssetGraph, atlaspackNapiRespondToFsEvents, createDependencyId, createEnvironmentId, getAvailableThreads, initializeMonitoring, closeMonitoring, newNodejsWorker, runInlineRequiresOptimizer, runInlineRequiresOptimizerAsync, Resolver, performStringReplacements, transform, transformAsync, getVcsStateSnapshot, getEventsSince } = nativeBinding
313
+ const { initTracingSubscriber, Lmdb, findAncestorFile, findFirstFile, findNodeModule, hashString, hashBuffer, Hash, optimizeImage, AtlaspackTracer, createAssetId, atlaspackNapiCreate, atlaspackNapiBuildAssetGraph, atlaspackNapiRespondToFsEvents, createDependencyId, createEnvironmentId, setAllEnvironments, getAllEnvironments, getEnvironment, addEnvironment, getAvailableThreads, initializeMonitoring, closeMonitoring, getNativeMemoryStats, resetMemoryTracking, sampleNativeMemory, newNodejsWorker, runInlineRequiresOptimizer, runInlineRequiresOptimizerAsync, applyCompiledCssInJsPlugin, Resolver, SourceMap, performStringReplacements, transform, transformAsync, getVcsStateSnapshot, getEventsSince, applyTokensPlugin } = nativeBinding
314
314
 
315
315
  module.exports.initTracingSubscriber = initTracingSubscriber
316
316
  module.exports.Lmdb = Lmdb
@@ -328,15 +328,25 @@ module.exports.atlaspackNapiBuildAssetGraph = atlaspackNapiBuildAssetGraph
328
328
  module.exports.atlaspackNapiRespondToFsEvents = atlaspackNapiRespondToFsEvents
329
329
  module.exports.createDependencyId = createDependencyId
330
330
  module.exports.createEnvironmentId = createEnvironmentId
331
+ module.exports.setAllEnvironments = setAllEnvironments
332
+ module.exports.getAllEnvironments = getAllEnvironments
333
+ module.exports.getEnvironment = getEnvironment
334
+ module.exports.addEnvironment = addEnvironment
331
335
  module.exports.getAvailableThreads = getAvailableThreads
332
336
  module.exports.initializeMonitoring = initializeMonitoring
333
337
  module.exports.closeMonitoring = closeMonitoring
338
+ module.exports.getNativeMemoryStats = getNativeMemoryStats
339
+ module.exports.resetMemoryTracking = resetMemoryTracking
340
+ module.exports.sampleNativeMemory = sampleNativeMemory
334
341
  module.exports.newNodejsWorker = newNodejsWorker
335
342
  module.exports.runInlineRequiresOptimizer = runInlineRequiresOptimizer
336
343
  module.exports.runInlineRequiresOptimizerAsync = runInlineRequiresOptimizerAsync
344
+ module.exports.applyCompiledCssInJsPlugin = applyCompiledCssInJsPlugin
337
345
  module.exports.Resolver = Resolver
346
+ module.exports.SourceMap = SourceMap
338
347
  module.exports.performStringReplacements = performStringReplacements
339
348
  module.exports.transform = transform
340
349
  module.exports.transformAsync = transformAsync
341
350
  module.exports.getVcsStateSnapshot = getVcsStateSnapshot
342
351
  module.exports.getEventsSince = getEventsSince
352
+ module.exports.applyTokensPlugin = applyTokensPlugin
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/rust",
3
- "version": "3.2.1-canary.30+c41daba65",
3
+ "version": "3.2.1-canary.300+2f3af9374",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -10,7 +10,7 @@
10
10
  "url": "https://github.com/atlassian-labs/atlaspack.git"
11
11
  },
12
12
  "main": "index.js",
13
- "browser": "browser.js",
13
+ "types": "./types.d.ts",
14
14
  "napi": {
15
15
  "name": "atlaspack-node-bindings",
16
16
  "permittedTargets": "*"
@@ -20,7 +20,8 @@
20
20
  },
21
21
  "files": [
22
22
  "browser.js",
23
- "index.d.ts",
23
+ "types.d.ts",
24
+ "*.d.ts",
24
25
  "index.js",
25
26
  "index.js.flow",
26
27
  "*.node",
@@ -31,8 +32,9 @@
31
32
  "napi-wasm": "^1.0.1"
32
33
  },
33
34
  "scripts": {
34
- "test": "mocha"
35
+ "test": "mocha",
36
+ "build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
35
37
  },
36
38
  "type": "commonjs",
37
- "gitHead": "c41daba6521e3d746cbea2fc3db55a8a3c006cb7"
39
+ "gitHead": "2f3af9374bcc082e6f4835f6f5a2b98e32ea45b4"
38
40
  }
package/types.d.ts ADDED
@@ -0,0 +1,340 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export type AtlaspackNapi = any;
5
+ export type JsTransferable = any;
6
+ export type NapiSideEffectsVariants = any;
7
+ export type LMDBOptions = any;
8
+ export type SpanId = any;
9
+
10
+ export interface LmdbOptions {
11
+ /** The database directory path */
12
+ path: string;
13
+ /**
14
+ * If enabled, the database writer will set the following flags:
15
+ *
16
+ * * MAP_ASYNC - "use asynchronous msync when MDB_WRITEMAP is used"
17
+ * * NO_SYNC - "don't fsync after commit"
18
+ * * NO_META_SYNC - "don't fsync metapage after commit"
19
+ *
20
+ * `MDB_WRITEMAP` is on by default.
21
+ */
22
+ asyncWrites: boolean;
23
+ /**
24
+ * The mmap size, this corresponds to [`mdb_env_set_mapsize`](http://www.lmdb.tech/doc/group__mdb.html#gaa2506ec8dab3d969b0e609cd82e619e5)
25
+ * if this isn't set it'll default to around 10MB.
26
+ */
27
+ mapSize?: number;
28
+ }
29
+ export declare function initTracingSubscriber(): void;
30
+ export interface Entry {
31
+ key: string;
32
+ value: Buffer;
33
+ }
34
+ export declare function findAncestorFile(
35
+ filenames: Array<string>,
36
+ from: string,
37
+ root: string,
38
+ ): string | null;
39
+ export declare function findFirstFile(names: Array<string>): string | null;
40
+ export declare function findNodeModule(
41
+ module: string,
42
+ from: string,
43
+ ): string | null;
44
+ export declare function hashString(s: string): string;
45
+ export declare function hashBuffer(buf: Buffer): string;
46
+ export declare function optimizeImage(kind: string, buf: Buffer): Buffer;
47
+ export declare function createAssetId(params: unknown): string;
48
+ export interface AtlaspackNapiOptions {
49
+ fs?: object;
50
+ options: object;
51
+ packageManager?: object;
52
+ threads?: number;
53
+ napiWorkerPool: object;
54
+ }
55
+ export declare function atlaspackNapiCreate(
56
+ napiOptions: AtlaspackNapiOptions,
57
+ lmdb: LMDB,
58
+ ): object;
59
+ export declare function atlaspackNapiBuildAssetGraph(
60
+ atlaspackNapi: AtlaspackNapi,
61
+ ): object;
62
+ export declare function atlaspackNapiRespondToFsEvents(
63
+ atlaspackNapi: AtlaspackNapi,
64
+ options: object,
65
+ ): object;
66
+ export declare function createDependencyId(params: unknown): string;
67
+ export declare function createEnvironmentId(params: unknown): string;
68
+ /** Overwrite all environments with a new set of environments */
69
+ export declare function setAllEnvironments(environments: unknown): void;
70
+ /** Get an array of all environments */
71
+ export declare function getAllEnvironments(): Array<unknown>;
72
+ /** Get environment by ID */
73
+ export declare function getEnvironment(id: string): unknown;
74
+ /** Add an environment to the global manager */
75
+ export declare function addEnvironment(environment: unknown): void;
76
+ export declare function getAvailableThreads(): number;
77
+ export declare function initializeMonitoring(): void;
78
+ export declare function closeMonitoring(): void;
79
+ export declare function getNativeMemoryStats(): NativeMemoryStats | null;
80
+ export declare function resetMemoryTracking(): void;
81
+ export declare function sampleNativeMemory(): void;
82
+ /** Called on the worker thread to create a reference to the NodeJs worker */
83
+ export declare function newNodejsWorker(worker: object): JsTransferable;
84
+ export interface InlineRequiresOptimizerInput {
85
+ code: string;
86
+ sourceMaps: boolean;
87
+ ignoreModuleIds: Array<string>;
88
+ }
89
+ export interface InlineRequiresOptimizerResult {
90
+ code: string;
91
+ sourceMap?: string;
92
+ }
93
+ export declare function runInlineRequiresOptimizer(
94
+ input: InlineRequiresOptimizerInput,
95
+ ): InlineRequiresOptimizerResult;
96
+ /** Runs in the rayon thread pool */
97
+ export declare function runInlineRequiresOptimizerAsync(
98
+ input: InlineRequiresOptimizerInput,
99
+ ): object;
100
+ export interface JsFileSystemOptions {
101
+ canonicalize: (...args: any[]) => any;
102
+ read: (...args: any[]) => any;
103
+ isFile: (...args: any[]) => any;
104
+ isDir: (...args: any[]) => any;
105
+ includeNodeModules?: NapiSideEffectsVariants;
106
+ }
107
+ export interface FileSystem {
108
+ fs?: JsFileSystemOptions;
109
+ includeNodeModules?: NapiSideEffectsVariants;
110
+ conditions?: number;
111
+ moduleDirResolver?: (...args: any[]) => any;
112
+ mode: number;
113
+ entries?: number;
114
+ extensions?: Array<string>;
115
+ packageExports: boolean;
116
+ typescript?: boolean;
117
+ reduceStringCreation?: boolean;
118
+ }
119
+ export interface ResolveOptions {
120
+ filename: string;
121
+ specifierType: string;
122
+ parent: string;
123
+ packageConditions?: Array<string>;
124
+ }
125
+ export interface FilePathCreateInvalidation {
126
+ filePath: string;
127
+ }
128
+ export interface FileNameCreateInvalidation {
129
+ fileName: string;
130
+ aboveFilePath: string;
131
+ }
132
+ export interface GlobCreateInvalidation {
133
+ glob: string;
134
+ }
135
+ export interface ResolveResult {
136
+ resolution: unknown;
137
+ invalidateOnFileChange: Array<string>;
138
+ invalidateOnFileCreate: Array<
139
+ | FilePathCreateInvalidation
140
+ | FileNameCreateInvalidation
141
+ | GlobCreateInvalidation
142
+ >;
143
+ query?: string;
144
+ sideEffects: boolean;
145
+ error: unknown;
146
+ moduleType: number;
147
+ }
148
+ export interface JsInvalidations {
149
+ invalidateOnFileChange: Array<string>;
150
+ invalidateOnFileCreate: Array<
151
+ | FilePathCreateInvalidation
152
+ | FileNameCreateInvalidation
153
+ | GlobCreateInvalidation
154
+ >;
155
+ invalidateOnStartup: boolean;
156
+ }
157
+ export interface Replacement {
158
+ from: string;
159
+ to: string;
160
+ }
161
+ export declare function performStringReplacements(
162
+ input: string,
163
+ replacements: Array<Replacement>,
164
+ ): string;
165
+ export declare function transform(opts: object): unknown;
166
+ export declare function transformAsync(opts: object): object;
167
+ export declare function getVcsStateSnapshot(
168
+ path: string,
169
+ excludePatterns: Array<string>,
170
+ ): object;
171
+ export declare function getEventsSince(
172
+ repoPath: string,
173
+ vcsStateSnapshot: unknown,
174
+ newRev?: string | undefined | null,
175
+ ): object;
176
+ export type LMDB = Lmdb;
177
+ export class Lmdb {
178
+ constructor(options: LmdbOptions);
179
+ get(key: string): Promise<Buffer | null | undefined>;
180
+ hasSync(key: string): boolean;
181
+ keysSync(skip: number, limit: number): Array<string>;
182
+ getSync(key: string): Buffer | null;
183
+ getManySync(keys: Array<string>): Array<Buffer | undefined | null>;
184
+ putMany(entries: Array<Entry>): Promise<void>;
185
+ put(key: string, data: Buffer): Promise<void>;
186
+ putNoConfirm(key: string, data: Buffer): void;
187
+ delete(key: string): Promise<void>;
188
+ startReadTransaction(): void;
189
+ commitReadTransaction(): void;
190
+ startWriteTransaction(): Promise<void>;
191
+ commitWriteTransaction(): Promise<void>;
192
+ /** Compact the database to the target path */
193
+ compact(targetPath: string): void;
194
+ constructor(options: LMDBOptions);
195
+ get(key: string): Promise<Buffer | null | undefined>;
196
+ hasSync(key: string): boolean;
197
+ keysSync(skip: number, limit: number): Array<string>;
198
+ getSync(key: string): Buffer | null;
199
+ getManySync(keys: Array<string>): Array<Buffer | undefined | null>;
200
+ putMany(entries: Array<Entry>): Promise<void>;
201
+ put(key: string, data: Buffer): Promise<void>;
202
+ delete(key: string): Promise<void>;
203
+ putNoConfirm(key: string, data: Buffer): void;
204
+ startReadTransaction(): void;
205
+ commitReadTransaction(): void;
206
+ startWriteTransaction(): Promise<void>;
207
+ commitWriteTransaction(): Promise<void>;
208
+ compact(targetPath: string): void;
209
+ }
210
+ export class Hash {
211
+ constructor();
212
+ writeString(s: string): void;
213
+ writeBuffer(buf: Buffer): void;
214
+ finish(): string;
215
+ }
216
+ export class AtlaspackTracer {
217
+ constructor();
218
+ enter(label: string): SpanId;
219
+ exit(id: SpanId): void;
220
+ }
221
+ export class Resolver {
222
+ constructor(projectRoot: string, options: FileSystem);
223
+ resolve(options: ResolveOptions): ResolveResult;
224
+ resolveAsync(): object;
225
+ resolveAsync(options: ResolveOptions): object;
226
+ getInvalidations(path: string): JsInvalidations;
227
+ getInvalidations(path: string): JsInvalidations;
228
+ }
229
+
230
+ export interface SourceLocation {
231
+ filePath: string;
232
+ start: {
233
+ line: number;
234
+ column: number;
235
+ line: number;
236
+ column: number;
237
+ };
238
+ end: {
239
+ line: number;
240
+ column: number;
241
+ line: number;
242
+ column: number;
243
+ };
244
+ }
245
+
246
+ export interface Symbol {
247
+ local: string;
248
+ exported: string;
249
+ loc?: SourceLocation;
250
+ isWeak: boolean;
251
+ isEsmExport: boolean;
252
+ isStaticBindingSafe: boolean;
253
+ selfReferenced: boolean;
254
+ }
255
+
256
+ export interface TokensPluginOptions {
257
+ tokenDataPath: string;
258
+ shouldUseAutoFallback: boolean;
259
+ shouldForceAutoFallback: boolean;
260
+ forceAutoFallbackExemptions: Array<string>;
261
+ defaultTheme: string;
262
+ }
263
+
264
+ export interface TokensConfig {
265
+ filename: string;
266
+ projectRoot: string;
267
+ isSource: boolean;
268
+ sourceMaps: boolean;
269
+ tokensOptions: TokensPluginOptions;
270
+ }
271
+
272
+ export interface TokensPluginResult {
273
+ code: string;
274
+ map: string | null;
275
+ }
276
+
277
+ /** Apply the tokens transformation plugin to the given code asynchronously */
278
+ export declare function applyTokensPlugin(
279
+ rawCode: Buffer,
280
+ config: TokensConfig,
281
+ ): object;
282
+
283
+ export interface DetailedMemoryStats {
284
+ min: number;
285
+ max: number;
286
+ mean: number;
287
+ median: number;
288
+ p95: number;
289
+ p99: number;
290
+ standardDeviation: number;
291
+ range: number;
292
+ }
293
+
294
+ export interface NativeMemoryStats {
295
+ physicalMem: DetailedMemoryStats;
296
+ virtualMem: DetailedMemoryStats;
297
+ sampleCount: number;
298
+ }
299
+
300
+ export type JsSourceMap = SourceMap;
301
+ export class SourceMap {
302
+ constructor(projectRoot: string, buffer?: Buffer | undefined | null);
303
+ addSource(source: string): number;
304
+ getSource(sourceIndex: number): string;
305
+ getSources(): Array<string>;
306
+ getSourcesContent(): Array<string>;
307
+ getSourceIndex(source: string): number;
308
+ setSourceContentBySource(source: string, sourceContent: string): void;
309
+ getSourceContentBySource(source: string): string;
310
+ addName(name: string): number;
311
+ getName(nameIndex: number): string;
312
+ getNames(): Array<string>;
313
+ getNameIndex(name: string): number;
314
+ getMappings(): unknown[];
315
+ toBuffer(): Buffer;
316
+ addSourceMap(sourcemapObject: SourceMap, lineOffset: number): void;
317
+ addVLQMap(
318
+ vlqMappings: string,
319
+ sources: Array<string>,
320
+ sourcesContent: Array<string>,
321
+ names: Array<string>,
322
+ lineOffset: number,
323
+ columnOffset: number,
324
+ ): void;
325
+ toVLQ(): object;
326
+ addIndexedMappings(mappings: JsTypedArray): void;
327
+ offsetLines(generatedLine: number, generatedLineOffset: number): void;
328
+ offsetColumns(
329
+ generatedLine: number,
330
+ generatedColumn: number,
331
+ generatedColumnOffset: number,
332
+ ): void;
333
+ addEmptyMap(source: string, sourceContent: string, lineOffset: number): void;
334
+ extends(originalSourcemap: SourceMap): void;
335
+ findClosestMapping(
336
+ generatedLine: number,
337
+ generatedColumn: number,
338
+ ): object | null;
339
+ getProjectRoot(): string;
340
+ }
package/index.js.flow DELETED
@@ -1,439 +0,0 @@
1
- // @flow
2
- import type {
3
- Encoding,
4
- FileCreateInvalidation,
5
- FilePath,
6
- InitialAtlaspackOptions,
7
- PackageManager,
8
- } from '@atlaspack/types';
9
-
10
- // This is defined in browser.js for wasm builds
11
- declare export var init: void | (() => void);
12
-
13
- export type WatchEventType = 'create' | 'update' | 'delete';
14
-
15
- export interface WatchEvent {
16
- path: string;
17
- type: WatchEventType;
18
- }
19
-
20
- export type WatchEvents = Array<WatchEvent>;
21
-
22
- export type Transferable = {||};
23
-
24
- export type JsCallable<Args: $ReadOnlyArray<mixed>, Return> = (
25
- ...Args
26
- ) => Return | Promise<Return>;
27
-
28
- export type ProjectPath = any;
29
- export interface ConfigRequest {
30
- id: string;
31
- invalidateOnFileChange: Array<ProjectPath>;
32
- invalidateOnConfigKeyChange: Array<any>;
33
- invalidateOnFileCreate: Array<any>;
34
- invalidateOnEnvChange: Array<string>;
35
- invalidateOnOptionChange: Array<string>;
36
- invalidateOnStartup: boolean;
37
- invalidateOnBuild: boolean;
38
- }
39
- export interface RequestOptions {}
40
-
41
- export interface FileSystem {
42
- canonicalize: JsCallable<[FilePath], FilePath>;
43
- createDirectory: JsCallable<[FilePath], Promise<void>>;
44
- cwd: JsCallable<[], FilePath>;
45
- isDir: JsCallable<[FilePath], boolean>;
46
- isFile: JsCallable<[FilePath], boolean>;
47
- readFile: JsCallable<[FilePath, Encoding], string>;
48
- }
49
-
50
- export type AtlaspackNapiOptions = {|
51
- fs?: FileSystem,
52
- nodeWorkers?: number,
53
- napiWorkerPool: any,
54
- options: {|
55
- featureFlags?: {[string]: string | boolean},
56
- corePath?: string,
57
- // TODO Use Omit when available in flow >0.210.0
58
- ...$Diff<
59
- InitialAtlaspackOptions,
60
- {|
61
- inputFS: InitialAtlaspackOptions['inputFS'],
62
- outputFS: InitialAtlaspackOptions['outputFS'],
63
- packageManager: InitialAtlaspackOptions['packageManager'],
64
- |},
65
- >,
66
- |},
67
- packageManager?: PackageManager,
68
- threads?: number,
69
- |};
70
-
71
- // AtlaspackNapi
72
- export type AtlaspackNapi = {||};
73
- declare export function atlaspackNapiCreate(
74
- options: AtlaspackNapiOptions,
75
- lmdb: mixed,
76
- ): Promise<AtlaspackNapi>;
77
- declare export function atlaspackNapiBuildAssetGraph(
78
- atlaspack: AtlaspackNapi,
79
- ): Promise<any>;
80
- declare export function atlaspackNapiRespondToFsEvents(
81
- atlaspack: AtlaspackNapi,
82
- events: WatchEvents,
83
- ): boolean;
84
- // AtlaspackNapi
85
-
86
- declare export function getAvailableThreads(): number;
87
-
88
- declare export function newNodejsWorker(delegate: any): Transferable;
89
-
90
- declare export function initializeMonitoring(): void;
91
- declare export function closeMonitoring(): void;
92
- declare export function napiRunConfigRequest(
93
- configRequest: ConfigRequest,
94
- api: any,
95
- options: any,
96
- ): void;
97
- declare export function findAncestorFile(
98
- filenames: Array<string>,
99
- from: string,
100
- root: string,
101
- ): string | null;
102
- declare export function findFirstFile(names: Array<string>): string | null;
103
- declare export function findNodeModule(
104
- module: string,
105
- from: string,
106
- ): string | null;
107
- declare export function hashString(s: string): string;
108
- declare export function hashBuffer(buf: Buffer): string;
109
- declare export function optimizeImage(kind: string, buf: Buffer): Buffer;
110
-
111
- export interface ResolveOptions {
112
- filename: string;
113
- specifierType: string;
114
- parent: string;
115
- packageConditions?: Array<string>;
116
- }
117
-
118
- export interface ResolveResult {
119
- resolution: Resolution;
120
- invalidateOnFileChange: Array<string>;
121
- invalidateOnFileCreate: Array<FileCreateInvalidation>;
122
- query?: string;
123
- sideEffects: boolean;
124
- error: mixed;
125
- moduleType: number;
126
- }
127
- export interface JsInvalidations {
128
- invalidateOnFileChange: Array<string>;
129
- invalidateOnFileCreate: Array<FileCreateInvalidation>;
130
- invalidateOnStartup: boolean;
131
- }
132
- declare export function transform(opts: any): any;
133
- declare export function transformAsync(opts: any): Promise<any>;
134
- declare export class Hash {
135
- writeString(s: string): void;
136
- writeBuffer(b: Buffer): void;
137
- finish(): string;
138
- }
139
-
140
- export type Engines = {|
141
- atlaspack?: string,
142
- browsers?: string | string[],
143
- electron?: string,
144
- node?: string,
145
- |};
146
-
147
- export type Environment = {|
148
- context: string,
149
- engines: Engines,
150
- includeNodeModules: IncludeNodeModules,
151
- isLibrary: boolean,
152
- loc?: SourceLocation,
153
- outputFormat: string,
154
- shouldScopeHoist: boolean,
155
- shouldOptimize: boolean,
156
- sourceMap?: {|
157
- inline?: boolean,
158
- inlineSources?: boolean,
159
- sourceRoot?: string,
160
- |},
161
- sourceType: string,
162
- |};
163
-
164
- export type SourceLocation = {|
165
- filePath: string,
166
- start: {|
167
- line: number,
168
- column: number,
169
- |},
170
- end: {|
171
- line: number,
172
- column: number,
173
- |},
174
- |};
175
-
176
- export type Symbol = {|
177
- local: string,
178
- exported: string,
179
- loc?: SourceLocation,
180
- isWeak: boolean,
181
- isEsmExport: boolean,
182
- selfReferenced: boolean,
183
- |};
184
-
185
- export type Target = {|
186
- distDir: string,
187
- distEntry?: string,
188
- env: Environment,
189
- loc?: SourceLocation,
190
- name: string,
191
- publicUrl: string,
192
- |};
193
-
194
- export type Dependency = {|
195
- bundleBehavior?: number,
196
- env: Environment,
197
- loc: SourceLocation,
198
- meta?: any,
199
- packageConditions: number[],
200
- pipeline?: string,
201
- priority: number,
202
- range?: string,
203
- resolveFrom?: string,
204
- sourceAssetId?: string,
205
- sourcePath?: string,
206
- specifier: string,
207
- specifierType: number,
208
- sourceAssetType?: string,
209
- symbols?: Symbol[],
210
- target?: Target,
211
- isEntry: boolean,
212
- isOptional: boolean,
213
- needsStableName: boolean,
214
- shouldWrap: boolean,
215
- isEsm: boolean,
216
- placeholder?: string,
217
- |};
218
-
219
- export type RpcAssetResult = {|
220
- id: string,
221
- bundleBehavior: ?number,
222
- filePath: string,
223
- type: string,
224
- code: Array<number>,
225
- meta: any,
226
- pipeline?: ?string,
227
- query?: string,
228
- symbols?: Symbol[],
229
- uniqueKey?: ?string,
230
- sideEffects: boolean,
231
- isBundleSplittable: boolean,
232
- isSource: boolean,
233
- |};
234
-
235
- export type RpcTransformerOpts = {|
236
- resolveFrom: string,
237
- specifier: string,
238
- options: RpcPluginOptions,
239
- asset: Asset,
240
- |};
241
-
242
- export type RpcHmrOptions = {|
243
- port?: number,
244
- host?: string,
245
- |};
246
-
247
- export type RpcPluginOptions = {|
248
- hmrOptions?: RpcHmrOptions,
249
- projectRoot: string,
250
- |};
251
-
252
- export type Asset = {|
253
- id: string,
254
- bundleBehavior: number,
255
- env: Environment,
256
- filePath: string,
257
- type: string,
258
- code: Array<number>,
259
- meta: any,
260
- pipeline?: string,
261
- query?: string,
262
- stats: {|
263
- size: number,
264
- time: number,
265
- |},
266
- symbols?: Symbol[],
267
- uniqueKey?: string,
268
- sideEffects: boolean,
269
- isBundleSplittable: boolean,
270
- isSource: boolean,
271
- hasCjsExports: boolean,
272
- staticExports: boolean,
273
- shouldWrap: boolean,
274
- hasNodeReplacements: boolean,
275
- isConstantModule: boolean,
276
- conditions: Array<{|
277
- key: string,
278
- ifTruePlaceholder?: string,
279
- ifFalsePlaceholder?: string,
280
- |}>,
281
- configPath?: string,
282
- configKeyPath?: string,
283
- |};
284
-
285
- declare export class Resolver {
286
- constructor(projectRoot: string, options: ResolverOptions): Resolver;
287
- resolve(options: ResolveOptions): ResolveResult;
288
- resolveAsync(options: ResolveOptions): Promise<ResolveResult>;
289
- getInvalidations(path: string): JsInvalidations;
290
- }
291
-
292
- export interface LmdbOptions {
293
- /** The database directory path */
294
- path: string;
295
- /**
296
- * If enabled, the database writer will set the following flags:
297
- *
298
- * * MAP_ASYNC - "use asynchronous msync when MDB_WRITEMAP is used"
299
- * * NO_SYNC - "don't fsync after commit"
300
- * * NO_META_SYNC - "don't fsync metapage after commit"
301
- *
302
- * `MDB_WRITEMAP` is on by default.
303
- */
304
- asyncWrites: boolean;
305
- /**
306
- * The mmap size, this corresponds to [`mdb_env_set_mapsize`](http://www.lmdb.tech/doc/group__mdb.html#gaa2506ec8dab3d969b0e609cd82e619e5)
307
- * if this isn't set it'll default to around 10MB.
308
- */
309
- mapSize?: number;
310
- }
311
-
312
- export interface LmdbEntry {
313
- key: string;
314
- value: Buffer;
315
- }
316
-
317
- export type StringReplacement = {|
318
- from: string,
319
- to: string,
320
- |};
321
-
322
- declare export function performStringReplacements(
323
- input: string,
324
- replacements: Array<StringReplacement>,
325
- ): string;
326
-
327
- declare export class Lmdb {
328
- constructor(options: LmdbOptions): Lmdb;
329
- get(key: string): Promise<Buffer | null | void>;
330
- keysSync(skip: number, limit: number): Array<string>;
331
- hasSync(key: string): boolean;
332
- getSync(key: string): Buffer | null;
333
- getManySync(keys: Array<string>): Array<Buffer | void | null>;
334
- putMany(entries: Array<LmdbEntry>): Promise<void>;
335
- put(key: string, data: Buffer): Promise<void>;
336
- putNoConfirm(key: string, data: Buffer): void;
337
- startReadTransaction(): void;
338
- commitReadTransaction(): void;
339
- startWriteTransaction(): Promise<void>;
340
- commitWriteTransaction(): Promise<void>;
341
- delete(key: string): Promise<void>;
342
- close(): void;
343
- compact(targetPath: string): void;
344
- }
345
-
346
- export interface InlineRequiresOptimizerInput {
347
- code: string;
348
- sourceMaps: boolean;
349
- ignoreModuleIds: Array<string>;
350
- }
351
- export interface InlineRequiresOptimizerResult {
352
- code: string;
353
- sourceMap?: string;
354
- }
355
-
356
- declare export function runInlineRequiresOptimizer(
357
- input: InlineRequiresOptimizerInput,
358
- ): InlineRequiresOptimizerResult;
359
-
360
- declare export function runInlineRequiresOptimizerAsync(
361
- input: InlineRequiresOptimizerInput,
362
- ): Promise<InlineRequiresOptimizerResult>;
363
-
364
- export interface VCSFile {
365
- path: string;
366
- hash?: string | null;
367
- }
368
-
369
- export interface YarnState {
370
- yarnLockPath: string;
371
- yarnLock: mixed;
372
- yarnState: mixed;
373
- }
374
-
375
- export interface VCSState {
376
- gitHash: string;
377
- // Files that have been modified since the last commit
378
- dirtyFiles: VCSFile[];
379
- yarnStates: YarnState[];
380
- dirtyFilesExecutionTime: number;
381
- yarnStatesExecutionTime: number;
382
- }
383
-
384
- declare export function getVcsStateSnapshot(
385
- path: string,
386
- excludePatterns: Array<string>,
387
- ): Promise<VCSState>;
388
- export interface NodeChangeEvent {
389
- path: string;
390
- changeType: 'update' | 'create' | 'delete';
391
- }
392
-
393
- declare export function getEventsSince(
394
- repoPath: string,
395
- oldRev: string,
396
- newRev?: string | void | null,
397
- ): Promise<Array<NodeChangeEvent>>;
398
-
399
- declare export function createAssetId(params: mixed): string;
400
- declare export function createDependencyId(params: mixed): string;
401
- declare export function createEnvironmentId(params: mixed): string;
402
-
403
- export interface ResolverOptions {
404
- fs?: JsFileSystemOptions;
405
- includeNodeModules?: IncludeNodeModules;
406
- conditions?: number;
407
- moduleDirResolver?: (...args: any[]) => any;
408
- mode: number;
409
- entries?: number;
410
- extensions?: Array<string>;
411
- }
412
-
413
- export interface JsFileSystemOptions {
414
- canonicalize: (string) => string;
415
- read: (string) => Buffer;
416
- isFile: (string) => boolean;
417
- isDir: (string) => boolean;
418
- includeNodeModules?: IncludeNodeModules;
419
- }
420
-
421
- // Types below break IDE highlighting, place them at the bottom of the file
422
-
423
- export type IncludeNodeModules =
424
- | boolean
425
- | Array<string>
426
- | {|[string]: boolean|};
427
-
428
- export type Resolution =
429
- | {|type: 'Path', value: string|}
430
- | {|type: 'Builtin', value: string|}
431
- | {|type: 'External'|}
432
- | {|type: 'Empty'|}
433
- | {|type: 'Global', value: string|};
434
-
435
- declare export class AtlaspackTracer {
436
- constructor(): AtlaspackTracer;
437
- enter(label: string): number;
438
- exit(id: number): void;
439
- }