@parcel/utils 2.0.0-beta.3 → 2.0.0-dev.1510

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 (79) hide show
  1. package/lib/index.js +37516 -542
  2. package/lib/index.js.map +1 -0
  3. package/package.json +41 -18
  4. package/src/DefaultMap.js +1 -1
  5. package/src/PromiseQueue.js +13 -0
  6. package/src/alternatives.js +21 -6
  7. package/src/ansi-html.js +1 -1
  8. package/src/blob.js +1 -0
  9. package/src/collection.js +35 -3
  10. package/src/config.js +77 -22
  11. package/src/debounce.js +1 -1
  12. package/src/dependency-location.js +5 -5
  13. package/src/getExisting.js +1 -4
  14. package/src/getModuleParts.js +23 -0
  15. package/src/glob.js +26 -3
  16. package/src/hash.js +49 -0
  17. package/src/http-server.js +19 -7
  18. package/src/index.js +25 -10
  19. package/src/path.js +11 -1
  20. package/src/prettyDiagnostic.js +90 -40
  21. package/src/progress-message.js +22 -0
  22. package/src/replaceBundleReferences.js +49 -25
  23. package/src/schema.js +20 -19
  24. package/src/shared-buffer.js +23 -0
  25. package/src/sourcemap.js +13 -7
  26. package/src/urlJoin.js +3 -1
  27. package/test/DefaultMap.test.js +7 -4
  28. package/test/PromiseQueue.test.js +28 -0
  29. package/test/collection.test.js +13 -1
  30. package/test/config.test.js +98 -0
  31. package/test/input/config/.testrc +3 -0
  32. package/test/input/config/config.cjs +3 -0
  33. package/test/input/config/config.js +3 -0
  34. package/test/input/config/config.json +3 -0
  35. package/test/input/config/empty.json +0 -0
  36. package/test/input/config/empty.toml +0 -0
  37. package/test/replaceBundleReferences.test.js +88 -4
  38. package/test/throttle.test.js +1 -1
  39. package/test/urlJoin.test.js +11 -0
  40. package/lib/DefaultMap.js +0 -64
  41. package/lib/Deferred.js +0 -34
  42. package/lib/PromiseQueue.js +0 -144
  43. package/lib/TapStream.js +0 -46
  44. package/lib/alternatives.js +0 -151
  45. package/lib/ansi-html.js +0 -32
  46. package/lib/blob.js +0 -47
  47. package/lib/bundle-url.js +0 -43
  48. package/lib/collection.js +0 -51
  49. package/lib/config.js +0 -159
  50. package/lib/countLines.js +0 -18
  51. package/lib/debounce.js +0 -20
  52. package/lib/dependency-location.js +0 -21
  53. package/lib/escape-html.js +0 -24
  54. package/lib/generateBuildMetrics.js +0 -156
  55. package/lib/generateCertificate.js +0 -149
  56. package/lib/getCertificate.js +0 -19
  57. package/lib/getExisting.js +0 -31
  58. package/lib/getRootDir.js +0 -74
  59. package/lib/glob.js +0 -118
  60. package/lib/http-server.js +0 -110
  61. package/lib/is-url.js +0 -27
  62. package/lib/isDirectoryInside.js +0 -24
  63. package/lib/md5.js +0 -61
  64. package/lib/objectHash.js +0 -34
  65. package/lib/openInBrowser.js +0 -94
  66. package/lib/parseCSSImport.js +0 -16
  67. package/lib/path.js +0 -44
  68. package/lib/prettifyTime.js +0 -10
  69. package/lib/prettyDiagnostic.js +0 -119
  70. package/lib/relativeBundlePath.js +0 -38
  71. package/lib/relativeUrl.js +0 -32
  72. package/lib/replaceBundleReferences.js +0 -184
  73. package/lib/schema.js +0 -391
  74. package/lib/sourcemap.js +0 -155
  75. package/lib/stream.js +0 -86
  76. package/lib/throttle.js +0 -16
  77. package/lib/urlJoin.js +0 -43
  78. package/src/.babelrc +0 -3
  79. package/src/md5.js +0 -56
package/src/md5.js DELETED
@@ -1,56 +0,0 @@
1
- // @flow strict-local
2
-
3
- import type {Readable} from 'stream';
4
- import type {FileSystem} from '@parcel/fs';
5
-
6
- import crypto from 'crypto';
7
- import {objectSortedEntriesDeep} from './collection';
8
-
9
- type StringHashEncoding = 'hex' | 'latin1' | 'binary' | 'base64';
10
-
11
- export function md5FromString(
12
- string: string | Buffer,
13
- encoding: StringHashEncoding = 'hex',
14
- ): string {
15
- return crypto
16
- .createHash('md5')
17
- .update(string)
18
- .digest(encoding);
19
- }
20
-
21
- export function md5FromReadableStream(stream: Readable): Promise<string> {
22
- return new Promise((resolve, reject) => {
23
- stream.on('error', err => {
24
- reject(err);
25
- });
26
- stream
27
- .pipe(crypto.createHash('md5').setEncoding('hex'))
28
- .on('finish', function() {
29
- resolve(this.read());
30
- })
31
- .on('error', err => {
32
- reject(err);
33
- });
34
- });
35
- }
36
-
37
- export function md5FromOrderedObject(
38
- obj: {+[string]: mixed, ...},
39
- encoding: StringHashEncoding = 'hex',
40
- ): string {
41
- return md5FromString(JSON.stringify(obj), encoding);
42
- }
43
-
44
- export function md5FromObject(
45
- obj: {+[string]: mixed, ...},
46
- encoding: StringHashEncoding = 'hex',
47
- ): string {
48
- return md5FromString(JSON.stringify(objectSortedEntriesDeep(obj)), encoding);
49
- }
50
-
51
- export function md5FromFilePath(
52
- fs: FileSystem,
53
- filePath: string,
54
- ): Promise<string> {
55
- return md5FromReadableStream(fs.createReadStream(filePath));
56
- }