@atlaspack/utils 2.17.3 → 2.17.4-typescript-17c3d1dec.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 (113) hide show
  1. package/LICENSE +201 -0
  2. package/lib/DefaultMap.d.ts +13 -0
  3. package/lib/DefaultMap.js +0 -4
  4. package/lib/Deferred.d.ts +8 -0
  5. package/lib/PromiseQueue.d.ts +25 -0
  6. package/lib/TapStream.d.ts +6 -0
  7. package/lib/alternatives.d.ts +3 -0
  8. package/lib/ansi-html.d.ts +1 -0
  9. package/lib/ansi-html.js +2 -0
  10. package/lib/blob.d.ts +4 -0
  11. package/lib/bundle-url.d.ts +4 -0
  12. package/lib/collection.d.ts +33 -0
  13. package/lib/config.d.ts +17 -0
  14. package/lib/config.js +3 -1
  15. package/lib/countLines.d.ts +1 -0
  16. package/lib/debounce.d.ts +1 -0
  17. package/lib/debug-tools.d.ts +6 -0
  18. package/lib/debug-tools.js +1 -0
  19. package/lib/dependency-location.d.ts +14 -0
  20. package/lib/escape-html.d.ts +1 -0
  21. package/lib/generateBuildMetrics.d.ts +18 -0
  22. package/lib/generateCertificate.d.ts +5 -0
  23. package/lib/getCertificate.d.ts +6 -0
  24. package/lib/getExisting.d.ts +8 -0
  25. package/lib/getModuleParts.d.ts +4 -0
  26. package/lib/getRootDir.d.ts +2 -0
  27. package/lib/glob.d.ts +10 -0
  28. package/lib/glob.js +12 -4
  29. package/lib/hash.d.ts +7 -0
  30. package/lib/http-server.d.ts +19 -0
  31. package/lib/index.d.ts +48 -0
  32. package/lib/index.js +164 -9
  33. package/lib/is-url.d.ts +1 -0
  34. package/lib/is-url.js +2 -0
  35. package/lib/isDirectoryInside.d.ts +2 -0
  36. package/lib/objectHash.d.ts +3 -0
  37. package/lib/objectHash.js +0 -1
  38. package/lib/openInBrowser.d.ts +1 -0
  39. package/lib/parseCSSImport.d.ts +1 -0
  40. package/lib/path.d.ts +8 -0
  41. package/lib/prettifyTime.d.ts +1 -0
  42. package/lib/prettyDiagnostic.d.ts +17 -0
  43. package/lib/prettyDiagnostic.js +3 -5
  44. package/lib/progress-message.d.ts +3 -0
  45. package/lib/relativeBundlePath.d.ts +4 -0
  46. package/lib/relativeUrl.d.ts +1 -0
  47. package/lib/replaceBundleReferences.d.ts +39 -0
  48. package/lib/schema.d.ts +107 -0
  49. package/lib/schema.js +38 -19
  50. package/lib/shared-buffer.d.ts +2 -0
  51. package/lib/shared-buffer.js +5 -1
  52. package/lib/sourcemap.d.ts +16 -0
  53. package/lib/stream.d.ts +8 -0
  54. package/lib/throttle.d.ts +1 -0
  55. package/lib/urlJoin.d.ts +5 -0
  56. package/lib/urlJoin.js +1 -1
  57. package/package.json +22 -15
  58. package/src/{DefaultMap.js → DefaultMap.ts} +8 -12
  59. package/src/Deferred.ts +26 -0
  60. package/src/{PromiseQueue.js → PromiseQueue.ts} +40 -35
  61. package/src/{TapStream.js → TapStream.ts} +8 -7
  62. package/src/{alternatives.js → alternatives.ts} +14 -15
  63. package/src/{ansi-html.js → ansi-html.ts} +1 -1
  64. package/src/{blob.js → blob.ts} +2 -4
  65. package/src/{bundle-url.js → bundle-url.ts} +3 -5
  66. package/src/{collection.js → collection.ts} +14 -21
  67. package/src/{config.js → config.ts} +18 -19
  68. package/src/{countLines.js → countLines.ts} +0 -2
  69. package/src/{debounce.js → debounce.ts} +3 -5
  70. package/src/{debug-tools.js → debug-tools.ts} +6 -8
  71. package/src/{dependency-location.js → dependency-location.ts} +15 -11
  72. package/src/{escape-html.js → escape-html.ts} +5 -3
  73. package/src/{generateBuildMetrics.js → generateBuildMetrics.ts} +16 -18
  74. package/src/{generateCertificate.js → generateCertificate.ts} +7 -5
  75. package/src/{getCertificate.js → getCertificate.ts} +5 -3
  76. package/src/{getExisting.js → getExisting.ts} +4 -3
  77. package/src/{getModuleParts.js → getModuleParts.ts} +3 -2
  78. package/src/{getRootDir.js → getRootDir.ts} +0 -2
  79. package/src/{glob.js → glob.ts} +14 -10
  80. package/src/{hash.js → hash.ts} +22 -17
  81. package/src/{http-server.js → http-server.ts} +32 -38
  82. package/src/{index.js → index.ts} +7 -8
  83. package/src/{is-url.js → is-url.ts} +1 -2
  84. package/src/{isDirectoryInside.js → isDirectoryInside.ts} +0 -1
  85. package/src/{objectHash.js → objectHash.ts} +1 -4
  86. package/src/{openInBrowser.js → openInBrowser.ts} +2 -4
  87. package/src/{parseCSSImport.js → parseCSSImport.ts} +0 -2
  88. package/src/{path.js → path.ts} +1 -3
  89. package/src/{prettifyTime.js → prettifyTime.ts} +0 -2
  90. package/src/{prettyDiagnostic.js → prettyDiagnostic.ts} +22 -20
  91. package/src/{progress-message.js → progress-message.ts} +3 -2
  92. package/src/{relativeBundlePath.js → relativeBundlePath.ts} +3 -3
  93. package/src/{relativeUrl.js → relativeUrl.ts} +0 -1
  94. package/src/{replaceBundleReferences.js → replaceBundleReferences.ts} +54 -36
  95. package/src/{schema.js → schema.ts} +158 -141
  96. package/src/{shared-buffer.js → shared-buffer.ts} +5 -3
  97. package/src/{sourcemap.js → sourcemap.ts} +16 -6
  98. package/src/{stream.js → stream.ts} +29 -21
  99. package/src/throttle.ts +13 -0
  100. package/src/{urlJoin.js → urlJoin.ts} +1 -3
  101. package/test/{DefaultMap.test.js → DefaultMap.test.ts} +4 -6
  102. package/test/{PromiseQueue.test.js → PromiseQueue.test.ts} +5 -6
  103. package/test/{collection.test.js → collection.test.ts} +0 -2
  104. package/test/{config.test.js → config.test.ts} +0 -3
  105. package/test/{objectHash.test.js → objectHash.test.ts} +4 -5
  106. package/test/{prettifyTime.test.js → prettifyTime.test.ts} +0 -1
  107. package/test/{replaceBundleReferences.test.js → replaceBundleReferences.test.ts} +0 -32
  108. package/test/{sourcemap.test.js → sourcemap.test.ts} +0 -1
  109. package/test/{throttle.test.js → throttle.test.ts} +1 -3
  110. package/test/{urlJoin.test.js → urlJoin.test.ts} +0 -2
  111. package/tsconfig.json +4 -0
  112. package/src/Deferred.js +0 -23
  113. package/src/throttle.js +0 -15
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright (c) 2024 Atlassian US., Inc.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -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,8 @@
1
+ export type Deferred<T> = {
2
+ resolve(arg1: T): void;
3
+ reject(arg1: unknown): void;
4
+ };
5
+ export declare function makeDeferredWithPromise<T>(): {
6
+ deferred: Deferred<T>;
7
+ promise: Promise<T>;
8
+ };
@@ -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,4 @@
1
+ import type { Blob } from '@atlaspack/types';
2
+ import { Buffer } from 'buffer';
3
+ export declare function blobToBuffer(blob: Blob): Promise<Buffer>;
4
+ export declare function blobToString(blob: Blob): Promise<string>;
@@ -0,0 +1,4 @@
1
+ declare function getBundleURLCached(): string;
2
+ export declare function getBaseURL(url?: string | null): string;
3
+ export declare const getBundleURL: typeof getBundleURLCached;
4
+ export {};
@@ -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;
@@ -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;
@@ -0,0 +1,6 @@
1
+ type DebugTools = {
2
+ ['asset-file-names-in-output']: boolean;
3
+ ['simple-cli-reporter']: boolean;
4
+ };
5
+ export declare let debugTools: DebugTools;
6
+ export {};
@@ -14,6 +14,7 @@ exports.debugTools = void 0;
14
14
  *
15
15
  * You can enable all tools by setting `ATLASPACK_DEBUG_TOOLS=all`.
16
16
  */
17
+
17
18
  let debugTools = exports.debugTools = {
18
19
  'asset-file-names-in-output': false,
19
20
  'simple-cli-reporter': false
@@ -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,5 @@
1
+ import type { FileSystem } from '@atlaspack/fs';
2
+ export default function generateCertificate(fs: FileSystem, cacheDir: string, host?: string | null): Promise<{
3
+ cert: Buffer;
4
+ key: Buffer;
5
+ }>;
@@ -0,0 +1,6 @@
1
+ import type { HTTPSOptions } from '@atlaspack/types';
2
+ import type { FileSystem } from '@atlaspack/fs';
3
+ export default function getCertificate(fs: FileSystem, options: HTTPSOptions): Promise<{
4
+ cert: Buffer;
5
+ key: Buffer;
6
+ }>;
@@ -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
+ };
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Returns the package name and the optional subpath
3
+ */
4
+ export default function getModuleParts(_name: string): [string, string | null | undefined];
@@ -0,0 +1,2 @@
1
+ import type { FilePath } from '@atlaspack/types';
2
+ export default function getRootDir(files: Array<FilePath>): FilePath;
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
- // $FlowFixMe
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
- // $FlowFixMe Added in Flow 0.121.0 upgrade in #4381
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';