prettier 1.15.2 → 1.15.3
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/README.md +2 -2
- package/bin-prettier.js +410 -241
- package/index.js +405 -238
- package/package.json +1 -1
- package/parser-babylon.js +1 -1
- package/parser-html.js +1 -1
- package/parser-markdown.js +1 -1
- package/parser-postcss.js +2978 -3390
- package/parser-typescript.js +1 -1
- package/standalone.js +373 -237
- package/third-party.js +150 -17
package/standalone.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
}(this, (function () { 'use strict';
|
|
6
6
|
|
|
7
7
|
var name = "prettier";
|
|
8
|
-
var version$1 = "1.15.
|
|
8
|
+
var version$1 = "1.15.3";
|
|
9
9
|
var description = "Prettier is an opinionated code formatter";
|
|
10
10
|
var bin = {
|
|
11
11
|
"prettier": "./bin/prettier.js"
|
|
@@ -21,20 +21,20 @@ var engines = {
|
|
|
21
21
|
var dependencies = {
|
|
22
22
|
"@angular/compiler": "6.1.10",
|
|
23
23
|
"@babel/code-frame": "7.0.0-beta.46",
|
|
24
|
-
"@babel/parser": "7.1.
|
|
24
|
+
"@babel/parser": "7.1.6",
|
|
25
25
|
"@glimmer/syntax": "0.30.3",
|
|
26
26
|
"@iarna/toml": "2.0.0",
|
|
27
27
|
"angular-estree-parser": "1.1.5",
|
|
28
|
-
"angular-html-parser": "1.
|
|
28
|
+
"angular-html-parser": "1.1.0",
|
|
29
29
|
"camelcase": "4.1.0",
|
|
30
30
|
"chalk": "2.1.0",
|
|
31
31
|
"cjk-regex": "2.0.0",
|
|
32
|
-
"cosmiconfig": "5.0.
|
|
32
|
+
"cosmiconfig": "5.0.7",
|
|
33
33
|
"dashify": "0.2.2",
|
|
34
34
|
"dedent": "0.7.0",
|
|
35
35
|
"diff": "3.2.0",
|
|
36
36
|
"editorconfig": "0.15.2",
|
|
37
|
-
"editorconfig-to-prettier": "0.1.
|
|
37
|
+
"editorconfig-to-prettier": "0.1.1",
|
|
38
38
|
"emoji-regex": "6.5.1",
|
|
39
39
|
"escape-string-regexp": "1.0.5",
|
|
40
40
|
"esutils": "2.0.2",
|
|
@@ -62,7 +62,7 @@ var dependencies = {
|
|
|
62
62
|
"parse-srcset": "ikatyang/parse-srcset#54eb9c1cb21db5c62b4d0e275d7249516df6f0ee",
|
|
63
63
|
"postcss-less": "1.1.5",
|
|
64
64
|
"postcss-media-query-parser": "0.2.3",
|
|
65
|
-
"postcss-scss": "
|
|
65
|
+
"postcss-scss": "2.0.0",
|
|
66
66
|
"postcss-selector-parser": "2.2.3",
|
|
67
67
|
"postcss-values-parser": "1.5.0",
|
|
68
68
|
"regexp-util": "1.2.2",
|
|
@@ -71,8 +71,8 @@ var dependencies = {
|
|
|
71
71
|
"resolve": "1.5.0",
|
|
72
72
|
"semver": "5.4.1",
|
|
73
73
|
"string-width": "2.1.1",
|
|
74
|
-
"typescript": "3.
|
|
75
|
-
"typescript-estree": "
|
|
74
|
+
"typescript": "3.2.1",
|
|
75
|
+
"typescript-estree": "6.0.0-rc.1",
|
|
76
76
|
"unicode-regex": "2.0.0",
|
|
77
77
|
"unified": "6.1.6",
|
|
78
78
|
"vnopts": "1.0.2",
|
|
@@ -101,7 +101,7 @@ var devDependencies = {
|
|
|
101
101
|
"jest-snapshot-serializer-raw": "1.1.0",
|
|
102
102
|
"jest-watch-typeahead": "0.1.0",
|
|
103
103
|
"mkdirp": "0.5.1",
|
|
104
|
-
"prettier": "1.15.
|
|
104
|
+
"prettier": "1.15.2",
|
|
105
105
|
"prettylint": "1.0.0",
|
|
106
106
|
"rimraf": "2.6.2",
|
|
107
107
|
"rollup": "0.47.6",
|
|
@@ -134,6 +134,7 @@ var scripts = {
|
|
|
134
134
|
"perf-benchmark": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js --debug-benchmark --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
|
|
135
135
|
"lint": "cross-env EFF_NO_LINK_RULES=true eslint . --format node_modules/eslint-friendly-formatter",
|
|
136
136
|
"lint-docs": "prettylint {.,docs,website,website/blog}/*.md",
|
|
137
|
+
"lint-dist": "eslint --no-eslintrc --no-ignore --env=browser \"dist/!(bin-prettier|index|third-party).js\"",
|
|
137
138
|
"build": "node --max-old-space-size=2048 ./scripts/build/build.js",
|
|
138
139
|
"build-docs": "node ./scripts/build-docs.js",
|
|
139
140
|
"check-deps": "node ./scripts/check-deps.js"
|
|
@@ -8524,7 +8525,7 @@ function supportsColor(stream) {
|
|
|
8524
8525
|
return 2;
|
|
8525
8526
|
}
|
|
8526
8527
|
|
|
8527
|
-
if (/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(env$1.TERM)) {
|
|
8528
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env$1.TERM)) {
|
|
8528
8529
|
return 1;
|
|
8529
8530
|
}
|
|
8530
8531
|
|
|
@@ -11950,7 +11951,7 @@ function supportsColor$4(stream) {
|
|
|
11950
11951
|
return 2;
|
|
11951
11952
|
}
|
|
11952
11953
|
|
|
11953
|
-
if (/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(env$2.TERM)) {
|
|
11954
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env$2.TERM)) {
|
|
11954
11955
|
return 1;
|
|
11955
11956
|
}
|
|
11956
11957
|
|
|
@@ -18959,7 +18960,7 @@ var htmlElementAttributes = Object.freeze({
|
|
|
18959
18960
|
default: index$13
|
|
18960
18961
|
});
|
|
18961
18962
|
|
|
18962
|
-
|
|
18963
|
+
var json$4 = {"CSS_DISPLAY_TAGS":{"area":"none","base":"none","basefont":"none","datalist":"none","head":"none","link":"none","meta":"none","noembed":"none","noframes":"none","param":"none","rp":"none","script":"none","source":"block","style":"none","template":"inline","track":"block","title":"none","html":"block","body":"block","address":"block","blockquote":"block","center":"block","div":"block","figure":"block","figcaption":"block","footer":"block","form":"block","header":"block","hr":"block","legend":"block","listing":"block","main":"block","p":"block","plaintext":"block","pre":"block","xmp":"block","slot":"contents","ruby":"ruby","rt":"ruby-text","article":"block","aside":"block","h1":"block","h2":"block","h3":"block","h4":"block","h5":"block","h6":"block","hgroup":"block","nav":"block","section":"block","dir":"block","dd":"block","dl":"block","dt":"block","ol":"block","ul":"block","li":"list-item","table":"table","caption":"table-caption","colgroup":"table-column-group","col":"table-column","thead":"table-header-group","tbody":"table-row-group","tfoot":"table-footer-group","tr":"table-row","td":"table-cell","th":"table-cell","fieldset":"block","button":"inline-block","video":"inline-block","audio":"inline-block"},"CSS_DISPLAY_DEFAULT":"inline","CSS_WHITE_SPACE_TAGS":{"listing":"pre","plaintext":"pre","pre":"pre","xmp":"pre","nobr":"nowrap","table":"initial","textarea":"pre-wrap"},"CSS_WHITE_SPACE_DEFAULT":"normal"};
|
|
18963
18964
|
|
|
18964
18965
|
var htmlElementAttributes$1 = ( htmlElementAttributes && index$13 ) || htmlElementAttributes;
|
|
18965
18966
|
|
|
@@ -19014,7 +19015,7 @@ function mapObject(object, fn) {
|
|
|
19014
19015
|
return newObject;
|
|
19015
19016
|
}
|
|
19016
19017
|
|
|
19017
|
-
function shouldPreserveContent$1(node) {
|
|
19018
|
+
function shouldPreserveContent$1(node, options) {
|
|
19018
19019
|
if (node.type === "element" && node.fullName === "template" && node.attrMap.lang && node.attrMap.lang !== "html") {
|
|
19019
19020
|
return true;
|
|
19020
19021
|
} // unterminated node in ie conditional comment
|
|
@@ -19029,10 +19030,17 @@ function shouldPreserveContent$1(node) {
|
|
|
19029
19030
|
|
|
19030
19031
|
if (node.type === "ieConditionalComment" && !node.complete) {
|
|
19031
19032
|
return true;
|
|
19033
|
+
} // top-level elements (excluding <template>, <style> and <script>) in Vue SFC are considered custom block
|
|
19034
|
+
// custom blocks can be written in other languages so we should preserve them to not break the code
|
|
19035
|
+
|
|
19036
|
+
|
|
19037
|
+
if (options.parser === "vue" && node.type === "element" && node.parent.type === "root" && ["template", "style", "script", // vue parser can be used for vue dom template as well, so we should still format top-level <html>
|
|
19038
|
+
"html"].indexOf(node.fullName) === -1) {
|
|
19039
|
+
return true;
|
|
19032
19040
|
} // TODO: handle non-text children in <pre>
|
|
19033
19041
|
|
|
19034
19042
|
|
|
19035
|
-
if (isPreLikeNode
|
|
19043
|
+
if (isPreLikeNode(node) && node.children.some(function (child) {
|
|
19036
19044
|
return child.type !== "text" && child.type !== "interpolation";
|
|
19037
19045
|
})) {
|
|
19038
19046
|
return true;
|
|
@@ -19042,7 +19050,7 @@ function shouldPreserveContent$1(node) {
|
|
|
19042
19050
|
}
|
|
19043
19051
|
|
|
19044
19052
|
function hasPrettierIgnore$1(node) {
|
|
19045
|
-
if (node.type === "attribute" || node
|
|
19053
|
+
if (node.type === "attribute" || isTextLikeNode$1(node)) {
|
|
19046
19054
|
return false;
|
|
19047
19055
|
}
|
|
19048
19056
|
|
|
@@ -19075,6 +19083,12 @@ function getPrettierIgnoreAttributeCommentData$1(value) {
|
|
|
19075
19083
|
|
|
19076
19084
|
return match[1].split(/\s+/);
|
|
19077
19085
|
}
|
|
19086
|
+
/** there's no opening/closing tag or it's considered not breakable */
|
|
19087
|
+
|
|
19088
|
+
|
|
19089
|
+
function isTextLikeNode$1(node) {
|
|
19090
|
+
return node.type === "text" || node.type === "comment";
|
|
19091
|
+
}
|
|
19078
19092
|
|
|
19079
19093
|
function isScriptLikeTag$1(node) {
|
|
19080
19094
|
return node.type === "element" && (node.fullName === "script" || node.fullName === "style" || node.fullName === "svg:style");
|
|
@@ -19097,35 +19111,41 @@ function isIndentationSensitiveNode(node) {
|
|
|
19097
19111
|
}
|
|
19098
19112
|
|
|
19099
19113
|
function isLeadingSpaceSensitiveNode(node) {
|
|
19100
|
-
|
|
19101
|
-
return false;
|
|
19102
|
-
}
|
|
19114
|
+
var isLeadingSpaceSensitive = _isLeadingSpaceSensitiveNode();
|
|
19103
19115
|
|
|
19104
|
-
if (
|
|
19105
|
-
return
|
|
19116
|
+
if (isLeadingSpaceSensitive && !node.prev && node.parent && node.parent.tagDefinition && node.parent.tagDefinition.ignoreFirstLf) {
|
|
19117
|
+
return node.type === "interpolation";
|
|
19106
19118
|
}
|
|
19107
19119
|
|
|
19108
|
-
|
|
19109
|
-
return false;
|
|
19110
|
-
}
|
|
19120
|
+
return isLeadingSpaceSensitive;
|
|
19111
19121
|
|
|
19112
|
-
|
|
19113
|
-
|
|
19114
|
-
|
|
19122
|
+
function _isLeadingSpaceSensitiveNode() {
|
|
19123
|
+
if (isFrontMatterNode(node)) {
|
|
19124
|
+
return false;
|
|
19125
|
+
}
|
|
19115
19126
|
|
|
19116
|
-
|
|
19117
|
-
|
|
19118
|
-
|
|
19127
|
+
if ((node.type === "text" || node.type === "interpolation") && node.prev && (node.prev.type === "text" || node.prev.type === "interpolation")) {
|
|
19128
|
+
return true;
|
|
19129
|
+
}
|
|
19119
19130
|
|
|
19120
|
-
|
|
19121
|
-
|
|
19122
|
-
|
|
19131
|
+
if (!node.parent || node.parent.cssDisplay === "none") {
|
|
19132
|
+
return false;
|
|
19133
|
+
}
|
|
19123
19134
|
|
|
19124
|
-
|
|
19125
|
-
|
|
19126
|
-
|
|
19135
|
+
if (isPreLikeNode(node.parent)) {
|
|
19136
|
+
return true;
|
|
19137
|
+
}
|
|
19127
19138
|
|
|
19128
|
-
|
|
19139
|
+
if (!node.prev && (node.parent.type === "root" || isScriptLikeTag$1(node.parent) || !isFirstChildLeadingSpaceSensitiveCssDisplay(node.parent.cssDisplay))) {
|
|
19140
|
+
return false;
|
|
19141
|
+
}
|
|
19142
|
+
|
|
19143
|
+
if (node.prev && !isNextLeadingSpaceSensitiveCssDisplay(node.prev.cssDisplay)) {
|
|
19144
|
+
return false;
|
|
19145
|
+
}
|
|
19146
|
+
|
|
19147
|
+
return true;
|
|
19148
|
+
}
|
|
19129
19149
|
}
|
|
19130
19150
|
|
|
19131
19151
|
function isTrailingSpaceSensitiveNode(node) {
|
|
@@ -19141,7 +19161,7 @@ function isTrailingSpaceSensitiveNode(node) {
|
|
|
19141
19161
|
return false;
|
|
19142
19162
|
}
|
|
19143
19163
|
|
|
19144
|
-
if (isPreLikeNode
|
|
19164
|
+
if (isPreLikeNode(node.parent)) {
|
|
19145
19165
|
return true;
|
|
19146
19166
|
}
|
|
19147
19167
|
|
|
@@ -19298,7 +19318,7 @@ function isDanglingSpaceSensitiveCssDisplay(cssDisplay) {
|
|
|
19298
19318
|
return !isBlockLikeCssDisplay(cssDisplay) && cssDisplay !== "inline-block";
|
|
19299
19319
|
}
|
|
19300
19320
|
|
|
19301
|
-
function isPreLikeNode
|
|
19321
|
+
function isPreLikeNode(node) {
|
|
19302
19322
|
return getNodeCssStyleWhiteSpace(node).startsWith("pre");
|
|
19303
19323
|
}
|
|
19304
19324
|
|
|
@@ -19371,58 +19391,6 @@ function getNodeCssStyleWhiteSpace(node) {
|
|
|
19371
19391
|
return node.type === "element" && !node.namespace && CSS_WHITE_SPACE_TAGS[node.name] || CSS_WHITE_SPACE_DEFAULT;
|
|
19372
19392
|
}
|
|
19373
19393
|
|
|
19374
|
-
function getCommentData$1(node) {
|
|
19375
|
-
var rightTrimmedValue = node.value.trimRight();
|
|
19376
|
-
var hasLeadingEmptyLine = /^[^\S\n]*?\n/.test(node.value);
|
|
19377
|
-
|
|
19378
|
-
if (hasLeadingEmptyLine) {
|
|
19379
|
-
/**
|
|
19380
|
-
* <!--
|
|
19381
|
-
* 123
|
|
19382
|
-
* 456
|
|
19383
|
-
* -->
|
|
19384
|
-
*/
|
|
19385
|
-
return dedentString$1(rightTrimmedValue.replace(/^\s*\n/, ""));
|
|
19386
|
-
}
|
|
19387
|
-
/**
|
|
19388
|
-
* <!-- 123 -->
|
|
19389
|
-
*
|
|
19390
|
-
* <!-- 123
|
|
19391
|
-
* -->
|
|
19392
|
-
*
|
|
19393
|
-
* <!-- 123
|
|
19394
|
-
*
|
|
19395
|
-
* -->
|
|
19396
|
-
*/
|
|
19397
|
-
|
|
19398
|
-
|
|
19399
|
-
if (!rightTrimmedValue.includes("\n")) {
|
|
19400
|
-
return rightTrimmedValue.trimLeft();
|
|
19401
|
-
}
|
|
19402
|
-
|
|
19403
|
-
var firstNewlineIndex = rightTrimmedValue.indexOf("\n");
|
|
19404
|
-
var dataWithoutLeadingLine = rightTrimmedValue.slice(firstNewlineIndex + 1);
|
|
19405
|
-
var minIndentationForDataWithoutLeadingLine = getMinIndentation(dataWithoutLeadingLine);
|
|
19406
|
-
var leadingSpaces = rightTrimmedValue.match(/^[^\n\S]*/)[0].length;
|
|
19407
|
-
var commentDataStartColumn = node.sourceSpan.start.col + "<!--".length + leadingSpaces;
|
|
19408
|
-
/**
|
|
19409
|
-
* <!-- 123
|
|
19410
|
-
* 456 -->
|
|
19411
|
-
*/
|
|
19412
|
-
|
|
19413
|
-
if (minIndentationForDataWithoutLeadingLine >= commentDataStartColumn) {
|
|
19414
|
-
return dedentString$1(" ".repeat(commentDataStartColumn) + rightTrimmedValue.slice(leadingSpaces));
|
|
19415
|
-
}
|
|
19416
|
-
|
|
19417
|
-
var leadingLineValue = rightTrimmedValue.slice(0, firstNewlineIndex);
|
|
19418
|
-
/**
|
|
19419
|
-
* <!-- 123
|
|
19420
|
-
* 456 -->
|
|
19421
|
-
*/
|
|
19422
|
-
|
|
19423
|
-
return leadingLineValue.trim() + "\n" + dedentString$1(dataWithoutLeadingLine, minIndentationForDataWithoutLeadingLine);
|
|
19424
|
-
}
|
|
19425
|
-
|
|
19426
19394
|
function getMinIndentation(text) {
|
|
19427
19395
|
var minIndentation = Infinity;
|
|
19428
19396
|
var _iteratorNormalCompletion2 = true;
|
|
@@ -19507,8 +19475,8 @@ function identity(x) {
|
|
|
19507
19475
|
return x;
|
|
19508
19476
|
}
|
|
19509
19477
|
|
|
19510
|
-
function shouldNotPrintClosingTag$1(node) {
|
|
19511
|
-
return !node.isSelfClosing && !node.endSourceSpan && (hasPrettierIgnore$1(node) || shouldPreserveContent$1(node.parent));
|
|
19478
|
+
function shouldNotPrintClosingTag$1(node, options) {
|
|
19479
|
+
return !node.isSelfClosing && !node.endSourceSpan && (hasPrettierIgnore$1(node) || shouldPreserveContent$1(node.parent, options));
|
|
19512
19480
|
}
|
|
19513
19481
|
|
|
19514
19482
|
var utils_1$3 = {
|
|
@@ -19520,7 +19488,6 @@ var utils_1$3 = {
|
|
|
19520
19488
|
forceBreakChildren: forceBreakChildren$1,
|
|
19521
19489
|
forceBreakContent: forceBreakContent$1,
|
|
19522
19490
|
forceNextEmptyLine: forceNextEmptyLine$1,
|
|
19523
|
-
getCommentData: getCommentData$1,
|
|
19524
19491
|
getLastDescendant: getLastDescendant$1,
|
|
19525
19492
|
getNodeCssStyleDisplay: getNodeCssStyleDisplay,
|
|
19526
19493
|
getNodeCssStyleWhiteSpace: getNodeCssStyleWhiteSpace,
|
|
@@ -19532,8 +19499,9 @@ var utils_1$3 = {
|
|
|
19532
19499
|
isFrontMatterNode: isFrontMatterNode,
|
|
19533
19500
|
isIndentationSensitiveNode: isIndentationSensitiveNode,
|
|
19534
19501
|
isLeadingSpaceSensitiveNode: isLeadingSpaceSensitiveNode,
|
|
19535
|
-
isPreLikeNode: isPreLikeNode
|
|
19502
|
+
isPreLikeNode: isPreLikeNode,
|
|
19536
19503
|
isScriptLikeTag: isScriptLikeTag$1,
|
|
19504
|
+
isTextLikeNode: isTextLikeNode$1,
|
|
19537
19505
|
isTrailingSpaceSensitiveNode: isTrailingSpaceSensitiveNode,
|
|
19538
19506
|
isWhitespaceSensitiveNode: isWhitespaceSensitiveNode,
|
|
19539
19507
|
normalizeParts: normalizeParts$1,
|
|
@@ -19552,7 +19520,7 @@ var isIndentationSensitiveNode$1 = utils_1$3.isIndentationSensitiveNode;
|
|
|
19552
19520
|
var isLeadingSpaceSensitiveNode$1 = utils_1$3.isLeadingSpaceSensitiveNode;
|
|
19553
19521
|
var isTrailingSpaceSensitiveNode$1 = utils_1$3.isTrailingSpaceSensitiveNode;
|
|
19554
19522
|
var isWhitespaceSensitiveNode$1 = utils_1$3.isWhitespaceSensitiveNode;
|
|
19555
|
-
var PREPROCESS_PIPELINE = [removeIgnorableFirstLf, mergeCdataIntoText, extractInterpolation, extractWhitespaces, addCssDisplay, addIsSelfClosing, addIsSpaceSensitive, mergeSimpleElementIntoText];
|
|
19523
|
+
var PREPROCESS_PIPELINE = [removeIgnorableFirstLf, mergeIeConditonalStartEndCommentIntoElementOpeningTag, mergeCdataIntoText, extractInterpolation, extractWhitespaces, addCssDisplay, addIsSelfClosing, addHasHtmComponentClosingTag, addIsSpaceSensitive, mergeSimpleElementIntoText];
|
|
19556
19524
|
|
|
19557
19525
|
function preprocess(ast, options) {
|
|
19558
19526
|
for (var _i = 0; _i < PREPROCESS_PIPELINE.length; _i++) {
|
|
@@ -19580,6 +19548,59 @@ function removeIgnorableFirstLf(ast
|
|
|
19580
19548
|
});
|
|
19581
19549
|
}
|
|
19582
19550
|
|
|
19551
|
+
function mergeIeConditonalStartEndCommentIntoElementOpeningTag(ast
|
|
19552
|
+
/*, options */
|
|
19553
|
+
) {
|
|
19554
|
+
/**
|
|
19555
|
+
* <!--[if ...]><!--><target><!--<![endif]-->
|
|
19556
|
+
*/
|
|
19557
|
+
var isTarget = function isTarget(node) {
|
|
19558
|
+
return node.type === "element" && node.prev && node.prev.type === "ieConditionalStartComment" && node.prev.sourceSpan.end.offset === node.startSourceSpan.start.offset && node.firstChild && node.firstChild.type === "ieConditionalEndComment" && node.firstChild.sourceSpan.start.offset === node.startSourceSpan.end.offset;
|
|
19559
|
+
};
|
|
19560
|
+
|
|
19561
|
+
return ast.map(function (node) {
|
|
19562
|
+
if (node.children) {
|
|
19563
|
+
var isTargetResults = node.children.map(isTarget);
|
|
19564
|
+
|
|
19565
|
+
if (isTargetResults.some(Boolean)) {
|
|
19566
|
+
var newChildren = [];
|
|
19567
|
+
|
|
19568
|
+
for (var i = 0; i < node.children.length; i++) {
|
|
19569
|
+
var child = node.children[i];
|
|
19570
|
+
|
|
19571
|
+
if (isTargetResults[i + 1]) {
|
|
19572
|
+
// ieConditionalStartComment
|
|
19573
|
+
continue;
|
|
19574
|
+
}
|
|
19575
|
+
|
|
19576
|
+
if (isTargetResults[i]) {
|
|
19577
|
+
var ieConditionalStartComment = child.prev;
|
|
19578
|
+
var ieConditionalEndComment = child.firstChild;
|
|
19579
|
+
var ParseSourceSpan = child.sourceSpan.constructor;
|
|
19580
|
+
var startSourceSpan = new ParseSourceSpan(ieConditionalStartComment.sourceSpan.start, ieConditionalEndComment.sourceSpan.end);
|
|
19581
|
+
var sourceSpan = new ParseSourceSpan(startSourceSpan.start, child.sourceSpan.end);
|
|
19582
|
+
newChildren.push(child.clone({
|
|
19583
|
+
condition: ieConditionalStartComment.condition,
|
|
19584
|
+
sourceSpan: sourceSpan,
|
|
19585
|
+
startSourceSpan: startSourceSpan,
|
|
19586
|
+
children: child.children.slice(1)
|
|
19587
|
+
}));
|
|
19588
|
+
continue;
|
|
19589
|
+
}
|
|
19590
|
+
|
|
19591
|
+
newChildren.push(child);
|
|
19592
|
+
}
|
|
19593
|
+
|
|
19594
|
+
return node.clone({
|
|
19595
|
+
children: newChildren
|
|
19596
|
+
});
|
|
19597
|
+
}
|
|
19598
|
+
}
|
|
19599
|
+
|
|
19600
|
+
return node;
|
|
19601
|
+
});
|
|
19602
|
+
}
|
|
19603
|
+
|
|
19583
19604
|
function mergeNodeIntoText(ast, shouldMerge, getValue) {
|
|
19584
19605
|
return ast.map(function (node) {
|
|
19585
19606
|
if (node.children) {
|
|
@@ -19787,19 +19808,14 @@ function extractWhitespaces(ast
|
|
|
19787
19808
|
var isWhitespaceSensitive = isWhitespaceSensitiveNode$1(node);
|
|
19788
19809
|
var isIndentationSensitive = isIndentationSensitiveNode$1(node);
|
|
19789
19810
|
return node.clone({
|
|
19811
|
+
isWhitespaceSensitive: isWhitespaceSensitive,
|
|
19812
|
+
isIndentationSensitive: isIndentationSensitive,
|
|
19790
19813
|
children: node.children // extract whitespace nodes
|
|
19791
19814
|
.reduce(function (newChildren, child) {
|
|
19792
|
-
if (child.type !== "text") {
|
|
19815
|
+
if (child.type !== "text" || isWhitespaceSensitive) {
|
|
19793
19816
|
return newChildren.concat(child);
|
|
19794
19817
|
}
|
|
19795
19818
|
|
|
19796
|
-
if (isWhitespaceSensitive) {
|
|
19797
|
-
return newChildren.concat(Object.assign({}, child, {
|
|
19798
|
-
isWhitespaceSensitive: isWhitespaceSensitive,
|
|
19799
|
-
isIndentationSensitive: isIndentationSensitive
|
|
19800
|
-
}));
|
|
19801
|
-
}
|
|
19802
|
-
|
|
19803
19819
|
var localChildren = [];
|
|
19804
19820
|
|
|
19805
19821
|
var _child$value$match = child.value.match(/^(\s*)([\s\S]*?)(\s*)$/),
|
|
@@ -19859,6 +19875,14 @@ function addIsSelfClosing(ast
|
|
|
19859
19875
|
});
|
|
19860
19876
|
}
|
|
19861
19877
|
|
|
19878
|
+
function addHasHtmComponentClosingTag(ast, options) {
|
|
19879
|
+
return ast.map(function (node) {
|
|
19880
|
+
return node.type !== "element" ? node : Object.assign(node, {
|
|
19881
|
+
hasHtmComponentClosingTag: node.endSourceSpan && /^<\s*\/\s*\/\s*>$/.test(options.originalText.slice(node.endSourceSpan.start.offset, node.endSourceSpan.end.offset))
|
|
19882
|
+
});
|
|
19883
|
+
});
|
|
19884
|
+
}
|
|
19885
|
+
|
|
19862
19886
|
function addCssDisplay(ast, options) {
|
|
19863
19887
|
return ast.map(function (node) {
|
|
19864
19888
|
return Object.assign(node, {
|
|
@@ -19983,7 +20007,19 @@ function printVueSlotScope$1(value, textToDoc) {
|
|
|
19983
20007
|
});
|
|
19984
20008
|
}
|
|
19985
20009
|
|
|
20010
|
+
function isVueEventBindingExpression$1(eventBindingValue) {
|
|
20011
|
+
// https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/codegen/events.js#L3-L4
|
|
20012
|
+
// arrow function or anonymous function
|
|
20013
|
+
var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/; // simple member expression chain (a, a.b, a['b'], a["b"], a[0], a[b])
|
|
20014
|
+
|
|
20015
|
+
var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/; // https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/helpers.js#L104
|
|
20016
|
+
|
|
20017
|
+
var value = eventBindingValue.trim();
|
|
20018
|
+
return fnExpRE.test(value) || simplePathRE.test(value);
|
|
20019
|
+
}
|
|
20020
|
+
|
|
19986
20021
|
var syntaxVue = {
|
|
20022
|
+
isVueEventBindingExpression: isVueEventBindingExpression$1,
|
|
19987
20023
|
printVueFor: printVueFor$1,
|
|
19988
20024
|
printVueSlotScope: printVueSlotScope$1
|
|
19989
20025
|
};
|
|
@@ -20387,6 +20423,7 @@ var _require$$0$utils = doc.utils;
|
|
|
20387
20423
|
var stripTrailingHardline$1 = _require$$0$utils.stripTrailingHardline;
|
|
20388
20424
|
var mapDoc$3 = _require$$0$utils.mapDoc;
|
|
20389
20425
|
var breakParent$2 = builders.breakParent;
|
|
20426
|
+
var dedentToRoot$1 = builders.dedentToRoot;
|
|
20390
20427
|
var fill$3 = builders.fill;
|
|
20391
20428
|
var group$8 = builders.group;
|
|
20392
20429
|
var hardline$7 = builders.hardline;
|
|
@@ -20402,13 +20439,12 @@ var dedentString = utils_1$3.dedentString;
|
|
|
20402
20439
|
var forceBreakChildren = utils_1$3.forceBreakChildren;
|
|
20403
20440
|
var forceBreakContent = utils_1$3.forceBreakContent;
|
|
20404
20441
|
var forceNextEmptyLine = utils_1$3.forceNextEmptyLine;
|
|
20405
|
-
var getCommentData = utils_1$3.getCommentData;
|
|
20406
20442
|
var getLastDescendant = utils_1$3.getLastDescendant;
|
|
20407
20443
|
var getPrettierIgnoreAttributeCommentData = utils_1$3.getPrettierIgnoreAttributeCommentData;
|
|
20408
20444
|
var hasPrettierIgnore = utils_1$3.hasPrettierIgnore;
|
|
20409
20445
|
var inferScriptParser = utils_1$3.inferScriptParser;
|
|
20410
|
-
var isPreLikeNode = utils_1$3.isPreLikeNode;
|
|
20411
20446
|
var isScriptLikeTag = utils_1$3.isScriptLikeTag;
|
|
20447
|
+
var isTextLikeNode = utils_1$3.isTextLikeNode;
|
|
20412
20448
|
var normalizeParts = utils_1$3.normalizeParts;
|
|
20413
20449
|
var preferHardlineAsLeadingSpaces = utils_1$3.preferHardlineAsLeadingSpaces;
|
|
20414
20450
|
var replaceDocNewlines = utils_1$3.replaceDocNewlines;
|
|
@@ -20418,6 +20454,7 @@ var shouldPreserveContent = utils_1$3.shouldPreserveContent;
|
|
|
20418
20454
|
var insertPragma$5 = pragma$6.insertPragma;
|
|
20419
20455
|
var printVueFor = syntaxVue.printVueFor;
|
|
20420
20456
|
var printVueSlotScope = syntaxVue.printVueSlotScope;
|
|
20457
|
+
var isVueEventBindingExpression = syntaxVue.isVueEventBindingExpression;
|
|
20421
20458
|
var printImgSrcset = syntaxAttribute.printImgSrcset;
|
|
20422
20459
|
|
|
20423
20460
|
function concat$8(parts) {
|
|
@@ -20436,9 +20473,9 @@ function embed$2(path, print, textToDoc, options) {
|
|
|
20436
20473
|
|
|
20437
20474
|
if (parser) {
|
|
20438
20475
|
var value = parser === "markdown" ? dedentString(node.value.replace(/^[^\S\n]*?\n/, "")) : node.value;
|
|
20439
|
-
return builders.concat([concat$8([breakParent$2, printOpeningTagPrefix(node),
|
|
20476
|
+
return builders.concat([concat$8([breakParent$2, printOpeningTagPrefix(node, options), stripTrailingHardline$1(textToDoc(value, {
|
|
20440
20477
|
parser: parser
|
|
20441
|
-
}))
|
|
20478
|
+
})), printClosingTagSuffix(node, options)])]);
|
|
20442
20479
|
}
|
|
20443
20480
|
} else if (node.parent.type === "interpolation") {
|
|
20444
20481
|
return concat$8([indent$5(concat$8([line$6, textToDoc(node.value, options.parser === "angular" ? {
|
|
@@ -20458,6 +20495,11 @@ function embed$2(path, print, textToDoc, options) {
|
|
|
20458
20495
|
{
|
|
20459
20496
|
if (!node.value) {
|
|
20460
20497
|
break;
|
|
20498
|
+
} // lit-html: html`<my-element obj=${obj}></my-element>`
|
|
20499
|
+
|
|
20500
|
+
|
|
20501
|
+
if (/^PRETTIER_HTML_PLACEHOLDER_\d+_IN_JS$/.test(options.originalText.slice(node.valueSpan.start.offset, node.valueSpan.end.offset))) {
|
|
20502
|
+
return concat$8([node.rawName, "=", node.value]);
|
|
20461
20503
|
}
|
|
20462
20504
|
|
|
20463
20505
|
var embeddedAttributeValueDoc = printEmbeddedAttributeValue(node, function (code, opts) {
|
|
@@ -20469,9 +20511,9 @@ function embed$2(path, print, textToDoc, options) {
|
|
|
20469
20511
|
}, options);
|
|
20470
20512
|
|
|
20471
20513
|
if (embeddedAttributeValueDoc) {
|
|
20472
|
-
return concat$8([node.rawName, '="', mapDoc$3(embeddedAttributeValueDoc, function (doc$$2) {
|
|
20514
|
+
return concat$8([node.rawName, '="', group$8(mapDoc$3(embeddedAttributeValueDoc, function (doc$$2) {
|
|
20473
20515
|
return typeof doc$$2 === "string" ? doc$$2.replace(/"/g, """) : doc$$2;
|
|
20474
|
-
}), '"']);
|
|
20516
|
+
})), '"']);
|
|
20475
20517
|
}
|
|
20476
20518
|
|
|
20477
20519
|
break;
|
|
@@ -20525,11 +20567,11 @@ function genericPrint$2(path, options, print) {
|
|
|
20525
20567
|
}) : isScriptLikeTag(node) && node.parent.type === "root" && options.parser === "vue" ? childrenDoc : indent$5(childrenDoc);
|
|
20526
20568
|
}(concat$8([shouldHugContent ? ifBreak$4(softline$4, "", {
|
|
20527
20569
|
groupId: attrGroupId
|
|
20528
|
-
}) : node.firstChild.
|
|
20570
|
+
}) : node.firstChild.hasLeadingSpaces && node.firstChild.isLeadingSpaceSensitive ? line$6 : node.firstChild.type === "text" && node.isWhitespaceSensitive && node.isIndentationSensitive ? dedentToRoot$1(softline$4) : softline$4, printChildren(path, options, print)])), (node.next ? needsToBorrowPrevClosingTagEndMarker(node.next) : needsToBorrowLastChildClosingTagEndMarker(node.parent)) ? node.lastChild.hasTrailingSpaces && node.lastChild.isTrailingSpaceSensitive ? " " : "" : shouldHugContent ? ifBreak$4(softline$4, "", {
|
|
20529
20571
|
groupId: attrGroupId
|
|
20530
|
-
}) : node.lastChild.hasTrailingSpaces && node.lastChild.isTrailingSpaceSensitive ? line$6 : node.type === "
|
|
20572
|
+
}) : node.lastChild.hasTrailingSpaces && node.lastChild.isTrailingSpaceSensitive ? line$6 : (node.lastChild.type === "comment" || node.lastChild.type === "text" && node.isWhitespaceSensitive && node.isIndentationSensitive) && new RegExp("\\n\\s{".concat(options.tabWidth * countParents(path, function (n) {
|
|
20531
20573
|
return n.parent && n.parent.type !== "root";
|
|
20532
|
-
}), "}$")).test(node.lastChild.value)
|
|
20574
|
+
}), "}$")).test(node.lastChild.value) ?
|
|
20533
20575
|
/**
|
|
20534
20576
|
* <div>
|
|
20535
20577
|
* <pre>
|
|
@@ -20538,11 +20580,15 @@ function genericPrint$2(path, options, print) {
|
|
|
20538
20580
|
* ~
|
|
20539
20581
|
* </div>
|
|
20540
20582
|
*/
|
|
20541
|
-
"" : softline$4])])), printClosingTag(node)]);
|
|
20583
|
+
"" : softline$4])])), printClosingTag(node, options)]);
|
|
20542
20584
|
}
|
|
20543
20585
|
|
|
20586
|
+
case "ieConditionalStartComment":
|
|
20587
|
+
case "ieConditionalEndComment":
|
|
20588
|
+
return concat$8([printOpeningTagStart(node), printClosingTagEnd(node)]);
|
|
20589
|
+
|
|
20544
20590
|
case "interpolation":
|
|
20545
|
-
return concat$8([printOpeningTagStart(node), concat$8(path.map(print, "children")), printClosingTagEnd(node)]);
|
|
20591
|
+
return concat$8([printOpeningTagStart(node, options), concat$8(path.map(print, "children")), printClosingTagEnd(node, options)]);
|
|
20546
20592
|
|
|
20547
20593
|
case "text":
|
|
20548
20594
|
{
|
|
@@ -20554,17 +20600,15 @@ function genericPrint$2(path, options, print) {
|
|
|
20554
20600
|
return concat$8([concat$8(replaceNewlines(value, literalline$2)), hasTrailingNewline ? hardline$7 : ""]);
|
|
20555
20601
|
}
|
|
20556
20602
|
|
|
20557
|
-
return fill$3(normalizeParts([].concat(printOpeningTagPrefix(node), getTextValueParts(node), printClosingTagSuffix(node))));
|
|
20603
|
+
return fill$3(normalizeParts([].concat(printOpeningTagPrefix(node, options), getTextValueParts(node), printClosingTagSuffix(node, options))));
|
|
20558
20604
|
}
|
|
20559
20605
|
|
|
20560
20606
|
case "docType":
|
|
20561
|
-
return concat$8([group$8(concat$8([printOpeningTagStart(node), " ", node.value.replace(/^html\b/i, "html").replace(/\s+/g, " ")])), printClosingTagEnd(node)]);
|
|
20607
|
+
return concat$8([group$8(concat$8([printOpeningTagStart(node, options), " ", node.value.replace(/^html\b/i, "html").replace(/\s+/g, " ")])), printClosingTagEnd(node, options)]);
|
|
20562
20608
|
|
|
20563
20609
|
case "comment":
|
|
20564
20610
|
{
|
|
20565
|
-
|
|
20566
|
-
|
|
20567
|
-
return concat$8([group$8(concat$8([printOpeningTagStart(node), _value.trim().length === 0 ? "" : concat$8([indent$5(concat$8([node.prev && needsToBorrowNextOpeningTagStartMarker(node.prev) ? breakParent$2 : "", line$6, concat$8(replaceNewlines(_value, hardline$7))])), (node.next ? needsToBorrowPrevClosingTagEndMarker(node.next) : needsToBorrowLastChildClosingTagEndMarker(node.parent)) ? " " : line$6])])), printClosingTagEnd(node)]);
|
|
20611
|
+
return concat$8([printOpeningTagPrefix(node, options), concat$8(replaceNewlines(options.originalText.slice(options.locStart(node), options.locEnd(node)), literalline$2)), printClosingTagSuffix(node, options)]);
|
|
20568
20612
|
}
|
|
20569
20613
|
|
|
20570
20614
|
case "attribute":
|
|
@@ -20596,7 +20640,19 @@ function printChildren(path, options, print) {
|
|
|
20596
20640
|
return concat$8(path.map(function (childPath, childIndex) {
|
|
20597
20641
|
var childNode = childPath.getValue();
|
|
20598
20642
|
|
|
20599
|
-
if (childNode
|
|
20643
|
+
if (isTextLikeNode(childNode)) {
|
|
20644
|
+
if (childNode.prev && isTextLikeNode(childNode.prev)) {
|
|
20645
|
+
var _prevBetweenLine = printBetweenLine(childNode.prev, childNode);
|
|
20646
|
+
|
|
20647
|
+
if (_prevBetweenLine) {
|
|
20648
|
+
if (forceNextEmptyLine(childNode.prev)) {
|
|
20649
|
+
return concat$8([hardline$7, hardline$7, printChild(childPath)]);
|
|
20650
|
+
}
|
|
20651
|
+
|
|
20652
|
+
return concat$8([_prevBetweenLine, printChild(childPath)]);
|
|
20653
|
+
}
|
|
20654
|
+
}
|
|
20655
|
+
|
|
20600
20656
|
return printChild(childPath);
|
|
20601
20657
|
}
|
|
20602
20658
|
|
|
@@ -20613,7 +20669,7 @@ function printChildren(path, options, print) {
|
|
|
20613
20669
|
} else if (prevBetweenLine === hardline$7) {
|
|
20614
20670
|
prevParts.push(hardline$7);
|
|
20615
20671
|
} else {
|
|
20616
|
-
if (childNode.prev
|
|
20672
|
+
if (isTextLikeNode(childNode.prev)) {
|
|
20617
20673
|
leadingParts.push(prevBetweenLine);
|
|
20618
20674
|
} else {
|
|
20619
20675
|
leadingParts.push(ifBreak$4("", softline$4, {
|
|
@@ -20625,11 +20681,11 @@ function printChildren(path, options, print) {
|
|
|
20625
20681
|
|
|
20626
20682
|
if (nextBetweenLine) {
|
|
20627
20683
|
if (forceNextEmptyLine(childNode)) {
|
|
20628
|
-
if (childNode.next
|
|
20684
|
+
if (isTextLikeNode(childNode.next)) {
|
|
20629
20685
|
nextParts.push(hardline$7, hardline$7);
|
|
20630
20686
|
}
|
|
20631
20687
|
} else if (nextBetweenLine === hardline$7) {
|
|
20632
|
-
if (childNode.next
|
|
20688
|
+
if (isTextLikeNode(childNode.next)) {
|
|
20633
20689
|
nextParts.push(hardline$7);
|
|
20634
20690
|
}
|
|
20635
20691
|
} else {
|
|
@@ -20646,18 +20702,18 @@ function printChildren(path, options, print) {
|
|
|
20646
20702
|
var child = childPath.getValue();
|
|
20647
20703
|
|
|
20648
20704
|
if (hasPrettierIgnore(child)) {
|
|
20649
|
-
return concat$8([].concat(printOpeningTagPrefix(child), replaceNewlines(options.originalText.slice(options.locStart(child) + (child.prev && needsToBorrowNextOpeningTagStartMarker(child.prev) ? printOpeningTagStartMarker(child).length : 0), options.locEnd(child) - (child.next && needsToBorrowPrevClosingTagEndMarker(child.next) ? printClosingTagEndMarker(child).length : 0)), literalline$2), printClosingTagSuffix(child)));
|
|
20705
|
+
return concat$8([].concat(printOpeningTagPrefix(child, options), replaceNewlines(options.originalText.slice(options.locStart(child) + (child.prev && needsToBorrowNextOpeningTagStartMarker(child.prev) ? printOpeningTagStartMarker(child).length : 0), options.locEnd(child) - (child.next && needsToBorrowPrevClosingTagEndMarker(child.next) ? printClosingTagEndMarker(child, options).length : 0)), literalline$2), printClosingTagSuffix(child, options)));
|
|
20650
20706
|
}
|
|
20651
20707
|
|
|
20652
|
-
if (shouldPreserveContent(child)) {
|
|
20653
|
-
return concat$8([].concat(printOpeningTagPrefix(child), group$8(printOpeningTag(childPath, options, print)), replaceNewlines(options.originalText.slice(child.startSourceSpan.end.offset
|
|
20708
|
+
if (shouldPreserveContent(child, options)) {
|
|
20709
|
+
return concat$8([].concat(printOpeningTagPrefix(child, options), group$8(printOpeningTag(childPath, options, print)), replaceNewlines(options.originalText.slice(child.startSourceSpan.end.offset + (child.firstChild && needsToBorrowParentOpeningTagEndMarker(child.firstChild) ? -printOpeningTagEndMarker(child).length : 0), child.endSourceSpan.start.offset + (child.lastChild && needsToBorrowParentClosingTagStartMarker(child.lastChild) ? printClosingTagStartMarker(child, options).length : needsToBorrowLastChildClosingTagEndMarker(child) ? -printClosingTagEndMarker(child.lastChild, options).length : 0)), literalline$2), printClosingTag(child, options), printClosingTagSuffix(child, options)));
|
|
20654
20710
|
}
|
|
20655
20711
|
|
|
20656
20712
|
return print(childPath);
|
|
20657
20713
|
}
|
|
20658
20714
|
|
|
20659
20715
|
function printBetweenLine(prevNode, nextNode) {
|
|
20660
|
-
return needsToBorrowNextOpeningTagStartMarker(prevNode) && (
|
|
20716
|
+
return isTextLikeNode(prevNode) && isTextLikeNode(nextNode) ? prevNode.isTrailingSpaceSensitive ? prevNode.hasTrailingSpaces ? preferHardlineAsLeadingSpaces(nextNode) ? hardline$7 : line$6 : "" : preferHardlineAsLeadingSpaces(nextNode) ? hardline$7 : softline$4 : needsToBorrowNextOpeningTagStartMarker(prevNode) && (
|
|
20661
20717
|
/**
|
|
20662
20718
|
* 123<a
|
|
20663
20719
|
* ~
|
|
@@ -20696,7 +20752,7 @@ function printChildren(path, options, print) {
|
|
|
20696
20752
|
function printOpeningTag(path, options, print) {
|
|
20697
20753
|
var node = path.getValue();
|
|
20698
20754
|
var forceNotToBreakAttrContent = node.type === "element" && node.fullName === "script" && node.attrs.length === 1 && node.attrs[0].fullName === "src" && node.children.length === 0;
|
|
20699
|
-
return concat$8([printOpeningTagStart(node), !node.attrs || node.attrs.length === 0 ? node.isSelfClosing ?
|
|
20755
|
+
return concat$8([printOpeningTagStart(node, options), !node.attrs || node.attrs.length === 0 ? node.isSelfClosing ?
|
|
20700
20756
|
/**
|
|
20701
20757
|
* <br />
|
|
20702
20758
|
* ^
|
|
@@ -20730,24 +20786,24 @@ function printOpeningTag(path, options, print) {
|
|
|
20730
20786
|
node.isSelfClosing && needsToBorrowLastChildClosingTagEndMarker(node.parent) ? "" : node.isSelfClosing ? forceNotToBreakAttrContent ? " " : line$6 : forceNotToBreakAttrContent ? "" : softline$4]), node.isSelfClosing ? "" : printOpeningTagEnd(node)]);
|
|
20731
20787
|
}
|
|
20732
20788
|
|
|
20733
|
-
function printOpeningTagStart(node) {
|
|
20734
|
-
return node.prev && needsToBorrowNextOpeningTagStartMarker(node.prev) ? "" : concat$8([printOpeningTagPrefix(node), printOpeningTagStartMarker(node)]);
|
|
20789
|
+
function printOpeningTagStart(node, options) {
|
|
20790
|
+
return node.prev && needsToBorrowNextOpeningTagStartMarker(node.prev) ? "" : concat$8([printOpeningTagPrefix(node, options), printOpeningTagStartMarker(node)]);
|
|
20735
20791
|
}
|
|
20736
20792
|
|
|
20737
20793
|
function printOpeningTagEnd(node) {
|
|
20738
20794
|
return node.firstChild && needsToBorrowParentOpeningTagEndMarker(node.firstChild) ? "" : printOpeningTagEndMarker(node);
|
|
20739
20795
|
}
|
|
20740
20796
|
|
|
20741
|
-
function printClosingTag(node) {
|
|
20742
|
-
return concat$8([node.isSelfClosing ? "" : printClosingTagStart(node), printClosingTagEnd(node)]);
|
|
20797
|
+
function printClosingTag(node, options) {
|
|
20798
|
+
return concat$8([node.isSelfClosing ? "" : printClosingTagStart(node, options), printClosingTagEnd(node, options)]);
|
|
20743
20799
|
}
|
|
20744
20800
|
|
|
20745
|
-
function printClosingTagStart(node) {
|
|
20746
|
-
return node.lastChild && needsToBorrowParentClosingTagStartMarker(node.lastChild) ? "" : concat$8([printClosingTagPrefix(node), printClosingTagStartMarker(node)]);
|
|
20801
|
+
function printClosingTagStart(node, options) {
|
|
20802
|
+
return node.lastChild && needsToBorrowParentClosingTagStartMarker(node.lastChild) ? "" : concat$8([printClosingTagPrefix(node, options), printClosingTagStartMarker(node, options)]);
|
|
20747
20803
|
}
|
|
20748
20804
|
|
|
20749
|
-
function printClosingTagEnd(node) {
|
|
20750
|
-
return (node.next ? needsToBorrowPrevClosingTagEndMarker(node.next) : needsToBorrowLastChildClosingTagEndMarker(node.parent)) ? "" : concat$8([printClosingTagEndMarker(node), printClosingTagSuffix(node)]);
|
|
20805
|
+
function printClosingTagEnd(node, options) {
|
|
20806
|
+
return (node.next ? needsToBorrowPrevClosingTagEndMarker(node.next) : needsToBorrowLastChildClosingTagEndMarker(node.parent)) ? "" : concat$8([printClosingTagEndMarker(node, options), printClosingTagSuffix(node, options)]);
|
|
20751
20807
|
}
|
|
20752
20808
|
|
|
20753
20809
|
function needsToBorrowNextOpeningTagStartMarker(node) {
|
|
@@ -20756,7 +20812,7 @@ function needsToBorrowNextOpeningTagStartMarker(node) {
|
|
|
20756
20812
|
* ^^
|
|
20757
20813
|
* >
|
|
20758
20814
|
*/
|
|
20759
|
-
return node.next && node.
|
|
20815
|
+
return node.next && !isTextLikeNode(node.next) && isTextLikeNode(node) && node.isTrailingSpaceSensitive && !node.hasTrailingSpaces;
|
|
20760
20816
|
}
|
|
20761
20817
|
|
|
20762
20818
|
function needsToBorrowParentOpeningTagEndMarker(node) {
|
|
@@ -20782,7 +20838,7 @@ function needsToBorrowPrevClosingTagEndMarker(node) {
|
|
|
20782
20838
|
* ><a
|
|
20783
20839
|
* ^
|
|
20784
20840
|
*/
|
|
20785
|
-
return node.prev && node.isLeadingSpaceSensitive && !node.hasLeadingSpaces;
|
|
20841
|
+
return node.prev && !isTextLikeNode(node.prev) && node.isLeadingSpaceSensitive && !node.hasLeadingSpaces;
|
|
20786
20842
|
}
|
|
20787
20843
|
|
|
20788
20844
|
function needsToBorrowLastChildClosingTagEndMarker(node) {
|
|
@@ -20793,7 +20849,7 @@ function needsToBorrowLastChildClosingTagEndMarker(node) {
|
|
|
20793
20849
|
* ^
|
|
20794
20850
|
* >
|
|
20795
20851
|
*/
|
|
20796
|
-
return node.lastChild && node.lastChild.isTrailingSpaceSensitive && !node.lastChild.hasTrailingSpaces && getLastDescendant(node.lastChild)
|
|
20852
|
+
return node.lastChild && node.lastChild.isTrailingSpaceSensitive && !node.lastChild.hasTrailingSpaces && !isTextLikeNode(getLastDescendant(node.lastChild));
|
|
20797
20853
|
}
|
|
20798
20854
|
|
|
20799
20855
|
function needsToBorrowParentClosingTagStartMarker(node) {
|
|
@@ -20808,35 +20864,43 @@ function needsToBorrowParentClosingTagStartMarker(node) {
|
|
|
20808
20864
|
* ^^^
|
|
20809
20865
|
* >
|
|
20810
20866
|
*/
|
|
20811
|
-
return !node.next && !node.hasTrailingSpaces && node.isTrailingSpaceSensitive && getLastDescendant(node)
|
|
20867
|
+
return !node.next && !node.hasTrailingSpaces && node.isTrailingSpaceSensitive && isTextLikeNode(getLastDescendant(node));
|
|
20812
20868
|
}
|
|
20813
20869
|
|
|
20814
|
-
function printOpeningTagPrefix(node) {
|
|
20815
|
-
return needsToBorrowParentOpeningTagEndMarker(node) ? printOpeningTagEndMarker(node.parent) : needsToBorrowPrevClosingTagEndMarker(node) ? printClosingTagEndMarker(node.prev) : "";
|
|
20870
|
+
function printOpeningTagPrefix(node, options) {
|
|
20871
|
+
return needsToBorrowParentOpeningTagEndMarker(node) ? printOpeningTagEndMarker(node.parent) : needsToBorrowPrevClosingTagEndMarker(node) ? printClosingTagEndMarker(node.prev, options) : "";
|
|
20816
20872
|
}
|
|
20817
20873
|
|
|
20818
|
-
function printClosingTagPrefix(node) {
|
|
20819
|
-
return needsToBorrowLastChildClosingTagEndMarker(node) ? printClosingTagEndMarker(node.lastChild) : "";
|
|
20874
|
+
function printClosingTagPrefix(node, options) {
|
|
20875
|
+
return needsToBorrowLastChildClosingTagEndMarker(node) ? printClosingTagEndMarker(node.lastChild, options) : "";
|
|
20820
20876
|
}
|
|
20821
20877
|
|
|
20822
|
-
function printClosingTagSuffix(node) {
|
|
20823
|
-
return needsToBorrowParentClosingTagStartMarker(node) ? printClosingTagStartMarker(node.parent) : needsToBorrowNextOpeningTagStartMarker(node) ? printOpeningTagStartMarker(node.next) : "";
|
|
20878
|
+
function printClosingTagSuffix(node, options) {
|
|
20879
|
+
return needsToBorrowParentClosingTagStartMarker(node) ? printClosingTagStartMarker(node.parent, options) : needsToBorrowNextOpeningTagStartMarker(node) ? printOpeningTagStartMarker(node.next) : "";
|
|
20824
20880
|
}
|
|
20825
20881
|
|
|
20826
20882
|
function printOpeningTagStartMarker(node) {
|
|
20827
20883
|
switch (node.type) {
|
|
20828
|
-
case "comment":
|
|
20829
|
-
return "<!--";
|
|
20830
|
-
|
|
20831
20884
|
case "ieConditionalComment":
|
|
20885
|
+
case "ieConditionalStartComment":
|
|
20832
20886
|
return "<!--[if ".concat(node.condition);
|
|
20833
20887
|
|
|
20888
|
+
case "ieConditionalEndComment":
|
|
20889
|
+
return "<!--<!";
|
|
20890
|
+
|
|
20834
20891
|
case "interpolation":
|
|
20835
20892
|
return "{{";
|
|
20836
20893
|
|
|
20837
20894
|
case "docType":
|
|
20838
20895
|
return "<!DOCTYPE";
|
|
20839
20896
|
|
|
20897
|
+
case "element":
|
|
20898
|
+
if (node.condition) {
|
|
20899
|
+
return "<!--[if ".concat(node.condition, "]><!--><").concat(node.rawName);
|
|
20900
|
+
}
|
|
20901
|
+
|
|
20902
|
+
// fall through
|
|
20903
|
+
|
|
20840
20904
|
default:
|
|
20841
20905
|
return "<".concat(node.rawName);
|
|
20842
20906
|
}
|
|
@@ -20849,15 +20913,22 @@ function printOpeningTagEndMarker(node) {
|
|
|
20849
20913
|
case "ieConditionalComment":
|
|
20850
20914
|
return "]>";
|
|
20851
20915
|
|
|
20916
|
+
case "element":
|
|
20917
|
+
if (node.condition) {
|
|
20918
|
+
return "><!--<![endif]-->";
|
|
20919
|
+
}
|
|
20920
|
+
|
|
20921
|
+
// fall through
|
|
20922
|
+
|
|
20852
20923
|
default:
|
|
20853
20924
|
return ">";
|
|
20854
20925
|
}
|
|
20855
20926
|
}
|
|
20856
20927
|
|
|
20857
|
-
function printClosingTagStartMarker(node) {
|
|
20928
|
+
function printClosingTagStartMarker(node, options) {
|
|
20858
20929
|
assert$3(!node.isSelfClosing);
|
|
20859
20930
|
|
|
20860
|
-
if (shouldNotPrintClosingTag(node)) {
|
|
20931
|
+
if (shouldNotPrintClosingTag(node, options)) {
|
|
20861
20932
|
return "";
|
|
20862
20933
|
}
|
|
20863
20934
|
|
|
@@ -20865,23 +20936,31 @@ function printClosingTagStartMarker(node) {
|
|
|
20865
20936
|
case "ieConditionalComment":
|
|
20866
20937
|
return "<!";
|
|
20867
20938
|
|
|
20939
|
+
case "element":
|
|
20940
|
+
if (node.hasHtmComponentClosingTag) {
|
|
20941
|
+
return "<//";
|
|
20942
|
+
}
|
|
20943
|
+
|
|
20944
|
+
// fall through
|
|
20945
|
+
|
|
20868
20946
|
default:
|
|
20869
20947
|
return "</".concat(node.rawName);
|
|
20870
20948
|
}
|
|
20871
20949
|
}
|
|
20872
20950
|
|
|
20873
|
-
function printClosingTagEndMarker(node) {
|
|
20874
|
-
if (shouldNotPrintClosingTag(node)) {
|
|
20951
|
+
function printClosingTagEndMarker(node, options) {
|
|
20952
|
+
if (shouldNotPrintClosingTag(node, options)) {
|
|
20875
20953
|
return "";
|
|
20876
20954
|
}
|
|
20877
20955
|
|
|
20878
20956
|
switch (node.type) {
|
|
20879
|
-
case "comment":
|
|
20880
|
-
return "-->";
|
|
20881
|
-
|
|
20882
20957
|
case "ieConditionalComment":
|
|
20958
|
+
case "ieConditionalEndComment":
|
|
20883
20959
|
return "[endif]-->";
|
|
20884
20960
|
|
|
20961
|
+
case "ieConditionalStartComment":
|
|
20962
|
+
return "]><!-->";
|
|
20963
|
+
|
|
20885
20964
|
case "interpolation":
|
|
20886
20965
|
return "}}";
|
|
20887
20966
|
|
|
@@ -20899,7 +20978,7 @@ function printClosingTagEndMarker(node) {
|
|
|
20899
20978
|
|
|
20900
20979
|
function getTextValueParts(node) {
|
|
20901
20980
|
var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : node.value;
|
|
20902
|
-
return node.isWhitespaceSensitive ? node.isIndentationSensitive ? replaceNewlines(value, literalline$2) : replaceNewlines(dedentString(value.replace(/^\s*?\n|\n\s*?$/g, "")), hardline$7) : // non-breaking whitespace: 0xA0
|
|
20981
|
+
return node.parent.isWhitespaceSensitive ? node.parent.isIndentationSensitive ? replaceNewlines(value, literalline$2) : replaceNewlines(dedentString(value.replace(/^\s*?\n|\n\s*?$/g, "")), hardline$7) : // non-breaking whitespace: 0xA0
|
|
20903
20982
|
join$5(line$6, value.split(/[^\S\xA0]+/)).parts;
|
|
20904
20983
|
}
|
|
20905
20984
|
|
|
@@ -20974,15 +21053,11 @@ function printEmbeddedAttributeValue(node, originalTextToDoc, options) {
|
|
|
20974
21053
|
var jsExpressionBindingPatterns = ["^v-"];
|
|
20975
21054
|
|
|
20976
21055
|
if (isKeyMatched(vueEventBindingPatterns)) {
|
|
20977
|
-
|
|
20978
|
-
|
|
20979
|
-
var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
|
|
20980
|
-
var value = getValue() // https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/helpers.js#L104
|
|
20981
|
-
.trim();
|
|
20982
|
-
return printMaybeHug(simplePathRE.test(value) || fnExpRE.test(value) ? textToDoc(value, {
|
|
21056
|
+
var value = getValue();
|
|
21057
|
+
return printMaybeHug(isVueEventBindingExpression(value) ? textToDoc(value, {
|
|
20983
21058
|
parser: "__js_expression"
|
|
20984
21059
|
}) : stripTrailingHardline$1(textToDoc(value, {
|
|
20985
|
-
parser: "
|
|
21060
|
+
parser: "__vue_event_binding"
|
|
20986
21061
|
})));
|
|
20987
21062
|
}
|
|
20988
21063
|
|
|
@@ -21045,6 +21120,30 @@ function printEmbeddedAttributeValue(node, originalTextToDoc, options) {
|
|
|
21045
21120
|
parser: "__ng_directive"
|
|
21046
21121
|
}));
|
|
21047
21122
|
}
|
|
21123
|
+
|
|
21124
|
+
var interpolationRegex = /\{\{([\s\S]+?)\}\}/g;
|
|
21125
|
+
|
|
21126
|
+
var _value = getValue();
|
|
21127
|
+
|
|
21128
|
+
if (interpolationRegex.test(_value)) {
|
|
21129
|
+
var parts = [];
|
|
21130
|
+
|
|
21131
|
+
_value.split(interpolationRegex).forEach(function (part, index) {
|
|
21132
|
+
if (index % 2 === 0) {
|
|
21133
|
+
parts.push(concat$8(replaceNewlines(part, literalline$2)));
|
|
21134
|
+
} else {
|
|
21135
|
+
try {
|
|
21136
|
+
parts.push(group$8(concat$8(["{{", indent$5(concat$8([line$6, ngTextToDoc(part, {
|
|
21137
|
+
parser: "__ng_interpolation"
|
|
21138
|
+
})])), line$6, "}}"])));
|
|
21139
|
+
} catch (e) {
|
|
21140
|
+
parts.push("{{", concat$8(replaceNewlines(part, literalline$2)), "}}");
|
|
21141
|
+
}
|
|
21142
|
+
}
|
|
21143
|
+
});
|
|
21144
|
+
|
|
21145
|
+
return group$8(concat$8(parts));
|
|
21146
|
+
}
|
|
21048
21147
|
}
|
|
21049
21148
|
|
|
21050
21149
|
return null;
|
|
@@ -21188,7 +21287,7 @@ var softline$6 = _require$$0$builders$6.softline;
|
|
|
21188
21287
|
var literalline$4 = _require$$0$builders$6.literalline;
|
|
21189
21288
|
var concat$13 = _require$$0$builders$6.concat;
|
|
21190
21289
|
var group$11 = _require$$0$builders$6.group;
|
|
21191
|
-
var dedentToRoot$
|
|
21290
|
+
var dedentToRoot$2 = _require$$0$builders$6.dedentToRoot;
|
|
21192
21291
|
var _require$$0$utils$1 = doc.utils;
|
|
21193
21292
|
var mapDoc$5 = _require$$0$utils$1.mapDoc;
|
|
21194
21293
|
var stripTrailingHardline$2 = _require$$0$utils$1.stripTrailingHardline;
|
|
@@ -21325,7 +21424,7 @@ function embed$4(path, print, textToDoc
|
|
|
21325
21424
|
|
|
21326
21425
|
var indentation = getIndentation(_text2);
|
|
21327
21426
|
var hasIndent = indentation !== "";
|
|
21328
|
-
return concat$13([hasIndent ? indent$7(concat$13([softline$6, printMarkdown(_text2.replace(new RegExp("^".concat(indentation), "gm"), ""))])) : concat$13([literalline$4, dedentToRoot$
|
|
21427
|
+
return concat$13([hasIndent ? indent$7(concat$13([softline$6, printMarkdown(_text2.replace(new RegExp("^".concat(indentation), "gm"), ""))])) : concat$13([literalline$4, dedentToRoot$2(printMarkdown(_text2))]), softline$6]);
|
|
21329
21428
|
}
|
|
21330
21429
|
|
|
21331
21430
|
break;
|
|
@@ -21669,9 +21768,9 @@ function isHtml(path) {
|
|
|
21669
21768
|
|
|
21670
21769
|
function printHtmlTemplateLiteral(path, print, textToDoc, parser) {
|
|
21671
21770
|
var node = path.getValue();
|
|
21672
|
-
var placeholderPattern = "
|
|
21771
|
+
var placeholderPattern = "PRETTIER_HTML_PLACEHOLDER_(\\d+)_IN_JS";
|
|
21673
21772
|
var placeholders = node.expressions.map(function (_, i) {
|
|
21674
|
-
return "
|
|
21773
|
+
return "PRETTIER_HTML_PLACEHOLDER_".concat(i, "_IN_JS");
|
|
21675
21774
|
});
|
|
21676
21775
|
var text = node.quasis.map(function (quasi, index, quasis) {
|
|
21677
21776
|
return index === quasis.length - 1 ? quasi.value.raw : quasi.value.raw + placeholders[index];
|
|
@@ -22589,6 +22688,7 @@ function needsParens(path, options) {
|
|
|
22589
22688
|
return true;
|
|
22590
22689
|
|
|
22591
22690
|
case "MemberExpression":
|
|
22691
|
+
case "OptionalMemberExpression":
|
|
22592
22692
|
return name === "object" && parent.object === node;
|
|
22593
22693
|
|
|
22594
22694
|
case "AssignmentExpression":
|
|
@@ -22938,9 +23038,31 @@ function printHtmlBinding$1(path, options, print) {
|
|
|
22938
23038
|
return join$9(concat$14([",", line$9]), functionDeclarationPath.map(print, "params"));
|
|
22939
23039
|
}, "program", "body", 0);
|
|
22940
23040
|
}
|
|
23041
|
+
} // based on https://github.com/prettier/prettier/blob/master/src/language-html/syntax-vue.js isVueEventBindingExpression()
|
|
23042
|
+
|
|
23043
|
+
|
|
23044
|
+
function isVueEventBindingExpression$3(node) {
|
|
23045
|
+
switch (node.type) {
|
|
23046
|
+
case "MemberExpression":
|
|
23047
|
+
switch (node.property.type) {
|
|
23048
|
+
case "Identifier":
|
|
23049
|
+
case "NumericLiteral":
|
|
23050
|
+
case "StringLiteral":
|
|
23051
|
+
return isVueEventBindingExpression$3(node.object);
|
|
23052
|
+
}
|
|
23053
|
+
|
|
23054
|
+
return false;
|
|
23055
|
+
|
|
23056
|
+
case "Identifier":
|
|
23057
|
+
return true;
|
|
23058
|
+
|
|
23059
|
+
default:
|
|
23060
|
+
return false;
|
|
23061
|
+
}
|
|
22941
23062
|
}
|
|
22942
23063
|
|
|
22943
23064
|
var htmlBinding = {
|
|
23065
|
+
isVueEventBindingExpression: isVueEventBindingExpression$3,
|
|
22944
23066
|
printHtmlBinding: printHtmlBinding$1
|
|
22945
23067
|
};
|
|
22946
23068
|
|
|
@@ -22988,6 +23110,7 @@ var getNextNonSpaceNonCommentCharacterIndex$2 = utilShared.getNextNonSpaceNonCom
|
|
|
22988
23110
|
var isIdentifierName = utils$2.keyword.isIdentifierNameES5;
|
|
22989
23111
|
var insertPragma$7 = pragma$2.insertPragma;
|
|
22990
23112
|
var printHtmlBinding = htmlBinding.printHtmlBinding;
|
|
23113
|
+
var isVueEventBindingExpression$2 = htmlBinding.isVueEventBindingExpression;
|
|
22991
23114
|
var hasNode = utils$6.hasNode;
|
|
22992
23115
|
var hasFlowAnnotationComment = utils$6.hasFlowAnnotationComment;
|
|
22993
23116
|
var hasFlowShorthandAnnotationComment = utils$6.hasFlowShorthandAnnotationComment;
|
|
@@ -23052,7 +23175,7 @@ function genericPrint$3(path, options, printPath, args) {
|
|
|
23052
23175
|
var parentExportDecl = getParentExportDeclaration$1(path);
|
|
23053
23176
|
var decorators = [];
|
|
23054
23177
|
|
|
23055
|
-
if (node.type === "ClassMethod" || node.type === "ClassProperty" || node.type === "TSAbstractClassProperty" || node.type === "ClassPrivateProperty") {// their decorators are handled themselves
|
|
23178
|
+
if (node.type === "ClassMethod" || node.type === "ClassProperty" || node.type === "TSAbstractClassProperty" || node.type === "ClassPrivateProperty" || node.type === "MethodDefinition" || node.type === "TSAbstractMethodDefinition") {// their decorators are handled themselves
|
|
23056
23179
|
} else if (node.decorators && node.decorators.length > 0 && // If the parent node is an export declaration and the decorator
|
|
23057
23180
|
// was written before the export, the export will be responsible
|
|
23058
23181
|
// for printing the decorators.
|
|
@@ -23346,6 +23469,14 @@ function printPathNoParens(path, options, print, args) {
|
|
|
23346
23469
|
// Detect Flow-parsed directives
|
|
23347
23470
|
if (n.directive) {
|
|
23348
23471
|
return concat$12([nodeStr(n.expression, options, true), semi]);
|
|
23472
|
+
}
|
|
23473
|
+
|
|
23474
|
+
if (options.parser === "__vue_event_binding") {
|
|
23475
|
+
var parent = path.getParentNode();
|
|
23476
|
+
|
|
23477
|
+
if (parent.type === "Program" && parent.body.length === 1 && parent.body[0] === n) {
|
|
23478
|
+
return concat$12([path.call(print, "expression"), isVueEventBindingExpression$2(n.expression) ? ";" : ""]);
|
|
23479
|
+
}
|
|
23349
23480
|
} // Do not append semicolon after the only JSX element in a program
|
|
23350
23481
|
|
|
23351
23482
|
|
|
@@ -23362,9 +23493,10 @@ function printPathNoParens(path, options, print, args) {
|
|
|
23362
23493
|
case "LogicalExpression":
|
|
23363
23494
|
case "NGPipeExpression":
|
|
23364
23495
|
{
|
|
23365
|
-
var
|
|
23496
|
+
var _parent = path.getParentNode();
|
|
23497
|
+
|
|
23366
23498
|
var parentParent = path.getParentNode(1);
|
|
23367
|
-
var isInsideParenthesis = n !==
|
|
23499
|
+
var isInsideParenthesis = n !== _parent.body && (_parent.type === "IfStatement" || _parent.type === "WhileStatement" || _parent.type === "DoWhileStatement");
|
|
23368
23500
|
|
|
23369
23501
|
var _parts = printBinaryishExpressions(path, print, options,
|
|
23370
23502
|
/* isNested */
|
|
@@ -23391,14 +23523,14 @@ function printPathNoParens(path, options, print, args) {
|
|
|
23391
23523
|
// ).call()
|
|
23392
23524
|
|
|
23393
23525
|
|
|
23394
|
-
if (
|
|
23526
|
+
if (_parent.type === "UnaryExpression" || (_parent.type === "MemberExpression" || _parent.type === "OptionalMemberExpression") && !_parent.computed) {
|
|
23395
23527
|
return group$10(concat$12([indent$6(concat$12([softline$5, concat$12(_parts)])), softline$5]));
|
|
23396
23528
|
} // Avoid indenting sub-expressions in some cases where the first sub-expression is already
|
|
23397
23529
|
// indented accordingly. We should indent sub-expressions where the first case isn't indented.
|
|
23398
23530
|
|
|
23399
23531
|
|
|
23400
|
-
var shouldNotIndent =
|
|
23401
|
-
var shouldIndentIfInlining =
|
|
23532
|
+
var shouldNotIndent = _parent.type === "ReturnStatement" || _parent.type === "JSXExpressionContainer" && parentParent.type === "JSXAttribute" || n.type !== "NGPipeExpression" && (_parent.type === "NGRoot" && options.parser === "__ng_binding" || _parent.type === "NGMicrosyntaxExpression" && parentParent.type === "NGMicrosyntax" && parentParent.body.length === 1) || n === _parent.body && _parent.type === "ArrowFunctionExpression" || n !== _parent.body && _parent.type === "ForStatement" || _parent.type === "ConditionalExpression" && parentParent.type !== "ReturnStatement" && parentParent.type !== "CallExpression";
|
|
23533
|
+
var shouldIndentIfInlining = _parent.type === "AssignmentExpression" || _parent.type === "VariableDeclarator" || _parent.type === "ClassProperty" || _parent.type === "TSAbstractClassProperty" || _parent.type === "ClassPrivateProperty" || _parent.type === "ObjectProperty" || _parent.type === "Property";
|
|
23402
23534
|
var samePrecedenceSubExpression = isBinaryish(n.left) && shouldFlatten$1(n.operator, n.left.operator);
|
|
23403
23535
|
|
|
23404
23536
|
if (shouldNotIndent || shouldInlineLogicalExpression(n) && !samePrecedenceSubExpression || !shouldInlineLogicalExpression(n) && shouldIndentIfInlining) {
|
|
@@ -23458,7 +23590,7 @@ function printPathNoParens(path, options, print, args) {
|
|
|
23458
23590
|
case "OptionalMemberExpression":
|
|
23459
23591
|
case "MemberExpression":
|
|
23460
23592
|
{
|
|
23461
|
-
var
|
|
23593
|
+
var _parent2 = path.getParentNode();
|
|
23462
23594
|
|
|
23463
23595
|
var firstNonMemberParent;
|
|
23464
23596
|
var i = 0;
|
|
@@ -23468,7 +23600,7 @@ function printPathNoParens(path, options, print, args) {
|
|
|
23468
23600
|
i++;
|
|
23469
23601
|
} while (firstNonMemberParent && (firstNonMemberParent.type === "MemberExpression" || firstNonMemberParent.type === "OptionalMemberExpression" || firstNonMemberParent.type === "TSNonNullExpression"));
|
|
23470
23602
|
|
|
23471
|
-
var shouldInline = firstNonMemberParent && (firstNonMemberParent.type === "NewExpression" || firstNonMemberParent.type === "BindExpression" || firstNonMemberParent.type === "VariableDeclarator" && firstNonMemberParent.id.type !== "Identifier" || firstNonMemberParent.type === "AssignmentExpression" && firstNonMemberParent.left.type !== "Identifier") || n.computed || n.object.type === "Identifier" && n.property.type === "Identifier" &&
|
|
23603
|
+
var shouldInline = firstNonMemberParent && (firstNonMemberParent.type === "NewExpression" || firstNonMemberParent.type === "BindExpression" || firstNonMemberParent.type === "VariableDeclarator" && firstNonMemberParent.id.type !== "Identifier" || firstNonMemberParent.type === "AssignmentExpression" && firstNonMemberParent.left.type !== "Identifier") || n.computed || n.object.type === "Identifier" && n.property.type === "Identifier" && _parent2.type !== "MemberExpression" && _parent2.type !== "OptionalMemberExpression";
|
|
23472
23604
|
return concat$12([path.call(print, "object"), shouldInline ? printMemberLookup(path, options, print) : group$10(indent$6(concat$12([softline$5, printMemberLookup(path, options, print)])))]);
|
|
23473
23605
|
}
|
|
23474
23606
|
|
|
@@ -23571,6 +23703,10 @@ function printPathNoParens(path, options, print, args) {
|
|
|
23571
23703
|
|
|
23572
23704
|
case "MethodDefinition":
|
|
23573
23705
|
case "TSAbstractMethodDefinition":
|
|
23706
|
+
if (n.decorators && n.decorators.length !== 0) {
|
|
23707
|
+
parts.push(printDecorators(path, options, print));
|
|
23708
|
+
}
|
|
23709
|
+
|
|
23574
23710
|
if (n.accessibility) {
|
|
23575
23711
|
parts.push(n.accessibility + " ");
|
|
23576
23712
|
}
|
|
@@ -23714,6 +23850,7 @@ function printPathNoParens(path, options, print, args) {
|
|
|
23714
23850
|
case "Import":
|
|
23715
23851
|
return "import";
|
|
23716
23852
|
|
|
23853
|
+
case "TSModuleBlock":
|
|
23717
23854
|
case "BlockStatement":
|
|
23718
23855
|
{
|
|
23719
23856
|
var naked = path.call(function (bodyPath) {
|
|
@@ -23724,11 +23861,11 @@ function printPathNoParens(path, options, print, args) {
|
|
|
23724
23861
|
});
|
|
23725
23862
|
var hasDirectives = n.directives && n.directives.length > 0;
|
|
23726
23863
|
|
|
23727
|
-
var
|
|
23864
|
+
var _parent3 = path.getParentNode();
|
|
23728
23865
|
|
|
23729
23866
|
var _parentParent = path.getParentNode(1);
|
|
23730
23867
|
|
|
23731
|
-
if (!hasContent && !hasDirectives && !hasDanglingComments(n) && (
|
|
23868
|
+
if (!hasContent && !hasDirectives && !hasDanglingComments(n) && (_parent3.type === "ArrowFunctionExpression" || _parent3.type === "FunctionExpression" || _parent3.type === "FunctionDeclaration" || _parent3.type === "ObjectMethod" || _parent3.type === "ClassMethod" || _parent3.type === "ForStatement" || _parent3.type === "WhileStatement" || _parent3.type === "DoWhileStatement" || _parent3.type === "DoExpression" || _parent3.type === "CatchClause" && !_parentParent.finalizer || _parent3.type === "TSModuleDeclaration")) {
|
|
23732
23869
|
return "{}";
|
|
23733
23870
|
}
|
|
23734
23871
|
|
|
@@ -23860,10 +23997,10 @@ function printPathNoParens(path, options, print, args) {
|
|
|
23860
23997
|
return options.locStart(a) - options.locStart(b);
|
|
23861
23998
|
})[0];
|
|
23862
23999
|
|
|
23863
|
-
var
|
|
24000
|
+
var _parent4 = path.getParentNode(0);
|
|
23864
24001
|
|
|
23865
|
-
var isFlowInterfaceLikeBody = isTypeAnnotation &&
|
|
23866
|
-
var shouldBreak = n.type === "TSInterfaceBody" || isFlowInterfaceLikeBody || n.type === "ObjectPattern" &&
|
|
24002
|
+
var isFlowInterfaceLikeBody = isTypeAnnotation && _parent4 && (_parent4.type === "InterfaceDeclaration" || _parent4.type === "DeclareInterface" || _parent4.type === "DeclareClass") && path.getName() === "body";
|
|
24003
|
+
var shouldBreak = n.type === "TSInterfaceBody" || isFlowInterfaceLikeBody || n.type === "ObjectPattern" && _parent4.type !== "FunctionDeclaration" && _parent4.type !== "FunctionExpression" && _parent4.type !== "ArrowFunctionExpression" && _parent4.type !== "AssignmentPattern" && _parent4.type !== "CatchClause" && n.properties.some(function (property) {
|
|
23867
24004
|
return property.value && (property.value.type === "ObjectPattern" || property.value.type === "ArrayPattern");
|
|
23868
24005
|
}) || n.type !== "ObjectPattern" && firstProperty && hasNewlineInRange$1(options.originalText, options.locStart(n), options.locStart(firstProperty));
|
|
23869
24006
|
var separator = isFlowInterfaceLikeBody ? ";" : n.type === "TSInterfaceBody" || n.type === "TSTypeLiteral" ? ifBreak$6(semi, ";") : ",";
|
|
@@ -23890,7 +24027,7 @@ function printPathNoParens(path, options, print, args) {
|
|
|
23890
24027
|
var result = concat$12(separatorParts.concat(group$10(prop.printed)));
|
|
23891
24028
|
separatorParts = [separator, line$8];
|
|
23892
24029
|
|
|
23893
|
-
if ((prop.node.type === "TSPropertySignature" || prop.node.type === "TSMethodSignature") && hasNodeIgnoreComment$1(prop.node)) {
|
|
24030
|
+
if ((prop.node.type === "TSPropertySignature" || prop.node.type === "TSMethodSignature" || prop.node.type === "TSConstructSignature") && hasNodeIgnoreComment$1(prop.node)) {
|
|
23894
24031
|
separatorParts.shift();
|
|
23895
24032
|
}
|
|
23896
24033
|
|
|
@@ -23924,7 +24061,7 @@ function printPathNoParens(path, options, print, args) {
|
|
|
23924
24061
|
|
|
23925
24062
|
var parentParentParent = path.getParentNode(2);
|
|
23926
24063
|
|
|
23927
|
-
if (n.type === "ObjectPattern" &&
|
|
24064
|
+
if (n.type === "ObjectPattern" && _parent4 && shouldHugArguments(_parent4) && _parent4.params[0] === n || shouldHugType(n) && parentParentParent && shouldHugArguments(parentParentParent) && parentParentParent.params[0].typeAnnotation && parentParentParent.params[0].typeAnnotation.typeAnnotation === n) {
|
|
23928
24065
|
return content;
|
|
23929
24066
|
}
|
|
23930
24067
|
|
|
@@ -24010,9 +24147,9 @@ function printPathNoParens(path, options, print, args) {
|
|
|
24010
24147
|
|
|
24011
24148
|
case "SequenceExpression":
|
|
24012
24149
|
{
|
|
24013
|
-
var
|
|
24150
|
+
var _parent5 = path.getParentNode(0);
|
|
24014
24151
|
|
|
24015
|
-
if (
|
|
24152
|
+
if (_parent5.type === "ExpressionStatement" || _parent5.type === "ForStatement") {
|
|
24016
24153
|
// For ExpressionStatements and for-loop heads, which are among
|
|
24017
24154
|
// the few places a SequenceExpression appears unparenthesized, we want
|
|
24018
24155
|
// to indent expressions after the first.
|
|
@@ -24049,7 +24186,8 @@ function printPathNoParens(path, options, print, args) {
|
|
|
24049
24186
|
return printNumber$2(n.extra.raw);
|
|
24050
24187
|
|
|
24051
24188
|
case "BigIntLiteral":
|
|
24052
|
-
return concat$12([printNumber$2(n.extra.rawValue
|
|
24189
|
+
return concat$12([printNumber$2(n.extra ? n.extra.rawValue : // TypeScript
|
|
24190
|
+
n.value), "n"]);
|
|
24053
24191
|
|
|
24054
24192
|
case "BooleanLiteral": // Babel 6 Literal split
|
|
24055
24193
|
|
|
@@ -24371,11 +24509,11 @@ function printPathNoParens(path, options, print, args) {
|
|
|
24371
24509
|
|
|
24372
24510
|
case "JSXExpressionContainer":
|
|
24373
24511
|
{
|
|
24374
|
-
var
|
|
24512
|
+
var _parent6 = path.getParentNode(0);
|
|
24375
24513
|
|
|
24376
|
-
var preventInline =
|
|
24514
|
+
var preventInline = _parent6.type === "JSXAttribute" && n.expression.comments && n.expression.comments.length > 0;
|
|
24377
24515
|
|
|
24378
|
-
var _shouldInline = !preventInline && (n.expression.type === "ArrayExpression" || n.expression.type === "ObjectExpression" || n.expression.type === "ArrowFunctionExpression" || n.expression.type === "CallExpression" || n.expression.type === "OptionalCallExpression" || n.expression.type === "FunctionExpression" || n.expression.type === "JSXEmptyExpression" || n.expression.type === "TemplateLiteral" || n.expression.type === "TaggedTemplateExpression" || n.expression.type === "DoExpression" || isJSXNode(
|
|
24516
|
+
var _shouldInline = !preventInline && (n.expression.type === "ArrayExpression" || n.expression.type === "ObjectExpression" || n.expression.type === "ArrowFunctionExpression" || n.expression.type === "CallExpression" || n.expression.type === "OptionalCallExpression" || n.expression.type === "FunctionExpression" || n.expression.type === "JSXEmptyExpression" || n.expression.type === "TemplateLiteral" || n.expression.type === "TaggedTemplateExpression" || n.expression.type === "DoExpression" || isJSXNode(_parent6) && (n.expression.type === "ConditionalExpression" || isBinaryish(n.expression)));
|
|
24379
24517
|
|
|
24380
24518
|
if (_shouldInline) {
|
|
24381
24519
|
return group$10(concat$12(["{", path.call(print, "expression"), lineSuffixBoundary$1, "}"]));
|
|
@@ -24385,7 +24523,6 @@ function printPathNoParens(path, options, print, args) {
|
|
|
24385
24523
|
}
|
|
24386
24524
|
|
|
24387
24525
|
case "JSXFragment":
|
|
24388
|
-
case "TSJsxFragment":
|
|
24389
24526
|
case "JSXElement":
|
|
24390
24527
|
{
|
|
24391
24528
|
var elem = comments.printComments(path, function () {
|
|
@@ -24447,12 +24584,10 @@ function printPathNoParens(path, options, print, args) {
|
|
|
24447
24584
|
|
|
24448
24585
|
case "JSXOpeningFragment":
|
|
24449
24586
|
case "JSXClosingFragment":
|
|
24450
|
-
case "TSJsxOpeningFragment":
|
|
24451
|
-
case "TSJsxClosingFragment":
|
|
24452
24587
|
{
|
|
24453
24588
|
var hasComment = n.comments && n.comments.length;
|
|
24454
24589
|
var hasOwnLineComment = hasComment && !n.comments.every(comments$3.isBlockComment);
|
|
24455
|
-
var isOpeningFragment = n.type === "JSXOpeningFragment"
|
|
24590
|
+
var isOpeningFragment = n.type === "JSXOpeningFragment";
|
|
24456
24591
|
return concat$12([isOpeningFragment ? "<" : "</", indent$6(concat$12([hasOwnLineComment ? hardline$8 : hasComment && !isOpeningFragment ? " " : "", comments.printDanglingComments(path, options, true)])), hasOwnLineComment ? hardline$8 : "", ">"]);
|
|
24457
24592
|
}
|
|
24458
24593
|
|
|
@@ -24785,20 +24920,20 @@ function printPathNoParens(path, options, print, args) {
|
|
|
24785
24920
|
// FunctionTypeAnnotation is ambiguous:
|
|
24786
24921
|
// declare function foo(a: B): void; OR
|
|
24787
24922
|
// var A: (a: B) => void;
|
|
24788
|
-
var
|
|
24923
|
+
var _parent7 = path.getParentNode(0);
|
|
24789
24924
|
|
|
24790
24925
|
var _parentParent2 = path.getParentNode(1);
|
|
24791
24926
|
|
|
24792
24927
|
var _parentParentParent = path.getParentNode(2);
|
|
24793
24928
|
|
|
24794
|
-
var isArrowFunctionTypeAnnotation = n.type === "TSFunctionType" || !((
|
|
24795
|
-
var needsColon = isArrowFunctionTypeAnnotation && (
|
|
24929
|
+
var isArrowFunctionTypeAnnotation = n.type === "TSFunctionType" || !((_parent7.type === "ObjectTypeProperty" || _parent7.type === "ObjectTypeInternalSlot") && !getFlowVariance(_parent7) && !_parent7.optional && options.locStart(_parent7) === options.locStart(n) || _parent7.type === "ObjectTypeCallProperty" || _parentParentParent && _parentParentParent.type === "DeclareFunction");
|
|
24930
|
+
var needsColon = isArrowFunctionTypeAnnotation && (_parent7.type === "TypeAnnotation" || _parent7.type === "TSTypeAnnotation"); // Sadly we can't put it inside of FastPath::needsColon because we are
|
|
24796
24931
|
// printing ":" as part of the expression and it would put parenthesis
|
|
24797
24932
|
// around :(
|
|
24798
24933
|
|
|
24799
|
-
var needsParens = needsColon && isArrowFunctionTypeAnnotation && (
|
|
24934
|
+
var needsParens = needsColon && isArrowFunctionTypeAnnotation && (_parent7.type === "TypeAnnotation" || _parent7.type === "TSTypeAnnotation") && _parentParent2.type === "ArrowFunctionExpression";
|
|
24800
24935
|
|
|
24801
|
-
if (isObjectTypePropertyAFunction(
|
|
24936
|
+
if (isObjectTypePropertyAFunction(_parent7, options)) {
|
|
24802
24937
|
isArrowFunctionTypeAnnotation = true;
|
|
24803
24938
|
needsColon = true;
|
|
24804
24939
|
}
|
|
@@ -24901,12 +25036,12 @@ function printPathNoParens(path, options, print, args) {
|
|
|
24901
25036
|
// | A
|
|
24902
25037
|
// | B
|
|
24903
25038
|
// | C
|
|
24904
|
-
var
|
|
25039
|
+
var _parent8 = path.getParentNode();
|
|
24905
25040
|
|
|
24906
25041
|
var _parentParent3 = path.getParentNode(1); // If there's a leading comment, the parent is doing the indentation
|
|
24907
25042
|
|
|
24908
25043
|
|
|
24909
|
-
var shouldIndent =
|
|
25044
|
+
var shouldIndent = _parent8.type !== "TypeParameterInstantiation" && _parent8.type !== "TSTypeParameterInstantiation" && _parent8.type !== "GenericTypeAnnotation" && _parent8.type !== "TSTypeReference" && !(_parent8.type === "FunctionTypeParam" && !_parent8.name) && _parentParent3.type !== "TSTypeAssertionExpression" && !((_parent8.type === "TypeAlias" || _parent8.type === "VariableDeclarator") && hasLeadingOwnLineComment(options.originalText, n, options)); // {
|
|
24910
25045
|
// a: string
|
|
24911
25046
|
// } | null | void
|
|
24912
25047
|
// should be inlined and not be printed in the multi-line variant
|
|
@@ -24932,7 +25067,8 @@ function printPathNoParens(path, options, print, args) {
|
|
|
24932
25067
|
return join$7(" | ", _printed2);
|
|
24933
25068
|
}
|
|
24934
25069
|
|
|
24935
|
-
var
|
|
25070
|
+
var shouldAddStartLine = shouldIndent && !hasLeadingOwnLineComment(options.originalText, n, options);
|
|
25071
|
+
var code = concat$12([ifBreak$6(concat$12([shouldAddStartLine ? line$8 : "", "| "])), join$7(concat$12([line$8, "| "]), _printed2)]);
|
|
24936
25072
|
var hasParens;
|
|
24937
25073
|
|
|
24938
25074
|
if (n.type === "TSUnionType") {
|
|
@@ -25065,9 +25201,9 @@ function printPathNoParens(path, options, print, args) {
|
|
|
25065
25201
|
case "TSTypeParameter":
|
|
25066
25202
|
case "TypeParameter":
|
|
25067
25203
|
{
|
|
25068
|
-
var
|
|
25204
|
+
var _parent9 = path.getParentNode();
|
|
25069
25205
|
|
|
25070
|
-
if (
|
|
25206
|
+
if (_parent9.type === "TSMappedType") {
|
|
25071
25207
|
parts.push("[", path.call(print, "name"));
|
|
25072
25208
|
|
|
25073
25209
|
if (n.constraint) {
|
|
@@ -25129,6 +25265,9 @@ function printPathNoParens(path, options, print, args) {
|
|
|
25129
25265
|
case "TSBooleanKeyword":
|
|
25130
25266
|
return "boolean";
|
|
25131
25267
|
|
|
25268
|
+
case "TSBigIntKeyword":
|
|
25269
|
+
return "bigint";
|
|
25270
|
+
|
|
25132
25271
|
case "TSConstKeyword":
|
|
25133
25272
|
return "const";
|
|
25134
25273
|
|
|
@@ -25259,9 +25398,9 @@ function printPathNoParens(path, options, print, args) {
|
|
|
25259
25398
|
|
|
25260
25399
|
case "TSIndexSignature":
|
|
25261
25400
|
{
|
|
25262
|
-
var
|
|
25401
|
+
var _parent10 = path.getParentNode();
|
|
25263
25402
|
|
|
25264
|
-
return concat$12([n.export ? "export " : "", n.accessibility ? concat$12([n.accessibility, " "]) : "", n.static ? "static " : "", n.readonly ? "readonly " : "", "[", path.call(print, "index"), "]: ", path.call(print, "typeAnnotation"),
|
|
25403
|
+
return concat$12([n.export ? "export " : "", n.accessibility ? concat$12([n.accessibility, " "]) : "", n.static ? "static " : "", n.readonly ? "readonly " : "", "[", path.call(print, "index"), "]: ", path.call(print, "typeAnnotation"), _parent10.type === "ClassBody" ? semi : ""]);
|
|
25265
25404
|
}
|
|
25266
25405
|
|
|
25267
25406
|
case "TSTypePredicate":
|
|
@@ -25382,10 +25521,10 @@ function printPathNoParens(path, options, print, args) {
|
|
|
25382
25521
|
|
|
25383
25522
|
case "TSModuleDeclaration":
|
|
25384
25523
|
{
|
|
25385
|
-
var
|
|
25524
|
+
var _parent11 = path.getParentNode();
|
|
25386
25525
|
|
|
25387
25526
|
var isExternalModule = isLiteral(n.id);
|
|
25388
|
-
var parentIsDeclaration =
|
|
25527
|
+
var parentIsDeclaration = _parent11.type === "TSModuleDeclaration";
|
|
25389
25528
|
var bodyIsDeclaration = n.body && n.body.type === "TSModuleDeclaration";
|
|
25390
25529
|
|
|
25391
25530
|
if (parentIsDeclaration) {
|
|
@@ -25402,7 +25541,7 @@ function printPathNoParens(path, options, print, args) {
|
|
|
25402
25541
|
var isGlobalDeclaration = n.id.type === "Identifier" && n.id.name === "global" && !/namespace|module/.test(textBetweenNodeAndItsId);
|
|
25403
25542
|
|
|
25404
25543
|
if (!isGlobalDeclaration) {
|
|
25405
|
-
parts.push(isExternalModule ||
|
|
25544
|
+
parts.push(isExternalModule || /(^|\s)module(\s|$)/.test(textBetweenNodeAndItsId) ? "module " : "namespace ");
|
|
25406
25545
|
}
|
|
25407
25546
|
}
|
|
25408
25547
|
|
|
@@ -25411,9 +25550,7 @@ function printPathNoParens(path, options, print, args) {
|
|
|
25411
25550
|
if (bodyIsDeclaration) {
|
|
25412
25551
|
parts.push(path.call(print, "body"));
|
|
25413
25552
|
} else if (n.body) {
|
|
25414
|
-
parts.push("
|
|
25415
|
-
return comments.printDanglingComments(bodyPath, options, true);
|
|
25416
|
-
}, "body"), group$10(path.call(print, "body"))])), line$8, "}");
|
|
25553
|
+
parts.push(" ", group$10(path.call(print, "body")));
|
|
25417
25554
|
} else {
|
|
25418
25555
|
parts.push(semi);
|
|
25419
25556
|
}
|
|
@@ -25421,11 +25558,6 @@ function printPathNoParens(path, options, print, args) {
|
|
|
25421
25558
|
return concat$12(parts);
|
|
25422
25559
|
}
|
|
25423
25560
|
|
|
25424
|
-
case "TSModuleBlock":
|
|
25425
|
-
return path.call(function (bodyPath) {
|
|
25426
|
-
return printStatementSequence(bodyPath, options, print);
|
|
25427
|
-
}, "body");
|
|
25428
|
-
|
|
25429
25561
|
case "PrivateName":
|
|
25430
25562
|
return concat$12(["#", path.call(print, "id")]);
|
|
25431
25563
|
|
|
@@ -25473,7 +25605,7 @@ function printPathNoParens(path, options, print, args) {
|
|
|
25473
25605
|
|
|
25474
25606
|
case "NGMicrosyntax":
|
|
25475
25607
|
return concat$12(path.map(function (childPath, index) {
|
|
25476
|
-
return concat$12([index === 0 ? "" : isNgForOf(childPath) ? " " : concat$12([";", line$8]), print(childPath)]);
|
|
25608
|
+
return concat$12([index === 0 ? "" : isNgForOf(childPath.getValue(), index, n) ? " " : concat$12([";", line$8]), print(childPath)]);
|
|
25477
25609
|
}, "body"));
|
|
25478
25610
|
|
|
25479
25611
|
case "NGMicrosyntaxKey":
|
|
@@ -25483,7 +25615,14 @@ function printPathNoParens(path, options, print, args) {
|
|
|
25483
25615
|
return concat$12([path.call(print, "expression"), n.alias === null ? "" : concat$12([" as ", path.call(print, "alias")])]);
|
|
25484
25616
|
|
|
25485
25617
|
case "NGMicrosyntaxKeyedExpression":
|
|
25486
|
-
|
|
25618
|
+
{
|
|
25619
|
+
var index = path.getName();
|
|
25620
|
+
|
|
25621
|
+
var _parentNode2 = path.getParentNode();
|
|
25622
|
+
|
|
25623
|
+
var shouldNotPrintColon = isNgForOf(n, index, _parentNode2) || (index === 1 && (n.key.name === "then" || n.key.name === "else") || index === 2 && n.key.name === "else" && _parentNode2.body[index - 1].type === "NGMicrosyntaxKeyedExpression" && _parentNode2.body[index - 1].key.name === "then") && _parentNode2.body[0].type === "NGMicrosyntaxExpression";
|
|
25624
|
+
return concat$12([path.call(print, "key"), shouldNotPrintColon ? " " : ": ", path.call(print, "expression")]);
|
|
25625
|
+
}
|
|
25487
25626
|
|
|
25488
25627
|
case "NGMicrosyntaxLet":
|
|
25489
25628
|
return concat$12(["let ", path.call(print, "key"), n.value === null ? "" : concat$12([" = ", path.call(print, "value")])]);
|
|
@@ -25496,13 +25635,8 @@ function printPathNoParens(path, options, print, args) {
|
|
|
25496
25635
|
throw new Error("unknown type: " + JSON.stringify(n.type));
|
|
25497
25636
|
}
|
|
25498
25637
|
}
|
|
25499
|
-
/** prefer `let hero of heros` over `let hero; of: heros` */
|
|
25500
|
-
|
|
25501
25638
|
|
|
25502
|
-
function isNgForOf(
|
|
25503
|
-
var node = path.getValue();
|
|
25504
|
-
var index = path.getName();
|
|
25505
|
-
var parentNode = path.getParentNode();
|
|
25639
|
+
function isNgForOf(node, index, parentNode) {
|
|
25506
25640
|
return node.type === "NGMicrosyntaxKeyedExpression" && node.key.name === "of" && index === 1 && parentNode.body[0].type === "NGMicrosyntaxLet" && parentNode.body[0].value === null;
|
|
25507
25641
|
}
|
|
25508
25642
|
/** identify if an angular expression seems to have side effects */
|
|
@@ -26515,7 +26649,7 @@ function isCallOrOptionalCallExpression(node) {
|
|
|
26515
26649
|
}
|
|
26516
26650
|
|
|
26517
26651
|
function isJSXNode(node) {
|
|
26518
|
-
return node.type === "JSXElement" || node.type === "JSXFragment"
|
|
26652
|
+
return node.type === "JSXElement" || node.type === "JSXFragment";
|
|
26519
26653
|
}
|
|
26520
26654
|
|
|
26521
26655
|
function isEmptyJSXElement(node) {
|
|
@@ -26917,7 +27051,6 @@ function maybeWrapJSXElementInParens(path, elem) {
|
|
|
26917
27051
|
JSXElement: true,
|
|
26918
27052
|
JSXExpressionContainer: true,
|
|
26919
27053
|
JSXFragment: true,
|
|
26920
|
-
TSJsxFragment: true,
|
|
26921
27054
|
ExpressionStatement: true,
|
|
26922
27055
|
CallExpression: true,
|
|
26923
27056
|
OptionalCallExpression: true,
|
|
@@ -28036,7 +28169,7 @@ var languageJs = {
|
|
|
28036
28169
|
printers: printers$4
|
|
28037
28170
|
};
|
|
28038
28171
|
|
|
28039
|
-
|
|
28172
|
+
var json$9 = {"cjkPattern":"[\\u02ea-\\u02eb\\u1100-\\u11ff\\u2e80-\\u2e99\\u2e9b-\\u2ef3\\u2f00-\\u2fd5\\u3000-\\u303f\\u3041-\\u3096\\u3099-\\u309f\\u30a1-\\u30fa\\u30fc-\\u30ff\\u3105-\\u312e\\u3131-\\u318e\\u3190-\\u3191\\u3196-\\u31ba\\u31c0-\\u31e3\\u31f0-\\u321e\\u322a-\\u3247\\u3260-\\u327e\\u328a-\\u32b0\\u32c0-\\u32cb\\u32d0-\\u32fe\\u3300-\\u3370\\u337b-\\u337f\\u33e0-\\u33fe\\u3400-\\u4db5\\u4e00-\\u9fea\\ua960-\\ua97c\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufa6d\\ufa70-\\ufad9\\ufe10-\\ufe1f\\ufe30-\\ufe6f\\uff00-\\uffef]|[\\ud840-\\ud868\\ud86a-\\ud86c\\ud86f-\\ud872\\ud874-\\ud879][\\udc00-\\udfff]|\\ud82c[\\udc00-\\udd1e]|\\ud83c[\\ude00\\ude50-\\ude51]|\\ud869[\\udc00-\\uded6\\udf00-\\udfff]|\\ud86d[\\udc00-\\udf34\\udf40-\\udfff]|\\ud86e[\\udc00-\\udc1d\\udc20-\\udfff]|\\ud873[\\udc00-\\udea1\\udeb0-\\udfff]|\\ud87a[\\udc00-\\udfe0]|\\ud87e[\\udc00-\\ude1d]","kPattern":"[\\u1100-\\u11ff\\u3001-\\u3003\\u3008-\\u3011\\u3013-\\u301f\\u302e-\\u3030\\u3037\\u30fb\\u3131-\\u318e\\u3200-\\u321e\\u3260-\\u327e\\ua960-\\ua97c\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\ufe45-\\ufe46\\uff61-\\uff65\\uffa0-\\uffbe\\uffc2-\\uffc7\\uffca-\\uffcf\\uffd2-\\uffd7\\uffda-\\uffdc]","punctuationPattern":"[\\u0021-\\u002f\\u003a-\\u0040\\u005b-\\u0060\\u007b-\\u007e\\u00a1\\u00a7\\u00ab\\u00b6-\\u00b7\\u00bb\\u00bf\\u037e\\u0387\\u055a-\\u055f\\u0589-\\u058a\\u05be\\u05c0\\u05c3\\u05c6\\u05f3-\\u05f4\\u0609-\\u060a\\u060c-\\u060d\\u061b\\u061e-\\u061f\\u066a-\\u066d\\u06d4\\u0700-\\u070d\\u07f7-\\u07f9\\u0830-\\u083e\\u085e\\u0964-\\u0965\\u0970\\u09fd\\u0af0\\u0df4\\u0e4f\\u0e5a-\\u0e5b\\u0f04-\\u0f12\\u0f14\\u0f3a-\\u0f3d\\u0f85\\u0fd0-\\u0fd4\\u0fd9-\\u0fda\\u104a-\\u104f\\u10fb\\u1360-\\u1368\\u1400\\u166d-\\u166e\\u169b-\\u169c\\u16eb-\\u16ed\\u1735-\\u1736\\u17d4-\\u17d6\\u17d8-\\u17da\\u1800-\\u180a\\u1944-\\u1945\\u1a1e-\\u1a1f\\u1aa0-\\u1aa6\\u1aa8-\\u1aad\\u1b5a-\\u1b60\\u1bfc-\\u1bff\\u1c3b-\\u1c3f\\u1c7e-\\u1c7f\\u1cc0-\\u1cc7\\u1cd3\\u2010-\\u2027\\u2030-\\u2043\\u2045-\\u2051\\u2053-\\u205e\\u207d-\\u207e\\u208d-\\u208e\\u2308-\\u230b\\u2329-\\u232a\\u2768-\\u2775\\u27c5-\\u27c6\\u27e6-\\u27ef\\u2983-\\u2998\\u29d8-\\u29db\\u29fc-\\u29fd\\u2cf9-\\u2cfc\\u2cfe-\\u2cff\\u2d70\\u2e00-\\u2e2e\\u2e30-\\u2e49\\u3001-\\u3003\\u3008-\\u3011\\u3014-\\u301f\\u3030\\u303d\\u30a0\\u30fb\\ua4fe-\\ua4ff\\ua60d-\\ua60f\\ua673\\ua67e\\ua6f2-\\ua6f7\\ua874-\\ua877\\ua8ce-\\ua8cf\\ua8f8-\\ua8fa\\ua8fc\\ua92e-\\ua92f\\ua95f\\ua9c1-\\ua9cd\\ua9de-\\ua9df\\uaa5c-\\uaa5f\\uaade-\\uaadf\\uaaf0-\\uaaf1\\uabeb\\ufd3e-\\ufd3f\\ufe10-\\ufe19\\ufe30-\\ufe52\\ufe54-\\ufe61\\ufe63\\ufe68\\ufe6a-\\ufe6b\\uff01-\\uff03\\uff05-\\uff0a\\uff0c-\\uff0f\\uff1a-\\uff1b\\uff1f-\\uff20\\uff3b-\\uff3d\\uff3f\\uff5b\\uff5d\\uff5f-\\uff65]|\\ud800[\\udd00-\\udd02\\udf9f\\udfd0]|\\ud801[\\udd6f]|\\ud802[\\udc57\\udd1f\\udd3f\\ude50-\\ude58\\ude7f\\udef0-\\udef6\\udf39-\\udf3f\\udf99-\\udf9c]|\\ud804[\\udc47-\\udc4d\\udcbb-\\udcbc\\udcbe-\\udcc1\\udd40-\\udd43\\udd74-\\udd75\\uddc5-\\uddc9\\uddcd\\udddb\\udddd-\\udddf\\ude38-\\ude3d\\udea9]|\\ud805[\\udc4b-\\udc4f\\udc5b\\udc5d\\udcc6\\uddc1-\\uddd7\\ude41-\\ude43\\ude60-\\ude6c\\udf3c-\\udf3e]|\\ud806[\\ude3f-\\ude46\\ude9a-\\ude9c\\ude9e-\\udea2]|\\ud807[\\udc41-\\udc45\\udc70-\\udc71]|\\ud809[\\udc70-\\udc74]|\\ud81a[\\ude6e-\\ude6f\\udef5\\udf37-\\udf3b\\udf44]|\\ud82f[\\udc9f]|\\ud836[\\ude87-\\ude8b]|\\ud83a[\\udd5e-\\udd5f]"};
|
|
28040
28173
|
|
|
28041
28174
|
var cjkPattern = json$9.cjkPattern;
|
|
28042
28175
|
var kPattern = json$9.kPattern;
|
|
@@ -28812,11 +28945,9 @@ function genericPrint$5(path, options, print) {
|
|
|
28812
28945
|
|
|
28813
28946
|
case "inlineMath":
|
|
28814
28947
|
{
|
|
28815
|
-
//
|
|
28816
|
-
//
|
|
28817
|
-
|
|
28818
|
-
|
|
28819
|
-
return concat$16([_style3, node.value, _style3]);
|
|
28948
|
+
// remark-math trims content but we don't want to remove whitespaces
|
|
28949
|
+
// since it's very possible that it's recognized as math accidentally
|
|
28950
|
+
return options.originalText.slice(options.locStart(node), options.locEnd(node));
|
|
28820
28951
|
}
|
|
28821
28952
|
|
|
28822
28953
|
case "tableRow": // handled in "table"
|
|
@@ -29686,7 +29817,7 @@ var conditionalGroup$2 = docBuilders$3.conditionalGroup;
|
|
|
29686
29817
|
var breakParent$4 = docBuilders$3.breakParent;
|
|
29687
29818
|
var concat$18 = docBuilders$3.concat;
|
|
29688
29819
|
var dedent$4 = docBuilders$3.dedent;
|
|
29689
|
-
var dedentToRoot$
|
|
29820
|
+
var dedentToRoot$3 = docBuilders$3.dedentToRoot;
|
|
29690
29821
|
var fill$6 = docBuilders$3.fill;
|
|
29691
29822
|
var group$16 = docBuilders$3.group;
|
|
29692
29823
|
var hardline$13 = docBuilders$3.hardline;
|
|
@@ -29760,7 +29891,7 @@ function _print(node, parentNode, path, options, print) {
|
|
|
29760
29891
|
case "document":
|
|
29761
29892
|
{
|
|
29762
29893
|
var nextDocument = parentNode.children[path.getName() + 1];
|
|
29763
|
-
return join$12(hardline$13, [shouldPrintDocumentHeadEndMarker(node, nextDocument) === "head" ? join$12(hardline$13, [node.head.children.length === 0 && node.head.endComments.length === 0 ? "" : path.call(print, "head"), concat$18(["---", hasTrailingComment$1(node.head) ? concat$18([" ", path.call(print, "head", "trailingComment")]) : ""])].filter(Boolean)) : "", shouldPrintDocumentBody(node) ? path.call(print, "body") : ""].filter(Boolean));
|
|
29894
|
+
return join$12(hardline$13, [shouldPrintDocumentHeadEndMarker(node, nextDocument, parentNode, options) === "head" ? join$12(hardline$13, [node.head.children.length === 0 && node.head.endComments.length === 0 ? "" : path.call(print, "head"), concat$18(["---", hasTrailingComment$1(node.head) ? concat$18([" ", path.call(print, "head", "trailingComment")]) : ""])].filter(Boolean)) : "", shouldPrintDocumentBody(node) ? path.call(print, "body") : ""].filter(Boolean));
|
|
29764
29895
|
}
|
|
29765
29896
|
|
|
29766
29897
|
case "documentHead":
|
|
@@ -29829,12 +29960,12 @@ function _print(node, parentNode, path, options, print) {
|
|
|
29829
29960
|
return isNode(ancestorNode, ["sequence", "mapping"]);
|
|
29830
29961
|
});
|
|
29831
29962
|
var isLastDescendant = isLastDescendantNode(path);
|
|
29832
|
-
return concat$18([node.type === "blockFolded" ? ">" : "|", node.indent === null ? "" : node.indent.toString(), node.chomping === "clip" ? "" : node.chomping === "keep" ? "+" : "-", hasIndicatorComment(node) ? concat$18([" ", path.call(print, "indicatorComment")]) : "", (node.indent === null ? dedent$4 : dedentToRoot$
|
|
29963
|
+
return concat$18([node.type === "blockFolded" ? ">" : "|", node.indent === null ? "" : node.indent.toString(), node.chomping === "clip" ? "" : node.chomping === "keep" ? "+" : "-", hasIndicatorComment(node) ? concat$18([" ", path.call(print, "indicatorComment")]) : "", (node.indent === null ? dedent$4 : dedentToRoot$3)(align$3(node.indent === null ? options.tabWidth : node.indent - 1 + parentIndent, concat$18(getBlockValueLineContents(node, {
|
|
29833
29964
|
parentIndent: parentIndent,
|
|
29834
29965
|
isLastDescendant: isLastDescendant,
|
|
29835
29966
|
options: options
|
|
29836
29967
|
}).reduce(function (reduced, lineWords, index, lineContents) {
|
|
29837
|
-
return reduced.concat(index === 0 ? hardline$13 : "", fill$6(join$12(line$11, lineWords).parts), index !== lineContents.length - 1 ? lineWords.length === 0 ? hardline$13 : markAsRoot$5(literalline$7) : node.chomping === "keep" && isLastDescendant ? lineWords.length === 0 ? dedentToRoot$
|
|
29968
|
+
return reduced.concat(index === 0 ? hardline$13 : "", fill$6(join$12(line$11, lineWords).parts), index !== lineContents.length - 1 ? lineWords.length === 0 ? hardline$13 : markAsRoot$5(literalline$7) : node.chomping === "keep" && isLastDescendant ? lineWords.length === 0 ? dedentToRoot$3(hardline$13) : dedentToRoot$3(literalline$7) : "");
|
|
29838
29969
|
}, []))))]);
|
|
29839
29970
|
}
|
|
29840
29971
|
|
|
@@ -29982,8 +30113,13 @@ function shouldPrintDocumentEndMarker(document, nextDocument) {
|
|
|
29982
30113
|
);
|
|
29983
30114
|
}
|
|
29984
30115
|
|
|
29985
|
-
function shouldPrintDocumentHeadEndMarker(document, nextDocument) {
|
|
30116
|
+
function shouldPrintDocumentHeadEndMarker(document, nextDocument, root, options) {
|
|
29986
30117
|
if (
|
|
30118
|
+
/**
|
|
30119
|
+
* ---
|
|
30120
|
+
* preserve the first document head end marker
|
|
30121
|
+
*/
|
|
30122
|
+
root.children[0] === document && /---(\s|$)/.test(options.originalText.slice(options.locStart(document), options.locStart(document) + 4)) ||
|
|
29987
30123
|
/**
|
|
29988
30124
|
* %DIRECTIVE
|
|
29989
30125
|
* ---
|