@atlaspack/utils 2.14.5-canary.137 → 2.14.5-canary.139
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/CHANGELOG.md +7 -0
- package/lib/DefaultMap.d.ts +13 -0
- package/lib/DefaultMap.js +0 -4
- package/lib/Deferred.d.ts +8 -0
- package/lib/PromiseQueue.d.ts +25 -0
- package/lib/TapStream.d.ts +6 -0
- package/lib/alternatives.d.ts +3 -0
- package/lib/ansi-html.d.ts +1 -0
- package/lib/ansi-html.js +2 -0
- package/lib/blob.d.ts +4 -0
- package/lib/bundle-url.d.ts +4 -0
- package/lib/collection.d.ts +33 -0
- package/lib/config.d.ts +17 -0
- package/lib/config.js +3 -1
- package/lib/countLines.d.ts +1 -0
- package/lib/debounce.d.ts +1 -0
- package/lib/debug-tools.d.ts +6 -0
- package/lib/debug-tools.js +1 -0
- package/lib/dependency-location.d.ts +14 -0
- package/lib/escape-html.d.ts +1 -0
- package/lib/generateBuildMetrics.d.ts +18 -0
- package/lib/generateCertificate.d.ts +5 -0
- package/lib/getCertificate.d.ts +6 -0
- package/lib/getExisting.d.ts +8 -0
- package/lib/getModuleParts.d.ts +4 -0
- package/lib/getRootDir.d.ts +2 -0
- package/lib/glob.d.ts +10 -0
- package/lib/glob.js +12 -4
- package/lib/hash.d.ts +7 -0
- package/lib/http-server.d.ts +19 -0
- package/lib/index.d.ts +48 -0
- package/lib/index.js +164 -9
- package/lib/is-url.d.ts +1 -0
- package/lib/is-url.js +2 -0
- package/lib/isDirectoryInside.d.ts +2 -0
- package/lib/objectHash.d.ts +3 -0
- package/lib/objectHash.js +0 -1
- package/lib/openInBrowser.d.ts +1 -0
- package/lib/parseCSSImport.d.ts +1 -0
- package/lib/path.d.ts +8 -0
- package/lib/prettifyTime.d.ts +1 -0
- package/lib/prettyDiagnostic.d.ts +17 -0
- package/lib/prettyDiagnostic.js +3 -5
- package/lib/progress-message.d.ts +3 -0
- package/lib/relativeBundlePath.d.ts +4 -0
- package/lib/relativeUrl.d.ts +1 -0
- package/lib/replaceBundleReferences.d.ts +39 -0
- package/lib/schema.d.ts +107 -0
- package/lib/schema.js +38 -19
- package/lib/shared-buffer.d.ts +2 -0
- package/lib/shared-buffer.js +5 -1
- package/lib/sourcemap.d.ts +16 -0
- package/lib/stream.d.ts +8 -0
- package/lib/throttle.d.ts +1 -0
- package/lib/urlJoin.d.ts +5 -0
- package/lib/urlJoin.js +1 -1
- package/package.json +17 -11
- package/src/{DefaultMap.js → DefaultMap.ts} +8 -12
- package/src/Deferred.ts +26 -0
- package/src/{PromiseQueue.js → PromiseQueue.ts} +40 -35
- package/src/{TapStream.js → TapStream.ts} +8 -7
- package/src/{alternatives.js → alternatives.ts} +14 -15
- package/src/{ansi-html.js → ansi-html.ts} +1 -1
- package/src/{blob.js → blob.ts} +2 -4
- package/src/{bundle-url.js → bundle-url.ts} +3 -5
- package/src/{collection.js → collection.ts} +14 -21
- package/src/{config.js → config.ts} +18 -19
- package/src/{countLines.js → countLines.ts} +0 -2
- package/src/{debounce.js → debounce.ts} +3 -5
- package/src/{debug-tools.js → debug-tools.ts} +6 -8
- package/src/{dependency-location.js → dependency-location.ts} +15 -11
- package/src/{escape-html.js → escape-html.ts} +5 -3
- package/src/{generateBuildMetrics.js → generateBuildMetrics.ts} +16 -18
- package/src/{generateCertificate.js → generateCertificate.ts} +7 -5
- package/src/{getCertificate.js → getCertificate.ts} +5 -3
- package/src/{getExisting.js → getExisting.ts} +4 -3
- package/src/{getModuleParts.js → getModuleParts.ts} +3 -2
- package/src/{getRootDir.js → getRootDir.ts} +0 -2
- package/src/{glob.js → glob.ts} +14 -10
- package/src/{hash.js → hash.ts} +22 -17
- package/src/{http-server.js → http-server.ts} +32 -38
- package/src/{index.js → index.ts} +7 -8
- package/src/{is-url.js → is-url.ts} +1 -2
- package/src/{isDirectoryInside.js → isDirectoryInside.ts} +0 -1
- package/src/{objectHash.js → objectHash.ts} +1 -4
- package/src/{openInBrowser.js → openInBrowser.ts} +2 -4
- package/src/{parseCSSImport.js → parseCSSImport.ts} +0 -2
- package/src/{path.js → path.ts} +1 -3
- package/src/{prettifyTime.js → prettifyTime.ts} +0 -2
- package/src/{prettyDiagnostic.js → prettyDiagnostic.ts} +22 -20
- package/src/{progress-message.js → progress-message.ts} +3 -2
- package/src/{relativeBundlePath.js → relativeBundlePath.ts} +3 -3
- package/src/{relativeUrl.js → relativeUrl.ts} +0 -1
- package/src/{replaceBundleReferences.js → replaceBundleReferences.ts} +54 -36
- package/src/{schema.js → schema.ts} +158 -141
- package/src/{shared-buffer.js → shared-buffer.ts} +5 -3
- package/src/{sourcemap.js → sourcemap.ts} +16 -6
- package/src/{stream.js → stream.ts} +29 -21
- package/src/throttle.ts +13 -0
- package/src/{urlJoin.js → urlJoin.ts} +1 -3
- package/test/{DefaultMap.test.js → DefaultMap.test.ts} +4 -6
- package/test/{PromiseQueue.test.js → PromiseQueue.test.ts} +5 -6
- package/test/{collection.test.js → collection.test.ts} +0 -2
- package/test/{config.test.js → config.test.ts} +0 -3
- package/test/{objectHash.test.js → objectHash.test.ts} +4 -5
- package/test/{prettifyTime.test.js → prettifyTime.test.ts} +0 -1
- package/test/{replaceBundleReferences.test.js → replaceBundleReferences.test.ts} +0 -32
- package/test/{sourcemap.test.js → sourcemap.test.ts} +0 -1
- package/test/{throttle.test.js → throttle.test.ts} +1 -3
- package/test/{urlJoin.test.js → urlJoin.test.ts} +0 -2
- package/tsconfig.json +4 -0
- package/src/Deferred.js +0 -23
- package/src/throttle.js +0 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaspack/utils
|
|
2
2
|
|
|
3
|
+
## 2.17.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`069de47`](https://github.com/atlassian-labs/atlaspack/commit/069de478e64fb5889f6f2ce023eb510782767fbd)]:
|
|
8
|
+
- @atlaspack/feature-flags@2.20.0
|
|
9
|
+
|
|
3
10
|
## 2.17.2
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class DefaultMap<K, V> extends Map<K, V> {
|
|
2
|
+
_getDefault: (arg1: K) => V;
|
|
3
|
+
constructor(getDefault: (arg1: K) => V, entries?: Iterable<[K, V]>);
|
|
4
|
+
get(key: K): V;
|
|
5
|
+
}
|
|
6
|
+
interface Key {
|
|
7
|
+
}
|
|
8
|
+
export declare class DefaultWeakMap<K extends Key, V> extends WeakMap<K, V> {
|
|
9
|
+
_getDefault: (arg1: K) => V;
|
|
10
|
+
constructor(getDefault: (arg1: K) => V, entries?: Iterable<[K, V]>);
|
|
11
|
+
get(key: K): V;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
package/lib/DefaultMap.js
CHANGED
|
@@ -17,8 +17,6 @@ class DefaultMap extends Map {
|
|
|
17
17
|
ret = this._getDefault(key);
|
|
18
18
|
this.set(key, ret);
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
// $FlowFixMe
|
|
22
20
|
return ret;
|
|
23
21
|
}
|
|
24
22
|
}
|
|
@@ -38,8 +36,6 @@ class DefaultWeakMap extends WeakMap {
|
|
|
38
36
|
ret = this._getDefault(key);
|
|
39
37
|
this.set(key, ret);
|
|
40
38
|
}
|
|
41
|
-
|
|
42
|
-
// $FlowFixMe
|
|
43
39
|
return ret;
|
|
44
40
|
}
|
|
45
41
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type Deferred } from './Deferred';
|
|
2
|
+
type PromiseQueueOpts = {
|
|
3
|
+
maxConcurrent: number;
|
|
4
|
+
};
|
|
5
|
+
export default class PromiseQueue<T> {
|
|
6
|
+
_deferred: Deferred<Array<T>> | null | undefined;
|
|
7
|
+
_maxConcurrent: number;
|
|
8
|
+
_numRunning: number;
|
|
9
|
+
_queue: Array<() => Promise<void>>;
|
|
10
|
+
_runPromise: Promise<Array<T>> | null | undefined;
|
|
11
|
+
_error: unknown;
|
|
12
|
+
_count: number;
|
|
13
|
+
_results: Array<T>;
|
|
14
|
+
_addSubscriptions: Set<() => void>;
|
|
15
|
+
constructor(opts?: PromiseQueueOpts);
|
|
16
|
+
getNumWaiting(): number;
|
|
17
|
+
add(fn: () => Promise<T>): void;
|
|
18
|
+
subscribeToAdd(fn: () => void): () => void;
|
|
19
|
+
run(): Promise<Array<T>>;
|
|
20
|
+
_next(): Promise<void>;
|
|
21
|
+
_runFn(fn: () => unknown): Promise<void>;
|
|
22
|
+
_resetState(): void;
|
|
23
|
+
_done(): void;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Transform } from 'stream';
|
|
2
|
+
export default class TapStream extends Transform {
|
|
3
|
+
_tap: (arg1: Buffer) => unknown;
|
|
4
|
+
constructor(tap: (arg1: Buffer) => unknown, options: unknown);
|
|
5
|
+
_transform(chunk: Buffer | string, encoding: string, callback: (err?: Error | null | undefined, chunk?: Buffer | string) => unknown): void;
|
|
6
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { FileSystem } from '@atlaspack/types';
|
|
2
|
+
export declare function findAlternativeNodeModules(fs: FileSystem, moduleName: string, dir: string): Promise<Array<string>>;
|
|
3
|
+
export declare function findAlternativeFiles(fs: FileSystem, fileSpecifier: string, dir: string, projectRoot: string, leadingDotSlash?: boolean, includeDirectories?: boolean, includeExtension?: boolean): Promise<Array<string>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ansiHtml(ansi: string): string;
|
package/lib/ansi-html.js
CHANGED
|
@@ -13,6 +13,8 @@ function _ansiHtmlCommunity() {
|
|
|
13
13
|
}
|
|
14
14
|
var _escapeHtml = require("./escape-html");
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
// @ts-expect-error ansi-html-community is not typed
|
|
17
|
+
|
|
16
18
|
function ansiHtml(ansi) {
|
|
17
19
|
return (0, _ansiHtmlCommunity().default)((0, _escapeHtml.escapeHTML)(ansi));
|
|
18
20
|
}
|
package/lib/blob.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare function unique<T>(array: Array<T>): Array<T>;
|
|
2
|
+
export declare function objectSortedEntries(obj: {
|
|
3
|
+
readonly [key: string]: unknown;
|
|
4
|
+
}): Array<[string, unknown]>;
|
|
5
|
+
export declare function objectSortedEntriesDeep(object: {
|
|
6
|
+
readonly [key: string]: unknown;
|
|
7
|
+
}): Array<[string, unknown]>;
|
|
8
|
+
/**
|
|
9
|
+
* Get the difference of A and B sets
|
|
10
|
+
*
|
|
11
|
+
* This is the set of elements which are in A but not in B
|
|
12
|
+
* For example, the difference of the sets {1,2,3} and {3,4} is {1,2}
|
|
13
|
+
*
|
|
14
|
+
* @param {*} a Set A
|
|
15
|
+
* @param {*} b Set B
|
|
16
|
+
* @returns A \ B
|
|
17
|
+
*/
|
|
18
|
+
export declare function setDifference<T>(a: ReadonlySet<T>, b: ReadonlySet<T>): Set<T>;
|
|
19
|
+
/**
|
|
20
|
+
* Get the symmetric difference of A and B sets
|
|
21
|
+
*
|
|
22
|
+
* This is the set of elements which are in either of the sets, but not in their intersection.
|
|
23
|
+
* For example, the symmetric difference of the sets {1,2,3} and {3,4} is {1,2,4}
|
|
24
|
+
*
|
|
25
|
+
* @param {*} a Set A
|
|
26
|
+
* @param {*} b Set B
|
|
27
|
+
* @returns A Δ B
|
|
28
|
+
*/
|
|
29
|
+
export declare function setSymmetricDifference<T>(a: ReadonlySet<T>, b: ReadonlySet<T>): Set<T>;
|
|
30
|
+
export declare function setIntersect<T>(a: Set<T>, b: ReadonlySet<T>): void;
|
|
31
|
+
export declare function setIntersectStatic<T>(a: Set<T>, b: Set<T>): Set<T>;
|
|
32
|
+
export declare function setUnion<T>(a: Iterable<T>, b: Iterable<T>): Set<T>;
|
|
33
|
+
export declare function setEqual<T>(a: ReadonlySet<T>, b: ReadonlySet<T>): boolean;
|
package/lib/config.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ConfigResult, File, FilePath } from '@atlaspack/types';
|
|
2
|
+
import type { FileSystem } from '@atlaspack/fs';
|
|
3
|
+
export type ConfigOutput = {
|
|
4
|
+
config: ConfigResult;
|
|
5
|
+
files: Array<File>;
|
|
6
|
+
};
|
|
7
|
+
export type ConfigOptions = {
|
|
8
|
+
parse?: boolean;
|
|
9
|
+
parser?: (arg1: string) => any;
|
|
10
|
+
};
|
|
11
|
+
export declare function resolveConfig(fs: FileSystem, filepath: FilePath, filenames: Array<FilePath>, projectRoot: FilePath): Promise<FilePath | null | undefined>;
|
|
12
|
+
export declare function resolveConfigSync(fs: FileSystem, filepath: FilePath, filenames: Array<FilePath>, projectRoot: FilePath): FilePath | null | undefined;
|
|
13
|
+
export declare function loadConfig(fs: FileSystem, filepath: FilePath, filenames: Array<FilePath>, projectRoot: FilePath, opts?: ConfigOptions | null): Promise<ConfigOutput | null>;
|
|
14
|
+
export declare namespace loadConfig {
|
|
15
|
+
var clear: () => void;
|
|
16
|
+
}
|
|
17
|
+
export declare function readConfig(fs: FileSystem, configFile: FilePath, opts?: ConfigOptions | null): Promise<ConfigOutput | null>;
|
package/lib/config.js
CHANGED
|
@@ -50,6 +50,9 @@ function _lruCache() {
|
|
|
50
50
|
return data;
|
|
51
51
|
}
|
|
52
52
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
53
|
+
// @ts-expect-error TS7016
|
|
54
|
+
|
|
55
|
+
// @ts-expect-error TS2351
|
|
53
56
|
const configCache = new (_lruCache().default)({
|
|
54
57
|
max: 500
|
|
55
58
|
});
|
|
@@ -81,7 +84,6 @@ async function loadConfig(fs, filepath, filenames, projectRoot, opts) {
|
|
|
81
84
|
let extname = _path().default.extname(configFile).slice(1);
|
|
82
85
|
if (extname === 'js' || extname === 'cjs') {
|
|
83
86
|
let output = {
|
|
84
|
-
// $FlowFixMe
|
|
85
87
|
config: (0, _clone().default)(module.require(configFile)),
|
|
86
88
|
files: [{
|
|
87
89
|
filePath: configFile
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function countLines(string: string, startIndex?: number): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function debounce<TArgs extends Array<unknown>>(fn: (...args: TArgs) => unknown, delay: number): (...args: TArgs) => void;
|
package/lib/debug-tools.js
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default function createDependencyLocation(start: {
|
|
2
|
+
line: number;
|
|
3
|
+
column: number;
|
|
4
|
+
}, specifier: string, lineOffset?: number, columnOffset?: number, importWrapperLength?: number): {
|
|
5
|
+
end: {
|
|
6
|
+
column: number;
|
|
7
|
+
line: number;
|
|
8
|
+
};
|
|
9
|
+
filePath: string;
|
|
10
|
+
start: {
|
|
11
|
+
column: number;
|
|
12
|
+
line: number;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function escapeHTML(s: string): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { FilePath, PackagedBundle } from '@atlaspack/types';
|
|
2
|
+
import type { FileSystem } from '@atlaspack/fs';
|
|
3
|
+
export type AssetStats = {
|
|
4
|
+
filePath: string;
|
|
5
|
+
size: number;
|
|
6
|
+
originalSize: number;
|
|
7
|
+
time: number;
|
|
8
|
+
};
|
|
9
|
+
export type BundleStats = {
|
|
10
|
+
filePath: string;
|
|
11
|
+
size: number;
|
|
12
|
+
time: number;
|
|
13
|
+
assets: Array<AssetStats>;
|
|
14
|
+
};
|
|
15
|
+
export type BuildMetrics = {
|
|
16
|
+
bundles: Array<BundleStats>;
|
|
17
|
+
};
|
|
18
|
+
export default function generateBuildMetrics(bundles: Array<PackagedBundle>, fs: FileSystem, projectRoot: FilePath): Promise<BuildMetrics>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates an object that contains both source and minified (using the source as a fallback).
|
|
3
|
+
* e.g. builtins.min.js and builtins.js.
|
|
4
|
+
*/
|
|
5
|
+
export default function getExisting(minifiedPath: string, sourcePath: string): {
|
|
6
|
+
minified: string;
|
|
7
|
+
source: string;
|
|
8
|
+
};
|
package/lib/glob.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FilePath, Glob } from '@atlaspack/types';
|
|
2
|
+
import type { FileSystem } from '@atlaspack/fs';
|
|
3
|
+
import { FastGlobOptions } from 'fast-glob';
|
|
4
|
+
import { type Options } from 'micromatch';
|
|
5
|
+
export declare function isGlob(p: FilePath): any;
|
|
6
|
+
export declare function isGlobMatch(filePath: FilePath, glob: Glob | Array<Glob>, opts?: Options): any;
|
|
7
|
+
export declare function globMatch(values: Array<string>, glob: Glob | Array<Glob>, opts?: Options): Array<string>;
|
|
8
|
+
export declare function globToRegex(glob: Glob, opts?: Options): RegExp;
|
|
9
|
+
export declare function globSync(p: FilePath, fs: FileSystem, options?: FastGlobOptions<FilePath>): Array<FilePath>;
|
|
10
|
+
export declare function glob(p: FilePath, fs: FileSystem, options: FastGlobOptions<FilePath>): Promise<Array<FilePath>>;
|
package/lib/glob.js
CHANGED
|
@@ -34,6 +34,10 @@ var _path = require("./path");
|
|
|
34
34
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
35
35
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
36
36
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
37
|
+
// @ts-expect-error TS7016
|
|
38
|
+
|
|
39
|
+
// @ts-expect-error TS2305
|
|
40
|
+
|
|
37
41
|
function isGlob(p) {
|
|
38
42
|
return (0, _isGlob2().default)((0, _path.normalizeSeparators)(p));
|
|
39
43
|
}
|
|
@@ -49,32 +53,34 @@ function globToRegex(glob, opts) {
|
|
|
49
53
|
return (0, _micromatch().makeRe)(glob, opts);
|
|
50
54
|
}
|
|
51
55
|
function globSync(p, fs, options) {
|
|
52
|
-
// $FlowFixMe
|
|
53
56
|
options = {
|
|
54
57
|
...options,
|
|
55
58
|
fs: {
|
|
59
|
+
// @ts-expect-error TS7006
|
|
56
60
|
statSync: p => {
|
|
57
61
|
return fs.statSync(p);
|
|
58
62
|
},
|
|
63
|
+
// @ts-expect-error TS7006
|
|
59
64
|
lstatSync: p => {
|
|
60
65
|
// Our FileSystem interface doesn't have lstat support at the moment,
|
|
61
66
|
// but this is fine for our purposes since we follow symlinks by default.
|
|
62
67
|
return fs.statSync(p);
|
|
63
68
|
},
|
|
69
|
+
// @ts-expect-error TS7006
|
|
64
70
|
readdirSync: (p, opts) => {
|
|
65
71
|
return fs.readdirSync(p, opts);
|
|
66
72
|
}
|
|
67
73
|
}
|
|
68
74
|
};
|
|
69
75
|
|
|
70
|
-
//
|
|
76
|
+
// @ts-expect-error TS2322
|
|
71
77
|
return _fastGlob().default.sync((0, _path.normalizeSeparators)(p), options);
|
|
72
78
|
}
|
|
73
79
|
function glob(p, fs, options) {
|
|
74
|
-
// $FlowFixMe
|
|
75
80
|
options = {
|
|
76
81
|
...options,
|
|
77
82
|
fs: {
|
|
83
|
+
// @ts-expect-error TS7006
|
|
78
84
|
stat: async (p, cb) => {
|
|
79
85
|
try {
|
|
80
86
|
cb(null, await fs.stat(p));
|
|
@@ -82,6 +88,7 @@ function glob(p, fs, options) {
|
|
|
82
88
|
cb(err);
|
|
83
89
|
}
|
|
84
90
|
},
|
|
91
|
+
// @ts-expect-error TS7006
|
|
85
92
|
lstat: async (p, cb) => {
|
|
86
93
|
// Our FileSystem interface doesn't have lstat support at the moment,
|
|
87
94
|
// but this is fine for our purposes since we follow symlinks by default.
|
|
@@ -91,6 +98,7 @@ function glob(p, fs, options) {
|
|
|
91
98
|
cb(err);
|
|
92
99
|
}
|
|
93
100
|
},
|
|
101
|
+
// @ts-expect-error TS7006
|
|
94
102
|
readdir: async (p, opts, cb) => {
|
|
95
103
|
if (typeof opts === 'function') {
|
|
96
104
|
cb = opts;
|
|
@@ -105,6 +113,6 @@ function glob(p, fs, options) {
|
|
|
105
113
|
}
|
|
106
114
|
};
|
|
107
115
|
|
|
108
|
-
//
|
|
116
|
+
// @ts-expect-error TS2322
|
|
109
117
|
return (0, _fastGlob().default)((0, _path.normalizeSeparators)(p), options);
|
|
110
118
|
}
|
package/lib/hash.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Readable } from 'stream';
|
|
2
|
+
import type { FileSystem } from '@atlaspack/fs';
|
|
3
|
+
export declare function hashStream(stream: Readable): Promise<string>;
|
|
4
|
+
export declare function hashObject(obj: {
|
|
5
|
+
readonly [key: string]: unknown;
|
|
6
|
+
}): string;
|
|
7
|
+
export declare function hashFile(fs: FileSystem, filePath: string): Promise<string>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Server as HTTPOnlyServer, IncomingMessage as HTTPRequest, ServerResponse as HTTPResponse } from 'http';
|
|
2
|
+
import type { Server as HTTPSServer } from 'https';
|
|
3
|
+
import type { FilePath, HTTPSOptions } from '@atlaspack/types';
|
|
4
|
+
import type { FileSystem } from '@atlaspack/fs';
|
|
5
|
+
type CreateHTTPServerOpts = {
|
|
6
|
+
listener?: (arg1: HTTPRequest, arg2: HTTPResponse) => void;
|
|
7
|
+
host?: string;
|
|
8
|
+
} & ({
|
|
9
|
+
https: HTTPSOptions | boolean | null | undefined;
|
|
10
|
+
inputFS: FileSystem;
|
|
11
|
+
outputFS: FileSystem;
|
|
12
|
+
cacheDir: FilePath;
|
|
13
|
+
} | Record<any, any>);
|
|
14
|
+
export type HTTPServer = HTTPOnlyServer | HTTPSServer;
|
|
15
|
+
export declare function createHTTPServer(options: CreateHTTPServerOpts): Promise<{
|
|
16
|
+
stop: () => Promise<void>;
|
|
17
|
+
server: HTTPServer;
|
|
18
|
+
}>;
|
|
19
|
+
export {};
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export * from './config';
|
|
2
|
+
export * from './Deferred';
|
|
3
|
+
export * from './generateBuildMetrics';
|
|
4
|
+
export * from './http-server';
|
|
5
|
+
export * from './path';
|
|
6
|
+
export * from './prettyDiagnostic';
|
|
7
|
+
export * from './schema';
|
|
8
|
+
export { default as countLines } from './countLines';
|
|
9
|
+
export { default as generateBuildMetrics } from './generateBuildMetrics';
|
|
10
|
+
export { default as generateCertificate } from './generateCertificate';
|
|
11
|
+
export { default as getCertificate } from './getCertificate';
|
|
12
|
+
export { default as getModuleParts } from './getModuleParts';
|
|
13
|
+
export { default as getRootDir } from './getRootDir';
|
|
14
|
+
export { default as isDirectoryInside } from './isDirectoryInside';
|
|
15
|
+
export { default as isURL } from './is-url';
|
|
16
|
+
export { default as objectHash } from './objectHash';
|
|
17
|
+
export { default as prettifyTime } from './prettifyTime';
|
|
18
|
+
export { default as prettyDiagnostic } from './prettyDiagnostic';
|
|
19
|
+
export { default as PromiseQueue } from './PromiseQueue';
|
|
20
|
+
export { default as validateSchema } from './schema';
|
|
21
|
+
export { default as TapStream } from './TapStream';
|
|
22
|
+
export { default as urlJoin } from './urlJoin';
|
|
23
|
+
export { default as relativeUrl } from './relativeUrl';
|
|
24
|
+
export { default as createDependencyLocation } from './dependency-location';
|
|
25
|
+
export { default as debounce } from './debounce';
|
|
26
|
+
export { default as throttle } from './throttle';
|
|
27
|
+
export { default as openInBrowser } from './openInBrowser';
|
|
28
|
+
export { findAlternativeNodeModules, findAlternativeFiles } from './alternatives';
|
|
29
|
+
export { blobToBuffer, blobToString } from './blob';
|
|
30
|
+
export { unique, objectSortedEntries, objectSortedEntriesDeep, setDifference, setSymmetricDifference, setEqual, setIntersect, setIntersectStatic, setUnion, } from './collection';
|
|
31
|
+
export { resolveConfig, resolveConfigSync, loadConfig, readConfig, } from './config';
|
|
32
|
+
export { debugTools } from './debug-tools';
|
|
33
|
+
export { DefaultMap, DefaultWeakMap } from './DefaultMap';
|
|
34
|
+
export { makeDeferredWithPromise } from './Deferred';
|
|
35
|
+
export { getProgressMessage, getPackageProgressMessage, } from './progress-message';
|
|
36
|
+
export { isGlob, isGlobMatch, globMatch, globSync, glob, globToRegex, } from './glob';
|
|
37
|
+
export { hashStream, hashObject, hashFile } from './hash';
|
|
38
|
+
export { SharedBuffer } from './shared-buffer';
|
|
39
|
+
export { fuzzySearch } from './schema';
|
|
40
|
+
export { createHTTPServer } from './http-server';
|
|
41
|
+
export { normalizePath, normalizeSeparators, relativePath } from './path';
|
|
42
|
+
export { replaceURLReferences, replaceInlineReferences, } from './replaceBundleReferences';
|
|
43
|
+
export { measureStreamLength, readableFromStringOrBuffer, bufferStream, blobToStream, streamFromPromise, fallbackStream, } from './stream';
|
|
44
|
+
export { relativeBundlePath } from './relativeBundlePath';
|
|
45
|
+
export { ansiHtml } from './ansi-html';
|
|
46
|
+
export { escapeHTML } from './escape-html';
|
|
47
|
+
export { SOURCEMAP_RE, SOURCEMAP_EXTENSIONS, matchSourceMappingURL, loadSourceMapUrl, loadSourceMap, remapSourceLocation, } from './sourcemap';
|
|
48
|
+
export { default as stripAnsi } from 'strip-ansi';
|