@atlaspack/utils 2.17.3-typescript-8e1995d58.0 → 2.17.3-typescript-b27501580.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.
Files changed (46) hide show
  1. package/package.json +14 -14
  2. package/src/PromiseQueue.ts +1 -1
  3. package/src/glob.ts +1 -1
  4. package/lib/DefaultMap.js +0 -42
  5. package/lib/Deferred.js +0 -30
  6. package/lib/PromiseQueue.js +0 -112
  7. package/lib/TapStream.js +0 -34
  8. package/lib/alternatives.js +0 -116
  9. package/lib/ansi-html.js +0 -20
  10. package/lib/blob.js +0 -40
  11. package/lib/bundle-url.js +0 -34
  12. package/lib/collection.js +0 -111
  13. package/lib/config.js +0 -174
  14. package/lib/countLines.js +0 -15
  15. package/lib/debounce.js +0 -18
  16. package/lib/debug-tools.js +0 -37
  17. package/lib/dependency-location.js +0 -21
  18. package/lib/escape-html.js +0 -22
  19. package/lib/generateBuildMetrics.js +0 -121
  20. package/lib/generateCertificate.js +0 -129
  21. package/lib/getCertificate.js +0 -18
  22. package/lib/getExisting.js +0 -25
  23. package/lib/getModuleParts.js +0 -30
  24. package/lib/getRootDir.js +0 -52
  25. package/lib/glob.js +0 -118
  26. package/lib/hash.js +0 -50
  27. package/lib/http-server.js +0 -85
  28. package/lib/index.js +0 -665
  29. package/lib/is-url.js +0 -24
  30. package/lib/isDirectoryInside.js +0 -18
  31. package/lib/objectHash.js +0 -26
  32. package/lib/openInBrowser.js +0 -74
  33. package/lib/parseCSSImport.js +0 -15
  34. package/lib/path.js +0 -39
  35. package/lib/prettifyTime.js +0 -9
  36. package/lib/prettyDiagnostic.js +0 -134
  37. package/lib/progress-message.js +0 -36
  38. package/lib/relativeBundlePath.js +0 -22
  39. package/lib/relativeUrl.js +0 -24
  40. package/lib/replaceBundleReferences.js +0 -199
  41. package/lib/schema.js +0 -355
  42. package/lib/shared-buffer.js +0 -31
  43. package/lib/sourcemap.js +0 -127
  44. package/lib/stream.js +0 -76
  45. package/lib/throttle.js +0 -15
  46. package/lib/urlJoin.js +0 -35
package/lib/glob.js DELETED
@@ -1,118 +0,0 @@
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.js DELETED
@@ -1,50 +0,0 @@
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
- }
@@ -1,85 +0,0 @@
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
- }