@danielx/civet 0.7.9 → 0.7.10
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/browser.js +457 -372
- package/dist/civet +35 -11
- package/dist/esm.mjs +1 -2
- package/dist/main.js +460 -373
- package/dist/main.mjs +458 -372
- package/dist/types.d.ts +11 -4
- package/package.json +4 -4
package/dist/main.js
CHANGED
|
@@ -30,9 +30,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
));
|
|
31
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
32
|
|
|
33
|
-
//
|
|
33
|
+
// node_modules/@danielx/hera/dist/machine.js
|
|
34
34
|
var require_machine = __commonJS({
|
|
35
|
-
"
|
|
35
|
+
"node_modules/@danielx/hera/dist/machine.js"(exports2, module2) {
|
|
36
36
|
"use strict";
|
|
37
37
|
var __defProp2 = Object.defineProperty;
|
|
38
38
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -71,6 +71,7 @@ var require_machine = __commonJS({
|
|
|
71
71
|
$TS: () => $TS2,
|
|
72
72
|
$TV: () => $TV2,
|
|
73
73
|
$Y: () => $Y2,
|
|
74
|
+
ParseError: () => ParseError2,
|
|
74
75
|
Validator: () => Validator2
|
|
75
76
|
});
|
|
76
77
|
module2.exports = __toCommonJS2(machine_exports);
|
|
@@ -437,11 +438,10 @@ ${input.slice(result.pos)}
|
|
|
437
438
|
hint = JSON.stringify(hint);
|
|
438
439
|
else
|
|
439
440
|
hint = "EOF";
|
|
440
|
-
const error = new
|
|
441
|
-
Expected:
|
|
441
|
+
const error = new ParseError2("Failed to parse", `Expected:
|
|
442
442
|
${expectations.join("\n ")}
|
|
443
443
|
Found: ${hint}
|
|
444
|
-
`,
|
|
444
|
+
`, filename2, line, column, maxFailPos);
|
|
445
445
|
throw error;
|
|
446
446
|
}
|
|
447
447
|
if (result) {
|
|
@@ -464,15 +464,21 @@ ${input.slice(result.pos)}
|
|
|
464
464
|
reset
|
|
465
465
|
};
|
|
466
466
|
}
|
|
467
|
-
var
|
|
468
|
-
constructor(
|
|
467
|
+
var ParseError2 = class extends Error {
|
|
468
|
+
constructor(header, body, filename2, line, column, offset) {
|
|
469
|
+
let message = `${filename2}:${line}:${column} ${header}`;
|
|
470
|
+
if (body)
|
|
471
|
+
message += `
|
|
472
|
+
${body}`;
|
|
469
473
|
super(message);
|
|
470
|
-
this.
|
|
471
|
-
this.
|
|
474
|
+
this.header = header;
|
|
475
|
+
this.body = body;
|
|
472
476
|
this.filename = filename2;
|
|
473
477
|
this.line = line;
|
|
474
478
|
this.column = column;
|
|
475
479
|
this.offset = offset;
|
|
480
|
+
this.name = "ParseError";
|
|
481
|
+
this.message = message;
|
|
476
482
|
}
|
|
477
483
|
};
|
|
478
484
|
}
|
|
@@ -481,7 +487,9 @@ ${input.slice(result.pos)}
|
|
|
481
487
|
// source/main.civet
|
|
482
488
|
var main_exports = {};
|
|
483
489
|
__export(main_exports, {
|
|
490
|
+
ParseError: () => import_lib3.ParseError,
|
|
484
491
|
ParseErrors: () => ParseErrors,
|
|
492
|
+
SourceMap: () => SourceMap2,
|
|
485
493
|
compile: () => compile,
|
|
486
494
|
default: () => main_default,
|
|
487
495
|
generate: () => generate_default,
|
|
@@ -490,7 +498,7 @@ __export(main_exports, {
|
|
|
490
498
|
parse: () => parse,
|
|
491
499
|
parseProgram: () => parseProgram,
|
|
492
500
|
prune: () => prune,
|
|
493
|
-
|
|
501
|
+
sourcemap: () => sourcemap_exports
|
|
494
502
|
});
|
|
495
503
|
module.exports = __toCommonJS(main_exports);
|
|
496
504
|
|
|
@@ -546,6 +554,7 @@ __export(lib_exports, {
|
|
|
546
554
|
processAssignmentDeclaration: () => processAssignmentDeclaration,
|
|
547
555
|
processBinaryOpExpression: () => processBinaryOpExpression,
|
|
548
556
|
processCallMemberExpression: () => processCallMemberExpression,
|
|
557
|
+
processCoffeeDo: () => processCoffeeDo,
|
|
549
558
|
processCoffeeInterpolation: () => processCoffeeInterpolation,
|
|
550
559
|
processForInOf: () => processForInOf,
|
|
551
560
|
processProgram: () => processProgram,
|
|
@@ -1247,6 +1256,56 @@ function skipImplicitArguments(args) {
|
|
|
1247
1256
|
}
|
|
1248
1257
|
return false;
|
|
1249
1258
|
}
|
|
1259
|
+
function processCoffeeDo(ws, expression) {
|
|
1260
|
+
ws = insertTrimmingSpace(ws, "");
|
|
1261
|
+
const args = [];
|
|
1262
|
+
if (typeof expression === "object" && expression != null && "type" in expression && expression.type === "ArrowFunction" || typeof expression === "object" && expression != null && "type" in expression && expression.type === "FunctionExpression") {
|
|
1263
|
+
const { parameters } = expression;
|
|
1264
|
+
const newParameters = {
|
|
1265
|
+
...parameters,
|
|
1266
|
+
children: (() => {
|
|
1267
|
+
const results = [];
|
|
1268
|
+
for (let ref6 = parameters.children, i1 = 0, len3 = ref6.length; i1 < len3; i1++) {
|
|
1269
|
+
let parameter = ref6[i1];
|
|
1270
|
+
if (typeof parameter === "object" && parameter != null && "type" in parameter && parameter.type === "Parameter") {
|
|
1271
|
+
let ref7;
|
|
1272
|
+
if (ref7 = parameter.initializer) {
|
|
1273
|
+
const initializer = ref7;
|
|
1274
|
+
args.push(initializer.expression, parameter.delim);
|
|
1275
|
+
parameter = {
|
|
1276
|
+
...parameter,
|
|
1277
|
+
initializer: void 0,
|
|
1278
|
+
children: parameter.children.filter((a2) => a2 !== initializer)
|
|
1279
|
+
};
|
|
1280
|
+
} else {
|
|
1281
|
+
args.push(parameter.children.filter(
|
|
1282
|
+
(a3) => a3 !== parameter.typeSuffix
|
|
1283
|
+
));
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
results.push(parameter);
|
|
1287
|
+
}
|
|
1288
|
+
return results;
|
|
1289
|
+
})()
|
|
1290
|
+
};
|
|
1291
|
+
expression = {
|
|
1292
|
+
...expression,
|
|
1293
|
+
parameters: newParameters,
|
|
1294
|
+
children: expression.children.map(($) => $ === parameters ? newParameters : $)
|
|
1295
|
+
};
|
|
1296
|
+
}
|
|
1297
|
+
return {
|
|
1298
|
+
type: "CallExpression",
|
|
1299
|
+
children: [
|
|
1300
|
+
makeLeftHandSideExpression(expression),
|
|
1301
|
+
{
|
|
1302
|
+
type: "Call",
|
|
1303
|
+
args,
|
|
1304
|
+
children: ["(", args, ")"]
|
|
1305
|
+
}
|
|
1306
|
+
]
|
|
1307
|
+
};
|
|
1308
|
+
}
|
|
1250
1309
|
|
|
1251
1310
|
// source/parser/block.civet
|
|
1252
1311
|
function blockWithPrefix(prefixStatements, block) {
|
|
@@ -1407,6 +1466,9 @@ function needsPrecedingSemicolon(exp) {
|
|
|
1407
1466
|
}
|
|
1408
1467
|
return false;
|
|
1409
1468
|
}
|
|
1469
|
+
if (isToken(exp)) {
|
|
1470
|
+
exp = exp.token;
|
|
1471
|
+
}
|
|
1410
1472
|
if (typeof exp === "string") {
|
|
1411
1473
|
return /^\s*[\(\[\`\+\-\/]/.test(exp);
|
|
1412
1474
|
}
|
|
@@ -1842,24 +1904,29 @@ function makeAmpersandFunction(rhs) {
|
|
|
1842
1904
|
}
|
|
1843
1905
|
return fn;
|
|
1844
1906
|
}
|
|
1907
|
+
var skipParens = /* @__PURE__ */ new Set([
|
|
1908
|
+
"AmpersandRef",
|
|
1909
|
+
"CallExpression",
|
|
1910
|
+
"Identifier",
|
|
1911
|
+
"JSXElement",
|
|
1912
|
+
"JSXFragment",
|
|
1913
|
+
"Literal",
|
|
1914
|
+
"MemberExpression",
|
|
1915
|
+
"NewExpression",
|
|
1916
|
+
"ParenthesizedExpression",
|
|
1917
|
+
"Ref",
|
|
1918
|
+
"Placeholder",
|
|
1919
|
+
"StatementExpression"
|
|
1920
|
+
// wrapIIFE
|
|
1921
|
+
]);
|
|
1845
1922
|
function makeLeftHandSideExpression(expression) {
|
|
1846
|
-
if (expression
|
|
1847
|
-
|
|
1848
|
-
}
|
|
1849
|
-
switch (expression.type) {
|
|
1850
|
-
case "AmpersandRef":
|
|
1851
|
-
case "CallExpression":
|
|
1852
|
-
case "Identifier":
|
|
1853
|
-
case "JSXElement":
|
|
1854
|
-
case "JSXFragment":
|
|
1855
|
-
case "Literal":
|
|
1856
|
-
case "MemberExpression":
|
|
1857
|
-
case "NewExpression":
|
|
1858
|
-
case "ParenthesizedExpression":
|
|
1859
|
-
case "Ref":
|
|
1860
|
-
case "Placeholder":
|
|
1861
|
-
case "StatementExpression":
|
|
1923
|
+
if (isASTNodeObject(expression)) {
|
|
1924
|
+
if (expression.parenthesized) {
|
|
1862
1925
|
return expression;
|
|
1926
|
+
}
|
|
1927
|
+
if (skipParens.has(expression.type)) {
|
|
1928
|
+
return expression;
|
|
1929
|
+
}
|
|
1863
1930
|
}
|
|
1864
1931
|
return makeNode({
|
|
1865
1932
|
type: "ParenthesizedExpression",
|
|
@@ -3232,7 +3299,6 @@ function processDeclarationConditionStatement(s) {
|
|
|
3232
3299
|
if (s.negated) {
|
|
3233
3300
|
let m;
|
|
3234
3301
|
if (!(m = condition.expression, typeof m === "object" && m != null && "type" in m && m.type === "UnaryExpression" && "children" in m && Array.isArray(m.children) && len2(m.children, 2) && m.children[0] === "!" && typeof m.children[1] === "object" && m.children[1] != null && "type" in m.children[1] && m.children[1].type === "ParenthesizedExpression")) {
|
|
3235
|
-
console.log(condition.expression);
|
|
3236
3302
|
throw new Error("Unsupported negated condition");
|
|
3237
3303
|
}
|
|
3238
3304
|
const { children } = condition.expression.children[1];
|
|
@@ -4125,49 +4191,71 @@ function stringify(node) {
|
|
|
4125
4191
|
return `${node}`;
|
|
4126
4192
|
}
|
|
4127
4193
|
}
|
|
4128
|
-
function gen(
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
options?.updateSourceMap?.(node);
|
|
4134
|
-
return node;
|
|
4135
|
-
}
|
|
4136
|
-
if (Array.isArray(node)) {
|
|
4137
|
-
return node.map(function(child) {
|
|
4138
|
-
return gen(child, options);
|
|
4139
|
-
}).join("");
|
|
4140
|
-
}
|
|
4141
|
-
if (typeof node === "object") {
|
|
4142
|
-
if (options.js && node.ts) {
|
|
4143
|
-
return "";
|
|
4144
|
-
}
|
|
4145
|
-
if (!options.js && node.js) {
|
|
4194
|
+
function gen(root, options) {
|
|
4195
|
+
const updateSourceMap = options?.sourceMap?.updateSourceMap;
|
|
4196
|
+
return recurse(root);
|
|
4197
|
+
function recurse(node) {
|
|
4198
|
+
if (!(node != null)) {
|
|
4146
4199
|
return "";
|
|
4147
4200
|
}
|
|
4148
|
-
if (node
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
return "";
|
|
4201
|
+
if (typeof node === "string") {
|
|
4202
|
+
updateSourceMap?.(node);
|
|
4203
|
+
return node;
|
|
4152
4204
|
}
|
|
4153
|
-
if (node
|
|
4154
|
-
|
|
4155
|
-
options?.updateSourceMap?.(token, $loc.pos);
|
|
4156
|
-
return token;
|
|
4205
|
+
if (Array.isArray(node)) {
|
|
4206
|
+
return node.map(recurse).join("");
|
|
4157
4207
|
}
|
|
4158
|
-
if (
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4208
|
+
if (typeof node === "object") {
|
|
4209
|
+
if (options.js && node.ts) {
|
|
4210
|
+
return "";
|
|
4211
|
+
}
|
|
4212
|
+
if (!options.js && node.js) {
|
|
4213
|
+
return "";
|
|
4214
|
+
}
|
|
4215
|
+
if (node.type === "Error") {
|
|
4216
|
+
const filename2 = options?.filename ?? "unknown";
|
|
4217
|
+
let line = "?";
|
|
4218
|
+
let column = "?";
|
|
4219
|
+
let offset;
|
|
4220
|
+
if (options && typeof options === "object" && "sourceMap" in options) {
|
|
4221
|
+
const { sourceMap } = options;
|
|
4222
|
+
line = sourceMap.data.srcLine + 1;
|
|
4223
|
+
column = sourceMap.data.srcColumn + 1;
|
|
4224
|
+
offset = sourceMap.data.srcOffset;
|
|
4225
|
+
}
|
|
4226
|
+
options.errors ??= [];
|
|
4227
|
+
options.errors.push(new import_lib3.ParseError(
|
|
4228
|
+
node.message,
|
|
4229
|
+
void 0,
|
|
4230
|
+
// body
|
|
4231
|
+
filename2,
|
|
4232
|
+
line,
|
|
4233
|
+
column,
|
|
4234
|
+
offset
|
|
4235
|
+
));
|
|
4236
|
+
return "";
|
|
4237
|
+
}
|
|
4238
|
+
if (node.$loc != null) {
|
|
4239
|
+
const { token, $loc } = node;
|
|
4240
|
+
updateSourceMap?.(token, $loc.pos);
|
|
4241
|
+
return token;
|
|
4242
|
+
}
|
|
4243
|
+
if (!node.children) {
|
|
4244
|
+
switch (node.type) {
|
|
4245
|
+
case "Ref": {
|
|
4246
|
+
throw new Error(`Unpopulated ref ${stringify(node)}`);
|
|
4247
|
+
}
|
|
4162
4248
|
}
|
|
4249
|
+
debugger;
|
|
4250
|
+
throw new Error(`Unknown node ${stringify(node)}`);
|
|
4163
4251
|
}
|
|
4164
|
-
|
|
4165
|
-
throw new Error(`Unknown node ${stringify(node)}`);
|
|
4252
|
+
return recurse(node.children);
|
|
4166
4253
|
}
|
|
4167
|
-
|
|
4254
|
+
debugger;
|
|
4255
|
+
throw new Error(`Unknown node ${stringify(node)}`);
|
|
4168
4256
|
}
|
|
4169
|
-
|
|
4170
|
-
|
|
4257
|
+
;
|
|
4258
|
+
return recurse;
|
|
4171
4259
|
}
|
|
4172
4260
|
var generate_default = gen;
|
|
4173
4261
|
function prune(node) {
|
|
@@ -5271,7 +5359,8 @@ function processAssignments(statements) {
|
|
|
5271
5359
|
while (expr.type === "ParenthesizedExpression") {
|
|
5272
5360
|
expr = expr.expression;
|
|
5273
5361
|
}
|
|
5274
|
-
|
|
5362
|
+
let m;
|
|
5363
|
+
if (m = expr.type, m === "AssignmentExpression" || m === "UpdateExpression") {
|
|
5275
5364
|
if (expr.type === "UpdateExpression" && expr.children[0] === expr.assigned) {
|
|
5276
5365
|
pre.push("(");
|
|
5277
5366
|
post.push([", ", lhs, ")"]);
|
|
@@ -5285,26 +5374,31 @@ function processAssignments(statements) {
|
|
|
5285
5374
|
return;
|
|
5286
5375
|
}
|
|
5287
5376
|
const pre = [], post = [];
|
|
5377
|
+
let ref4;
|
|
5288
5378
|
switch (exp.type) {
|
|
5289
|
-
case "AssignmentExpression":
|
|
5379
|
+
case "AssignmentExpression": {
|
|
5290
5380
|
if (!exp.lhs)
|
|
5291
5381
|
return;
|
|
5292
5382
|
exp.lhs.forEach((lhsPart, i) => {
|
|
5293
|
-
let
|
|
5294
|
-
if (
|
|
5295
|
-
|
|
5383
|
+
let ref5;
|
|
5384
|
+
if (ref5 = extractAssignment(lhsPart[1])) {
|
|
5385
|
+
const newLhs = ref5;
|
|
5386
|
+
return lhsPart[1] = newLhs;
|
|
5296
5387
|
}
|
|
5297
5388
|
;
|
|
5298
5389
|
return;
|
|
5299
5390
|
});
|
|
5300
5391
|
break;
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
if (
|
|
5392
|
+
}
|
|
5393
|
+
case "UpdateExpression": {
|
|
5394
|
+
if (ref4 = extractAssignment(exp.assigned)) {
|
|
5395
|
+
const newLhs = ref4;
|
|
5304
5396
|
const i = exp.children.indexOf(exp.assigned);
|
|
5305
5397
|
exp.assigned = exp.children[i] = newLhs;
|
|
5306
5398
|
}
|
|
5399
|
+
;
|
|
5307
5400
|
break;
|
|
5401
|
+
}
|
|
5308
5402
|
}
|
|
5309
5403
|
if (pre.length)
|
|
5310
5404
|
exp.children.unshift(...pre);
|
|
@@ -5314,13 +5408,7 @@ function processAssignments(statements) {
|
|
|
5314
5408
|
const { assigned } = exp;
|
|
5315
5409
|
const ref = makeRef();
|
|
5316
5410
|
const newMemberExp = unchainOptionalMemberExpression(assigned, ref, (children) => {
|
|
5317
|
-
return exp.children.map((
|
|
5318
|
-
if (c === assigned) {
|
|
5319
|
-
return children;
|
|
5320
|
-
} else {
|
|
5321
|
-
return c;
|
|
5322
|
-
}
|
|
5323
|
-
});
|
|
5411
|
+
return exp.children.map(($) => $ === assigned ? children : $);
|
|
5324
5412
|
});
|
|
5325
5413
|
if (newMemberExp !== assigned) {
|
|
5326
5414
|
if (newMemberExp.usesRef) {
|
|
@@ -5342,38 +5430,34 @@ function processAssignments(statements) {
|
|
|
5342
5430
|
statements,
|
|
5343
5431
|
(n) => n.type === "AssignmentExpression" && n.names === null,
|
|
5344
5432
|
(exp) => {
|
|
5345
|
-
let { lhs: $1, expression: $2 } = exp, tail = [],
|
|
5433
|
+
let { lhs: $1, expression: $2 } = exp, tail = [], len3 = $1.length;
|
|
5346
5434
|
let block;
|
|
5347
|
-
let
|
|
5348
|
-
if (exp.parent?.type === "BlockStatement" && !(
|
|
5435
|
+
let ref6;
|
|
5436
|
+
if (exp.parent?.type === "BlockStatement" && !(ref6 = $1[$1.length - 1])?.[ref6.length - 1]?.special) {
|
|
5349
5437
|
block = makeBlockFragment();
|
|
5350
|
-
let
|
|
5351
|
-
if (
|
|
5438
|
+
let ref7;
|
|
5439
|
+
if (ref7 = prependStatementExpressionBlock(
|
|
5352
5440
|
{ type: "Initializer", expression: $2, children: [void 0, void 0, $2] },
|
|
5353
5441
|
block
|
|
5354
5442
|
)) {
|
|
5355
|
-
const ref =
|
|
5356
|
-
exp.children = exp.children.map(
|
|
5357
|
-
if (c === $2)
|
|
5358
|
-
return ref;
|
|
5359
|
-
else
|
|
5360
|
-
return c;
|
|
5361
|
-
});
|
|
5443
|
+
const ref = ref7;
|
|
5444
|
+
exp.children = exp.children.map(($3) => $3 === $2 ? ref : $3);
|
|
5362
5445
|
$2 = ref;
|
|
5363
5446
|
} else {
|
|
5364
5447
|
block = void 0;
|
|
5365
5448
|
}
|
|
5366
5449
|
}
|
|
5367
|
-
|
|
5450
|
+
let ref8;
|
|
5451
|
+
if ($1.some(($4) => (ref8 = $4)[ref8.length - 1].special)) {
|
|
5368
5452
|
if ($1.length !== 1)
|
|
5369
5453
|
throw new Error("Only one assignment with id= is allowed");
|
|
5370
5454
|
const [, lhs, , op] = $1[0];
|
|
5371
5455
|
const { call, omitLhs } = op;
|
|
5372
|
-
const
|
|
5373
|
-
if (
|
|
5456
|
+
const index = exp.children.indexOf($2);
|
|
5457
|
+
if (index < 0)
|
|
5374
5458
|
throw new Error("Assertion error: exp not in AssignmentExpression");
|
|
5375
5459
|
exp.children.splice(
|
|
5376
|
-
|
|
5460
|
+
index,
|
|
5377
5461
|
1,
|
|
5378
5462
|
exp.expression = $2 = [call, "(", lhs, ", ", $2, ")"]
|
|
5379
5463
|
);
|
|
@@ -5382,12 +5466,15 @@ function processAssignments(statements) {
|
|
|
5382
5466
|
}
|
|
5383
5467
|
}
|
|
5384
5468
|
let wrapped = false;
|
|
5469
|
+
let i = 0;
|
|
5385
5470
|
while (i < len3) {
|
|
5386
5471
|
const lastAssignment = $1[i++];
|
|
5387
5472
|
const [, lhs, , op] = lastAssignment;
|
|
5388
|
-
if (op.token
|
|
5473
|
+
if (!(op.token === "=")) {
|
|
5389
5474
|
continue;
|
|
5390
|
-
|
|
5475
|
+
}
|
|
5476
|
+
let m1;
|
|
5477
|
+
if (m1 = lhs.type, m1 === "ObjectExpression" || m1 === "ObjectBindingPattern") {
|
|
5391
5478
|
if (!wrapped) {
|
|
5392
5479
|
wrapped = true;
|
|
5393
5480
|
lhs.children.splice(0, 0, "(");
|
|
@@ -5400,6 +5487,7 @@ function processAssignments(statements) {
|
|
|
5400
5487
|
const lastAssignment = $1[i];
|
|
5401
5488
|
if (lastAssignment[3].token === "=") {
|
|
5402
5489
|
const lhs = lastAssignment[1];
|
|
5490
|
+
let m2;
|
|
5403
5491
|
if (lhs.type === "MemberExpression") {
|
|
5404
5492
|
const members = lhs.children;
|
|
5405
5493
|
const lastMember = members[members.length - 1];
|
|
@@ -5423,9 +5511,9 @@ function processAssignments(statements) {
|
|
|
5423
5511
|
}
|
|
5424
5512
|
exp.children = [$1];
|
|
5425
5513
|
exp.names = [];
|
|
5426
|
-
|
|
5514
|
+
break;
|
|
5427
5515
|
}
|
|
5428
|
-
} else if (lhs.type === "ObjectBindingPattern" ||
|
|
5516
|
+
} else if (m2 = lhs.type, m2 === "ObjectBindingPattern" || m2 === "ArrayBindingPattern") {
|
|
5429
5517
|
processBindingPatternLHS(lhs, tail);
|
|
5430
5518
|
}
|
|
5431
5519
|
}
|
|
@@ -5458,10 +5546,12 @@ function processAssignments(statements) {
|
|
|
5458
5546
|
i--;
|
|
5459
5547
|
}
|
|
5460
5548
|
exp.names = $1.flatMap(([, l]) => l.names || []);
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5549
|
+
if (tail.length) {
|
|
5550
|
+
const index = exp.children.indexOf($2);
|
|
5551
|
+
if (index < 0)
|
|
5552
|
+
throw new Error("Assertion error: exp not in AssignmentExpression");
|
|
5553
|
+
exp.children.splice(index + 1, 0, ...tail);
|
|
5554
|
+
}
|
|
5465
5555
|
if (block) {
|
|
5466
5556
|
block.parent = exp.parent;
|
|
5467
5557
|
block.expressions.push(["", exp]);
|
|
@@ -5520,9 +5610,9 @@ function unchainOptionalMemberExpression(exp, ref, innerExp) {
|
|
|
5520
5610
|
}
|
|
5521
5611
|
j++;
|
|
5522
5612
|
}
|
|
5523
|
-
let
|
|
5524
|
-
if (
|
|
5525
|
-
const l =
|
|
5613
|
+
let ref9;
|
|
5614
|
+
if (ref9 = conditions.length) {
|
|
5615
|
+
const l = ref9;
|
|
5526
5616
|
const cs = flatJoin(conditions, " && ");
|
|
5527
5617
|
return {
|
|
5528
5618
|
...exp,
|
|
@@ -5559,8 +5649,8 @@ function processTypes(node) {
|
|
|
5559
5649
|
return gatherRecursiveAll(node, (n) => n.type === "UnaryType").forEach((unary) => {
|
|
5560
5650
|
let last;
|
|
5561
5651
|
let count = 0;
|
|
5562
|
-
let
|
|
5563
|
-
while (unary.suffix.length && (
|
|
5652
|
+
let ref10;
|
|
5653
|
+
while (unary.suffix.length && (ref10 = unary.suffix)[ref10.length - 1]?.token === "?") {
|
|
5564
5654
|
last = unary.suffix.pop();
|
|
5565
5655
|
count++;
|
|
5566
5656
|
}
|
|
@@ -5591,14 +5681,14 @@ function processTypes(node) {
|
|
|
5591
5681
|
});
|
|
5592
5682
|
}
|
|
5593
5683
|
function processStatementExpressions(statements) {
|
|
5594
|
-
gatherRecursiveAll(statements, ($) =>
|
|
5684
|
+
gatherRecursiveAll(statements, ($5) => $5.type === "StatementExpression").forEach((_exp) => {
|
|
5595
5685
|
const exp = _exp;
|
|
5596
5686
|
const { statement } = exp;
|
|
5597
|
-
let
|
|
5687
|
+
let ref11;
|
|
5598
5688
|
switch (statement.type) {
|
|
5599
5689
|
case "IfStatement": {
|
|
5600
|
-
if (
|
|
5601
|
-
const expression =
|
|
5690
|
+
if (ref11 = expressionizeIfStatement(statement)) {
|
|
5691
|
+
const expression = ref11;
|
|
5602
5692
|
return replaceNode(statement, expression, exp);
|
|
5603
5693
|
} else {
|
|
5604
5694
|
return replaceNode(statement, wrapIIFE([["", statement]]), exp);
|
|
@@ -5640,7 +5730,7 @@ function processNegativeIndexAccess(statements) {
|
|
|
5640
5730
|
}
|
|
5641
5731
|
} else if (index > start + 1) {
|
|
5642
5732
|
ref = makeRef();
|
|
5643
|
-
subexp = children.splice(start, index);
|
|
5733
|
+
subexp = children.splice(start, index - start);
|
|
5644
5734
|
} else {
|
|
5645
5735
|
throw new Error("Invalid parse tree for negative index access");
|
|
5646
5736
|
}
|
|
@@ -5649,7 +5739,7 @@ function processNegativeIndexAccess(statements) {
|
|
|
5649
5739
|
exp.hoistDec = hoistDec;
|
|
5650
5740
|
children.splice(start, 0, makeLeftHandSideExpression(refAssignment));
|
|
5651
5741
|
}
|
|
5652
|
-
|
|
5742
|
+
exp.len.children = [
|
|
5653
5743
|
ref,
|
|
5654
5744
|
".length"
|
|
5655
5745
|
];
|
|
@@ -5721,11 +5811,11 @@ function populateRefs(statements) {
|
|
|
5721
5811
|
function processPlaceholders(statements) {
|
|
5722
5812
|
const placeholderMap = /* @__PURE__ */ new Map();
|
|
5723
5813
|
const liftedIfs = /* @__PURE__ */ new Set();
|
|
5724
|
-
gatherRecursiveAll(statements, ($
|
|
5814
|
+
gatherRecursiveAll(statements, ($6) => $6.type === "Placeholder").forEach((_exp) => {
|
|
5725
5815
|
const exp = _exp;
|
|
5726
5816
|
let ancestor;
|
|
5727
5817
|
if (exp.subtype === ".") {
|
|
5728
|
-
({ ancestor } = findAncestor(exp, ($
|
|
5818
|
+
({ ancestor } = findAncestor(exp, ($7) => $7.type === "Call"));
|
|
5729
5819
|
ancestor = ancestor?.parent;
|
|
5730
5820
|
while (ancestor?.parent?.type === "UnaryExpression" || ancestor?.parent?.type === "NewExpression") {
|
|
5731
5821
|
ancestor = ancestor.parent;
|
|
@@ -5744,10 +5834,10 @@ function processPlaceholders(statements) {
|
|
|
5744
5834
|
if (type === "IfStatement") {
|
|
5745
5835
|
liftedIfs.add(ancestor2);
|
|
5746
5836
|
}
|
|
5747
|
-
let
|
|
5748
|
-
let
|
|
5837
|
+
let m3;
|
|
5838
|
+
let m4;
|
|
5749
5839
|
return type === "Call" || // Block, except for if/else blocks when condition already lifted
|
|
5750
|
-
type === "BlockStatement" && !((
|
|
5840
|
+
type === "BlockStatement" && !((m3 = ancestor2.parent, typeof m3 === "object" && m3 != null && "type" in m3 && m3.type === "IfStatement") && liftedIfs.has(ancestor2.parent)) && !((m4 = ancestor2.parent, typeof m4 === "object" && m4 != null && "type" in m4 && m4.type === "ElseClause" && "parent" in m4 && typeof m4.parent === "object" && m4.parent != null && "type" in m4.parent && m4.parent.type === "IfStatement") && liftedIfs.has(ancestor2.parent.parent)) || type === "PipelineExpression" || // Declaration
|
|
5751
5841
|
type === "Initializer" || // Right-hand side of assignment
|
|
5752
5842
|
type === "AssignmentExpression" && findChildIndex(ancestor2, child2) === ancestor2.children.indexOf(ancestor2.expression) || type === "ReturnStatement" || type === "YieldExpression";
|
|
5753
5843
|
}));
|
|
@@ -5826,8 +5916,8 @@ function processPlaceholders(statements) {
|
|
|
5826
5916
|
for (let i4 = 0, len3 = placeholders.length; i4 < len3; i4++) {
|
|
5827
5917
|
const placeholder = placeholders[i4];
|
|
5828
5918
|
typeSuffix ??= placeholder.typeSuffix;
|
|
5829
|
-
let
|
|
5830
|
-
replaceNode((
|
|
5919
|
+
let ref12;
|
|
5920
|
+
replaceNode((ref12 = placeholder.children)[ref12.length - 1], ref);
|
|
5831
5921
|
}
|
|
5832
5922
|
const { parent } = ancestor;
|
|
5833
5923
|
const body = maybeUnwrap(ancestor);
|
|
@@ -5858,9 +5948,9 @@ function processPlaceholders(statements) {
|
|
|
5858
5948
|
fnExp = makeLeftHandSideExpression(fnExp);
|
|
5859
5949
|
}
|
|
5860
5950
|
replaceNode(ancestor, fnExp, parent);
|
|
5861
|
-
let
|
|
5862
|
-
if (
|
|
5863
|
-
const ws =
|
|
5951
|
+
let ref13;
|
|
5952
|
+
if (ref13 = getTrimmingSpace(body)) {
|
|
5953
|
+
const ws = ref13;
|
|
5864
5954
|
inplaceInsertTrimmingSpace(body, "");
|
|
5865
5955
|
inplacePrepend(ws, fnExp);
|
|
5866
5956
|
}
|
|
@@ -5885,43 +5975,39 @@ function reorderBindingRestProperty(props) {
|
|
|
5885
5975
|
children: props,
|
|
5886
5976
|
names
|
|
5887
5977
|
};
|
|
5888
|
-
}
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
|
|
5898
|
-
};
|
|
5899
|
-
after = [
|
|
5900
|
-
...after.slice(0, -1),
|
|
5901
|
-
{
|
|
5902
|
-
...lastAfterProp,
|
|
5903
|
-
delim: restDelim,
|
|
5904
|
-
children: [...lastAfterChildren.slice(0, -1), restDelim]
|
|
5905
|
-
}
|
|
5906
|
-
];
|
|
5907
|
-
}
|
|
5908
|
-
let ref11;
|
|
5909
|
-
if (Array.isArray(rest.delim) && (ref11 = rest.delim)[ref11.length - 1]?.token === ",") {
|
|
5910
|
-
rest.delim = rest.delim.slice(0, -1);
|
|
5911
|
-
rest.children = [...rest.children.slice(0, -1), rest.delim];
|
|
5912
|
-
}
|
|
5913
|
-
const children = [...props, ...after, rest];
|
|
5914
|
-
return {
|
|
5915
|
-
children,
|
|
5916
|
-
names
|
|
5978
|
+
}
|
|
5979
|
+
let after = props.slice(restIndex + 1);
|
|
5980
|
+
let rest = props[restIndex];
|
|
5981
|
+
props = props.slice(0, restIndex);
|
|
5982
|
+
if (after.length) {
|
|
5983
|
+
const { delim: restDelim } = rest, lastAfterProp = after[after.length - 1], { delim: lastDelim, children: lastAfterChildren } = lastAfterProp;
|
|
5984
|
+
rest = {
|
|
5985
|
+
...rest,
|
|
5986
|
+
delim: lastDelim,
|
|
5987
|
+
children: [...rest.children.slice(0, -1), lastDelim]
|
|
5917
5988
|
};
|
|
5989
|
+
after = [
|
|
5990
|
+
...after.slice(0, -1),
|
|
5991
|
+
{
|
|
5992
|
+
...lastAfterProp,
|
|
5993
|
+
delim: restDelim,
|
|
5994
|
+
children: [...lastAfterChildren.slice(0, -1), restDelim]
|
|
5995
|
+
}
|
|
5996
|
+
];
|
|
5918
5997
|
}
|
|
5919
|
-
|
|
5920
|
-
|
|
5998
|
+
let ref14;
|
|
5999
|
+
if (Array.isArray(rest.delim) && (ref14 = rest.delim)[ref14.length - 1]?.token === ",") {
|
|
6000
|
+
rest.delim = rest.delim.slice(0, -1);
|
|
6001
|
+
rest.children = [...rest.children.slice(0, -1), rest.delim];
|
|
6002
|
+
}
|
|
6003
|
+
const children = [...props, ...after, rest];
|
|
6004
|
+
if (restCount > 1) {
|
|
6005
|
+
children.push({
|
|
5921
6006
|
type: "Error",
|
|
5922
6007
|
message: "Multiple rest properties in object pattern"
|
|
5923
|
-
}
|
|
5924
|
-
}
|
|
6008
|
+
});
|
|
6009
|
+
}
|
|
6010
|
+
return { children, names };
|
|
5925
6011
|
}
|
|
5926
6012
|
function replaceNodes(root, predicate, replacer) {
|
|
5927
6013
|
if (!(root != null)) {
|
|
@@ -6104,6 +6190,7 @@ var grammar = {
|
|
|
6104
6190
|
YieldExpression,
|
|
6105
6191
|
ArrowFunction,
|
|
6106
6192
|
FatArrow,
|
|
6193
|
+
FatArrowToken,
|
|
6107
6194
|
TrailingDeclaration,
|
|
6108
6195
|
TrailingPipe,
|
|
6109
6196
|
FatArrowBody,
|
|
@@ -6224,9 +6311,11 @@ var grammar = {
|
|
|
6224
6311
|
NoCommaBracedOrEmptyBlock,
|
|
6225
6312
|
NoPostfixBracedOrEmptyBlock,
|
|
6226
6313
|
EmptyBlock,
|
|
6314
|
+
BlockOrEmptyStatement,
|
|
6227
6315
|
BlockOrEmpty,
|
|
6228
|
-
EmptyBareBlock,
|
|
6229
6316
|
EmptyStatementBareBlock,
|
|
6317
|
+
EmptyBareBlock,
|
|
6318
|
+
NoBlock,
|
|
6230
6319
|
BracedBlock,
|
|
6231
6320
|
NoPostfixBracedBlock,
|
|
6232
6321
|
NoCommaBracedBlock,
|
|
@@ -7245,13 +7334,14 @@ function ExpressionizedStatement(ctx, state2) {
|
|
|
7245
7334
|
}
|
|
7246
7335
|
var StatementExpression$0 = DebuggerStatement;
|
|
7247
7336
|
var StatementExpression$1 = (0, import_lib3.$TS)((0, import_lib3.$S)(IfStatement), function($skip, $loc, $0, $1) {
|
|
7248
|
-
if (!$1.else &&
|
|
7337
|
+
if (!$1.else && $1.then.implicit)
|
|
7249
7338
|
return $skip;
|
|
7250
7339
|
return $1;
|
|
7251
7340
|
});
|
|
7252
7341
|
var StatementExpression$2 = (0, import_lib3.$TS)((0, import_lib3.$S)(IterationExpression), function($skip, $loc, $0, $1) {
|
|
7253
|
-
if (
|
|
7342
|
+
if ($1.block.implicit && $1.subtype !== "DoStatement" && $1.subtype !== "ComptimeStatement") {
|
|
7254
7343
|
return $skip;
|
|
7344
|
+
}
|
|
7255
7345
|
return $1;
|
|
7256
7346
|
});
|
|
7257
7347
|
var StatementExpression$3 = SwitchStatement;
|
|
@@ -7342,7 +7432,7 @@ var ForbiddenImplicitCalls$6 = (0, import_lib3.$TS)((0, import_lib3.$S)(OmittedN
|
|
|
7342
7432
|
return $0;
|
|
7343
7433
|
return $skip;
|
|
7344
7434
|
});
|
|
7345
|
-
var ForbiddenImplicitCalls$7 = (0, import_lib3.$S)(PostfixStatement,
|
|
7435
|
+
var ForbiddenImplicitCalls$7 = (0, import_lib3.$S)(PostfixStatement, NoBlock);
|
|
7346
7436
|
var ForbiddenImplicitCalls$8 = (0, import_lib3.$EXPECT)($L5, 'ForbiddenImplicitCalls "... "');
|
|
7347
7437
|
var ForbiddenImplicitCalls$$ = [ForbiddenImplicitCalls$0, ForbiddenImplicitCalls$1, ForbiddenImplicitCalls$2, ForbiddenImplicitCalls$3, ForbiddenImplicitCalls$4, ForbiddenImplicitCalls$5, ForbiddenImplicitCalls$6, ForbiddenImplicitCalls$7, ForbiddenImplicitCalls$8];
|
|
7348
7438
|
function ForbiddenImplicitCalls(ctx, state2) {
|
|
@@ -7567,11 +7657,10 @@ var UnaryExpression$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3
|
|
|
7567
7657
|
var post = $3;
|
|
7568
7658
|
return processUnaryExpression(pre, exp, post);
|
|
7569
7659
|
});
|
|
7570
|
-
var UnaryExpression$1 = (0, import_lib3.$TS)((0, import_lib3.$S)(CoffeeDoEnabled, Do, __, (0, import_lib3.$C)((0, import_lib3.$S)(LeftHandSideExpression, (0, import_lib3.$N)((0, import_lib3.$S)(__, AssignmentOpSymbol))),
|
|
7660
|
+
var UnaryExpression$1 = (0, import_lib3.$TS)((0, import_lib3.$S)(CoffeeDoEnabled, Do, __, (0, import_lib3.$C)(ArrowFunction, (0, import_lib3.$S)(LeftHandSideExpression, (0, import_lib3.$N)((0, import_lib3.$S)(__, AssignmentOpSymbol))), ExtendedExpression)), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
7571
7661
|
var ws = $3;
|
|
7572
7662
|
var exp = $4;
|
|
7573
|
-
|
|
7574
|
-
return ["(", ...ws, exp, ")()"];
|
|
7663
|
+
return processCoffeeDo(ws, exp);
|
|
7575
7664
|
});
|
|
7576
7665
|
var UnaryExpression$$ = [UnaryExpression$0, UnaryExpression$1];
|
|
7577
7666
|
function UnaryExpression(ctx, state2) {
|
|
@@ -7793,6 +7882,7 @@ var ArrowFunction$1 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$
|
|
|
7793
7882
|
var async = $1;
|
|
7794
7883
|
var parameters = $2;
|
|
7795
7884
|
var suffix = $3;
|
|
7885
|
+
var arrow = $4;
|
|
7796
7886
|
var expOrBlock = $5;
|
|
7797
7887
|
if (hasAwait(expOrBlock) && !async) {
|
|
7798
7888
|
async = "async ";
|
|
@@ -7817,22 +7907,29 @@ var ArrowFunction$1 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$
|
|
|
7817
7907
|
ts: false,
|
|
7818
7908
|
async,
|
|
7819
7909
|
block: expOrBlock,
|
|
7820
|
-
children: [async,
|
|
7910
|
+
children: [async, parameters, suffix, arrow, error, expOrBlock]
|
|
7821
7911
|
};
|
|
7822
7912
|
});
|
|
7823
7913
|
var ArrowFunction$$ = [ArrowFunction$0, ArrowFunction$1];
|
|
7824
7914
|
function ArrowFunction(ctx, state2) {
|
|
7825
7915
|
return (0, import_lib3.$EVENT_C)(ctx, state2, "ArrowFunction", ArrowFunction$$);
|
|
7826
7916
|
}
|
|
7827
|
-
var FatArrow$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(_),
|
|
7917
|
+
var FatArrow$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(_), FatArrowToken), function($skip, $loc, $0, $1, $2) {
|
|
7828
7918
|
var ws = $1;
|
|
7919
|
+
var arrow = $2;
|
|
7829
7920
|
if (!ws)
|
|
7830
|
-
|
|
7831
|
-
return [
|
|
7921
|
+
ws = " ";
|
|
7922
|
+
return [ws, arrow];
|
|
7832
7923
|
});
|
|
7833
7924
|
function FatArrow(ctx, state2) {
|
|
7834
7925
|
return (0, import_lib3.$EVENT)(ctx, state2, "FatArrow", FatArrow$0);
|
|
7835
7926
|
}
|
|
7927
|
+
var FatArrowToken$0 = (0, import_lib3.$TV)((0, import_lib3.$C)((0, import_lib3.$EXPECT)($L13, 'FatArrowToken "=>"'), (0, import_lib3.$EXPECT)($L14, 'FatArrowToken "\u21D2"')), function($skip, $loc, $0, $1) {
|
|
7928
|
+
return { $loc, token: "=>" };
|
|
7929
|
+
});
|
|
7930
|
+
function FatArrowToken(ctx, state2) {
|
|
7931
|
+
return (0, import_lib3.$EVENT)(ctx, state2, "FatArrowToken", FatArrowToken$0);
|
|
7932
|
+
}
|
|
7836
7933
|
var TrailingDeclaration$0 = (0, import_lib3.$S)((0, import_lib3.$E)(_), (0, import_lib3.$C)(ConstAssignment, LetAssignment));
|
|
7837
7934
|
function TrailingDeclaration(ctx, state2) {
|
|
7838
7935
|
return (0, import_lib3.$EVENT)(ctx, state2, "TrailingDeclaration", TrailingDeclaration$0);
|
|
@@ -8344,7 +8441,13 @@ var ThisLiteral$2 = (0, import_lib3.$TS)((0, import_lib3.$S)(AtThis, (0, import_
|
|
|
8344
8441
|
children: [at, {
|
|
8345
8442
|
type: "PropertyAccess",
|
|
8346
8443
|
name: id,
|
|
8347
|
-
children: [".",
|
|
8444
|
+
children: [".", {
|
|
8445
|
+
$loc: {
|
|
8446
|
+
pos: $loc.pos + 1,
|
|
8447
|
+
length: $loc.length - 1
|
|
8448
|
+
},
|
|
8449
|
+
token: id
|
|
8450
|
+
}]
|
|
8348
8451
|
}],
|
|
8349
8452
|
thisShorthand: true
|
|
8350
8453
|
};
|
|
@@ -9016,11 +9119,17 @@ function FunctionRestParameter(ctx, state2) {
|
|
|
9016
9119
|
var ParameterElement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(_), (0, import_lib3.$E)(AccessModifier), (0, import_lib3.$E)(_), (0, import_lib3.$C)(NWBindingIdentifier, BindingPattern), (0, import_lib3.$E)(TypeSuffix), (0, import_lib3.$E)(Initializer), ParameterElementDelimiter), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
|
|
9017
9120
|
var accessModifier = $2;
|
|
9018
9121
|
var binding = $4;
|
|
9122
|
+
var typeSuffix = $5;
|
|
9123
|
+
var initializer = $6;
|
|
9124
|
+
var delim = $7;
|
|
9019
9125
|
return {
|
|
9020
9126
|
type: "Parameter",
|
|
9021
9127
|
children: $0,
|
|
9022
9128
|
names: binding.names,
|
|
9023
|
-
|
|
9129
|
+
typeSuffix,
|
|
9130
|
+
accessModifier,
|
|
9131
|
+
initializer,
|
|
9132
|
+
delim
|
|
9024
9133
|
};
|
|
9025
9134
|
});
|
|
9026
9135
|
function ParameterElement(ctx, state2) {
|
|
@@ -9882,43 +9991,62 @@ var EmptyBlock$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(InsertOpenBrace, Ins
|
|
|
9882
9991
|
expressions,
|
|
9883
9992
|
children: [$1, expressions, $2],
|
|
9884
9993
|
bare: false,
|
|
9885
|
-
empty: true
|
|
9994
|
+
empty: true,
|
|
9995
|
+
implicit: true
|
|
9886
9996
|
};
|
|
9887
9997
|
});
|
|
9888
9998
|
function EmptyBlock(ctx, state2) {
|
|
9889
9999
|
return (0, import_lib3.$EVENT)(ctx, state2, "EmptyBlock", EmptyBlock$0);
|
|
9890
10000
|
}
|
|
10001
|
+
var BlockOrEmptyStatement$0 = Block;
|
|
10002
|
+
var BlockOrEmptyStatement$1 = (0, import_lib3.$T)((0, import_lib3.$S)(NoBlock, EmptyStatementBareBlock), function(value) {
|
|
10003
|
+
return value[1];
|
|
10004
|
+
});
|
|
10005
|
+
var BlockOrEmptyStatement$$ = [BlockOrEmptyStatement$0, BlockOrEmptyStatement$1];
|
|
10006
|
+
function BlockOrEmptyStatement(ctx, state2) {
|
|
10007
|
+
return (0, import_lib3.$EVENT_C)(ctx, state2, "BlockOrEmptyStatement", BlockOrEmptyStatement$$);
|
|
10008
|
+
}
|
|
9891
10009
|
var BlockOrEmpty$0 = Block;
|
|
9892
|
-
var BlockOrEmpty$1 =
|
|
10010
|
+
var BlockOrEmpty$1 = (0, import_lib3.$T)((0, import_lib3.$S)(NoBlock, EmptyBlock), function(value) {
|
|
10011
|
+
return value[1];
|
|
10012
|
+
});
|
|
9893
10013
|
var BlockOrEmpty$$ = [BlockOrEmpty$0, BlockOrEmpty$1];
|
|
9894
10014
|
function BlockOrEmpty(ctx, state2) {
|
|
9895
10015
|
return (0, import_lib3.$EVENT_C)(ctx, state2, "BlockOrEmpty", BlockOrEmpty$$);
|
|
9896
10016
|
}
|
|
9897
|
-
var
|
|
9898
|
-
|
|
10017
|
+
var EmptyStatementBareBlock$0 = (0, import_lib3.$TV)(InsertEmptyStatement, function($skip, $loc, $0, $1) {
|
|
10018
|
+
var s = $0;
|
|
10019
|
+
const expressions = [["", s]];
|
|
9899
10020
|
return {
|
|
9900
10021
|
type: "BlockStatement",
|
|
9901
10022
|
expressions,
|
|
9902
10023
|
children: [expressions],
|
|
9903
|
-
bare: true
|
|
10024
|
+
bare: true,
|
|
10025
|
+
empty: true,
|
|
10026
|
+
implicit: true,
|
|
10027
|
+
semicolon: s.children[0]
|
|
9904
10028
|
};
|
|
9905
10029
|
});
|
|
9906
|
-
function
|
|
9907
|
-
return (0, import_lib3.$EVENT)(ctx, state2, "
|
|
10030
|
+
function EmptyStatementBareBlock(ctx, state2) {
|
|
10031
|
+
return (0, import_lib3.$EVENT)(ctx, state2, "EmptyStatementBareBlock", EmptyStatementBareBlock$0);
|
|
9908
10032
|
}
|
|
9909
|
-
var
|
|
9910
|
-
|
|
9911
|
-
const expressions = [["", s]];
|
|
10033
|
+
var EmptyBareBlock$0 = (0, import_lib3.$TV)((0, import_lib3.$EXPECT)($L0, 'EmptyBareBlock ""'), function($skip, $loc, $0, $1) {
|
|
10034
|
+
const expressions = [];
|
|
9912
10035
|
return {
|
|
9913
10036
|
type: "BlockStatement",
|
|
9914
10037
|
expressions,
|
|
9915
10038
|
children: [expressions],
|
|
9916
10039
|
bare: true,
|
|
9917
|
-
|
|
10040
|
+
empty: true,
|
|
10041
|
+
implicit: true
|
|
9918
10042
|
};
|
|
9919
10043
|
});
|
|
9920
|
-
function
|
|
9921
|
-
return (0, import_lib3.$EVENT)(ctx, state2, "
|
|
10044
|
+
function EmptyBareBlock(ctx, state2) {
|
|
10045
|
+
return (0, import_lib3.$EVENT)(ctx, state2, "EmptyBareBlock", EmptyBareBlock$0);
|
|
10046
|
+
}
|
|
10047
|
+
var NoBlock$0 = (0, import_lib3.$S)((0, import_lib3.$Y)(EOS), (0, import_lib3.$N)(IndentedFurther));
|
|
10048
|
+
function NoBlock(ctx, state2) {
|
|
10049
|
+
return (0, import_lib3.$EVENT)(ctx, state2, "NoBlock", NoBlock$0);
|
|
9922
10050
|
}
|
|
9923
10051
|
var BracedBlock$0 = NonSingleBracedBlock;
|
|
9924
10052
|
var BracedBlock$1 = (0, import_lib3.$TS)((0, import_lib3.$S)(InsertOpenBrace, (0, import_lib3.$N)(EOS), PostfixedSingleLineStatements, InsertSpace, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
@@ -11770,7 +11898,7 @@ var IterationExpression$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_
|
|
|
11770
11898
|
function IterationExpression(ctx, state2) {
|
|
11771
11899
|
return (0, import_lib3.$EVENT)(ctx, state2, "IterationExpression", IterationExpression$0);
|
|
11772
11900
|
}
|
|
11773
|
-
var LoopStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(LoopClause,
|
|
11901
|
+
var LoopStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(LoopClause, BlockOrEmptyStatement), function($skip, $loc, $0, $1, $2) {
|
|
11774
11902
|
var clause = $1;
|
|
11775
11903
|
var block = $2;
|
|
11776
11904
|
return {
|
|
@@ -11848,7 +11976,7 @@ var ComptimeStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(Comptime, NoP
|
|
|
11848
11976
|
function ComptimeStatement(ctx, state2) {
|
|
11849
11977
|
return (0, import_lib3.$EVENT)(ctx, state2, "ComptimeStatement", ComptimeStatement$0);
|
|
11850
11978
|
}
|
|
11851
|
-
var WhileStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(WhileClause,
|
|
11979
|
+
var WhileStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(WhileClause, BlockOrEmptyStatement), function($skip, $loc, $0, $1, $2) {
|
|
11852
11980
|
var clause = $1;
|
|
11853
11981
|
var block = $2;
|
|
11854
11982
|
return {
|
|
@@ -11879,7 +12007,7 @@ var WhileClause$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$C)
|
|
|
11879
12007
|
function WhileClause(ctx, state2) {
|
|
11880
12008
|
return (0, import_lib3.$EVENT)(ctx, state2, "WhileClause", WhileClause$0);
|
|
11881
12009
|
}
|
|
11882
|
-
var ForStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(ForClause,
|
|
12010
|
+
var ForStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(ForClause, BlockOrEmptyStatement), function($skip, $loc, $0, $1, $2) {
|
|
11883
12011
|
var clause = $1;
|
|
11884
12012
|
var block = $2;
|
|
11885
12013
|
block = blockWithPrefix(clause.blockPrefix, block);
|
|
@@ -16457,33 +16585,20 @@ function parseProgram(input, options) {
|
|
|
16457
16585
|
}
|
|
16458
16586
|
}
|
|
16459
16587
|
|
|
16460
|
-
// source/
|
|
16461
|
-
var
|
|
16462
|
-
__export(
|
|
16588
|
+
// source/sourcemap.civet
|
|
16589
|
+
var sourcemap_exports = {};
|
|
16590
|
+
__export(sourcemap_exports, {
|
|
16463
16591
|
SourceMap: () => SourceMap,
|
|
16464
16592
|
base64Encode: () => base64Encode,
|
|
16465
16593
|
locationTable: () => locationTable,
|
|
16466
16594
|
lookupLineColumn: () => lookupLineColumn
|
|
16467
16595
|
});
|
|
16468
|
-
var smRegexp;
|
|
16469
|
-
var prettySourceExcerpt;
|
|
16470
|
-
var VLQ_SHIFT;
|
|
16471
|
-
var VLQ_CONTINUATION_BIT;
|
|
16472
|
-
var VLQ_VALUE_MASK;
|
|
16473
|
-
var encodeVlq;
|
|
16474
|
-
var BASE64_CHARS;
|
|
16475
|
-
var encodeBase64;
|
|
16476
|
-
var vlqTable;
|
|
16477
|
-
var vlqChars;
|
|
16478
|
-
var decodeError;
|
|
16479
|
-
var decodeVLQ;
|
|
16480
|
-
var remapPosition;
|
|
16481
16596
|
var locationTable = function(input) {
|
|
16482
|
-
|
|
16483
|
-
|
|
16484
|
-
|
|
16485
|
-
|
|
16486
|
-
|
|
16597
|
+
const linesRe = /([^\r\n]*)(\r\n|\r|\n|$)/y;
|
|
16598
|
+
const lines = [];
|
|
16599
|
+
let line = 0;
|
|
16600
|
+
let pos = 0;
|
|
16601
|
+
let result;
|
|
16487
16602
|
while (result = linesRe.exec(input)) {
|
|
16488
16603
|
pos += result[0].length;
|
|
16489
16604
|
lines[line++] = pos;
|
|
@@ -16494,39 +16609,35 @@ var locationTable = function(input) {
|
|
|
16494
16609
|
return lines;
|
|
16495
16610
|
};
|
|
16496
16611
|
var lookupLineColumn = function(table, pos) {
|
|
16497
|
-
|
|
16498
|
-
|
|
16499
|
-
prevEnd = 0;
|
|
16612
|
+
let l = 0;
|
|
16613
|
+
let prevEnd = 0;
|
|
16500
16614
|
while (table[l] <= pos) {
|
|
16501
16615
|
prevEnd = table[l++];
|
|
16502
16616
|
}
|
|
16503
16617
|
return [l, pos - prevEnd];
|
|
16504
16618
|
};
|
|
16505
16619
|
var SourceMap = function(sourceString) {
|
|
16506
|
-
|
|
16507
|
-
|
|
16508
|
-
sm = {
|
|
16620
|
+
const srcTable = locationTable(sourceString);
|
|
16621
|
+
const sm = {
|
|
16509
16622
|
lines: [[]],
|
|
16510
|
-
|
|
16511
|
-
|
|
16623
|
+
line: 0,
|
|
16624
|
+
column: 0,
|
|
16625
|
+
srcLine: 0,
|
|
16626
|
+
srcColumn: 0,
|
|
16627
|
+
srcOffset: 0,
|
|
16512
16628
|
srcTable
|
|
16513
16629
|
};
|
|
16514
|
-
EOL2 = /\r?\n|\r/;
|
|
16630
|
+
const EOL2 = /\r?\n|\r/;
|
|
16515
16631
|
return {
|
|
16516
16632
|
data: sm,
|
|
16517
|
-
source: function() {
|
|
16518
|
-
return sourceString;
|
|
16519
|
-
},
|
|
16520
16633
|
renderMappings: function() {
|
|
16521
|
-
|
|
16522
|
-
|
|
16523
|
-
lastSourceColumn = 0;
|
|
16634
|
+
let lastSourceLine = 0;
|
|
16635
|
+
let lastSourceColumn = 0;
|
|
16524
16636
|
return sm.lines.map(function(line) {
|
|
16525
16637
|
return line.map(function(entry) {
|
|
16526
|
-
var colDelta, sourceFileIndex, srcLine, srcCol, lineDelta;
|
|
16527
16638
|
if (entry.length === 4) {
|
|
16528
|
-
[colDelta, sourceFileIndex, srcLine, srcCol] = entry;
|
|
16529
|
-
lineDelta = srcLine - lastSourceLine;
|
|
16639
|
+
let [colDelta, sourceFileIndex, srcLine, srcCol] = entry;
|
|
16640
|
+
const lineDelta = srcLine - lastSourceLine;
|
|
16530
16641
|
colDelta = srcCol - lastSourceColumn;
|
|
16531
16642
|
lastSourceLine = srcLine;
|
|
16532
16643
|
lastSourceColumn = srcCol;
|
|
@@ -16550,26 +16661,31 @@ var SourceMap = function(sourceString) {
|
|
|
16550
16661
|
}
|
|
16551
16662
|
};
|
|
16552
16663
|
},
|
|
16553
|
-
updateSourceMap: function(outputStr, inputPos) {
|
|
16554
|
-
|
|
16555
|
-
|
|
16664
|
+
updateSourceMap: function(outputStr, inputPos, colOffset = 0) {
|
|
16665
|
+
const outLines = outputStr.split(EOL2);
|
|
16666
|
+
let srcLine, srcCol;
|
|
16556
16667
|
if (inputPos != null) {
|
|
16557
16668
|
[srcLine, srcCol] = lookupLineColumn(srcTable, inputPos);
|
|
16669
|
+
srcCol += colOffset;
|
|
16670
|
+
sm.srcLine = srcLine;
|
|
16671
|
+
sm.srcColumn = srcCol;
|
|
16672
|
+
sm.srcOffset = inputPos + outputStr.length;
|
|
16558
16673
|
}
|
|
16559
16674
|
outLines.forEach(function(line, i) {
|
|
16560
|
-
var l;
|
|
16561
16675
|
if (i > 0) {
|
|
16562
|
-
sm.
|
|
16563
|
-
sm.
|
|
16564
|
-
sm.
|
|
16565
|
-
|
|
16676
|
+
sm.line++;
|
|
16677
|
+
sm.srcLine++;
|
|
16678
|
+
sm.column = 0;
|
|
16679
|
+
sm.lines[sm.line] = [];
|
|
16680
|
+
sm.srcColumn = srcCol = colOffset;
|
|
16566
16681
|
}
|
|
16567
|
-
l = sm.
|
|
16568
|
-
sm.
|
|
16682
|
+
const l = sm.column;
|
|
16683
|
+
sm.column += line.length;
|
|
16684
|
+
sm.srcColumn += line.length;
|
|
16569
16685
|
if (inputPos != null) {
|
|
16570
|
-
return sm.lines[sm.
|
|
16571
|
-
} else if (l
|
|
16572
|
-
return sm.lines[sm.
|
|
16686
|
+
return sm.lines[sm.line].push([l, 0, srcLine + i, srcCol]);
|
|
16687
|
+
} else if (l != 0) {
|
|
16688
|
+
return sm.lines[sm.line].push([l]);
|
|
16573
16689
|
}
|
|
16574
16690
|
;
|
|
16575
16691
|
return;
|
|
@@ -16578,74 +16694,36 @@ var SourceMap = function(sourceString) {
|
|
|
16578
16694
|
}
|
|
16579
16695
|
};
|
|
16580
16696
|
};
|
|
16581
|
-
|
|
16582
|
-
|
|
16583
|
-
|
|
16584
|
-
|
|
16585
|
-
|
|
16586
|
-
|
|
16587
|
-
if (line.length === 0) {
|
|
16588
|
-
return [];
|
|
16589
|
-
}
|
|
16590
|
-
return line.split(",").map(function(entry) {
|
|
16591
|
-
var result;
|
|
16592
|
-
result = decodeVLQ(entry);
|
|
16593
|
-
switch (result.length) {
|
|
16594
|
-
case 1: {
|
|
16595
|
-
return [result[0]];
|
|
16596
|
-
}
|
|
16597
|
-
case 4: {
|
|
16598
|
-
return [result[0], result[1], sourceLine += result[2], sourceColumn += result[3]];
|
|
16599
|
-
}
|
|
16600
|
-
case 5: {
|
|
16601
|
-
return [result[0], result[1], sourceLine += result[2], sourceColumn += result[3], result[4]];
|
|
16602
|
-
}
|
|
16603
|
-
default: {
|
|
16604
|
-
throw new Error("Unknown source map entry", result);
|
|
16605
|
-
}
|
|
16606
|
-
}
|
|
16607
|
-
});
|
|
16697
|
+
var smRegexp = /\n\/\/# sourceMappingURL=data:application\/json;charset=utf-8;base64,([+a-zA-Z0-9\/]*=?=?)$/;
|
|
16698
|
+
var remap = function(codeWithSourceMap, upstreamMap, sourcePath, targetPath) {
|
|
16699
|
+
let sourceMapText;
|
|
16700
|
+
const codeWithoutSourceMap = codeWithSourceMap.replace(smRegexp, (match, sm) => {
|
|
16701
|
+
sourceMapText = sm;
|
|
16702
|
+
return "";
|
|
16608
16703
|
});
|
|
16609
|
-
json.lines = lines;
|
|
16610
|
-
return json;
|
|
16611
|
-
};
|
|
16612
|
-
smRegexp = /\n\/\/# sourceMappingURL=data:application\/json;charset=utf-8;base64,([+a-zA-Z0-9\/]*=?=?)$/;
|
|
16613
|
-
SourceMap.remap = function(codeWithSourceMap, upstreamMap, sourcePath, targetPath) {
|
|
16614
|
-
var sourceMapText, codeWithoutSourceMap, remappedSourceMapJSON, newSourceMap, remappedCodeWithSourceMap, parsed, composedLines;
|
|
16615
|
-
sourceMapText = null;
|
|
16616
|
-
codeWithoutSourceMap = codeWithSourceMap.replace(
|
|
16617
|
-
smRegexp,
|
|
16618
|
-
(match, sm) => {
|
|
16619
|
-
sourceMapText = sm;
|
|
16620
|
-
return "";
|
|
16621
|
-
}
|
|
16622
|
-
);
|
|
16623
16704
|
if (sourceMapText) {
|
|
16624
|
-
parsed =
|
|
16625
|
-
composedLines =
|
|
16705
|
+
const parsed = parseWithLines(sourceMapText);
|
|
16706
|
+
const composedLines = composeLines(upstreamMap.data.lines, parsed.lines);
|
|
16626
16707
|
upstreamMap.data.lines = composedLines;
|
|
16627
16708
|
}
|
|
16628
|
-
remappedSourceMapJSON = upstreamMap.json(sourcePath, targetPath);
|
|
16629
|
-
newSourceMap = `${"sourceMapping"}URL=data:application/json;charset=utf-8;base64,${base64Encode(JSON.stringify(remappedSourceMapJSON))}`;
|
|
16630
|
-
remappedCodeWithSourceMap = `${codeWithoutSourceMap}
|
|
16709
|
+
const remappedSourceMapJSON = upstreamMap.json(sourcePath, targetPath);
|
|
16710
|
+
const newSourceMap = `${"sourceMapping"}URL=data:application/json;charset=utf-8;base64,${base64Encode(JSON.stringify(remappedSourceMapJSON))}`;
|
|
16711
|
+
const remappedCodeWithSourceMap = `${codeWithoutSourceMap}
|
|
16631
16712
|
//# ${newSourceMap}`;
|
|
16632
16713
|
return remappedCodeWithSourceMap;
|
|
16633
16714
|
};
|
|
16634
|
-
|
|
16635
|
-
return lines.map(function(line
|
|
16715
|
+
var composeLines = function(upstreamMapping, lines) {
|
|
16716
|
+
return lines.map(function(line) {
|
|
16636
16717
|
return line.map(function(entry) {
|
|
16637
|
-
var colDelta, sourceFileIndex, srcLine, srcCol, srcPos, upstreamLine, upstreamCol;
|
|
16638
16718
|
if (entry.length === 1) {
|
|
16639
16719
|
return entry;
|
|
16640
16720
|
}
|
|
16641
|
-
;
|
|
16642
|
-
|
|
16643
|
-
srcPos = remapPosition([srcLine, srcCol], upstreamMapping);
|
|
16721
|
+
const [colDelta, sourceFileIndex, srcLine, srcCol] = entry;
|
|
16722
|
+
const srcPos = remapPosition([srcLine, srcCol], upstreamMapping);
|
|
16644
16723
|
if (!srcPos) {
|
|
16645
16724
|
return [entry[0]];
|
|
16646
16725
|
}
|
|
16647
|
-
;
|
|
16648
|
-
[upstreamLine, upstreamCol] = srcPos;
|
|
16726
|
+
const [upstreamLine, upstreamCol] = srcPos;
|
|
16649
16727
|
if (entry.length === 4) {
|
|
16650
16728
|
return [colDelta, sourceFileIndex, upstreamLine, upstreamCol];
|
|
16651
16729
|
}
|
|
@@ -16653,44 +16731,50 @@ SourceMap.composeLines = function(upstreamMapping, lines) {
|
|
|
16653
16731
|
});
|
|
16654
16732
|
});
|
|
16655
16733
|
};
|
|
16656
|
-
|
|
16657
|
-
|
|
16658
|
-
|
|
16659
|
-
|
|
16660
|
-
|
|
16661
|
-
|
|
16662
|
-
|
|
16663
|
-
continue;
|
|
16664
|
-
}
|
|
16665
|
-
line = lines[i];
|
|
16666
|
-
lineNumStr = (i + 1).toString();
|
|
16667
|
-
while (lineNumStr.length < 4) {
|
|
16668
|
-
lineNumStr = " " + lineNumStr;
|
|
16669
|
-
}
|
|
16670
|
-
if (i === lineNum) {
|
|
16671
|
-
console.log(`${lineNumStr}: ${line}`);
|
|
16672
|
-
console.log(" ".repeat(lineNumStr.length + 2 + colNum) + "^".repeat(length));
|
|
16673
|
-
} else {
|
|
16674
|
-
console.log(`${lineNumStr}: ${line}`);
|
|
16734
|
+
var parseWithLines = function(base64encodedJSONstr) {
|
|
16735
|
+
const json = JSON.parse(Buffer.from(base64encodedJSONstr, "base64").toString("utf8"));
|
|
16736
|
+
let sourceLine = 0;
|
|
16737
|
+
let sourceColumn = 0;
|
|
16738
|
+
const lines = json.mappings.split(";").map(function(line) {
|
|
16739
|
+
if (line.length === 0) {
|
|
16740
|
+
return [];
|
|
16675
16741
|
}
|
|
16676
|
-
|
|
16677
|
-
|
|
16742
|
+
return line.split(",").map(function(entry) {
|
|
16743
|
+
const result = decodeVLQ(entry);
|
|
16744
|
+
switch (result.length) {
|
|
16745
|
+
case 1: {
|
|
16746
|
+
return [result[0]];
|
|
16747
|
+
}
|
|
16748
|
+
case 4: {
|
|
16749
|
+
return [result[0], result[1], sourceLine += result[2], sourceColumn += result[3]];
|
|
16750
|
+
}
|
|
16751
|
+
case 5: {
|
|
16752
|
+
return [result[0], result[1], sourceLine += result[2], sourceColumn += result[3], result[4]];
|
|
16753
|
+
}
|
|
16754
|
+
default: {
|
|
16755
|
+
throw new Error("Unknown source map entry", result);
|
|
16756
|
+
}
|
|
16757
|
+
}
|
|
16758
|
+
});
|
|
16759
|
+
});
|
|
16760
|
+
json.lines = lines;
|
|
16761
|
+
return json;
|
|
16678
16762
|
};
|
|
16679
|
-
|
|
16680
|
-
|
|
16681
|
-
|
|
16682
|
-
|
|
16683
|
-
|
|
16684
|
-
answer = "";
|
|
16763
|
+
Object.assign(SourceMap, { remap, parseWithLines, composeLines });
|
|
16764
|
+
var VLQ_SHIFT = 5;
|
|
16765
|
+
var VLQ_CONTINUATION_BIT = 1 << VLQ_SHIFT;
|
|
16766
|
+
var VLQ_VALUE_MASK = VLQ_CONTINUATION_BIT - 1;
|
|
16767
|
+
var encodeVlq = function(value) {
|
|
16768
|
+
let answer = "";
|
|
16685
16769
|
let ref;
|
|
16686
16770
|
if (value < 0)
|
|
16687
16771
|
ref = 1;
|
|
16688
16772
|
else
|
|
16689
16773
|
ref = 0;
|
|
16690
|
-
signBit = ref;
|
|
16691
|
-
valueToEncode = (Math.abs(value) << 1) + signBit;
|
|
16774
|
+
const signBit = ref;
|
|
16775
|
+
let valueToEncode = (Math.abs(value) << 1) + signBit;
|
|
16692
16776
|
while (valueToEncode || !answer) {
|
|
16693
|
-
nextChunk = valueToEncode & VLQ_VALUE_MASK;
|
|
16777
|
+
let nextChunk = valueToEncode & VLQ_VALUE_MASK;
|
|
16694
16778
|
valueToEncode = valueToEncode >> VLQ_SHIFT;
|
|
16695
16779
|
if (valueToEncode) {
|
|
16696
16780
|
nextChunk |= VLQ_CONTINUATION_BIT;
|
|
@@ -16699,21 +16783,20 @@ encodeVlq = function(value) {
|
|
|
16699
16783
|
}
|
|
16700
16784
|
return answer;
|
|
16701
16785
|
};
|
|
16702
|
-
BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
16703
|
-
encodeBase64 = function(value) {
|
|
16786
|
+
var BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
16787
|
+
var encodeBase64 = function(value) {
|
|
16704
16788
|
return BASE64_CHARS[value] || (() => {
|
|
16705
|
-
throw new Error(
|
|
16789
|
+
throw new Error("Cannot Base64 encode value: ${value}");
|
|
16706
16790
|
})();
|
|
16707
16791
|
};
|
|
16708
16792
|
var base64Encode = function(src) {
|
|
16709
16793
|
return Buffer.from(src).toString("base64");
|
|
16710
16794
|
};
|
|
16711
|
-
vlqTable = new Uint8Array(128);
|
|
16712
|
-
vlqChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
16795
|
+
var vlqTable = new Uint8Array(128);
|
|
16796
|
+
var vlqChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
16713
16797
|
(function() {
|
|
16714
|
-
|
|
16715
|
-
|
|
16716
|
-
l = vlqTable.length;
|
|
16798
|
+
let i = 0;
|
|
16799
|
+
let l = vlqTable.length;
|
|
16717
16800
|
while (i < l) {
|
|
16718
16801
|
vlqTable[i] = 255;
|
|
16719
16802
|
i++;
|
|
@@ -16728,28 +16811,28 @@ vlqChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
|
16728
16811
|
;
|
|
16729
16812
|
return results;
|
|
16730
16813
|
})();
|
|
16731
|
-
decodeError = function(message) {
|
|
16814
|
+
var decodeError = function(message) {
|
|
16732
16815
|
throw new Error(message);
|
|
16733
16816
|
};
|
|
16734
|
-
decodeVLQ = function(mapping) {
|
|
16735
|
-
|
|
16736
|
-
|
|
16737
|
-
|
|
16738
|
-
result = [];
|
|
16817
|
+
var decodeVLQ = function(mapping) {
|
|
16818
|
+
let i = 0;
|
|
16819
|
+
let l = mapping.length;
|
|
16820
|
+
let result = [];
|
|
16739
16821
|
while (i < l) {
|
|
16740
|
-
shift = 0;
|
|
16741
|
-
vlq = 0;
|
|
16822
|
+
let shift = 0;
|
|
16823
|
+
let vlq = 0;
|
|
16824
|
+
let v = 0;
|
|
16742
16825
|
while (true) {
|
|
16743
16826
|
if (i >= l) {
|
|
16744
16827
|
decodeError("Unexpected early end of mapping data");
|
|
16745
16828
|
}
|
|
16746
|
-
c = mapping.charCodeAt(i);
|
|
16747
|
-
if ((c & 127)
|
|
16748
|
-
decodeError(
|
|
16829
|
+
const c = mapping.charCodeAt(i);
|
|
16830
|
+
if ((c & 127) != c) {
|
|
16831
|
+
decodeError("Invalid mapping character: ${JSON.stringify(String.fromCharCode(c))}");
|
|
16749
16832
|
}
|
|
16750
|
-
index = vlqTable[c & 127];
|
|
16833
|
+
const index = vlqTable[c & 127];
|
|
16751
16834
|
if (index === 255) {
|
|
16752
|
-
decodeError(
|
|
16835
|
+
decodeError("Invalid mapping character: ${JSON.stringify(String.fromCharCode(c))}");
|
|
16753
16836
|
}
|
|
16754
16837
|
i++;
|
|
16755
16838
|
vlq |= (index & 31) << shift;
|
|
@@ -16767,20 +16850,19 @@ decodeVLQ = function(mapping) {
|
|
|
16767
16850
|
}
|
|
16768
16851
|
return result;
|
|
16769
16852
|
};
|
|
16770
|
-
remapPosition = function(position, sourcemapLines) {
|
|
16771
|
-
|
|
16772
|
-
|
|
16773
|
-
textLine = sourcemapLines[line];
|
|
16853
|
+
var remapPosition = function(position, sourcemapLines) {
|
|
16854
|
+
const [line, character] = position;
|
|
16855
|
+
const textLine = sourcemapLines[line];
|
|
16774
16856
|
if (!textLine?.length) {
|
|
16775
16857
|
return void 0;
|
|
16776
16858
|
}
|
|
16777
|
-
i = 0;
|
|
16778
|
-
p = 0;
|
|
16779
|
-
l = textLine.length;
|
|
16780
|
-
lastMapping = void 0;
|
|
16781
|
-
lastMappingPosition = 0;
|
|
16859
|
+
let i = 0;
|
|
16860
|
+
let p = 0;
|
|
16861
|
+
const l = textLine.length;
|
|
16862
|
+
let lastMapping = void 0;
|
|
16863
|
+
let lastMappingPosition = 0;
|
|
16782
16864
|
while (i < l) {
|
|
16783
|
-
mapping = textLine[i];
|
|
16865
|
+
const mapping = textLine[i];
|
|
16784
16866
|
p += mapping[0];
|
|
16785
16867
|
if (mapping.length === 4) {
|
|
16786
16868
|
lastMapping = mapping;
|
|
@@ -16791,7 +16873,7 @@ remapPosition = function(position, sourcemapLines) {
|
|
|
16791
16873
|
}
|
|
16792
16874
|
i++;
|
|
16793
16875
|
}
|
|
16794
|
-
if (character - lastMappingPosition
|
|
16876
|
+
if (character - lastMappingPosition != 0) {
|
|
16795
16877
|
return void 0;
|
|
16796
16878
|
}
|
|
16797
16879
|
if (lastMapping) {
|
|
@@ -16842,20 +16924,15 @@ var StateCache = class {
|
|
|
16842
16924
|
};
|
|
16843
16925
|
|
|
16844
16926
|
// source/main.civet
|
|
16845
|
-
var { SourceMap: SourceMap2 } =
|
|
16927
|
+
var { SourceMap: SourceMap2 } = sourcemap_exports;
|
|
16846
16928
|
var ParseErrors = class extends Error {
|
|
16847
16929
|
name = "ParseErrors";
|
|
16848
|
-
|
|
16849
|
-
|
|
16850
|
-
|
|
16851
|
-
|
|
16852
|
-
constructor(message, filename1, line1, column1, offset1) {
|
|
16853
|
-
super(message);
|
|
16854
|
-
this.filename = filename1;
|
|
16855
|
-
this.line = line1;
|
|
16856
|
-
this.column = column1;
|
|
16857
|
-
this.offset = offset1;
|
|
16930
|
+
errors;
|
|
16931
|
+
constructor(errors) {
|
|
16932
|
+
const message = errors.map(($) => $.message).join("\n");
|
|
16933
|
+
super(errors.map(($1) => $1.message).join("\n"));
|
|
16858
16934
|
this.message = message;
|
|
16935
|
+
this.errors = errors;
|
|
16859
16936
|
}
|
|
16860
16937
|
};
|
|
16861
16938
|
var uncacheable = /* @__PURE__ */ new Set([
|
|
@@ -16957,6 +17034,7 @@ ${counts}`;
|
|
|
16957
17034
|
});
|
|
16958
17035
|
}
|
|
16959
17036
|
}
|
|
17037
|
+
const throwOnErrors = options.errors == null;
|
|
16960
17038
|
function rest(ast2) {
|
|
16961
17039
|
options = options;
|
|
16962
17040
|
if (!(options.ast === "raw")) {
|
|
@@ -16966,28 +17044,36 @@ ${counts}`;
|
|
|
16966
17044
|
return ast2;
|
|
16967
17045
|
}
|
|
16968
17046
|
function checkErrors() {
|
|
17047
|
+
if (!throwOnErrors) {
|
|
17048
|
+
return;
|
|
17049
|
+
}
|
|
17050
|
+
options = options;
|
|
16969
17051
|
if (options.errors?.length) {
|
|
16970
|
-
throw new ParseErrors(options.errors
|
|
17052
|
+
throw new ParseErrors(options.errors);
|
|
16971
17053
|
}
|
|
16972
17054
|
;
|
|
16973
17055
|
return;
|
|
16974
17056
|
}
|
|
16975
17057
|
if (options.sourceMap || options.inlineMap) {
|
|
16976
|
-
|
|
16977
|
-
options.updateSourceMap = sm.updateSourceMap;
|
|
17058
|
+
options.sourceMap = SourceMap2(src);
|
|
16978
17059
|
const code = generate_default(ast2, options);
|
|
16979
17060
|
checkErrors();
|
|
16980
17061
|
if (options.inlineMap) {
|
|
16981
|
-
return SourceMap2.remap(code,
|
|
17062
|
+
return SourceMap2.remap(code, options.sourceMap, filename2, filename2 + ".tsx");
|
|
16982
17063
|
} else {
|
|
16983
17064
|
return {
|
|
16984
17065
|
code,
|
|
16985
|
-
sourceMap:
|
|
17066
|
+
sourceMap: options.sourceMap
|
|
16986
17067
|
};
|
|
16987
17068
|
}
|
|
16988
17069
|
}
|
|
16989
17070
|
const result = generate_default(ast2, options);
|
|
16990
|
-
|
|
17071
|
+
if (options.errors?.length) {
|
|
17072
|
+
delete options.errors;
|
|
17073
|
+
options.sourceMap = SourceMap2(src);
|
|
17074
|
+
generate_default(ast2, options);
|
|
17075
|
+
checkErrors();
|
|
17076
|
+
}
|
|
16991
17077
|
return result;
|
|
16992
17078
|
}
|
|
16993
17079
|
if (ast.then != null) {
|
|
@@ -17059,13 +17145,14 @@ var makeCache = function({ hits, trace } = {}) {
|
|
|
17059
17145
|
return events;
|
|
17060
17146
|
};
|
|
17061
17147
|
var isCompileError = function(err) {
|
|
17062
|
-
return err instanceof
|
|
17063
|
-
[err.message, err.name, err.filename, err.line, err.column, err.offset].every(($1) => $1 !== void 0);
|
|
17148
|
+
return err instanceof import_lib3.ParseError || err instanceof ParseErrors;
|
|
17064
17149
|
};
|
|
17065
|
-
var main_default = { parse, parseProgram, generate: generate_default,
|
|
17150
|
+
var main_default = { parse, parseProgram, ParseError: import_lib3.ParseError, ParseErrors, generate: generate_default, sourcemap: sourcemap_exports, SourceMap: SourceMap2, compile, isCompileError };
|
|
17066
17151
|
// Annotate the CommonJS export names for ESM import in node:
|
|
17067
17152
|
0 && (module.exports = {
|
|
17153
|
+
ParseError,
|
|
17068
17154
|
ParseErrors,
|
|
17155
|
+
SourceMap,
|
|
17069
17156
|
compile,
|
|
17070
17157
|
generate,
|
|
17071
17158
|
isCompileError,
|
|
@@ -17073,5 +17160,5 @@ var main_default = { parse, parseProgram, generate: generate_default, util: util
|
|
|
17073
17160
|
parse,
|
|
17074
17161
|
parseProgram,
|
|
17075
17162
|
prune,
|
|
17076
|
-
|
|
17163
|
+
sourcemap
|
|
17077
17164
|
});
|