@danielx/civet 0.9.2 → 0.9.3
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/CHANGELOG.md +7 -0
- package/dist/browser.js +329 -144
- package/dist/main.js +331 -86
- package/dist/main.mjs +331 -86
- package/dist/unplugin/unplugin.js +3 -13
- package/dist/unplugin/unplugin.mjs +3 -13
- package/package.json +2 -2
package/dist/browser.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var Civet = (() => {
|
|
3
2
|
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
@@ -401,37 +400,38 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
|
|
|
401
400
|
}
|
|
402
401
|
});
|
|
403
402
|
|
|
404
|
-
// source
|
|
405
|
-
var
|
|
406
|
-
__export(
|
|
403
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\browser.civet.jsx
|
|
404
|
+
var browser_civet_exports = {};
|
|
405
|
+
__export(browser_civet_exports, {
|
|
407
406
|
ParseError: () => import_lib2.ParseError,
|
|
408
407
|
ParseErrors: () => ParseErrors,
|
|
409
408
|
SourceMap: () => SourceMap2,
|
|
410
409
|
autoRunScripts: () => autoRunScripts,
|
|
411
410
|
compile: () => compile,
|
|
412
|
-
generate: () =>
|
|
411
|
+
generate: () => generate_civet_default,
|
|
413
412
|
isCompileError: () => isCompileError,
|
|
414
|
-
lib: () =>
|
|
413
|
+
lib: () => lib_civet_exports,
|
|
415
414
|
parse: () => parse,
|
|
416
415
|
parseProgram: () => parseProgram,
|
|
417
416
|
prune: () => prune,
|
|
418
417
|
runScript: () => runScript,
|
|
419
418
|
runScripts: () => runScripts,
|
|
420
|
-
sourcemap: () =>
|
|
419
|
+
sourcemap: () => sourcemap_civet_exports
|
|
421
420
|
});
|
|
422
421
|
|
|
423
422
|
// source/parser.hera
|
|
424
423
|
var import_lib2 = __toESM(require_machine());
|
|
425
424
|
|
|
426
|
-
// source
|
|
427
|
-
var
|
|
428
|
-
__export(
|
|
425
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\lib.civet.jsx
|
|
426
|
+
var lib_civet_exports = {};
|
|
427
|
+
__export(lib_civet_exports, {
|
|
429
428
|
addPostfixStatement: () => addPostfixStatement,
|
|
430
429
|
adjustBindingElements: () => adjustBindingElements,
|
|
431
430
|
adjustIndexAccess: () => adjustIndexAccess,
|
|
432
431
|
append: () => append,
|
|
433
432
|
attachPostfixStatementAsExpression: () => attachPostfixStatementAsExpression,
|
|
434
433
|
blockWithPrefix: () => blockWithPrefix,
|
|
434
|
+
braceBlock: () => braceBlock,
|
|
435
435
|
convertNamedImportsToObject: () => convertNamedImportsToObject,
|
|
436
436
|
convertObjectToJSXAttributes: () => convertObjectToJSXAttributes,
|
|
437
437
|
convertWithClause: () => convertWithClause,
|
|
@@ -499,7 +499,7 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
|
|
|
499
499
|
wrapTypeInPromise: () => wrapTypeInPromise
|
|
500
500
|
});
|
|
501
501
|
|
|
502
|
-
// source
|
|
502
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\util.civet.jsx
|
|
503
503
|
function len(arr, length) {
|
|
504
504
|
return arr.length === length;
|
|
505
505
|
}
|
|
@@ -793,6 +793,49 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
|
|
|
793
793
|
throw new Error("Unrecognized literal " + JSON.stringify(literal));
|
|
794
794
|
}
|
|
795
795
|
}
|
|
796
|
+
function literalType(literal) {
|
|
797
|
+
let t;
|
|
798
|
+
switch (literal.type) {
|
|
799
|
+
case "RegularExpressionLiteral": {
|
|
800
|
+
t = "RegExp";
|
|
801
|
+
break;
|
|
802
|
+
}
|
|
803
|
+
case "TemplateLiteral": {
|
|
804
|
+
t = "string";
|
|
805
|
+
break;
|
|
806
|
+
}
|
|
807
|
+
case "Literal": {
|
|
808
|
+
switch (literal.subtype) {
|
|
809
|
+
case "NullLiteral": {
|
|
810
|
+
t = "null";
|
|
811
|
+
break;
|
|
812
|
+
}
|
|
813
|
+
case "BooleanLiteral": {
|
|
814
|
+
t = "boolean";
|
|
815
|
+
break;
|
|
816
|
+
}
|
|
817
|
+
case "NumericLiteral": {
|
|
818
|
+
literal.raw.endsWith("n") ? t = "bigint" : t = "number";
|
|
819
|
+
break;
|
|
820
|
+
}
|
|
821
|
+
case "StringLiteral": {
|
|
822
|
+
t = "string";
|
|
823
|
+
break;
|
|
824
|
+
}
|
|
825
|
+
default:
|
|
826
|
+
throw new Error(`unknown literal subtype ${literal.subtype}`);
|
|
827
|
+
}
|
|
828
|
+
break;
|
|
829
|
+
}
|
|
830
|
+
default:
|
|
831
|
+
throw new Error(`unknown literal type ${literal.type}`);
|
|
832
|
+
}
|
|
833
|
+
return {
|
|
834
|
+
type: "TypeLiteral",
|
|
835
|
+
t,
|
|
836
|
+
children: [t]
|
|
837
|
+
};
|
|
838
|
+
}
|
|
796
839
|
function makeNumericLiteral(n) {
|
|
797
840
|
let s = n.toString();
|
|
798
841
|
return {
|
|
@@ -1013,7 +1056,7 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
|
|
|
1013
1056
|
return target;
|
|
1014
1057
|
}
|
|
1015
1058
|
function spliceChild(node, child, del, ...replacements) {
|
|
1016
|
-
let children = node
|
|
1059
|
+
let children = Array.isArray(node) ? node : node.children;
|
|
1017
1060
|
if (!Array.isArray(children))
|
|
1018
1061
|
throw new Error("spliceChild: non-array node has no children field");
|
|
1019
1062
|
let index = children.indexOf(child);
|
|
@@ -1153,7 +1196,7 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
|
|
|
1153
1196
|
return result;
|
|
1154
1197
|
}
|
|
1155
1198
|
|
|
1156
|
-
// source
|
|
1199
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\traversal.civet.jsx
|
|
1157
1200
|
function gatherRecursiveWithinFunction(node, predicate) {
|
|
1158
1201
|
return gatherRecursive(node, predicate, isFunction);
|
|
1159
1202
|
}
|
|
@@ -1227,7 +1270,7 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
|
|
|
1227
1270
|
return predicate(node) && nodes.push(node), nodes;
|
|
1228
1271
|
}
|
|
1229
1272
|
|
|
1230
|
-
// source
|
|
1273
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\ref.civet.jsx
|
|
1231
1274
|
function makeRef(base = "ref", id = base) {
|
|
1232
1275
|
return {
|
|
1233
1276
|
type: "Ref",
|
|
@@ -1278,7 +1321,7 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
|
|
|
1278
1321
|
return ref === exp ? { ref, refAssignmentComma: [] } : { ref, ...makeRefAssignment(ref, exp) };
|
|
1279
1322
|
}
|
|
1280
1323
|
|
|
1281
|
-
// source
|
|
1324
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\binding.civet.jsx
|
|
1282
1325
|
function adjustAtBindings(statements, asThis = !1) {
|
|
1283
1326
|
for (let ref1 = gatherRecursiveAll(statements, ($) => $.type === "AtBindingProperty"), i1 = 0, len3 = ref1.length; i1 < len3; i1++) {
|
|
1284
1327
|
let binding = ref1[i1], { ref } = binding;
|
|
@@ -1342,13 +1385,30 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
|
|
|
1342
1385
|
function gatherBindingCode(statements, opts) {
|
|
1343
1386
|
let thisAssignments = [], splices = [];
|
|
1344
1387
|
function insertRestSplices(s, p, thisAssignments2) {
|
|
1345
|
-
|
|
1388
|
+
let m;
|
|
1389
|
+
for (let ref2 = gatherRecursiveAll(
|
|
1390
|
+
s,
|
|
1391
|
+
(n) => n.blockPrefix || opts?.injectParamProps && n.accessModifier || n.type === "AtBinding" || opts?.assignPins && (m = n.type, m === "PinPattern" || m === "PinProperty")
|
|
1392
|
+
), i3 = 0, len22 = ref2.length; i3 < len22; i3++) {
|
|
1346
1393
|
let n = ref2[i3];
|
|
1347
1394
|
if (n.type === "AtBinding") {
|
|
1348
1395
|
let { ref } = n, { id } = ref;
|
|
1349
1396
|
thisAssignments2.push([`this.${id} = `, ref]);
|
|
1350
1397
|
continue;
|
|
1351
1398
|
}
|
|
1399
|
+
if (opts?.assignPins && (n.type === "PinProperty" && (n.children = n.children.flatMap(($2) => $2 === n.name ? [n.name, ": ", n.value] : $2), updateParentPointers(n), n = n.value), n.type === "PinPattern")) {
|
|
1400
|
+
n.ref = makeRef(
|
|
1401
|
+
n.expression.type === "Identifier" ? n.expression.name : "pin"
|
|
1402
|
+
), n.children = [n.ref], updateParentPointers(n), thisAssignments2.push({
|
|
1403
|
+
type: "AssignmentExpression",
|
|
1404
|
+
children: [n.expression, " = ", n.ref],
|
|
1405
|
+
names: [],
|
|
1406
|
+
lhs: n.expression,
|
|
1407
|
+
assigned: n.expression,
|
|
1408
|
+
expression: n.ref
|
|
1409
|
+
});
|
|
1410
|
+
continue;
|
|
1411
|
+
}
|
|
1352
1412
|
if (opts?.injectParamProps && n.type === "Parameter" && n.accessModifier) {
|
|
1353
1413
|
for (let ref3 = n.names, i4 = 0, len3 = ref3.length; i4 < len3; i4++) {
|
|
1354
1414
|
let id = ref3[i4];
|
|
@@ -1440,12 +1500,12 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
|
|
|
1440
1500
|
return pattern;
|
|
1441
1501
|
}
|
|
1442
1502
|
|
|
1443
|
-
// source
|
|
1503
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\comptime.civet.jsx
|
|
1444
1504
|
init_browser_shim();
|
|
1445
1505
|
init_browser_shim();
|
|
1446
1506
|
init_browser_shim();
|
|
1447
1507
|
|
|
1448
|
-
// source
|
|
1508
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\helper.civet.jsx
|
|
1449
1509
|
var preludeVar = "var ";
|
|
1450
1510
|
function ts(children) {
|
|
1451
1511
|
return {
|
|
@@ -1698,7 +1758,7 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
|
|
|
1698
1758
|
return helpers = new Set(gatherRecursive(node, helpers.has.bind(helpers))), state.prelude.filter((s) => gatherRecursive(s, helpers.has.bind(helpers)).length);
|
|
1699
1759
|
}
|
|
1700
1760
|
|
|
1701
|
-
// source
|
|
1761
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\generate.civet.jsx
|
|
1702
1762
|
function stringify(node) {
|
|
1703
1763
|
try {
|
|
1704
1764
|
return JSON.stringify(removeParentPointers(node));
|
|
@@ -1755,7 +1815,7 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
|
|
|
1755
1815
|
throw new Error(`Unknown node ${stringify(node)}`);
|
|
1756
1816
|
}
|
|
1757
1817
|
}
|
|
1758
|
-
var
|
|
1818
|
+
var generate_civet_default = gen;
|
|
1759
1819
|
function prune(node) {
|
|
1760
1820
|
if (node != null && !(typeof node == "string" && node.length === 0)) {
|
|
1761
1821
|
if (node.parent != null && delete node.parent, Array.isArray(node)) {
|
|
@@ -1766,7 +1826,7 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
|
|
|
1766
1826
|
}
|
|
1767
1827
|
}
|
|
1768
1828
|
|
|
1769
|
-
// source
|
|
1829
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\comptime.civet.jsx
|
|
1770
1830
|
function expressionizeComptime(statement) {
|
|
1771
1831
|
let { expressions } = statement.block, expression = wrapIIFE(expressions, hasAwait(expressions));
|
|
1772
1832
|
return makeNode({
|
|
@@ -1795,7 +1855,7 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
|
|
|
1795
1855
|
...extractPreludeFor(content),
|
|
1796
1856
|
content
|
|
1797
1857
|
];
|
|
1798
|
-
let options = { js: !0 }, js =
|
|
1858
|
+
let options = { js: !0 }, js = generate_civet_default(prune(content), options);
|
|
1799
1859
|
if (js = `"use strict";${js}`, options.errors != null)
|
|
1800
1860
|
return;
|
|
1801
1861
|
let output, context, contextGlobal;
|
|
@@ -2000,7 +2060,7 @@ ${js}`
|
|
|
2000
2060
|
return recurse(value);
|
|
2001
2061
|
}
|
|
2002
2062
|
|
|
2003
|
-
// source
|
|
2063
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\function.civet.jsx
|
|
2004
2064
|
var concatAssign = (lhs, rhs) => (rhs?.[Symbol.isConcatSpreadable] ?? Array.isArray(rhs) ? lhs.push.apply(lhs, rhs) : lhs.push(rhs), lhs);
|
|
2005
2065
|
function getTypeArguments(args) {
|
|
2006
2066
|
for (; typeof args == "object" && args != null && "args" in args; )
|
|
@@ -2684,7 +2744,7 @@ ${js}`
|
|
|
2684
2744
|
names
|
|
2685
2745
|
});
|
|
2686
2746
|
if (rest.typeSuffix) {
|
|
2687
|
-
let
|
|
2747
|
+
let optionalType = function(typeSuffix3, fallback) {
|
|
2688
2748
|
let t2 = typeSuffix3?.t ?? fallback;
|
|
2689
2749
|
return typeSuffix3?.optional ? [
|
|
2690
2750
|
t2,
|
|
@@ -2693,9 +2753,7 @@ ${js}`
|
|
|
2693
2753
|
message: "Optional parameter not allowed in/after rest parameter"
|
|
2694
2754
|
}
|
|
2695
2755
|
] : t2;
|
|
2696
|
-
}
|
|
2697
|
-
var optionalType = optionalType2;
|
|
2698
|
-
let ref = makeRef("rest"), restRef = [
|
|
2756
|
+
}, ref = makeRef("rest"), restRef = [
|
|
2699
2757
|
{ children: [ref], ts: !0 },
|
|
2700
2758
|
{ children: [restIdentifier], js: !0 }
|
|
2701
2759
|
];
|
|
@@ -2715,10 +2773,10 @@ ${js}`
|
|
|
2715
2773
|
children: [ref],
|
|
2716
2774
|
ts: !0
|
|
2717
2775
|
});
|
|
2718
|
-
let oldSuffix = rest.typeSuffix, colon = oldSuffix.colon ?? ": ", afterTypes = after.flatMap((p) => [",",
|
|
2776
|
+
let oldSuffix = rest.typeSuffix, colon = oldSuffix.colon ?? ": ", afterTypes = after.flatMap((p) => [",", optionalType(p.typeSuffix, " unknown")]), t = [
|
|
2719
2777
|
"[",
|
|
2720
2778
|
"...",
|
|
2721
|
-
|
|
2779
|
+
optionalType(oldSuffix, "unknown[]"),
|
|
2722
2780
|
...afterTypes,
|
|
2723
2781
|
"]"
|
|
2724
2782
|
], typeSuffix2 = makeNode({
|
|
@@ -2751,17 +2809,18 @@ ${js}`
|
|
|
2751
2809
|
let indent;
|
|
2752
2810
|
expressions.length ? indent = expressions[0][0] : indent = "";
|
|
2753
2811
|
let [splices, thisAssignments] = gatherBindingCode(parameters, {
|
|
2754
|
-
injectParamProps: isConstructor
|
|
2812
|
+
injectParamProps: isConstructor,
|
|
2813
|
+
assignPins: !0
|
|
2755
2814
|
});
|
|
2756
2815
|
if (isConstructor) {
|
|
2757
2816
|
let { ancestor } = findAncestor(f, ($9) => $9.type === "ClassExpression");
|
|
2758
2817
|
if (ancestor != null) {
|
|
2759
|
-
let fields = new Set(gatherRecursiveWithinFunction(ancestor, ($10) => $10.type === "FieldDefinition").map(($11) => $11.id).filter((a3) => typeof a3 == "object" && a3 != null && "type" in a3 && a3.type === "Identifier").map(($12) => $12.name)), classExpressions = ancestor.body.expressions,
|
|
2760
|
-
assert.notEqual(
|
|
2818
|
+
let fields = new Set(gatherRecursiveWithinFunction(ancestor, ($10) => $10.type === "FieldDefinition").map(($11) => $11.id).filter((a3) => typeof a3 == "object" && a3 != null && "type" in a3 && a3.type === "Identifier").map(($12) => $12.name)), classExpressions = ancestor.body.expressions, index2 = findChildIndex(classExpressions, f);
|
|
2819
|
+
assert.notEqual(index2, -1, "Could not find constructor in class");
|
|
2761
2820
|
let m4;
|
|
2762
|
-
for (; m4 = classExpressions[
|
|
2763
|
-
|
|
2764
|
-
let fStatement = classExpressions[
|
|
2821
|
+
for (; m4 = classExpressions[index2 - 1]?.[1], typeof m4 == "object" && m4 != null && "type" in m4 && m4.type === "MethodDefinition" && "name" in m4 && m4.name === "constructor"; )
|
|
2822
|
+
index2--;
|
|
2823
|
+
let fStatement = classExpressions[index2];
|
|
2765
2824
|
for (let ref18 = gatherRecursive(parameters, ($13) => $13.type === "Parameter"), i9 = 0, len8 = ref18.length; i9 < len8; i9++) {
|
|
2766
2825
|
let parameter = ref18[i9], { accessModifier } = parameter;
|
|
2767
2826
|
if (accessModifier || parameter.typeSuffix)
|
|
@@ -2771,7 +2830,7 @@ ${js}`
|
|
|
2771
2830
|
continue;
|
|
2772
2831
|
parameter.accessModifier && (replaceNode(parameter.accessModifier, void 0), parameter.accessModifier = void 0);
|
|
2773
2832
|
let id = binding.ref.id;
|
|
2774
|
-
fields.has(id) || (classExpressions.splice(
|
|
2833
|
+
fields.has(id) || (classExpressions.splice(index2++, 0, [fStatement[0], {
|
|
2775
2834
|
type: "FieldDefinition",
|
|
2776
2835
|
id,
|
|
2777
2836
|
typeSuffix,
|
|
@@ -2800,22 +2859,23 @@ ${js}`
|
|
|
2800
2859
|
// TODO: figure out how to get JS only statement tuples
|
|
2801
2860
|
...s,
|
|
2802
2861
|
children: [indent, ...s.children, delimiter]
|
|
2803
|
-
})] : [indent, s, delimiter]),
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
}
|
|
2862
|
+
})] : [indent, s, delimiter]), !prefix.length)
|
|
2863
|
+
return;
|
|
2864
|
+
let index = -1;
|
|
2865
|
+
isConstructor && (index = findSuperCall(block)), expressions.splice(index + 1, 0, ...prefix), updateParentPointers(block), braceBlock(block);
|
|
2866
|
+
}
|
|
2867
|
+
function findSuperCall(block) {
|
|
2868
|
+
let { expressions } = block, superCalls = gatherNodes(
|
|
2869
|
+
expressions,
|
|
2870
|
+
(a4) => typeof a4 == "object" && a4 != null && "type" in a4 && a4.type === "CallExpression" && "children" in a4 && Array.isArray(a4.children) && a4.children.length >= 1 && typeof a4.children[0] == "object" && a4.children[0] != null && "token" in a4.children[0] && a4.children[0].token === "super"
|
|
2871
|
+
);
|
|
2872
|
+
if (superCalls.length) {
|
|
2873
|
+
let { child } = findAncestor(superCalls[0], (a5) => a5 === block), index = findChildIndex(expressions, child);
|
|
2874
|
+
if (index < 0)
|
|
2875
|
+
throw new Error("Could not find super call within top-level expressions");
|
|
2876
|
+
return index;
|
|
2877
|
+
} else
|
|
2878
|
+
return -1;
|
|
2819
2879
|
}
|
|
2820
2880
|
function processSignature(f) {
|
|
2821
2881
|
let { block, signature } = f;
|
|
@@ -2990,7 +3050,7 @@ ${js}`
|
|
|
2990
3050
|
).length > 1 && (fn.ampersandBlock = !1), fn;
|
|
2991
3051
|
}
|
|
2992
3052
|
|
|
2993
|
-
// source
|
|
3053
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\block.civet.jsx
|
|
2994
3054
|
function blockWithPrefix(prefixStatements, block) {
|
|
2995
3055
|
if (prefixStatements && prefixStatements.length) {
|
|
2996
3056
|
let expressions = [...prefixStatements, ...block.expressions];
|
|
@@ -3137,7 +3197,7 @@ ${js}`
|
|
|
3137
3197
|
};
|
|
3138
3198
|
}
|
|
3139
3199
|
|
|
3140
|
-
// source
|
|
3200
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\op.civet.jsx
|
|
3141
3201
|
var precedenceOrder = [
|
|
3142
3202
|
["||", "??"],
|
|
3143
3203
|
["^^"],
|
|
@@ -3188,7 +3248,7 @@ ${js}`
|
|
|
3188
3248
|
for (; i < expandedOps.length; ) {
|
|
3189
3249
|
let op = expandedOps[i];
|
|
3190
3250
|
if (op.special) {
|
|
3191
|
-
let
|
|
3251
|
+
let advanceLeft = function(allowEqual) {
|
|
3192
3252
|
for (; start >= 4; ) {
|
|
3193
3253
|
let prevPrec = getPrecedence(expandedOps[start - 2]);
|
|
3194
3254
|
if (!(prevPrec > prec || allowEqual && prevPrec === prec))
|
|
@@ -3196,7 +3256,7 @@ ${js}`
|
|
|
3196
3256
|
start -= 4;
|
|
3197
3257
|
}
|
|
3198
3258
|
return !1;
|
|
3199
|
-
},
|
|
3259
|
+
}, advanceRight = function(allowEqual) {
|
|
3200
3260
|
for (; end + 4 < expandedOps.length; ) {
|
|
3201
3261
|
let nextPrec = getPrecedence(expandedOps[end + 2]);
|
|
3202
3262
|
if (!(nextPrec > prec || allowEqual && nextPrec === prec))
|
|
@@ -3204,31 +3264,29 @@ ${js}`
|
|
|
3204
3264
|
end += 4;
|
|
3205
3265
|
}
|
|
3206
3266
|
return !1;
|
|
3207
|
-
};
|
|
3208
|
-
var advanceLeft = advanceLeft2, advanceRight = advanceRight2;
|
|
3209
|
-
let start = i - 2, end = i + 2, prec = getPrecedence(op), error;
|
|
3267
|
+
}, start = i - 2, end = i + 2, prec = getPrecedence(op), error;
|
|
3210
3268
|
switch (op.assoc) {
|
|
3211
3269
|
case "left":
|
|
3212
3270
|
case void 0: {
|
|
3213
|
-
|
|
3271
|
+
advanceLeft(!0), advanceRight(!1);
|
|
3214
3272
|
break;
|
|
3215
3273
|
}
|
|
3216
3274
|
case "right": {
|
|
3217
|
-
|
|
3275
|
+
advanceLeft(!1), advanceRight(!0);
|
|
3218
3276
|
break;
|
|
3219
3277
|
}
|
|
3220
3278
|
case "non": {
|
|
3221
|
-
(
|
|
3279
|
+
(advanceLeft(!1) || advanceRight(!1)) && (error = {
|
|
3222
3280
|
type: "Error",
|
|
3223
3281
|
message: `non-associative operator ${op.token} used at same precedence level without parenthesization`
|
|
3224
3282
|
});
|
|
3225
3283
|
break;
|
|
3226
3284
|
}
|
|
3227
3285
|
case "arguments": {
|
|
3228
|
-
|
|
3286
|
+
advanceLeft(!1) && (error = {
|
|
3229
3287
|
type: "Error",
|
|
3230
3288
|
message: `arguments operator ${op.token} used at same precedence level as ${expandedOps[start - 2].token} to the left`
|
|
3231
|
-
}),
|
|
3289
|
+
}), advanceRight(!0);
|
|
3232
3290
|
break;
|
|
3233
3291
|
}
|
|
3234
3292
|
default:
|
|
@@ -3333,7 +3391,7 @@ ${js}`
|
|
|
3333
3391
|
}
|
|
3334
3392
|
}
|
|
3335
3393
|
|
|
3336
|
-
// source
|
|
3394
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\pattern-matching.civet.jsx
|
|
3337
3395
|
function processPatternTest(lhs, patterns) {
|
|
3338
3396
|
let { ref, refAssignmentComma } = maybeRefAssignment(lhs, "m"), conditionExpression = flatJoin(patterns.map(($1) => getPatternConditions($1, ref)).map(($2) => flatJoin($2, " && ")), " || ");
|
|
3339
3397
|
return makeLeftHandSideExpression(makeNode({
|
|
@@ -3698,7 +3756,7 @@ ${js}`
|
|
|
3698
3756
|
}
|
|
3699
3757
|
}
|
|
3700
3758
|
|
|
3701
|
-
// source
|
|
3759
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\declaration.civet.jsx
|
|
3702
3760
|
function len2(arr, length) {
|
|
3703
3761
|
return arr.length === length;
|
|
3704
3762
|
}
|
|
@@ -3740,13 +3798,36 @@ ${js}`
|
|
|
3740
3798
|
function processDeclarations(statements) {
|
|
3741
3799
|
for (let ref1 = gatherRecursiveAll(statements, ($) => $.type === "Declaration"), i1 = 0, len1 = ref1.length; i1 < len1; i1++) {
|
|
3742
3800
|
let declaration = ref1[i1], { bindings } = declaration;
|
|
3743
|
-
bindings
|
|
3744
|
-
let
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3801
|
+
if (bindings != null)
|
|
3802
|
+
for (let i2 = 0, len22 = bindings.length; i2 < len22; i2++) {
|
|
3803
|
+
let binding = bindings[i2], { typeSuffix, initializer } = binding;
|
|
3804
|
+
if (typeSuffix && typeSuffix.optional) {
|
|
3805
|
+
if (initializer && !typeSuffix.t) {
|
|
3806
|
+
let expression = trimFirstSpace(initializer.expression), m;
|
|
3807
|
+
if (m = expression.type, m === "Identifier" || m === "MemberExpression")
|
|
3808
|
+
typeSuffix.children.push(": ", typeSuffix.t = {
|
|
3809
|
+
type: "TypeTypeof",
|
|
3810
|
+
children: ["typeof ", expression],
|
|
3811
|
+
expression
|
|
3812
|
+
});
|
|
3813
|
+
else if (expression.type === "Literal" || expression.type === "RegularExpressionLiteral" || expression.type === "TemplateLiteral")
|
|
3814
|
+
typeSuffix.children.push(": ", typeSuffix.t = literalType(expression));
|
|
3815
|
+
else {
|
|
3816
|
+
spliceChild(binding, typeSuffix, 1, {
|
|
3817
|
+
type: "Error",
|
|
3818
|
+
message: `Optional type can only be inferred from literals or member expressions, not ${expression.type}`
|
|
3819
|
+
});
|
|
3820
|
+
continue;
|
|
3821
|
+
}
|
|
3822
|
+
}
|
|
3823
|
+
typeSuffix.t ? convertOptionalType(typeSuffix) : (spliceChild(binding, typeSuffix, 1), binding.children.push(initializer = binding.initializer = {
|
|
3824
|
+
type: "Initializer",
|
|
3825
|
+
expression: "undefined",
|
|
3826
|
+
children: [" = ", "undefined"]
|
|
3827
|
+
}));
|
|
3828
|
+
}
|
|
3829
|
+
initializer && prependStatementExpressionBlock(initializer, declaration);
|
|
3830
|
+
}
|
|
3750
3831
|
}
|
|
3751
3832
|
}
|
|
3752
3833
|
function prependStatementExpressionBlock(initializer, statement) {
|
|
@@ -3863,14 +3944,14 @@ ${js}`
|
|
|
3863
3944
|
if (conditions.length) {
|
|
3864
3945
|
let children = condition.children;
|
|
3865
3946
|
if (s.negated) {
|
|
3866
|
-
let
|
|
3867
|
-
if (
|
|
3947
|
+
let m1;
|
|
3948
|
+
if (m1 = condition.expression, !(typeof m1 == "object" && m1 != null && "type" in m1 && m1.type === "UnaryExpression" && "children" in m1 && Array.isArray(m1.children) && len2(m1.children, 2) && Array.isArray(m1.children[0]) && len2(m1.children[0], 1) && m1.children[0][0] === "!" && typeof m1.children[1] == "object" && m1.children[1] != null && "type" in m1.children[1] && m1.children[1].type === "ParenthesizedExpression"))
|
|
3868
3949
|
throw new Error("Unsupported negated condition");
|
|
3869
3950
|
({ children } = condition.expression.children[1]);
|
|
3870
3951
|
}
|
|
3871
3952
|
children.unshift("(");
|
|
3872
|
-
for (let
|
|
3873
|
-
let c = conditions[
|
|
3953
|
+
for (let i3 = 0, len3 = conditions.length; i3 < len3; i3++) {
|
|
3954
|
+
let c = conditions[i3];
|
|
3874
3955
|
children.push(" && ", c);
|
|
3875
3956
|
}
|
|
3876
3957
|
children.push(")");
|
|
@@ -4067,7 +4148,7 @@ ${js}`
|
|
|
4067
4148
|
return [extendsToken, insertTrimmingSpace(ws, " "), wrapped];
|
|
4068
4149
|
}
|
|
4069
4150
|
|
|
4070
|
-
// source
|
|
4151
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\unary.civet.jsx
|
|
4071
4152
|
function processUnaryExpression(pre, exp, post) {
|
|
4072
4153
|
if (!(pre.length || post))
|
|
4073
4154
|
return exp;
|
|
@@ -4178,7 +4259,7 @@ ${js}`
|
|
|
4178
4259
|
return processUnaryExpression(pre, args, post);
|
|
4179
4260
|
}
|
|
4180
4261
|
|
|
4181
|
-
// source
|
|
4262
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\pipe.civet.jsx
|
|
4182
4263
|
function constructInvocation(fn, arg) {
|
|
4183
4264
|
let expr = fn.expr;
|
|
4184
4265
|
for (; expr.type === "ParenthesizedExpression"; )
|
|
@@ -4340,7 +4421,7 @@ ${js}`
|
|
|
4340
4421
|
});
|
|
4341
4422
|
}
|
|
4342
4423
|
|
|
4343
|
-
// source
|
|
4424
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\for.civet.jsx
|
|
4344
4425
|
function processRangeExpression(start, ws1, range, end) {
|
|
4345
4426
|
ws1 = [ws1, range.children[0]];
|
|
4346
4427
|
let ws2 = range.children[1], comma = { $loc: range.$loc, token: "," }, ref;
|
|
@@ -4618,7 +4699,7 @@ ${js}`
|
|
|
4618
4699
|
};
|
|
4619
4700
|
}
|
|
4620
4701
|
|
|
4621
|
-
// source
|
|
4702
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\auto-dec.civet.jsx
|
|
4622
4703
|
var concatAssign2 = (lhs, rhs) => (rhs?.[Symbol.isConcatSpreadable] ?? Array.isArray(rhs) ? lhs.push.apply(lhs, rhs) : lhs.push(rhs), lhs);
|
|
4623
4704
|
function findDecs(statements) {
|
|
4624
4705
|
let declarationNames = gatherNodes(statements, ($) => $.type === "Declaration").flatMap((d) => d.names), globals = getConfig().globals || [];
|
|
@@ -4681,9 +4762,7 @@ ${js}`
|
|
|
4681
4762
|
findAssignments(assignmentStatements2.map((s) => s.children), decs2)
|
|
4682
4763
|
), assignmentStatements2;
|
|
4683
4764
|
}
|
|
4684
|
-
pushVar
|
|
4685
|
-
return varIds.push(name), decs.add(name);
|
|
4686
|
-
});
|
|
4765
|
+
pushVar ??= (name) => (varIds.push(name), decs.add(name));
|
|
4687
4766
|
let { expressions: statements } = block, decs = findDecs(statements);
|
|
4688
4767
|
scopes.push(decs);
|
|
4689
4768
|
let varIds = [];
|
|
@@ -4702,7 +4781,7 @@ ${js}`
|
|
|
4702
4781
|
scopes.pop();
|
|
4703
4782
|
}
|
|
4704
4783
|
|
|
4705
|
-
// source
|
|
4784
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\string.civet.jsx
|
|
4706
4785
|
function getIndentLevel(str, tab) {
|
|
4707
4786
|
if (tab != null && tab != 1) {
|
|
4708
4787
|
let tabs = str.match(/\t/g), numTabs = tabs ? tabs.length : 0;
|
|
@@ -4812,7 +4891,7 @@ ${js}`
|
|
|
4812
4891
|
return JSON.stringify(str);
|
|
4813
4892
|
}
|
|
4814
4893
|
|
|
4815
|
-
// source
|
|
4894
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\lib.civet.jsx
|
|
4816
4895
|
var xor = (a, b) => a ? !b && a : b;
|
|
4817
4896
|
function addPostfixStatement(statement, ws, post) {
|
|
4818
4897
|
let expressions = [
|
|
@@ -5430,16 +5509,14 @@ ${js}`
|
|
|
5430
5509
|
}
|
|
5431
5510
|
function processAssignments(statements) {
|
|
5432
5511
|
for (let ref7 = gatherRecursiveAll(statements, ($4) => $4.type === "AssignmentExpression" || $4.type === "UpdateExpression"), i5 = 0, len3 = ref7.length; i5 < len3; i5++) {
|
|
5433
|
-
let
|
|
5512
|
+
let extractAssignment = function(lhs) {
|
|
5434
5513
|
let expr = lhs;
|
|
5435
5514
|
for (; expr.type === "ParenthesizedExpression"; )
|
|
5436
5515
|
expr = expr.expression;
|
|
5437
5516
|
let m1;
|
|
5438
5517
|
if (m1 = expr.type, m1 === "AssignmentExpression" || m1 === "UpdateExpression")
|
|
5439
5518
|
return expr.type === "UpdateExpression" && expr.children[0] === expr.assigned ? (pre.push("("), post.push([", ", lhs, ")"])) : (pre.push(["(", lhs, ", "]), post.push(")")), expr.assigned;
|
|
5440
|
-
};
|
|
5441
|
-
var extractAssignment = extractAssignment2;
|
|
5442
|
-
let exp = ref7[i5];
|
|
5519
|
+
}, exp = ref7[i5];
|
|
5443
5520
|
checkValidLHS(exp.assigned);
|
|
5444
5521
|
let pre = [], post = [], ref8;
|
|
5445
5522
|
switch (exp.type) {
|
|
@@ -5448,7 +5525,7 @@ ${js}`
|
|
|
5448
5525
|
continue;
|
|
5449
5526
|
for (let ref9 = exp.lhs, i6 = 0, len4 = ref9.length; i6 < len4; i6++) {
|
|
5450
5527
|
let lhsPart = ref9[i6], ref10;
|
|
5451
|
-
if (ref10 =
|
|
5528
|
+
if (ref10 = extractAssignment(lhsPart[1])) {
|
|
5452
5529
|
let newLhs = ref10;
|
|
5453
5530
|
lhsPart[1] = newLhs;
|
|
5454
5531
|
}
|
|
@@ -5456,7 +5533,7 @@ ${js}`
|
|
|
5456
5533
|
break;
|
|
5457
5534
|
}
|
|
5458
5535
|
case "UpdateExpression": {
|
|
5459
|
-
if (ref8 =
|
|
5536
|
+
if (ref8 = extractAssignment(exp.assigned)) {
|
|
5460
5537
|
let newLhs = ref8, i = exp.children.indexOf(exp.assigned);
|
|
5461
5538
|
exp.assigned = exp.children[i] = newLhs;
|
|
5462
5539
|
}
|
|
@@ -5834,6 +5911,80 @@ ${js}`
|
|
|
5834
5911
|
label.children.push(label.name = parent.label.name), delete label.special;
|
|
5835
5912
|
}
|
|
5836
5913
|
}
|
|
5914
|
+
function processCoffeeClasses(statements) {
|
|
5915
|
+
for (let ref21 = gatherRecursiveAll(statements, ($13) => $13.type === "ClassExpression"), i11 = 0, len9 = ref21.length; i11 < len9; i11++) {
|
|
5916
|
+
let ce = ref21[i11], { expressions } = ce.body, indent = expressions[0]?.[0] ?? `
|
|
5917
|
+
`, autoBinds = expressions.filter(($14) => $14[1]?.autoBind);
|
|
5918
|
+
if (autoBinds.length) {
|
|
5919
|
+
let construct;
|
|
5920
|
+
for (let [, c] of expressions)
|
|
5921
|
+
if (typeof c == "object" && c != null && "type" in c && c.type === "MethodDefinition" && "name" in c && c.name === "constructor" && c.block) {
|
|
5922
|
+
construct = c;
|
|
5923
|
+
break;
|
|
5924
|
+
}
|
|
5925
|
+
if (!construct) {
|
|
5926
|
+
let parametersList = [], parameters = {
|
|
5927
|
+
type: "Parameters",
|
|
5928
|
+
children: [parametersList],
|
|
5929
|
+
parameters: parametersList,
|
|
5930
|
+
names: []
|
|
5931
|
+
}, signature = {
|
|
5932
|
+
type: "MethodSignature",
|
|
5933
|
+
children: ["constructor(", parameters, ")"],
|
|
5934
|
+
parameters,
|
|
5935
|
+
modifier: {},
|
|
5936
|
+
returnType: void 0
|
|
5937
|
+
}, block = makeEmptyBlock();
|
|
5938
|
+
construct = {
|
|
5939
|
+
...signature,
|
|
5940
|
+
type: "MethodDefinition",
|
|
5941
|
+
name: "constructor",
|
|
5942
|
+
block,
|
|
5943
|
+
signature,
|
|
5944
|
+
children: [...signature.children, block]
|
|
5945
|
+
}, expressions.unshift([indent, construct]);
|
|
5946
|
+
}
|
|
5947
|
+
let index = findSuperCall(construct.block);
|
|
5948
|
+
construct.block.expressions.splice(
|
|
5949
|
+
index + 1,
|
|
5950
|
+
0,
|
|
5951
|
+
...(() => {
|
|
5952
|
+
let results3 = [];
|
|
5953
|
+
for (let i12 = 0, len10 = autoBinds.length; i12 < len10; i12++) {
|
|
5954
|
+
let [, a] = autoBinds[i12];
|
|
5955
|
+
results3.push([indent, ["this.", a.name, " = this.", a.name, ".bind(this)"], ";"]);
|
|
5956
|
+
}
|
|
5957
|
+
return results3;
|
|
5958
|
+
})()
|
|
5959
|
+
);
|
|
5960
|
+
}
|
|
5961
|
+
let privates = expressions.filter(($15) => $15[1]?.type === "CoffeeClassPrivate");
|
|
5962
|
+
if (!privates.length)
|
|
5963
|
+
continue;
|
|
5964
|
+
let { parent } = ce;
|
|
5965
|
+
for (let i13 = expressions.length + -1; i13 >= 0; --i13) {
|
|
5966
|
+
let i = i13;
|
|
5967
|
+
expressions[i][1]?.type === "CoffeeClassPrivate" && expressions.splice(i, 1);
|
|
5968
|
+
}
|
|
5969
|
+
let wrapped = wrapIIFE([
|
|
5970
|
+
...privates,
|
|
5971
|
+
[indent, wrapWithReturn(ce)]
|
|
5972
|
+
]);
|
|
5973
|
+
if (ce && typeof ce == "object" && "binding" in ce) {
|
|
5974
|
+
let { binding } = ce;
|
|
5975
|
+
binding = trimFirstSpace(binding), wrapped = makeNode({
|
|
5976
|
+
type: "AssignmentExpression",
|
|
5977
|
+
children: [binding, " = ", wrapped],
|
|
5978
|
+
lhs: binding,
|
|
5979
|
+
// TODO: incorrect shape
|
|
5980
|
+
assigned: binding,
|
|
5981
|
+
expression: wrapped,
|
|
5982
|
+
names: [ce.name]
|
|
5983
|
+
});
|
|
5984
|
+
}
|
|
5985
|
+
replaceNode(ce, wrapped, parent);
|
|
5986
|
+
}
|
|
5987
|
+
}
|
|
5837
5988
|
function processProgram(root) {
|
|
5838
5989
|
let state2 = getState(), config2 = getConfig();
|
|
5839
5990
|
assert.equal(state2.forbidBracedApplication.length, 1, "forbidBracedApplication"), assert.equal(state2.forbidClassImplicitCall.length, 1, "forbidClassImplicitCall"), assert.equal(state2.forbidIndentedApplication.length, 1, "forbidIndentedApplication"), assert.equal(state2.forbidNestedBinaryOp.length, 1, "forbidNestedBinaryOp"), assert.equal(state2.forbidNewlineBinaryOp.length, 1, "forbidNewlineBinaryOp"), assert.equal(state2.forbidTrailingMemberProperty.length, 1, "forbidTrailingMemberProperty"), assert.equal(state2.JSXTagStack.length, 1, "JSXTagStack");
|
|
@@ -5841,33 +5992,33 @@ ${js}`
|
|
|
5841
5992
|
if (config2.iife || config2.repl) {
|
|
5842
5993
|
rootIIFE = wrapIIFE(root.expressions, root.topLevelAwait);
|
|
5843
5994
|
let newExpressions = [["", rootIIFE]];
|
|
5844
|
-
root.children = root.children.map(($
|
|
5995
|
+
root.children = root.children.map(($16) => $16 === root.expressions ? newExpressions : $16), root.expressions = newExpressions;
|
|
5845
5996
|
}
|
|
5846
5997
|
addParentPointers(root);
|
|
5847
5998
|
let { expressions: statements } = root;
|
|
5848
|
-
processPlaceholders(statements), processNegativeIndexAccess(statements), processTypes(statements), processDeclarationConditions(statements), processPipelineExpressions(statements), processDeclarations(statements), processAssignments(statements), processStatementExpressions(statements), processPatternMatching(statements), processIterationExpressions(statements), processFinallyClauses(statements), processBreaksContinues(statements), hoistRefDecs(statements), processFunctions(statements, config2), statements.unshift(...state2.prelude), config2.autoLet ? createConstLetDecs(statements, [], "let") : config2.autoConst ? createConstLetDecs(statements, [], "const") : config2.autoVar && createVarDecs(root, []), config2.repl && processRepl(root, rootIIFE), processBlocks(statements), populateRefs(statements), adjustAtBindings(statements), getSync() && processComptime(statements);
|
|
5999
|
+
processPlaceholders(statements), processNegativeIndexAccess(statements), processTypes(statements), processDeclarationConditions(statements), processPipelineExpressions(statements), processDeclarations(statements), processAssignments(statements), processStatementExpressions(statements), processPatternMatching(statements), processIterationExpressions(statements), processFinallyClauses(statements), processBreaksContinues(statements), hoistRefDecs(statements), processFunctions(statements, config2), config2.coffeeClasses && processCoffeeClasses(statements), statements.unshift(...state2.prelude), config2.autoLet ? createConstLetDecs(statements, [], "let") : config2.autoConst ? createConstLetDecs(statements, [], "const") : config2.autoVar && createVarDecs(root, []), config2.repl && processRepl(root, rootIIFE), processBlocks(statements), populateRefs(statements), adjustAtBindings(statements), getSync() && processComptime(statements);
|
|
5849
6000
|
}
|
|
5850
6001
|
async function processProgramAsync(root) {
|
|
5851
6002
|
let { expressions: statements } = root;
|
|
5852
6003
|
await processComptime(statements);
|
|
5853
6004
|
}
|
|
5854
6005
|
function processRepl(root, rootIIFE) {
|
|
5855
|
-
let topBlock = gatherRecursive(rootIIFE, ($
|
|
5856
|
-
for (let
|
|
5857
|
-
let decl =
|
|
6006
|
+
let topBlock = gatherRecursive(rootIIFE, ($17) => $17.type === "BlockStatement")[0], i = 0;
|
|
6007
|
+
for (let ref22 = gatherRecursiveWithinFunction(topBlock, ($18) => $18.type === "Declaration"), i14 = 0, len11 = ref22.length; i14 < len11; i14++) {
|
|
6008
|
+
let decl = ref22[i14];
|
|
5858
6009
|
decl.names?.length && (decl.parent === topBlock || decl.decl === "var") && (decl.children.shift(), decl.bindings[0]?.pattern?.type === "ObjectBindingPattern" && (decl.children.unshift("("), decl.children.push(")")), root.expressions.splice(i++, 0, ["", `var ${decl.names.join(",")}`, ";"]));
|
|
5859
6010
|
}
|
|
5860
|
-
for (let
|
|
5861
|
-
let func =
|
|
6011
|
+
for (let ref23 = gatherRecursive(topBlock, ($19) => $19.type === "FunctionExpression"), i15 = 0, len12 = ref23.length; i15 < len12; i15++) {
|
|
6012
|
+
let func = ref23[i15];
|
|
5862
6013
|
func.name && func.parent?.type === "BlockStatement" && (func.parent === topBlock ? (replaceNode(func, void 0), root.expressions.splice(i++, 0, ["", func]), func.parent = root) : (func.children.unshift(func.name, "="), root.expressions.splice(i++, 0, ["", `var ${func.name}`, ";"])));
|
|
5863
6014
|
}
|
|
5864
|
-
for (let
|
|
5865
|
-
let classExp =
|
|
6015
|
+
for (let ref24 = gatherRecursiveWithinFunction(topBlock, ($20) => $20.type === "ClassExpression"), i16 = 0, len13 = ref24.length; i16 < len13; i16++) {
|
|
6016
|
+
let classExp = ref24[i16], m8;
|
|
5866
6017
|
(classExp.name && classExp.parent === topBlock || (m8 = classExp.parent, typeof m8 == "object" && m8 != null && "type" in m8 && m8.type === "ReturnStatement" && "parent" in m8 && m8.parent === topBlock)) && (classExp.children.unshift(classExp.name, "="), root.expressions.splice(i++, 0, ["", `var ${classExp.name}`, ";"]));
|
|
5867
6018
|
}
|
|
5868
6019
|
}
|
|
5869
6020
|
function populateRefs(statements) {
|
|
5870
|
-
let refNodes = gatherRecursive(statements, ($
|
|
6021
|
+
let refNodes = gatherRecursive(statements, ($21) => $21.type === "Ref");
|
|
5871
6022
|
if (refNodes.length) {
|
|
5872
6023
|
let ids = gatherRecursive(statements, (s) => s.type === "Identifier"), names = new Set(ids.flatMap(({ names: names2 }) => names2 || []));
|
|
5873
6024
|
refNodes.forEach((ref) => {
|
|
@@ -5883,8 +6034,8 @@ ${js}`
|
|
|
5883
6034
|
}
|
|
5884
6035
|
function processPlaceholders(statements) {
|
|
5885
6036
|
let placeholderMap = /* @__PURE__ */ new Map(), liftedIfs = /* @__PURE__ */ new Set();
|
|
5886
|
-
for (let
|
|
5887
|
-
let exp =
|
|
6037
|
+
for (let ref25 = gatherRecursiveAll(statements, ($22) => $22.type === "Placeholder"), i17 = 0, len14 = ref25.length; i17 < len14; i17++) {
|
|
6038
|
+
let exp = ref25[i17], ancestor;
|
|
5888
6039
|
if (exp.subtype === ".") {
|
|
5889
6040
|
({ ancestor } = findAncestor(
|
|
5890
6041
|
exp,
|
|
@@ -5953,11 +6104,11 @@ ${js}`
|
|
|
5953
6104
|
}
|
|
5954
6105
|
for (let [ancestor, placeholders] of placeholderMap) {
|
|
5955
6106
|
let ref = makeRef("$"), typeSuffix;
|
|
5956
|
-
for (let
|
|
5957
|
-
let placeholder = placeholders[
|
|
6107
|
+
for (let i18 = 0, len15 = placeholders.length; i18 < len15; i18++) {
|
|
6108
|
+
let placeholder = placeholders[i18];
|
|
5958
6109
|
typeSuffix ??= placeholder.typeSuffix;
|
|
5959
|
-
let
|
|
5960
|
-
(
|
|
6110
|
+
let ref26;
|
|
6111
|
+
(ref26 = placeholder.children)[ref26.length - 1] = ref;
|
|
5961
6112
|
}
|
|
5962
6113
|
let { parent } = ancestor, body = maybeUnwrap(ancestor), fnExp = makeAmpersandFunction({ ref, typeSuffix, body }), outer;
|
|
5963
6114
|
switch (parent?.type) {
|
|
@@ -5974,8 +6125,8 @@ ${js}`
|
|
|
5974
6125
|
break;
|
|
5975
6126
|
}
|
|
5976
6127
|
case "PipelineExpression": {
|
|
5977
|
-
let i = findChildIndex(parent, ancestor),
|
|
5978
|
-
i === 1 ?
|
|
6128
|
+
let i = findChildIndex(parent, ancestor), ref27;
|
|
6129
|
+
i === 1 ? ref27 = ancestor === parent.children[i] : i === 2 ? ref27 = ancestor === parent.children[i][findChildIndex(parent.children[i], ancestor)][3] : ref27 = void 0, outer = ref27;
|
|
5979
6130
|
break;
|
|
5980
6131
|
}
|
|
5981
6132
|
case "AssignmentExpression":
|
|
@@ -5987,9 +6138,9 @@ ${js}`
|
|
|
5987
6138
|
}
|
|
5988
6139
|
}
|
|
5989
6140
|
outer || (fnExp = makeLeftHandSideExpression(fnExp)), replaceNode(ancestor, fnExp, parent);
|
|
5990
|
-
let
|
|
5991
|
-
if (
|
|
5992
|
-
let ws =
|
|
6141
|
+
let ref28;
|
|
6142
|
+
if (ref28 = getTrimmingSpace(body)) {
|
|
6143
|
+
let ws = ref28;
|
|
5993
6144
|
inplaceInsertTrimmingSpace(body, ""), inplacePrepend(ws, fnExp);
|
|
5994
6145
|
}
|
|
5995
6146
|
}
|
|
@@ -6020,8 +6171,8 @@ ${js}`
|
|
|
6020
6171
|
}
|
|
6021
6172
|
];
|
|
6022
6173
|
}
|
|
6023
|
-
let
|
|
6024
|
-
Array.isArray(rest.delim) && (
|
|
6174
|
+
let ref29;
|
|
6175
|
+
Array.isArray(rest.delim) && (ref29 = rest.delim)[ref29.length - 1]?.token === "," && (rest.delim = rest.delim.slice(0, -1), rest.children = [...rest.children.slice(0, -1), rest.delim]);
|
|
6025
6176
|
let children = [...props, ...after, rest];
|
|
6026
6177
|
return restCount > 1 && children.push({
|
|
6027
6178
|
type: "Error",
|
|
@@ -7878,13 +8029,28 @@ ${js}`
|
|
|
7878
8029
|
var FieldDefinition$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(CoffeeClassesEnabled, ClassElementName, (0, import_lib2.$E)(_), Colon, __, AssignmentExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
7879
8030
|
var id = $2, exp = $6;
|
|
7880
8031
|
switch (exp.type) {
|
|
7881
|
-
|
|
7882
|
-
case "FunctionExpression":
|
|
8032
|
+
case "FunctionExpression": {
|
|
7883
8033
|
let fnTokenIndex = exp.children.findIndex((c) => c?.token?.startsWith("function")), children = exp.children.slice();
|
|
7884
8034
|
return exp.generator ? children.splice(fnTokenIndex, 2, children[fnTokenIndex + 1], id) : children.splice(fnTokenIndex, 1, id), {
|
|
7885
8035
|
...exp,
|
|
8036
|
+
type: "MethodDefinition",
|
|
8037
|
+
name: id.name,
|
|
8038
|
+
signature: { ...exp.signature, id, name: id.name },
|
|
7886
8039
|
children
|
|
7887
8040
|
};
|
|
8041
|
+
}
|
|
8042
|
+
case "ArrowFunction": {
|
|
8043
|
+
let block = { ...exp.block }, children = exp.children.filter((c) => !(Array.isArray(c) && c[c.length - 1]?.token?.includes("=>"))).map((c) => c === exp.block ? block : c);
|
|
8044
|
+
return children.unshift(id), exp = {
|
|
8045
|
+
...exp,
|
|
8046
|
+
type: "MethodDefinition",
|
|
8047
|
+
name: id.name,
|
|
8048
|
+
signature: { ...exp.signature, id, name: id.name },
|
|
8049
|
+
block,
|
|
8050
|
+
children,
|
|
8051
|
+
autoBind: !0
|
|
8052
|
+
}, block.parent = exp, braceBlock(block), exp;
|
|
8053
|
+
}
|
|
7888
8054
|
default:
|
|
7889
8055
|
return {
|
|
7890
8056
|
type: "FieldDefinition",
|
|
@@ -7893,26 +8059,37 @@ ${js}`
|
|
|
7893
8059
|
};
|
|
7894
8060
|
}
|
|
7895
8061
|
}), FieldDefinition$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(InsertReadonly, ClassElementName, (0, import_lib2.$E)(TypeSuffix), __, ConstAssignment, MaybeNestedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
7896
|
-
var
|
|
7897
|
-
return
|
|
8062
|
+
var readonly = $1, id = $2, typeSuffix = $3, ca = $5;
|
|
8063
|
+
return readonly.children[0].$loc = {
|
|
7898
8064
|
pos: ca.$loc.pos - 1,
|
|
7899
8065
|
length: ca.$loc.length + 1
|
|
7900
8066
|
}, {
|
|
7901
8067
|
type: "FieldDefinition",
|
|
7902
8068
|
id,
|
|
7903
8069
|
typeSuffix,
|
|
7904
|
-
children: $0
|
|
8070
|
+
children: $0,
|
|
8071
|
+
readonly
|
|
7905
8072
|
};
|
|
7906
|
-
}), FieldDefinition$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(
|
|
7907
|
-
var
|
|
8073
|
+
}), FieldDefinition$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(CoffeeClassesEnabled, ActualAssignment), function($skip, $loc, $0, $1, $2) {
|
|
8074
|
+
var assignment = $2;
|
|
8075
|
+
return {
|
|
8076
|
+
type: "CoffeeClassPrivate",
|
|
8077
|
+
children: [assignment],
|
|
8078
|
+
assignment
|
|
8079
|
+
};
|
|
8080
|
+
}), FieldDefinition$3 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)((0, import_lib2.$S)(Abstract, (0, import_lib2.$E)(_))), (0, import_lib2.$E)((0, import_lib2.$S)(Readonly, (0, import_lib2.$E)(_))), ClassElementName, (0, import_lib2.$E)(TypeSuffix), (0, import_lib2.$E)(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
8081
|
+
var abstract = $1, readonly = $2, id = $3, typeSuffix = $4, initializer = $5;
|
|
7908
8082
|
return {
|
|
7909
8083
|
type: "FieldDefinition",
|
|
7910
8084
|
children: $0,
|
|
7911
|
-
ts:
|
|
8085
|
+
ts: abstract ? !0 : void 0,
|
|
7912
8086
|
id,
|
|
7913
|
-
typeSuffix
|
|
8087
|
+
typeSuffix,
|
|
8088
|
+
abstract,
|
|
8089
|
+
readonly,
|
|
8090
|
+
initializer
|
|
7914
8091
|
};
|
|
7915
|
-
}), FieldDefinition$$ = [FieldDefinition$0, FieldDefinition$1, FieldDefinition$2];
|
|
8092
|
+
}), FieldDefinition$$ = [FieldDefinition$0, FieldDefinition$1, FieldDefinition$2, FieldDefinition$3];
|
|
7916
8093
|
function FieldDefinition(ctx, state2) {
|
|
7917
8094
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "FieldDefinition", FieldDefinition$$);
|
|
7918
8095
|
}
|
|
@@ -8524,7 +8701,7 @@ ${js}`
|
|
|
8524
8701
|
var expression = $2;
|
|
8525
8702
|
return {
|
|
8526
8703
|
type: "PinPattern",
|
|
8527
|
-
children:
|
|
8704
|
+
children: [expression],
|
|
8528
8705
|
expression
|
|
8529
8706
|
};
|
|
8530
8707
|
}), PinPattern$1 = (0, import_lib2.$TV)(ActualMemberExpression, function($skip, $loc, $0, $1) {
|
|
@@ -8683,6 +8860,7 @@ ${js}`
|
|
|
8683
8860
|
name: binding,
|
|
8684
8861
|
value: {
|
|
8685
8862
|
type: "PinPattern",
|
|
8863
|
+
children: [binding],
|
|
8686
8864
|
expression: binding
|
|
8687
8865
|
}
|
|
8688
8866
|
}) : {
|
|
@@ -9360,7 +9538,7 @@ ${js}`
|
|
|
9360
9538
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "LiteralContent", LiteralContent$$);
|
|
9361
9539
|
}
|
|
9362
9540
|
var NullLiteral$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($L38, 'NullLiteral "null"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
|
|
9363
|
-
return { $loc, token: $1 };
|
|
9541
|
+
return { type: "NullLiteral", $loc, token: $1 };
|
|
9364
9542
|
});
|
|
9365
9543
|
function NullLiteral(ctx, state2) {
|
|
9366
9544
|
return (0, import_lib2.$EVENT)(ctx, state2, "NullLiteral", NullLiteral$0);
|
|
@@ -9374,15 +9552,15 @@ ${js}`
|
|
|
9374
9552
|
var _BooleanLiteral$0 = (0, import_lib2.$T)((0, import_lib2.$S)(CoffeeBooleansEnabled, CoffeeScriptBooleanLiteral), function(value) {
|
|
9375
9553
|
return value[1];
|
|
9376
9554
|
}), _BooleanLiteral$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$C)((0, import_lib2.$EXPECT)($L39, '_BooleanLiteral "true"'), (0, import_lib2.$EXPECT)($L40, '_BooleanLiteral "false"')), NonIdContinue), function($skip, $loc, $0, $1, $2) {
|
|
9377
|
-
return { $loc, token: $1 };
|
|
9555
|
+
return { type: "BooleanLiteral", $loc, token: $1 };
|
|
9378
9556
|
}), _BooleanLiteral$$ = [_BooleanLiteral$0, _BooleanLiteral$1];
|
|
9379
9557
|
function _BooleanLiteral(ctx, state2) {
|
|
9380
9558
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "_BooleanLiteral", _BooleanLiteral$$);
|
|
9381
9559
|
}
|
|
9382
9560
|
var CoffeeScriptBooleanLiteral$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$C)((0, import_lib2.$EXPECT)($L41, 'CoffeeScriptBooleanLiteral "yes"'), (0, import_lib2.$EXPECT)($L42, 'CoffeeScriptBooleanLiteral "on"')), NonIdContinue), function($skip, $loc, $0, $1, $2) {
|
|
9383
|
-
return { $loc, token: "true" };
|
|
9561
|
+
return { type: "BooleanLiteral", $loc, token: "true" };
|
|
9384
9562
|
}), CoffeeScriptBooleanLiteral$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$C)((0, import_lib2.$EXPECT)($L43, 'CoffeeScriptBooleanLiteral "no"'), (0, import_lib2.$EXPECT)($L44, 'CoffeeScriptBooleanLiteral "off"')), NonIdContinue), function($skip, $loc, $0, $1, $2) {
|
|
9385
|
-
return { $loc, token: "false" };
|
|
9563
|
+
return { type: "BooleanLiteral", $loc, token: "false" };
|
|
9386
9564
|
}), CoffeeScriptBooleanLiteral$$ = [CoffeeScriptBooleanLiteral$0, CoffeeScriptBooleanLiteral$1];
|
|
9387
9565
|
function CoffeeScriptBooleanLiteral(ctx, state2) {
|
|
9388
9566
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "CoffeeScriptBooleanLiteral", CoffeeScriptBooleanLiteral$$);
|
|
@@ -12391,7 +12569,12 @@ ${js}`
|
|
|
12391
12569
|
return (0, import_lib2.$EVENT)(ctx, state2, "CoffeeDoubleQuotedStringCharacters", CoffeeDoubleQuotedStringCharacters$0);
|
|
12392
12570
|
}
|
|
12393
12571
|
var RegularExpressionLiteral$0 = HeregexLiteral, RegularExpressionLiteral$1 = (0, import_lib2.$TV)((0, import_lib2.$TEXT)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($L77, 'RegularExpressionLiteral "/"'), RegularExpressionBody, (0, import_lib2.$EXPECT)($L77, 'RegularExpressionLiteral "/"'), RegularExpressionFlags)), function($skip, $loc, $0, $1) {
|
|
12394
|
-
|
|
12572
|
+
var raw = $0;
|
|
12573
|
+
return {
|
|
12574
|
+
type: "RegularExpressionLiteral",
|
|
12575
|
+
raw,
|
|
12576
|
+
children: [{ $loc, token: raw }]
|
|
12577
|
+
};
|
|
12395
12578
|
}), RegularExpressionLiteral$$ = [RegularExpressionLiteral$0, RegularExpressionLiteral$1];
|
|
12396
12579
|
function RegularExpressionLiteral(ctx, state2) {
|
|
12397
12580
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "RegularExpressionLiteral", RegularExpressionLiteral$$);
|
|
@@ -14371,9 +14554,11 @@ ${js}`
|
|
|
14371
14554
|
return (0, import_lib2.$EVENT)(ctx, state2, "UnknownAlias", UnknownAlias$0);
|
|
14372
14555
|
}
|
|
14373
14556
|
var TypePrimary$0 = (0, import_lib2.$S)((0, import_lib2.$E)(_), Infer, (0, import_lib2.$E)(_), IdentifierName, (0, import_lib2.$E)((0, import_lib2.$S)(NotDedented, ExtendsToken, Type))), TypePrimary$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), Typeof, (0, import_lib2.$E)(_), UnaryExpression), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
14557
|
+
var expression = $4;
|
|
14374
14558
|
return {
|
|
14375
|
-
type: "
|
|
14376
|
-
children: $0
|
|
14559
|
+
type: "TypeTypeof",
|
|
14560
|
+
children: $0,
|
|
14561
|
+
expression
|
|
14377
14562
|
};
|
|
14378
14563
|
}), TypePrimary$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), TypeTuple), function($skip, $loc, $0, $1, $2) {
|
|
14379
14564
|
return prepend($1, $2);
|
|
@@ -15484,9 +15669,9 @@ ${js}`
|
|
|
15484
15669
|
"unscopables"
|
|
15485
15670
|
];
|
|
15486
15671
|
|
|
15487
|
-
// source
|
|
15488
|
-
var
|
|
15489
|
-
__export(
|
|
15672
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\sourcemap.civet.jsx
|
|
15673
|
+
var sourcemap_civet_exports = {};
|
|
15674
|
+
__export(sourcemap_civet_exports, {
|
|
15490
15675
|
SourceMap: () => SourceMap,
|
|
15491
15676
|
base64Encode: () => base64Encode,
|
|
15492
15677
|
locationTable: () => locationTable,
|
|
@@ -15643,7 +15828,7 @@ ${js}`
|
|
|
15643
15828
|
return [lastMapping[2], lastMapping[3]];
|
|
15644
15829
|
};
|
|
15645
15830
|
|
|
15646
|
-
// source
|
|
15831
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\state-cache.civet.jsx
|
|
15647
15832
|
var StateCache = class {
|
|
15648
15833
|
cache = /* @__PURE__ */ new Map();
|
|
15649
15834
|
get(key) {
|
|
@@ -15666,8 +15851,8 @@ ${js}`
|
|
|
15666
15851
|
}
|
|
15667
15852
|
};
|
|
15668
15853
|
|
|
15669
|
-
// source
|
|
15670
|
-
var { SourceMap: SourceMap2 } =
|
|
15854
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\main.civet.jsx
|
|
15855
|
+
var { SourceMap: SourceMap2 } = sourcemap_civet_exports;
|
|
15671
15856
|
var ParseErrors = class extends Error {
|
|
15672
15857
|
name = "ParseErrors";
|
|
15673
15858
|
errors;
|
|
@@ -15772,14 +15957,14 @@ ${counts}`;
|
|
|
15772
15957
|
}
|
|
15773
15958
|
if (options.sourceMap || options.inlineMap) {
|
|
15774
15959
|
options.sourceMap = SourceMap2(src);
|
|
15775
|
-
let code =
|
|
15960
|
+
let code = generate_civet_default(ast2, options);
|
|
15776
15961
|
return checkErrors(), options.inlineMap ? SourceMap2.remap(code, options.sourceMap, filename2, filename2 + ".tsx") : {
|
|
15777
15962
|
code,
|
|
15778
15963
|
sourceMap: options.sourceMap
|
|
15779
15964
|
};
|
|
15780
15965
|
}
|
|
15781
|
-
let result =
|
|
15782
|
-
return options.errors?.length && (delete options.errors, options.sourceMap = SourceMap2(src),
|
|
15966
|
+
let result = generate_civet_default(ast2, options);
|
|
15967
|
+
return options.errors?.length && (delete options.errors, options.sourceMap = SourceMap2(src), generate_civet_default(ast2, options), checkErrors()), result;
|
|
15783
15968
|
}
|
|
15784
15969
|
return ast.then != null ? ast.then(rest) : rest(ast);
|
|
15785
15970
|
}
|
|
@@ -15816,7 +16001,7 @@ ${counts}`;
|
|
|
15816
16001
|
return err instanceof import_lib2.ParseError || err instanceof ParseErrors;
|
|
15817
16002
|
};
|
|
15818
16003
|
|
|
15819
|
-
// source
|
|
16004
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\browser.civet.jsx
|
|
15820
16005
|
async function runScripts(type = "text/civet") {
|
|
15821
16006
|
let scripts = window.document.querySelectorAll(`script[type=${JSON.stringify(type)}]`);
|
|
15822
16007
|
for (let i1 = 0, len3 = scripts.length; i1 < len3; i1++) {
|
|
@@ -15862,5 +16047,5 @@ ${counts}`;
|
|
|
15862
16047
|
return autoRunScripts([document.head, document.body]);
|
|
15863
16048
|
});
|
|
15864
16049
|
}
|
|
15865
|
-
return __toCommonJS(
|
|
16050
|
+
return __toCommonJS(browser_civet_exports);
|
|
15866
16051
|
})();
|