@sanity/pkg-utils 4.3.1 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/consoleSpy.cjs +23 -22
- package/dist/_chunks/consoleSpy.cjs.map +1 -1
- package/dist/_chunks/index.cjs +81 -65
- package/dist/_chunks/index.cjs.map +1 -1
- package/dist/_chunks/logger.cjs +5 -0
- package/dist/_chunks/logger.cjs.map +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +107 -86
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/node/core/pkg/loadPkgWithReporting.ts +1 -1
- package/src/node/core/pkg/parseExports.ts +2 -0
- package/src/node/core/pkg/types.ts +5 -0
- package/src/node/core/pkg/validatePkg.ts +5 -0
package/dist/_chunks/index.cjs
CHANGED
|
@@ -18,7 +18,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
18
18
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
19
19
|
mod
|
|
20
20
|
));
|
|
21
|
-
var chalk = require("chalk"), rxjs = require("rxjs"), path$1 = require("path"), rimraf = require("rimraf"), ts = require("typescript"), apiExtractor = require("@microsoft/api-extractor"), fs = require("fs/promises"), mkdirp = require("mkdirp"), prettier = require("prettier"), tsdocConfig = require("@microsoft/tsdoc-config"), jsoncParser = require("jsonc-parser"), fs$1 = require("fs"), require$$
|
|
21
|
+
var chalk = require("chalk"), rxjs = require("rxjs"), path$1 = require("path"), rimraf = require("rimraf"), ts = require("typescript"), apiExtractor = require("@microsoft/api-extractor"), fs = require("fs/promises"), mkdirp = require("mkdirp"), prettier = require("prettier"), tsdocConfig = require("@microsoft/tsdoc-config"), jsoncParser = require("jsonc-parser"), fs$1 = require("fs"), require$$4 = require("os"), rollup = require("rollup"), consoleSpy = require("./consoleSpy.cjs"), alias = require("@rollup/plugin-alias"), pluginBabel = require("@rollup/plugin-babel"), commonjs = require("@rollup/plugin-commonjs"), json = require("@rollup/plugin-json"), pluginNodeResolve = require("@rollup/plugin-node-resolve"), replace = require("@rollup/plugin-replace"), terser = require("@rollup/plugin-terser"), esbuild = require("rollup-plugin-esbuild");
|
|
22
22
|
require("esbuild-register/dist/node");
|
|
23
23
|
require("pkg-up");
|
|
24
24
|
require("find-config");
|
|
@@ -29,7 +29,7 @@ require("prompts");
|
|
|
29
29
|
function _interopDefaultCompat(e) {
|
|
30
30
|
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
|
31
31
|
}
|
|
32
|
-
var chalk__default = /* @__PURE__ */ _interopDefaultCompat(chalk), path__default = /* @__PURE__ */ _interopDefaultCompat(path$1), rimraf__default = /* @__PURE__ */ _interopDefaultCompat(rimraf), ts__default = /* @__PURE__ */ _interopDefaultCompat(ts), fs__default$1 = /* @__PURE__ */ _interopDefaultCompat(fs), prettier__default = /* @__PURE__ */ _interopDefaultCompat(prettier), fs__default = /* @__PURE__ */ _interopDefaultCompat(fs$1), require$$
|
|
32
|
+
var chalk__default = /* @__PURE__ */ _interopDefaultCompat(chalk), path__default = /* @__PURE__ */ _interopDefaultCompat(path$1), rimraf__default = /* @__PURE__ */ _interopDefaultCompat(rimraf), ts__default = /* @__PURE__ */ _interopDefaultCompat(ts), fs__default$1 = /* @__PURE__ */ _interopDefaultCompat(fs), prettier__default = /* @__PURE__ */ _interopDefaultCompat(prettier), fs__default = /* @__PURE__ */ _interopDefaultCompat(fs$1), require$$4__default = /* @__PURE__ */ _interopDefaultCompat(require$$4), alias__default = /* @__PURE__ */ _interopDefaultCompat(alias), commonjs__default = /* @__PURE__ */ _interopDefaultCompat(commonjs), json__default = /* @__PURE__ */ _interopDefaultCompat(json), replace__default = /* @__PURE__ */ _interopDefaultCompat(replace), terser__default = /* @__PURE__ */ _interopDefaultCompat(terser), esbuild__default = /* @__PURE__ */ _interopDefaultCompat(esbuild);
|
|
33
33
|
function printExtractMessages(ctx, messages) {
|
|
34
34
|
const { cwd, logger } = ctx, warnings = messages.filter((msg) => msg.logLevel === "warning");
|
|
35
35
|
warnings.length && logger.log();
|
|
@@ -2752,7 +2752,23 @@ function requireMain() {
|
|
|
2752
2752
|
exports2.astNodesAreEquivalent = astNodesAreEquivalent, exports2.builders = builders, exports2.builtInTypes = builtInTypes, exports2.defineMethod = defineMethod, exports2.eachField = eachField, exports2.finalize = finalize, exports2.getBuilderName = getBuilderName, exports2.getFieldNames = getFieldNames, exports2.getFieldValue = getFieldValue, exports2.getSupertypeNames = getSupertypeNames, exports2.NodePath = NodePath, exports2.Path = Path, exports2.PathVisitor = PathVisitor, exports2.someField = someField, exports2.Type = Type, exports2.use = use, exports2.visit = visit, Object.assign(namedTypes_1.namedTypes, n);
|
|
2753
2753
|
}(main)), main;
|
|
2754
2754
|
}
|
|
2755
|
-
var parser = {},
|
|
2755
|
+
var parser = {}, tinyInvariant_cjs, hasRequiredTinyInvariant_cjs;
|
|
2756
|
+
function requireTinyInvariant_cjs() {
|
|
2757
|
+
if (hasRequiredTinyInvariant_cjs)
|
|
2758
|
+
return tinyInvariant_cjs;
|
|
2759
|
+
hasRequiredTinyInvariant_cjs = 1;
|
|
2760
|
+
var isProduction = process.env.NODE_ENV === "production", prefix = "Invariant failed";
|
|
2761
|
+
function invariant(condition, message) {
|
|
2762
|
+
if (!condition) {
|
|
2763
|
+
if (isProduction)
|
|
2764
|
+
throw new Error(prefix);
|
|
2765
|
+
var provided = typeof message == "function" ? message() : message, value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
|
2766
|
+
throw new Error(value);
|
|
2767
|
+
}
|
|
2768
|
+
}
|
|
2769
|
+
return tinyInvariant_cjs = invariant, tinyInvariant_cjs;
|
|
2770
|
+
}
|
|
2771
|
+
var options = {}, util$1 = {}, sourceMap = {}, sourceMapGenerator = {}, base64Vlq = {}, base64 = {}, hasRequiredBase64;
|
|
2756
2772
|
function requireBase64() {
|
|
2757
2773
|
if (hasRequiredBase64)
|
|
2758
2774
|
return base64;
|
|
@@ -3691,7 +3707,7 @@ function requireUtil() {
|
|
|
3691
3707
|
if (hasRequiredUtil)
|
|
3692
3708
|
return util$1;
|
|
3693
3709
|
hasRequiredUtil = 1, Object.defineProperty(util$1, "__esModule", { value: !0 }), util$1.isTrailingCommaEnabled = util$1.getParentExportDeclaration = util$1.isExportDeclaration = util$1.fixFaultyLocations = util$1.getTrueLoc = util$1.composeSourceMaps = util$1.copyPos = util$1.comparePos = util$1.getUnionOfKeys = util$1.getOption = util$1.isBrowser = util$1.getLineTerminator = void 0;
|
|
3694
|
-
var tslib_12 = require$$0,
|
|
3710
|
+
var tslib_12 = require$$0, tiny_invariant_1 = tslib_12.__importDefault(requireTinyInvariant_cjs()), types2 = tslib_12.__importStar(requireMain()), n = types2.namedTypes, source_map_1 = tslib_12.__importDefault(requireSourceMap()), SourceMapConsumer = source_map_1.default.SourceMapConsumer, SourceMapGenerator = source_map_1.default.SourceMapGenerator, hasOwn = Object.prototype.hasOwnProperty;
|
|
3695
3711
|
function getLineTerminator() {
|
|
3696
3712
|
return isBrowser() ? `
|
|
3697
3713
|
` : require$$4__default.default.EOL || `
|
|
@@ -3806,11 +3822,11 @@ function requireUtil() {
|
|
|
3806
3822
|
if (node.type === "TemplateLiteral" && node.quasis.length !== 0) {
|
|
3807
3823
|
if (node.loc) {
|
|
3808
3824
|
var afterLeftBackTickPos = copyPos(node.loc.start);
|
|
3809
|
-
|
|
3825
|
+
(0, tiny_invariant_1.default)(lines2.charAt(afterLeftBackTickPos) === "`"), (0, tiny_invariant_1.default)(lines2.nextPos(afterLeftBackTickPos));
|
|
3810
3826
|
var firstQuasi = node.quasis[0];
|
|
3811
3827
|
comparePos(firstQuasi.loc.start, afterLeftBackTickPos) < 0 && (firstQuasi.loc.start = afterLeftBackTickPos);
|
|
3812
3828
|
var rightBackTickPos = copyPos(node.loc.end);
|
|
3813
|
-
|
|
3829
|
+
(0, tiny_invariant_1.default)(lines2.prevPos(rightBackTickPos)), (0, tiny_invariant_1.default)(lines2.charAt(rightBackTickPos) === "`");
|
|
3814
3830
|
var lastQuasi = node.quasis[node.quasis.length - 1];
|
|
3815
3831
|
comparePos(rightBackTickPos, lastQuasi.loc.end) < 0 && (lastQuasi.loc.end = rightBackTickPos);
|
|
3816
3832
|
}
|
|
@@ -3822,7 +3838,7 @@ function requireUtil() {
|
|
|
3822
3838
|
}
|
|
3823
3839
|
var rightCurlyPos = lines2.skipSpaces(expr.loc.end, !1, !1);
|
|
3824
3840
|
if (lines2.charAt(rightCurlyPos) === "}") {
|
|
3825
|
-
|
|
3841
|
+
(0, tiny_invariant_1.default)(lines2.nextPos(rightCurlyPos));
|
|
3826
3842
|
var quasiAfter = node.quasis[i + 1];
|
|
3827
3843
|
comparePos(quasiAfter.loc.start, rightCurlyPos) < 0 && (quasiAfter.loc.start = rightCurlyPos);
|
|
3828
3844
|
}
|
|
@@ -7720,7 +7736,7 @@ function requireMapping() {
|
|
|
7720
7736
|
if (hasRequiredMapping)
|
|
7721
7737
|
return mapping;
|
|
7722
7738
|
hasRequiredMapping = 1, Object.defineProperty(mapping, "__esModule", { value: !0 });
|
|
7723
|
-
var tslib_12 = require$$0,
|
|
7739
|
+
var tslib_12 = require$$0, tiny_invariant_1 = tslib_12.__importDefault(requireTinyInvariant_cjs()), util_1 = requireUtil(), Mapping = (
|
|
7724
7740
|
/** @class */
|
|
7725
7741
|
function() {
|
|
7726
7742
|
function Mapping2(sourceLines, sourceLoc, targetLoc) {
|
|
@@ -7731,7 +7747,7 @@ function requireMapping() {
|
|
|
7731
7747
|
var sourceLines = this.sourceLines, sourceLoc = this.sourceLoc, targetLoc = this.targetLoc;
|
|
7732
7748
|
function skip(name) {
|
|
7733
7749
|
var sourceFromPos = sourceLoc[name], targetFromPos = targetLoc[name], targetToPos = start;
|
|
7734
|
-
return name === "end" ? targetToPos = end :
|
|
7750
|
+
return name === "end" ? targetToPos = end : (0, tiny_invariant_1.default)(name === "start"), skipChars(sourceLines, sourceFromPos, lines2, targetFromPos, targetToPos);
|
|
7735
7751
|
}
|
|
7736
7752
|
if ((0, util_1.comparePos)(start, targetLoc.start) <= 0)
|
|
7737
7753
|
if ((0, util_1.comparePos)(targetLoc.end, end) <= 0)
|
|
@@ -7828,13 +7844,13 @@ function requireMapping() {
|
|
|
7828
7844
|
if (targetComparison < 0) {
|
|
7829
7845
|
sourceCursor = sourceLines.skipSpaces(sourceFromPos) || sourceLines.lastPos(), targetCursor = targetLines.skipSpaces(targetFromPos) || targetLines.lastPos();
|
|
7830
7846
|
var lineDiff = targetToPos.line - targetCursor.line;
|
|
7831
|
-
for (sourceCursor.line += lineDiff, targetCursor.line += lineDiff, lineDiff > 0 ? (sourceCursor.column = 0, targetCursor.column = 0) :
|
|
7832
|
-
|
|
7847
|
+
for (sourceCursor.line += lineDiff, targetCursor.line += lineDiff, lineDiff > 0 ? (sourceCursor.column = 0, targetCursor.column = 0) : (0, tiny_invariant_1.default)(lineDiff === 0); (0, util_1.comparePos)(targetCursor, targetToPos) < 0 && targetLines.nextPos(targetCursor, !0); )
|
|
7848
|
+
(0, tiny_invariant_1.default)(sourceLines.nextPos(sourceCursor, !0)), (0, tiny_invariant_1.default)(sourceLines.charAt(sourceCursor) === targetLines.charAt(targetCursor));
|
|
7833
7849
|
} else {
|
|
7834
7850
|
sourceCursor = sourceLines.skipSpaces(sourceFromPos, !0) || sourceLines.firstPos(), targetCursor = targetLines.skipSpaces(targetFromPos, !0) || targetLines.firstPos();
|
|
7835
7851
|
var lineDiff = targetToPos.line - targetCursor.line;
|
|
7836
|
-
for (sourceCursor.line += lineDiff, targetCursor.line += lineDiff, lineDiff < 0 ? (sourceCursor.column = sourceLines.getLineLength(sourceCursor.line), targetCursor.column = targetLines.getLineLength(targetCursor.line)) :
|
|
7837
|
-
|
|
7852
|
+
for (sourceCursor.line += lineDiff, targetCursor.line += lineDiff, lineDiff < 0 ? (sourceCursor.column = sourceLines.getLineLength(sourceCursor.line), targetCursor.column = targetLines.getLineLength(targetCursor.line)) : (0, tiny_invariant_1.default)(lineDiff === 0); (0, util_1.comparePos)(targetToPos, targetCursor) < 0 && targetLines.prevPos(targetCursor, !0); )
|
|
7853
|
+
(0, tiny_invariant_1.default)(sourceLines.prevPos(sourceCursor, !0)), (0, tiny_invariant_1.default)(sourceLines.charAt(sourceCursor) === targetLines.charAt(targetCursor));
|
|
7838
7854
|
}
|
|
7839
7855
|
return sourceCursor;
|
|
7840
7856
|
}
|
|
@@ -7845,11 +7861,11 @@ function requireLines() {
|
|
|
7845
7861
|
if (hasRequiredLines)
|
|
7846
7862
|
return lines;
|
|
7847
7863
|
hasRequiredLines = 1, Object.defineProperty(lines, "__esModule", { value: !0 }), lines.concat = lines.fromString = lines.countSpaces = lines.Lines = void 0;
|
|
7848
|
-
var tslib_12 = require$$0,
|
|
7864
|
+
var tslib_12 = require$$0, tiny_invariant_1 = tslib_12.__importDefault(requireTinyInvariant_cjs()), source_map_1 = tslib_12.__importDefault(requireSourceMap()), options_1 = requireOptions(), util_1 = requireUtil(), mapping_1 = tslib_12.__importDefault(requireMapping()), Lines = (
|
|
7849
7865
|
/** @class */
|
|
7850
7866
|
function() {
|
|
7851
7867
|
function Lines2(infos, sourceFileName) {
|
|
7852
|
-
sourceFileName === void 0 && (sourceFileName = null), this.infos = infos, this.mappings = [], this.cachedSourceMap = null, this.cachedTabWidth = void 0,
|
|
7868
|
+
sourceFileName === void 0 && (sourceFileName = null), this.infos = infos, this.mappings = [], this.cachedSourceMap = null, this.cachedTabWidth = void 0, (0, tiny_invariant_1.default)(infos.length > 0), this.length = infos.length, this.name = sourceFileName || null, this.name && this.mappings.push(new mapping_1.default(this, {
|
|
7853
7869
|
start: this.firstPos(),
|
|
7854
7870
|
end: this.lastPos()
|
|
7855
7871
|
}));
|
|
@@ -7869,7 +7885,7 @@ function requireLines() {
|
|
|
7869
7885
|
return targetLines.mappings.forEach(function(mapping2) {
|
|
7870
7886
|
for (var sourceCursor = mapping2.sourceLines.skipSpaces(mapping2.sourceLoc.start) || mapping2.sourceLines.lastPos(), targetCursor = targetLines.skipSpaces(mapping2.targetLoc.start) || targetLines.lastPos(); (0, util_1.comparePos)(sourceCursor, mapping2.sourceLoc.end) < 0 && (0, util_1.comparePos)(targetCursor, mapping2.targetLoc.end) < 0; ) {
|
|
7871
7887
|
var sourceChar = mapping2.sourceLines.charAt(sourceCursor), targetChar = targetLines.charAt(targetCursor);
|
|
7872
|
-
|
|
7888
|
+
(0, tiny_invariant_1.default)(sourceChar === targetChar);
|
|
7873
7889
|
var sourceName = mapping2.sourceLines.name;
|
|
7874
7890
|
if (smg.addMapping({
|
|
7875
7891
|
source: sourceName,
|
|
@@ -7883,12 +7899,12 @@ function requireLines() {
|
|
|
7883
7899
|
}
|
|
7884
7900
|
}), targetLines.cachedSourceMap = smg, smg.toJSON();
|
|
7885
7901
|
}, Lines2.prototype.bootstrapCharAt = function(pos) {
|
|
7886
|
-
|
|
7902
|
+
(0, tiny_invariant_1.default)(typeof pos == "object"), (0, tiny_invariant_1.default)(typeof pos.line == "number"), (0, tiny_invariant_1.default)(typeof pos.column == "number");
|
|
7887
7903
|
var line = pos.line, column = pos.column, strings = this.toString().split(lineTerminatorSeqExp), string = strings[line - 1];
|
|
7888
7904
|
return typeof string > "u" ? "" : column === string.length && line < strings.length ? `
|
|
7889
7905
|
` : column >= string.length ? "" : string.charAt(column);
|
|
7890
7906
|
}, Lines2.prototype.charAt = function(pos) {
|
|
7891
|
-
|
|
7907
|
+
(0, tiny_invariant_1.default)(typeof pos == "object"), (0, tiny_invariant_1.default)(typeof pos.line == "number"), (0, tiny_invariant_1.default)(typeof pos.column == "number");
|
|
7892
7908
|
var line = pos.line, column = pos.column, secret = this, infos = secret.infos, info = infos[line - 1], c = column;
|
|
7893
7909
|
if (typeof info > "u" || c < 0)
|
|
7894
7910
|
return "";
|
|
@@ -7898,14 +7914,14 @@ function requireLines() {
|
|
|
7898
7914
|
}, Lines2.prototype.stripMargin = function(width, skipFirstLine) {
|
|
7899
7915
|
if (width === 0)
|
|
7900
7916
|
return this;
|
|
7901
|
-
if (
|
|
7917
|
+
if ((0, tiny_invariant_1.default)(width > 0, "negative margin: " + width), skipFirstLine && this.length === 1)
|
|
7902
7918
|
return this;
|
|
7903
7919
|
var lines2 = new Lines2(this.infos.map(function(info, i) {
|
|
7904
7920
|
return info.line && (i > 0 || !skipFirstLine) && (info = tslib_12.__assign(tslib_12.__assign({}, info), { indent: Math.max(0, info.indent - width) })), info;
|
|
7905
7921
|
}));
|
|
7906
7922
|
if (this.mappings.length > 0) {
|
|
7907
7923
|
var newMappings_1 = lines2.mappings;
|
|
7908
|
-
|
|
7924
|
+
(0, tiny_invariant_1.default)(newMappings_1.length === 0), this.mappings.forEach(function(mapping2) {
|
|
7909
7925
|
newMappings_1.push(mapping2.indent(width, skipFirstLine, !0));
|
|
7910
7926
|
});
|
|
7911
7927
|
}
|
|
@@ -7918,7 +7934,7 @@ function requireLines() {
|
|
|
7918
7934
|
}));
|
|
7919
7935
|
if (this.mappings.length > 0) {
|
|
7920
7936
|
var newMappings_2 = lines2.mappings;
|
|
7921
|
-
|
|
7937
|
+
(0, tiny_invariant_1.default)(newMappings_2.length === 0), this.mappings.forEach(function(mapping2) {
|
|
7922
7938
|
newMappings_2.push(mapping2.indent(by));
|
|
7923
7939
|
});
|
|
7924
7940
|
}
|
|
@@ -7933,7 +7949,7 @@ function requireLines() {
|
|
|
7933
7949
|
}));
|
|
7934
7950
|
if (this.mappings.length > 0) {
|
|
7935
7951
|
var newMappings_3 = lines2.mappings;
|
|
7936
|
-
|
|
7952
|
+
(0, tiny_invariant_1.default)(newMappings_3.length === 0), this.mappings.forEach(function(mapping2) {
|
|
7937
7953
|
newMappings_3.push(mapping2.indent(by, !0));
|
|
7938
7954
|
});
|
|
7939
7955
|
}
|
|
@@ -7943,7 +7959,7 @@ function requireLines() {
|
|
|
7943
7959
|
return tslib_12.__assign(tslib_12.__assign({}, info), { locked: i > 0 });
|
|
7944
7960
|
}));
|
|
7945
7961
|
}, Lines2.prototype.getIndentAt = function(line) {
|
|
7946
|
-
return
|
|
7962
|
+
return (0, tiny_invariant_1.default)(line >= 1, "no line " + line + " (line numbers start from 1)"), Math.max(this.infos[line - 1].indent, 0);
|
|
7947
7963
|
}, Lines2.prototype.guessTabWidth = function() {
|
|
7948
7964
|
if (typeof this.cachedTabWidth == "number")
|
|
7949
7965
|
return this.cachedTabWidth;
|
|
@@ -8041,11 +8057,11 @@ function requireLines() {
|
|
|
8041
8057
|
if (!start)
|
|
8042
8058
|
throw new Error("cannot slice with end but not start");
|
|
8043
8059
|
var sliced = this.infos.slice(start.line - 1, end.line);
|
|
8044
|
-
start.line === end.line ? sliced[0] = sliceInfo(sliced[0], start.column, end.column) : (
|
|
8060
|
+
start.line === end.line ? sliced[0] = sliceInfo(sliced[0], start.column, end.column) : ((0, tiny_invariant_1.default)(start.line < end.line), sliced[0] = sliceInfo(sliced[0], start.column), sliced.push(sliceInfo(sliced.pop(), 0, end.column)));
|
|
8045
8061
|
var lines2 = new Lines2(sliced);
|
|
8046
8062
|
if (this.mappings.length > 0) {
|
|
8047
8063
|
var newMappings_4 = lines2.mappings;
|
|
8048
|
-
|
|
8064
|
+
(0, tiny_invariant_1.default)(newMappings_4.length === 0), this.mappings.forEach(function(mapping2) {
|
|
8049
8065
|
var sliced2 = mapping2.slice(this, start, end);
|
|
8050
8066
|
sliced2 && newMappings_4.push(sliced2);
|
|
8051
8067
|
}, this);
|
|
@@ -8103,7 +8119,7 @@ function requireLines() {
|
|
|
8103
8119
|
for (var args = [], _i = 0; _i < arguments.length; _i++)
|
|
8104
8120
|
args[_i] = arguments[_i];
|
|
8105
8121
|
var list = [this];
|
|
8106
|
-
return list.push.apply(list, args),
|
|
8122
|
+
return list.push.apply(list, args), (0, tiny_invariant_1.default)(list.length === args.length + 1), emptyLines.join(list);
|
|
8107
8123
|
}, Lines2;
|
|
8108
8124
|
}()
|
|
8109
8125
|
);
|
|
@@ -8113,7 +8129,7 @@ function requireLines() {
|
|
|
8113
8129
|
for (var count = 0, len = spaces.length, i = 0; i < len; ++i)
|
|
8114
8130
|
switch (spaces.charCodeAt(i)) {
|
|
8115
8131
|
case 9: {
|
|
8116
|
-
|
|
8132
|
+
(0, tiny_invariant_1.default)(typeof tabWidth == "number"), (0, tiny_invariant_1.default)(tabWidth > 0);
|
|
8117
8133
|
var next = Math.ceil(count / tabWidth) * tabWidth;
|
|
8118
8134
|
next === count ? count += tabWidth : count = next;
|
|
8119
8135
|
break;
|
|
@@ -8137,7 +8153,7 @@ function requireLines() {
|
|
|
8137
8153
|
return string;
|
|
8138
8154
|
string += "";
|
|
8139
8155
|
var tabWidth = options2 && options2.tabWidth, tabless = string.indexOf(" ") < 0, cacheable = !options2 && tabless && string.length <= maxCacheKeyLen;
|
|
8140
|
-
if (
|
|
8156
|
+
if ((0, tiny_invariant_1.default)(tabWidth || tabless, `No tab width specified but encountered tabs in string
|
|
8141
8157
|
` + string), cacheable && hasOwn.call(fromStringCache, string))
|
|
8142
8158
|
return fromStringCache[string];
|
|
8143
8159
|
var lines2 = new Lines(string.split(lineTerminatorSeqExp).map(function(line) {
|
|
@@ -8159,7 +8175,7 @@ function requireLines() {
|
|
|
8159
8175
|
}
|
|
8160
8176
|
function sliceInfo(info, startCol, endCol) {
|
|
8161
8177
|
var sliceStart = info.sliceStart, sliceEnd = info.sliceEnd, indent = Math.max(info.indent, 0), lineLength = indent + sliceEnd - sliceStart;
|
|
8162
|
-
return typeof endCol > "u" && (endCol = lineLength), startCol = Math.max(startCol, 0), endCol = Math.min(endCol, lineLength), endCol = Math.max(endCol, startCol), endCol < indent ? (indent = endCol, sliceEnd = sliceStart) : sliceEnd -= lineLength - endCol, lineLength = endCol, lineLength -= startCol, startCol < indent ? indent -= startCol : (startCol -= indent, indent = 0, sliceStart += startCol),
|
|
8178
|
+
return typeof endCol > "u" && (endCol = lineLength), startCol = Math.max(startCol, 0), endCol = Math.min(endCol, lineLength), endCol = Math.max(endCol, startCol), endCol < indent ? (indent = endCol, sliceEnd = sliceStart) : sliceEnd -= lineLength - endCol, lineLength = endCol, lineLength -= startCol, startCol < indent ? indent -= startCol : (startCol -= indent, indent = 0, sliceStart += startCol), (0, tiny_invariant_1.default)(indent >= 0), (0, tiny_invariant_1.default)(sliceStart <= sliceEnd), (0, tiny_invariant_1.default)(lineLength === indent + sliceEnd - sliceStart), info.indent === indent && info.sliceStart === sliceStart && info.sliceEnd === sliceEnd ? info : {
|
|
8163
8179
|
line: info.line,
|
|
8164
8180
|
indent,
|
|
8165
8181
|
// A destructive slice always unlocks indentation.
|
|
@@ -8180,7 +8196,7 @@ function requireComments() {
|
|
|
8180
8196
|
if (hasRequiredComments)
|
|
8181
8197
|
return comments;
|
|
8182
8198
|
hasRequiredComments = 1, Object.defineProperty(comments, "__esModule", { value: !0 }), comments.printComments = comments.attach = void 0;
|
|
8183
|
-
var tslib_12 = require$$0,
|
|
8199
|
+
var tslib_12 = require$$0, tiny_invariant_1 = tslib_12.__importDefault(requireTinyInvariant_cjs()), types2 = tslib_12.__importStar(requireMain()), n = types2.namedTypes, isArray = types2.builtInTypes.array, isObject = types2.builtInTypes.object, lines_1 = requireLines(), util_1 = requireUtil(), childNodesCache = /* @__PURE__ */ new WeakMap();
|
|
8184
8200
|
function getSortedChildNodes(node, lines2, resultArray) {
|
|
8185
8201
|
if (!node)
|
|
8186
8202
|
return resultArray;
|
|
@@ -8239,7 +8255,7 @@ function requireComments() {
|
|
|
8239
8255
|
var tieCount = tiesToBreak.length;
|
|
8240
8256
|
if (tieCount > 0) {
|
|
8241
8257
|
var lastTie = tiesToBreak[tieCount - 1];
|
|
8242
|
-
|
|
8258
|
+
(0, tiny_invariant_1.default)(lastTie.precedingNode === comment.precedingNode == (lastTie.followingNode === comment.followingNode)), lastTie.followingNode !== comment.followingNode && breakTies(tiesToBreak, lines2);
|
|
8243
8259
|
}
|
|
8244
8260
|
tiesToBreak.push(comment);
|
|
8245
8261
|
} else if (pn)
|
|
@@ -8260,7 +8276,7 @@ function requireComments() {
|
|
|
8260
8276
|
var tieCount = tiesToBreak.length;
|
|
8261
8277
|
if (tieCount !== 0) {
|
|
8262
8278
|
for (var pn = tiesToBreak[0].precedingNode, fn = tiesToBreak[0].followingNode, gapEndPos = fn.loc.start, indexOfFirstLeadingComment = tieCount, comment; indexOfFirstLeadingComment > 0; --indexOfFirstLeadingComment) {
|
|
8263
|
-
comment = tiesToBreak[indexOfFirstLeadingComment - 1],
|
|
8279
|
+
comment = tiesToBreak[indexOfFirstLeadingComment - 1], (0, tiny_invariant_1.default)(comment.precedingNode === pn), (0, tiny_invariant_1.default)(comment.followingNode === fn);
|
|
8264
8280
|
var gap = lines2.sliceString(comment.loc.end, gapEndPos);
|
|
8265
8281
|
if (/\S/.test(gap))
|
|
8266
8282
|
break;
|
|
@@ -8336,7 +8352,7 @@ function requireParser() {
|
|
|
8336
8352
|
if (hasRequiredParser)
|
|
8337
8353
|
return parser;
|
|
8338
8354
|
hasRequiredParser = 1, Object.defineProperty(parser, "__esModule", { value: !0 }), parser.parse = void 0;
|
|
8339
|
-
var tslib_12 = require$$0,
|
|
8355
|
+
var tslib_12 = require$$0, tiny_invariant_1 = tslib_12.__importDefault(requireTinyInvariant_cjs()), types2 = tslib_12.__importStar(requireMain()), b = types2.builders, isObject = types2.builtInTypes.object, isArray = types2.builtInTypes.array, options_1 = requireOptions(), lines_1 = requireLines(), comments_1 = requireComments(), util2 = tslib_12.__importStar(requireUtil());
|
|
8340
8356
|
function parse2(source, options2) {
|
|
8341
8357
|
options2 = (0, options_1.normalize)(options2);
|
|
8342
8358
|
var lines2 = (0, lines_1.fromString)(source, options2), sourceWithoutTabs = lines2.toString({
|
|
@@ -8379,7 +8395,7 @@ function requireParser() {
|
|
|
8379
8395
|
}
|
|
8380
8396
|
parser.parse = parse2;
|
|
8381
8397
|
var TreeCopier = function TreeCopier2(lines2, tokens) {
|
|
8382
|
-
|
|
8398
|
+
(0, tiny_invariant_1.default)(this instanceof TreeCopier2), this.lines = lines2, this.tokens = tokens, this.startTokenIndex = 0, this.endTokenIndex = tokens.length, this.indent = 0, this.seen = /* @__PURE__ */ new Map();
|
|
8383
8399
|
}, TCp = TreeCopier.prototype;
|
|
8384
8400
|
return TCp.copy = function(node) {
|
|
8385
8401
|
if (this.seen.has(node))
|
|
@@ -8447,7 +8463,7 @@ function requireFastPath() {
|
|
|
8447
8463
|
if (hasRequiredFastPath)
|
|
8448
8464
|
return fastPath;
|
|
8449
8465
|
hasRequiredFastPath = 1, Object.defineProperty(fastPath, "__esModule", { value: !0 });
|
|
8450
|
-
var tslib_12 = require$$0,
|
|
8466
|
+
var tslib_12 = require$$0, tiny_invariant_1 = tslib_12.__importDefault(requireTinyInvariant_cjs()), types2 = tslib_12.__importStar(requireMain()), util2 = tslib_12.__importStar(requireUtil()), n = types2.namedTypes, isArray = types2.builtInTypes.array, isNumber = types2.builtInTypes.number, PRECEDENCE = {};
|
|
8451
8467
|
[
|
|
8452
8468
|
["??"],
|
|
8453
8469
|
["||"],
|
|
@@ -8467,7 +8483,7 @@ function requireFastPath() {
|
|
|
8467
8483
|
});
|
|
8468
8484
|
});
|
|
8469
8485
|
var FastPath = function FastPath2(value) {
|
|
8470
|
-
|
|
8486
|
+
(0, tiny_invariant_1.default)(this instanceof FastPath2), this.stack = [value];
|
|
8471
8487
|
}, FPp = FastPath.prototype;
|
|
8472
8488
|
FastPath.from = function(obj) {
|
|
8473
8489
|
if (obj instanceof FastPath)
|
|
@@ -8603,7 +8619,7 @@ function requireFastPath() {
|
|
|
8603
8619
|
if (pp > np)
|
|
8604
8620
|
return !0;
|
|
8605
8621
|
if (pp === np && name === "right")
|
|
8606
|
-
return
|
|
8622
|
+
return (0, tiny_invariant_1.default)(parent.right === node), !0;
|
|
8607
8623
|
break;
|
|
8608
8624
|
}
|
|
8609
8625
|
default:
|
|
@@ -8682,35 +8698,35 @@ function requireFastPath() {
|
|
|
8682
8698
|
for (var s = this.stack, parentName, parent, childName, child, i = s.length - 1; i >= 0; i -= 2)
|
|
8683
8699
|
if (n.Node.check(s[i]) && (childName = parentName, child = parent, parentName = s[i - 1], parent = s[i]), !(!parent || !child)) {
|
|
8684
8700
|
if (n.BlockStatement.check(parent) && parentName === "body" && childName === 0)
|
|
8685
|
-
return
|
|
8701
|
+
return (0, tiny_invariant_1.default)(parent.body[0] === child), !0;
|
|
8686
8702
|
if (n.ExpressionStatement.check(parent) && childName === "expression")
|
|
8687
|
-
return
|
|
8703
|
+
return (0, tiny_invariant_1.default)(parent.expression === child), !0;
|
|
8688
8704
|
if (n.AssignmentExpression.check(parent) && childName === "left")
|
|
8689
|
-
return
|
|
8705
|
+
return (0, tiny_invariant_1.default)(parent.left === child), !0;
|
|
8690
8706
|
if (n.ArrowFunctionExpression.check(parent) && childName === "body")
|
|
8691
|
-
return
|
|
8707
|
+
return (0, tiny_invariant_1.default)(parent.body === child), !0;
|
|
8692
8708
|
if (n.SequenceExpression.check(parent) && s[i + 1] === "expressions" && childName === 0) {
|
|
8693
|
-
|
|
8709
|
+
(0, tiny_invariant_1.default)(parent.expressions[0] === child);
|
|
8694
8710
|
continue;
|
|
8695
8711
|
}
|
|
8696
8712
|
if (n.CallExpression.check(parent) && childName === "callee") {
|
|
8697
|
-
|
|
8713
|
+
(0, tiny_invariant_1.default)(parent.callee === child);
|
|
8698
8714
|
continue;
|
|
8699
8715
|
}
|
|
8700
8716
|
if (n.MemberExpression.check(parent) && childName === "object") {
|
|
8701
|
-
|
|
8717
|
+
(0, tiny_invariant_1.default)(parent.object === child);
|
|
8702
8718
|
continue;
|
|
8703
8719
|
}
|
|
8704
8720
|
if (n.ConditionalExpression.check(parent) && childName === "test") {
|
|
8705
|
-
|
|
8721
|
+
(0, tiny_invariant_1.default)(parent.test === child);
|
|
8706
8722
|
continue;
|
|
8707
8723
|
}
|
|
8708
8724
|
if (isBinary(parent) && childName === "left") {
|
|
8709
|
-
|
|
8725
|
+
(0, tiny_invariant_1.default)(parent.left === child);
|
|
8710
8726
|
continue;
|
|
8711
8727
|
}
|
|
8712
8728
|
if (n.UnaryExpression.check(parent) && !parent.prefix && childName === "argument") {
|
|
8713
|
-
|
|
8729
|
+
(0, tiny_invariant_1.default)(parent.argument === child);
|
|
8714
8730
|
continue;
|
|
8715
8731
|
}
|
|
8716
8732
|
return !1;
|
|
@@ -8723,8 +8739,8 @@ function requirePatcher() {
|
|
|
8723
8739
|
if (hasRequiredPatcher)
|
|
8724
8740
|
return patcher;
|
|
8725
8741
|
hasRequiredPatcher = 1, Object.defineProperty(patcher, "__esModule", { value: !0 }), patcher.getReprinter = patcher.Patcher = void 0;
|
|
8726
|
-
var tslib_12 = require$$0,
|
|
8727
|
-
|
|
8742
|
+
var tslib_12 = require$$0, tiny_invariant_1 = tslib_12.__importDefault(requireTinyInvariant_cjs()), linesModule = tslib_12.__importStar(requireLines()), types2 = tslib_12.__importStar(requireMain()), Printable = types2.namedTypes.Printable, Expression = types2.namedTypes.Expression, ReturnStatement = types2.namedTypes.ReturnStatement, SourceLocation = types2.namedTypes.SourceLocation, util_1 = requireUtil(), fast_path_1 = tslib_12.__importDefault(requireFastPath()), isObject = types2.builtInTypes.object, isArray = types2.builtInTypes.array, isString = types2.builtInTypes.string, riskyAdjoiningCharExp = /[0-9a-z_$]/i, Patcher = function Patcher2(lines2) {
|
|
8743
|
+
(0, tiny_invariant_1.default)(this instanceof Patcher2), (0, tiny_invariant_1.default)(lines2 instanceof linesModule.Lines);
|
|
8728
8744
|
var self2 = this, replacements = [];
|
|
8729
8745
|
self2.replace = function(loc, lines3) {
|
|
8730
8746
|
isString.check(lines3) && (lines3 = linesModule.fromString(lines3)), replacements.push({
|
|
@@ -8739,7 +8755,7 @@ function requirePatcher() {
|
|
|
8739
8755
|
};
|
|
8740
8756
|
var sliceFrom = loc.start, toConcat = [];
|
|
8741
8757
|
function pushSlice(from, to) {
|
|
8742
|
-
|
|
8758
|
+
(0, tiny_invariant_1.default)((0, util_1.comparePos)(from, to) <= 0), toConcat.push(lines2.slice(from, to));
|
|
8743
8759
|
}
|
|
8744
8760
|
return replacements.sort(function(a, b) {
|
|
8745
8761
|
return (0, util_1.comparePos)(a.start, b.start);
|
|
@@ -8759,7 +8775,7 @@ function requirePatcher() {
|
|
|
8759
8775
|
var reprints = [], ableToReprintComments = findArrayReprints(newPath, oldPath, reprints);
|
|
8760
8776
|
return ableToReprintComments && reprints.length > 0 && reprints.forEach(function(reprint) {
|
|
8761
8777
|
var oldComment = reprint.oldPath.getValue();
|
|
8762
|
-
|
|
8778
|
+
(0, tiny_invariant_1.default)(oldComment.leading || oldComment.trailing), patcher2.replace(
|
|
8763
8779
|
oldComment.loc,
|
|
8764
8780
|
// Comments can't have .comments, so it doesn't matter whether we
|
|
8765
8781
|
// print with comments or without.
|
|
@@ -8788,7 +8804,7 @@ function requirePatcher() {
|
|
|
8788
8804
|
}
|
|
8789
8805
|
};
|
|
8790
8806
|
function getReprinter(path2) {
|
|
8791
|
-
|
|
8807
|
+
(0, tiny_invariant_1.default)(path2 instanceof fast_path_1.default);
|
|
8792
8808
|
var node = path2.getValue();
|
|
8793
8809
|
if (Printable.check(node)) {
|
|
8794
8810
|
var orig = node.original, origLoc = orig && orig.loc, lines2 = origLoc && origLoc.lines, reprints = [];
|
|
@@ -8833,7 +8849,7 @@ function requirePatcher() {
|
|
|
8833
8849
|
var newNode = newPath.getValue();
|
|
8834
8850
|
Printable.assert(newNode);
|
|
8835
8851
|
var oldNode = newNode.original;
|
|
8836
|
-
if (Printable.assert(oldNode),
|
|
8852
|
+
if (Printable.assert(oldNode), (0, tiny_invariant_1.default)(reprints.length === 0), newNode.type !== oldNode.type)
|
|
8837
8853
|
return !1;
|
|
8838
8854
|
var oldPath = new fast_path_1.default(oldNode), canReprint = findChildReprints(newPath, oldPath, reprints);
|
|
8839
8855
|
return canReprint || (reprints.length = 0), canReprint;
|
|
@@ -8921,14 +8937,14 @@ function requirePrinter() {
|
|
|
8921
8937
|
if (hasRequiredPrinter)
|
|
8922
8938
|
return printer;
|
|
8923
8939
|
hasRequiredPrinter = 1, Object.defineProperty(printer, "__esModule", { value: !0 }), printer.Printer = void 0;
|
|
8924
|
-
var tslib_12 = require$$0,
|
|
8925
|
-
|
|
8940
|
+
var tslib_12 = require$$0, tiny_invariant_1 = tslib_12.__importDefault(requireTinyInvariant_cjs()), types2 = tslib_12.__importStar(requireMain()), comments_1 = requireComments(), fast_path_1 = tslib_12.__importDefault(requireFastPath()), lines_1 = requireLines(), options_1 = requireOptions(), patcher_1 = requirePatcher(), util2 = tslib_12.__importStar(requireUtil()), namedTypes2 = types2.namedTypes, isString = types2.builtInTypes.string, isObject = types2.builtInTypes.object, PrintResult = function PrintResult2(code, sourceMap2) {
|
|
8941
|
+
(0, tiny_invariant_1.default)(this instanceof PrintResult2), isString.assert(code), this.code = code, sourceMap2 && (isObject.assert(sourceMap2), this.map = sourceMap2);
|
|
8926
8942
|
}, PRp = PrintResult.prototype, warnedAboutToString = !1;
|
|
8927
8943
|
PRp.toString = function() {
|
|
8928
8944
|
return warnedAboutToString || (console.warn("Deprecation warning: recast.print now returns an object with a .code property. You appear to be treating the object as a string, which might still work but is strongly discouraged."), warnedAboutToString = !0), this.code;
|
|
8929
8945
|
};
|
|
8930
8946
|
var emptyPrintResult = new PrintResult(""), Printer = function Printer2(config) {
|
|
8931
|
-
|
|
8947
|
+
(0, tiny_invariant_1.default)(this instanceof Printer2);
|
|
8932
8948
|
var explicitTabWidth = config && config.tabWidth;
|
|
8933
8949
|
config = (0, options_1.normalize)(config), config.sourceFileName = null;
|
|
8934
8950
|
function makePrintFunctionWith(options2, overrides) {
|
|
@@ -8937,7 +8953,7 @@ function requirePrinter() {
|
|
|
8937
8953
|
};
|
|
8938
8954
|
}
|
|
8939
8955
|
function print(path2, options2) {
|
|
8940
|
-
if (
|
|
8956
|
+
if ((0, tiny_invariant_1.default)(path2 instanceof fast_path_1.default), options2 = options2 || {}, options2.includeComments)
|
|
8941
8957
|
return (0, comments_1.printComments)(path2, makePrintFunctionWith(options2, {
|
|
8942
8958
|
includeComments: !1
|
|
8943
8959
|
}));
|
|
@@ -8989,7 +9005,7 @@ function requirePrinter() {
|
|
|
8989
9005
|
};
|
|
8990
9006
|
printer.Printer = Printer;
|
|
8991
9007
|
function genericPrint(path2, config, options2, printPath) {
|
|
8992
|
-
|
|
9008
|
+
(0, tiny_invariant_1.default)(path2 instanceof fast_path_1.default);
|
|
8993
9009
|
var node = path2.getValue(), parts = [], linesWithoutParens = genericPrintNoParens(path2, config, printPath);
|
|
8994
9010
|
if (!node || linesWithoutParens.isEmpty())
|
|
8995
9011
|
return linesWithoutParens;
|
|
@@ -9092,7 +9108,7 @@ function requirePrinter() {
|
|
|
9092
9108
|
}`
|
|
9093
9109
|
]);
|
|
9094
9110
|
case "ModuleDeclaration":
|
|
9095
|
-
return parts.push("module", path2.call(print, "id")), n.source ? (
|
|
9111
|
+
return parts.push("module", path2.call(print, "id")), n.source ? ((0, tiny_invariant_1.default)(!n.body), parts.push("from", path2.call(print, "source"))) : parts.push(path2.call(print, "body")), (0, lines_1.fromString)(" ").join(parts);
|
|
9096
9112
|
case "ImportSpecifier":
|
|
9097
9113
|
return n.importKind && n.importKind !== "value" && parts.push(n.importKind + " "), n.imported ? (parts.push(path2.call(print, "imported")), n.local && n.local.name !== n.imported.name && parts.push(" as ", path2.call(print, "local"))) : n.id && (parts.push(path2.call(print, "id")), n.name && parts.push(" as ", path2.call(print, "name"))), (0, lines_1.concat)(parts);
|
|
9098
9114
|
case "ExportSpecifier":
|
|
@@ -9424,7 +9440,7 @@ while`), parts.push(" (", path2.call(print, "test"), ");"), (0, lines_1.concat)(
|
|
|
9424
9440
|
case "JSXFragment": {
|
|
9425
9441
|
var openingPropName = "opening" + (n.type === "JSXElement" ? "Element" : "Fragment"), closingPropName = "closing" + (n.type === "JSXElement" ? "Element" : "Fragment"), openingLines = path2.call(print, openingPropName);
|
|
9426
9442
|
if (n[openingPropName].selfClosing)
|
|
9427
|
-
return
|
|
9443
|
+
return (0, tiny_invariant_1.default)(!n[closingPropName], "unexpected " + closingPropName + " element in self-closing " + n.type), openingLines;
|
|
9428
9444
|
var childLines = (0, lines_1.concat)(path2.map(function(childPath) {
|
|
9429
9445
|
var child = childPath.getValue();
|
|
9430
9446
|
if (namedTypes2.Literal.check(child) && typeof child.value == "string") {
|
|
@@ -9446,7 +9462,7 @@ while`), parts.push(" (", path2.call(print, "test"), ");"), (0, lines_1.concat)(
|
|
|
9446
9462
|
}, "attributes");
|
|
9447
9463
|
var attrLines = (0, lines_1.concat)(attrParts_1), needLineWrap = attrLines.length > 1 || attrLines.getLineLength(1) > options2.wrapColumn;
|
|
9448
9464
|
return needLineWrap && (attrParts_1.forEach(function(part, i) {
|
|
9449
|
-
part === " " && (
|
|
9465
|
+
part === " " && ((0, tiny_invariant_1.default)(i % 2 === 0), attrParts_1[i] = `
|
|
9450
9466
|
`);
|
|
9451
9467
|
}), attrLines = (0, lines_1.concat)(attrParts_1).indentTail(options2.tabWidth)), parts.push(attrLines, n.selfClosing ? " />" : ">"), (0, lines_1.concat)(parts);
|
|
9452
9468
|
}
|
|
@@ -9562,7 +9578,7 @@ while`), parts.push(" (", path2.call(print, "test"), ");"), (0, lines_1.concat)(
|
|
|
9562
9578
|
case "BooleanTypeAnnotation":
|
|
9563
9579
|
return (0, lines_1.fromString)("boolean", options2);
|
|
9564
9580
|
case "BooleanLiteralTypeAnnotation":
|
|
9565
|
-
return
|
|
9581
|
+
return (0, tiny_invariant_1.default)(typeof n.value == "boolean"), (0, lines_1.fromString)("" + n.value, options2);
|
|
9566
9582
|
case "InterfaceTypeAnnotation":
|
|
9567
9583
|
return parts.push("interface"), n.extends && n.extends.length > 0 && parts.push(" extends ", (0, lines_1.fromString)(", ").join(path2.map(print, "extends"))), parts.push(" ", path2.call(print, "body")), (0, lines_1.concat)(parts);
|
|
9568
9584
|
case "DeclareFunction":
|
|
@@ -9689,7 +9705,7 @@ while`), parts.push(" (", path2.call(print, "test"), ");"), (0, lines_1.concat)(
|
|
|
9689
9705
|
return (0, lines_1.fromString)(nodeStr(n.value, options2), options2);
|
|
9690
9706
|
case "NumberLiteralTypeAnnotation":
|
|
9691
9707
|
case "NumericLiteralTypeAnnotation":
|
|
9692
|
-
return
|
|
9708
|
+
return (0, tiny_invariant_1.default)(typeof n.value == "number"), (0, lines_1.fromString)(JSON.stringify(n.value), options2);
|
|
9693
9709
|
case "BigIntLiteralTypeAnnotation":
|
|
9694
9710
|
return (0, lines_1.fromString)(n.raw, options2);
|
|
9695
9711
|
case "StringTypeAnnotation":
|
|
@@ -10036,7 +10052,7 @@ while`), parts.push(" (", path2.call(print, "test"), ");"), (0, lines_1.concat)(
|
|
|
10036
10052
|
node: stmt,
|
|
10037
10053
|
printed: print(stmtPath)
|
|
10038
10054
|
})));
|
|
10039
|
-
}), sawComment &&
|
|
10055
|
+
}), sawComment && (0, tiny_invariant_1.default)(sawStatement === !1, "Comments may appear as statements in otherwise empty statement lists, but may not coexist with non-Comment nodes.");
|
|
10040
10056
|
var prevTrailingSpace = null, len = filtered.length, parts = [];
|
|
10041
10057
|
return filtered.forEach(function(info, i) {
|
|
10042
10058
|
var printed = info.printed, stmt = info.node, multiLine = printed.length > 1, notFirst = i > 0, notLast = i < len - 1, leadingSpace, trailingSpace, lines2 = stmt && stmt.loc && stmt.loc.lines, trueLoc = lines2 && options2.reuseWhitespace && util2.getTrueLoc(stmt, lines2);
|
|
@@ -10164,7 +10180,7 @@ while`), parts.push(" (", path2.call(print, "test"), ");"), (0, lines_1.concat)(
|
|
|
10164
10180
|
}
|
|
10165
10181
|
function printFlowDeclaration(path2, parts) {
|
|
10166
10182
|
var parentExportDecl = util2.getParentExportDeclaration(path2);
|
|
10167
|
-
return parentExportDecl ?
|
|
10183
|
+
return parentExportDecl ? (0, tiny_invariant_1.default)(parentExportDecl.type === "DeclareExportDeclaration") : parts.unshift("declare "), (0, lines_1.concat)(parts);
|
|
10168
10184
|
}
|
|
10169
10185
|
function printVariance(path2, print) {
|
|
10170
10186
|
return path2.call(function(variancePath) {
|