@danielx/civet 0.7.4 → 0.7.6
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/astro.js +6 -6
- package/dist/babel-plugin.mjs +4 -2
- package/dist/browser.js +335 -150
- package/dist/bun-civet.mjs +4 -4
- package/dist/civet +20 -12
- package/dist/config.js +4 -1
- package/dist/esbuild-plugin.js +1 -1
- package/dist/esbuild.js +6 -6
- package/dist/esm.mjs +1 -1
- package/dist/main.js +322 -150
- package/dist/main.mjs +320 -150
- package/dist/rollup.js +6 -6
- package/dist/types.d.ts +16 -5
- package/dist/unplugin-shared.mjs +6 -6
- package/dist/unplugin.js +6 -6
- package/dist/vite.js +6 -6
- package/dist/webpack.js +6 -6
- package/package.json +3 -3
package/dist/browser.js
CHANGED
|
@@ -38,9 +38,9 @@ var Civet = (() => {
|
|
|
38
38
|
));
|
|
39
39
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
40
40
|
|
|
41
|
-
//
|
|
41
|
+
// ../Hera/dist/machine.js
|
|
42
42
|
var require_machine = __commonJS({
|
|
43
|
-
"
|
|
43
|
+
"../Hera/dist/machine.js"(exports, module) {
|
|
44
44
|
"use strict";
|
|
45
45
|
var __defProp2 = Object.defineProperty;
|
|
46
46
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -426,14 +426,14 @@ var Civet = (() => {
|
|
|
426
426
|
}, [1, 1]);
|
|
427
427
|
return [line, column];
|
|
428
428
|
}
|
|
429
|
-
function validate(input, result, { filename }) {
|
|
429
|
+
function validate(input, result, { filename: filename2 }) {
|
|
430
430
|
if (result && result.pos === input.length)
|
|
431
431
|
return result.value;
|
|
432
432
|
const expectations = Array.from(new Set(failExpected.slice(0, failIndex)));
|
|
433
433
|
let l = location(input, maxFailPos), [line, column] = l;
|
|
434
434
|
if (result && result.pos > maxFailPos) {
|
|
435
435
|
l = location(input, result.pos);
|
|
436
|
-
throw new Error(`${
|
|
436
|
+
throw new Error(`${filename2}:${line}:${column} Unconsumed input at #{l}
|
|
437
437
|
|
|
438
438
|
${input.slice(result.pos)}
|
|
439
439
|
`);
|
|
@@ -445,11 +445,11 @@ ${input.slice(result.pos)}
|
|
|
445
445
|
hint = JSON.stringify(hint);
|
|
446
446
|
else
|
|
447
447
|
hint = "EOF";
|
|
448
|
-
const error = new ParseError(`${
|
|
448
|
+
const error = new ParseError(`${filename2}:${line}:${column} Failed to parse
|
|
449
449
|
Expected:
|
|
450
450
|
${expectations.join("\n ")}
|
|
451
451
|
Found: ${hint}
|
|
452
|
-
`, "ParseError",
|
|
452
|
+
`, "ParseError", filename2, line, column, maxFailPos);
|
|
453
453
|
throw error;
|
|
454
454
|
}
|
|
455
455
|
if (result) {
|
|
@@ -473,11 +473,11 @@ ${input.slice(result.pos)}
|
|
|
473
473
|
};
|
|
474
474
|
}
|
|
475
475
|
var ParseError = class extends Error {
|
|
476
|
-
constructor(message, name,
|
|
476
|
+
constructor(message, name, filename2, line, column, offset) {
|
|
477
477
|
super(message);
|
|
478
478
|
this.message = message;
|
|
479
479
|
this.name = name;
|
|
480
|
-
this.filename =
|
|
480
|
+
this.filename = filename2;
|
|
481
481
|
this.line = line;
|
|
482
482
|
this.column = column;
|
|
483
483
|
this.offset = offset;
|
|
@@ -489,12 +489,14 @@ ${input.slice(result.pos)}
|
|
|
489
489
|
// source/main.civet
|
|
490
490
|
var main_exports = {};
|
|
491
491
|
__export(main_exports, {
|
|
492
|
+
ParseErrors: () => ParseErrors,
|
|
492
493
|
compile: () => compile,
|
|
493
494
|
default: () => main_default,
|
|
494
495
|
generate: () => generate_default,
|
|
495
496
|
isCompileError: () => isCompileError,
|
|
496
497
|
lib: () => lib_exports,
|
|
497
498
|
parse: () => parse,
|
|
499
|
+
parseProgram: () => parseProgram,
|
|
498
500
|
prune: () => prune,
|
|
499
501
|
util: () => util_exports
|
|
500
502
|
});
|
|
@@ -554,6 +556,7 @@ ${input.slice(result.pos)}
|
|
|
554
556
|
processCoffeeInterpolation: () => processCoffeeInterpolation,
|
|
555
557
|
processForInOf: () => processForInOf,
|
|
556
558
|
processProgram: () => processProgram,
|
|
559
|
+
processProgramAsync: () => processProgramAsync,
|
|
557
560
|
processUnaryExpression: () => processUnaryExpression,
|
|
558
561
|
quoteString: () => quoteString,
|
|
559
562
|
reorderBindingRestProperty: () => reorderBindingRestProperty,
|
|
@@ -968,6 +971,9 @@ ${input.slice(result.pos)}
|
|
|
968
971
|
wrapIterationReturningResults(exp, outer, collect);
|
|
969
972
|
return;
|
|
970
973
|
case "BlockStatement":
|
|
974
|
+
if (node.expressions.some(isExit)) {
|
|
975
|
+
return;
|
|
976
|
+
}
|
|
971
977
|
assignResults(exp.expressions[exp.expressions.length - 1], collect);
|
|
972
978
|
return;
|
|
973
979
|
case "IfStatement":
|
|
@@ -1002,6 +1008,9 @@ ${input.slice(result.pos)}
|
|
|
1002
1008
|
switch (node.type) {
|
|
1003
1009
|
case "BlockStatement":
|
|
1004
1010
|
if (node.expressions.length) {
|
|
1011
|
+
if (node.expressions.some(([, exp2]) => isExit(exp2))) {
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
1005
1014
|
const last = node.expressions[node.expressions.length - 1];
|
|
1006
1015
|
insertReturn(last);
|
|
1007
1016
|
} else {
|
|
@@ -1176,14 +1185,12 @@ ${input.slice(result.pos)}
|
|
|
1176
1185
|
if (!prefix.length)
|
|
1177
1186
|
return;
|
|
1178
1187
|
if (isConstructor) {
|
|
1179
|
-
const superCalls = gatherNodes(
|
|
1180
|
-
|
|
1181
|
-
|
|
1188
|
+
const superCalls = gatherNodes(
|
|
1189
|
+
expressions,
|
|
1190
|
+
(a) => typeof a === "object" && a != null && "type" in a && a.type === "CallExpression" && "children" in a && Array.isArray(a.children) && a.children.length >= 1 && typeof a.children[0] === "object" && a.children[0] != null && "token" in a.children[0] && a.children[0].token === "super"
|
|
1191
|
+
);
|
|
1182
1192
|
if (superCalls.length) {
|
|
1183
|
-
const { child } = findAncestor(
|
|
1184
|
-
superCalls[0],
|
|
1185
|
-
(ancestor) => ancestor === block
|
|
1186
|
-
);
|
|
1193
|
+
const { child } = findAncestor(superCalls[0], (a1) => a1 === block);
|
|
1187
1194
|
const index = findChildIndex(expressions, child);
|
|
1188
1195
|
if (index < 0) {
|
|
1189
1196
|
throw new Error("Could not find super call within top-level expressions");
|
|
@@ -1249,12 +1256,6 @@ ${input.slice(result.pos)}
|
|
|
1249
1256
|
// source/parser/block.civet
|
|
1250
1257
|
function blockWithPrefix(prefixStatements, block) {
|
|
1251
1258
|
if (prefixStatements && prefixStatements.length) {
|
|
1252
|
-
const indent = getIndent(block.expressions[0]);
|
|
1253
|
-
if (indent) {
|
|
1254
|
-
prefixStatements = prefixStatements.map((statement) => {
|
|
1255
|
-
return [indent, ...statement.slice(1)];
|
|
1256
|
-
});
|
|
1257
|
-
}
|
|
1258
1259
|
const expressions = [...prefixStatements, ...block.expressions];
|
|
1259
1260
|
updateParentPointers(prefixStatements, block);
|
|
1260
1261
|
block = {
|
|
@@ -1268,7 +1269,7 @@ ${input.slice(result.pos)}
|
|
|
1268
1269
|
return block;
|
|
1269
1270
|
}
|
|
1270
1271
|
function braceBlock(block) {
|
|
1271
|
-
if (block.bare) {
|
|
1272
|
+
if (block.bare && !block.root) {
|
|
1272
1273
|
if (block.children === block.expressions) {
|
|
1273
1274
|
block.children = [block.expressions];
|
|
1274
1275
|
}
|
|
@@ -1320,7 +1321,7 @@ ${input.slice(result.pos)}
|
|
|
1320
1321
|
function replaceBlockExpression(node, child, replacement) {
|
|
1321
1322
|
let found = false;
|
|
1322
1323
|
const { expressions } = node;
|
|
1323
|
-
for (let i1 = 0,
|
|
1324
|
+
for (let i1 = 0, len3 = expressions.length; i1 < len3; i1++) {
|
|
1324
1325
|
const statement = expressions[i1];
|
|
1325
1326
|
const [, s] = statement;
|
|
1326
1327
|
if (s === child) {
|
|
@@ -1402,7 +1403,7 @@ ${input.slice(result.pos)}
|
|
|
1402
1403
|
return false;
|
|
1403
1404
|
}
|
|
1404
1405
|
if (Array.isArray(exp)) {
|
|
1405
|
-
for (let i3 = 0,
|
|
1406
|
+
for (let i3 = 0, len22 = exp.length; i3 < len22; i3++) {
|
|
1406
1407
|
const child = exp[i3];
|
|
1407
1408
|
if (!(child != null)) {
|
|
1408
1409
|
continue;
|
|
@@ -1445,6 +1446,9 @@ ${input.slice(result.pos)}
|
|
|
1445
1446
|
}
|
|
1446
1447
|
|
|
1447
1448
|
// source/parser/util.civet
|
|
1449
|
+
function len(arr, length) {
|
|
1450
|
+
return arr.length === length;
|
|
1451
|
+
}
|
|
1448
1452
|
var assert = {
|
|
1449
1453
|
equal(a, b, msg) {
|
|
1450
1454
|
if (a !== b) {
|
|
@@ -1468,7 +1472,7 @@ ${input.slice(result.pos)}
|
|
|
1468
1472
|
node.parent = parent;
|
|
1469
1473
|
}
|
|
1470
1474
|
if (node.children) {
|
|
1471
|
-
for (let ref1 = node.children, i1 = 0,
|
|
1475
|
+
for (let ref1 = node.children, i1 = 0, len1 = ref1.length; i1 < len1; i1++) {
|
|
1472
1476
|
const child = ref1[i1];
|
|
1473
1477
|
addParentPointers(child, node);
|
|
1474
1478
|
}
|
|
@@ -1525,8 +1529,7 @@ ${input.slice(result.pos)}
|
|
|
1525
1529
|
if (node?.type !== "BlockStatement")
|
|
1526
1530
|
return false;
|
|
1527
1531
|
const { bare, expressions } = node;
|
|
1528
|
-
return bare &&
|
|
1529
|
-
(expressions.length === 0 || expressions.length === 1 && expressions[0][1]?.type === "EmptyStatement");
|
|
1532
|
+
return bare && (Array.isArray(expressions) && len(expressions, 0) || Array.isArray(expressions) && len(expressions, 1) && Array.isArray(expressions[0]) && expressions[0].length >= 2 && typeof expressions[0][1] === "object" && expressions[0][1] != null && "type" in expressions[0][1] && expressions[0][1].type === "EmptyStatement");
|
|
1530
1533
|
}
|
|
1531
1534
|
function isFunction(node) {
|
|
1532
1535
|
const { type } = node;
|
|
@@ -1883,7 +1886,7 @@ ${input.slice(result.pos)}
|
|
|
1883
1886
|
return;
|
|
1884
1887
|
}
|
|
1885
1888
|
if (Array.isArray(node)) {
|
|
1886
|
-
for (let i2 = 0,
|
|
1889
|
+
for (let i2 = 0, len22 = node.length; i2 < len22; i2++) {
|
|
1887
1890
|
const child = node[i2];
|
|
1888
1891
|
updateParentPointers(child, parent, depth);
|
|
1889
1892
|
}
|
|
@@ -1894,7 +1897,7 @@ ${input.slice(result.pos)}
|
|
|
1894
1897
|
node.parent = parent;
|
|
1895
1898
|
}
|
|
1896
1899
|
if (depth && isParent(node)) {
|
|
1897
|
-
for (let ref4 = node.children, i3 = 0,
|
|
1900
|
+
for (let ref4 = node.children, i3 = 0, len3 = ref4.length; i3 < len3; i3++) {
|
|
1898
1901
|
const child = ref4[i3];
|
|
1899
1902
|
updateParentPointers(child, node, depth - 1);
|
|
1900
1903
|
}
|
|
@@ -2025,7 +2028,7 @@ ${input.slice(result.pos)}
|
|
|
2025
2028
|
}
|
|
2026
2029
|
function flatJoin(array, separator) {
|
|
2027
2030
|
const result = [];
|
|
2028
|
-
for (let i4 = 0,
|
|
2031
|
+
for (let i4 = 0, len4 = array.length; i4 < len4; i4++) {
|
|
2029
2032
|
const i = i4;
|
|
2030
2033
|
const items = array[i4];
|
|
2031
2034
|
if (i) {
|
|
@@ -2048,7 +2051,7 @@ ${input.slice(result.pos)}
|
|
|
2048
2051
|
if (!(children != null)) {
|
|
2049
2052
|
return -1;
|
|
2050
2053
|
}
|
|
2051
|
-
for (let i1 = 0,
|
|
2054
|
+
for (let i1 = 0, len3 = children.length; i1 < len3; i1++) {
|
|
2052
2055
|
const i = i1;
|
|
2053
2056
|
const c = children[i1];
|
|
2054
2057
|
if (c === child || Array.isArray(c) && arrayRecurse(c)) {
|
|
@@ -2163,7 +2166,7 @@ ${input.slice(result.pos)}
|
|
|
2163
2166
|
["**"]
|
|
2164
2167
|
];
|
|
2165
2168
|
var precedenceMap = /* @__PURE__ */ new Map();
|
|
2166
|
-
for (let i1 = 0,
|
|
2169
|
+
for (let i1 = 0, len3 = precedenceOrder.length; i1 < len3; i1++) {
|
|
2167
2170
|
const prec = i1;
|
|
2168
2171
|
const ops = precedenceOrder[i1];
|
|
2169
2172
|
for (let i2 = 0, len1 = ops.length; i2 < len1; i2++) {
|
|
@@ -2274,7 +2277,7 @@ ${input.slice(result.pos)}
|
|
|
2274
2277
|
} else {
|
|
2275
2278
|
b = recurse(b);
|
|
2276
2279
|
}
|
|
2277
|
-
if (op.token === "instanceof" && b.type === "Literal" && b.children
|
|
2280
|
+
if (op.token === "instanceof" && (typeof b === "object" && b != null && "type" in b && b.type === "Literal" && "children" in b && Array.isArray(b.children) && b.children.length >= 1 && typeof b.children[0] === "object" && b.children[0] != null && "type" in b.children[0] && b.children[0].type === "StringLiteral")) {
|
|
2278
2281
|
a = ["typeof ", makeLeftHandSideExpression(a)];
|
|
2279
2282
|
if (op.negated) {
|
|
2280
2283
|
op = { ...op, token: "!==", negated: false };
|
|
@@ -2379,7 +2382,7 @@ ${input.slice(result.pos)}
|
|
|
2379
2382
|
let start = 0;
|
|
2380
2383
|
const chains = [];
|
|
2381
2384
|
var i = 0;
|
|
2382
|
-
for (let i3 = 0,
|
|
2385
|
+
for (let i3 = 0, len22 = binops.length; i3 < len22; i3++) {
|
|
2383
2386
|
var i = i3;
|
|
2384
2387
|
var [, op] = binops[i3];
|
|
2385
2388
|
if (isRelationalOp(op)) {
|
|
@@ -2610,6 +2613,11 @@ ${input.slice(result.pos)}
|
|
|
2610
2613
|
declareHelper[base](ref);
|
|
2611
2614
|
return state.helperRefs[base] = ref;
|
|
2612
2615
|
}
|
|
2616
|
+
function extractPreludeFor(node) {
|
|
2617
|
+
let helpers = new Set(Object.values(state.helperRefs));
|
|
2618
|
+
helpers = new Set(gatherRecursive(node, helpers.has.bind(helpers)));
|
|
2619
|
+
return state.prelude.filter((s) => gatherRecursive(s, helpers.has.bind(helpers)).length);
|
|
2620
|
+
}
|
|
2613
2621
|
|
|
2614
2622
|
// source/parser/pattern-matching.civet
|
|
2615
2623
|
function processPatternTest(lhs, patterns) {
|
|
@@ -2989,7 +2997,7 @@ ${input.slice(result.pos)}
|
|
|
2989
2997
|
}
|
|
2990
2998
|
|
|
2991
2999
|
// source/parser/declaration.civet
|
|
2992
|
-
function
|
|
3000
|
+
function len2(arr, length) {
|
|
2993
3001
|
return arr.length === length;
|
|
2994
3002
|
}
|
|
2995
3003
|
function processAssignmentDeclaration(decl, pattern, suffix, ws, assign, e) {
|
|
@@ -3187,7 +3195,7 @@ ${input.slice(result.pos)}
|
|
|
3187
3195
|
return;
|
|
3188
3196
|
}
|
|
3189
3197
|
let { expression } = condition;
|
|
3190
|
-
if (typeof expression === "object" && expression != null && "type" in expression && expression.type === "UnaryExpression" && "children" in expression && Array.isArray(expression.children) &&
|
|
3198
|
+
if (typeof expression === "object" && expression != null && "type" in expression && expression.type === "UnaryExpression" && "children" in expression && Array.isArray(expression.children) && len2(expression.children, 2) && expression.children[0] === "!" && typeof expression.children[1] === "object" && expression.children[1] != null && "type" in expression.children[1] && expression.children[1].type === "ParenthesizedExpression" && "expression" in expression.children[1]) {
|
|
3191
3199
|
const { type: type1, children: [, { type: type2, expression: expression2 }] } = expression;
|
|
3192
3200
|
const type = [type1, type2];
|
|
3193
3201
|
expression = expression2;
|
|
@@ -3196,7 +3204,7 @@ ${input.slice(result.pos)}
|
|
|
3196
3204
|
const { ref, pattern } = expression;
|
|
3197
3205
|
if (pattern) {
|
|
3198
3206
|
const conditions = getPatternConditions(pattern, ref).filter((c) => {
|
|
3199
|
-
if (Array.isArray(c) &&
|
|
3207
|
+
if (Array.isArray(c) && len2(c, 2) && c[0] === ref && c[1] === " != null") {
|
|
3200
3208
|
const [,] = c;
|
|
3201
3209
|
return false;
|
|
3202
3210
|
} else {
|
|
@@ -4028,6 +4036,26 @@ ${input.slice(result.pos)}
|
|
|
4028
4036
|
scopes.pop();
|
|
4029
4037
|
}
|
|
4030
4038
|
|
|
4039
|
+
// source/browser.civet
|
|
4040
|
+
function dirname(path) {
|
|
4041
|
+
return path.replace(/[^]*\//, "");
|
|
4042
|
+
}
|
|
4043
|
+
function resolve(path) {
|
|
4044
|
+
return path;
|
|
4045
|
+
}
|
|
4046
|
+
function createRequire(path) {
|
|
4047
|
+
return (id) => {
|
|
4048
|
+
throw new ReferenceError(
|
|
4049
|
+
"Civet comptime does not support 'require' on this platform"
|
|
4050
|
+
);
|
|
4051
|
+
};
|
|
4052
|
+
}
|
|
4053
|
+
var browser_default = {
|
|
4054
|
+
dirname,
|
|
4055
|
+
resolve,
|
|
4056
|
+
createRequire
|
|
4057
|
+
};
|
|
4058
|
+
|
|
4031
4059
|
// source/generate.civet
|
|
4032
4060
|
function stringify(node) {
|
|
4033
4061
|
try {
|
|
@@ -4113,36 +4141,122 @@ ${input.slice(result.pos)}
|
|
|
4113
4141
|
if (!getInitialConfig()?.comptime) {
|
|
4114
4142
|
return;
|
|
4115
4143
|
}
|
|
4116
|
-
|
|
4144
|
+
const promises = runComptime(statements);
|
|
4145
|
+
if (getSync()) {
|
|
4146
|
+
return;
|
|
4147
|
+
} else {
|
|
4148
|
+
return (async () => {
|
|
4149
|
+
{
|
|
4150
|
+
await Promise.all(promises);
|
|
4151
|
+
}
|
|
4152
|
+
})();
|
|
4153
|
+
}
|
|
4154
|
+
}
|
|
4155
|
+
function runComptime(statements) {
|
|
4156
|
+
const sync2 = getSync();
|
|
4157
|
+
return gatherRecursive(
|
|
4117
4158
|
statements,
|
|
4118
4159
|
(node) => {
|
|
4119
4160
|
return node.type === "ComptimeStatement" || node.type === "ComptimeExpression";
|
|
4120
4161
|
}
|
|
4121
|
-
).
|
|
4122
|
-
|
|
4162
|
+
).map((exp) => {
|
|
4163
|
+
let content = exp.type === "ComptimeStatement" ? exp.block : exp.expression;
|
|
4164
|
+
content = [
|
|
4165
|
+
...extractPreludeFor(content),
|
|
4166
|
+
content
|
|
4167
|
+
];
|
|
4123
4168
|
const options = { js: true };
|
|
4124
|
-
|
|
4169
|
+
let js = generate_default(prune(content), options);
|
|
4170
|
+
js = `"use strict";${js}`;
|
|
4125
4171
|
if (options.errors != null) {
|
|
4126
4172
|
return;
|
|
4127
4173
|
}
|
|
4128
|
-
|
|
4174
|
+
let output, context;
|
|
4175
|
+
try {
|
|
4176
|
+
context = browser_default.createContext?.() ?? globalThis;
|
|
4177
|
+
const filename2 = context.__filename = resolve(getFilename() ?? "");
|
|
4178
|
+
context.__dirname = dirname(filename2);
|
|
4179
|
+
context.require = createRequire(filename2);
|
|
4180
|
+
if (browser_default.runInContext != null) {
|
|
4181
|
+
for (const global of [
|
|
4182
|
+
"RegExp",
|
|
4183
|
+
"Date",
|
|
4184
|
+
"Set",
|
|
4185
|
+
"Map",
|
|
4186
|
+
"URL",
|
|
4187
|
+
"Int8Array",
|
|
4188
|
+
"Uint8Array",
|
|
4189
|
+
"Int16Array",
|
|
4190
|
+
"Uint16Array",
|
|
4191
|
+
"Int32Array",
|
|
4192
|
+
"Uint32Array",
|
|
4193
|
+
"Float32Array",
|
|
4194
|
+
"Float64Array",
|
|
4195
|
+
"Uint8ClampedArray",
|
|
4196
|
+
"BigInt64Array",
|
|
4197
|
+
"BigUint64Array",
|
|
4198
|
+
"Buffer"
|
|
4199
|
+
]) {
|
|
4200
|
+
context[global] = globalThis[global];
|
|
4201
|
+
}
|
|
4202
|
+
context.Object2 = Object;
|
|
4203
|
+
output = browser_default.runInContext(js, context, {
|
|
4204
|
+
filename: filename2,
|
|
4205
|
+
importModuleDynamically: browser_default.constants?.USE_MAIN_CONTEXT_DEFAULT_LOADER
|
|
4206
|
+
});
|
|
4207
|
+
} else {
|
|
4208
|
+
output = eval?.(js);
|
|
4209
|
+
}
|
|
4210
|
+
} catch (e) {
|
|
4211
|
+
exp.children = [
|
|
4212
|
+
{
|
|
4213
|
+
type: "Error",
|
|
4214
|
+
message: `comptime block failed to execute: ${e}
|
|
4215
|
+
${js}`
|
|
4216
|
+
}
|
|
4217
|
+
];
|
|
4218
|
+
return;
|
|
4219
|
+
}
|
|
4220
|
+
let promise;
|
|
4129
4221
|
if (exp.type === "ComptimeExpression") {
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4222
|
+
const finish = () => {
|
|
4223
|
+
let string;
|
|
4224
|
+
try {
|
|
4225
|
+
if (browser_default.runInContext != null) {
|
|
4226
|
+
context.output = output;
|
|
4227
|
+
string = browser_default.runInContext(
|
|
4228
|
+
`${serialize(serialize)}serialize(output)`,
|
|
4229
|
+
context
|
|
4230
|
+
);
|
|
4231
|
+
} else {
|
|
4232
|
+
string = serialize(output);
|
|
4233
|
+
}
|
|
4234
|
+
} catch (e) {
|
|
4235
|
+
exp.children = [
|
|
4236
|
+
{
|
|
4237
|
+
type: "Error",
|
|
4238
|
+
message: `comptime result ${output} not serializable: ${e}`
|
|
4239
|
+
}
|
|
4240
|
+
];
|
|
4241
|
+
return;
|
|
4242
|
+
}
|
|
4243
|
+
return exp.children = [string];
|
|
4244
|
+
};
|
|
4245
|
+
if (sync2) {
|
|
4246
|
+
finish();
|
|
4247
|
+
} else {
|
|
4248
|
+
promise = (async () => {
|
|
4135
4249
|
{
|
|
4136
|
-
|
|
4137
|
-
|
|
4250
|
+
output = await output;
|
|
4251
|
+
return finish();
|
|
4138
4252
|
}
|
|
4139
|
-
|
|
4140
|
-
return;
|
|
4253
|
+
})();
|
|
4141
4254
|
}
|
|
4142
|
-
return exp.children = [string];
|
|
4143
4255
|
} else {
|
|
4144
|
-
|
|
4256
|
+
promise = output;
|
|
4257
|
+
exp.children = [];
|
|
4145
4258
|
}
|
|
4259
|
+
return promise;
|
|
4146
4260
|
});
|
|
4147
4261
|
}
|
|
4148
4262
|
function serialize(value) {
|
|
@@ -4243,14 +4357,11 @@ ${input.slice(result.pos)}
|
|
|
4243
4357
|
})().join(",") + "])";
|
|
4244
4358
|
break;
|
|
4245
4359
|
}
|
|
4246
|
-
case
|
|
4247
|
-
|
|
4248
|
-
break;
|
|
4249
|
-
}
|
|
4250
|
-
case Object.prototype: {
|
|
4360
|
+
case Object.prototype:
|
|
4361
|
+
case globalThis.Object2?.prototype: {
|
|
4251
4362
|
let objStr = "{";
|
|
4252
4363
|
let descStr = "";
|
|
4253
|
-
for (let ref2 = Object.getOwnPropertyNames(val).concat(Object.getOwnPropertySymbols(val)), i = 0,
|
|
4364
|
+
for (let ref2 = Object.getOwnPropertyNames(val).concat(Object.getOwnPropertySymbols(val)), i = 0, len3 = ref2.length; i < len3; i++) {
|
|
4254
4365
|
const prop = ref2[i];
|
|
4255
4366
|
const desc = Object.getOwnPropertyDescriptor(val, prop);
|
|
4256
4367
|
if (desc.enumerable && desc.configurable && desc.writable) {
|
|
@@ -4312,7 +4423,11 @@ ${input.slice(result.pos)}
|
|
|
4312
4423
|
break;
|
|
4313
4424
|
}
|
|
4314
4425
|
default: {
|
|
4315
|
-
|
|
4426
|
+
if (Array.isArray(val)) {
|
|
4427
|
+
ref1 = `[${val.map(recurse).join(",")}]`;
|
|
4428
|
+
} else {
|
|
4429
|
+
throw new TypeError(`cannot serialize object with prototype ${val.constructor?.name ?? Object.getPrototypeOf(val)}`);
|
|
4430
|
+
}
|
|
4316
4431
|
}
|
|
4317
4432
|
}
|
|
4318
4433
|
;
|
|
@@ -4339,7 +4454,7 @@ ${input.slice(result.pos)}
|
|
|
4339
4454
|
}
|
|
4340
4455
|
function reduceIndentLevel(str, dedent, tab) {
|
|
4341
4456
|
if (tab != null && tab != 1) {
|
|
4342
|
-
for (let i1 = 0,
|
|
4457
|
+
for (let i1 = 0, len3 = str.length; i1 < len3; i1++) {
|
|
4343
4458
|
const i = i1;
|
|
4344
4459
|
const char = str[i1];
|
|
4345
4460
|
if (!dedent) {
|
|
@@ -4421,7 +4536,7 @@ ${input.slice(result.pos)}
|
|
|
4421
4536
|
;
|
|
4422
4537
|
const dedent = ref1;
|
|
4423
4538
|
let results = [s];
|
|
4424
|
-
for (let i3 = 0,
|
|
4539
|
+
for (let i3 = 0, len22 = strWithSubstitutions.length; i3 < len22; i3++) {
|
|
4425
4540
|
const i = i3;
|
|
4426
4541
|
let part = strWithSubstitutions[i3];
|
|
4427
4542
|
if (part.token != null) {
|
|
@@ -4551,9 +4666,8 @@ ${input.slice(result.pos)}
|
|
|
4551
4666
|
return true;
|
|
4552
4667
|
}
|
|
4553
4668
|
function expressionizeBlock(blockOrExpression) {
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
const { expressions } = ref1;
|
|
4669
|
+
if (blockOrExpression && typeof blockOrExpression === "object" && "expressions" in blockOrExpression) {
|
|
4670
|
+
const { expressions } = blockOrExpression;
|
|
4557
4671
|
const l = expressions.length;
|
|
4558
4672
|
const results = [];
|
|
4559
4673
|
let i1 = 0;
|
|
@@ -4652,7 +4766,7 @@ ${input.slice(result.pos)}
|
|
|
4652
4766
|
}
|
|
4653
4767
|
function processCallMemberExpression(node) {
|
|
4654
4768
|
const { children } = node;
|
|
4655
|
-
if (children[0]
|
|
4769
|
+
if (Array.isArray(children) && children.length >= 2 && typeof children[0] === "object" && children[0] != null && "parenthesizedOp" in children[0] && typeof children[0].parenthesizedOp === "object" && children[0].parenthesizedOp != null && "token" in children[0].parenthesizedOp && typeof children[1] === "object" && children[1] != null && "type" in children[1] && children[1].type === "Call") {
|
|
4656
4770
|
const op = children[0].parenthesizedOp;
|
|
4657
4771
|
let call = children[1];
|
|
4658
4772
|
const args = [...call.args];
|
|
@@ -4699,11 +4813,23 @@ ${input.slice(result.pos)}
|
|
|
4699
4813
|
}
|
|
4700
4814
|
prefix = prefix.concat(glob.dot);
|
|
4701
4815
|
for (const part of glob.object.properties) {
|
|
4816
|
+
if (part.type === "Error") {
|
|
4817
|
+
parts.push(part);
|
|
4818
|
+
continue;
|
|
4819
|
+
}
|
|
4702
4820
|
if (part.type === "MethodDefinition") {
|
|
4703
|
-
|
|
4821
|
+
parts.push({
|
|
4822
|
+
type: "Error",
|
|
4823
|
+
message: "Glob pattern cannot have method definition"
|
|
4824
|
+
});
|
|
4825
|
+
continue;
|
|
4704
4826
|
}
|
|
4705
4827
|
if (part.value && !["CallExpression", "MemberExpression", "Identifier"].includes(part.value.type)) {
|
|
4706
|
-
|
|
4828
|
+
parts.push({
|
|
4829
|
+
type: "Error",
|
|
4830
|
+
message: `Glob pattern must have call or member expression value, found ${JSON.stringify(part.value)}`
|
|
4831
|
+
});
|
|
4832
|
+
continue;
|
|
4707
4833
|
}
|
|
4708
4834
|
let suppressPrefix = false;
|
|
4709
4835
|
let name = part.name;
|
|
@@ -4746,14 +4872,14 @@ ${input.slice(result.pos)}
|
|
|
4746
4872
|
});
|
|
4747
4873
|
}
|
|
4748
4874
|
}
|
|
4749
|
-
let
|
|
4875
|
+
let ref1;
|
|
4750
4876
|
let object = {
|
|
4751
4877
|
type: "ObjectExpression",
|
|
4752
4878
|
children: [
|
|
4753
4879
|
glob.object.children[0],
|
|
4754
4880
|
// {
|
|
4755
4881
|
...parts,
|
|
4756
|
-
(
|
|
4882
|
+
(ref1 = glob.object.children)[ref1.length - 1]
|
|
4757
4883
|
// whitespace and }
|
|
4758
4884
|
],
|
|
4759
4885
|
properties: parts,
|
|
@@ -4805,7 +4931,7 @@ ${input.slice(result.pos)}
|
|
|
4805
4931
|
throw new Error("replaceNode failed: node has no parent");
|
|
4806
4932
|
}
|
|
4807
4933
|
function recurse(children) {
|
|
4808
|
-
for (let i3 = 0,
|
|
4934
|
+
for (let i3 = 0, len22 = children.length; i3 < len22; i3++) {
|
|
4809
4935
|
const i = i3;
|
|
4810
4936
|
const child = children[i3];
|
|
4811
4937
|
if (child === node) {
|
|
@@ -4852,6 +4978,10 @@ ${input.slice(result.pos)}
|
|
|
4852
4978
|
}
|
|
4853
4979
|
let children, i;
|
|
4854
4980
|
do {
|
|
4981
|
+
if (!(exp.children != null)) {
|
|
4982
|
+
return;
|
|
4983
|
+
}
|
|
4984
|
+
;
|
|
4855
4985
|
({ children } = exp);
|
|
4856
4986
|
i = children.length - 1;
|
|
4857
4987
|
while (i >= 0 && (children[i].type === "Call" || children[i].type === "NonNullAssertion" || children[i].type === "Optional"))
|
|
@@ -4895,8 +5025,8 @@ ${input.slice(result.pos)}
|
|
|
4895
5025
|
return { type: "Error", message: "cannot use `type` in dynamic import" };
|
|
4896
5026
|
} else {
|
|
4897
5027
|
const { source, binding } = specifier;
|
|
4898
|
-
let
|
|
4899
|
-
const delim = (
|
|
5028
|
+
let ref2;
|
|
5029
|
+
const delim = (ref2 = specifier.children)[ref2.length - 1];
|
|
4900
5030
|
return {
|
|
4901
5031
|
type: pattern ? "BindingProperty" : "Property",
|
|
4902
5032
|
name: source,
|
|
@@ -4906,7 +5036,7 @@ ${input.slice(result.pos)}
|
|
|
4906
5036
|
};
|
|
4907
5037
|
}
|
|
4908
5038
|
});
|
|
4909
|
-
let
|
|
5039
|
+
let ref3;
|
|
4910
5040
|
return {
|
|
4911
5041
|
type: pattern ? "ObjectBindingPattern" : "ObjectExpression",
|
|
4912
5042
|
names: node.names,
|
|
@@ -4915,7 +5045,7 @@ ${input.slice(result.pos)}
|
|
|
4915
5045
|
node.children[0],
|
|
4916
5046
|
// {
|
|
4917
5047
|
properties,
|
|
4918
|
-
(
|
|
5048
|
+
(ref3 = node.children)[ref3.length - 1]
|
|
4919
5049
|
// }
|
|
4920
5050
|
]
|
|
4921
5051
|
};
|
|
@@ -5092,17 +5222,17 @@ ${input.slice(result.pos)}
|
|
|
5092
5222
|
statements,
|
|
5093
5223
|
(n) => n.type === "AssignmentExpression" && n.names === null,
|
|
5094
5224
|
(exp) => {
|
|
5095
|
-
let { lhs: $1, expression: $2 } = exp, tail = [], i = 0,
|
|
5225
|
+
let { lhs: $1, expression: $2 } = exp, tail = [], i = 0, len3 = $1.length;
|
|
5096
5226
|
let block;
|
|
5097
|
-
let
|
|
5098
|
-
if (exp.parent?.type === "BlockStatement" && !(
|
|
5227
|
+
let ref4;
|
|
5228
|
+
if (exp.parent?.type === "BlockStatement" && !(ref4 = $1[$1.length - 1])?.[ref4.length - 1]?.special) {
|
|
5099
5229
|
block = makeBlockFragment();
|
|
5100
|
-
let
|
|
5101
|
-
if (
|
|
5230
|
+
let ref5;
|
|
5231
|
+
if (ref5 = prependStatementExpressionBlock(
|
|
5102
5232
|
{ type: "Initializer", expression: $2, children: [void 0, void 0, $2] },
|
|
5103
5233
|
block
|
|
5104
5234
|
)) {
|
|
5105
|
-
const ref =
|
|
5235
|
+
const ref = ref5;
|
|
5106
5236
|
exp.children = exp.children.map(function(c) {
|
|
5107
5237
|
if (c === $2)
|
|
5108
5238
|
return ref;
|
|
@@ -5132,7 +5262,7 @@ ${input.slice(result.pos)}
|
|
|
5132
5262
|
}
|
|
5133
5263
|
}
|
|
5134
5264
|
let wrapped = false;
|
|
5135
|
-
while (i <
|
|
5265
|
+
while (i < len3) {
|
|
5136
5266
|
const lastAssignment = $1[i++];
|
|
5137
5267
|
const [, lhs, , op] = lastAssignment;
|
|
5138
5268
|
if (op.token !== "=")
|
|
@@ -5145,7 +5275,7 @@ ${input.slice(result.pos)}
|
|
|
5145
5275
|
}
|
|
5146
5276
|
}
|
|
5147
5277
|
}
|
|
5148
|
-
i =
|
|
5278
|
+
i = len3 - 1;
|
|
5149
5279
|
while (i >= 0) {
|
|
5150
5280
|
const lastAssignment = $1[i];
|
|
5151
5281
|
if (lastAssignment[3].token === "=") {
|
|
@@ -5181,14 +5311,14 @@ ${input.slice(result.pos)}
|
|
|
5181
5311
|
}
|
|
5182
5312
|
i--;
|
|
5183
5313
|
}
|
|
5184
|
-
i =
|
|
5314
|
+
i = len3 - 1;
|
|
5185
5315
|
const optionalChainRef = makeRef();
|
|
5186
5316
|
while (i >= 0) {
|
|
5187
5317
|
const assignment = $1[i];
|
|
5188
5318
|
const [ws1, lhs, ws2, op] = assignment;
|
|
5189
5319
|
if (lhs.type === "MemberExpression" || lhs.type === "CallExpression") {
|
|
5190
5320
|
const newMemberExp = unchainOptionalMemberExpression(lhs, optionalChainRef, (children) => {
|
|
5191
|
-
const assigns = $1.splice(i + 1,
|
|
5321
|
+
const assigns = $1.splice(i + 1, len3 - 1 - i);
|
|
5192
5322
|
$1.pop();
|
|
5193
5323
|
return [ws1, ...children, ws2, op, ...assigns, $2];
|
|
5194
5324
|
});
|
|
@@ -5270,9 +5400,9 @@ ${input.slice(result.pos)}
|
|
|
5270
5400
|
}
|
|
5271
5401
|
j++;
|
|
5272
5402
|
}
|
|
5273
|
-
let
|
|
5274
|
-
if (
|
|
5275
|
-
const l =
|
|
5403
|
+
let ref6;
|
|
5404
|
+
if (ref6 = conditions.length) {
|
|
5405
|
+
const l = ref6;
|
|
5276
5406
|
const cs = flatJoin(conditions, " && ");
|
|
5277
5407
|
return {
|
|
5278
5408
|
...exp,
|
|
@@ -5309,8 +5439,8 @@ ${input.slice(result.pos)}
|
|
|
5309
5439
|
return gatherRecursiveAll(node, (n) => n.type === "UnaryType").forEach((unary) => {
|
|
5310
5440
|
let last;
|
|
5311
5441
|
let count = 0;
|
|
5312
|
-
let
|
|
5313
|
-
while (unary.suffix.length && (
|
|
5442
|
+
let ref7;
|
|
5443
|
+
while (unary.suffix.length && (ref7 = unary.suffix)[ref7.length - 1]?.token === "?") {
|
|
5314
5444
|
last = unary.suffix.pop();
|
|
5315
5445
|
count++;
|
|
5316
5446
|
}
|
|
@@ -5344,11 +5474,11 @@ ${input.slice(result.pos)}
|
|
|
5344
5474
|
gatherRecursiveAll(statements, ($) => $.type === "StatementExpression").forEach((_exp) => {
|
|
5345
5475
|
const exp = _exp;
|
|
5346
5476
|
const { statement } = exp;
|
|
5347
|
-
let
|
|
5477
|
+
let ref8;
|
|
5348
5478
|
switch (statement.type) {
|
|
5349
5479
|
case "IfStatement": {
|
|
5350
|
-
if (
|
|
5351
|
-
const expression =
|
|
5480
|
+
if (ref8 = expressionizeIfStatement(statement)) {
|
|
5481
|
+
const expression = ref8;
|
|
5352
5482
|
return replaceNode(statement, expression, exp);
|
|
5353
5483
|
} else {
|
|
5354
5484
|
return replaceNode(statement, wrapIIFE([["", statement]]), exp);
|
|
@@ -5356,7 +5486,8 @@ ${input.slice(result.pos)}
|
|
|
5356
5486
|
}
|
|
5357
5487
|
case "IterationExpression": {
|
|
5358
5488
|
if (statement.subtype === "ComptimeStatement") {
|
|
5359
|
-
const
|
|
5489
|
+
const { expressions } = statement.statement.block;
|
|
5490
|
+
const expression = wrapIIFE(expressions, hasAwait(expressions));
|
|
5360
5491
|
return replaceNode(statement, makeNode({
|
|
5361
5492
|
type: "ComptimeExpression",
|
|
5362
5493
|
expression,
|
|
@@ -5434,7 +5565,13 @@ ${input.slice(result.pos)}
|
|
|
5434
5565
|
processBlocks(statements);
|
|
5435
5566
|
populateRefs(statements);
|
|
5436
5567
|
adjustAtBindings(statements);
|
|
5437
|
-
|
|
5568
|
+
if (getSync()) {
|
|
5569
|
+
processComptime(statements);
|
|
5570
|
+
}
|
|
5571
|
+
}
|
|
5572
|
+
async function processProgramAsync(root) {
|
|
5573
|
+
const { expressions: statements } = root;
|
|
5574
|
+
await processComptime(statements);
|
|
5438
5575
|
}
|
|
5439
5576
|
function populateRefs(statements) {
|
|
5440
5577
|
const refNodes = gatherRecursive(statements, ({ type }) => type === "Ref");
|
|
@@ -5558,8 +5695,8 @@ ${input.slice(result.pos)}
|
|
|
5558
5695
|
for (let i4 = 0, len3 = placeholders.length; i4 < len3; i4++) {
|
|
5559
5696
|
const placeholder = placeholders[i4];
|
|
5560
5697
|
typeSuffix ??= placeholder.typeSuffix;
|
|
5561
|
-
let
|
|
5562
|
-
replaceNode((
|
|
5698
|
+
let ref9;
|
|
5699
|
+
replaceNode((ref9 = placeholder.children)[ref9.length - 1], ref);
|
|
5563
5700
|
}
|
|
5564
5701
|
const { parent } = ancestor;
|
|
5565
5702
|
const body = maybeUnwrap(ancestor);
|
|
@@ -5590,9 +5727,9 @@ ${input.slice(result.pos)}
|
|
|
5590
5727
|
fnExp = makeLeftHandSideExpression(fnExp);
|
|
5591
5728
|
}
|
|
5592
5729
|
replaceNode(ancestor, fnExp, parent);
|
|
5593
|
-
let
|
|
5594
|
-
if (
|
|
5595
|
-
const ws =
|
|
5730
|
+
let ref10;
|
|
5731
|
+
if (ref10 = getTrimmingSpace(body)) {
|
|
5732
|
+
const ws = ref10;
|
|
5596
5733
|
inplaceInsertTrimmingSpace(body, "");
|
|
5597
5734
|
inplacePrepend(ws, fnExp);
|
|
5598
5735
|
}
|
|
@@ -5637,8 +5774,8 @@ ${input.slice(result.pos)}
|
|
|
5637
5774
|
}
|
|
5638
5775
|
];
|
|
5639
5776
|
}
|
|
5640
|
-
let
|
|
5641
|
-
if (Array.isArray(rest.delim) && (
|
|
5777
|
+
let ref11;
|
|
5778
|
+
if (Array.isArray(rest.delim) && (ref11 = rest.delim)[ref11.length - 1]?.token === ",") {
|
|
5642
5779
|
rest.delim = rest.delim.slice(0, -1);
|
|
5643
5780
|
rest.children = [...rest.children.slice(0, -1), rest.delim];
|
|
5644
5781
|
}
|
|
@@ -6836,15 +6973,20 @@ ${input.slice(result.pos)}
|
|
|
6836
6973
|
var $R93 = (0, import_lib2.$R)(new RegExp("\\r\\n|\\n|\\r|$", "suy"));
|
|
6837
6974
|
var $R94 = (0, import_lib2.$R)(new RegExp("[^]*", "suy"));
|
|
6838
6975
|
var Program$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Reset, Init, (0, import_lib2.$E)(EOS), TopLevelStatements, __), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
6976
|
+
var reset = $1;
|
|
6977
|
+
var init = $2;
|
|
6978
|
+
var ws1 = $3;
|
|
6839
6979
|
var statements = $4;
|
|
6840
|
-
|
|
6980
|
+
var ws2 = $5;
|
|
6981
|
+
const program = {
|
|
6841
6982
|
type: "BlockStatement",
|
|
6842
6983
|
expressions: statements,
|
|
6843
|
-
children: [statements],
|
|
6984
|
+
children: [reset, init, ws1, statements, ws2],
|
|
6844
6985
|
bare: true,
|
|
6845
6986
|
root: true
|
|
6846
|
-
}
|
|
6847
|
-
|
|
6987
|
+
};
|
|
6988
|
+
processProgram(program);
|
|
6989
|
+
return program;
|
|
6848
6990
|
});
|
|
6849
6991
|
function Program(ctx, state2) {
|
|
6850
6992
|
return (0, import_lib2.$EVENT)(ctx, state2, "Program", Program$0);
|
|
@@ -8442,11 +8584,11 @@ ${input.slice(result.pos)}
|
|
|
8442
8584
|
var dot = $1;
|
|
8443
8585
|
var neg = $2;
|
|
8444
8586
|
var num = $3;
|
|
8445
|
-
const
|
|
8587
|
+
const len3 = {
|
|
8446
8588
|
children: []
|
|
8447
8589
|
}, children = [
|
|
8448
8590
|
adjustIndexAccess(dot),
|
|
8449
|
-
|
|
8591
|
+
len3,
|
|
8450
8592
|
neg,
|
|
8451
8593
|
num,
|
|
8452
8594
|
"]"
|
|
@@ -8454,7 +8596,7 @@ ${input.slice(result.pos)}
|
|
|
8454
8596
|
return {
|
|
8455
8597
|
type: "NegativeIndex",
|
|
8456
8598
|
children,
|
|
8457
|
-
len:
|
|
8599
|
+
len: len3
|
|
8458
8600
|
};
|
|
8459
8601
|
});
|
|
8460
8602
|
var PropertyAccess$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(AccessStart, (0, import_lib2.$Q)(InlineComment), (0, import_lib2.$C)(IdentifierName, PrivateIdentifier, LengthShorthand)), function($skip, $loc, $0, $1, $2, $3) {
|
|
@@ -10944,6 +11086,7 @@ ${input.slice(result.pos)}
|
|
|
10944
11086
|
if (!state.operators.has(id.name))
|
|
10945
11087
|
return $skip;
|
|
10946
11088
|
return {
|
|
11089
|
+
token: id.name,
|
|
10947
11090
|
call: id,
|
|
10948
11091
|
special: true,
|
|
10949
11092
|
...state.operators.get(id.name)
|
|
@@ -10954,6 +11097,7 @@ ${input.slice(result.pos)}
|
|
|
10954
11097
|
if (!state.operators.has(id.name))
|
|
10955
11098
|
return $skip;
|
|
10956
11099
|
return {
|
|
11100
|
+
token: id.name,
|
|
10957
11101
|
call: id,
|
|
10958
11102
|
special: true,
|
|
10959
11103
|
negated: true,
|
|
@@ -16126,26 +16270,29 @@ ${input.slice(result.pos)}
|
|
|
16126
16270
|
const parser2 = options.startRule != null ? grammar[options.startRule] : Object.values(grammar)[0];
|
|
16127
16271
|
if (!parser2)
|
|
16128
16272
|
throw new Error(`Could not find rule with name '${options.startRule}'`);
|
|
16129
|
-
const
|
|
16273
|
+
const filename2 = options.filename || "<anonymous>";
|
|
16130
16274
|
reset();
|
|
16131
16275
|
Object.assign(ctx, { ...options.events, tokenize: options.tokenize });
|
|
16132
16276
|
return validate(input, parser2(ctx, {
|
|
16133
16277
|
input,
|
|
16134
16278
|
pos: 0
|
|
16135
16279
|
}), {
|
|
16136
|
-
filename
|
|
16280
|
+
filename: filename2
|
|
16137
16281
|
});
|
|
16138
16282
|
}
|
|
16139
16283
|
};
|
|
16140
16284
|
}();
|
|
16141
16285
|
var { parse } = parser;
|
|
16286
|
+
var filename;
|
|
16142
16287
|
var initialConfig;
|
|
16143
16288
|
var config;
|
|
16289
|
+
var sync;
|
|
16144
16290
|
var state = {};
|
|
16145
16291
|
var getState = () => state;
|
|
16146
16292
|
var getConfig = () => config;
|
|
16147
16293
|
var getInitialConfig = () => initialConfig;
|
|
16148
|
-
var
|
|
16294
|
+
var getFilename = () => filename;
|
|
16295
|
+
var getSync = () => sync;
|
|
16149
16296
|
Object.defineProperties(state, {
|
|
16150
16297
|
currentIndent: {
|
|
16151
16298
|
get() {
|
|
@@ -16190,6 +16337,21 @@ ${input.slice(result.pos)}
|
|
|
16190
16337
|
}
|
|
16191
16338
|
}
|
|
16192
16339
|
});
|
|
16340
|
+
function parseProgram(input, options) {
|
|
16341
|
+
filename = options?.filename;
|
|
16342
|
+
initialConfig = options?.parseOptions;
|
|
16343
|
+
sync = options?.sync;
|
|
16344
|
+
const root = parse(input, options);
|
|
16345
|
+
if (sync) {
|
|
16346
|
+
filename = initialConfig = sync = null;
|
|
16347
|
+
return root;
|
|
16348
|
+
} else {
|
|
16349
|
+
return processProgramAsync(root).then(() => {
|
|
16350
|
+
filename = initialConfig = sync = null;
|
|
16351
|
+
return root;
|
|
16352
|
+
});
|
|
16353
|
+
}
|
|
16354
|
+
}
|
|
16193
16355
|
|
|
16194
16356
|
// source/util.civet
|
|
16195
16357
|
var util_exports = {};
|
|
@@ -16577,6 +16739,21 @@ ${input.slice(result.pos)}
|
|
|
16577
16739
|
|
|
16578
16740
|
// source/main.civet
|
|
16579
16741
|
var { SourceMap: SourceMap2 } = util_exports;
|
|
16742
|
+
var ParseErrors = class extends Error {
|
|
16743
|
+
name = "ParseErrors";
|
|
16744
|
+
filename;
|
|
16745
|
+
line;
|
|
16746
|
+
column;
|
|
16747
|
+
offset;
|
|
16748
|
+
constructor(message, filename1, line1, column1, offset1) {
|
|
16749
|
+
super(message);
|
|
16750
|
+
this.filename = filename1;
|
|
16751
|
+
this.line = line1;
|
|
16752
|
+
this.column = column1;
|
|
16753
|
+
this.offset = offset1;
|
|
16754
|
+
this.message = message;
|
|
16755
|
+
}
|
|
16756
|
+
};
|
|
16580
16757
|
var uncacheable = /* @__PURE__ */ new Set([
|
|
16581
16758
|
// Meta
|
|
16582
16759
|
"DebugHere",
|
|
@@ -16616,15 +16793,15 @@ ${input.slice(result.pos)}
|
|
|
16616
16793
|
"RestoreTrailingMemberProperty",
|
|
16617
16794
|
"RestoreNewlineBinaryOp"
|
|
16618
16795
|
]);
|
|
16619
|
-
|
|
16796
|
+
function compile(src, options) {
|
|
16620
16797
|
if (!options) {
|
|
16621
16798
|
options = {};
|
|
16622
16799
|
} else {
|
|
16623
16800
|
options = { ...options };
|
|
16624
16801
|
}
|
|
16625
16802
|
options.parseOptions = { ...options.parseOptions };
|
|
16626
|
-
const
|
|
16627
|
-
if (
|
|
16803
|
+
const filename2 = options.filename || "unknown";
|
|
16804
|
+
if (filename2.endsWith(".coffee") && !/^(#![^\r\n]*(\r\n|\n|\r))?\s*['"]civet/.test(src)) {
|
|
16628
16805
|
options.parseOptions.coffeeCompat = true;
|
|
16629
16806
|
}
|
|
16630
16807
|
const { hits, trace, noCache } = options;
|
|
@@ -16636,21 +16813,18 @@ ${input.slice(result.pos)}
|
|
|
16636
16813
|
});
|
|
16637
16814
|
}
|
|
16638
16815
|
let ast;
|
|
16639
|
-
setInitialConfig(options.parseOptions);
|
|
16640
16816
|
try {
|
|
16641
|
-
ast =
|
|
16642
|
-
|
|
16817
|
+
ast = parseProgram(src, {
|
|
16818
|
+
parseOptions: options.parseOptions,
|
|
16819
|
+
sync: options.sync,
|
|
16820
|
+
filename: filename2,
|
|
16643
16821
|
events
|
|
16644
16822
|
});
|
|
16645
|
-
if (!(options.ast === "raw")) {
|
|
16646
|
-
ast = prune(ast);
|
|
16647
|
-
}
|
|
16648
16823
|
} finally {
|
|
16649
|
-
setInitialConfig(void 0);
|
|
16650
16824
|
if (hits || trace) {
|
|
16651
|
-
import("fs").then(function({ writeFileSync }) {
|
|
16825
|
+
import("node:fs").then(function({ writeFileSync }) {
|
|
16652
16826
|
let ref;
|
|
16653
|
-
if ((ref = events?.meta) && "logs" in ref) {
|
|
16827
|
+
if ((ref = events?.meta) && typeof ref === "object" && "logs" in ref) {
|
|
16654
16828
|
const { logs } = ref;
|
|
16655
16829
|
if (trace) {
|
|
16656
16830
|
writeFileSync(trace, logs.join("\n"));
|
|
@@ -16679,34 +16853,45 @@ ${counts}`;
|
|
|
16679
16853
|
});
|
|
16680
16854
|
}
|
|
16681
16855
|
}
|
|
16682
|
-
|
|
16683
|
-
|
|
16684
|
-
|
|
16685
|
-
|
|
16686
|
-
if (options.errors?.length) {
|
|
16687
|
-
throw new Error(`Parse errors: ${options.errors.map(($) => $.message).join("\n")} `);
|
|
16856
|
+
function rest(ast2) {
|
|
16857
|
+
options = options;
|
|
16858
|
+
if (!(options.ast === "raw")) {
|
|
16859
|
+
ast2 = prune(ast2);
|
|
16688
16860
|
}
|
|
16689
|
-
|
|
16690
|
-
|
|
16691
|
-
}
|
|
16692
|
-
if (options.sourceMap || options.inlineMap) {
|
|
16693
|
-
const sm = SourceMap2(src);
|
|
16694
|
-
options.updateSourceMap = sm.updateSourceMap;
|
|
16695
|
-
const code = generate_default(ast, options);
|
|
16696
|
-
checkErrors();
|
|
16697
|
-
if (options.inlineMap) {
|
|
16698
|
-
return SourceMap2.remap(code, sm, filename, filename + ".tsx");
|
|
16699
|
-
} else {
|
|
16700
|
-
return {
|
|
16701
|
-
code,
|
|
16702
|
-
sourceMap: sm
|
|
16703
|
-
};
|
|
16861
|
+
if (options.ast) {
|
|
16862
|
+
return ast2;
|
|
16704
16863
|
}
|
|
16864
|
+
function checkErrors() {
|
|
16865
|
+
if (options.errors?.length) {
|
|
16866
|
+
throw new ParseErrors(options.errors.map(($) => $.message).join("\n"));
|
|
16867
|
+
}
|
|
16868
|
+
;
|
|
16869
|
+
return;
|
|
16870
|
+
}
|
|
16871
|
+
if (options.sourceMap || options.inlineMap) {
|
|
16872
|
+
const sm = SourceMap2(src);
|
|
16873
|
+
options.updateSourceMap = sm.updateSourceMap;
|
|
16874
|
+
const code = generate_default(ast2, options);
|
|
16875
|
+
checkErrors();
|
|
16876
|
+
if (options.inlineMap) {
|
|
16877
|
+
return SourceMap2.remap(code, sm, filename2, filename2 + ".tsx");
|
|
16878
|
+
} else {
|
|
16879
|
+
return {
|
|
16880
|
+
code,
|
|
16881
|
+
sourceMap: sm
|
|
16882
|
+
};
|
|
16883
|
+
}
|
|
16884
|
+
}
|
|
16885
|
+
const result = generate_default(ast2, options);
|
|
16886
|
+
checkErrors();
|
|
16887
|
+
return result;
|
|
16705
16888
|
}
|
|
16706
|
-
|
|
16707
|
-
|
|
16708
|
-
|
|
16709
|
-
|
|
16889
|
+
if (ast.then != null) {
|
|
16890
|
+
return ast.then(rest);
|
|
16891
|
+
} else {
|
|
16892
|
+
return rest(ast);
|
|
16893
|
+
}
|
|
16894
|
+
}
|
|
16710
16895
|
var makeCache = function({ hits, trace } = {}) {
|
|
16711
16896
|
const meta = {};
|
|
16712
16897
|
let hitCount;
|
|
@@ -16773,6 +16958,6 @@ ${counts}`;
|
|
|
16773
16958
|
return err instanceof Error && //@ts-ignore
|
|
16774
16959
|
[err.message, err.name, err.filename, err.line, err.column, err.offset].every(($1) => $1 !== void 0);
|
|
16775
16960
|
};
|
|
16776
|
-
var main_default = { parse, generate: generate_default, util: util_exports, compile, isCompileError };
|
|
16961
|
+
var main_default = { parse, parseProgram, generate: generate_default, util: util_exports, compile, isCompileError };
|
|
16777
16962
|
return __toCommonJS(main_exports);
|
|
16778
16963
|
})();
|