@danielx/civet 0.7.3 → 0.7.4
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 +63 -43
- package/dist/main.js +63 -43
- package/dist/main.mjs +63 -43
- package/package.json +1 -1
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
|
+
// node_modules/@danielx/hera/dist/machine.js
|
|
42
42
|
var require_machine = __commonJS({
|
|
43
|
-
"
|
|
43
|
+
"node_modules/@danielx/hera/dist/machine.js"(exports, module) {
|
|
44
44
|
"use strict";
|
|
45
45
|
var __defProp2 = Object.defineProperty;
|
|
46
46
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -1320,8 +1320,8 @@ ${input.slice(result.pos)}
|
|
|
1320
1320
|
function replaceBlockExpression(node, child, replacement) {
|
|
1321
1321
|
let found = false;
|
|
1322
1322
|
const { expressions } = node;
|
|
1323
|
-
for (let
|
|
1324
|
-
const statement = expressions[
|
|
1323
|
+
for (let i1 = 0, len2 = expressions.length; i1 < len2; i1++) {
|
|
1324
|
+
const statement = expressions[i1];
|
|
1325
1325
|
const [, s] = statement;
|
|
1326
1326
|
if (s === child) {
|
|
1327
1327
|
statement[1] = replacement;
|
|
@@ -1382,9 +1382,9 @@ ${input.slice(result.pos)}
|
|
|
1382
1382
|
}
|
|
1383
1383
|
function insertSemicolon(statements) {
|
|
1384
1384
|
const l = statements.length;
|
|
1385
|
-
for (let
|
|
1386
|
-
const i =
|
|
1387
|
-
const s = statements[
|
|
1385
|
+
for (let i2 = 0, len1 = statements.length; i2 < len1; i2++) {
|
|
1386
|
+
const i = i2;
|
|
1387
|
+
const s = statements[i2];
|
|
1388
1388
|
if (i < l - 1) {
|
|
1389
1389
|
if (needsPrecedingSemicolon(statements[i + 1][1])) {
|
|
1390
1390
|
const delim = s[2];
|
|
@@ -1402,8 +1402,8 @@ ${input.slice(result.pos)}
|
|
|
1402
1402
|
return false;
|
|
1403
1403
|
}
|
|
1404
1404
|
if (Array.isArray(exp)) {
|
|
1405
|
-
for (let
|
|
1406
|
-
const child = exp[
|
|
1405
|
+
for (let i3 = 0, len2 = exp.length; i3 < len2; i3++) {
|
|
1406
|
+
const child = exp[i3];
|
|
1407
1407
|
if (!(child != null)) {
|
|
1408
1408
|
continue;
|
|
1409
1409
|
}
|
|
@@ -1464,9 +1464,12 @@ ${input.slice(result.pos)}
|
|
|
1464
1464
|
return;
|
|
1465
1465
|
}
|
|
1466
1466
|
node = node;
|
|
1467
|
-
|
|
1467
|
+
if (parent != null) {
|
|
1468
|
+
node.parent = parent;
|
|
1469
|
+
}
|
|
1468
1470
|
if (node.children) {
|
|
1469
|
-
for (
|
|
1471
|
+
for (let ref1 = node.children, i1 = 0, len2 = ref1.length; i1 < len2; i1++) {
|
|
1472
|
+
const child = ref1[i1];
|
|
1470
1473
|
addParentPointers(child, node);
|
|
1471
1474
|
}
|
|
1472
1475
|
}
|
|
@@ -1476,10 +1479,9 @@ ${input.slice(result.pos)}
|
|
|
1476
1479
|
return deepCopy(node);
|
|
1477
1480
|
}
|
|
1478
1481
|
function removeParentPointers(node) {
|
|
1479
|
-
if (node
|
|
1480
|
-
return;
|
|
1481
|
-
if (typeof node !== "object")
|
|
1482
|
+
if (!(node != null && typeof node === "object")) {
|
|
1482
1483
|
return;
|
|
1484
|
+
}
|
|
1483
1485
|
if (Array.isArray(node)) {
|
|
1484
1486
|
for (const child of node) {
|
|
1485
1487
|
removeParentPointers(child);
|
|
@@ -1523,7 +1525,8 @@ ${input.slice(result.pos)}
|
|
|
1523
1525
|
if (node?.type !== "BlockStatement")
|
|
1524
1526
|
return false;
|
|
1525
1527
|
const { bare, expressions } = node;
|
|
1526
|
-
return bare &&
|
|
1528
|
+
return bare && //expressions is like [], [, {type: "EmptyStatement"}]
|
|
1529
|
+
(expressions.length === 0 || expressions.length === 1 && expressions[0][1]?.type === "EmptyStatement");
|
|
1527
1530
|
}
|
|
1528
1531
|
function isFunction(node) {
|
|
1529
1532
|
const { type } = node;
|
|
@@ -1571,8 +1574,8 @@ ${input.slice(result.pos)}
|
|
|
1571
1574
|
if (!(node != null)) {
|
|
1572
1575
|
return false;
|
|
1573
1576
|
}
|
|
1574
|
-
let ref1;
|
|
1575
1577
|
let ref2;
|
|
1578
|
+
let ref3;
|
|
1576
1579
|
switch (node.type) {
|
|
1577
1580
|
case "ReturnStatement":
|
|
1578
1581
|
case "ThrowStatement":
|
|
@@ -1581,10 +1584,10 @@ ${input.slice(result.pos)}
|
|
|
1581
1584
|
return true;
|
|
1582
1585
|
}
|
|
1583
1586
|
case "IfStatement": {
|
|
1584
|
-
return isExit(node.then) && isExit((
|
|
1587
|
+
return isExit(node.then) && isExit((ref2 = node.else)?.[ref2.length - 1]);
|
|
1585
1588
|
}
|
|
1586
1589
|
case "BlockStatement": {
|
|
1587
|
-
return isExit((
|
|
1590
|
+
return isExit((ref3 = node.expressions)[ref3.length - 1]?.[1]);
|
|
1588
1591
|
}
|
|
1589
1592
|
case "IterationStatement": {
|
|
1590
1593
|
return node.condition?.type === "ParenthesizedExpression" && node.condition.expression?.type === "Literal" && node.condition.expression?.raw === "true" && gatherRecursiveWithinFunction(
|
|
@@ -1880,8 +1883,8 @@ ${input.slice(result.pos)}
|
|
|
1880
1883
|
return;
|
|
1881
1884
|
}
|
|
1882
1885
|
if (Array.isArray(node)) {
|
|
1883
|
-
for (let
|
|
1884
|
-
const child = node[
|
|
1886
|
+
for (let i2 = 0, len1 = node.length; i2 < len1; i2++) {
|
|
1887
|
+
const child = node[i2];
|
|
1885
1888
|
updateParentPointers(child, parent, depth);
|
|
1886
1889
|
}
|
|
1887
1890
|
return;
|
|
@@ -1891,8 +1894,8 @@ ${input.slice(result.pos)}
|
|
|
1891
1894
|
node.parent = parent;
|
|
1892
1895
|
}
|
|
1893
1896
|
if (depth && isParent(node)) {
|
|
1894
|
-
for (let
|
|
1895
|
-
const child =
|
|
1897
|
+
for (let ref4 = node.children, i3 = 0, len2 = ref4.length; i3 < len2; i3++) {
|
|
1898
|
+
const child = ref4[i3];
|
|
1896
1899
|
updateParentPointers(child, node, depth - 1);
|
|
1897
1900
|
}
|
|
1898
1901
|
}
|
|
@@ -2022,9 +2025,9 @@ ${input.slice(result.pos)}
|
|
|
2022
2025
|
}
|
|
2023
2026
|
function flatJoin(array, separator) {
|
|
2024
2027
|
const result = [];
|
|
2025
|
-
for (let
|
|
2026
|
-
const i =
|
|
2027
|
-
const items = array[
|
|
2028
|
+
for (let i4 = 0, len3 = array.length; i4 < len3; i4++) {
|
|
2029
|
+
const i = i4;
|
|
2030
|
+
const items = array[i4];
|
|
2028
2031
|
if (i) {
|
|
2029
2032
|
result.push(separator);
|
|
2030
2033
|
}
|
|
@@ -2075,8 +2078,9 @@ ${input.slice(result.pos)}
|
|
|
2075
2078
|
return { ancestor: void 0, child: node };
|
|
2076
2079
|
}
|
|
2077
2080
|
function gatherNodes(node, predicate) {
|
|
2078
|
-
if (node == null)
|
|
2081
|
+
if (node == null || typeof node === "string") {
|
|
2079
2082
|
return [];
|
|
2083
|
+
}
|
|
2080
2084
|
if (Array.isArray(node)) {
|
|
2081
2085
|
return node.flatMap((n) => gatherNodes(n, predicate));
|
|
2082
2086
|
}
|
|
@@ -2084,24 +2088,30 @@ ${input.slice(result.pos)}
|
|
|
2084
2088
|
return [node];
|
|
2085
2089
|
}
|
|
2086
2090
|
switch (node.type) {
|
|
2087
|
-
case "BlockStatement":
|
|
2091
|
+
case "BlockStatement": {
|
|
2088
2092
|
return [];
|
|
2089
|
-
|
|
2093
|
+
}
|
|
2094
|
+
case "ForStatement": {
|
|
2090
2095
|
const isDec = node.declaration?.type === "Declaration";
|
|
2091
2096
|
return node.children.flatMap((n) => {
|
|
2092
|
-
if (isDec && n === node.declaration)
|
|
2097
|
+
if (isDec && n === node.declaration) {
|
|
2093
2098
|
return [];
|
|
2094
|
-
|
|
2099
|
+
} else {
|
|
2100
|
+
return gatherNodes(n, predicate);
|
|
2101
|
+
}
|
|
2095
2102
|
});
|
|
2096
|
-
|
|
2103
|
+
}
|
|
2104
|
+
default: {
|
|
2097
2105
|
return gatherNodes(node.children, predicate);
|
|
2106
|
+
}
|
|
2098
2107
|
}
|
|
2099
2108
|
}
|
|
2100
2109
|
function gatherRecursive(node, predicate, skipPredicate) {
|
|
2101
|
-
if (node == null)
|
|
2110
|
+
if (node == null || typeof node === "string") {
|
|
2102
2111
|
return [];
|
|
2112
|
+
}
|
|
2103
2113
|
if (Array.isArray(node)) {
|
|
2104
|
-
return node.flatMap((
|
|
2114
|
+
return node.flatMap(($) => gatherRecursive($, predicate, skipPredicate));
|
|
2105
2115
|
}
|
|
2106
2116
|
if (skipPredicate?.(node))
|
|
2107
2117
|
return [];
|
|
@@ -2111,8 +2121,9 @@ ${input.slice(result.pos)}
|
|
|
2111
2121
|
return gatherRecursive(node.children, predicate, skipPredicate);
|
|
2112
2122
|
}
|
|
2113
2123
|
function gatherRecursiveAll(node, predicate) {
|
|
2114
|
-
if (node == null)
|
|
2124
|
+
if (node == null || typeof node === "string") {
|
|
2115
2125
|
return [];
|
|
2126
|
+
}
|
|
2116
2127
|
if (Array.isArray(node)) {
|
|
2117
2128
|
return node.flatMap((n) => gatherRecursiveAll(n, predicate));
|
|
2118
2129
|
}
|
|
@@ -3161,9 +3172,12 @@ ${input.slice(result.pos)}
|
|
|
3161
3172
|
rootCondition.blockPrefix = getPatternBlockPrefix(pattern, ref, decl, suffix);
|
|
3162
3173
|
}
|
|
3163
3174
|
function processDeclarationConditions(node) {
|
|
3164
|
-
gatherRecursiveAll(
|
|
3165
|
-
|
|
3166
|
-
|
|
3175
|
+
gatherRecursiveAll(
|
|
3176
|
+
node,
|
|
3177
|
+
(n) => {
|
|
3178
|
+
return n.type === "IfStatement" || n.type === "IterationStatement" || n.type === "SwitchStatement";
|
|
3179
|
+
}
|
|
3180
|
+
).forEach((s) => {
|
|
3167
3181
|
return processDeclarationConditionStatement(s);
|
|
3168
3182
|
});
|
|
3169
3183
|
}
|
|
@@ -7269,8 +7283,8 @@ ${input.slice(result.pos)}
|
|
|
7269
7283
|
function SingleLineBinaryOpRHS(ctx, state2) {
|
|
7270
7284
|
return (0, import_lib2.$EVENT)(ctx, state2, "SingleLineBinaryOpRHS", SingleLineBinaryOpRHS$0);
|
|
7271
7285
|
}
|
|
7272
|
-
var RHS$0 =
|
|
7273
|
-
var RHS$1 =
|
|
7286
|
+
var RHS$0 = ExpressionizedStatementWithTrailingCallExpressions;
|
|
7287
|
+
var RHS$1 = UnaryExpression;
|
|
7274
7288
|
var RHS$$ = [RHS$0, RHS$1];
|
|
7275
7289
|
function RHS(ctx, state2) {
|
|
7276
7290
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "RHS", RHS$$);
|
|
@@ -13526,7 +13540,7 @@ ${input.slice(result.pos)}
|
|
|
13526
13540
|
function Comma(ctx, state2) {
|
|
13527
13541
|
return (0, import_lib2.$EVENT)(ctx, state2, "Comma", Comma$0);
|
|
13528
13542
|
}
|
|
13529
|
-
var Comptime$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($L138, 'Comptime "comptime"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
|
|
13543
|
+
var Comptime$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($L138, 'Comptime "comptime"'), NonIdContinue, (0, import_lib2.$N)((0, import_lib2.$EXPECT)($L15, 'Comptime ":"'))), function($skip, $loc, $0, $1, $2, $3) {
|
|
13530
13544
|
return { $loc, token: $1 };
|
|
13531
13545
|
});
|
|
13532
13546
|
function Comptime(ctx, state2) {
|
|
@@ -16668,10 +16682,18 @@ ${counts}`;
|
|
|
16668
16682
|
if (options.ast) {
|
|
16669
16683
|
return ast;
|
|
16670
16684
|
}
|
|
16685
|
+
function checkErrors() {
|
|
16686
|
+
if (options.errors?.length) {
|
|
16687
|
+
throw new Error(`Parse errors: ${options.errors.map(($) => $.message).join("\n")} `);
|
|
16688
|
+
}
|
|
16689
|
+
;
|
|
16690
|
+
return;
|
|
16691
|
+
}
|
|
16671
16692
|
if (options.sourceMap || options.inlineMap) {
|
|
16672
16693
|
const sm = SourceMap2(src);
|
|
16673
16694
|
options.updateSourceMap = sm.updateSourceMap;
|
|
16674
16695
|
const code = generate_default(ast, options);
|
|
16696
|
+
checkErrors();
|
|
16675
16697
|
if (options.inlineMap) {
|
|
16676
16698
|
return SourceMap2.remap(code, sm, filename, filename + ".tsx");
|
|
16677
16699
|
} else {
|
|
@@ -16682,9 +16704,7 @@ ${counts}`;
|
|
|
16682
16704
|
}
|
|
16683
16705
|
}
|
|
16684
16706
|
const result = generate_default(ast, options);
|
|
16685
|
-
|
|
16686
|
-
throw new Error(`Parse errors: ${options.errors.map(($) => $.message).join("\n")} `);
|
|
16687
|
-
}
|
|
16707
|
+
checkErrors();
|
|
16688
16708
|
return result;
|
|
16689
16709
|
};
|
|
16690
16710
|
var makeCache = function({ hits, trace } = {}) {
|
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;
|
|
@@ -1313,8 +1313,8 @@ function makeBlockFragment() {
|
|
|
1313
1313
|
function replaceBlockExpression(node, child, replacement) {
|
|
1314
1314
|
let found = false;
|
|
1315
1315
|
const { expressions } = node;
|
|
1316
|
-
for (let
|
|
1317
|
-
const statement = expressions[
|
|
1316
|
+
for (let i1 = 0, len2 = expressions.length; i1 < len2; i1++) {
|
|
1317
|
+
const statement = expressions[i1];
|
|
1318
1318
|
const [, s] = statement;
|
|
1319
1319
|
if (s === child) {
|
|
1320
1320
|
statement[1] = replacement;
|
|
@@ -1375,9 +1375,9 @@ function processBlocks(statements) {
|
|
|
1375
1375
|
}
|
|
1376
1376
|
function insertSemicolon(statements) {
|
|
1377
1377
|
const l = statements.length;
|
|
1378
|
-
for (let
|
|
1379
|
-
const i =
|
|
1380
|
-
const s = statements[
|
|
1378
|
+
for (let i2 = 0, len1 = statements.length; i2 < len1; i2++) {
|
|
1379
|
+
const i = i2;
|
|
1380
|
+
const s = statements[i2];
|
|
1381
1381
|
if (i < l - 1) {
|
|
1382
1382
|
if (needsPrecedingSemicolon(statements[i + 1][1])) {
|
|
1383
1383
|
const delim = s[2];
|
|
@@ -1395,8 +1395,8 @@ function needsPrecedingSemicolon(exp) {
|
|
|
1395
1395
|
return false;
|
|
1396
1396
|
}
|
|
1397
1397
|
if (Array.isArray(exp)) {
|
|
1398
|
-
for (let
|
|
1399
|
-
const child = exp[
|
|
1398
|
+
for (let i3 = 0, len2 = exp.length; i3 < len2; i3++) {
|
|
1399
|
+
const child = exp[i3];
|
|
1400
1400
|
if (!(child != null)) {
|
|
1401
1401
|
continue;
|
|
1402
1402
|
}
|
|
@@ -1457,9 +1457,12 @@ function addParentPointers(node, parent) {
|
|
|
1457
1457
|
return;
|
|
1458
1458
|
}
|
|
1459
1459
|
node = node;
|
|
1460
|
-
|
|
1460
|
+
if (parent != null) {
|
|
1461
|
+
node.parent = parent;
|
|
1462
|
+
}
|
|
1461
1463
|
if (node.children) {
|
|
1462
|
-
for (
|
|
1464
|
+
for (let ref1 = node.children, i1 = 0, len2 = ref1.length; i1 < len2; i1++) {
|
|
1465
|
+
const child = ref1[i1];
|
|
1463
1466
|
addParentPointers(child, node);
|
|
1464
1467
|
}
|
|
1465
1468
|
}
|
|
@@ -1469,10 +1472,9 @@ function clone(node) {
|
|
|
1469
1472
|
return deepCopy(node);
|
|
1470
1473
|
}
|
|
1471
1474
|
function removeParentPointers(node) {
|
|
1472
|
-
if (node
|
|
1473
|
-
return;
|
|
1474
|
-
if (typeof node !== "object")
|
|
1475
|
+
if (!(node != null && typeof node === "object")) {
|
|
1475
1476
|
return;
|
|
1477
|
+
}
|
|
1476
1478
|
if (Array.isArray(node)) {
|
|
1477
1479
|
for (const child of node) {
|
|
1478
1480
|
removeParentPointers(child);
|
|
@@ -1516,7 +1518,8 @@ function isEmptyBareBlock(node) {
|
|
|
1516
1518
|
if (node?.type !== "BlockStatement")
|
|
1517
1519
|
return false;
|
|
1518
1520
|
const { bare, expressions } = node;
|
|
1519
|
-
return bare &&
|
|
1521
|
+
return bare && //expressions is like [], [, {type: "EmptyStatement"}]
|
|
1522
|
+
(expressions.length === 0 || expressions.length === 1 && expressions[0][1]?.type === "EmptyStatement");
|
|
1520
1523
|
}
|
|
1521
1524
|
function isFunction(node) {
|
|
1522
1525
|
const { type } = node;
|
|
@@ -1564,8 +1567,8 @@ function isExit(node) {
|
|
|
1564
1567
|
if (!(node != null)) {
|
|
1565
1568
|
return false;
|
|
1566
1569
|
}
|
|
1567
|
-
let ref1;
|
|
1568
1570
|
let ref2;
|
|
1571
|
+
let ref3;
|
|
1569
1572
|
switch (node.type) {
|
|
1570
1573
|
case "ReturnStatement":
|
|
1571
1574
|
case "ThrowStatement":
|
|
@@ -1574,10 +1577,10 @@ function isExit(node) {
|
|
|
1574
1577
|
return true;
|
|
1575
1578
|
}
|
|
1576
1579
|
case "IfStatement": {
|
|
1577
|
-
return isExit(node.then) && isExit((
|
|
1580
|
+
return isExit(node.then) && isExit((ref2 = node.else)?.[ref2.length - 1]);
|
|
1578
1581
|
}
|
|
1579
1582
|
case "BlockStatement": {
|
|
1580
|
-
return isExit((
|
|
1583
|
+
return isExit((ref3 = node.expressions)[ref3.length - 1]?.[1]);
|
|
1581
1584
|
}
|
|
1582
1585
|
case "IterationStatement": {
|
|
1583
1586
|
return node.condition?.type === "ParenthesizedExpression" && node.condition.expression?.type === "Literal" && node.condition.expression?.raw === "true" && gatherRecursiveWithinFunction(
|
|
@@ -1873,8 +1876,8 @@ function updateParentPointers(node, parent, depth = 1) {
|
|
|
1873
1876
|
return;
|
|
1874
1877
|
}
|
|
1875
1878
|
if (Array.isArray(node)) {
|
|
1876
|
-
for (let
|
|
1877
|
-
const child = node[
|
|
1879
|
+
for (let i2 = 0, len1 = node.length; i2 < len1; i2++) {
|
|
1880
|
+
const child = node[i2];
|
|
1878
1881
|
updateParentPointers(child, parent, depth);
|
|
1879
1882
|
}
|
|
1880
1883
|
return;
|
|
@@ -1884,8 +1887,8 @@ function updateParentPointers(node, parent, depth = 1) {
|
|
|
1884
1887
|
node.parent = parent;
|
|
1885
1888
|
}
|
|
1886
1889
|
if (depth && isParent(node)) {
|
|
1887
|
-
for (let
|
|
1888
|
-
const child =
|
|
1890
|
+
for (let ref4 = node.children, i3 = 0, len2 = ref4.length; i3 < len2; i3++) {
|
|
1891
|
+
const child = ref4[i3];
|
|
1889
1892
|
updateParentPointers(child, node, depth - 1);
|
|
1890
1893
|
}
|
|
1891
1894
|
}
|
|
@@ -2015,9 +2018,9 @@ function wrapWithReturn(expression) {
|
|
|
2015
2018
|
}
|
|
2016
2019
|
function flatJoin(array, separator) {
|
|
2017
2020
|
const result = [];
|
|
2018
|
-
for (let
|
|
2019
|
-
const i =
|
|
2020
|
-
const items = array[
|
|
2021
|
+
for (let i4 = 0, len3 = array.length; i4 < len3; i4++) {
|
|
2022
|
+
const i = i4;
|
|
2023
|
+
const items = array[i4];
|
|
2021
2024
|
if (i) {
|
|
2022
2025
|
result.push(separator);
|
|
2023
2026
|
}
|
|
@@ -2068,8 +2071,9 @@ function findAncestor(node, predicate, stopPredicate) {
|
|
|
2068
2071
|
return { ancestor: void 0, child: node };
|
|
2069
2072
|
}
|
|
2070
2073
|
function gatherNodes(node, predicate) {
|
|
2071
|
-
if (node == null)
|
|
2074
|
+
if (node == null || typeof node === "string") {
|
|
2072
2075
|
return [];
|
|
2076
|
+
}
|
|
2073
2077
|
if (Array.isArray(node)) {
|
|
2074
2078
|
return node.flatMap((n) => gatherNodes(n, predicate));
|
|
2075
2079
|
}
|
|
@@ -2077,24 +2081,30 @@ function gatherNodes(node, predicate) {
|
|
|
2077
2081
|
return [node];
|
|
2078
2082
|
}
|
|
2079
2083
|
switch (node.type) {
|
|
2080
|
-
case "BlockStatement":
|
|
2084
|
+
case "BlockStatement": {
|
|
2081
2085
|
return [];
|
|
2082
|
-
|
|
2086
|
+
}
|
|
2087
|
+
case "ForStatement": {
|
|
2083
2088
|
const isDec = node.declaration?.type === "Declaration";
|
|
2084
2089
|
return node.children.flatMap((n) => {
|
|
2085
|
-
if (isDec && n === node.declaration)
|
|
2090
|
+
if (isDec && n === node.declaration) {
|
|
2086
2091
|
return [];
|
|
2087
|
-
|
|
2092
|
+
} else {
|
|
2093
|
+
return gatherNodes(n, predicate);
|
|
2094
|
+
}
|
|
2088
2095
|
});
|
|
2089
|
-
|
|
2096
|
+
}
|
|
2097
|
+
default: {
|
|
2090
2098
|
return gatherNodes(node.children, predicate);
|
|
2099
|
+
}
|
|
2091
2100
|
}
|
|
2092
2101
|
}
|
|
2093
2102
|
function gatherRecursive(node, predicate, skipPredicate) {
|
|
2094
|
-
if (node == null)
|
|
2103
|
+
if (node == null || typeof node === "string") {
|
|
2095
2104
|
return [];
|
|
2105
|
+
}
|
|
2096
2106
|
if (Array.isArray(node)) {
|
|
2097
|
-
return node.flatMap((
|
|
2107
|
+
return node.flatMap(($) => gatherRecursive($, predicate, skipPredicate));
|
|
2098
2108
|
}
|
|
2099
2109
|
if (skipPredicate?.(node))
|
|
2100
2110
|
return [];
|
|
@@ -2104,8 +2114,9 @@ function gatherRecursive(node, predicate, skipPredicate) {
|
|
|
2104
2114
|
return gatherRecursive(node.children, predicate, skipPredicate);
|
|
2105
2115
|
}
|
|
2106
2116
|
function gatherRecursiveAll(node, predicate) {
|
|
2107
|
-
if (node == null)
|
|
2117
|
+
if (node == null || typeof node === "string") {
|
|
2108
2118
|
return [];
|
|
2119
|
+
}
|
|
2109
2120
|
if (Array.isArray(node)) {
|
|
2110
2121
|
return node.flatMap((n) => gatherRecursiveAll(n, predicate));
|
|
2111
2122
|
}
|
|
@@ -3154,9 +3165,12 @@ function processDeclarationCondition(condition, rootCondition, parent) {
|
|
|
3154
3165
|
rootCondition.blockPrefix = getPatternBlockPrefix(pattern, ref, decl, suffix);
|
|
3155
3166
|
}
|
|
3156
3167
|
function processDeclarationConditions(node) {
|
|
3157
|
-
gatherRecursiveAll(
|
|
3158
|
-
|
|
3159
|
-
|
|
3168
|
+
gatherRecursiveAll(
|
|
3169
|
+
node,
|
|
3170
|
+
(n) => {
|
|
3171
|
+
return n.type === "IfStatement" || n.type === "IterationStatement" || n.type === "SwitchStatement";
|
|
3172
|
+
}
|
|
3173
|
+
).forEach((s) => {
|
|
3160
3174
|
return processDeclarationConditionStatement(s);
|
|
3161
3175
|
});
|
|
3162
3176
|
}
|
|
@@ -7262,8 +7276,8 @@ var SingleLineBinaryOpRHS$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, impor
|
|
|
7262
7276
|
function SingleLineBinaryOpRHS(ctx, state2) {
|
|
7263
7277
|
return (0, import_lib2.$EVENT)(ctx, state2, "SingleLineBinaryOpRHS", SingleLineBinaryOpRHS$0);
|
|
7264
7278
|
}
|
|
7265
|
-
var RHS$0 =
|
|
7266
|
-
var RHS$1 =
|
|
7279
|
+
var RHS$0 = ExpressionizedStatementWithTrailingCallExpressions;
|
|
7280
|
+
var RHS$1 = UnaryExpression;
|
|
7267
7281
|
var RHS$$ = [RHS$0, RHS$1];
|
|
7268
7282
|
function RHS(ctx, state2) {
|
|
7269
7283
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "RHS", RHS$$);
|
|
@@ -13519,7 +13533,7 @@ var Comma$0 = (0, import_lib2.$TV)((0, import_lib2.$EXPECT)($L25, 'Comma ","'),
|
|
|
13519
13533
|
function Comma(ctx, state2) {
|
|
13520
13534
|
return (0, import_lib2.$EVENT)(ctx, state2, "Comma", Comma$0);
|
|
13521
13535
|
}
|
|
13522
|
-
var Comptime$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($L138, 'Comptime "comptime"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
|
|
13536
|
+
var Comptime$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($L138, 'Comptime "comptime"'), NonIdContinue, (0, import_lib2.$N)((0, import_lib2.$EXPECT)($L15, 'Comptime ":"'))), function($skip, $loc, $0, $1, $2, $3) {
|
|
13523
13537
|
return { $loc, token: $1 };
|
|
13524
13538
|
});
|
|
13525
13539
|
function Comptime(ctx, state2) {
|
|
@@ -16661,10 +16675,18 @@ ${counts}`;
|
|
|
16661
16675
|
if (options.ast) {
|
|
16662
16676
|
return ast;
|
|
16663
16677
|
}
|
|
16678
|
+
function checkErrors() {
|
|
16679
|
+
if (options.errors?.length) {
|
|
16680
|
+
throw new Error(`Parse errors: ${options.errors.map(($) => $.message).join("\n")} `);
|
|
16681
|
+
}
|
|
16682
|
+
;
|
|
16683
|
+
return;
|
|
16684
|
+
}
|
|
16664
16685
|
if (options.sourceMap || options.inlineMap) {
|
|
16665
16686
|
const sm = SourceMap2(src);
|
|
16666
16687
|
options.updateSourceMap = sm.updateSourceMap;
|
|
16667
16688
|
const code = generate_default(ast, options);
|
|
16689
|
+
checkErrors();
|
|
16668
16690
|
if (options.inlineMap) {
|
|
16669
16691
|
return SourceMap2.remap(code, sm, filename, filename + ".tsx");
|
|
16670
16692
|
} else {
|
|
@@ -16675,9 +16697,7 @@ ${counts}`;
|
|
|
16675
16697
|
}
|
|
16676
16698
|
}
|
|
16677
16699
|
const result = generate_default(ast, options);
|
|
16678
|
-
|
|
16679
|
-
throw new Error(`Parse errors: ${options.errors.map(($) => $.message).join("\n")} `);
|
|
16680
|
-
}
|
|
16700
|
+
checkErrors();
|
|
16681
16701
|
return result;
|
|
16682
16702
|
};
|
|
16683
16703
|
var makeCache = function({ hits, trace } = {}) {
|
package/dist/main.mjs
CHANGED
|
@@ -28,9 +28,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
mod
|
|
29
29
|
));
|
|
30
30
|
|
|
31
|
-
//
|
|
31
|
+
// node_modules/@danielx/hera/dist/machine.js
|
|
32
32
|
var require_machine = __commonJS({
|
|
33
|
-
"
|
|
33
|
+
"node_modules/@danielx/hera/dist/machine.js"(exports, module) {
|
|
34
34
|
"use strict";
|
|
35
35
|
var __defProp2 = Object.defineProperty;
|
|
36
36
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -1297,8 +1297,8 @@ function makeBlockFragment() {
|
|
|
1297
1297
|
function replaceBlockExpression(node, child, replacement) {
|
|
1298
1298
|
let found = false;
|
|
1299
1299
|
const { expressions } = node;
|
|
1300
|
-
for (let
|
|
1301
|
-
const statement = expressions[
|
|
1300
|
+
for (let i1 = 0, len2 = expressions.length; i1 < len2; i1++) {
|
|
1301
|
+
const statement = expressions[i1];
|
|
1302
1302
|
const [, s] = statement;
|
|
1303
1303
|
if (s === child) {
|
|
1304
1304
|
statement[1] = replacement;
|
|
@@ -1359,9 +1359,9 @@ function processBlocks(statements) {
|
|
|
1359
1359
|
}
|
|
1360
1360
|
function insertSemicolon(statements) {
|
|
1361
1361
|
const l = statements.length;
|
|
1362
|
-
for (let
|
|
1363
|
-
const i =
|
|
1364
|
-
const s = statements[
|
|
1362
|
+
for (let i2 = 0, len1 = statements.length; i2 < len1; i2++) {
|
|
1363
|
+
const i = i2;
|
|
1364
|
+
const s = statements[i2];
|
|
1365
1365
|
if (i < l - 1) {
|
|
1366
1366
|
if (needsPrecedingSemicolon(statements[i + 1][1])) {
|
|
1367
1367
|
const delim = s[2];
|
|
@@ -1379,8 +1379,8 @@ function needsPrecedingSemicolon(exp) {
|
|
|
1379
1379
|
return false;
|
|
1380
1380
|
}
|
|
1381
1381
|
if (Array.isArray(exp)) {
|
|
1382
|
-
for (let
|
|
1383
|
-
const child = exp[
|
|
1382
|
+
for (let i3 = 0, len2 = exp.length; i3 < len2; i3++) {
|
|
1383
|
+
const child = exp[i3];
|
|
1384
1384
|
if (!(child != null)) {
|
|
1385
1385
|
continue;
|
|
1386
1386
|
}
|
|
@@ -1441,9 +1441,12 @@ function addParentPointers(node, parent) {
|
|
|
1441
1441
|
return;
|
|
1442
1442
|
}
|
|
1443
1443
|
node = node;
|
|
1444
|
-
|
|
1444
|
+
if (parent != null) {
|
|
1445
|
+
node.parent = parent;
|
|
1446
|
+
}
|
|
1445
1447
|
if (node.children) {
|
|
1446
|
-
for (
|
|
1448
|
+
for (let ref1 = node.children, i1 = 0, len2 = ref1.length; i1 < len2; i1++) {
|
|
1449
|
+
const child = ref1[i1];
|
|
1447
1450
|
addParentPointers(child, node);
|
|
1448
1451
|
}
|
|
1449
1452
|
}
|
|
@@ -1453,10 +1456,9 @@ function clone(node) {
|
|
|
1453
1456
|
return deepCopy(node);
|
|
1454
1457
|
}
|
|
1455
1458
|
function removeParentPointers(node) {
|
|
1456
|
-
if (node
|
|
1457
|
-
return;
|
|
1458
|
-
if (typeof node !== "object")
|
|
1459
|
+
if (!(node != null && typeof node === "object")) {
|
|
1459
1460
|
return;
|
|
1461
|
+
}
|
|
1460
1462
|
if (Array.isArray(node)) {
|
|
1461
1463
|
for (const child of node) {
|
|
1462
1464
|
removeParentPointers(child);
|
|
@@ -1500,7 +1502,8 @@ function isEmptyBareBlock(node) {
|
|
|
1500
1502
|
if (node?.type !== "BlockStatement")
|
|
1501
1503
|
return false;
|
|
1502
1504
|
const { bare, expressions } = node;
|
|
1503
|
-
return bare &&
|
|
1505
|
+
return bare && //expressions is like [], [, {type: "EmptyStatement"}]
|
|
1506
|
+
(expressions.length === 0 || expressions.length === 1 && expressions[0][1]?.type === "EmptyStatement");
|
|
1504
1507
|
}
|
|
1505
1508
|
function isFunction(node) {
|
|
1506
1509
|
const { type } = node;
|
|
@@ -1548,8 +1551,8 @@ function isExit(node) {
|
|
|
1548
1551
|
if (!(node != null)) {
|
|
1549
1552
|
return false;
|
|
1550
1553
|
}
|
|
1551
|
-
let ref1;
|
|
1552
1554
|
let ref2;
|
|
1555
|
+
let ref3;
|
|
1553
1556
|
switch (node.type) {
|
|
1554
1557
|
case "ReturnStatement":
|
|
1555
1558
|
case "ThrowStatement":
|
|
@@ -1558,10 +1561,10 @@ function isExit(node) {
|
|
|
1558
1561
|
return true;
|
|
1559
1562
|
}
|
|
1560
1563
|
case "IfStatement": {
|
|
1561
|
-
return isExit(node.then) && isExit((
|
|
1564
|
+
return isExit(node.then) && isExit((ref2 = node.else)?.[ref2.length - 1]);
|
|
1562
1565
|
}
|
|
1563
1566
|
case "BlockStatement": {
|
|
1564
|
-
return isExit((
|
|
1567
|
+
return isExit((ref3 = node.expressions)[ref3.length - 1]?.[1]);
|
|
1565
1568
|
}
|
|
1566
1569
|
case "IterationStatement": {
|
|
1567
1570
|
return node.condition?.type === "ParenthesizedExpression" && node.condition.expression?.type === "Literal" && node.condition.expression?.raw === "true" && gatherRecursiveWithinFunction(
|
|
@@ -1857,8 +1860,8 @@ function updateParentPointers(node, parent, depth = 1) {
|
|
|
1857
1860
|
return;
|
|
1858
1861
|
}
|
|
1859
1862
|
if (Array.isArray(node)) {
|
|
1860
|
-
for (let
|
|
1861
|
-
const child = node[
|
|
1863
|
+
for (let i2 = 0, len1 = node.length; i2 < len1; i2++) {
|
|
1864
|
+
const child = node[i2];
|
|
1862
1865
|
updateParentPointers(child, parent, depth);
|
|
1863
1866
|
}
|
|
1864
1867
|
return;
|
|
@@ -1868,8 +1871,8 @@ function updateParentPointers(node, parent, depth = 1) {
|
|
|
1868
1871
|
node.parent = parent;
|
|
1869
1872
|
}
|
|
1870
1873
|
if (depth && isParent(node)) {
|
|
1871
|
-
for (let
|
|
1872
|
-
const child =
|
|
1874
|
+
for (let ref4 = node.children, i3 = 0, len2 = ref4.length; i3 < len2; i3++) {
|
|
1875
|
+
const child = ref4[i3];
|
|
1873
1876
|
updateParentPointers(child, node, depth - 1);
|
|
1874
1877
|
}
|
|
1875
1878
|
}
|
|
@@ -1999,9 +2002,9 @@ function wrapWithReturn(expression) {
|
|
|
1999
2002
|
}
|
|
2000
2003
|
function flatJoin(array, separator) {
|
|
2001
2004
|
const result = [];
|
|
2002
|
-
for (let
|
|
2003
|
-
const i =
|
|
2004
|
-
const items = array[
|
|
2005
|
+
for (let i4 = 0, len3 = array.length; i4 < len3; i4++) {
|
|
2006
|
+
const i = i4;
|
|
2007
|
+
const items = array[i4];
|
|
2005
2008
|
if (i) {
|
|
2006
2009
|
result.push(separator);
|
|
2007
2010
|
}
|
|
@@ -2052,8 +2055,9 @@ function findAncestor(node, predicate, stopPredicate) {
|
|
|
2052
2055
|
return { ancestor: void 0, child: node };
|
|
2053
2056
|
}
|
|
2054
2057
|
function gatherNodes(node, predicate) {
|
|
2055
|
-
if (node == null)
|
|
2058
|
+
if (node == null || typeof node === "string") {
|
|
2056
2059
|
return [];
|
|
2060
|
+
}
|
|
2057
2061
|
if (Array.isArray(node)) {
|
|
2058
2062
|
return node.flatMap((n) => gatherNodes(n, predicate));
|
|
2059
2063
|
}
|
|
@@ -2061,24 +2065,30 @@ function gatherNodes(node, predicate) {
|
|
|
2061
2065
|
return [node];
|
|
2062
2066
|
}
|
|
2063
2067
|
switch (node.type) {
|
|
2064
|
-
case "BlockStatement":
|
|
2068
|
+
case "BlockStatement": {
|
|
2065
2069
|
return [];
|
|
2066
|
-
|
|
2070
|
+
}
|
|
2071
|
+
case "ForStatement": {
|
|
2067
2072
|
const isDec = node.declaration?.type === "Declaration";
|
|
2068
2073
|
return node.children.flatMap((n) => {
|
|
2069
|
-
if (isDec && n === node.declaration)
|
|
2074
|
+
if (isDec && n === node.declaration) {
|
|
2070
2075
|
return [];
|
|
2071
|
-
|
|
2076
|
+
} else {
|
|
2077
|
+
return gatherNodes(n, predicate);
|
|
2078
|
+
}
|
|
2072
2079
|
});
|
|
2073
|
-
|
|
2080
|
+
}
|
|
2081
|
+
default: {
|
|
2074
2082
|
return gatherNodes(node.children, predicate);
|
|
2083
|
+
}
|
|
2075
2084
|
}
|
|
2076
2085
|
}
|
|
2077
2086
|
function gatherRecursive(node, predicate, skipPredicate) {
|
|
2078
|
-
if (node == null)
|
|
2087
|
+
if (node == null || typeof node === "string") {
|
|
2079
2088
|
return [];
|
|
2089
|
+
}
|
|
2080
2090
|
if (Array.isArray(node)) {
|
|
2081
|
-
return node.flatMap((
|
|
2091
|
+
return node.flatMap(($) => gatherRecursive($, predicate, skipPredicate));
|
|
2082
2092
|
}
|
|
2083
2093
|
if (skipPredicate?.(node))
|
|
2084
2094
|
return [];
|
|
@@ -2088,8 +2098,9 @@ function gatherRecursive(node, predicate, skipPredicate) {
|
|
|
2088
2098
|
return gatherRecursive(node.children, predicate, skipPredicate);
|
|
2089
2099
|
}
|
|
2090
2100
|
function gatherRecursiveAll(node, predicate) {
|
|
2091
|
-
if (node == null)
|
|
2101
|
+
if (node == null || typeof node === "string") {
|
|
2092
2102
|
return [];
|
|
2103
|
+
}
|
|
2093
2104
|
if (Array.isArray(node)) {
|
|
2094
2105
|
return node.flatMap((n) => gatherRecursiveAll(n, predicate));
|
|
2095
2106
|
}
|
|
@@ -3138,9 +3149,12 @@ function processDeclarationCondition(condition, rootCondition, parent) {
|
|
|
3138
3149
|
rootCondition.blockPrefix = getPatternBlockPrefix(pattern, ref, decl, suffix);
|
|
3139
3150
|
}
|
|
3140
3151
|
function processDeclarationConditions(node) {
|
|
3141
|
-
gatherRecursiveAll(
|
|
3142
|
-
|
|
3143
|
-
|
|
3152
|
+
gatherRecursiveAll(
|
|
3153
|
+
node,
|
|
3154
|
+
(n) => {
|
|
3155
|
+
return n.type === "IfStatement" || n.type === "IterationStatement" || n.type === "SwitchStatement";
|
|
3156
|
+
}
|
|
3157
|
+
).forEach((s) => {
|
|
3144
3158
|
return processDeclarationConditionStatement(s);
|
|
3145
3159
|
});
|
|
3146
3160
|
}
|
|
@@ -7246,8 +7260,8 @@ var SingleLineBinaryOpRHS$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, impor
|
|
|
7246
7260
|
function SingleLineBinaryOpRHS(ctx, state2) {
|
|
7247
7261
|
return (0, import_lib2.$EVENT)(ctx, state2, "SingleLineBinaryOpRHS", SingleLineBinaryOpRHS$0);
|
|
7248
7262
|
}
|
|
7249
|
-
var RHS$0 =
|
|
7250
|
-
var RHS$1 =
|
|
7263
|
+
var RHS$0 = ExpressionizedStatementWithTrailingCallExpressions;
|
|
7264
|
+
var RHS$1 = UnaryExpression;
|
|
7251
7265
|
var RHS$$ = [RHS$0, RHS$1];
|
|
7252
7266
|
function RHS(ctx, state2) {
|
|
7253
7267
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "RHS", RHS$$);
|
|
@@ -13503,7 +13517,7 @@ var Comma$0 = (0, import_lib2.$TV)((0, import_lib2.$EXPECT)($L25, 'Comma ","'),
|
|
|
13503
13517
|
function Comma(ctx, state2) {
|
|
13504
13518
|
return (0, import_lib2.$EVENT)(ctx, state2, "Comma", Comma$0);
|
|
13505
13519
|
}
|
|
13506
|
-
var Comptime$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($L138, 'Comptime "comptime"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
|
|
13520
|
+
var Comptime$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($L138, 'Comptime "comptime"'), NonIdContinue, (0, import_lib2.$N)((0, import_lib2.$EXPECT)($L15, 'Comptime ":"'))), function($skip, $loc, $0, $1, $2, $3) {
|
|
13507
13521
|
return { $loc, token: $1 };
|
|
13508
13522
|
});
|
|
13509
13523
|
function Comptime(ctx, state2) {
|
|
@@ -16645,10 +16659,18 @@ ${counts}`;
|
|
|
16645
16659
|
if (options.ast) {
|
|
16646
16660
|
return ast;
|
|
16647
16661
|
}
|
|
16662
|
+
function checkErrors() {
|
|
16663
|
+
if (options.errors?.length) {
|
|
16664
|
+
throw new Error(`Parse errors: ${options.errors.map(($) => $.message).join("\n")} `);
|
|
16665
|
+
}
|
|
16666
|
+
;
|
|
16667
|
+
return;
|
|
16668
|
+
}
|
|
16648
16669
|
if (options.sourceMap || options.inlineMap) {
|
|
16649
16670
|
const sm = SourceMap2(src);
|
|
16650
16671
|
options.updateSourceMap = sm.updateSourceMap;
|
|
16651
16672
|
const code = generate_default(ast, options);
|
|
16673
|
+
checkErrors();
|
|
16652
16674
|
if (options.inlineMap) {
|
|
16653
16675
|
return SourceMap2.remap(code, sm, filename, filename + ".tsx");
|
|
16654
16676
|
} else {
|
|
@@ -16659,9 +16681,7 @@ ${counts}`;
|
|
|
16659
16681
|
}
|
|
16660
16682
|
}
|
|
16661
16683
|
const result = generate_default(ast, options);
|
|
16662
|
-
|
|
16663
|
-
throw new Error(`Parse errors: ${options.errors.map(($) => $.message).join("\n")} `);
|
|
16664
|
-
}
|
|
16684
|
+
checkErrors();
|
|
16665
16685
|
return result;
|
|
16666
16686
|
};
|
|
16667
16687
|
var makeCache = function({ hits, trace } = {}) {
|