@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/index.js
CHANGED
|
@@ -17,7 +17,6 @@ import { ExtractorConfig, Extractor } from "@microsoft/api-extractor";
|
|
|
17
17
|
import prettier from "prettier";
|
|
18
18
|
import { TSDocConfigFile } from "@microsoft/tsdoc-config";
|
|
19
19
|
import { parse as parse$1 } from "jsonc-parser";
|
|
20
|
-
import require$$1 from "assert";
|
|
21
20
|
import require$$4 from "os";
|
|
22
21
|
import { rollup, watch as watch$1 } from "rollup";
|
|
23
22
|
import alias from "@rollup/plugin-alias";
|
|
@@ -123,6 +122,11 @@ const pkgSchema = z.object({
|
|
|
123
122
|
import: z.optional(z.string()),
|
|
124
123
|
require: z.optional(z.string()),
|
|
125
124
|
default: z.string()
|
|
125
|
+
}),
|
|
126
|
+
z.object({
|
|
127
|
+
types: z.optional(z.string()),
|
|
128
|
+
svelte: z.string(),
|
|
129
|
+
default: z.optional(z.string())
|
|
126
130
|
})
|
|
127
131
|
])
|
|
128
132
|
)
|
|
@@ -160,7 +164,7 @@ async function loadPkgWithReporting(options2) {
|
|
|
160
164
|
if (pkg.exports) {
|
|
161
165
|
const _exports = Object.entries(pkg.exports);
|
|
162
166
|
for (const [expPath, exp] of _exports) {
|
|
163
|
-
if (typeof exp == "string")
|
|
167
|
+
if (typeof exp == "string" || "svelte" in exp)
|
|
164
168
|
continue;
|
|
165
169
|
const keys = Object.keys(exp);
|
|
166
170
|
if (assertFirst("types", keys) || (shouldError = !0, logger.error(`exports["${expPath}"]: the \`types\` property should be the first property`)), exp.node) {
|
|
@@ -247,27 +251,28 @@ function parseExports(options2) {
|
|
|
247
251
|
for (const [exportPath, exportEntry] of Object.entries(pkg.exports))
|
|
248
252
|
if (exportPath.endsWith(".json"))
|
|
249
253
|
exportPath === "./package.json" && exportEntry !== "./package.json" && errors.push('package.json: `exports["./package.json"] must be "./package.json".');
|
|
250
|
-
else if (isRecord(exportEntry))
|
|
251
|
-
if (
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
254
|
+
else if (!(isRecord(exportEntry) && "svelte" in exportEntry))
|
|
255
|
+
if (isRecord(exportEntry))
|
|
256
|
+
if (exportPath === ".")
|
|
257
|
+
exportEntry.require && rootExport.require && exportEntry.require !== rootExport.require && errors.push(
|
|
258
|
+
'package.json: mismatch between "main" and "exports.require". These must be equal.'
|
|
259
|
+
), exportEntry.import && rootExport.import && exportEntry.import !== rootExport.import && errors.push(
|
|
260
|
+
'package.json: mismatch between "module" and "exports.import" These must be equal.'
|
|
261
|
+
), exportEntry.types && rootExport.types && exportEntry.types !== rootExport.types && errors.push(
|
|
262
|
+
'package.json: mismatch between "types" and "exports.types". These must be equal.'
|
|
263
|
+
), exportEntry.source && rootExport.source && exportEntry.source !== rootExport.source && errors.push(
|
|
264
|
+
'package.json: mismatch between "source" and "exports.source". These must be equal.'
|
|
265
|
+
), Object.assign(rootExport, exportEntry);
|
|
266
|
+
else {
|
|
267
|
+
const extraExport = {
|
|
268
|
+
_exported: !0,
|
|
269
|
+
_path: exportPath,
|
|
270
|
+
...exportEntry
|
|
271
|
+
};
|
|
272
|
+
extraExports.push(extraExport);
|
|
273
|
+
}
|
|
274
|
+
else
|
|
275
|
+
errors.push("package.json: exports must be an object");
|
|
271
276
|
}
|
|
272
277
|
const _exports = [rootExport, ...extraExports];
|
|
273
278
|
if (errors.push(...validateExports(_exports, { extMap, pkg })), errors.length)
|
|
@@ -3336,7 +3341,23 @@ function requireMain() {
|
|
|
3336
3341
|
exports.astNodesAreEquivalent = astNodesAreEquivalent, exports.builders = builders, exports.builtInTypes = builtInTypes, exports.defineMethod = defineMethod, exports.eachField = eachField, exports.finalize = finalize, exports.getBuilderName = getBuilderName, exports.getFieldNames = getFieldNames, exports.getFieldValue = getFieldValue, exports.getSupertypeNames = getSupertypeNames, exports.NodePath = NodePath, exports.Path = Path, exports.PathVisitor = PathVisitor, exports.someField = someField, exports.Type = Type, exports.use = use, exports.visit = visit, Object.assign(namedTypes_1.namedTypes, n);
|
|
3337
3342
|
}(main)), main;
|
|
3338
3343
|
}
|
|
3339
|
-
var parser = {},
|
|
3344
|
+
var parser = {}, tinyInvariant_cjs, hasRequiredTinyInvariant_cjs;
|
|
3345
|
+
function requireTinyInvariant_cjs() {
|
|
3346
|
+
if (hasRequiredTinyInvariant_cjs)
|
|
3347
|
+
return tinyInvariant_cjs;
|
|
3348
|
+
hasRequiredTinyInvariant_cjs = 1;
|
|
3349
|
+
var isProduction = process.env.NODE_ENV === "production", prefix = "Invariant failed";
|
|
3350
|
+
function invariant(condition, message) {
|
|
3351
|
+
if (!condition) {
|
|
3352
|
+
if (isProduction)
|
|
3353
|
+
throw new Error(prefix);
|
|
3354
|
+
var provided = typeof message == "function" ? message() : message, value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
|
3355
|
+
throw new Error(value);
|
|
3356
|
+
}
|
|
3357
|
+
}
|
|
3358
|
+
return tinyInvariant_cjs = invariant, tinyInvariant_cjs;
|
|
3359
|
+
}
|
|
3360
|
+
var options = {}, util$1 = {}, sourceMap = {}, sourceMapGenerator = {}, base64Vlq = {}, base64 = {}, hasRequiredBase64;
|
|
3340
3361
|
function requireBase64() {
|
|
3341
3362
|
if (hasRequiredBase64)
|
|
3342
3363
|
return base64;
|
|
@@ -4275,7 +4296,7 @@ function requireUtil() {
|
|
|
4275
4296
|
if (hasRequiredUtil)
|
|
4276
4297
|
return util$1;
|
|
4277
4298
|
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;
|
|
4278
|
-
var tslib_12 = require$$0,
|
|
4299
|
+
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;
|
|
4279
4300
|
function getLineTerminator() {
|
|
4280
4301
|
return isBrowser() ? `
|
|
4281
4302
|
` : require$$4.EOL || `
|
|
@@ -4390,11 +4411,11 @@ function requireUtil() {
|
|
|
4390
4411
|
if (node.type === "TemplateLiteral" && node.quasis.length !== 0) {
|
|
4391
4412
|
if (node.loc) {
|
|
4392
4413
|
var afterLeftBackTickPos = copyPos(node.loc.start);
|
|
4393
|
-
|
|
4414
|
+
(0, tiny_invariant_1.default)(lines2.charAt(afterLeftBackTickPos) === "`"), (0, tiny_invariant_1.default)(lines2.nextPos(afterLeftBackTickPos));
|
|
4394
4415
|
var firstQuasi = node.quasis[0];
|
|
4395
4416
|
comparePos(firstQuasi.loc.start, afterLeftBackTickPos) < 0 && (firstQuasi.loc.start = afterLeftBackTickPos);
|
|
4396
4417
|
var rightBackTickPos = copyPos(node.loc.end);
|
|
4397
|
-
|
|
4418
|
+
(0, tiny_invariant_1.default)(lines2.prevPos(rightBackTickPos)), (0, tiny_invariant_1.default)(lines2.charAt(rightBackTickPos) === "`");
|
|
4398
4419
|
var lastQuasi = node.quasis[node.quasis.length - 1];
|
|
4399
4420
|
comparePos(rightBackTickPos, lastQuasi.loc.end) < 0 && (lastQuasi.loc.end = rightBackTickPos);
|
|
4400
4421
|
}
|
|
@@ -4406,7 +4427,7 @@ function requireUtil() {
|
|
|
4406
4427
|
}
|
|
4407
4428
|
var rightCurlyPos = lines2.skipSpaces(expr.loc.end, !1, !1);
|
|
4408
4429
|
if (lines2.charAt(rightCurlyPos) === "}") {
|
|
4409
|
-
|
|
4430
|
+
(0, tiny_invariant_1.default)(lines2.nextPos(rightCurlyPos));
|
|
4410
4431
|
var quasiAfter = node.quasis[i + 1];
|
|
4411
4432
|
comparePos(quasiAfter.loc.start, rightCurlyPos) < 0 && (quasiAfter.loc.start = rightCurlyPos);
|
|
4412
4433
|
}
|
|
@@ -8304,7 +8325,7 @@ function requireMapping() {
|
|
|
8304
8325
|
if (hasRequiredMapping)
|
|
8305
8326
|
return mapping;
|
|
8306
8327
|
hasRequiredMapping = 1, Object.defineProperty(mapping, "__esModule", { value: !0 });
|
|
8307
|
-
var tslib_12 = require$$0,
|
|
8328
|
+
var tslib_12 = require$$0, tiny_invariant_1 = tslib_12.__importDefault(requireTinyInvariant_cjs()), util_1 = requireUtil(), Mapping = (
|
|
8308
8329
|
/** @class */
|
|
8309
8330
|
function() {
|
|
8310
8331
|
function Mapping2(sourceLines, sourceLoc, targetLoc) {
|
|
@@ -8315,7 +8336,7 @@ function requireMapping() {
|
|
|
8315
8336
|
var sourceLines = this.sourceLines, sourceLoc = this.sourceLoc, targetLoc = this.targetLoc;
|
|
8316
8337
|
function skip(name) {
|
|
8317
8338
|
var sourceFromPos = sourceLoc[name], targetFromPos = targetLoc[name], targetToPos = start;
|
|
8318
|
-
return name === "end" ? targetToPos = end :
|
|
8339
|
+
return name === "end" ? targetToPos = end : (0, tiny_invariant_1.default)(name === "start"), skipChars(sourceLines, sourceFromPos, lines2, targetFromPos, targetToPos);
|
|
8319
8340
|
}
|
|
8320
8341
|
if ((0, util_1.comparePos)(start, targetLoc.start) <= 0)
|
|
8321
8342
|
if ((0, util_1.comparePos)(targetLoc.end, end) <= 0)
|
|
@@ -8412,13 +8433,13 @@ function requireMapping() {
|
|
|
8412
8433
|
if (targetComparison < 0) {
|
|
8413
8434
|
sourceCursor = sourceLines.skipSpaces(sourceFromPos) || sourceLines.lastPos(), targetCursor = targetLines.skipSpaces(targetFromPos) || targetLines.lastPos();
|
|
8414
8435
|
var lineDiff = targetToPos.line - targetCursor.line;
|
|
8415
|
-
for (sourceCursor.line += lineDiff, targetCursor.line += lineDiff, lineDiff > 0 ? (sourceCursor.column = 0, targetCursor.column = 0) :
|
|
8416
|
-
|
|
8436
|
+
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); )
|
|
8437
|
+
(0, tiny_invariant_1.default)(sourceLines.nextPos(sourceCursor, !0)), (0, tiny_invariant_1.default)(sourceLines.charAt(sourceCursor) === targetLines.charAt(targetCursor));
|
|
8417
8438
|
} else {
|
|
8418
8439
|
sourceCursor = sourceLines.skipSpaces(sourceFromPos, !0) || sourceLines.firstPos(), targetCursor = targetLines.skipSpaces(targetFromPos, !0) || targetLines.firstPos();
|
|
8419
8440
|
var lineDiff = targetToPos.line - targetCursor.line;
|
|
8420
|
-
for (sourceCursor.line += lineDiff, targetCursor.line += lineDiff, lineDiff < 0 ? (sourceCursor.column = sourceLines.getLineLength(sourceCursor.line), targetCursor.column = targetLines.getLineLength(targetCursor.line)) :
|
|
8421
|
-
|
|
8441
|
+
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); )
|
|
8442
|
+
(0, tiny_invariant_1.default)(sourceLines.prevPos(sourceCursor, !0)), (0, tiny_invariant_1.default)(sourceLines.charAt(sourceCursor) === targetLines.charAt(targetCursor));
|
|
8422
8443
|
}
|
|
8423
8444
|
return sourceCursor;
|
|
8424
8445
|
}
|
|
@@ -8429,11 +8450,11 @@ function requireLines() {
|
|
|
8429
8450
|
if (hasRequiredLines)
|
|
8430
8451
|
return lines;
|
|
8431
8452
|
hasRequiredLines = 1, Object.defineProperty(lines, "__esModule", { value: !0 }), lines.concat = lines.fromString = lines.countSpaces = lines.Lines = void 0;
|
|
8432
|
-
var tslib_12 = require$$0,
|
|
8453
|
+
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 = (
|
|
8433
8454
|
/** @class */
|
|
8434
8455
|
function() {
|
|
8435
8456
|
function Lines2(infos, sourceFileName) {
|
|
8436
|
-
sourceFileName === void 0 && (sourceFileName = null), this.infos = infos, this.mappings = [], this.cachedSourceMap = null, this.cachedTabWidth = void 0,
|
|
8457
|
+
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, {
|
|
8437
8458
|
start: this.firstPos(),
|
|
8438
8459
|
end: this.lastPos()
|
|
8439
8460
|
}));
|
|
@@ -8453,7 +8474,7 @@ function requireLines() {
|
|
|
8453
8474
|
return targetLines.mappings.forEach(function(mapping2) {
|
|
8454
8475
|
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; ) {
|
|
8455
8476
|
var sourceChar = mapping2.sourceLines.charAt(sourceCursor), targetChar = targetLines.charAt(targetCursor);
|
|
8456
|
-
|
|
8477
|
+
(0, tiny_invariant_1.default)(sourceChar === targetChar);
|
|
8457
8478
|
var sourceName = mapping2.sourceLines.name;
|
|
8458
8479
|
if (smg.addMapping({
|
|
8459
8480
|
source: sourceName,
|
|
@@ -8467,12 +8488,12 @@ function requireLines() {
|
|
|
8467
8488
|
}
|
|
8468
8489
|
}), targetLines.cachedSourceMap = smg, smg.toJSON();
|
|
8469
8490
|
}, Lines2.prototype.bootstrapCharAt = function(pos) {
|
|
8470
|
-
|
|
8491
|
+
(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");
|
|
8471
8492
|
var line = pos.line, column = pos.column, strings = this.toString().split(lineTerminatorSeqExp), string = strings[line - 1];
|
|
8472
8493
|
return typeof string > "u" ? "" : column === string.length && line < strings.length ? `
|
|
8473
8494
|
` : column >= string.length ? "" : string.charAt(column);
|
|
8474
8495
|
}, Lines2.prototype.charAt = function(pos) {
|
|
8475
|
-
|
|
8496
|
+
(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");
|
|
8476
8497
|
var line = pos.line, column = pos.column, secret = this, infos = secret.infos, info = infos[line - 1], c = column;
|
|
8477
8498
|
if (typeof info > "u" || c < 0)
|
|
8478
8499
|
return "";
|
|
@@ -8482,14 +8503,14 @@ function requireLines() {
|
|
|
8482
8503
|
}, Lines2.prototype.stripMargin = function(width, skipFirstLine) {
|
|
8483
8504
|
if (width === 0)
|
|
8484
8505
|
return this;
|
|
8485
|
-
if (
|
|
8506
|
+
if ((0, tiny_invariant_1.default)(width > 0, "negative margin: " + width), skipFirstLine && this.length === 1)
|
|
8486
8507
|
return this;
|
|
8487
8508
|
var lines2 = new Lines2(this.infos.map(function(info, i) {
|
|
8488
8509
|
return info.line && (i > 0 || !skipFirstLine) && (info = tslib_12.__assign(tslib_12.__assign({}, info), { indent: Math.max(0, info.indent - width) })), info;
|
|
8489
8510
|
}));
|
|
8490
8511
|
if (this.mappings.length > 0) {
|
|
8491
8512
|
var newMappings_1 = lines2.mappings;
|
|
8492
|
-
|
|
8513
|
+
(0, tiny_invariant_1.default)(newMappings_1.length === 0), this.mappings.forEach(function(mapping2) {
|
|
8493
8514
|
newMappings_1.push(mapping2.indent(width, skipFirstLine, !0));
|
|
8494
8515
|
});
|
|
8495
8516
|
}
|
|
@@ -8502,7 +8523,7 @@ function requireLines() {
|
|
|
8502
8523
|
}));
|
|
8503
8524
|
if (this.mappings.length > 0) {
|
|
8504
8525
|
var newMappings_2 = lines2.mappings;
|
|
8505
|
-
|
|
8526
|
+
(0, tiny_invariant_1.default)(newMappings_2.length === 0), this.mappings.forEach(function(mapping2) {
|
|
8506
8527
|
newMappings_2.push(mapping2.indent(by));
|
|
8507
8528
|
});
|
|
8508
8529
|
}
|
|
@@ -8517,7 +8538,7 @@ function requireLines() {
|
|
|
8517
8538
|
}));
|
|
8518
8539
|
if (this.mappings.length > 0) {
|
|
8519
8540
|
var newMappings_3 = lines2.mappings;
|
|
8520
|
-
|
|
8541
|
+
(0, tiny_invariant_1.default)(newMappings_3.length === 0), this.mappings.forEach(function(mapping2) {
|
|
8521
8542
|
newMappings_3.push(mapping2.indent(by, !0));
|
|
8522
8543
|
});
|
|
8523
8544
|
}
|
|
@@ -8527,7 +8548,7 @@ function requireLines() {
|
|
|
8527
8548
|
return tslib_12.__assign(tslib_12.__assign({}, info), { locked: i > 0 });
|
|
8528
8549
|
}));
|
|
8529
8550
|
}, Lines2.prototype.getIndentAt = function(line) {
|
|
8530
|
-
return
|
|
8551
|
+
return (0, tiny_invariant_1.default)(line >= 1, "no line " + line + " (line numbers start from 1)"), Math.max(this.infos[line - 1].indent, 0);
|
|
8531
8552
|
}, Lines2.prototype.guessTabWidth = function() {
|
|
8532
8553
|
if (typeof this.cachedTabWidth == "number")
|
|
8533
8554
|
return this.cachedTabWidth;
|
|
@@ -8625,11 +8646,11 @@ function requireLines() {
|
|
|
8625
8646
|
if (!start)
|
|
8626
8647
|
throw new Error("cannot slice with end but not start");
|
|
8627
8648
|
var sliced = this.infos.slice(start.line - 1, end.line);
|
|
8628
|
-
start.line === end.line ? sliced[0] = sliceInfo(sliced[0], start.column, end.column) : (
|
|
8649
|
+
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)));
|
|
8629
8650
|
var lines2 = new Lines2(sliced);
|
|
8630
8651
|
if (this.mappings.length > 0) {
|
|
8631
8652
|
var newMappings_4 = lines2.mappings;
|
|
8632
|
-
|
|
8653
|
+
(0, tiny_invariant_1.default)(newMappings_4.length === 0), this.mappings.forEach(function(mapping2) {
|
|
8633
8654
|
var sliced2 = mapping2.slice(this, start, end);
|
|
8634
8655
|
sliced2 && newMappings_4.push(sliced2);
|
|
8635
8656
|
}, this);
|
|
@@ -8687,7 +8708,7 @@ function requireLines() {
|
|
|
8687
8708
|
for (var args = [], _i = 0; _i < arguments.length; _i++)
|
|
8688
8709
|
args[_i] = arguments[_i];
|
|
8689
8710
|
var list = [this];
|
|
8690
|
-
return list.push.apply(list, args),
|
|
8711
|
+
return list.push.apply(list, args), (0, tiny_invariant_1.default)(list.length === args.length + 1), emptyLines.join(list);
|
|
8691
8712
|
}, Lines2;
|
|
8692
8713
|
}()
|
|
8693
8714
|
);
|
|
@@ -8697,7 +8718,7 @@ function requireLines() {
|
|
|
8697
8718
|
for (var count = 0, len = spaces.length, i = 0; i < len; ++i)
|
|
8698
8719
|
switch (spaces.charCodeAt(i)) {
|
|
8699
8720
|
case 9: {
|
|
8700
|
-
|
|
8721
|
+
(0, tiny_invariant_1.default)(typeof tabWidth == "number"), (0, tiny_invariant_1.default)(tabWidth > 0);
|
|
8701
8722
|
var next = Math.ceil(count / tabWidth) * tabWidth;
|
|
8702
8723
|
next === count ? count += tabWidth : count = next;
|
|
8703
8724
|
break;
|
|
@@ -8721,7 +8742,7 @@ function requireLines() {
|
|
|
8721
8742
|
return string;
|
|
8722
8743
|
string += "";
|
|
8723
8744
|
var tabWidth = options2 && options2.tabWidth, tabless = string.indexOf(" ") < 0, cacheable = !options2 && tabless && string.length <= maxCacheKeyLen;
|
|
8724
|
-
if (
|
|
8745
|
+
if ((0, tiny_invariant_1.default)(tabWidth || tabless, `No tab width specified but encountered tabs in string
|
|
8725
8746
|
` + string), cacheable && hasOwn.call(fromStringCache, string))
|
|
8726
8747
|
return fromStringCache[string];
|
|
8727
8748
|
var lines2 = new Lines(string.split(lineTerminatorSeqExp).map(function(line) {
|
|
@@ -8743,7 +8764,7 @@ function requireLines() {
|
|
|
8743
8764
|
}
|
|
8744
8765
|
function sliceInfo(info, startCol, endCol) {
|
|
8745
8766
|
var sliceStart = info.sliceStart, sliceEnd = info.sliceEnd, indent = Math.max(info.indent, 0), lineLength = indent + sliceEnd - sliceStart;
|
|
8746
|
-
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),
|
|
8767
|
+
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 : {
|
|
8747
8768
|
line: info.line,
|
|
8748
8769
|
indent,
|
|
8749
8770
|
// A destructive slice always unlocks indentation.
|
|
@@ -8764,7 +8785,7 @@ function requireComments() {
|
|
|
8764
8785
|
if (hasRequiredComments)
|
|
8765
8786
|
return comments;
|
|
8766
8787
|
hasRequiredComments = 1, Object.defineProperty(comments, "__esModule", { value: !0 }), comments.printComments = comments.attach = void 0;
|
|
8767
|
-
var tslib_12 = require$$0,
|
|
8788
|
+
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();
|
|
8768
8789
|
function getSortedChildNodes(node, lines2, resultArray) {
|
|
8769
8790
|
if (!node)
|
|
8770
8791
|
return resultArray;
|
|
@@ -8823,7 +8844,7 @@ function requireComments() {
|
|
|
8823
8844
|
var tieCount = tiesToBreak.length;
|
|
8824
8845
|
if (tieCount > 0) {
|
|
8825
8846
|
var lastTie = tiesToBreak[tieCount - 1];
|
|
8826
|
-
|
|
8847
|
+
(0, tiny_invariant_1.default)(lastTie.precedingNode === comment.precedingNode == (lastTie.followingNode === comment.followingNode)), lastTie.followingNode !== comment.followingNode && breakTies(tiesToBreak, lines2);
|
|
8827
8848
|
}
|
|
8828
8849
|
tiesToBreak.push(comment);
|
|
8829
8850
|
} else if (pn)
|
|
@@ -8844,7 +8865,7 @@ function requireComments() {
|
|
|
8844
8865
|
var tieCount = tiesToBreak.length;
|
|
8845
8866
|
if (tieCount !== 0) {
|
|
8846
8867
|
for (var pn = tiesToBreak[0].precedingNode, fn = tiesToBreak[0].followingNode, gapEndPos = fn.loc.start, indexOfFirstLeadingComment = tieCount, comment; indexOfFirstLeadingComment > 0; --indexOfFirstLeadingComment) {
|
|
8847
|
-
comment = tiesToBreak[indexOfFirstLeadingComment - 1],
|
|
8868
|
+
comment = tiesToBreak[indexOfFirstLeadingComment - 1], (0, tiny_invariant_1.default)(comment.precedingNode === pn), (0, tiny_invariant_1.default)(comment.followingNode === fn);
|
|
8848
8869
|
var gap = lines2.sliceString(comment.loc.end, gapEndPos);
|
|
8849
8870
|
if (/\S/.test(gap))
|
|
8850
8871
|
break;
|
|
@@ -8920,7 +8941,7 @@ function requireParser() {
|
|
|
8920
8941
|
if (hasRequiredParser)
|
|
8921
8942
|
return parser;
|
|
8922
8943
|
hasRequiredParser = 1, Object.defineProperty(parser, "__esModule", { value: !0 }), parser.parse = void 0;
|
|
8923
|
-
var tslib_12 = require$$0,
|
|
8944
|
+
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());
|
|
8924
8945
|
function parse2(source, options2) {
|
|
8925
8946
|
options2 = (0, options_1.normalize)(options2);
|
|
8926
8947
|
var lines2 = (0, lines_1.fromString)(source, options2), sourceWithoutTabs = lines2.toString({
|
|
@@ -8963,7 +8984,7 @@ function requireParser() {
|
|
|
8963
8984
|
}
|
|
8964
8985
|
parser.parse = parse2;
|
|
8965
8986
|
var TreeCopier = function TreeCopier2(lines2, tokens) {
|
|
8966
|
-
|
|
8987
|
+
(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();
|
|
8967
8988
|
}, TCp = TreeCopier.prototype;
|
|
8968
8989
|
return TCp.copy = function(node) {
|
|
8969
8990
|
if (this.seen.has(node))
|
|
@@ -9031,7 +9052,7 @@ function requireFastPath() {
|
|
|
9031
9052
|
if (hasRequiredFastPath)
|
|
9032
9053
|
return fastPath;
|
|
9033
9054
|
hasRequiredFastPath = 1, Object.defineProperty(fastPath, "__esModule", { value: !0 });
|
|
9034
|
-
var tslib_12 = require$$0,
|
|
9055
|
+
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 = {};
|
|
9035
9056
|
[
|
|
9036
9057
|
["??"],
|
|
9037
9058
|
["||"],
|
|
@@ -9051,7 +9072,7 @@ function requireFastPath() {
|
|
|
9051
9072
|
});
|
|
9052
9073
|
});
|
|
9053
9074
|
var FastPath = function FastPath2(value) {
|
|
9054
|
-
|
|
9075
|
+
(0, tiny_invariant_1.default)(this instanceof FastPath2), this.stack = [value];
|
|
9055
9076
|
}, FPp = FastPath.prototype;
|
|
9056
9077
|
FastPath.from = function(obj) {
|
|
9057
9078
|
if (obj instanceof FastPath)
|
|
@@ -9187,7 +9208,7 @@ function requireFastPath() {
|
|
|
9187
9208
|
if (pp > np)
|
|
9188
9209
|
return !0;
|
|
9189
9210
|
if (pp === np && name === "right")
|
|
9190
|
-
return
|
|
9211
|
+
return (0, tiny_invariant_1.default)(parent.right === node), !0;
|
|
9191
9212
|
break;
|
|
9192
9213
|
}
|
|
9193
9214
|
default:
|
|
@@ -9266,35 +9287,35 @@ function requireFastPath() {
|
|
|
9266
9287
|
for (var s = this.stack, parentName, parent, childName, child, i = s.length - 1; i >= 0; i -= 2)
|
|
9267
9288
|
if (n.Node.check(s[i]) && (childName = parentName, child = parent, parentName = s[i - 1], parent = s[i]), !(!parent || !child)) {
|
|
9268
9289
|
if (n.BlockStatement.check(parent) && parentName === "body" && childName === 0)
|
|
9269
|
-
return
|
|
9290
|
+
return (0, tiny_invariant_1.default)(parent.body[0] === child), !0;
|
|
9270
9291
|
if (n.ExpressionStatement.check(parent) && childName === "expression")
|
|
9271
|
-
return
|
|
9292
|
+
return (0, tiny_invariant_1.default)(parent.expression === child), !0;
|
|
9272
9293
|
if (n.AssignmentExpression.check(parent) && childName === "left")
|
|
9273
|
-
return
|
|
9294
|
+
return (0, tiny_invariant_1.default)(parent.left === child), !0;
|
|
9274
9295
|
if (n.ArrowFunctionExpression.check(parent) && childName === "body")
|
|
9275
|
-
return
|
|
9296
|
+
return (0, tiny_invariant_1.default)(parent.body === child), !0;
|
|
9276
9297
|
if (n.SequenceExpression.check(parent) && s[i + 1] === "expressions" && childName === 0) {
|
|
9277
|
-
|
|
9298
|
+
(0, tiny_invariant_1.default)(parent.expressions[0] === child);
|
|
9278
9299
|
continue;
|
|
9279
9300
|
}
|
|
9280
9301
|
if (n.CallExpression.check(parent) && childName === "callee") {
|
|
9281
|
-
|
|
9302
|
+
(0, tiny_invariant_1.default)(parent.callee === child);
|
|
9282
9303
|
continue;
|
|
9283
9304
|
}
|
|
9284
9305
|
if (n.MemberExpression.check(parent) && childName === "object") {
|
|
9285
|
-
|
|
9306
|
+
(0, tiny_invariant_1.default)(parent.object === child);
|
|
9286
9307
|
continue;
|
|
9287
9308
|
}
|
|
9288
9309
|
if (n.ConditionalExpression.check(parent) && childName === "test") {
|
|
9289
|
-
|
|
9310
|
+
(0, tiny_invariant_1.default)(parent.test === child);
|
|
9290
9311
|
continue;
|
|
9291
9312
|
}
|
|
9292
9313
|
if (isBinary(parent) && childName === "left") {
|
|
9293
|
-
|
|
9314
|
+
(0, tiny_invariant_1.default)(parent.left === child);
|
|
9294
9315
|
continue;
|
|
9295
9316
|
}
|
|
9296
9317
|
if (n.UnaryExpression.check(parent) && !parent.prefix && childName === "argument") {
|
|
9297
|
-
|
|
9318
|
+
(0, tiny_invariant_1.default)(parent.argument === child);
|
|
9298
9319
|
continue;
|
|
9299
9320
|
}
|
|
9300
9321
|
return !1;
|
|
@@ -9307,8 +9328,8 @@ function requirePatcher() {
|
|
|
9307
9328
|
if (hasRequiredPatcher)
|
|
9308
9329
|
return patcher;
|
|
9309
9330
|
hasRequiredPatcher = 1, Object.defineProperty(patcher, "__esModule", { value: !0 }), patcher.getReprinter = patcher.Patcher = void 0;
|
|
9310
|
-
var tslib_12 = require$$0,
|
|
9311
|
-
|
|
9331
|
+
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) {
|
|
9332
|
+
(0, tiny_invariant_1.default)(this instanceof Patcher2), (0, tiny_invariant_1.default)(lines2 instanceof linesModule.Lines);
|
|
9312
9333
|
var self2 = this, replacements = [];
|
|
9313
9334
|
self2.replace = function(loc, lines3) {
|
|
9314
9335
|
isString.check(lines3) && (lines3 = linesModule.fromString(lines3)), replacements.push({
|
|
@@ -9323,7 +9344,7 @@ function requirePatcher() {
|
|
|
9323
9344
|
};
|
|
9324
9345
|
var sliceFrom = loc.start, toConcat = [];
|
|
9325
9346
|
function pushSlice(from2, to) {
|
|
9326
|
-
|
|
9347
|
+
(0, tiny_invariant_1.default)((0, util_1.comparePos)(from2, to) <= 0), toConcat.push(lines2.slice(from2, to));
|
|
9327
9348
|
}
|
|
9328
9349
|
return replacements.sort(function(a, b) {
|
|
9329
9350
|
return (0, util_1.comparePos)(a.start, b.start);
|
|
@@ -9343,7 +9364,7 @@ function requirePatcher() {
|
|
|
9343
9364
|
var reprints = [], ableToReprintComments = findArrayReprints(newPath, oldPath, reprints);
|
|
9344
9365
|
return ableToReprintComments && reprints.length > 0 && reprints.forEach(function(reprint) {
|
|
9345
9366
|
var oldComment = reprint.oldPath.getValue();
|
|
9346
|
-
|
|
9367
|
+
(0, tiny_invariant_1.default)(oldComment.leading || oldComment.trailing), patcher2.replace(
|
|
9347
9368
|
oldComment.loc,
|
|
9348
9369
|
// Comments can't have .comments, so it doesn't matter whether we
|
|
9349
9370
|
// print with comments or without.
|
|
@@ -9372,7 +9393,7 @@ function requirePatcher() {
|
|
|
9372
9393
|
}
|
|
9373
9394
|
};
|
|
9374
9395
|
function getReprinter(path2) {
|
|
9375
|
-
|
|
9396
|
+
(0, tiny_invariant_1.default)(path2 instanceof fast_path_1.default);
|
|
9376
9397
|
var node = path2.getValue();
|
|
9377
9398
|
if (Printable.check(node)) {
|
|
9378
9399
|
var orig = node.original, origLoc = orig && orig.loc, lines2 = origLoc && origLoc.lines, reprints = [];
|
|
@@ -9417,7 +9438,7 @@ function requirePatcher() {
|
|
|
9417
9438
|
var newNode = newPath.getValue();
|
|
9418
9439
|
Printable.assert(newNode);
|
|
9419
9440
|
var oldNode = newNode.original;
|
|
9420
|
-
if (Printable.assert(oldNode),
|
|
9441
|
+
if (Printable.assert(oldNode), (0, tiny_invariant_1.default)(reprints.length === 0), newNode.type !== oldNode.type)
|
|
9421
9442
|
return !1;
|
|
9422
9443
|
var oldPath = new fast_path_1.default(oldNode), canReprint = findChildReprints(newPath, oldPath, reprints);
|
|
9423
9444
|
return canReprint || (reprints.length = 0), canReprint;
|
|
@@ -9505,14 +9526,14 @@ function requirePrinter() {
|
|
|
9505
9526
|
if (hasRequiredPrinter)
|
|
9506
9527
|
return printer;
|
|
9507
9528
|
hasRequiredPrinter = 1, Object.defineProperty(printer, "__esModule", { value: !0 }), printer.Printer = void 0;
|
|
9508
|
-
var tslib_12 = require$$0,
|
|
9509
|
-
|
|
9529
|
+
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) {
|
|
9530
|
+
(0, tiny_invariant_1.default)(this instanceof PrintResult2), isString.assert(code), this.code = code, sourceMap2 && (isObject.assert(sourceMap2), this.map = sourceMap2);
|
|
9510
9531
|
}, PRp = PrintResult.prototype, warnedAboutToString = !1;
|
|
9511
9532
|
PRp.toString = function() {
|
|
9512
9533
|
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;
|
|
9513
9534
|
};
|
|
9514
9535
|
var emptyPrintResult = new PrintResult(""), Printer = function Printer2(config2) {
|
|
9515
|
-
|
|
9536
|
+
(0, tiny_invariant_1.default)(this instanceof Printer2);
|
|
9516
9537
|
var explicitTabWidth = config2 && config2.tabWidth;
|
|
9517
9538
|
config2 = (0, options_1.normalize)(config2), config2.sourceFileName = null;
|
|
9518
9539
|
function makePrintFunctionWith(options2, overrides) {
|
|
@@ -9521,7 +9542,7 @@ function requirePrinter() {
|
|
|
9521
9542
|
};
|
|
9522
9543
|
}
|
|
9523
9544
|
function print(path2, options2) {
|
|
9524
|
-
if (
|
|
9545
|
+
if ((0, tiny_invariant_1.default)(path2 instanceof fast_path_1.default), options2 = options2 || {}, options2.includeComments)
|
|
9525
9546
|
return (0, comments_1.printComments)(path2, makePrintFunctionWith(options2, {
|
|
9526
9547
|
includeComments: !1
|
|
9527
9548
|
}));
|
|
@@ -9573,7 +9594,7 @@ function requirePrinter() {
|
|
|
9573
9594
|
};
|
|
9574
9595
|
printer.Printer = Printer;
|
|
9575
9596
|
function genericPrint(path2, config2, options2, printPath) {
|
|
9576
|
-
|
|
9597
|
+
(0, tiny_invariant_1.default)(path2 instanceof fast_path_1.default);
|
|
9577
9598
|
var node = path2.getValue(), parts = [], linesWithoutParens = genericPrintNoParens(path2, config2, printPath);
|
|
9578
9599
|
if (!node || linesWithoutParens.isEmpty())
|
|
9579
9600
|
return linesWithoutParens;
|
|
@@ -9676,7 +9697,7 @@ function requirePrinter() {
|
|
|
9676
9697
|
}`
|
|
9677
9698
|
]);
|
|
9678
9699
|
case "ModuleDeclaration":
|
|
9679
|
-
return parts.push("module", path2.call(print, "id")), n.source ? (
|
|
9700
|
+
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);
|
|
9680
9701
|
case "ImportSpecifier":
|
|
9681
9702
|
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);
|
|
9682
9703
|
case "ExportSpecifier":
|
|
@@ -10008,7 +10029,7 @@ while`), parts.push(" (", path2.call(print, "test"), ");"), (0, lines_1.concat)(
|
|
|
10008
10029
|
case "JSXFragment": {
|
|
10009
10030
|
var openingPropName = "opening" + (n.type === "JSXElement" ? "Element" : "Fragment"), closingPropName = "closing" + (n.type === "JSXElement" ? "Element" : "Fragment"), openingLines = path2.call(print, openingPropName);
|
|
10010
10031
|
if (n[openingPropName].selfClosing)
|
|
10011
|
-
return
|
|
10032
|
+
return (0, tiny_invariant_1.default)(!n[closingPropName], "unexpected " + closingPropName + " element in self-closing " + n.type), openingLines;
|
|
10012
10033
|
var childLines = (0, lines_1.concat)(path2.map(function(childPath) {
|
|
10013
10034
|
var child = childPath.getValue();
|
|
10014
10035
|
if (namedTypes2.Literal.check(child) && typeof child.value == "string") {
|
|
@@ -10030,7 +10051,7 @@ while`), parts.push(" (", path2.call(print, "test"), ");"), (0, lines_1.concat)(
|
|
|
10030
10051
|
}, "attributes");
|
|
10031
10052
|
var attrLines = (0, lines_1.concat)(attrParts_1), needLineWrap = attrLines.length > 1 || attrLines.getLineLength(1) > options2.wrapColumn;
|
|
10032
10053
|
return needLineWrap && (attrParts_1.forEach(function(part, i) {
|
|
10033
|
-
part === " " && (
|
|
10054
|
+
part === " " && ((0, tiny_invariant_1.default)(i % 2 === 0), attrParts_1[i] = `
|
|
10034
10055
|
`);
|
|
10035
10056
|
}), attrLines = (0, lines_1.concat)(attrParts_1).indentTail(options2.tabWidth)), parts.push(attrLines, n.selfClosing ? " />" : ">"), (0, lines_1.concat)(parts);
|
|
10036
10057
|
}
|
|
@@ -10146,7 +10167,7 @@ while`), parts.push(" (", path2.call(print, "test"), ");"), (0, lines_1.concat)(
|
|
|
10146
10167
|
case "BooleanTypeAnnotation":
|
|
10147
10168
|
return (0, lines_1.fromString)("boolean", options2);
|
|
10148
10169
|
case "BooleanLiteralTypeAnnotation":
|
|
10149
|
-
return
|
|
10170
|
+
return (0, tiny_invariant_1.default)(typeof n.value == "boolean"), (0, lines_1.fromString)("" + n.value, options2);
|
|
10150
10171
|
case "InterfaceTypeAnnotation":
|
|
10151
10172
|
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);
|
|
10152
10173
|
case "DeclareFunction":
|
|
@@ -10273,7 +10294,7 @@ while`), parts.push(" (", path2.call(print, "test"), ");"), (0, lines_1.concat)(
|
|
|
10273
10294
|
return (0, lines_1.fromString)(nodeStr(n.value, options2), options2);
|
|
10274
10295
|
case "NumberLiteralTypeAnnotation":
|
|
10275
10296
|
case "NumericLiteralTypeAnnotation":
|
|
10276
|
-
return
|
|
10297
|
+
return (0, tiny_invariant_1.default)(typeof n.value == "number"), (0, lines_1.fromString)(JSON.stringify(n.value), options2);
|
|
10277
10298
|
case "BigIntLiteralTypeAnnotation":
|
|
10278
10299
|
return (0, lines_1.fromString)(n.raw, options2);
|
|
10279
10300
|
case "StringTypeAnnotation":
|
|
@@ -10620,7 +10641,7 @@ while`), parts.push(" (", path2.call(print, "test"), ");"), (0, lines_1.concat)(
|
|
|
10620
10641
|
node: stmt,
|
|
10621
10642
|
printed: print(stmtPath)
|
|
10622
10643
|
})));
|
|
10623
|
-
}), sawComment &&
|
|
10644
|
+
}), 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.");
|
|
10624
10645
|
var prevTrailingSpace = null, len = filtered.length, parts = [];
|
|
10625
10646
|
return filtered.forEach(function(info, i) {
|
|
10626
10647
|
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);
|
|
@@ -10748,7 +10769,7 @@ while`), parts.push(" (", path2.call(print, "test"), ");"), (0, lines_1.concat)(
|
|
|
10748
10769
|
}
|
|
10749
10770
|
function printFlowDeclaration(path2, parts) {
|
|
10750
10771
|
var parentExportDecl = util2.getParentExportDeclaration(path2);
|
|
10751
|
-
return parentExportDecl ?
|
|
10772
|
+
return parentExportDecl ? (0, tiny_invariant_1.default)(parentExportDecl.type === "DeclareExportDeclaration") : parts.unshift("declare "), (0, lines_1.concat)(parts);
|
|
10752
10773
|
}
|
|
10753
10774
|
function printVariance(path2, print) {
|
|
10754
10775
|
return path2.call(function(variancePath) {
|