@atlaspack/utils 2.17.3 → 2.17.4-typescript-5ad950d33.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
@@ -1,10 +1,8 @@
1
- // @flow strict-local
2
-
3
- export default function debounce<TArgs: Array<mixed>>(
4
- fn: (...args: TArgs) => mixed,
1
+ export default function debounce<TArgs extends Array<unknown>>(
2
+ fn: (...args: TArgs) => unknown,
5
3
  delay: number,
6
4
  ): (...args: TArgs) => void {
7
- let timeout;
5
+ let timeout: NodeJS.Timeout | undefined | null;
8
6
 
9
7
  return function (...args: TArgs) {
10
8
  if (timeout) {
@@ -1,5 +1,3 @@
1
- // @flow
2
-
3
1
  /*
4
2
  * These tools are intended for Atlaspack developers, to provide extra utilities
5
3
  * to make debugging Atlaspack issues more straightforward.
@@ -11,10 +9,10 @@
11
9
  * You can enable all tools by setting `ATLASPACK_DEBUG_TOOLS=all`.
12
10
  */
13
11
 
14
- type DebugTools = {|
15
- 'asset-file-names-in-output': boolean,
16
- 'simple-cli-reporter': boolean,
17
- |};
12
+ type DebugTools = {
13
+ ['asset-file-names-in-output']: boolean;
14
+ ['simple-cli-reporter']: boolean;
15
+ };
18
16
 
19
17
  export let debugTools: DebugTools = {
20
18
  'asset-file-names-in-output': false,
@@ -28,11 +26,11 @@ for (let tool of envVarValue.split(',')) {
28
26
 
29
27
  if (tool === 'all') {
30
28
  for (let key in debugTools) {
31
- debugTools[key] = true;
29
+ debugTools[key as keyof DebugTools] = true;
32
30
  }
33
31
  break;
34
32
  } else if (debugTools.hasOwnProperty(tool)) {
35
- debugTools[tool] = true;
33
+ debugTools[tool as keyof DebugTools] = true;
36
34
  } else if (tool === '') {
37
35
  continue;
38
36
  } else {
@@ -1,20 +1,24 @@
1
- // @flow
2
-
3
1
  export default function createDependencyLocation(
4
- start: {|
5
- line: number,
6
- column: number,
7
- |},
2
+ start: {
3
+ line: number;
4
+ column: number;
5
+ },
8
6
  specifier: string,
9
7
  lineOffset: number = 0,
10
8
  columnOffset: number = 0,
11
9
  // Imports are usually wrapped in quotes
12
10
  importWrapperLength: number = 2,
13
- ): {|
14
- end: {|column: number, line: number|},
15
- filePath: string,
16
- start: {|column: number, line: number|},
17
- |} {
11
+ ): {
12
+ end: {
13
+ column: number;
14
+ line: number;
15
+ };
16
+ filePath: string;
17
+ start: {
18
+ column: number;
19
+ line: number;
20
+ };
21
+ } {
18
22
  return {
19
23
  filePath: specifier,
20
24
  start: {
@@ -1,4 +1,3 @@
1
- // @flow
2
1
  // Based on _.escape https://github.com/lodash/lodash/blob/master/escape.js
3
2
  const reUnescapedHtml = /[&<>"']/g;
4
3
  const reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
@@ -9,11 +8,14 @@ const htmlEscapes = {
9
8
  '>': '&gt;',
10
9
  '"': '&quot;',
11
10
  "'": '&#39;',
12
- };
11
+ } as const;
13
12
 
14
13
  export function escapeHTML(s: string): string {
15
14
  if (reHasUnescapedHtml.test(s)) {
16
- return s.replace(reUnescapedHtml, (c) => htmlEscapes[c]);
15
+ return s.replace(
16
+ reUnescapedHtml,
17
+ (c) => htmlEscapes[c as keyof typeof htmlEscapes],
18
+ );
17
19
  }
18
20
 
19
21
  return s;
@@ -1,5 +1,3 @@
1
- // @flow
2
-
3
1
  import type {FilePath, PackagedBundle} from '@atlaspack/types';
4
2
  import type {FileSystem} from '@atlaspack/fs';
5
3
  import SourceMap from '@parcel/source-map';
@@ -7,29 +5,29 @@ import nullthrows from 'nullthrows';
7
5
  import path from 'path';
8
6
  import {loadSourceMapUrl} from './';
9
7
 
10
- export type AssetStats = {|
11
- filePath: string,
12
- size: number,
13
- originalSize: number,
14
- time: number,
15
- |};
8
+ export type AssetStats = {
9
+ filePath: string;
10
+ size: number;
11
+ originalSize: number;
12
+ time: number;
13
+ };
16
14
 
17
- export type BundleStats = {|
18
- filePath: string,
19
- size: number,
20
- time: number,
21
- assets: Array<AssetStats>,
22
- |};
15
+ export type BundleStats = {
16
+ filePath: string;
17
+ size: number;
18
+ time: number;
19
+ assets: Array<AssetStats>;
20
+ };
23
21
 
24
- export type BuildMetrics = {|
25
- bundles: Array<BundleStats>,
26
- |};
22
+ export type BuildMetrics = {
23
+ bundles: Array<BundleStats>;
24
+ };
27
25
 
28
26
  async function getSourcemapSizes(
29
27
  filePath: FilePath,
30
28
  fs: FileSystem,
31
29
  projectRoot: FilePath,
32
- ): Promise<?Map<string, number>> {
30
+ ): Promise<Map<string, number> | null | undefined> {
33
31
  let bundleContents = await fs.readFile(filePath, 'utf-8');
34
32
  let mapUrlData = await loadSourceMapUrl(fs, filePath, bundleContents);
35
33
  if (!mapUrlData) {
@@ -1,4 +1,3 @@
1
- // @flow
2
1
  import type {FileSystem} from '@atlaspack/fs';
3
2
  import forge from 'node-forge';
4
3
  import path from 'path';
@@ -7,8 +6,11 @@ import logger from '@atlaspack/logger';
7
6
  export default async function generateCertificate(
8
7
  fs: FileSystem,
9
8
  cacheDir: string,
10
- host: ?string,
11
- ): Promise<{|cert: Buffer, key: Buffer|}> {
9
+ host?: string | null,
10
+ ): Promise<{
11
+ cert: Buffer;
12
+ key: Buffer;
13
+ }> {
12
14
  let certDirectory = cacheDir;
13
15
 
14
16
  const privateKeyPath = path.join(certDirectory, 'private.pem');
@@ -134,7 +136,7 @@ export default async function generateCertificate(
134
136
  await fs.writeFile(certPath, certPem);
135
137
 
136
138
  return {
137
- key: privPem,
138
- cert: certPem,
139
+ key: privPem as unknown as Buffer,
140
+ cert: certPem as unknown as Buffer,
139
141
  };
140
142
  }
@@ -1,17 +1,19 @@
1
- // @flow
2
1
  import type {HTTPSOptions} from '@atlaspack/types';
3
2
  import type {FileSystem} from '@atlaspack/fs';
4
3
 
5
4
  export default async function getCertificate(
6
5
  fs: FileSystem,
7
6
  options: HTTPSOptions,
8
- ): Promise<{|cert: Buffer, key: Buffer|}> {
7
+ ): Promise<{
8
+ cert: Buffer;
9
+ key: Buffer;
10
+ }> {
9
11
  try {
10
12
  let cert = await fs.readFile(options.cert);
11
13
  let key = await fs.readFile(options.key);
12
14
 
13
15
  return {key, cert};
14
- } catch (err) {
16
+ } catch (err: any) {
15
17
  throw new Error('Certificate and/or key not found');
16
18
  }
17
19
  }
@@ -1,5 +1,3 @@
1
- // @flow strict-local
2
-
3
1
  import fs from 'fs';
4
2
 
5
3
  /**
@@ -9,7 +7,10 @@ import fs from 'fs';
9
7
  export default function getExisting(
10
8
  minifiedPath: string,
11
9
  sourcePath: string,
12
- ): {|minified: string, source: string|} {
10
+ ): {
11
+ minified: string;
12
+ source: string;
13
+ } {
13
14
  let source = fs.readFileSync(sourcePath, 'utf8').trim();
14
15
  return {
15
16
  source,
@@ -1,4 +1,3 @@
1
- // @flow strict-local
2
1
  import path from 'path';
3
2
 
4
3
  import {normalizeSeparators} from './path';
@@ -6,7 +5,9 @@ import {normalizeSeparators} from './path';
6
5
  /**
7
6
  * Returns the package name and the optional subpath
8
7
  */
9
- export default function getModuleParts(_name: string): [string, ?string] {
8
+ export default function getModuleParts(
9
+ _name: string,
10
+ ): [string, string | null | undefined] {
10
11
  let name = path.normalize(_name);
11
12
  let splitOn = name.indexOf(path.sep);
12
13
  if (name.charAt(0) === '@') {
@@ -1,5 +1,3 @@
1
- // @flow strict-local
2
-
3
1
  import type {FilePath} from '@atlaspack/types';
4
2
  import {isGlob} from './glob';
5
3
  import path from 'path';
@@ -1,10 +1,10 @@
1
- // @flow
2
-
3
1
  import type {FilePath, Glob} from '@atlaspack/types';
4
2
  import type {FileSystem} from '@atlaspack/fs';
5
3
 
4
+ // @ts-expect-error TS7016
6
5
  import _isGlob from 'is-glob';
7
- import fastGlob, {type FastGlobOptions} from 'fast-glob';
6
+ // @ts-expect-error TS2305
7
+ import fastGlob, {FastGlobOptions} from 'fast-glob';
8
8
  import micromatch, {isMatch, makeRe, type Options} from 'micromatch';
9
9
  import {normalizeSeparators} from './path';
10
10
 
@@ -44,25 +44,27 @@ export function globSync(
44
44
  fs: FileSystem,
45
45
  options?: FastGlobOptions<FilePath>,
46
46
  ): Array<FilePath> {
47
- // $FlowFixMe
48
47
  options = {
49
48
  ...options,
50
49
  fs: {
50
+ // @ts-expect-error TS7006
51
51
  statSync: (p) => {
52
52
  return fs.statSync(p);
53
53
  },
54
+ // @ts-expect-error TS7006
54
55
  lstatSync: (p) => {
55
56
  // Our FileSystem interface doesn't have lstat support at the moment,
56
57
  // but this is fine for our purposes since we follow symlinks by default.
57
58
  return fs.statSync(p);
58
59
  },
60
+ // @ts-expect-error TS7006
59
61
  readdirSync: (p, opts) => {
60
62
  return fs.readdirSync(p, opts);
61
63
  },
62
64
  },
63
65
  };
64
66
 
65
- // $FlowFixMe
67
+ // @ts-expect-error TS2322
66
68
  return fastGlob.sync(normalizeSeparators(p), options);
67
69
  }
68
70
 
@@ -71,26 +73,28 @@ export function glob(
71
73
  fs: FileSystem,
72
74
  options: FastGlobOptions<FilePath>,
73
75
  ): Promise<Array<FilePath>> {
74
- // $FlowFixMe
75
76
  options = {
76
77
  ...options,
77
78
  fs: {
79
+ // @ts-expect-error TS7006
78
80
  stat: async (p, cb) => {
79
81
  try {
80
82
  cb(null, await fs.stat(p));
81
- } catch (err) {
83
+ } catch (err: any) {
82
84
  cb(err);
83
85
  }
84
86
  },
87
+ // @ts-expect-error TS7006
85
88
  lstat: async (p, cb) => {
86
89
  // Our FileSystem interface doesn't have lstat support at the moment,
87
90
  // but this is fine for our purposes since we follow symlinks by default.
88
91
  try {
89
92
  cb(null, await fs.stat(p));
90
- } catch (err) {
93
+ } catch (err: any) {
91
94
  cb(err);
92
95
  }
93
96
  },
97
+ // @ts-expect-error TS7006
94
98
  readdir: async (p, opts, cb) => {
95
99
  if (typeof opts === 'function') {
96
100
  cb = opts;
@@ -99,13 +103,13 @@ export function glob(
99
103
 
100
104
  try {
101
105
  cb(null, await fs.readdir(p, opts));
102
- } catch (err) {
106
+ } catch (err: any) {
103
107
  cb(err);
104
108
  }
105
109
  },
106
110
  },
107
111
  };
108
112
 
109
- // $FlowFixMe Added in Flow 0.121.0 upgrade in #4381
113
+ // @ts-expect-error TS2322
110
114
  return fastGlob(normalizeSeparators(p), options);
111
115
  }
@@ -1,5 +1,3 @@
1
- // @flow strict-local
2
-
3
1
  import type {Readable} from 'stream';
4
2
  import type {FileSystem} from '@atlaspack/fs';
5
3
 
@@ -8,28 +6,35 @@ import {hashString, Hash} from '@atlaspack/rust';
8
6
 
9
7
  export function hashStream(stream: Readable): Promise<string> {
10
8
  let hash = new Hash();
11
- return new Promise((resolve, reject) => {
12
- stream.on('error', (err) => {
13
- reject(err);
14
- });
15
- stream
16
- .on('data', (chunk) => {
17
- hash.writeBuffer(chunk);
18
- })
19
- .on('end', function () {
20
- resolve(hash.finish());
21
- })
22
- .on('error', (err) => {
9
+ return new Promise(
10
+ (
11
+ resolve: (result: Promise<string> | string) => void,
12
+ reject: (error?: any) => void,
13
+ ) => {
14
+ stream.on('error', (err) => {
23
15
  reject(err);
24
16
  });
25
- });
17
+ stream
18
+ .on('data', (chunk) => {
19
+ hash.writeBuffer(chunk);
20
+ })
21
+ .on('end', function () {
22
+ resolve(hash.finish());
23
+ })
24
+ .on('error', (err) => {
25
+ reject(err);
26
+ });
27
+ },
28
+ );
26
29
  }
27
30
 
28
- export function hashObject(obj: {+[string]: mixed, ...}): string {
31
+ export function hashObject(obj: {readonly [key: string]: unknown}): string {
29
32
  return hashString(JSON.stringify(objectSortedEntriesDeep(obj)));
30
33
  }
31
34
 
32
- let testCache: {|[string]: Promise<string>|} = {
35
+ let testCache: {
36
+ [key: string]: Promise<string>;
37
+ } = {
33
38
  /*:: ...null */
34
39
  };
35
40
  export function hashFile(fs: FileSystem, filePath: string): Promise<string> {
@@ -1,15 +1,9 @@
1
- // @flow strict-local
2
-
3
1
  import type {
4
2
  Server as HTTPOnlyServer,
5
3
  IncomingMessage as HTTPRequest,
6
4
  ServerResponse as HTTPResponse,
7
5
  } from 'http';
8
- import type {
9
- Server as HTTPSServer,
10
- IncomingMessage as HTTPSRequest,
11
- ServerResponse as HTTPSResponse,
12
- } from 'https';
6
+ import type {Server as HTTPSServer} from 'https';
13
7
  import type {Socket} from 'net';
14
8
  import type {FilePath, HTTPSOptions} from '@atlaspack/types';
15
9
  import type {FileSystem} from '@atlaspack/fs';
@@ -19,29 +13,27 @@ import https from 'https';
19
13
  import nullthrows from 'nullthrows';
20
14
  import {getCertificate, generateCertificate} from './';
21
15
 
22
- type CreateHTTPServerOpts = {|
23
- listener?: (HTTPRequest | HTTPSRequest, HTTPResponse | HTTPSResponse) => void,
24
- host?: string,
25
- ...
26
- | {|
27
- https: ?(HTTPSOptions | boolean),
28
- inputFS: FileSystem,
29
- outputFS: FileSystem,
30
- cacheDir: FilePath,
31
- |}
32
- | {||},
33
- |};
16
+ type CreateHTTPServerOpts = {
17
+ listener?: (arg1: HTTPRequest, arg2: HTTPResponse) => void;
18
+ host?: string;
19
+ } & (
20
+ | {
21
+ https: HTTPSOptions | boolean | null | undefined;
22
+ inputFS: FileSystem;
23
+ outputFS: FileSystem;
24
+ cacheDir: FilePath;
25
+ }
26
+ | Record<any, any>
27
+ );
34
28
 
35
29
  export type HTTPServer = HTTPOnlyServer | HTTPSServer;
36
30
 
37
31
  // Creates either an http or https server with an awaitable dispose
38
32
  // that closes any connections
39
- export async function createHTTPServer(
40
- options: CreateHTTPServerOpts,
41
- ): Promise<{|
42
- stop: () => Promise<void>,
43
- server: HTTPServer,
44
- |}> {
33
+ export async function createHTTPServer(options: CreateHTTPServerOpts): Promise<{
34
+ stop: () => Promise<void>;
35
+ server: HTTPServer;
36
+ }> {
45
37
  let server;
46
38
  if (!options.https) {
47
39
  server = http.createServer(options.listener);
@@ -73,21 +65,23 @@ export async function createHTTPServer(
73
65
  return {
74
66
  server,
75
67
  stop() {
76
- return new Promise((resolve, reject) => {
77
- for (let socket of nullthrows(sockets)) {
78
- socket.destroy();
79
- }
80
- sockets = new Set();
81
-
82
- server.close((err) => {
83
- if (err != null) {
84
- reject(err);
85
- return;
68
+ return new Promise(
69
+ (resolve: () => void, reject: (error?: any) => void) => {
70
+ for (let socket of nullthrows(sockets)) {
71
+ socket.destroy();
86
72
  }
73
+ sockets = new Set();
74
+
75
+ server.close((err) => {
76
+ if (err != null) {
77
+ reject(err);
78
+ return;
79
+ }
87
80
 
88
- resolve();
89
- });
90
- });
81
+ resolve();
82
+ });
83
+ },
84
+ );
91
85
  },
92
86
  };
93
87
  }
@@ -1,11 +1,10 @@
1
- // @flow strict-local
2
- export type * from './config';
3
- export type * from './Deferred';
4
- export type * from './generateBuildMetrics';
5
- export type * from './http-server';
6
- export type * from './path';
7
- export type * from './prettyDiagnostic';
8
- export type * from './schema';
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';
9
8
 
10
9
  export {default as countLines} from './countLines';
11
10
  export {default as generateBuildMetrics} from './generateBuildMetrics';
@@ -1,5 +1,4 @@
1
- // @flow
2
-
1
+ // @ts-expect-error TS7016
3
2
  import _isURL from 'is-url';
4
3
 
5
4
  // Matches anchor (ie: #raptors)
@@ -1,4 +1,3 @@
1
- // @flow strict-local
2
1
  import type {FilePath} from '@atlaspack/types';
3
2
  import path from 'path';
4
3
 
@@ -1,9 +1,6 @@
1
- // @flow strict-local
2
-
3
1
  import crypto from 'crypto';
4
2
 
5
- // $FlowFixMe
6
- type Hashable = Object;
3
+ type Hashable = any;
7
4
 
8
5
  export default function objectHash(object: Hashable): string {
9
6
  let hash = crypto.createHash('md5');
@@ -1,5 +1,3 @@
1
- // @flow
2
-
3
1
  import open from 'open';
4
2
  import {execSync} from 'child_process';
5
3
  import logger from '@atlaspack/logger';
@@ -33,7 +31,7 @@ function commandExistsUnixSync(commandName: string) {
33
31
  ` && { echo >&1 '${commandName} found'; exit 0; }`,
34
32
  );
35
33
  return !!stdout;
36
- } catch (error) {
34
+ } catch (error: any) {
37
35
  return false;
38
36
  }
39
37
  }
@@ -54,7 +52,7 @@ export default async function openInBrowser(url: string, browser: string) {
54
52
  : undefined;
55
53
 
56
54
  await open(url, options);
57
- } catch (err) {
55
+ } catch (err: any) {
58
56
  logger.error(
59
57
  `Unexpected error while opening in browser: ${browser}`,
60
58
  '@atlaspack/utils',
@@ -1,5 +1,3 @@
1
- // @flow strict
2
-
3
1
  export default function parseCSSImport(url: string): string {
4
2
  if (!/^(~|\.\/|\/)/.test(url)) {
5
3
  return './' + url;
@@ -1,4 +1,3 @@
1
- // @flow strict-local
2
1
  import type {FilePath} from '@atlaspack/types';
3
2
  import path from 'path';
4
3
 
@@ -14,8 +13,7 @@ export function normalizeSeparators(filePath: FilePath): FilePath {
14
13
  }
15
14
 
16
15
  export type PathOptions = {
17
- noLeadingDotSlash?: boolean,
18
- ...
16
+ noLeadingDotSlash?: boolean;
19
17
  };
20
18
 
21
19
  export function normalizePath(
@@ -1,5 +1,3 @@
1
- // @flow strict-local
2
-
3
1
  export default function prettifyTime(timeInMs: number): string {
4
2
  return timeInMs < 1000 ? `${timeInMs}ms` : `${(timeInMs / 1000).toFixed(2)}s`;
5
3
  }