@atlaspack/utils 2.14.5-canary.14 → 2.14.5-canary.141

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 (147) hide show
  1. package/CHANGELOG.md +146 -0
  2. package/benchmark.js +23 -0
  3. package/lib/DefaultMap.d.ts +13 -0
  4. package/lib/DefaultMap.js +42 -0
  5. package/lib/Deferred.d.ts +8 -0
  6. package/lib/Deferred.js +30 -0
  7. package/lib/PromiseQueue.d.ts +25 -0
  8. package/lib/PromiseQueue.js +112 -0
  9. package/lib/TapStream.d.ts +6 -0
  10. package/lib/TapStream.js +34 -0
  11. package/lib/alternatives.d.ts +3 -0
  12. package/lib/alternatives.js +116 -0
  13. package/lib/ansi-html.d.ts +1 -0
  14. package/lib/ansi-html.js +20 -0
  15. package/lib/blob.d.ts +4 -0
  16. package/lib/blob.js +40 -0
  17. package/lib/bundle-url.d.ts +4 -0
  18. package/lib/bundle-url.js +34 -0
  19. package/lib/collection.d.ts +33 -0
  20. package/lib/collection.js +111 -0
  21. package/lib/config.d.ts +17 -0
  22. package/lib/config.js +174 -0
  23. package/lib/countLines.d.ts +1 -0
  24. package/lib/countLines.js +15 -0
  25. package/lib/debounce.d.ts +1 -0
  26. package/lib/debounce.js +18 -0
  27. package/lib/debug-tools.d.ts +6 -0
  28. package/lib/debug-tools.js +37 -0
  29. package/lib/dependency-location.d.ts +14 -0
  30. package/lib/dependency-location.js +21 -0
  31. package/lib/escape-html.d.ts +1 -0
  32. package/lib/escape-html.js +22 -0
  33. package/lib/generateBuildMetrics.d.ts +18 -0
  34. package/lib/generateBuildMetrics.js +121 -0
  35. package/lib/generateCertificate.d.ts +5 -0
  36. package/lib/generateCertificate.js +129 -0
  37. package/lib/getCertificate.d.ts +6 -0
  38. package/lib/getCertificate.js +18 -0
  39. package/lib/getExisting.d.ts +8 -0
  40. package/lib/getExisting.js +25 -0
  41. package/lib/getModuleParts.d.ts +4 -0
  42. package/lib/getModuleParts.js +30 -0
  43. package/lib/getRootDir.d.ts +2 -0
  44. package/lib/getRootDir.js +52 -0
  45. package/lib/glob.d.ts +10 -0
  46. package/lib/glob.js +118 -0
  47. package/lib/hash.d.ts +7 -0
  48. package/lib/hash.js +50 -0
  49. package/lib/http-server.d.ts +19 -0
  50. package/lib/http-server.js +85 -0
  51. package/lib/index.d.ts +48 -0
  52. package/lib/index.js +635 -37310
  53. package/lib/is-url.d.ts +1 -0
  54. package/lib/is-url.js +24 -0
  55. package/lib/isDirectoryInside.d.ts +2 -0
  56. package/lib/isDirectoryInside.js +18 -0
  57. package/lib/objectHash.d.ts +3 -0
  58. package/lib/objectHash.js +26 -0
  59. package/lib/openInBrowser.d.ts +1 -0
  60. package/lib/openInBrowser.js +74 -0
  61. package/lib/parseCSSImport.d.ts +1 -0
  62. package/lib/parseCSSImport.js +15 -0
  63. package/lib/path.d.ts +8 -0
  64. package/lib/path.js +39 -0
  65. package/lib/prettifyTime.d.ts +1 -0
  66. package/lib/prettifyTime.js +9 -0
  67. package/lib/prettyDiagnostic.d.ts +17 -0
  68. package/lib/prettyDiagnostic.js +134 -0
  69. package/lib/progress-message.d.ts +3 -0
  70. package/lib/progress-message.js +36 -0
  71. package/lib/relativeBundlePath.d.ts +4 -0
  72. package/lib/relativeBundlePath.js +22 -0
  73. package/lib/relativeUrl.d.ts +1 -0
  74. package/lib/relativeUrl.js +24 -0
  75. package/lib/replaceBundleReferences.d.ts +39 -0
  76. package/lib/replaceBundleReferences.js +199 -0
  77. package/lib/schema.d.ts +107 -0
  78. package/lib/schema.js +355 -0
  79. package/lib/shared-buffer.d.ts +2 -0
  80. package/lib/shared-buffer.js +31 -0
  81. package/lib/sourcemap.d.ts +16 -0
  82. package/lib/sourcemap.js +127 -0
  83. package/lib/stream.d.ts +8 -0
  84. package/lib/stream.js +76 -0
  85. package/lib/throttle.d.ts +1 -0
  86. package/lib/throttle.js +15 -0
  87. package/lib/urlJoin.d.ts +5 -0
  88. package/lib/urlJoin.js +35 -0
  89. package/package.json +24 -17
  90. package/src/{DefaultMap.js → DefaultMap.ts} +8 -12
  91. package/src/Deferred.ts +26 -0
  92. package/src/{PromiseQueue.js → PromiseQueue.ts} +40 -35
  93. package/src/{TapStream.js → TapStream.ts} +8 -7
  94. package/src/{alternatives.js → alternatives.ts} +14 -15
  95. package/src/{ansi-html.js → ansi-html.ts} +1 -1
  96. package/src/{blob.js → blob.ts} +2 -4
  97. package/src/{bundle-url.js → bundle-url.ts} +3 -5
  98. package/src/{collection.js → collection.ts} +23 -20
  99. package/src/{config.js → config.ts} +18 -19
  100. package/src/{countLines.js → countLines.ts} +0 -2
  101. package/src/{debounce.js → debounce.ts} +3 -5
  102. package/src/debug-tools.ts +43 -0
  103. package/src/{dependency-location.js → dependency-location.ts} +15 -11
  104. package/src/{escape-html.js → escape-html.ts} +5 -3
  105. package/src/{generateBuildMetrics.js → generateBuildMetrics.ts} +16 -18
  106. package/src/{generateCertificate.js → generateCertificate.ts} +7 -5
  107. package/src/{getCertificate.js → getCertificate.ts} +5 -3
  108. package/src/{getExisting.js → getExisting.ts} +4 -3
  109. package/src/{getModuleParts.js → getModuleParts.ts} +3 -2
  110. package/src/{getRootDir.js → getRootDir.ts} +0 -2
  111. package/src/{glob.js → glob.ts} +14 -10
  112. package/src/{hash.js → hash.ts} +22 -17
  113. package/src/{http-server.js → http-server.ts} +32 -38
  114. package/src/{index.js → index.ts} +13 -9
  115. package/src/{is-url.js → is-url.ts} +1 -2
  116. package/src/{isDirectoryInside.js → isDirectoryInside.ts} +0 -1
  117. package/src/{objectHash.js → objectHash.ts} +1 -4
  118. package/src/{openInBrowser.js → openInBrowser.ts} +2 -4
  119. package/src/{parseCSSImport.js → parseCSSImport.ts} +0 -2
  120. package/src/{path.js → path.ts} +1 -3
  121. package/src/{prettifyTime.js → prettifyTime.ts} +0 -2
  122. package/src/{prettyDiagnostic.js → prettyDiagnostic.ts} +22 -20
  123. package/src/progress-message.ts +38 -0
  124. package/src/{relativeBundlePath.js → relativeBundlePath.ts} +3 -3
  125. package/src/{relativeUrl.js → relativeUrl.ts} +0 -1
  126. package/src/{replaceBundleReferences.js → replaceBundleReferences.ts} +54 -36
  127. package/src/{schema.js → schema.ts} +158 -141
  128. package/src/{shared-buffer.js → shared-buffer.ts} +5 -3
  129. package/src/{sourcemap.js → sourcemap.ts} +16 -6
  130. package/src/{stream.js → stream.ts} +29 -21
  131. package/src/throttle.ts +13 -0
  132. package/src/{urlJoin.js → urlJoin.ts} +1 -3
  133. package/test/{DefaultMap.test.js → DefaultMap.test.ts} +4 -6
  134. package/test/{PromiseQueue.test.js → PromiseQueue.test.ts} +5 -6
  135. package/test/{collection.test.js → collection.test.ts} +0 -2
  136. package/test/{config.test.js → config.test.ts} +0 -3
  137. package/test/{objectHash.test.js → objectHash.test.ts} +4 -5
  138. package/test/{prettifyTime.test.js → prettifyTime.test.ts} +0 -1
  139. package/test/{replaceBundleReferences.test.js → replaceBundleReferences.test.ts} +0 -32
  140. package/test/{sourcemap.test.js → sourcemap.test.ts} +0 -1
  141. package/test/{throttle.test.js → throttle.test.ts} +1 -3
  142. package/test/{urlJoin.test.js → urlJoin.test.ts} +0 -2
  143. package/tsconfig.json +4 -0
  144. package/lib/index.js.map +0 -1
  145. package/src/Deferred.js +0 -23
  146. package/src/progress-message.js +0 -22
  147. package/src/throttle.js +0 -15
@@ -0,0 +1 @@
1
+ export default function isURL(url: string): boolean;
package/lib/is-url.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isURL;
7
+ function _isUrl() {
8
+ const data = _interopRequireDefault(require("is-url"));
9
+ _isUrl = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ // @ts-expect-error TS7016
16
+
17
+ // Matches anchor (ie: #raptors)
18
+ const ANCHOR_REGEXP = /^#/;
19
+
20
+ // Matches scheme (ie: tel:, mailto:, data:, itms-apps:)
21
+ const SCHEME_REGEXP = /^[a-z][a-z0-9\-+.]*:/i;
22
+ function isURL(url) {
23
+ return (0, _isUrl().default)(url) || ANCHOR_REGEXP.test(url) || SCHEME_REGEXP.test(url);
24
+ }
@@ -0,0 +1,2 @@
1
+ import type { FilePath } from '@atlaspack/types';
2
+ export default function isDirectoryInside(child: FilePath, parent: FilePath): boolean;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isDirectoryInside;
7
+ function _path() {
8
+ const data = _interopRequireDefault(require("path"));
9
+ _path = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ function isDirectoryInside(child, parent) {
16
+ const relative = _path().default.relative(parent, child);
17
+ return !relative.startsWith('..') && !_path().default.isAbsolute(relative);
18
+ }
@@ -0,0 +1,3 @@
1
+ type Hashable = any;
2
+ export default function objectHash(object: Hashable): string;
3
+ export {};
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = objectHash;
7
+ function _crypto() {
8
+ const data = _interopRequireDefault(require("crypto"));
9
+ _crypto = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ function objectHash(object) {
16
+ let hash = _crypto().default.createHash('md5');
17
+ for (let key of Object.keys(object).sort()) {
18
+ let val = object[key];
19
+ if (typeof val === 'object' && val) {
20
+ hash.update(key + objectHash(val));
21
+ } else {
22
+ hash.update(key + val);
23
+ }
24
+ }
25
+ return hash.digest('hex');
26
+ }
@@ -0,0 +1 @@
1
+ export default function openInBrowser(url: string, browser: string): Promise<void>;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = openInBrowser;
7
+ function _open() {
8
+ const data = _interopRequireDefault(require("open"));
9
+ _open = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _child_process() {
15
+ const data = require("child_process");
16
+ _child_process = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ function _logger() {
22
+ const data = _interopRequireDefault(require("@atlaspack/logger"));
23
+ _logger = function () {
24
+ return data;
25
+ };
26
+ return data;
27
+ }
28
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
+ // Chrome app name is platform dependent. we should not hard code it.
30
+ // https://github.com/react-native-community/cli/blob/e2be8a905285d9b37512fc78c9755b9635ecf805/packages/cli/src/commands/server/launchDebugger.ts#L28
31
+ function getChromeAppName() {
32
+ switch (process.platform) {
33
+ case 'darwin':
34
+ return 'google chrome';
35
+ case 'win32':
36
+ return 'chrome';
37
+ case 'linux':
38
+ if (commandExistsUnixSync('google-chrome')) {
39
+ return 'google-chrome';
40
+ }
41
+ if (commandExistsUnixSync('chromium-browser')) {
42
+ return 'chromium-browser';
43
+ }
44
+ return 'chromium';
45
+ default:
46
+ return 'google-chrome';
47
+ }
48
+ }
49
+ function commandExistsUnixSync(commandName) {
50
+ try {
51
+ const stdout = (0, _child_process().execSync)(`command -v ${commandName} 2>/dev/null` + ` && { echo >&1 '${commandName} found'; exit 0; }`);
52
+ return !!stdout;
53
+ } catch (error) {
54
+ return false;
55
+ }
56
+ }
57
+ function getAppName(appName) {
58
+ if (['google', 'chrome'].includes(appName)) {
59
+ return getChromeAppName();
60
+ } else if (['brave', 'Brave'].includes(appName)) {
61
+ return 'Brave Browser';
62
+ } else return appName;
63
+ }
64
+ async function openInBrowser(url, browser) {
65
+ try {
66
+ const options = typeof browser === 'string' && browser.length > 0 ? {
67
+ app: [getAppName(browser)]
68
+ } : undefined;
69
+ await (0, _open().default)(url, options);
70
+ } catch (err) {
71
+ _logger().default.error(`Unexpected error while opening in browser: ${browser}`, '@atlaspack/utils');
72
+ _logger().default.error(err, '@atlaspack/utils');
73
+ }
74
+ }
@@ -0,0 +1 @@
1
+ export default function parseCSSImport(url: string): string;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = parseCSSImport;
7
+ function parseCSSImport(url) {
8
+ if (!/^(~|\.\/|\/)/.test(url)) {
9
+ return './' + url;
10
+ } else if (!/^(~\/|\.\/|\/)/.test(url)) {
11
+ return url.substring(1);
12
+ } else {
13
+ return url;
14
+ }
15
+ }
package/lib/path.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import type { FilePath } from '@atlaspack/types';
2
+ export declare function isAbsolute(filepath: string): boolean;
3
+ export declare function normalizeSeparators(filePath: FilePath): FilePath;
4
+ export type PathOptions = {
5
+ noLeadingDotSlash?: boolean;
6
+ };
7
+ export declare function normalizePath(filePath: FilePath, leadingDotSlash?: boolean): FilePath;
8
+ export declare function relativePath(from: string, to: string, leadingDotSlash?: boolean): FilePath;
package/lib/path.js ADDED
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isAbsolute = isAbsolute;
7
+ exports.normalizePath = normalizePath;
8
+ exports.normalizeSeparators = normalizeSeparators;
9
+ exports.relativePath = relativePath;
10
+ function _path() {
11
+ const data = _interopRequireDefault(require("path"));
12
+ _path = function () {
13
+ return data;
14
+ };
15
+ return data;
16
+ }
17
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
+ const ABSOLUTE_PATH_REGEX = /^([a-zA-Z]:){0,1}[\\/]+/;
19
+ const SEPARATOR_REGEX = /[\\]+/g;
20
+ function isAbsolute(filepath) {
21
+ return ABSOLUTE_PATH_REGEX.test(filepath);
22
+ }
23
+ function normalizeSeparators(filePath) {
24
+ return filePath.replace(SEPARATOR_REGEX, '/');
25
+ }
26
+ function normalizePath(filePath, leadingDotSlash = true) {
27
+ if (leadingDotSlash && (filePath[0] !== '.' || filePath[1] !== '.' && filePath[1] !== '/' && filePath[1] !== '\\') && !_path().default.isAbsolute(filePath)) {
28
+ return normalizeSeparators('./' + filePath);
29
+ } else {
30
+ return normalizeSeparators(filePath);
31
+ }
32
+ }
33
+ function relativePath(from, to, leadingDotSlash = true) {
34
+ // Fast path
35
+ if (to.startsWith(from + '/')) {
36
+ return (leadingDotSlash ? './' : '') + to.slice(from.length + 1);
37
+ }
38
+ return normalizePath(_path().default.relative(from, to), leadingDotSlash);
39
+ }
@@ -0,0 +1 @@
1
+ export default function prettifyTime(timeInMs: number): string;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = prettifyTime;
7
+ function prettifyTime(timeInMs) {
8
+ return timeInMs < 1000 ? `${timeInMs}ms` : `${(timeInMs / 1000).toFixed(2)}s`;
9
+ }
@@ -0,0 +1,17 @@
1
+ import type { Diagnostic } from '@atlaspack/diagnostic';
2
+ import type { PluginOptions } from '@atlaspack/types';
3
+ export type FormattedCodeFrame = {
4
+ location: string;
5
+ code: string;
6
+ };
7
+ export type AnsiDiagnosticResult = {
8
+ message: string;
9
+ stack: string;
10
+ /** A formatted string containing all code frames, including their file locations. */
11
+ codeframe: string;
12
+ /** A list of code frames with highlighted code and file locations separately. */
13
+ frames: Array<FormattedCodeFrame>;
14
+ hints: Array<string>;
15
+ documentation: string;
16
+ };
17
+ export default function prettyDiagnostic(diagnostic: Diagnostic, options?: PluginOptions, terminalWidth?: number, format?: 'ansi' | 'html'): Promise<AnsiDiagnosticResult>;
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = prettyDiagnostic;
7
+ function _codeframe() {
8
+ const data = _interopRequireDefault(require("@atlaspack/codeframe"));
9
+ _codeframe = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _markdownAnsi() {
15
+ const data = _interopRequireDefault(require("@atlaspack/markdown-ansi"));
16
+ _markdownAnsi = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ function _chalk2() {
22
+ const data = _interopRequireDefault(require("chalk"));
23
+ _chalk2 = function () {
24
+ return data;
25
+ };
26
+ return data;
27
+ }
28
+ function _path() {
29
+ const data = _interopRequireDefault(require("path"));
30
+ _path = function () {
31
+ return data;
32
+ };
33
+ return data;
34
+ }
35
+ function _terminalLink2() {
36
+ const data = _interopRequireDefault(require("terminal-link"));
37
+ _terminalLink2 = function () {
38
+ return data;
39
+ };
40
+ return data;
41
+ }
42
+ function _snarkdown() {
43
+ const data = _interopRequireDefault(require("snarkdown"));
44
+ _snarkdown = function () {
45
+ return data;
46
+ };
47
+ return data;
48
+ }
49
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
50
+ /* eslint-disable import/no-extraneous-dependencies */
51
+
52
+ /* eslint-enable import/no-extraneous-dependencies */
53
+
54
+ async function prettyDiagnostic(diagnostic, options, terminalWidth, format = 'ansi') {
55
+ let {
56
+ origin,
57
+ message,
58
+ stack,
59
+ codeFrames,
60
+ hints,
61
+ skipFormatting,
62
+ documentationURL
63
+ } = diagnostic;
64
+ const md = format === 'ansi' ? _markdownAnsi().default : _snarkdown().default;
65
+ const terminalLink = format === 'ansi' ? _terminalLink2().default :
66
+ // eslint-disable-next-line no-unused-vars
67
+ (text, url, _) => `<a href="${url}">${text}</a>`;
68
+ const chalk = format === 'ansi' ? _chalk2().default : {
69
+ gray: {
70
+ underline: v => `<span style="color: grey; text-decoration: underline;">${v}</span>`
71
+ }
72
+ };
73
+ let result = {
74
+ message: md(`**${origin ?? 'unknown'}**: `) + (skipFormatting ? message : md(message)),
75
+ stack: '',
76
+ codeframe: '',
77
+ frames: [],
78
+ hints: [],
79
+ documentation: ''
80
+ };
81
+ if (codeFrames != null) {
82
+ for (let codeFrame of codeFrames) {
83
+ let filePath = codeFrame.filePath;
84
+ if (filePath != null && options && !_path().default.isAbsolute(filePath)) {
85
+ filePath = _path().default.join(options.projectRoot, filePath);
86
+ }
87
+ let highlights = codeFrame.codeHighlights;
88
+ let code = codeFrame.code;
89
+ if (code == null && options && filePath != null) {
90
+ code = await options.inputFS.readFile(filePath, 'utf8');
91
+ }
92
+ let formattedCodeFrame = '';
93
+ if (code != null) {
94
+ formattedCodeFrame = (0, _codeframe().default)(code, highlights, {
95
+ useColor: true,
96
+ syntaxHighlighting: true,
97
+ language: codeFrame.language || (filePath != null ? _path().default.extname(filePath).substr(1) : undefined),
98
+ terminalWidth
99
+ });
100
+ }
101
+ let location;
102
+ if (typeof filePath !== 'string') {
103
+ location = '';
104
+ } else if (highlights.length === 0) {
105
+ location = filePath;
106
+ } else {
107
+ location = `${filePath}:${highlights[0].start.line}:${highlights[0].start.column}`;
108
+ }
109
+ result.codeframe += location ? chalk.gray.underline(location) + '\n' : '';
110
+ result.codeframe += formattedCodeFrame;
111
+ if (codeFrame !== codeFrames[codeFrames.length - 1]) {
112
+ result.codeframe += '\n\n';
113
+ }
114
+ result.frames.push({
115
+ location,
116
+ code: formattedCodeFrame
117
+ });
118
+ }
119
+ }
120
+ if (stack != null) {
121
+ result.stack = stack;
122
+ }
123
+ if (Array.isArray(hints) && hints.length) {
124
+ result.hints = hints.map(h => {
125
+ return md(h);
126
+ });
127
+ }
128
+ if (documentationURL != null) {
129
+ result.documentation = terminalLink('Learn more', documentationURL, {
130
+ fallback: (text, url) => `${text}: ${url}`
131
+ });
132
+ }
133
+ return result;
134
+ }
@@ -0,0 +1,3 @@
1
+ import type { BuildProgressEvent } from '@atlaspack/types';
2
+ export declare function getProgressMessage(event: BuildProgressEvent): string | null | undefined;
3
+ export declare function getPackageProgressMessage(completeBundles: number, totalBundles: number): string;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getPackageProgressMessage = getPackageProgressMessage;
7
+ exports.getProgressMessage = getProgressMessage;
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 getProgressMessage(event) {
17
+ switch (event.phase) {
18
+ case 'transforming':
19
+ return `Building ${_path().default.basename(event.filePath)}...`;
20
+ case 'bundling':
21
+ return 'Bundling...';
22
+ case 'packaging':
23
+ return `Packaging ${event.bundle.displayName}...`;
24
+ case 'optimizing':
25
+ return `Optimizing ${event.bundle.displayName}...`;
26
+ case 'packagingAndOptimizing':
27
+ {
28
+ return getPackageProgressMessage(event.completeBundles, event.totalBundles);
29
+ }
30
+ }
31
+ return null;
32
+ }
33
+ function getPackageProgressMessage(completeBundles, totalBundles) {
34
+ let percent = Math.floor(completeBundles / totalBundles * 100);
35
+ return `Packaging bundles ${completeBundles}/${totalBundles} (${percent}%)`;
36
+ }
@@ -0,0 +1,4 @@
1
+ import type { FilePath, NamedBundle } from '@atlaspack/types';
2
+ export declare function relativeBundlePath(from: NamedBundle, to: NamedBundle, opts?: {
3
+ leadingDotSlash: boolean;
4
+ }): FilePath;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.relativeBundlePath = relativeBundlePath;
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
+ function relativeBundlePath(from, to, opts = {
17
+ leadingDotSlash: true
18
+ }) {
19
+ let fromPath = _path().default.join(from.target.distDir, from.name);
20
+ let toPath = _path().default.join(to.target.distDir, to.name);
21
+ return (0, _path2.relativePath)(_path().default.dirname(fromPath), toPath, opts.leadingDotSlash);
22
+ }
@@ -0,0 +1 @@
1
+ export default function relativeUrl(from: string, to: string): string;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = relativeUrl;
7
+ function _path() {
8
+ const data = _interopRequireDefault(require("path"));
9
+ _path = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _url() {
15
+ const data = _interopRequireDefault(require("url"));
16
+ _url = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
+ function relativeUrl(from, to) {
23
+ return _url().default.format(_url().default.parse(_path().default.relative(from, to)));
24
+ }
@@ -0,0 +1,39 @@
1
+ import type SourceMap from '@parcel/source-map';
2
+ import type { Async, Blob, Bundle, BundleGraph, Dependency, NamedBundle } from '@atlaspack/types';
3
+ export declare function replaceURLReferences({ bundle, bundleGraph, contents, map, getReplacement, relative, }: {
4
+ bundle: NamedBundle;
5
+ bundleGraph: BundleGraph<NamedBundle>;
6
+ contents: string;
7
+ relative?: boolean;
8
+ map?: SourceMap | null | undefined;
9
+ getReplacement?: (arg1: string) => string;
10
+ }): {
11
+ readonly contents: string;
12
+ readonly map: SourceMap | null | undefined;
13
+ };
14
+ export declare function replaceInlineReferences({ bundle, bundleGraph, contents, map, getInlineReplacement, getInlineBundleContents, }: {
15
+ bundle: Bundle;
16
+ bundleGraph: BundleGraph<NamedBundle>;
17
+ contents: string;
18
+ getInlineReplacement: (arg1: Dependency, arg2: 'string' | null | undefined, arg3: string) => {
19
+ from: string;
20
+ to: string;
21
+ };
22
+ getInlineBundleContents: (arg1: Bundle, arg2: BundleGraph<NamedBundle>) => Async<{
23
+ contents: Blob;
24
+ }>;
25
+ map?: SourceMap | null | undefined;
26
+ }): Promise<{
27
+ readonly contents: string;
28
+ readonly map: SourceMap | null | undefined;
29
+ }>;
30
+ export declare function getURLReplacement({ dependency, fromBundle, toBundle, relative, getReplacement, }: {
31
+ dependency: Dependency;
32
+ fromBundle: NamedBundle;
33
+ toBundle: NamedBundle;
34
+ relative: boolean;
35
+ getReplacement?: (arg1: string) => string;
36
+ }): {
37
+ from: string;
38
+ to: string;
39
+ };