@parcel/utils 2.4.1 → 2.6.1
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/index.js +4817 -4933
- package/lib/index.js.map +1 -1
- package/package.json +7 -8
- package/src/http-server.js +19 -7
- package/src/prettyDiagnostic.js +17 -4
- package/src/schema.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcel/utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"description": "Blazing fast, zero configuration web application bundler",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -33,16 +33,15 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@parcel/codeframe": "2.
|
|
37
|
-
"@parcel/diagnostic": "2.
|
|
38
|
-
"@parcel/hash": "2.
|
|
39
|
-
"@parcel/logger": "2.
|
|
40
|
-
"@parcel/markdown-ansi": "2.
|
|
36
|
+
"@parcel/codeframe": "2.6.1",
|
|
37
|
+
"@parcel/diagnostic": "2.6.1",
|
|
38
|
+
"@parcel/hash": "2.6.1",
|
|
39
|
+
"@parcel/logger": "2.6.1",
|
|
40
|
+
"@parcel/markdown-ansi": "2.6.1",
|
|
41
41
|
"@parcel/source-map": "^2.0.0",
|
|
42
42
|
"chalk": "^4.1.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@babel/plugin-transform-flow-strip-types": "^7.2.0",
|
|
46
45
|
"@iarna/toml": "^2.2.0",
|
|
47
46
|
"ansi-html-community": "0.0.8",
|
|
48
47
|
"clone": "^2.1.1",
|
|
@@ -64,5 +63,5 @@
|
|
|
64
63
|
"./src/http-server.js": false,
|
|
65
64
|
"./src/openInBrowser.js": false
|
|
66
65
|
},
|
|
67
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "b8b203da8302dfde6d875422c8c557a00b7d3c02"
|
|
68
67
|
}
|
package/src/http-server.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
// @flow strict-local
|
|
2
2
|
|
|
3
|
-
import type {
|
|
4
|
-
|
|
3
|
+
import type {
|
|
4
|
+
Server as HTTPOnlyServer,
|
|
5
|
+
IncomingMessage as HTTPRequest,
|
|
6
|
+
ServerResponse as HTTPResponse,
|
|
7
|
+
} from 'http';
|
|
8
|
+
import type {
|
|
9
|
+
Server as HTTPSServer,
|
|
10
|
+
IncomingMessage as HTTPSRequest,
|
|
11
|
+
ServerResponse as HTTPSResponse,
|
|
12
|
+
} from 'https';
|
|
5
13
|
import type {Socket} from 'net';
|
|
6
14
|
import type {FilePath, HTTPSOptions} from '@parcel/types';
|
|
7
15
|
import type {FileSystem} from '@parcel/fs';
|
|
@@ -12,12 +20,16 @@ import nullthrows from 'nullthrows';
|
|
|
12
20
|
import {getCertificate, generateCertificate} from './';
|
|
13
21
|
|
|
14
22
|
type CreateHTTPServerOpts = {|
|
|
15
|
-
|
|
16
|
-
inputFS: FileSystem,
|
|
17
|
-
outputFS: FileSystem,
|
|
18
|
-
cacheDir: FilePath,
|
|
19
|
-
listener?: (mixed, mixed) => void,
|
|
23
|
+
listener?: (HTTPRequest | HTTPSRequest, HTTPResponse | HTTPSResponse) => void,
|
|
20
24
|
host?: string,
|
|
25
|
+
...
|
|
26
|
+
| {|
|
|
27
|
+
https: ?(HTTPSOptions | boolean),
|
|
28
|
+
inputFS: FileSystem,
|
|
29
|
+
outputFS: FileSystem,
|
|
30
|
+
cacheDir: FilePath,
|
|
31
|
+
|}
|
|
32
|
+
| {||},
|
|
21
33
|
|};
|
|
22
34
|
|
|
23
35
|
export type HTTPServer = HTTPOnlyServer | HTTPSServer;
|
package/src/prettyDiagnostic.js
CHANGED
|
@@ -10,10 +10,18 @@ import nullthrows from 'nullthrows';
|
|
|
10
10
|
// $FlowFixMe
|
|
11
11
|
import terminalLink from 'terminal-link';
|
|
12
12
|
|
|
13
|
+
export type FormattedCodeFrame = {|
|
|
14
|
+
location: string,
|
|
15
|
+
code: string,
|
|
16
|
+
|};
|
|
17
|
+
|
|
13
18
|
export type AnsiDiagnosticResult = {|
|
|
14
19
|
message: string,
|
|
15
20
|
stack: string,
|
|
21
|
+
/** A formatted string containing all code frames, including their file locations. */
|
|
16
22
|
codeframe: string,
|
|
23
|
+
/** A list of code frames with highlighted code and file locations separately. */
|
|
24
|
+
frames: Array<FormattedCodeFrame>,
|
|
17
25
|
hints: Array<string>,
|
|
18
26
|
documentation: string,
|
|
19
27
|
|};
|
|
@@ -39,6 +47,7 @@ export default async function prettyDiagnostic(
|
|
|
39
47
|
(skipFormatting ? message : mdAnsi(message)),
|
|
40
48
|
stack: '',
|
|
41
49
|
codeframe: '',
|
|
50
|
+
frames: [],
|
|
42
51
|
hints: [],
|
|
43
52
|
documentation: '',
|
|
44
53
|
};
|
|
@@ -69,16 +78,20 @@ export default async function prettyDiagnostic(
|
|
|
69
78
|
});
|
|
70
79
|
}
|
|
71
80
|
|
|
72
|
-
|
|
81
|
+
let location =
|
|
73
82
|
typeof filePath !== 'string'
|
|
74
83
|
? ''
|
|
75
|
-
:
|
|
76
|
-
|
|
77
|
-
);
|
|
84
|
+
: `${filePath}:${highlights[0].start.line}:${highlights[0].start.column}`;
|
|
85
|
+
result.codeframe += location ? chalk.gray.underline(location) + '\n' : '';
|
|
78
86
|
result.codeframe += formattedCodeFrame;
|
|
79
87
|
if (codeFrame !== codeFrames[codeFrames.length - 1]) {
|
|
80
88
|
result.codeframe += '\n\n';
|
|
81
89
|
}
|
|
90
|
+
|
|
91
|
+
result.frames.push({
|
|
92
|
+
location,
|
|
93
|
+
code: formattedCodeFrame,
|
|
94
|
+
});
|
|
82
95
|
}
|
|
83
96
|
}
|
|
84
97
|
|
package/src/schema.js
CHANGED
|
@@ -4,7 +4,7 @@ import ThrowableDiagnostic, {
|
|
|
4
4
|
escapeMarkdown,
|
|
5
5
|
encodeJSONKeyComponent,
|
|
6
6
|
} from '@parcel/diagnostic';
|
|
7
|
-
import type {Mapping} from 'json-
|
|
7
|
+
import type {Mapping} from '@mischnic/json-sourcemap';
|
|
8
8
|
import nullthrows from 'nullthrows';
|
|
9
9
|
// flowlint-next-line untyped-import:off
|
|
10
10
|
import levenshtein from 'fastest-levenshtein';
|
|
@@ -406,7 +406,7 @@ validateSchema.diagnostic = function (
|
|
|
406
406
|
!data
|
|
407
407
|
) {
|
|
408
408
|
throw new Error(
|
|
409
|
-
'At least one of data.source and data.
|
|
409
|
+
'At least one of data.source and data.data must be defined!',
|
|
410
410
|
);
|
|
411
411
|
}
|
|
412
412
|
let object = data.map
|