@danielx/civet 0.10.5 → 0.10.7
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 +25 -2
- package/dist/babel-plugin.js +1 -1
- package/dist/babel-plugin.mjs +1 -1
- package/dist/browser.js +236 -151
- package/dist/civet +7 -8
- package/dist/config.js +2 -2
- package/dist/config.mjs +3 -3
- package/dist/esbuild-plugin.js +2 -2
- package/dist/esm.mjs +2 -2
- package/dist/main.js +303 -198
- package/dist/main.mjs +301 -197
- package/dist/node-worker.mjs +1 -1
- package/dist/types.d.ts +89 -11
- package/dist/unplugin/astro.js +1 -1
- package/dist/unplugin/astro.mjs +1 -1
- package/dist/unplugin/esbuild.js +1 -1
- package/dist/unplugin/esbuild.mjs +1 -1
- package/dist/unplugin/farm.js +1 -1
- package/dist/unplugin/farm.mjs +1 -1
- package/dist/unplugin/rolldown.js +1 -1
- package/dist/unplugin/rolldown.mjs +1 -1
- package/dist/unplugin/rollup.js +1 -1
- package/dist/unplugin/rollup.mjs +1 -1
- package/dist/unplugin/rspack.js +1 -1
- package/dist/unplugin/rspack.mjs +1 -1
- package/dist/unplugin/unplugin.js +6 -8
- package/dist/unplugin/unplugin.mjs +7 -9
- package/dist/unplugin/vite.js +1 -1
- package/dist/unplugin/vite.mjs +1 -1
- package/dist/unplugin/webpack.js +1 -1
- package/dist/unplugin/webpack.mjs +1 -1
- package/package.json +2 -2
- package/register.js +2 -2
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
|
+
// ../Hera/dist/machine.js
|
|
32
32
|
var require_machine = __commonJS({
|
|
33
|
-
"
|
|
33
|
+
"../Hera/dist/machine.js"(exports, module) {
|
|
34
34
|
"use strict";
|
|
35
35
|
var __defProp2 = Object.defineProperty;
|
|
36
36
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -485,7 +485,7 @@ ${body}`;
|
|
|
485
485
|
// source/parser.hera
|
|
486
486
|
var import_lib2 = __toESM(require_machine());
|
|
487
487
|
|
|
488
|
-
// unplugin-civet
|
|
488
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\lib.civet.jsx
|
|
489
489
|
var lib_civet_exports = {};
|
|
490
490
|
__export(lib_civet_exports, {
|
|
491
491
|
addPostfixStatement: () => addPostfixStatement,
|
|
@@ -496,6 +496,8 @@ __export(lib_civet_exports, {
|
|
|
496
496
|
blockWithPrefix: () => blockWithPrefix,
|
|
497
497
|
braceBlock: () => braceBlock,
|
|
498
498
|
bracedBlock: () => bracedBlock,
|
|
499
|
+
convertArrowFunctionToMethod: () => convertArrowFunctionToMethod,
|
|
500
|
+
convertFunctionToMethod: () => convertFunctionToMethod,
|
|
499
501
|
convertNamedImportsToObject: () => convertNamedImportsToObject,
|
|
500
502
|
convertObjectToJSXAttributes: () => convertObjectToJSXAttributes,
|
|
501
503
|
convertWithClause: () => convertWithClause,
|
|
@@ -565,7 +567,7 @@ __export(lib_civet_exports, {
|
|
|
565
567
|
wrapTypeInPromise: () => wrapTypeInPromise
|
|
566
568
|
});
|
|
567
569
|
|
|
568
|
-
// unplugin-civet
|
|
570
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\util.civet.jsx
|
|
569
571
|
function len(arr, length) {
|
|
570
572
|
return arr.length === length;
|
|
571
573
|
}
|
|
@@ -1566,7 +1568,7 @@ function flatJoin(array, separator) {
|
|
|
1566
1568
|
return result;
|
|
1567
1569
|
}
|
|
1568
1570
|
|
|
1569
|
-
// unplugin-civet
|
|
1571
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\traversal.civet.jsx
|
|
1570
1572
|
function gatherRecursiveWithinFunction(node, predicate) {
|
|
1571
1573
|
return gatherRecursive(node, predicate, isFunction);
|
|
1572
1574
|
}
|
|
@@ -1675,7 +1677,7 @@ function gatherRecursiveAll(node, predicate) {
|
|
|
1675
1677
|
return nodes;
|
|
1676
1678
|
}
|
|
1677
1679
|
|
|
1678
|
-
// unplugin-civet
|
|
1680
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\ref.civet.jsx
|
|
1679
1681
|
var range = (start, end) => {
|
|
1680
1682
|
const length = end - start;
|
|
1681
1683
|
if (length <= 0) return [];
|
|
@@ -1770,7 +1772,7 @@ function populateRefs(statements) {
|
|
|
1770
1772
|
}
|
|
1771
1773
|
}
|
|
1772
1774
|
|
|
1773
|
-
// unplugin-civet
|
|
1775
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\binding.civet.jsx
|
|
1774
1776
|
function adjustAtBindings(statements, asThis = false) {
|
|
1775
1777
|
for (let ref1 = gatherRecursiveAll(statements, ($1) => $1.type === "AtBindingProperty"), i1 = 0, len3 = ref1.length; i1 < len3; i1++) {
|
|
1776
1778
|
const binding = ref1[i1];
|
|
@@ -2037,12 +2039,12 @@ function gatherBindingPatternTypeSuffix(pattern) {
|
|
|
2037
2039
|
return pattern;
|
|
2038
2040
|
}
|
|
2039
2041
|
|
|
2040
|
-
// unplugin-civet
|
|
2042
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\comptime.civet.jsx
|
|
2041
2043
|
import { resolve, dirname } from "node:path";
|
|
2042
2044
|
import { createRequire } from "node:module";
|
|
2043
2045
|
import vm from "node:vm";
|
|
2044
2046
|
|
|
2045
|
-
// unplugin-civet
|
|
2047
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\helper.civet.jsx
|
|
2046
2048
|
var preludeVar = "var ";
|
|
2047
2049
|
function ts(children) {
|
|
2048
2050
|
return {
|
|
@@ -2359,7 +2361,7 @@ function extractPreludeFor(node) {
|
|
|
2359
2361
|
}
|
|
2360
2362
|
}
|
|
2361
2363
|
|
|
2362
|
-
// unplugin-civet
|
|
2364
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\generate.civet.jsx
|
|
2363
2365
|
function stringify(node) {
|
|
2364
2366
|
try {
|
|
2365
2367
|
return JSON.stringify(removeParentPointers(node));
|
|
@@ -2469,7 +2471,7 @@ function prune(node) {
|
|
|
2469
2471
|
return node;
|
|
2470
2472
|
}
|
|
2471
2473
|
|
|
2472
|
-
// unplugin-civet
|
|
2474
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\comptime.civet.jsx
|
|
2473
2475
|
function expressionizeComptime(statement) {
|
|
2474
2476
|
const { expressions } = statement.block;
|
|
2475
2477
|
const expression = wrapIIFE(expressions, hasAwait(expressions));
|
|
@@ -2790,7 +2792,7 @@ function serialize(value, context) {
|
|
|
2790
2792
|
return recurse(value);
|
|
2791
2793
|
}
|
|
2792
2794
|
|
|
2793
|
-
// unplugin-civet
|
|
2795
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\function.civet.jsx
|
|
2794
2796
|
var concatAssign = (lhs, rhs) => (rhs?.[Symbol.isConcatSpreadable] ?? Array.isArray(rhs) ? lhs.push.apply(lhs, rhs) : lhs.push(rhs), lhs);
|
|
2795
2797
|
function getTypeArguments(args) {
|
|
2796
2798
|
while (typeof args === "object" && args != null && "args" in args) {
|
|
@@ -4022,7 +4024,11 @@ function processSignature(f) {
|
|
|
4022
4024
|
}
|
|
4023
4025
|
}
|
|
4024
4026
|
if (signature.modifier.async && !signature.modifier.generator && signature.returnType && !isPromiseType(signature.returnType.t)) {
|
|
4025
|
-
replaceNode(
|
|
4027
|
+
replaceNode(
|
|
4028
|
+
signature.returnType.t,
|
|
4029
|
+
wrapTypeInPromise(signature.returnType.t),
|
|
4030
|
+
signature.returnType
|
|
4031
|
+
);
|
|
4026
4032
|
}
|
|
4027
4033
|
}
|
|
4028
4034
|
function processFunctions(statements, config2) {
|
|
@@ -4223,7 +4229,7 @@ function makeAmpersandFunction(rhs) {
|
|
|
4223
4229
|
return fn;
|
|
4224
4230
|
}
|
|
4225
4231
|
|
|
4226
|
-
// unplugin-civet
|
|
4232
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\block.civet.jsx
|
|
4227
4233
|
function blockWithPrefix(prefixStatements, block) {
|
|
4228
4234
|
if (prefixStatements && prefixStatements.length) {
|
|
4229
4235
|
const expressions = [...prefixStatements, ...block.expressions];
|
|
@@ -4444,7 +4450,7 @@ function blockContainingStatement(exp) {
|
|
|
4444
4450
|
};
|
|
4445
4451
|
}
|
|
4446
4452
|
|
|
4447
|
-
// unplugin-civet
|
|
4453
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\op.civet.jsx
|
|
4448
4454
|
var precedenceOrder = [
|
|
4449
4455
|
["||", "??"],
|
|
4450
4456
|
["^^"],
|
|
@@ -4780,7 +4786,7 @@ function expandChainedComparisons([first, binops]) {
|
|
|
4780
4786
|
}
|
|
4781
4787
|
}
|
|
4782
4788
|
|
|
4783
|
-
// unplugin-civet
|
|
4789
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\pattern-matching.civet.jsx
|
|
4784
4790
|
function processPatternTest(lhs, patterns) {
|
|
4785
4791
|
const { ref, refAssignmentComma } = maybeRefAssignment(lhs, "m");
|
|
4786
4792
|
const conditionExpression = flatJoin(patterns.map(($1) => getPatternConditions($1, ref)).map(($2) => flatJoin($2, " && ")), " || ");
|
|
@@ -5299,7 +5305,7 @@ function aliasBinding(p, ref) {
|
|
|
5299
5305
|
}
|
|
5300
5306
|
}
|
|
5301
5307
|
|
|
5302
|
-
// unplugin-civet
|
|
5308
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\declaration.civet.jsx
|
|
5303
5309
|
function len2(arr, length) {
|
|
5304
5310
|
return arr.length === length;
|
|
5305
5311
|
}
|
|
@@ -5853,7 +5859,7 @@ function convertWithClause(withClause, extendsClause) {
|
|
|
5853
5859
|
return [extendsToken, insertTrimmingSpace(ws, " "), wrapped];
|
|
5854
5860
|
}
|
|
5855
5861
|
|
|
5856
|
-
// unplugin-civet
|
|
5862
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\unary.civet.jsx
|
|
5857
5863
|
function processUnaryExpression(pre, exp, post) {
|
|
5858
5864
|
if (!(pre.length || post)) {
|
|
5859
5865
|
return exp;
|
|
@@ -6015,7 +6021,7 @@ function processUnaryNestedExpression(pre, args, post) {
|
|
|
6015
6021
|
return processUnaryExpression(pre, args, post);
|
|
6016
6022
|
}
|
|
6017
6023
|
|
|
6018
|
-
// unplugin-civet
|
|
6024
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\pipe.civet.jsx
|
|
6019
6025
|
function constructInvocation(fn, arg) {
|
|
6020
6026
|
let expr = fn.expr;
|
|
6021
6027
|
while (expr.type === "ParenthesizedExpression") {
|
|
@@ -6238,7 +6244,7 @@ function processPipelineExpressions(statements) {
|
|
|
6238
6244
|
}
|
|
6239
6245
|
}
|
|
6240
6246
|
|
|
6241
|
-
// unplugin-civet
|
|
6247
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\for.civet.jsx
|
|
6242
6248
|
function processRangeExpression(start, ws1, range2, end) {
|
|
6243
6249
|
ws1 = [ws1, range2.children[0]];
|
|
6244
6250
|
const ws2 = range2.children[1];
|
|
@@ -6683,7 +6689,7 @@ function processForInOf($0) {
|
|
|
6683
6689
|
};
|
|
6684
6690
|
}
|
|
6685
6691
|
|
|
6686
|
-
// unplugin-civet
|
|
6692
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\auto-dec.civet.jsx
|
|
6687
6693
|
var concatAssign2 = (lhs, rhs) => (rhs?.[Symbol.isConcatSpreadable] ?? Array.isArray(rhs) ? lhs.push.apply(lhs, rhs) : lhs.push(rhs), lhs);
|
|
6688
6694
|
function findDecs(statements) {
|
|
6689
6695
|
const declarations = gatherNodes(statements, ($) => $.type === "Declaration");
|
|
@@ -6780,7 +6786,7 @@ function createVarDecs(block, scopes, pushVar) {
|
|
|
6780
6786
|
findAssignments(assignmentStatements2.map((s) => s.children), decs2)
|
|
6781
6787
|
);
|
|
6782
6788
|
}
|
|
6783
|
-
return assignmentStatements2;
|
|
6789
|
+
return assignmentStatements2.filter(($4) => !($4.parent?.type === "CoffeeClassPublic"));
|
|
6784
6790
|
}
|
|
6785
6791
|
pushVar ??= (name) => {
|
|
6786
6792
|
varIds.push(name);
|
|
@@ -6791,7 +6797,7 @@ function createVarDecs(block, scopes, pushVar) {
|
|
|
6791
6797
|
scopes.push(decs);
|
|
6792
6798
|
const varIds = [];
|
|
6793
6799
|
const assignmentStatements = findAssignments(statements, scopes);
|
|
6794
|
-
const undeclaredIdentifiers = assignmentStatements.flatMap(($
|
|
6800
|
+
const undeclaredIdentifiers = assignmentStatements.flatMap(($5) => $5?.names || []);
|
|
6795
6801
|
undeclaredIdentifiers.filter((x, i, a) => {
|
|
6796
6802
|
if (!hasDec(x)) return a.indexOf(x) === i;
|
|
6797
6803
|
return;
|
|
@@ -6829,7 +6835,7 @@ function createVarDecs(block, scopes, pushVar) {
|
|
|
6829
6835
|
scopes.pop();
|
|
6830
6836
|
}
|
|
6831
6837
|
|
|
6832
|
-
// unplugin-civet
|
|
6838
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\string.civet.jsx
|
|
6833
6839
|
function getIndentLevel(str, tab) {
|
|
6834
6840
|
if (tab != null && tab != 1) {
|
|
6835
6841
|
const tabs = str.match(/\t/g);
|
|
@@ -6997,7 +7003,7 @@ function quoteString(str) {
|
|
|
6997
7003
|
return JSON.stringify(str);
|
|
6998
7004
|
}
|
|
6999
7005
|
|
|
7000
|
-
// unplugin-civet
|
|
7006
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\lib.civet.jsx
|
|
7001
7007
|
var xor = (a, b) => a ? !b && a : b;
|
|
7002
7008
|
function addPostfixStatement(statement, ws, post) {
|
|
7003
7009
|
const expressions = [
|
|
@@ -7625,21 +7631,18 @@ function makeExpressionStatement(expression) {
|
|
|
7625
7631
|
}
|
|
7626
7632
|
}
|
|
7627
7633
|
function lastAccessInCallExpression(exp) {
|
|
7628
|
-
|
|
7634
|
+
while (exp.type === "MemberExpression" || exp.type === "CallExpression") {
|
|
7635
|
+
const { children } = exp;
|
|
7636
|
+
let i = children.length - 1;
|
|
7637
|
+
while (i >= 0 && typeof children[i] === "object" && (children[i].type === "Call" || children[i].type === "NonNullAssertion" || children[i].type === "Optional")) i--;
|
|
7638
|
+
if (i < 0) return;
|
|
7639
|
+
exp = children[i];
|
|
7640
|
+
}
|
|
7641
|
+
if (exp.type === "Identifier" || exp.type === "PropertyAccess" || exp.type === "Index") {
|
|
7629
7642
|
return exp;
|
|
7630
7643
|
}
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
if (!(exp.children != null)) {
|
|
7634
|
-
return;
|
|
7635
|
-
}
|
|
7636
|
-
;
|
|
7637
|
-
({ children } = exp);
|
|
7638
|
-
i = children.length - 1;
|
|
7639
|
-
while (i >= 0 && (children[i].type === "Call" || children[i].type === "NonNullAssertion" || children[i].type === "Optional")) i--;
|
|
7640
|
-
if (i < 0) return;
|
|
7641
|
-
} while (children[i].type === "MemberExpression" && (exp = children[i]));
|
|
7642
|
-
return children[i];
|
|
7644
|
+
;
|
|
7645
|
+
return;
|
|
7643
7646
|
}
|
|
7644
7647
|
function convertMethodToFunction(method) {
|
|
7645
7648
|
const { signature, block } = method;
|
|
@@ -7669,6 +7672,45 @@ function convertMethodToFunction(method) {
|
|
|
7669
7672
|
block
|
|
7670
7673
|
};
|
|
7671
7674
|
}
|
|
7675
|
+
function convertFunctionToMethod(id, exp) {
|
|
7676
|
+
const fnTokenIndex = exp.children.findIndex(function(c) {
|
|
7677
|
+
return c?.token?.startsWith("function");
|
|
7678
|
+
});
|
|
7679
|
+
const children = exp.children.slice();
|
|
7680
|
+
if (exp.generator) {
|
|
7681
|
+
children.splice(fnTokenIndex, 2, children[fnTokenIndex + 1], id);
|
|
7682
|
+
} else {
|
|
7683
|
+
children.splice(fnTokenIndex, 1, id);
|
|
7684
|
+
}
|
|
7685
|
+
return {
|
|
7686
|
+
...exp,
|
|
7687
|
+
type: "MethodDefinition",
|
|
7688
|
+
name: id.name,
|
|
7689
|
+
signature: { ...exp.signature, id, name: id.name },
|
|
7690
|
+
children
|
|
7691
|
+
};
|
|
7692
|
+
}
|
|
7693
|
+
function convertArrowFunctionToMethod(id, exp) {
|
|
7694
|
+
const block = { ...exp.block };
|
|
7695
|
+
const children = exp.children.filter(function(c) {
|
|
7696
|
+
return !(Array.isArray(c) && c[c.length - 1]?.token?.includes("=>"));
|
|
7697
|
+
}).map(function(c) {
|
|
7698
|
+
return c === exp.block ? block : c;
|
|
7699
|
+
});
|
|
7700
|
+
children.unshift(id);
|
|
7701
|
+
exp = {
|
|
7702
|
+
...exp,
|
|
7703
|
+
type: "MethodDefinition",
|
|
7704
|
+
name: id.name,
|
|
7705
|
+
signature: { ...exp.signature, id, name: id.name },
|
|
7706
|
+
block,
|
|
7707
|
+
children,
|
|
7708
|
+
autoBind: true
|
|
7709
|
+
};
|
|
7710
|
+
block.parent = exp;
|
|
7711
|
+
braceBlock(block);
|
|
7712
|
+
return exp;
|
|
7713
|
+
}
|
|
7672
7714
|
function convertNamedImportsToObject(node, pattern) {
|
|
7673
7715
|
const properties = node.specifiers.map((specifier) => {
|
|
7674
7716
|
if (specifier.ts) {
|
|
@@ -8453,7 +8495,17 @@ function processCoffeeClasses(statements) {
|
|
|
8453
8495
|
})()
|
|
8454
8496
|
);
|
|
8455
8497
|
}
|
|
8456
|
-
const
|
|
8498
|
+
const public_static_function_assignments = expressions.filter(($15) => $15[1]?.type === "CoffeeClassPublic" && $15[1].assignment?.expression?.type === "FunctionExpression").map(($16) => $16[1].assignment);
|
|
8499
|
+
for (const public_static_function_assignment of public_static_function_assignments) {
|
|
8500
|
+
const id = public_static_function_assignment.lhs[0][1];
|
|
8501
|
+
replaceNode(public_static_function_assignment, convertFunctionToMethod(id, public_static_function_assignment.expression));
|
|
8502
|
+
}
|
|
8503
|
+
const public_static_arrow_function_assignments = expressions.filter(($17) => $17[1]?.type === "CoffeeClassPublic" && $17[1].assignment?.expression?.type === "ArrowFunction").map(($18) => $18[1].assignment);
|
|
8504
|
+
for (const public_static_arrow_function_assignment of public_static_arrow_function_assignments) {
|
|
8505
|
+
const id = public_static_arrow_function_assignment.lhs[0][1];
|
|
8506
|
+
replaceNode(public_static_arrow_function_assignment, convertArrowFunctionToMethod(id, public_static_arrow_function_assignment.expression));
|
|
8507
|
+
}
|
|
8508
|
+
const privates = expressions.filter(($19) => $19[1]?.type === "CoffeeClassPrivate");
|
|
8457
8509
|
if (!privates.length) {
|
|
8458
8510
|
continue;
|
|
8459
8511
|
}
|
|
@@ -8518,7 +8570,7 @@ function processProgram(root) {
|
|
|
8518
8570
|
root.topLevelYield ? "*" : void 0
|
|
8519
8571
|
);
|
|
8520
8572
|
statements = [["", rootIIFE]];
|
|
8521
|
-
root.children = root.children.map(($
|
|
8573
|
+
root.children = root.children.map(($20) => $20 === root.expressions ? statements : $20);
|
|
8522
8574
|
root.expressions = statements;
|
|
8523
8575
|
}
|
|
8524
8576
|
hoistRefDecs(statements);
|
|
@@ -8549,9 +8601,9 @@ async function processProgramAsync(root) {
|
|
|
8549
8601
|
await processComptime(statements);
|
|
8550
8602
|
}
|
|
8551
8603
|
function processRepl(root, rootIIFE) {
|
|
8552
|
-
const topBlock = gatherRecursive(rootIIFE, ($
|
|
8604
|
+
const topBlock = gatherRecursive(rootIIFE, ($21) => $21.type === "BlockStatement")[0];
|
|
8553
8605
|
let i = 0;
|
|
8554
|
-
for (let ref23 = gatherRecursiveWithinFunction(topBlock, ($
|
|
8606
|
+
for (let ref23 = gatherRecursiveWithinFunction(topBlock, ($22) => $22.type === "Declaration"), i14 = 0, len11 = ref23.length; i14 < len11; i14++) {
|
|
8555
8607
|
const decl = ref23[i14];
|
|
8556
8608
|
if (!decl.names?.length) {
|
|
8557
8609
|
continue;
|
|
@@ -8565,7 +8617,7 @@ function processRepl(root, rootIIFE) {
|
|
|
8565
8617
|
root.expressions.splice(i++, 0, ["", `var ${decl.names.join(",")}`, ";"]);
|
|
8566
8618
|
}
|
|
8567
8619
|
}
|
|
8568
|
-
for (let ref24 = gatherRecursive(topBlock, ($
|
|
8620
|
+
for (let ref24 = gatherRecursive(topBlock, ($23) => $23.type === "FunctionExpression"), i15 = 0, len12 = ref24.length; i15 < len12; i15++) {
|
|
8569
8621
|
const func = ref24[i15];
|
|
8570
8622
|
if (func.name && func.parent?.type === "BlockStatement") {
|
|
8571
8623
|
if (func.parent === topBlock) {
|
|
@@ -8578,7 +8630,7 @@ function processRepl(root, rootIIFE) {
|
|
|
8578
8630
|
}
|
|
8579
8631
|
}
|
|
8580
8632
|
}
|
|
8581
|
-
for (let ref25 = gatherRecursiveWithinFunction(topBlock, ($
|
|
8633
|
+
for (let ref25 = gatherRecursiveWithinFunction(topBlock, ($24) => $24.type === "ClassExpression"), i16 = 0, len13 = ref25.length; i16 < len13; i16++) {
|
|
8582
8634
|
const classExp = ref25[i16];
|
|
8583
8635
|
let m8;
|
|
8584
8636
|
if (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)) {
|
|
@@ -8590,7 +8642,7 @@ function processRepl(root, rootIIFE) {
|
|
|
8590
8642
|
function processPlaceholders(statements) {
|
|
8591
8643
|
const placeholderMap = /* @__PURE__ */ new Map();
|
|
8592
8644
|
const liftedIfs = /* @__PURE__ */ new Set();
|
|
8593
|
-
for (let ref26 = gatherRecursiveAll(statements, ($
|
|
8645
|
+
for (let ref26 = gatherRecursiveAll(statements, ($25) => $25.type === "Placeholder"), i17 = 0, len14 = ref26.length; i17 < len14; i17++) {
|
|
8594
8646
|
const exp = ref26[i17];
|
|
8595
8647
|
let ancestor;
|
|
8596
8648
|
if (exp.subtype === ".") {
|
|
@@ -9978,7 +10030,7 @@ var $R9 = (0, import_lib2.$R)(new RegExp("(?=[\\/?])", "suy"));
|
|
|
9978
10030
|
var $R10 = (0, import_lib2.$R)(new RegExp("(?=[\\/\\[{?.!@#'\u2019:])", "suy"));
|
|
9979
10031
|
var $R11 = (0, import_lib2.$R)(new RegExp("%%?", "suy"));
|
|
9980
10032
|
var $R12 = (0, import_lib2.$R)(new RegExp("[.\\s]", "suy"));
|
|
9981
|
-
var $R13 = (0, import_lib2.$R)(new RegExp("[)}]", "suy"));
|
|
10033
|
+
var $R13 = (0, import_lib2.$R)(new RegExp("[)\\]}]", "suy"));
|
|
9982
10034
|
var $R14 = (0, import_lib2.$R)(new RegExp("[+-]", "suy"));
|
|
9983
10035
|
var $R15 = (0, import_lib2.$R)(new RegExp("\\+\\+|--|\u29FA|\u2014|[\\+\\-&]\\S", "suy"));
|
|
9984
10036
|
var $R16 = (0, import_lib2.$R)(new RegExp(`(?=[0-9.'"tfyno])`, "suy"));
|
|
@@ -11358,7 +11410,20 @@ var NestedClassElement$0 = (0, import_lib2.$S)(Nested, ClassElement, StatementDe
|
|
|
11358
11410
|
function NestedClassElement(ctx, state2) {
|
|
11359
11411
|
return (0, import_lib2.$EVENT)(ctx, state2, "NestedClassElement", NestedClassElement$0);
|
|
11360
11412
|
}
|
|
11361
|
-
var ClassElement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(Decorators), (0, import_lib2.$E)((0, import_lib2.$S)(Declare, (0, import_lib2.$E)(_))), (0, import_lib2.$E)(AccessModifier), (0, import_lib2.$E)((0, import_lib2.$S)(Static, (0, import_lib2.$E)(_))), (0, import_lib2.$E)((0, import_lib2.$S)(Override, (0, import_lib2.$E)(_))),
|
|
11413
|
+
var ClassElement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(CoffeeClassesEnabled, (0, import_lib2.$E)(Decorators), (0, import_lib2.$E)((0, import_lib2.$S)(Declare, (0, import_lib2.$E)(_))), (0, import_lib2.$E)(AccessModifier), (0, import_lib2.$E)((0, import_lib2.$S)(Static, (0, import_lib2.$E)(_))), (0, import_lib2.$E)((0, import_lib2.$S)(Override, (0, import_lib2.$E)(_))), ActualAssignment), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
|
|
11414
|
+
var decorators = $2;
|
|
11415
|
+
var declare = $3;
|
|
11416
|
+
var access = $4;
|
|
11417
|
+
var static_ = $5;
|
|
11418
|
+
var override = $6;
|
|
11419
|
+
var assignment = $7;
|
|
11420
|
+
return {
|
|
11421
|
+
type: static_ ? "CoffeeClassPublic" : "CoffeeClassPrivate",
|
|
11422
|
+
children: [decorators, declare, access, static_, override, assignment],
|
|
11423
|
+
assignment
|
|
11424
|
+
};
|
|
11425
|
+
});
|
|
11426
|
+
var ClassElement$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(Decorators), (0, import_lib2.$E)((0, import_lib2.$S)(Declare, (0, import_lib2.$E)(_))), (0, import_lib2.$E)(AccessModifier), (0, import_lib2.$E)((0, import_lib2.$S)(Static, (0, import_lib2.$E)(_))), (0, import_lib2.$E)((0, import_lib2.$S)(Override, (0, import_lib2.$E)(_))), ClassElementDefinition), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
11362
11427
|
var decorators = $1;
|
|
11363
11428
|
var declare = $2;
|
|
11364
11429
|
var access = $3;
|
|
@@ -11384,14 +11449,14 @@ var ClassElement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E
|
|
|
11384
11449
|
children: [decorators, declare, access, static_, override, ...definition.children]
|
|
11385
11450
|
};
|
|
11386
11451
|
});
|
|
11387
|
-
var ClassElement$
|
|
11452
|
+
var ClassElement$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(Static, BracedBlock), function($skip, $loc, $0, $1, $2) {
|
|
11388
11453
|
return {
|
|
11389
11454
|
type: "ClassStaticBlock",
|
|
11390
11455
|
children: $0
|
|
11391
11456
|
};
|
|
11392
11457
|
});
|
|
11393
|
-
var ClassElement$
|
|
11394
|
-
var ClassElement$$ = [ClassElement$0, ClassElement$1, ClassElement$2];
|
|
11458
|
+
var ClassElement$3 = EmptyStatement;
|
|
11459
|
+
var ClassElement$$ = [ClassElement$0, ClassElement$1, ClassElement$2, ClassElement$3];
|
|
11395
11460
|
function ClassElement(ctx, state2) {
|
|
11396
11461
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "ClassElement", ClassElement$$);
|
|
11397
11462
|
}
|
|
@@ -11444,37 +11509,10 @@ var FieldDefinition$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(CoffeeClassesEn
|
|
|
11444
11509
|
var exp = $6;
|
|
11445
11510
|
switch (exp.type) {
|
|
11446
11511
|
case "FunctionExpression": {
|
|
11447
|
-
|
|
11448
|
-
const children = exp.children.slice();
|
|
11449
|
-
if (exp.generator) {
|
|
11450
|
-
children.splice(fnTokenIndex, 2, children[fnTokenIndex + 1], id);
|
|
11451
|
-
} else {
|
|
11452
|
-
children.splice(fnTokenIndex, 1, id);
|
|
11453
|
-
}
|
|
11454
|
-
return {
|
|
11455
|
-
...exp,
|
|
11456
|
-
type: "MethodDefinition",
|
|
11457
|
-
name: id.name,
|
|
11458
|
-
signature: { ...exp.signature, id, name: id.name },
|
|
11459
|
-
children
|
|
11460
|
-
};
|
|
11512
|
+
return convertFunctionToMethod(id, exp);
|
|
11461
11513
|
}
|
|
11462
11514
|
case "ArrowFunction": {
|
|
11463
|
-
|
|
11464
|
-
const children = exp.children.filter((c) => !(Array.isArray(c) && c[c.length - 1]?.token?.includes("=>"))).map((c) => c === exp.block ? block : c);
|
|
11465
|
-
children.unshift(id);
|
|
11466
|
-
exp = {
|
|
11467
|
-
...exp,
|
|
11468
|
-
type: "MethodDefinition",
|
|
11469
|
-
name: id.name,
|
|
11470
|
-
signature: { ...exp.signature, id, name: id.name },
|
|
11471
|
-
block,
|
|
11472
|
-
children,
|
|
11473
|
-
autoBind: true
|
|
11474
|
-
};
|
|
11475
|
-
block.parent = exp;
|
|
11476
|
-
braceBlock(block);
|
|
11477
|
-
return exp;
|
|
11515
|
+
return convertArrowFunctionToMethod(id, exp);
|
|
11478
11516
|
}
|
|
11479
11517
|
default:
|
|
11480
11518
|
return {
|
|
@@ -11501,15 +11539,7 @@ var FieldDefinition$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(InsertReadonly,
|
|
|
11501
11539
|
readonly
|
|
11502
11540
|
};
|
|
11503
11541
|
});
|
|
11504
|
-
var FieldDefinition$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(
|
|
11505
|
-
var assignment = $2;
|
|
11506
|
-
return {
|
|
11507
|
-
type: "CoffeeClassPrivate",
|
|
11508
|
-
children: [assignment],
|
|
11509
|
-
assignment
|
|
11510
|
-
};
|
|
11511
|
-
});
|
|
11512
|
-
var 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) {
|
|
11542
|
+
var FieldDefinition$2 = (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) {
|
|
11513
11543
|
var abstract = $1;
|
|
11514
11544
|
var readonly = $2;
|
|
11515
11545
|
var id = $3;
|
|
@@ -11526,7 +11556,7 @@ var FieldDefinition$3 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2
|
|
|
11526
11556
|
initializer
|
|
11527
11557
|
};
|
|
11528
11558
|
});
|
|
11529
|
-
var FieldDefinition$$ = [FieldDefinition$0, FieldDefinition$1, FieldDefinition$2
|
|
11559
|
+
var FieldDefinition$$ = [FieldDefinition$0, FieldDefinition$1, FieldDefinition$2];
|
|
11530
11560
|
function FieldDefinition(ctx, state2) {
|
|
11531
11561
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "FieldDefinition", FieldDefinition$$);
|
|
11532
11562
|
}
|
|
@@ -12297,7 +12327,7 @@ function ParameterElement(ctx, state2) {
|
|
|
12297
12327
|
return (0, import_lib2.$EVENT)(ctx, state2, "ParameterElement", ParameterElement$0);
|
|
12298
12328
|
}
|
|
12299
12329
|
var ParameterElementDelimiter$0 = (0, import_lib2.$S)((0, import_lib2.$E)(_), Comma);
|
|
12300
|
-
var ParameterElementDelimiter$1 = (0, import_lib2.$Y)((0, import_lib2.$S)(__, (0, import_lib2.$R$0)((0, import_lib2.$EXPECT)($R13, "ParameterElementDelimiter /[)}]/"))));
|
|
12330
|
+
var ParameterElementDelimiter$1 = (0, import_lib2.$Y)((0, import_lib2.$S)(__, (0, import_lib2.$R$0)((0, import_lib2.$EXPECT)($R13, "ParameterElementDelimiter /[)\\]}]/"))));
|
|
12301
12331
|
var ParameterElementDelimiter$2 = (0, import_lib2.$T)((0, import_lib2.$S)((0, import_lib2.$Y)(EOS), InsertComma), function(value) {
|
|
12302
12332
|
return value[1];
|
|
12303
12333
|
});
|
|
@@ -12962,7 +12992,7 @@ var OperatorDeclaration$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Operator, (
|
|
|
12962
12992
|
var behavior = $2;
|
|
12963
12993
|
var w = $3;
|
|
12964
12994
|
var decl = $4;
|
|
12965
|
-
decl.names.forEach((name) =>
|
|
12995
|
+
decl.names.forEach((name) => setOperatorBehavior(name, behavior));
|
|
12966
12996
|
if (behavior?.error) decl = prepend(behavior.error, decl);
|
|
12967
12997
|
decl = prepend(trimFirstSpace(w), decl);
|
|
12968
12998
|
return decl;
|
|
@@ -12970,7 +13000,7 @@ var OperatorDeclaration$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Operator, (
|
|
|
12970
13000
|
var OperatorDeclaration$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(OperatorSignature, BracedBlock), function($skip, $loc, $0, $1, $2) {
|
|
12971
13001
|
var signature = $1;
|
|
12972
13002
|
var block = $2;
|
|
12973
|
-
|
|
13003
|
+
setOperatorBehavior(signature.id.name, signature.behavior);
|
|
12974
13004
|
return {
|
|
12975
13005
|
...signature,
|
|
12976
13006
|
type: "FunctionExpression",
|
|
@@ -12987,10 +13017,10 @@ var OperatorDeclaration$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(Operator, _
|
|
|
12987
13017
|
var behavior = $4;
|
|
12988
13018
|
var ids = $5;
|
|
12989
13019
|
const children = [];
|
|
12990
|
-
|
|
13020
|
+
setOperatorBehavior(id.name, behavior);
|
|
12991
13021
|
if (behavior?.error) children.push(behavior.error);
|
|
12992
13022
|
ids.forEach(([, , id2, behavior2]) => {
|
|
12993
|
-
|
|
13023
|
+
setOperatorBehavior(id2.name, behavior2);
|
|
12994
13024
|
if (behavior2?.error) children.push(behavior2.error);
|
|
12995
13025
|
});
|
|
12996
13026
|
return {
|
|
@@ -14233,7 +14263,7 @@ function InlineObjectPropertyDelimiter(ctx, state2) {
|
|
|
14233
14263
|
return (0, import_lib2.$EVENT)(ctx, state2, "InlineObjectPropertyDelimiter", InlineObjectPropertyDelimiter$0);
|
|
14234
14264
|
}
|
|
14235
14265
|
var ObjectPropertyDelimiter$0 = (0, import_lib2.$S)((0, import_lib2.$E)(_), Comma);
|
|
14236
|
-
var ObjectPropertyDelimiter$1 = (0, import_lib2.$Y)((0, import_lib2.$S)(__, (0, import_lib2.$EXPECT)($
|
|
14266
|
+
var ObjectPropertyDelimiter$1 = (0, import_lib2.$Y)((0, import_lib2.$S)(__, (0, import_lib2.$R$0)((0, import_lib2.$EXPECT)($R13, "ObjectPropertyDelimiter /[)\\]}]/"))));
|
|
14237
14267
|
var ObjectPropertyDelimiter$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$Y)(EOS), InsertComma), function($skip, $loc, $0, $1, $2) {
|
|
14238
14268
|
return { ...$2, implicit: true };
|
|
14239
14269
|
});
|
|
@@ -16723,7 +16753,7 @@ var ImportDeclaration$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_li
|
|
|
16723
16753
|
const errors = [];
|
|
16724
16754
|
if (behavior?.error) errors.push(behavior.error);
|
|
16725
16755
|
imports.specifiers.forEach((spec) => {
|
|
16726
|
-
|
|
16756
|
+
setOperatorBehavior(spec.binding.name, spec.behavior ?? behavior);
|
|
16727
16757
|
if (spec.behavior?.error) errors.push(spec.behavior.error);
|
|
16728
16758
|
});
|
|
16729
16759
|
return {
|
|
@@ -16774,7 +16804,7 @@ var ImportDeclaration$5 = (0, import_lib2.$TS)((0, import_lib2.$S)(FromClause, _
|
|
|
16774
16804
|
const errors = [];
|
|
16775
16805
|
if (behavior?.error) errors.push(behavior.error);
|
|
16776
16806
|
imports.specifiers.forEach((spec) => {
|
|
16777
|
-
|
|
16807
|
+
setOperatorBehavior(spec.binding.name, spec.behavior ?? behavior);
|
|
16778
16808
|
if (spec.behavior?.error) errors.push(spec.behavior.error);
|
|
16779
16809
|
});
|
|
16780
16810
|
return {
|
|
@@ -16906,7 +16936,7 @@ var TypeAndImportSpecifier$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(__, Oper
|
|
|
16906
16936
|
if (spec.binding.type !== "Identifier") {
|
|
16907
16937
|
throw new Error("Expected identifier after `operator`");
|
|
16908
16938
|
}
|
|
16909
|
-
|
|
16939
|
+
setOperatorBehavior(spec.binding.name, spec.behavior);
|
|
16910
16940
|
return {
|
|
16911
16941
|
...spec,
|
|
16912
16942
|
children: [
|
|
@@ -20502,6 +20532,7 @@ var CivetOption$0 = (0, import_lib2.$TR)((0, import_lib2.$EXPECT)($R99, "CivetOp
|
|
|
20502
20532
|
break;
|
|
20503
20533
|
case "globals":
|
|
20504
20534
|
case "symbols":
|
|
20535
|
+
case "operators":
|
|
20505
20536
|
value = value.split(",").filter(Boolean);
|
|
20506
20537
|
break;
|
|
20507
20538
|
}
|
|
@@ -20910,6 +20941,36 @@ var Reset$0 = (0, import_lib2.$TV)((0, import_lib2.$EXPECT)($L0, 'Reset ""'), fu
|
|
|
20910
20941
|
}
|
|
20911
20942
|
}
|
|
20912
20943
|
});
|
|
20944
|
+
Object.defineProperty(config, "operators", {
|
|
20945
|
+
set(o) {
|
|
20946
|
+
if (!o) return;
|
|
20947
|
+
if (typeof o !== "object") {
|
|
20948
|
+
throw new Error("operators configuration must be an object or array");
|
|
20949
|
+
}
|
|
20950
|
+
if (Array.isArray(o)) {
|
|
20951
|
+
o.forEach((name) => {
|
|
20952
|
+
if (typeof name !== "string") {
|
|
20953
|
+
throw new Error("operators configuration array must contain only strings");
|
|
20954
|
+
}
|
|
20955
|
+
setOperatorBehavior(name, void 0);
|
|
20956
|
+
});
|
|
20957
|
+
} else {
|
|
20958
|
+
for (let [name, behavior] of Object.entries(o)) {
|
|
20959
|
+
if (typeof behavior === "string") {
|
|
20960
|
+
behavior = behavior.trim();
|
|
20961
|
+
behavior = behavior ? parse(behavior, {
|
|
20962
|
+
startRule: "OperatorBehavior",
|
|
20963
|
+
filename: `operator config for ${name}`
|
|
20964
|
+
}) : void 0;
|
|
20965
|
+
}
|
|
20966
|
+
if (behavior && typeof behavior !== "object") {
|
|
20967
|
+
throw new Error("operators configuration object must have string or object values");
|
|
20968
|
+
}
|
|
20969
|
+
setOperatorBehavior(name, behavior);
|
|
20970
|
+
}
|
|
20971
|
+
}
|
|
20972
|
+
}
|
|
20973
|
+
});
|
|
20913
20974
|
Object.assign(config, initialConfig);
|
|
20914
20975
|
});
|
|
20915
20976
|
function Reset(ctx, state2) {
|
|
@@ -21041,26 +21102,24 @@ var PushExtraIndent1$0 = (0, import_lib2.$TV)((0, import_lib2.$EXPECT)($L0, 'Pus
|
|
|
21041
21102
|
function PushExtraIndent1(ctx, state2) {
|
|
21042
21103
|
return (0, import_lib2.$EVENT)(ctx, state2, "PushExtraIndent1", PushExtraIndent1$0);
|
|
21043
21104
|
}
|
|
21044
|
-
var parser =
|
|
21045
|
-
|
|
21046
|
-
|
|
21047
|
-
|
|
21048
|
-
|
|
21049
|
-
|
|
21050
|
-
|
|
21051
|
-
|
|
21052
|
-
|
|
21053
|
-
|
|
21054
|
-
|
|
21055
|
-
|
|
21056
|
-
|
|
21057
|
-
|
|
21058
|
-
|
|
21059
|
-
|
|
21060
|
-
|
|
21061
|
-
|
|
21062
|
-
};
|
|
21063
|
-
}();
|
|
21105
|
+
var parser = {
|
|
21106
|
+
parse: (input, options = {}) => {
|
|
21107
|
+
const { fail, validate, reset } = (0, import_lib2.Validator)();
|
|
21108
|
+
let ctx = { expectation: "", fail };
|
|
21109
|
+
if (typeof input !== "string") throw new Error("Input must be a string");
|
|
21110
|
+
const parser2 = options.startRule != null ? grammar[options.startRule] : Object.values(grammar)[0];
|
|
21111
|
+
if (!parser2) throw new Error(`Could not find rule with name '${options.startRule}'`);
|
|
21112
|
+
const filename2 = options.filename || "<anonymous>";
|
|
21113
|
+
reset();
|
|
21114
|
+
Object.assign(ctx, { ...options.events, tokenize: options.tokenize });
|
|
21115
|
+
return validate(input, parser2(ctx, {
|
|
21116
|
+
input,
|
|
21117
|
+
pos: 0
|
|
21118
|
+
}), {
|
|
21119
|
+
filename: filename2
|
|
21120
|
+
});
|
|
21121
|
+
}
|
|
21122
|
+
};
|
|
21064
21123
|
var { parse } = parser;
|
|
21065
21124
|
var filename;
|
|
21066
21125
|
var initialConfig;
|
|
@@ -21139,6 +21198,14 @@ Object.defineProperties(state, {
|
|
|
21139
21198
|
}
|
|
21140
21199
|
}
|
|
21141
21200
|
});
|
|
21201
|
+
function setOperatorBehavior(name, behavior) {
|
|
21202
|
+
const existing = state.operators.get(name);
|
|
21203
|
+
if (existing && behavior) {
|
|
21204
|
+
state.operators.set(name, { ...existing, ...behavior });
|
|
21205
|
+
} else {
|
|
21206
|
+
state.operators.set(name, behavior || existing);
|
|
21207
|
+
}
|
|
21208
|
+
}
|
|
21142
21209
|
function getStateKey() {
|
|
21143
21210
|
const stateInt = state.currentIndent.level % 256 << 8 | state.classImplicitCallForbidden << 7 | state.indentedApplicationForbidden << 6 | state.bracedApplicationForbidden << 5 | state.trailingMemberPropertyForbidden << 4 | state.nestedBinaryOpForbidden << 3 | state.newlineBinaryOpForbidden << 2 | state.pipelineForbidden << 1 | // This is slightly different than the rest of the state,
|
|
21144
21211
|
// since it is affected by the directive prologue and may be hit
|
|
@@ -21179,11 +21246,12 @@ var wellKnownSymbols = [
|
|
|
21179
21246
|
"unscopables"
|
|
21180
21247
|
];
|
|
21181
21248
|
|
|
21182
|
-
// unplugin-civet
|
|
21249
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\sourcemap.civet.jsx
|
|
21183
21250
|
var sourcemap_civet_exports = {};
|
|
21184
21251
|
__export(sourcemap_civet_exports, {
|
|
21185
21252
|
SourceMap: () => SourceMap,
|
|
21186
21253
|
base64Encode: () => base64Encode,
|
|
21254
|
+
decodeVLQ: () => decodeVLQ,
|
|
21187
21255
|
locationTable: () => locationTable,
|
|
21188
21256
|
lookupLineColumn: () => lookupLineColumn
|
|
21189
21257
|
});
|
|
@@ -21219,7 +21287,6 @@ var SourceMap = class {
|
|
|
21219
21287
|
// relative to previous entry
|
|
21220
21288
|
srcLine;
|
|
21221
21289
|
srcColumn;
|
|
21222
|
-
srcOffset;
|
|
21223
21290
|
srcTable;
|
|
21224
21291
|
source;
|
|
21225
21292
|
constructor(source1) {
|
|
@@ -21229,7 +21296,6 @@ var SourceMap = class {
|
|
|
21229
21296
|
this.colOffset = 0;
|
|
21230
21297
|
this.srcLine = 0;
|
|
21231
21298
|
this.srcColumn = 0;
|
|
21232
|
-
this.srcOffset = 0;
|
|
21233
21299
|
this.srcTable = locationTable(this.source);
|
|
21234
21300
|
}
|
|
21235
21301
|
renderMappings() {
|
|
@@ -21273,6 +21339,10 @@ var SourceMap = class {
|
|
|
21273
21339
|
}
|
|
21274
21340
|
};
|
|
21275
21341
|
}
|
|
21342
|
+
/** Generate a comment with the source mapping URL. */
|
|
21343
|
+
comment(srcFileName, outFileName) {
|
|
21344
|
+
return `//${"#"} sourceMappingURL=data:application/json;base64,${base64Encode(JSON.stringify(this.json(srcFileName, outFileName)))}`;
|
|
21345
|
+
}
|
|
21276
21346
|
updateSourceMap(outputStr, inputPos, colOffset = 0) {
|
|
21277
21347
|
const outLines = outputStr.split(EOL2);
|
|
21278
21348
|
let srcLine, srcCol;
|
|
@@ -21281,7 +21351,6 @@ var SourceMap = class {
|
|
|
21281
21351
|
srcCol += colOffset;
|
|
21282
21352
|
this.srcLine = srcLine;
|
|
21283
21353
|
this.srcColumn = srcCol;
|
|
21284
|
-
this.srcOffset = inputPos + outputStr.length;
|
|
21285
21354
|
}
|
|
21286
21355
|
for (let i3 = 0, len22 = outLines.length; i3 < len22; i3++) {
|
|
21287
21356
|
const i = i3;
|
|
@@ -21304,74 +21373,85 @@ var SourceMap = class {
|
|
|
21304
21373
|
}
|
|
21305
21374
|
return;
|
|
21306
21375
|
}
|
|
21307
|
-
|
|
21308
|
-
|
|
21309
|
-
|
|
21310
|
-
|
|
21311
|
-
|
|
21312
|
-
|
|
21313
|
-
|
|
21314
|
-
|
|
21315
|
-
|
|
21316
|
-
|
|
21317
|
-
const composedLines = composeLines(upstreamMap.lines, parsed.lines);
|
|
21318
|
-
upstreamMap.lines = composedLines;
|
|
21319
|
-
}
|
|
21320
|
-
const remappedSourceMapJSON = upstreamMap.json(sourcePath, targetPath);
|
|
21321
|
-
const newSourceMap = `${"sourceMapping"}URL=data:application/json;charset=utf-8;base64,${base64Encode(JSON.stringify(remappedSourceMapJSON))}`;
|
|
21322
|
-
const remappedCodeWithSourceMap = `${codeWithoutSourceMap}
|
|
21323
|
-
//# ${newSourceMap}`;
|
|
21324
|
-
return remappedCodeWithSourceMap;
|
|
21325
|
-
};
|
|
21326
|
-
var composeLines = function(upstreamMapping, lines) {
|
|
21327
|
-
return lines.map((line) => {
|
|
21328
|
-
return line.map((entry) => {
|
|
21329
|
-
if (entry.length === 1) {
|
|
21330
|
-
return entry;
|
|
21331
|
-
}
|
|
21332
|
-
const [colDelta, sourceFileIndex, srcLine, srcCol] = entry;
|
|
21333
|
-
const srcPos = remapPosition([srcLine, srcCol], upstreamMapping);
|
|
21334
|
-
if (!srcPos) {
|
|
21335
|
-
return [entry[0]];
|
|
21336
|
-
}
|
|
21337
|
-
const [upstreamLine, upstreamCol] = srcPos;
|
|
21338
|
-
if (entry.length === 4) {
|
|
21339
|
-
return [colDelta, sourceFileIndex, upstreamLine, upstreamCol];
|
|
21340
|
-
}
|
|
21341
|
-
return [colDelta, sourceFileIndex, upstreamLine, upstreamCol, entry[4]];
|
|
21376
|
+
/**
|
|
21377
|
+
Remap a string with compiled code and a source map to use a new source map
|
|
21378
|
+
referencing upstream source files.
|
|
21379
|
+
This modifies the upstream map in place.
|
|
21380
|
+
*/
|
|
21381
|
+
static remap = (codeWithSourceMap, upstreamMap, sourcePath, targetPath) => {
|
|
21382
|
+
let sourceMapText;
|
|
21383
|
+
const codeWithoutSourceMap = codeWithSourceMap.replace(smRegexp, (_match, sm) => {
|
|
21384
|
+
sourceMapText = sm;
|
|
21385
|
+
return "";
|
|
21342
21386
|
});
|
|
21343
|
-
|
|
21344
|
-
|
|
21345
|
-
|
|
21346
|
-
|
|
21347
|
-
let sourceLine = 0;
|
|
21348
|
-
let sourceColumn = 0;
|
|
21349
|
-
const lines = json.mappings.split(";").map((line) => {
|
|
21350
|
-
if (line.length === 0) {
|
|
21351
|
-
return [];
|
|
21387
|
+
if (sourceMapText) {
|
|
21388
|
+
const parsed = this.parseWithLines(sourceMapText);
|
|
21389
|
+
const composedLines = this.composeLines(upstreamMap.lines, parsed.lines);
|
|
21390
|
+
upstreamMap.lines = composedLines;
|
|
21352
21391
|
}
|
|
21353
|
-
|
|
21354
|
-
|
|
21355
|
-
|
|
21356
|
-
|
|
21357
|
-
|
|
21358
|
-
|
|
21359
|
-
|
|
21360
|
-
|
|
21392
|
+
const remappedCodeWithSourceMap = `${codeWithoutSourceMap}
|
|
21393
|
+
${upstreamMap.comment(sourcePath, targetPath)}`;
|
|
21394
|
+
return remappedCodeWithSourceMap;
|
|
21395
|
+
};
|
|
21396
|
+
/**
|
|
21397
|
+
Compose lines from an upstream source map with lines from a downstream source map.
|
|
21398
|
+
*/
|
|
21399
|
+
static composeLines = (upstreamMapping, lines) => {
|
|
21400
|
+
return lines.map((line) => {
|
|
21401
|
+
return line.map((entry) => {
|
|
21402
|
+
if (entry.length === 1) {
|
|
21403
|
+
return entry;
|
|
21361
21404
|
}
|
|
21362
|
-
|
|
21363
|
-
|
|
21405
|
+
const [colDelta, sourceFileIndex, srcLine, srcCol] = entry;
|
|
21406
|
+
const srcPos = remapPosition([srcLine, srcCol], upstreamMapping);
|
|
21407
|
+
if (!srcPos) {
|
|
21408
|
+
return [entry[0]];
|
|
21364
21409
|
}
|
|
21365
|
-
|
|
21366
|
-
|
|
21410
|
+
const [upstreamLine, upstreamCol] = srcPos;
|
|
21411
|
+
if (entry.length === 4) {
|
|
21412
|
+
return [colDelta, sourceFileIndex, upstreamLine, upstreamCol];
|
|
21367
21413
|
}
|
|
21414
|
+
return [colDelta, sourceFileIndex, upstreamLine, upstreamCol, entry[4]];
|
|
21415
|
+
});
|
|
21416
|
+
});
|
|
21417
|
+
};
|
|
21418
|
+
/**
|
|
21419
|
+
Parse a base64 encoded source map string into a SourceMapJSON object with lines.
|
|
21420
|
+
*/
|
|
21421
|
+
static parseWithLines = (base64encodedJSONstr) => {
|
|
21422
|
+
const json = JSON.parse(Buffer.from(base64encodedJSONstr, "base64").toString("utf8"));
|
|
21423
|
+
let sourceLine = 0;
|
|
21424
|
+
let sourceColumn = 0;
|
|
21425
|
+
const lines = json.mappings.split(";").map((line) => {
|
|
21426
|
+
if (line.length === 0) {
|
|
21427
|
+
return [];
|
|
21368
21428
|
}
|
|
21429
|
+
return line.split(",").map((entry) => {
|
|
21430
|
+
const result = decodeVLQ(entry);
|
|
21431
|
+
switch (result.length) {
|
|
21432
|
+
case 1: {
|
|
21433
|
+
;
|
|
21434
|
+
break;
|
|
21435
|
+
}
|
|
21436
|
+
case 4:
|
|
21437
|
+
case 5: {
|
|
21438
|
+
sourceLine += result[2];
|
|
21439
|
+
result[2] = sourceLine;
|
|
21440
|
+
sourceColumn += result[3];
|
|
21441
|
+
result[3] = sourceColumn;
|
|
21442
|
+
break;
|
|
21443
|
+
}
|
|
21444
|
+
default: {
|
|
21445
|
+
throw new Error(`Unknown source map entry ${JSON.stringify(result)}`);
|
|
21446
|
+
}
|
|
21447
|
+
}
|
|
21448
|
+
return result;
|
|
21449
|
+
});
|
|
21369
21450
|
});
|
|
21370
|
-
|
|
21371
|
-
|
|
21372
|
-
return json;
|
|
21451
|
+
return { ...json, lines };
|
|
21452
|
+
};
|
|
21373
21453
|
};
|
|
21374
|
-
|
|
21454
|
+
var smRegexp = /(?:\r?\n|\r)\/\/# sourceMappingURL=data:application\/json;(?:charset=[^;]*;)?base64,([+a-zA-Z0-9\/]*=?=?)(?:\s*)$/;
|
|
21375
21455
|
var VLQ_SHIFT = 5;
|
|
21376
21456
|
var VLQ_CONTINUATION_BIT = 1 << VLQ_SHIFT;
|
|
21377
21457
|
var VLQ_VALUE_MASK = VLQ_CONTINUATION_BIT - 1;
|
|
@@ -21388,21 +21468,18 @@ var encodeVlq = function(value) {
|
|
|
21388
21468
|
if (valueToEncode) {
|
|
21389
21469
|
nextChunk |= VLQ_CONTINUATION_BIT;
|
|
21390
21470
|
}
|
|
21391
|
-
answer +=
|
|
21471
|
+
answer += BASE64_CHARS[nextChunk];
|
|
21392
21472
|
}
|
|
21393
21473
|
return answer;
|
|
21394
21474
|
};
|
|
21395
21475
|
var BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
21396
|
-
var encodeBase64 = function(value) {
|
|
21397
|
-
return BASE64_CHARS[value] || (() => {
|
|
21398
|
-
throw new Error("Cannot Base64 encode value: ${value}");
|
|
21399
|
-
})();
|
|
21400
|
-
};
|
|
21401
21476
|
var base64Encode = function(src) {
|
|
21402
21477
|
if (typeof Buffer !== "undefined") {
|
|
21403
21478
|
return Buffer.from(src).toString("base64");
|
|
21404
21479
|
} else {
|
|
21405
|
-
|
|
21480
|
+
const bytes = new TextEncoder().encode(src);
|
|
21481
|
+
const binaryString = String.fromCodePoint(...bytes);
|
|
21482
|
+
return btoa(binaryString);
|
|
21406
21483
|
}
|
|
21407
21484
|
};
|
|
21408
21485
|
var vlqTable = new Uint8Array(128);
|
|
@@ -21424,7 +21501,7 @@ var vlqChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
|
|
|
21424
21501
|
var decodeError = function(message) {
|
|
21425
21502
|
throw new Error(message);
|
|
21426
21503
|
};
|
|
21427
|
-
var decodeVLQ =
|
|
21504
|
+
var decodeVLQ = (mapping) => {
|
|
21428
21505
|
let i = 0;
|
|
21429
21506
|
let l = mapping.length;
|
|
21430
21507
|
let result = [];
|
|
@@ -21438,11 +21515,11 @@ var decodeVLQ = function(mapping) {
|
|
|
21438
21515
|
}
|
|
21439
21516
|
const c = mapping.charCodeAt(i);
|
|
21440
21517
|
if ((c & 127) != c) {
|
|
21441
|
-
decodeError(
|
|
21518
|
+
decodeError(`Invalid mapping character: ${JSON.stringify(String.fromCharCode(c))}`);
|
|
21442
21519
|
}
|
|
21443
21520
|
const index = vlqTable[c & 127];
|
|
21444
21521
|
if (index === 255) {
|
|
21445
|
-
decodeError(
|
|
21522
|
+
decodeError(`Invalid mapping character: ${JSON.stringify(String.fromCharCode(c))}`);
|
|
21446
21523
|
}
|
|
21447
21524
|
i++;
|
|
21448
21525
|
vlq |= (index & 31) << shift;
|
|
@@ -21460,7 +21537,7 @@ var decodeVLQ = function(mapping) {
|
|
|
21460
21537
|
}
|
|
21461
21538
|
return result;
|
|
21462
21539
|
};
|
|
21463
|
-
var remapPosition =
|
|
21540
|
+
var remapPosition = (position, sourcemapLines) => {
|
|
21464
21541
|
const [line, character] = position;
|
|
21465
21542
|
const textLine = sourcemapLines[line];
|
|
21466
21543
|
if (!textLine?.length) {
|
|
@@ -21493,7 +21570,7 @@ var remapPosition = function(position, sourcemapLines) {
|
|
|
21493
21570
|
}
|
|
21494
21571
|
};
|
|
21495
21572
|
|
|
21496
|
-
// unplugin-civet
|
|
21573
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\state-cache.civet.jsx
|
|
21497
21574
|
var StateCache = class {
|
|
21498
21575
|
cache = /* @__PURE__ */ new Map();
|
|
21499
21576
|
get(key) {
|
|
@@ -21533,7 +21610,7 @@ var StateCache = class {
|
|
|
21533
21610
|
}
|
|
21534
21611
|
};
|
|
21535
21612
|
|
|
21536
|
-
// unplugin-civet
|
|
21613
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\worker-pool.civet.jsx
|
|
21537
21614
|
var WorkerPool = class {
|
|
21538
21615
|
idle;
|
|
21539
21616
|
spawned;
|
|
@@ -21635,7 +21712,7 @@ var WorkerPool = class {
|
|
|
21635
21712
|
}
|
|
21636
21713
|
};
|
|
21637
21714
|
|
|
21638
|
-
// unplugin-civet
|
|
21715
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\main.civet.jsx
|
|
21639
21716
|
var { SourceMap: SourceMap2 } = sourcemap_civet_exports;
|
|
21640
21717
|
var ParseErrors = class extends Error {
|
|
21641
21718
|
name = "ParseErrors";
|
|
@@ -21695,7 +21772,32 @@ var uncacheable = /* @__PURE__ */ new Set([
|
|
|
21695
21772
|
"RestorePipeline"
|
|
21696
21773
|
]);
|
|
21697
21774
|
var workerPool;
|
|
21775
|
+
function decode(src) {
|
|
21776
|
+
if (typeof src === "string") {
|
|
21777
|
+
return src;
|
|
21778
|
+
}
|
|
21779
|
+
if (typeof Buffer === "undefined") {
|
|
21780
|
+
return src;
|
|
21781
|
+
}
|
|
21782
|
+
if (!Buffer?.isBuffer(src)) {
|
|
21783
|
+
return src;
|
|
21784
|
+
}
|
|
21785
|
+
if (src[0] === 239 && src[1] === 187 && src[2] === 191) {
|
|
21786
|
+
return src.toString("utf8", 3);
|
|
21787
|
+
} else if (src[0] === 255 && src[1] === 254) {
|
|
21788
|
+
return src.toString("utf16le", 2);
|
|
21789
|
+
} else if (src[0] === 254 && src[1] === 255) {
|
|
21790
|
+
for (let end = src.length - 2, i1 = 2; i1 <= end; i1 += 2) {
|
|
21791
|
+
const i = i1;
|
|
21792
|
+
[src[i], src[i + 1]] = [src[i + 1], src[i]];
|
|
21793
|
+
}
|
|
21794
|
+
return src.toString("utf16le", 2);
|
|
21795
|
+
} else {
|
|
21796
|
+
return src.toString("utf8");
|
|
21797
|
+
}
|
|
21798
|
+
}
|
|
21698
21799
|
function compile(src, options) {
|
|
21800
|
+
src = decode(src);
|
|
21699
21801
|
if (!(process.env.CIVET_THREADS == 0)) {
|
|
21700
21802
|
const threads = parseInt(options?.threads ?? process.env.CIVET_THREADS, 10);
|
|
21701
21803
|
if (threads === 0) {
|
|
@@ -21793,7 +21895,8 @@ ${counts}`;
|
|
|
21793
21895
|
const code = generate_civet_default(ast2, options);
|
|
21794
21896
|
checkErrors();
|
|
21795
21897
|
if (options.inlineMap) {
|
|
21796
|
-
return
|
|
21898
|
+
return `${code}
|
|
21899
|
+
${options.sourceMap.comment(filename2, filename2 + ".tsx")}`;
|
|
21797
21900
|
} else {
|
|
21798
21901
|
return {
|
|
21799
21902
|
code,
|
|
@@ -21891,6 +21994,7 @@ export {
|
|
|
21891
21994
|
ParseErrors,
|
|
21892
21995
|
SourceMap2 as SourceMap,
|
|
21893
21996
|
compile,
|
|
21997
|
+
decode,
|
|
21894
21998
|
main_civet_default as default,
|
|
21895
21999
|
generate_civet_default as generate,
|
|
21896
22000
|
isCompileError,
|