@atlaspack/utils 2.17.3-typescript-e99c742e9.0 → 2.17.3-typescript-bc4459c37.0
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/lib/DefaultMap.d.ts +13 -0
- package/lib/DefaultMap.js +42 -0
- package/lib/Deferred.d.ts +8 -0
- package/lib/Deferred.js +30 -0
- package/lib/PromiseQueue.d.ts +25 -0
- package/lib/PromiseQueue.js +112 -0
- package/lib/TapStream.d.ts +6 -0
- package/lib/TapStream.js +34 -0
- package/lib/alternatives.d.ts +3 -0
- package/lib/alternatives.js +116 -0
- package/lib/ansi-html.d.ts +1 -0
- package/lib/ansi-html.js +20 -0
- package/lib/blob.d.ts +4 -0
- package/lib/blob.js +40 -0
- package/lib/bundle-url.d.ts +4 -0
- package/lib/bundle-url.js +34 -0
- package/lib/collection.d.ts +33 -0
- package/lib/collection.js +111 -0
- package/lib/config.d.ts +17 -0
- package/lib/config.js +174 -0
- package/lib/countLines.d.ts +1 -0
- package/lib/countLines.js +15 -0
- package/lib/debounce.d.ts +1 -0
- package/lib/debounce.js +18 -0
- package/lib/debug-tools.d.ts +6 -0
- package/lib/debug-tools.js +37 -0
- package/lib/dependency-location.d.ts +14 -0
- package/lib/dependency-location.js +21 -0
- package/lib/escape-html.d.ts +1 -0
- package/lib/escape-html.js +22 -0
- package/lib/generateBuildMetrics.d.ts +18 -0
- package/lib/generateBuildMetrics.js +121 -0
- package/lib/generateCertificate.d.ts +5 -0
- package/lib/generateCertificate.js +129 -0
- package/lib/getCertificate.d.ts +6 -0
- package/lib/getCertificate.js +18 -0
- package/lib/getExisting.d.ts +8 -0
- package/lib/getExisting.js +25 -0
- package/lib/getModuleParts.d.ts +4 -0
- package/lib/getModuleParts.js +30 -0
- package/lib/getRootDir.d.ts +2 -0
- package/lib/getRootDir.js +52 -0
- package/lib/glob.d.ts +10 -0
- package/lib/glob.js +118 -0
- package/lib/hash.d.ts +7 -0
- package/lib/hash.js +50 -0
- package/lib/http-server.d.ts +19 -0
- package/lib/http-server.js +85 -0
- package/lib/index.d.ts +48 -0
- package/lib/index.js +665 -0
- package/lib/is-url.d.ts +1 -0
- package/lib/is-url.js +24 -0
- package/lib/isDirectoryInside.d.ts +2 -0
- package/lib/isDirectoryInside.js +18 -0
- package/lib/objectHash.d.ts +3 -0
- package/lib/objectHash.js +26 -0
- package/lib/openInBrowser.d.ts +1 -0
- package/lib/openInBrowser.js +74 -0
- package/lib/parseCSSImport.d.ts +1 -0
- package/lib/parseCSSImport.js +15 -0
- package/lib/path.d.ts +8 -0
- package/lib/path.js +39 -0
- package/lib/prettifyTime.d.ts +1 -0
- package/lib/prettifyTime.js +9 -0
- package/lib/prettyDiagnostic.d.ts +17 -0
- package/lib/prettyDiagnostic.js +134 -0
- package/lib/progress-message.d.ts +3 -0
- package/lib/progress-message.js +36 -0
- package/lib/relativeBundlePath.d.ts +4 -0
- package/lib/relativeBundlePath.js +22 -0
- package/lib/relativeUrl.d.ts +1 -0
- package/lib/relativeUrl.js +24 -0
- package/lib/replaceBundleReferences.d.ts +39 -0
- package/lib/replaceBundleReferences.js +199 -0
- package/lib/schema.d.ts +107 -0
- package/lib/schema.js +355 -0
- package/lib/shared-buffer.d.ts +2 -0
- package/lib/shared-buffer.js +31 -0
- package/lib/sourcemap.d.ts +16 -0
- package/lib/sourcemap.js +127 -0
- package/lib/stream.d.ts +8 -0
- package/lib/stream.js +76 -0
- package/lib/throttle.d.ts +1 -0
- package/lib/throttle.js +15 -0
- package/lib/urlJoin.d.ts +5 -0
- package/lib/urlJoin.js +35 -0
- package/package.json +9 -9
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = getModuleParts;
|
|
7
|
+
function _path() {
|
|
8
|
+
const data = _interopRequireDefault(require("path"));
|
|
9
|
+
_path = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
var _path2 = require("./path");
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
/**
|
|
17
|
+
* Returns the package name and the optional subpath
|
|
18
|
+
*/
|
|
19
|
+
function getModuleParts(_name) {
|
|
20
|
+
let name = _path().default.normalize(_name);
|
|
21
|
+
let splitOn = name.indexOf(_path().default.sep);
|
|
22
|
+
if (name.charAt(0) === '@') {
|
|
23
|
+
splitOn = name.indexOf(_path().default.sep, splitOn + 1);
|
|
24
|
+
}
|
|
25
|
+
if (splitOn < 0) {
|
|
26
|
+
return [(0, _path2.normalizeSeparators)(name), undefined];
|
|
27
|
+
} else {
|
|
28
|
+
return [(0, _path2.normalizeSeparators)(name.substring(0, splitOn)), name.substring(splitOn + 1) || undefined];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = getRootDir;
|
|
7
|
+
var _glob = require("./glob");
|
|
8
|
+
function _path() {
|
|
9
|
+
const data = _interopRequireDefault(require("path"));
|
|
10
|
+
_path = function () {
|
|
11
|
+
return data;
|
|
12
|
+
};
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
function getRootDir(files) {
|
|
17
|
+
let cur = null;
|
|
18
|
+
for (let file of files) {
|
|
19
|
+
let parsed = _path().default.parse(file);
|
|
20
|
+
parsed.dir = findGlobRoot(parsed.dir);
|
|
21
|
+
if (!cur) {
|
|
22
|
+
cur = parsed;
|
|
23
|
+
} else if (parsed.root !== cur.root) {
|
|
24
|
+
// bail out. there is no common root.
|
|
25
|
+
// this can happen on windows, e.g. C:\foo\bar vs. D:\foo\bar
|
|
26
|
+
return process.cwd();
|
|
27
|
+
} else {
|
|
28
|
+
// find the common path parts.
|
|
29
|
+
let curParts = cur.dir.split(_path().default.sep);
|
|
30
|
+
let newParts = parsed.dir.split(_path().default.sep);
|
|
31
|
+
let len = Math.min(curParts.length, newParts.length);
|
|
32
|
+
let i = 0;
|
|
33
|
+
while (i < len && curParts[i] === newParts[i]) {
|
|
34
|
+
i++;
|
|
35
|
+
}
|
|
36
|
+
cur.dir = i > 1 ? curParts.slice(0, i).join(_path().default.sep) : cur.root;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return cur ? cur.dir : process.cwd();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Transforms a path like `packages/*/src/index.js` to the root of the glob, `packages/`
|
|
43
|
+
function findGlobRoot(dir) {
|
|
44
|
+
let parts = dir.split(_path().default.sep);
|
|
45
|
+
let last = parts.length;
|
|
46
|
+
for (let i = parts.length - 1; i >= 0; i--) {
|
|
47
|
+
if ((0, _glob.isGlob)(parts[i])) {
|
|
48
|
+
last = i;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return parts.slice(0, last).join(_path().default.sep);
|
|
52
|
+
}
|
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
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.glob = glob;
|
|
7
|
+
exports.globMatch = globMatch;
|
|
8
|
+
exports.globSync = globSync;
|
|
9
|
+
exports.globToRegex = globToRegex;
|
|
10
|
+
exports.isGlob = isGlob;
|
|
11
|
+
exports.isGlobMatch = isGlobMatch;
|
|
12
|
+
function _isGlob2() {
|
|
13
|
+
const data = _interopRequireDefault(require("is-glob"));
|
|
14
|
+
_isGlob2 = function () {
|
|
15
|
+
return data;
|
|
16
|
+
};
|
|
17
|
+
return data;
|
|
18
|
+
}
|
|
19
|
+
function _fastGlob() {
|
|
20
|
+
const data = _interopRequireDefault(require("fast-glob"));
|
|
21
|
+
_fastGlob = function () {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
return data;
|
|
25
|
+
}
|
|
26
|
+
function _micromatch() {
|
|
27
|
+
const data = _interopRequireWildcard(require("micromatch"));
|
|
28
|
+
_micromatch = function () {
|
|
29
|
+
return data;
|
|
30
|
+
};
|
|
31
|
+
return data;
|
|
32
|
+
}
|
|
33
|
+
var _path = require("./path");
|
|
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
|
+
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
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
37
|
+
// @ts-expect-error TS7016
|
|
38
|
+
|
|
39
|
+
// @ts-expect-error TS2305
|
|
40
|
+
|
|
41
|
+
function isGlob(p) {
|
|
42
|
+
return (0, _isGlob2().default)((0, _path.normalizeSeparators)(p));
|
|
43
|
+
}
|
|
44
|
+
function isGlobMatch(filePath, glob, opts) {
|
|
45
|
+
glob = Array.isArray(glob) ? glob.map(_path.normalizeSeparators) : (0, _path.normalizeSeparators)(glob);
|
|
46
|
+
return (0, _micromatch().isMatch)(filePath, glob, opts);
|
|
47
|
+
}
|
|
48
|
+
function globMatch(values, glob, opts) {
|
|
49
|
+
glob = Array.isArray(glob) ? glob.map(_path.normalizeSeparators) : (0, _path.normalizeSeparators)(glob);
|
|
50
|
+
return (0, _micromatch().default)(values, glob, opts);
|
|
51
|
+
}
|
|
52
|
+
function globToRegex(glob, opts) {
|
|
53
|
+
return (0, _micromatch().makeRe)(glob, opts);
|
|
54
|
+
}
|
|
55
|
+
function globSync(p, fs, options) {
|
|
56
|
+
options = {
|
|
57
|
+
...options,
|
|
58
|
+
fs: {
|
|
59
|
+
// @ts-expect-error TS7006
|
|
60
|
+
statSync: p => {
|
|
61
|
+
return fs.statSync(p);
|
|
62
|
+
},
|
|
63
|
+
// @ts-expect-error TS7006
|
|
64
|
+
lstatSync: p => {
|
|
65
|
+
// Our FileSystem interface doesn't have lstat support at the moment,
|
|
66
|
+
// but this is fine for our purposes since we follow symlinks by default.
|
|
67
|
+
return fs.statSync(p);
|
|
68
|
+
},
|
|
69
|
+
// @ts-expect-error TS7006
|
|
70
|
+
readdirSync: (p, opts) => {
|
|
71
|
+
return fs.readdirSync(p, opts);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// @ts-expect-error TS2322
|
|
77
|
+
return _fastGlob().default.sync((0, _path.normalizeSeparators)(p), options);
|
|
78
|
+
}
|
|
79
|
+
function glob(p, fs, options) {
|
|
80
|
+
options = {
|
|
81
|
+
...options,
|
|
82
|
+
fs: {
|
|
83
|
+
// @ts-expect-error TS7006
|
|
84
|
+
stat: async (p, cb) => {
|
|
85
|
+
try {
|
|
86
|
+
cb(null, await fs.stat(p));
|
|
87
|
+
} catch (err) {
|
|
88
|
+
cb(err);
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
// @ts-expect-error TS7006
|
|
92
|
+
lstat: async (p, cb) => {
|
|
93
|
+
// Our FileSystem interface doesn't have lstat support at the moment,
|
|
94
|
+
// but this is fine for our purposes since we follow symlinks by default.
|
|
95
|
+
try {
|
|
96
|
+
cb(null, await fs.stat(p));
|
|
97
|
+
} catch (err) {
|
|
98
|
+
cb(err);
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
// @ts-expect-error TS7006
|
|
102
|
+
readdir: async (p, opts, cb) => {
|
|
103
|
+
if (typeof opts === 'function') {
|
|
104
|
+
cb = opts;
|
|
105
|
+
opts = null;
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
cb(null, await fs.readdir(p, opts));
|
|
109
|
+
} catch (err) {
|
|
110
|
+
cb(err);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// @ts-expect-error TS2322
|
|
117
|
+
return (0, _fastGlob().default)((0, _path.normalizeSeparators)(p), options);
|
|
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>;
|
package/lib/hash.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.hashFile = hashFile;
|
|
7
|
+
exports.hashObject = hashObject;
|
|
8
|
+
exports.hashStream = hashStream;
|
|
9
|
+
var _collection = require("./collection");
|
|
10
|
+
function _rust() {
|
|
11
|
+
const data = require("@atlaspack/rust");
|
|
12
|
+
_rust = function () {
|
|
13
|
+
return data;
|
|
14
|
+
};
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
function hashStream(stream) {
|
|
18
|
+
let hash = new (_rust().Hash)();
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
stream.on('error', err => {
|
|
21
|
+
reject(err);
|
|
22
|
+
});
|
|
23
|
+
stream.on('data', chunk => {
|
|
24
|
+
hash.writeBuffer(chunk);
|
|
25
|
+
}).on('end', function () {
|
|
26
|
+
resolve(hash.finish());
|
|
27
|
+
}).on('error', err => {
|
|
28
|
+
reject(err);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function hashObject(obj) {
|
|
33
|
+
return (0, _rust().hashString)(JSON.stringify((0, _collection.objectSortedEntriesDeep)(obj)));
|
|
34
|
+
}
|
|
35
|
+
let testCache = {
|
|
36
|
+
/*:: ...null */
|
|
37
|
+
};
|
|
38
|
+
function hashFile(fs, filePath) {
|
|
39
|
+
if (process.env.ATLASPACK_BUILD_ENV === 'test') {
|
|
40
|
+
// Development builds of these native modules are especially big and slow to hash.
|
|
41
|
+
if (/parcel-swc\.[^\\/]+\.node$|lightningcss.[^\\/]+.node$/.test(filePath)) {
|
|
42
|
+
let cacheEntry = testCache[filePath];
|
|
43
|
+
if (cacheEntry) return cacheEntry;
|
|
44
|
+
let v = hashStream(fs.createReadStream(filePath));
|
|
45
|
+
testCache[filePath] = v;
|
|
46
|
+
return v;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return hashStream(fs.createReadStream(filePath));
|
|
50
|
+
}
|
|
@@ -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 {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createHTTPServer = createHTTPServer;
|
|
7
|
+
function _http() {
|
|
8
|
+
const data = _interopRequireDefault(require("http"));
|
|
9
|
+
_http = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _https() {
|
|
15
|
+
const data = _interopRequireDefault(require("https"));
|
|
16
|
+
_https = function () {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _nullthrows() {
|
|
22
|
+
const data = _interopRequireDefault(require("nullthrows"));
|
|
23
|
+
_nullthrows = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
var _ = require("./");
|
|
29
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
30
|
+
// Creates either an http or https server with an awaitable dispose
|
|
31
|
+
// that closes any connections
|
|
32
|
+
async function createHTTPServer(options) {
|
|
33
|
+
let server;
|
|
34
|
+
if (!options.https) {
|
|
35
|
+
server = _http().default.createServer(options.listener);
|
|
36
|
+
} else if (options.https === true) {
|
|
37
|
+
let {
|
|
38
|
+
cert,
|
|
39
|
+
key
|
|
40
|
+
} = await (0, _.generateCertificate)(options.outputFS, options.cacheDir, options.host);
|
|
41
|
+
server = _https().default.createServer({
|
|
42
|
+
cert,
|
|
43
|
+
key
|
|
44
|
+
}, options.listener);
|
|
45
|
+
} else {
|
|
46
|
+
let {
|
|
47
|
+
cert,
|
|
48
|
+
key
|
|
49
|
+
} = await (0, _.getCertificate)(options.inputFS, options.https);
|
|
50
|
+
server = _https().default.createServer({
|
|
51
|
+
cert,
|
|
52
|
+
key
|
|
53
|
+
}, options.listener);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// HTTPServer#close only stops accepting new connections, and does not close existing ones.
|
|
57
|
+
// Before closing, destroy any active connections through their sockets. Additionally, remove sockets when they close:
|
|
58
|
+
// https://stackoverflow.com/questions/18874689/force-close-all-connections-in-a-node-js-http-server
|
|
59
|
+
// https://stackoverflow.com/questions/14626636/how-do-i-shutdown-a-node-js-https-server-immediately/14636625#14636625
|
|
60
|
+
let sockets = new Set();
|
|
61
|
+
server.on('connection', socket => {
|
|
62
|
+
(0, _nullthrows().default)(sockets).add(socket);
|
|
63
|
+
socket.on('close', () => {
|
|
64
|
+
(0, _nullthrows().default)(sockets).delete(socket);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
return {
|
|
68
|
+
server,
|
|
69
|
+
stop() {
|
|
70
|
+
return new Promise((resolve, reject) => {
|
|
71
|
+
for (let socket of (0, _nullthrows().default)(sockets)) {
|
|
72
|
+
socket.destroy();
|
|
73
|
+
}
|
|
74
|
+
sockets = new Set();
|
|
75
|
+
server.close(err => {
|
|
76
|
+
if (err != null) {
|
|
77
|
+
reject(err);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
resolve();
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
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';
|