@atlaspack/utils 2.17.3-typescript-b27501580.0 → 2.17.3-typescript-5b4d3ad41.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
package/lib/stream.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.blobToStream = blobToStream;
|
|
7
|
+
exports.bufferStream = bufferStream;
|
|
8
|
+
exports.fallbackStream = fallbackStream;
|
|
9
|
+
exports.measureStreamLength = measureStreamLength;
|
|
10
|
+
exports.readableFromStringOrBuffer = readableFromStringOrBuffer;
|
|
11
|
+
exports.streamFromPromise = streamFromPromise;
|
|
12
|
+
function _stream() {
|
|
13
|
+
const data = require("stream");
|
|
14
|
+
_stream = function () {
|
|
15
|
+
return data;
|
|
16
|
+
};
|
|
17
|
+
return data;
|
|
18
|
+
}
|
|
19
|
+
function measureStreamLength(stream) {
|
|
20
|
+
return new Promise((resolve, reject) => {
|
|
21
|
+
let length = 0;
|
|
22
|
+
stream.on('data', chunk => {
|
|
23
|
+
length += chunk;
|
|
24
|
+
});
|
|
25
|
+
stream.on('end', () => resolve(length));
|
|
26
|
+
stream.on('error', reject);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function readableFromStringOrBuffer(str) {
|
|
30
|
+
// https://stackoverflow.com/questions/12755997/how-to-create-streams-from-string-in-node-js
|
|
31
|
+
const stream = new (_stream().Readable)();
|
|
32
|
+
stream.push(str);
|
|
33
|
+
stream.push(null);
|
|
34
|
+
return stream;
|
|
35
|
+
}
|
|
36
|
+
function bufferStream(stream) {
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
let buf = Buffer.from([]);
|
|
39
|
+
stream.on('data', data => {
|
|
40
|
+
buf = Buffer.concat([buf, data]);
|
|
41
|
+
});
|
|
42
|
+
stream.on('end', () => {
|
|
43
|
+
resolve(buf);
|
|
44
|
+
});
|
|
45
|
+
stream.on('error', reject);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function blobToStream(blob) {
|
|
49
|
+
if (blob instanceof _stream().Readable) {
|
|
50
|
+
return blob;
|
|
51
|
+
}
|
|
52
|
+
return readableFromStringOrBuffer(blob);
|
|
53
|
+
}
|
|
54
|
+
function streamFromPromise(promise) {
|
|
55
|
+
const stream = new (_stream().PassThrough)();
|
|
56
|
+
promise.then(blob => {
|
|
57
|
+
if (blob instanceof _stream().Readable) {
|
|
58
|
+
blob.pipe(stream);
|
|
59
|
+
} else {
|
|
60
|
+
stream.end(blob);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
return stream;
|
|
64
|
+
}
|
|
65
|
+
function fallbackStream(stream, fallback) {
|
|
66
|
+
const res = new (_stream().PassThrough)();
|
|
67
|
+
stream.on('error', err => {
|
|
68
|
+
if (err.code === 'ENOENT') {
|
|
69
|
+
fallback().pipe(res);
|
|
70
|
+
} else {
|
|
71
|
+
res.emit('error', err);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
stream.pipe(res);
|
|
75
|
+
return res;
|
|
76
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function throttle<TArgs extends Array<unknown>>(fn: (...args: TArgs) => unknown, delay: number): (...args: TArgs) => void;
|
package/lib/throttle.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = throttle;
|
|
7
|
+
function throttle(fn, delay) {
|
|
8
|
+
let lastCalled;
|
|
9
|
+
return function throttled(...args) {
|
|
10
|
+
if (lastCalled == null || lastCalled + delay <= Date.now()) {
|
|
11
|
+
fn.call(this, ...args);
|
|
12
|
+
lastCalled = Date.now();
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
package/lib/urlJoin.d.ts
ADDED
package/lib/urlJoin.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = urlJoin;
|
|
7
|
+
function _url() {
|
|
8
|
+
const data = _interopRequireDefault(require("url"));
|
|
9
|
+
_url = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _path() {
|
|
15
|
+
const data = _interopRequireDefault(require("path"));
|
|
16
|
+
_path = function () {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
+
/**
|
|
23
|
+
* Joins a path onto a URL, and normalizes Windows paths
|
|
24
|
+
* e.g. from \path\to\res.js to /path/to/res.js.
|
|
25
|
+
*/
|
|
26
|
+
function urlJoin(publicURL, assetPath) {
|
|
27
|
+
const url = _url().default.parse(publicURL, false, true);
|
|
28
|
+
// Leading / ensures that paths with colons are not parsed as a protocol.
|
|
29
|
+
let p = assetPath.startsWith('/') ? assetPath : '/' + assetPath;
|
|
30
|
+
const assetUrl = _url().default.parse(p);
|
|
31
|
+
url.pathname = _path().default.posix.join(url.pathname ?? '', assetUrl.pathname ?? '');
|
|
32
|
+
url.search = assetUrl.search;
|
|
33
|
+
url.hash = assetUrl.hash;
|
|
34
|
+
return _url().default.format(url);
|
|
35
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/utils",
|
|
3
|
-
"version": "2.17.3-typescript-
|
|
3
|
+
"version": "2.17.3-typescript-5b4d3ad41.0",
|
|
4
4
|
"description": "Blazing fast, zero configuration web application bundler",
|
|
5
5
|
"license": "(MIT OR Apache-2.0)",
|
|
6
6
|
"publishConfig": {
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@atlaspack/codeframe": "2.13.5-typescript-
|
|
35
|
-
"@atlaspack/diagnostic": "2.14.2-typescript-
|
|
36
|
-
"@atlaspack/feature-flags": "2.19.3-typescript-
|
|
37
|
-
"@atlaspack/logger": "2.14.14-typescript-
|
|
38
|
-
"@atlaspack/markdown-ansi": "2.14.2-typescript-
|
|
39
|
-
"@atlaspack/rust": "3.4.2-typescript-
|
|
34
|
+
"@atlaspack/codeframe": "2.13.5-typescript-5b4d3ad41.0",
|
|
35
|
+
"@atlaspack/diagnostic": "2.14.2-typescript-5b4d3ad41.0",
|
|
36
|
+
"@atlaspack/feature-flags": "2.19.3-typescript-5b4d3ad41.0",
|
|
37
|
+
"@atlaspack/logger": "2.14.14-typescript-5b4d3ad41.0",
|
|
38
|
+
"@atlaspack/markdown-ansi": "2.14.2-typescript-5b4d3ad41.0",
|
|
39
|
+
"@atlaspack/rust": "3.4.2-typescript-5b4d3ad41.0",
|
|
40
40
|
"@iarna/toml": "^2.2.0",
|
|
41
41
|
"@parcel/source-map": "^2.1.1",
|
|
42
42
|
"@types/micromatch": "^4.0.9",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"terminal-link": "^2.1.1"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@atlaspack/babel-register": "2.14.2-typescript-
|
|
62
|
+
"@atlaspack/babel-register": "2.14.2-typescript-5b4d3ad41.0",
|
|
63
63
|
"benny": "^3.7.1",
|
|
64
64
|
"random-int": "^1.0.0"
|
|
65
65
|
},
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"scripts": {
|
|
74
74
|
"check-ts": "tsc --emitDeclarationOnly --rootDir src"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "5b4d3ad41ffa002b989ba77271bb3010a1f05b2a"
|
|
77
77
|
}
|