@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.js
CHANGED
|
@@ -29,9 +29,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
29
|
));
|
|
30
30
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
31
|
|
|
32
|
-
//
|
|
32
|
+
// ../Hera/dist/machine.js
|
|
33
33
|
var require_machine = __commonJS({
|
|
34
|
-
"
|
|
34
|
+
"../Hera/dist/machine.js"(exports2, module2) {
|
|
35
35
|
"use strict";
|
|
36
36
|
var __defProp2 = Object.defineProperty;
|
|
37
37
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -483,13 +483,14 @@ ${body}`;
|
|
|
483
483
|
}
|
|
484
484
|
});
|
|
485
485
|
|
|
486
|
-
// unplugin-civet
|
|
486
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\main.civet.jsx
|
|
487
487
|
var main_civet_exports = {};
|
|
488
488
|
__export(main_civet_exports, {
|
|
489
489
|
ParseError: () => import_lib2.ParseError,
|
|
490
490
|
ParseErrors: () => ParseErrors,
|
|
491
491
|
SourceMap: () => SourceMap2,
|
|
492
492
|
compile: () => compile,
|
|
493
|
+
decode: () => decode,
|
|
493
494
|
default: () => main_civet_default,
|
|
494
495
|
generate: () => generate_civet_default,
|
|
495
496
|
isCompileError: () => isCompileError,
|
|
@@ -504,7 +505,7 @@ module.exports = __toCommonJS(main_civet_exports);
|
|
|
504
505
|
// source/parser.hera
|
|
505
506
|
var import_lib2 = __toESM(require_machine());
|
|
506
507
|
|
|
507
|
-
// unplugin-civet
|
|
508
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\lib.civet.jsx
|
|
508
509
|
var lib_civet_exports = {};
|
|
509
510
|
__export(lib_civet_exports, {
|
|
510
511
|
addPostfixStatement: () => addPostfixStatement,
|
|
@@ -515,6 +516,8 @@ __export(lib_civet_exports, {
|
|
|
515
516
|
blockWithPrefix: () => blockWithPrefix,
|
|
516
517
|
braceBlock: () => braceBlock,
|
|
517
518
|
bracedBlock: () => bracedBlock,
|
|
519
|
+
convertArrowFunctionToMethod: () => convertArrowFunctionToMethod,
|
|
520
|
+
convertFunctionToMethod: () => convertFunctionToMethod,
|
|
518
521
|
convertNamedImportsToObject: () => convertNamedImportsToObject,
|
|
519
522
|
convertObjectToJSXAttributes: () => convertObjectToJSXAttributes,
|
|
520
523
|
convertWithClause: () => convertWithClause,
|
|
@@ -584,7 +587,7 @@ __export(lib_civet_exports, {
|
|
|
584
587
|
wrapTypeInPromise: () => wrapTypeInPromise
|
|
585
588
|
});
|
|
586
589
|
|
|
587
|
-
// unplugin-civet
|
|
590
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\util.civet.jsx
|
|
588
591
|
function len(arr, length) {
|
|
589
592
|
return arr.length === length;
|
|
590
593
|
}
|
|
@@ -1585,7 +1588,7 @@ function flatJoin(array, separator) {
|
|
|
1585
1588
|
return result;
|
|
1586
1589
|
}
|
|
1587
1590
|
|
|
1588
|
-
// unplugin-civet
|
|
1591
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\traversal.civet.jsx
|
|
1589
1592
|
function gatherRecursiveWithinFunction(node, predicate) {
|
|
1590
1593
|
return gatherRecursive(node, predicate, isFunction);
|
|
1591
1594
|
}
|
|
@@ -1694,7 +1697,7 @@ function gatherRecursiveAll(node, predicate) {
|
|
|
1694
1697
|
return nodes;
|
|
1695
1698
|
}
|
|
1696
1699
|
|
|
1697
|
-
// unplugin-civet
|
|
1700
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\ref.civet.jsx
|
|
1698
1701
|
var range = (start, end) => {
|
|
1699
1702
|
const length = end - start;
|
|
1700
1703
|
if (length <= 0) return [];
|
|
@@ -1789,7 +1792,7 @@ function populateRefs(statements) {
|
|
|
1789
1792
|
}
|
|
1790
1793
|
}
|
|
1791
1794
|
|
|
1792
|
-
// unplugin-civet
|
|
1795
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\binding.civet.jsx
|
|
1793
1796
|
function adjustAtBindings(statements, asThis = false) {
|
|
1794
1797
|
for (let ref1 = gatherRecursiveAll(statements, ($1) => $1.type === "AtBindingProperty"), i1 = 0, len3 = ref1.length; i1 < len3; i1++) {
|
|
1795
1798
|
const binding = ref1[i1];
|
|
@@ -2056,12 +2059,12 @@ function gatherBindingPatternTypeSuffix(pattern) {
|
|
|
2056
2059
|
return pattern;
|
|
2057
2060
|
}
|
|
2058
2061
|
|
|
2059
|
-
// unplugin-civet
|
|
2062
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\comptime.civet.jsx
|
|
2060
2063
|
var import_node_path = require("node:path");
|
|
2061
2064
|
var import_node_module = require("node:module");
|
|
2062
2065
|
var import_node_vm = __toESM(require("node:vm"));
|
|
2063
2066
|
|
|
2064
|
-
// unplugin-civet
|
|
2067
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\helper.civet.jsx
|
|
2065
2068
|
var preludeVar = "var ";
|
|
2066
2069
|
function ts(children) {
|
|
2067
2070
|
return {
|
|
@@ -2378,7 +2381,7 @@ function extractPreludeFor(node) {
|
|
|
2378
2381
|
}
|
|
2379
2382
|
}
|
|
2380
2383
|
|
|
2381
|
-
// unplugin-civet
|
|
2384
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\generate.civet.jsx
|
|
2382
2385
|
function stringify(node) {
|
|
2383
2386
|
try {
|
|
2384
2387
|
return JSON.stringify(removeParentPointers(node));
|
|
@@ -2488,7 +2491,7 @@ function prune(node) {
|
|
|
2488
2491
|
return node;
|
|
2489
2492
|
}
|
|
2490
2493
|
|
|
2491
|
-
// unplugin-civet
|
|
2494
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\comptime.civet.jsx
|
|
2492
2495
|
function expressionizeComptime(statement) {
|
|
2493
2496
|
const { expressions } = statement.block;
|
|
2494
2497
|
const expression = wrapIIFE(expressions, hasAwait(expressions));
|
|
@@ -2809,7 +2812,7 @@ function serialize(value, context) {
|
|
|
2809
2812
|
return recurse(value);
|
|
2810
2813
|
}
|
|
2811
2814
|
|
|
2812
|
-
// unplugin-civet
|
|
2815
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\function.civet.jsx
|
|
2813
2816
|
var concatAssign = (lhs, rhs) => (rhs?.[Symbol.isConcatSpreadable] ?? Array.isArray(rhs) ? lhs.push.apply(lhs, rhs) : lhs.push(rhs), lhs);
|
|
2814
2817
|
function getTypeArguments(args) {
|
|
2815
2818
|
while (typeof args === "object" && args != null && "args" in args) {
|
|
@@ -4041,7 +4044,11 @@ function processSignature(f) {
|
|
|
4041
4044
|
}
|
|
4042
4045
|
}
|
|
4043
4046
|
if (signature.modifier.async && !signature.modifier.generator && signature.returnType && !isPromiseType(signature.returnType.t)) {
|
|
4044
|
-
replaceNode(
|
|
4047
|
+
replaceNode(
|
|
4048
|
+
signature.returnType.t,
|
|
4049
|
+
wrapTypeInPromise(signature.returnType.t),
|
|
4050
|
+
signature.returnType
|
|
4051
|
+
);
|
|
4045
4052
|
}
|
|
4046
4053
|
}
|
|
4047
4054
|
function processFunctions(statements, config2) {
|
|
@@ -4242,7 +4249,7 @@ function makeAmpersandFunction(rhs) {
|
|
|
4242
4249
|
return fn;
|
|
4243
4250
|
}
|
|
4244
4251
|
|
|
4245
|
-
// unplugin-civet
|
|
4252
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\block.civet.jsx
|
|
4246
4253
|
function blockWithPrefix(prefixStatements, block) {
|
|
4247
4254
|
if (prefixStatements && prefixStatements.length) {
|
|
4248
4255
|
const expressions = [...prefixStatements, ...block.expressions];
|
|
@@ -4463,7 +4470,7 @@ function blockContainingStatement(exp) {
|
|
|
4463
4470
|
};
|
|
4464
4471
|
}
|
|
4465
4472
|
|
|
4466
|
-
// unplugin-civet
|
|
4473
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\op.civet.jsx
|
|
4467
4474
|
var precedenceOrder = [
|
|
4468
4475
|
["||", "??"],
|
|
4469
4476
|
["^^"],
|
|
@@ -4799,7 +4806,7 @@ function expandChainedComparisons([first, binops]) {
|
|
|
4799
4806
|
}
|
|
4800
4807
|
}
|
|
4801
4808
|
|
|
4802
|
-
// unplugin-civet
|
|
4809
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\pattern-matching.civet.jsx
|
|
4803
4810
|
function processPatternTest(lhs, patterns) {
|
|
4804
4811
|
const { ref, refAssignmentComma } = maybeRefAssignment(lhs, "m");
|
|
4805
4812
|
const conditionExpression = flatJoin(patterns.map(($1) => getPatternConditions($1, ref)).map(($2) => flatJoin($2, " && ")), " || ");
|
|
@@ -5318,7 +5325,7 @@ function aliasBinding(p, ref) {
|
|
|
5318
5325
|
}
|
|
5319
5326
|
}
|
|
5320
5327
|
|
|
5321
|
-
// unplugin-civet
|
|
5328
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\declaration.civet.jsx
|
|
5322
5329
|
function len2(arr, length) {
|
|
5323
5330
|
return arr.length === length;
|
|
5324
5331
|
}
|
|
@@ -5872,7 +5879,7 @@ function convertWithClause(withClause, extendsClause) {
|
|
|
5872
5879
|
return [extendsToken, insertTrimmingSpace(ws, " "), wrapped];
|
|
5873
5880
|
}
|
|
5874
5881
|
|
|
5875
|
-
// unplugin-civet
|
|
5882
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\unary.civet.jsx
|
|
5876
5883
|
function processUnaryExpression(pre, exp, post) {
|
|
5877
5884
|
if (!(pre.length || post)) {
|
|
5878
5885
|
return exp;
|
|
@@ -6034,7 +6041,7 @@ function processUnaryNestedExpression(pre, args, post) {
|
|
|
6034
6041
|
return processUnaryExpression(pre, args, post);
|
|
6035
6042
|
}
|
|
6036
6043
|
|
|
6037
|
-
// unplugin-civet
|
|
6044
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\pipe.civet.jsx
|
|
6038
6045
|
function constructInvocation(fn, arg) {
|
|
6039
6046
|
let expr = fn.expr;
|
|
6040
6047
|
while (expr.type === "ParenthesizedExpression") {
|
|
@@ -6257,7 +6264,7 @@ function processPipelineExpressions(statements) {
|
|
|
6257
6264
|
}
|
|
6258
6265
|
}
|
|
6259
6266
|
|
|
6260
|
-
// unplugin-civet
|
|
6267
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\for.civet.jsx
|
|
6261
6268
|
function processRangeExpression(start, ws1, range2, end) {
|
|
6262
6269
|
ws1 = [ws1, range2.children[0]];
|
|
6263
6270
|
const ws2 = range2.children[1];
|
|
@@ -6702,7 +6709,7 @@ function processForInOf($0) {
|
|
|
6702
6709
|
};
|
|
6703
6710
|
}
|
|
6704
6711
|
|
|
6705
|
-
// unplugin-civet
|
|
6712
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\auto-dec.civet.jsx
|
|
6706
6713
|
var concatAssign2 = (lhs, rhs) => (rhs?.[Symbol.isConcatSpreadable] ?? Array.isArray(rhs) ? lhs.push.apply(lhs, rhs) : lhs.push(rhs), lhs);
|
|
6707
6714
|
function findDecs(statements) {
|
|
6708
6715
|
const declarations = gatherNodes(statements, ($) => $.type === "Declaration");
|
|
@@ -6799,7 +6806,7 @@ function createVarDecs(block, scopes, pushVar) {
|
|
|
6799
6806
|
findAssignments(assignmentStatements2.map((s) => s.children), decs2)
|
|
6800
6807
|
);
|
|
6801
6808
|
}
|
|
6802
|
-
return assignmentStatements2;
|
|
6809
|
+
return assignmentStatements2.filter(($4) => !($4.parent?.type === "CoffeeClassPublic"));
|
|
6803
6810
|
}
|
|
6804
6811
|
pushVar ??= (name) => {
|
|
6805
6812
|
varIds.push(name);
|
|
@@ -6810,7 +6817,7 @@ function createVarDecs(block, scopes, pushVar) {
|
|
|
6810
6817
|
scopes.push(decs);
|
|
6811
6818
|
const varIds = [];
|
|
6812
6819
|
const assignmentStatements = findAssignments(statements, scopes);
|
|
6813
|
-
const undeclaredIdentifiers = assignmentStatements.flatMap(($
|
|
6820
|
+
const undeclaredIdentifiers = assignmentStatements.flatMap(($5) => $5?.names || []);
|
|
6814
6821
|
undeclaredIdentifiers.filter((x, i, a) => {
|
|
6815
6822
|
if (!hasDec(x)) return a.indexOf(x) === i;
|
|
6816
6823
|
return;
|
|
@@ -6848,7 +6855,7 @@ function createVarDecs(block, scopes, pushVar) {
|
|
|
6848
6855
|
scopes.pop();
|
|
6849
6856
|
}
|
|
6850
6857
|
|
|
6851
|
-
// unplugin-civet
|
|
6858
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\string.civet.jsx
|
|
6852
6859
|
function getIndentLevel(str, tab) {
|
|
6853
6860
|
if (tab != null && tab != 1) {
|
|
6854
6861
|
const tabs = str.match(/\t/g);
|
|
@@ -7016,7 +7023,7 @@ function quoteString(str) {
|
|
|
7016
7023
|
return JSON.stringify(str);
|
|
7017
7024
|
}
|
|
7018
7025
|
|
|
7019
|
-
// unplugin-civet
|
|
7026
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\lib.civet.jsx
|
|
7020
7027
|
var xor = (a, b) => a ? !b && a : b;
|
|
7021
7028
|
function addPostfixStatement(statement, ws, post) {
|
|
7022
7029
|
const expressions = [
|
|
@@ -7644,21 +7651,18 @@ function makeExpressionStatement(expression) {
|
|
|
7644
7651
|
}
|
|
7645
7652
|
}
|
|
7646
7653
|
function lastAccessInCallExpression(exp) {
|
|
7647
|
-
|
|
7654
|
+
while (exp.type === "MemberExpression" || exp.type === "CallExpression") {
|
|
7655
|
+
const { children } = exp;
|
|
7656
|
+
let i = children.length - 1;
|
|
7657
|
+
while (i >= 0 && typeof children[i] === "object" && (children[i].type === "Call" || children[i].type === "NonNullAssertion" || children[i].type === "Optional")) i--;
|
|
7658
|
+
if (i < 0) return;
|
|
7659
|
+
exp = children[i];
|
|
7660
|
+
}
|
|
7661
|
+
if (exp.type === "Identifier" || exp.type === "PropertyAccess" || exp.type === "Index") {
|
|
7648
7662
|
return exp;
|
|
7649
7663
|
}
|
|
7650
|
-
|
|
7651
|
-
|
|
7652
|
-
if (!(exp.children != null)) {
|
|
7653
|
-
return;
|
|
7654
|
-
}
|
|
7655
|
-
;
|
|
7656
|
-
({ children } = exp);
|
|
7657
|
-
i = children.length - 1;
|
|
7658
|
-
while (i >= 0 && (children[i].type === "Call" || children[i].type === "NonNullAssertion" || children[i].type === "Optional")) i--;
|
|
7659
|
-
if (i < 0) return;
|
|
7660
|
-
} while (children[i].type === "MemberExpression" && (exp = children[i]));
|
|
7661
|
-
return children[i];
|
|
7664
|
+
;
|
|
7665
|
+
return;
|
|
7662
7666
|
}
|
|
7663
7667
|
function convertMethodToFunction(method) {
|
|
7664
7668
|
const { signature, block } = method;
|
|
@@ -7688,6 +7692,45 @@ function convertMethodToFunction(method) {
|
|
|
7688
7692
|
block
|
|
7689
7693
|
};
|
|
7690
7694
|
}
|
|
7695
|
+
function convertFunctionToMethod(id, exp) {
|
|
7696
|
+
const fnTokenIndex = exp.children.findIndex(function(c) {
|
|
7697
|
+
return c?.token?.startsWith("function");
|
|
7698
|
+
});
|
|
7699
|
+
const children = exp.children.slice();
|
|
7700
|
+
if (exp.generator) {
|
|
7701
|
+
children.splice(fnTokenIndex, 2, children[fnTokenIndex + 1], id);
|
|
7702
|
+
} else {
|
|
7703
|
+
children.splice(fnTokenIndex, 1, id);
|
|
7704
|
+
}
|
|
7705
|
+
return {
|
|
7706
|
+
...exp,
|
|
7707
|
+
type: "MethodDefinition",
|
|
7708
|
+
name: id.name,
|
|
7709
|
+
signature: { ...exp.signature, id, name: id.name },
|
|
7710
|
+
children
|
|
7711
|
+
};
|
|
7712
|
+
}
|
|
7713
|
+
function convertArrowFunctionToMethod(id, exp) {
|
|
7714
|
+
const block = { ...exp.block };
|
|
7715
|
+
const children = exp.children.filter(function(c) {
|
|
7716
|
+
return !(Array.isArray(c) && c[c.length - 1]?.token?.includes("=>"));
|
|
7717
|
+
}).map(function(c) {
|
|
7718
|
+
return c === exp.block ? block : c;
|
|
7719
|
+
});
|
|
7720
|
+
children.unshift(id);
|
|
7721
|
+
exp = {
|
|
7722
|
+
...exp,
|
|
7723
|
+
type: "MethodDefinition",
|
|
7724
|
+
name: id.name,
|
|
7725
|
+
signature: { ...exp.signature, id, name: id.name },
|
|
7726
|
+
block,
|
|
7727
|
+
children,
|
|
7728
|
+
autoBind: true
|
|
7729
|
+
};
|
|
7730
|
+
block.parent = exp;
|
|
7731
|
+
braceBlock(block);
|
|
7732
|
+
return exp;
|
|
7733
|
+
}
|
|
7691
7734
|
function convertNamedImportsToObject(node, pattern) {
|
|
7692
7735
|
const properties = node.specifiers.map((specifier) => {
|
|
7693
7736
|
if (specifier.ts) {
|
|
@@ -8472,7 +8515,17 @@ function processCoffeeClasses(statements) {
|
|
|
8472
8515
|
})()
|
|
8473
8516
|
);
|
|
8474
8517
|
}
|
|
8475
|
-
const
|
|
8518
|
+
const public_static_function_assignments = expressions.filter(($15) => $15[1]?.type === "CoffeeClassPublic" && $15[1].assignment?.expression?.type === "FunctionExpression").map(($16) => $16[1].assignment);
|
|
8519
|
+
for (const public_static_function_assignment of public_static_function_assignments) {
|
|
8520
|
+
const id = public_static_function_assignment.lhs[0][1];
|
|
8521
|
+
replaceNode(public_static_function_assignment, convertFunctionToMethod(id, public_static_function_assignment.expression));
|
|
8522
|
+
}
|
|
8523
|
+
const public_static_arrow_function_assignments = expressions.filter(($17) => $17[1]?.type === "CoffeeClassPublic" && $17[1].assignment?.expression?.type === "ArrowFunction").map(($18) => $18[1].assignment);
|
|
8524
|
+
for (const public_static_arrow_function_assignment of public_static_arrow_function_assignments) {
|
|
8525
|
+
const id = public_static_arrow_function_assignment.lhs[0][1];
|
|
8526
|
+
replaceNode(public_static_arrow_function_assignment, convertArrowFunctionToMethod(id, public_static_arrow_function_assignment.expression));
|
|
8527
|
+
}
|
|
8528
|
+
const privates = expressions.filter(($19) => $19[1]?.type === "CoffeeClassPrivate");
|
|
8476
8529
|
if (!privates.length) {
|
|
8477
8530
|
continue;
|
|
8478
8531
|
}
|
|
@@ -8537,7 +8590,7 @@ function processProgram(root) {
|
|
|
8537
8590
|
root.topLevelYield ? "*" : void 0
|
|
8538
8591
|
);
|
|
8539
8592
|
statements = [["", rootIIFE]];
|
|
8540
|
-
root.children = root.children.map(($
|
|
8593
|
+
root.children = root.children.map(($20) => $20 === root.expressions ? statements : $20);
|
|
8541
8594
|
root.expressions = statements;
|
|
8542
8595
|
}
|
|
8543
8596
|
hoistRefDecs(statements);
|
|
@@ -8568,9 +8621,9 @@ async function processProgramAsync(root) {
|
|
|
8568
8621
|
await processComptime(statements);
|
|
8569
8622
|
}
|
|
8570
8623
|
function processRepl(root, rootIIFE) {
|
|
8571
|
-
const topBlock = gatherRecursive(rootIIFE, ($
|
|
8624
|
+
const topBlock = gatherRecursive(rootIIFE, ($21) => $21.type === "BlockStatement")[0];
|
|
8572
8625
|
let i = 0;
|
|
8573
|
-
for (let ref23 = gatherRecursiveWithinFunction(topBlock, ($
|
|
8626
|
+
for (let ref23 = gatherRecursiveWithinFunction(topBlock, ($22) => $22.type === "Declaration"), i14 = 0, len11 = ref23.length; i14 < len11; i14++) {
|
|
8574
8627
|
const decl = ref23[i14];
|
|
8575
8628
|
if (!decl.names?.length) {
|
|
8576
8629
|
continue;
|
|
@@ -8584,7 +8637,7 @@ function processRepl(root, rootIIFE) {
|
|
|
8584
8637
|
root.expressions.splice(i++, 0, ["", `var ${decl.names.join(",")}`, ";"]);
|
|
8585
8638
|
}
|
|
8586
8639
|
}
|
|
8587
|
-
for (let ref24 = gatherRecursive(topBlock, ($
|
|
8640
|
+
for (let ref24 = gatherRecursive(topBlock, ($23) => $23.type === "FunctionExpression"), i15 = 0, len12 = ref24.length; i15 < len12; i15++) {
|
|
8588
8641
|
const func = ref24[i15];
|
|
8589
8642
|
if (func.name && func.parent?.type === "BlockStatement") {
|
|
8590
8643
|
if (func.parent === topBlock) {
|
|
@@ -8597,7 +8650,7 @@ function processRepl(root, rootIIFE) {
|
|
|
8597
8650
|
}
|
|
8598
8651
|
}
|
|
8599
8652
|
}
|
|
8600
|
-
for (let ref25 = gatherRecursiveWithinFunction(topBlock, ($
|
|
8653
|
+
for (let ref25 = gatherRecursiveWithinFunction(topBlock, ($24) => $24.type === "ClassExpression"), i16 = 0, len13 = ref25.length; i16 < len13; i16++) {
|
|
8601
8654
|
const classExp = ref25[i16];
|
|
8602
8655
|
let m8;
|
|
8603
8656
|
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)) {
|
|
@@ -8609,7 +8662,7 @@ function processRepl(root, rootIIFE) {
|
|
|
8609
8662
|
function processPlaceholders(statements) {
|
|
8610
8663
|
const placeholderMap = /* @__PURE__ */ new Map();
|
|
8611
8664
|
const liftedIfs = /* @__PURE__ */ new Set();
|
|
8612
|
-
for (let ref26 = gatherRecursiveAll(statements, ($
|
|
8665
|
+
for (let ref26 = gatherRecursiveAll(statements, ($25) => $25.type === "Placeholder"), i17 = 0, len14 = ref26.length; i17 < len14; i17++) {
|
|
8613
8666
|
const exp = ref26[i17];
|
|
8614
8667
|
let ancestor;
|
|
8615
8668
|
if (exp.subtype === ".") {
|
|
@@ -9997,7 +10050,7 @@ var $R9 = (0, import_lib2.$R)(new RegExp("(?=[\\/?])", "suy"));
|
|
|
9997
10050
|
var $R10 = (0, import_lib2.$R)(new RegExp("(?=[\\/\\[{?.!@#'\u2019:])", "suy"));
|
|
9998
10051
|
var $R11 = (0, import_lib2.$R)(new RegExp("%%?", "suy"));
|
|
9999
10052
|
var $R12 = (0, import_lib2.$R)(new RegExp("[.\\s]", "suy"));
|
|
10000
|
-
var $R13 = (0, import_lib2.$R)(new RegExp("[)}]", "suy"));
|
|
10053
|
+
var $R13 = (0, import_lib2.$R)(new RegExp("[)\\]}]", "suy"));
|
|
10001
10054
|
var $R14 = (0, import_lib2.$R)(new RegExp("[+-]", "suy"));
|
|
10002
10055
|
var $R15 = (0, import_lib2.$R)(new RegExp("\\+\\+|--|\u29FA|\u2014|[\\+\\-&]\\S", "suy"));
|
|
10003
10056
|
var $R16 = (0, import_lib2.$R)(new RegExp(`(?=[0-9.'"tfyno])`, "suy"));
|
|
@@ -11377,7 +11430,20 @@ var NestedClassElement$0 = (0, import_lib2.$S)(Nested, ClassElement, StatementDe
|
|
|
11377
11430
|
function NestedClassElement(ctx, state2) {
|
|
11378
11431
|
return (0, import_lib2.$EVENT)(ctx, state2, "NestedClassElement", NestedClassElement$0);
|
|
11379
11432
|
}
|
|
11380
|
-
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)(_))),
|
|
11433
|
+
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) {
|
|
11434
|
+
var decorators = $2;
|
|
11435
|
+
var declare = $3;
|
|
11436
|
+
var access = $4;
|
|
11437
|
+
var static_ = $5;
|
|
11438
|
+
var override = $6;
|
|
11439
|
+
var assignment = $7;
|
|
11440
|
+
return {
|
|
11441
|
+
type: static_ ? "CoffeeClassPublic" : "CoffeeClassPrivate",
|
|
11442
|
+
children: [decorators, declare, access, static_, override, assignment],
|
|
11443
|
+
assignment
|
|
11444
|
+
};
|
|
11445
|
+
});
|
|
11446
|
+
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) {
|
|
11381
11447
|
var decorators = $1;
|
|
11382
11448
|
var declare = $2;
|
|
11383
11449
|
var access = $3;
|
|
@@ -11403,14 +11469,14 @@ var ClassElement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E
|
|
|
11403
11469
|
children: [decorators, declare, access, static_, override, ...definition.children]
|
|
11404
11470
|
};
|
|
11405
11471
|
});
|
|
11406
|
-
var ClassElement$
|
|
11472
|
+
var ClassElement$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(Static, BracedBlock), function($skip, $loc, $0, $1, $2) {
|
|
11407
11473
|
return {
|
|
11408
11474
|
type: "ClassStaticBlock",
|
|
11409
11475
|
children: $0
|
|
11410
11476
|
};
|
|
11411
11477
|
});
|
|
11412
|
-
var ClassElement$
|
|
11413
|
-
var ClassElement$$ = [ClassElement$0, ClassElement$1, ClassElement$2];
|
|
11478
|
+
var ClassElement$3 = EmptyStatement;
|
|
11479
|
+
var ClassElement$$ = [ClassElement$0, ClassElement$1, ClassElement$2, ClassElement$3];
|
|
11414
11480
|
function ClassElement(ctx, state2) {
|
|
11415
11481
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "ClassElement", ClassElement$$);
|
|
11416
11482
|
}
|
|
@@ -11463,37 +11529,10 @@ var FieldDefinition$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(CoffeeClassesEn
|
|
|
11463
11529
|
var exp = $6;
|
|
11464
11530
|
switch (exp.type) {
|
|
11465
11531
|
case "FunctionExpression": {
|
|
11466
|
-
|
|
11467
|
-
const children = exp.children.slice();
|
|
11468
|
-
if (exp.generator) {
|
|
11469
|
-
children.splice(fnTokenIndex, 2, children[fnTokenIndex + 1], id);
|
|
11470
|
-
} else {
|
|
11471
|
-
children.splice(fnTokenIndex, 1, id);
|
|
11472
|
-
}
|
|
11473
|
-
return {
|
|
11474
|
-
...exp,
|
|
11475
|
-
type: "MethodDefinition",
|
|
11476
|
-
name: id.name,
|
|
11477
|
-
signature: { ...exp.signature, id, name: id.name },
|
|
11478
|
-
children
|
|
11479
|
-
};
|
|
11532
|
+
return convertFunctionToMethod(id, exp);
|
|
11480
11533
|
}
|
|
11481
11534
|
case "ArrowFunction": {
|
|
11482
|
-
|
|
11483
|
-
const children = exp.children.filter((c) => !(Array.isArray(c) && c[c.length - 1]?.token?.includes("=>"))).map((c) => c === exp.block ? block : c);
|
|
11484
|
-
children.unshift(id);
|
|
11485
|
-
exp = {
|
|
11486
|
-
...exp,
|
|
11487
|
-
type: "MethodDefinition",
|
|
11488
|
-
name: id.name,
|
|
11489
|
-
signature: { ...exp.signature, id, name: id.name },
|
|
11490
|
-
block,
|
|
11491
|
-
children,
|
|
11492
|
-
autoBind: true
|
|
11493
|
-
};
|
|
11494
|
-
block.parent = exp;
|
|
11495
|
-
braceBlock(block);
|
|
11496
|
-
return exp;
|
|
11535
|
+
return convertArrowFunctionToMethod(id, exp);
|
|
11497
11536
|
}
|
|
11498
11537
|
default:
|
|
11499
11538
|
return {
|
|
@@ -11520,15 +11559,7 @@ var FieldDefinition$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(InsertReadonly,
|
|
|
11520
11559
|
readonly
|
|
11521
11560
|
};
|
|
11522
11561
|
});
|
|
11523
|
-
var FieldDefinition$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(
|
|
11524
|
-
var assignment = $2;
|
|
11525
|
-
return {
|
|
11526
|
-
type: "CoffeeClassPrivate",
|
|
11527
|
-
children: [assignment],
|
|
11528
|
-
assignment
|
|
11529
|
-
};
|
|
11530
|
-
});
|
|
11531
|
-
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) {
|
|
11562
|
+
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) {
|
|
11532
11563
|
var abstract = $1;
|
|
11533
11564
|
var readonly = $2;
|
|
11534
11565
|
var id = $3;
|
|
@@ -11545,7 +11576,7 @@ var FieldDefinition$3 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2
|
|
|
11545
11576
|
initializer
|
|
11546
11577
|
};
|
|
11547
11578
|
});
|
|
11548
|
-
var FieldDefinition$$ = [FieldDefinition$0, FieldDefinition$1, FieldDefinition$2
|
|
11579
|
+
var FieldDefinition$$ = [FieldDefinition$0, FieldDefinition$1, FieldDefinition$2];
|
|
11549
11580
|
function FieldDefinition(ctx, state2) {
|
|
11550
11581
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "FieldDefinition", FieldDefinition$$);
|
|
11551
11582
|
}
|
|
@@ -12316,7 +12347,7 @@ function ParameterElement(ctx, state2) {
|
|
|
12316
12347
|
return (0, import_lib2.$EVENT)(ctx, state2, "ParameterElement", ParameterElement$0);
|
|
12317
12348
|
}
|
|
12318
12349
|
var ParameterElementDelimiter$0 = (0, import_lib2.$S)((0, import_lib2.$E)(_), Comma);
|
|
12319
|
-
var ParameterElementDelimiter$1 = (0, import_lib2.$Y)((0, import_lib2.$S)(__, (0, import_lib2.$R$0)((0, import_lib2.$EXPECT)($R13, "ParameterElementDelimiter /[)}]/"))));
|
|
12350
|
+
var ParameterElementDelimiter$1 = (0, import_lib2.$Y)((0, import_lib2.$S)(__, (0, import_lib2.$R$0)((0, import_lib2.$EXPECT)($R13, "ParameterElementDelimiter /[)\\]}]/"))));
|
|
12320
12351
|
var ParameterElementDelimiter$2 = (0, import_lib2.$T)((0, import_lib2.$S)((0, import_lib2.$Y)(EOS), InsertComma), function(value) {
|
|
12321
12352
|
return value[1];
|
|
12322
12353
|
});
|
|
@@ -12981,7 +13012,7 @@ var OperatorDeclaration$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Operator, (
|
|
|
12981
13012
|
var behavior = $2;
|
|
12982
13013
|
var w = $3;
|
|
12983
13014
|
var decl = $4;
|
|
12984
|
-
decl.names.forEach((name) =>
|
|
13015
|
+
decl.names.forEach((name) => setOperatorBehavior(name, behavior));
|
|
12985
13016
|
if (behavior?.error) decl = prepend(behavior.error, decl);
|
|
12986
13017
|
decl = prepend(trimFirstSpace(w), decl);
|
|
12987
13018
|
return decl;
|
|
@@ -12989,7 +13020,7 @@ var OperatorDeclaration$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Operator, (
|
|
|
12989
13020
|
var OperatorDeclaration$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(OperatorSignature, BracedBlock), function($skip, $loc, $0, $1, $2) {
|
|
12990
13021
|
var signature = $1;
|
|
12991
13022
|
var block = $2;
|
|
12992
|
-
|
|
13023
|
+
setOperatorBehavior(signature.id.name, signature.behavior);
|
|
12993
13024
|
return {
|
|
12994
13025
|
...signature,
|
|
12995
13026
|
type: "FunctionExpression",
|
|
@@ -13006,10 +13037,10 @@ var OperatorDeclaration$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(Operator, _
|
|
|
13006
13037
|
var behavior = $4;
|
|
13007
13038
|
var ids = $5;
|
|
13008
13039
|
const children = [];
|
|
13009
|
-
|
|
13040
|
+
setOperatorBehavior(id.name, behavior);
|
|
13010
13041
|
if (behavior?.error) children.push(behavior.error);
|
|
13011
13042
|
ids.forEach(([, , id2, behavior2]) => {
|
|
13012
|
-
|
|
13043
|
+
setOperatorBehavior(id2.name, behavior2);
|
|
13013
13044
|
if (behavior2?.error) children.push(behavior2.error);
|
|
13014
13045
|
});
|
|
13015
13046
|
return {
|
|
@@ -14252,7 +14283,7 @@ function InlineObjectPropertyDelimiter(ctx, state2) {
|
|
|
14252
14283
|
return (0, import_lib2.$EVENT)(ctx, state2, "InlineObjectPropertyDelimiter", InlineObjectPropertyDelimiter$0);
|
|
14253
14284
|
}
|
|
14254
14285
|
var ObjectPropertyDelimiter$0 = (0, import_lib2.$S)((0, import_lib2.$E)(_), Comma);
|
|
14255
|
-
var ObjectPropertyDelimiter$1 = (0, import_lib2.$Y)((0, import_lib2.$S)(__, (0, import_lib2.$EXPECT)($
|
|
14286
|
+
var ObjectPropertyDelimiter$1 = (0, import_lib2.$Y)((0, import_lib2.$S)(__, (0, import_lib2.$R$0)((0, import_lib2.$EXPECT)($R13, "ObjectPropertyDelimiter /[)\\]}]/"))));
|
|
14256
14287
|
var ObjectPropertyDelimiter$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$Y)(EOS), InsertComma), function($skip, $loc, $0, $1, $2) {
|
|
14257
14288
|
return { ...$2, implicit: true };
|
|
14258
14289
|
});
|
|
@@ -16742,7 +16773,7 @@ var ImportDeclaration$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_li
|
|
|
16742
16773
|
const errors = [];
|
|
16743
16774
|
if (behavior?.error) errors.push(behavior.error);
|
|
16744
16775
|
imports.specifiers.forEach((spec) => {
|
|
16745
|
-
|
|
16776
|
+
setOperatorBehavior(spec.binding.name, spec.behavior ?? behavior);
|
|
16746
16777
|
if (spec.behavior?.error) errors.push(spec.behavior.error);
|
|
16747
16778
|
});
|
|
16748
16779
|
return {
|
|
@@ -16793,7 +16824,7 @@ var ImportDeclaration$5 = (0, import_lib2.$TS)((0, import_lib2.$S)(FromClause, _
|
|
|
16793
16824
|
const errors = [];
|
|
16794
16825
|
if (behavior?.error) errors.push(behavior.error);
|
|
16795
16826
|
imports.specifiers.forEach((spec) => {
|
|
16796
|
-
|
|
16827
|
+
setOperatorBehavior(spec.binding.name, spec.behavior ?? behavior);
|
|
16797
16828
|
if (spec.behavior?.error) errors.push(spec.behavior.error);
|
|
16798
16829
|
});
|
|
16799
16830
|
return {
|
|
@@ -16925,7 +16956,7 @@ var TypeAndImportSpecifier$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(__, Oper
|
|
|
16925
16956
|
if (spec.binding.type !== "Identifier") {
|
|
16926
16957
|
throw new Error("Expected identifier after `operator`");
|
|
16927
16958
|
}
|
|
16928
|
-
|
|
16959
|
+
setOperatorBehavior(spec.binding.name, spec.behavior);
|
|
16929
16960
|
return {
|
|
16930
16961
|
...spec,
|
|
16931
16962
|
children: [
|
|
@@ -20521,6 +20552,7 @@ var CivetOption$0 = (0, import_lib2.$TR)((0, import_lib2.$EXPECT)($R99, "CivetOp
|
|
|
20521
20552
|
break;
|
|
20522
20553
|
case "globals":
|
|
20523
20554
|
case "symbols":
|
|
20555
|
+
case "operators":
|
|
20524
20556
|
value = value.split(",").filter(Boolean);
|
|
20525
20557
|
break;
|
|
20526
20558
|
}
|
|
@@ -20929,6 +20961,36 @@ var Reset$0 = (0, import_lib2.$TV)((0, import_lib2.$EXPECT)($L0, 'Reset ""'), fu
|
|
|
20929
20961
|
}
|
|
20930
20962
|
}
|
|
20931
20963
|
});
|
|
20964
|
+
Object.defineProperty(config, "operators", {
|
|
20965
|
+
set(o) {
|
|
20966
|
+
if (!o) return;
|
|
20967
|
+
if (typeof o !== "object") {
|
|
20968
|
+
throw new Error("operators configuration must be an object or array");
|
|
20969
|
+
}
|
|
20970
|
+
if (Array.isArray(o)) {
|
|
20971
|
+
o.forEach((name) => {
|
|
20972
|
+
if (typeof name !== "string") {
|
|
20973
|
+
throw new Error("operators configuration array must contain only strings");
|
|
20974
|
+
}
|
|
20975
|
+
setOperatorBehavior(name, void 0);
|
|
20976
|
+
});
|
|
20977
|
+
} else {
|
|
20978
|
+
for (let [name, behavior] of Object.entries(o)) {
|
|
20979
|
+
if (typeof behavior === "string") {
|
|
20980
|
+
behavior = behavior.trim();
|
|
20981
|
+
behavior = behavior ? parse(behavior, {
|
|
20982
|
+
startRule: "OperatorBehavior",
|
|
20983
|
+
filename: `operator config for ${name}`
|
|
20984
|
+
}) : void 0;
|
|
20985
|
+
}
|
|
20986
|
+
if (behavior && typeof behavior !== "object") {
|
|
20987
|
+
throw new Error("operators configuration object must have string or object values");
|
|
20988
|
+
}
|
|
20989
|
+
setOperatorBehavior(name, behavior);
|
|
20990
|
+
}
|
|
20991
|
+
}
|
|
20992
|
+
}
|
|
20993
|
+
});
|
|
20932
20994
|
Object.assign(config, initialConfig);
|
|
20933
20995
|
});
|
|
20934
20996
|
function Reset(ctx, state2) {
|
|
@@ -21060,26 +21122,24 @@ var PushExtraIndent1$0 = (0, import_lib2.$TV)((0, import_lib2.$EXPECT)($L0, 'Pus
|
|
|
21060
21122
|
function PushExtraIndent1(ctx, state2) {
|
|
21061
21123
|
return (0, import_lib2.$EVENT)(ctx, state2, "PushExtraIndent1", PushExtraIndent1$0);
|
|
21062
21124
|
}
|
|
21063
|
-
var parser =
|
|
21064
|
-
|
|
21065
|
-
|
|
21066
|
-
|
|
21067
|
-
|
|
21068
|
-
|
|
21069
|
-
|
|
21070
|
-
|
|
21071
|
-
|
|
21072
|
-
|
|
21073
|
-
|
|
21074
|
-
|
|
21075
|
-
|
|
21076
|
-
|
|
21077
|
-
|
|
21078
|
-
|
|
21079
|
-
|
|
21080
|
-
|
|
21081
|
-
};
|
|
21082
|
-
}();
|
|
21125
|
+
var parser = {
|
|
21126
|
+
parse: (input, options = {}) => {
|
|
21127
|
+
const { fail, validate, reset } = (0, import_lib2.Validator)();
|
|
21128
|
+
let ctx = { expectation: "", fail };
|
|
21129
|
+
if (typeof input !== "string") throw new Error("Input must be a string");
|
|
21130
|
+
const parser2 = options.startRule != null ? grammar[options.startRule] : Object.values(grammar)[0];
|
|
21131
|
+
if (!parser2) throw new Error(`Could not find rule with name '${options.startRule}'`);
|
|
21132
|
+
const filename2 = options.filename || "<anonymous>";
|
|
21133
|
+
reset();
|
|
21134
|
+
Object.assign(ctx, { ...options.events, tokenize: options.tokenize });
|
|
21135
|
+
return validate(input, parser2(ctx, {
|
|
21136
|
+
input,
|
|
21137
|
+
pos: 0
|
|
21138
|
+
}), {
|
|
21139
|
+
filename: filename2
|
|
21140
|
+
});
|
|
21141
|
+
}
|
|
21142
|
+
};
|
|
21083
21143
|
var { parse } = parser;
|
|
21084
21144
|
var filename;
|
|
21085
21145
|
var initialConfig;
|
|
@@ -21158,6 +21218,14 @@ Object.defineProperties(state, {
|
|
|
21158
21218
|
}
|
|
21159
21219
|
}
|
|
21160
21220
|
});
|
|
21221
|
+
function setOperatorBehavior(name, behavior) {
|
|
21222
|
+
const existing = state.operators.get(name);
|
|
21223
|
+
if (existing && behavior) {
|
|
21224
|
+
state.operators.set(name, { ...existing, ...behavior });
|
|
21225
|
+
} else {
|
|
21226
|
+
state.operators.set(name, behavior || existing);
|
|
21227
|
+
}
|
|
21228
|
+
}
|
|
21161
21229
|
function getStateKey() {
|
|
21162
21230
|
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,
|
|
21163
21231
|
// since it is affected by the directive prologue and may be hit
|
|
@@ -21198,11 +21266,12 @@ var wellKnownSymbols = [
|
|
|
21198
21266
|
"unscopables"
|
|
21199
21267
|
];
|
|
21200
21268
|
|
|
21201
|
-
// unplugin-civet
|
|
21269
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\sourcemap.civet.jsx
|
|
21202
21270
|
var sourcemap_civet_exports = {};
|
|
21203
21271
|
__export(sourcemap_civet_exports, {
|
|
21204
21272
|
SourceMap: () => SourceMap,
|
|
21205
21273
|
base64Encode: () => base64Encode,
|
|
21274
|
+
decodeVLQ: () => decodeVLQ,
|
|
21206
21275
|
locationTable: () => locationTable,
|
|
21207
21276
|
lookupLineColumn: () => lookupLineColumn
|
|
21208
21277
|
});
|
|
@@ -21238,7 +21307,6 @@ var SourceMap = class {
|
|
|
21238
21307
|
// relative to previous entry
|
|
21239
21308
|
srcLine;
|
|
21240
21309
|
srcColumn;
|
|
21241
|
-
srcOffset;
|
|
21242
21310
|
srcTable;
|
|
21243
21311
|
source;
|
|
21244
21312
|
constructor(source1) {
|
|
@@ -21248,7 +21316,6 @@ var SourceMap = class {
|
|
|
21248
21316
|
this.colOffset = 0;
|
|
21249
21317
|
this.srcLine = 0;
|
|
21250
21318
|
this.srcColumn = 0;
|
|
21251
|
-
this.srcOffset = 0;
|
|
21252
21319
|
this.srcTable = locationTable(this.source);
|
|
21253
21320
|
}
|
|
21254
21321
|
renderMappings() {
|
|
@@ -21292,6 +21359,10 @@ var SourceMap = class {
|
|
|
21292
21359
|
}
|
|
21293
21360
|
};
|
|
21294
21361
|
}
|
|
21362
|
+
/** Generate a comment with the source mapping URL. */
|
|
21363
|
+
comment(srcFileName, outFileName) {
|
|
21364
|
+
return `//${"#"} sourceMappingURL=data:application/json;base64,${base64Encode(JSON.stringify(this.json(srcFileName, outFileName)))}`;
|
|
21365
|
+
}
|
|
21295
21366
|
updateSourceMap(outputStr, inputPos, colOffset = 0) {
|
|
21296
21367
|
const outLines = outputStr.split(EOL2);
|
|
21297
21368
|
let srcLine, srcCol;
|
|
@@ -21300,7 +21371,6 @@ var SourceMap = class {
|
|
|
21300
21371
|
srcCol += colOffset;
|
|
21301
21372
|
this.srcLine = srcLine;
|
|
21302
21373
|
this.srcColumn = srcCol;
|
|
21303
|
-
this.srcOffset = inputPos + outputStr.length;
|
|
21304
21374
|
}
|
|
21305
21375
|
for (let i3 = 0, len22 = outLines.length; i3 < len22; i3++) {
|
|
21306
21376
|
const i = i3;
|
|
@@ -21323,74 +21393,85 @@ var SourceMap = class {
|
|
|
21323
21393
|
}
|
|
21324
21394
|
return;
|
|
21325
21395
|
}
|
|
21326
|
-
|
|
21327
|
-
|
|
21328
|
-
|
|
21329
|
-
|
|
21330
|
-
|
|
21331
|
-
|
|
21332
|
-
|
|
21333
|
-
|
|
21334
|
-
|
|
21335
|
-
|
|
21336
|
-
const composedLines = composeLines(upstreamMap.lines, parsed.lines);
|
|
21337
|
-
upstreamMap.lines = composedLines;
|
|
21338
|
-
}
|
|
21339
|
-
const remappedSourceMapJSON = upstreamMap.json(sourcePath, targetPath);
|
|
21340
|
-
const newSourceMap = `${"sourceMapping"}URL=data:application/json;charset=utf-8;base64,${base64Encode(JSON.stringify(remappedSourceMapJSON))}`;
|
|
21341
|
-
const remappedCodeWithSourceMap = `${codeWithoutSourceMap}
|
|
21342
|
-
//# ${newSourceMap}`;
|
|
21343
|
-
return remappedCodeWithSourceMap;
|
|
21344
|
-
};
|
|
21345
|
-
var composeLines = function(upstreamMapping, lines) {
|
|
21346
|
-
return lines.map((line) => {
|
|
21347
|
-
return line.map((entry) => {
|
|
21348
|
-
if (entry.length === 1) {
|
|
21349
|
-
return entry;
|
|
21350
|
-
}
|
|
21351
|
-
const [colDelta, sourceFileIndex, srcLine, srcCol] = entry;
|
|
21352
|
-
const srcPos = remapPosition([srcLine, srcCol], upstreamMapping);
|
|
21353
|
-
if (!srcPos) {
|
|
21354
|
-
return [entry[0]];
|
|
21355
|
-
}
|
|
21356
|
-
const [upstreamLine, upstreamCol] = srcPos;
|
|
21357
|
-
if (entry.length === 4) {
|
|
21358
|
-
return [colDelta, sourceFileIndex, upstreamLine, upstreamCol];
|
|
21359
|
-
}
|
|
21360
|
-
return [colDelta, sourceFileIndex, upstreamLine, upstreamCol, entry[4]];
|
|
21396
|
+
/**
|
|
21397
|
+
Remap a string with compiled code and a source map to use a new source map
|
|
21398
|
+
referencing upstream source files.
|
|
21399
|
+
This modifies the upstream map in place.
|
|
21400
|
+
*/
|
|
21401
|
+
static remap = (codeWithSourceMap, upstreamMap, sourcePath, targetPath) => {
|
|
21402
|
+
let sourceMapText;
|
|
21403
|
+
const codeWithoutSourceMap = codeWithSourceMap.replace(smRegexp, (_match, sm) => {
|
|
21404
|
+
sourceMapText = sm;
|
|
21405
|
+
return "";
|
|
21361
21406
|
});
|
|
21362
|
-
|
|
21363
|
-
|
|
21364
|
-
|
|
21365
|
-
|
|
21366
|
-
let sourceLine = 0;
|
|
21367
|
-
let sourceColumn = 0;
|
|
21368
|
-
const lines = json.mappings.split(";").map((line) => {
|
|
21369
|
-
if (line.length === 0) {
|
|
21370
|
-
return [];
|
|
21407
|
+
if (sourceMapText) {
|
|
21408
|
+
const parsed = this.parseWithLines(sourceMapText);
|
|
21409
|
+
const composedLines = this.composeLines(upstreamMap.lines, parsed.lines);
|
|
21410
|
+
upstreamMap.lines = composedLines;
|
|
21371
21411
|
}
|
|
21372
|
-
|
|
21373
|
-
|
|
21374
|
-
|
|
21375
|
-
|
|
21376
|
-
|
|
21377
|
-
|
|
21378
|
-
|
|
21379
|
-
|
|
21412
|
+
const remappedCodeWithSourceMap = `${codeWithoutSourceMap}
|
|
21413
|
+
${upstreamMap.comment(sourcePath, targetPath)}`;
|
|
21414
|
+
return remappedCodeWithSourceMap;
|
|
21415
|
+
};
|
|
21416
|
+
/**
|
|
21417
|
+
Compose lines from an upstream source map with lines from a downstream source map.
|
|
21418
|
+
*/
|
|
21419
|
+
static composeLines = (upstreamMapping, lines) => {
|
|
21420
|
+
return lines.map((line) => {
|
|
21421
|
+
return line.map((entry) => {
|
|
21422
|
+
if (entry.length === 1) {
|
|
21423
|
+
return entry;
|
|
21380
21424
|
}
|
|
21381
|
-
|
|
21382
|
-
|
|
21425
|
+
const [colDelta, sourceFileIndex, srcLine, srcCol] = entry;
|
|
21426
|
+
const srcPos = remapPosition([srcLine, srcCol], upstreamMapping);
|
|
21427
|
+
if (!srcPos) {
|
|
21428
|
+
return [entry[0]];
|
|
21383
21429
|
}
|
|
21384
|
-
|
|
21385
|
-
|
|
21430
|
+
const [upstreamLine, upstreamCol] = srcPos;
|
|
21431
|
+
if (entry.length === 4) {
|
|
21432
|
+
return [colDelta, sourceFileIndex, upstreamLine, upstreamCol];
|
|
21386
21433
|
}
|
|
21434
|
+
return [colDelta, sourceFileIndex, upstreamLine, upstreamCol, entry[4]];
|
|
21435
|
+
});
|
|
21436
|
+
});
|
|
21437
|
+
};
|
|
21438
|
+
/**
|
|
21439
|
+
Parse a base64 encoded source map string into a SourceMapJSON object with lines.
|
|
21440
|
+
*/
|
|
21441
|
+
static parseWithLines = (base64encodedJSONstr) => {
|
|
21442
|
+
const json = JSON.parse(Buffer.from(base64encodedJSONstr, "base64").toString("utf8"));
|
|
21443
|
+
let sourceLine = 0;
|
|
21444
|
+
let sourceColumn = 0;
|
|
21445
|
+
const lines = json.mappings.split(";").map((line) => {
|
|
21446
|
+
if (line.length === 0) {
|
|
21447
|
+
return [];
|
|
21387
21448
|
}
|
|
21449
|
+
return line.split(",").map((entry) => {
|
|
21450
|
+
const result = decodeVLQ(entry);
|
|
21451
|
+
switch (result.length) {
|
|
21452
|
+
case 1: {
|
|
21453
|
+
;
|
|
21454
|
+
break;
|
|
21455
|
+
}
|
|
21456
|
+
case 4:
|
|
21457
|
+
case 5: {
|
|
21458
|
+
sourceLine += result[2];
|
|
21459
|
+
result[2] = sourceLine;
|
|
21460
|
+
sourceColumn += result[3];
|
|
21461
|
+
result[3] = sourceColumn;
|
|
21462
|
+
break;
|
|
21463
|
+
}
|
|
21464
|
+
default: {
|
|
21465
|
+
throw new Error(`Unknown source map entry ${JSON.stringify(result)}`);
|
|
21466
|
+
}
|
|
21467
|
+
}
|
|
21468
|
+
return result;
|
|
21469
|
+
});
|
|
21388
21470
|
});
|
|
21389
|
-
|
|
21390
|
-
|
|
21391
|
-
return json;
|
|
21471
|
+
return { ...json, lines };
|
|
21472
|
+
};
|
|
21392
21473
|
};
|
|
21393
|
-
|
|
21474
|
+
var smRegexp = /(?:\r?\n|\r)\/\/# sourceMappingURL=data:application\/json;(?:charset=[^;]*;)?base64,([+a-zA-Z0-9\/]*=?=?)(?:\s*)$/;
|
|
21394
21475
|
var VLQ_SHIFT = 5;
|
|
21395
21476
|
var VLQ_CONTINUATION_BIT = 1 << VLQ_SHIFT;
|
|
21396
21477
|
var VLQ_VALUE_MASK = VLQ_CONTINUATION_BIT - 1;
|
|
@@ -21407,21 +21488,18 @@ var encodeVlq = function(value) {
|
|
|
21407
21488
|
if (valueToEncode) {
|
|
21408
21489
|
nextChunk |= VLQ_CONTINUATION_BIT;
|
|
21409
21490
|
}
|
|
21410
|
-
answer +=
|
|
21491
|
+
answer += BASE64_CHARS[nextChunk];
|
|
21411
21492
|
}
|
|
21412
21493
|
return answer;
|
|
21413
21494
|
};
|
|
21414
21495
|
var BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
21415
|
-
var encodeBase64 = function(value) {
|
|
21416
|
-
return BASE64_CHARS[value] || (() => {
|
|
21417
|
-
throw new Error("Cannot Base64 encode value: ${value}");
|
|
21418
|
-
})();
|
|
21419
|
-
};
|
|
21420
21496
|
var base64Encode = function(src) {
|
|
21421
21497
|
if (typeof Buffer !== "undefined") {
|
|
21422
21498
|
return Buffer.from(src).toString("base64");
|
|
21423
21499
|
} else {
|
|
21424
|
-
|
|
21500
|
+
const bytes = new TextEncoder().encode(src);
|
|
21501
|
+
const binaryString = String.fromCodePoint(...bytes);
|
|
21502
|
+
return btoa(binaryString);
|
|
21425
21503
|
}
|
|
21426
21504
|
};
|
|
21427
21505
|
var vlqTable = new Uint8Array(128);
|
|
@@ -21443,7 +21521,7 @@ var vlqChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
|
|
|
21443
21521
|
var decodeError = function(message) {
|
|
21444
21522
|
throw new Error(message);
|
|
21445
21523
|
};
|
|
21446
|
-
var decodeVLQ =
|
|
21524
|
+
var decodeVLQ = (mapping) => {
|
|
21447
21525
|
let i = 0;
|
|
21448
21526
|
let l = mapping.length;
|
|
21449
21527
|
let result = [];
|
|
@@ -21457,11 +21535,11 @@ var decodeVLQ = function(mapping) {
|
|
|
21457
21535
|
}
|
|
21458
21536
|
const c = mapping.charCodeAt(i);
|
|
21459
21537
|
if ((c & 127) != c) {
|
|
21460
|
-
decodeError(
|
|
21538
|
+
decodeError(`Invalid mapping character: ${JSON.stringify(String.fromCharCode(c))}`);
|
|
21461
21539
|
}
|
|
21462
21540
|
const index = vlqTable[c & 127];
|
|
21463
21541
|
if (index === 255) {
|
|
21464
|
-
decodeError(
|
|
21542
|
+
decodeError(`Invalid mapping character: ${JSON.stringify(String.fromCharCode(c))}`);
|
|
21465
21543
|
}
|
|
21466
21544
|
i++;
|
|
21467
21545
|
vlq |= (index & 31) << shift;
|
|
@@ -21479,7 +21557,7 @@ var decodeVLQ = function(mapping) {
|
|
|
21479
21557
|
}
|
|
21480
21558
|
return result;
|
|
21481
21559
|
};
|
|
21482
|
-
var remapPosition =
|
|
21560
|
+
var remapPosition = (position, sourcemapLines) => {
|
|
21483
21561
|
const [line, character] = position;
|
|
21484
21562
|
const textLine = sourcemapLines[line];
|
|
21485
21563
|
if (!textLine?.length) {
|
|
@@ -21512,7 +21590,7 @@ var remapPosition = function(position, sourcemapLines) {
|
|
|
21512
21590
|
}
|
|
21513
21591
|
};
|
|
21514
21592
|
|
|
21515
|
-
// unplugin-civet
|
|
21593
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\state-cache.civet.jsx
|
|
21516
21594
|
var StateCache = class {
|
|
21517
21595
|
cache = /* @__PURE__ */ new Map();
|
|
21518
21596
|
get(key) {
|
|
@@ -21552,7 +21630,7 @@ var StateCache = class {
|
|
|
21552
21630
|
}
|
|
21553
21631
|
};
|
|
21554
21632
|
|
|
21555
|
-
// unplugin-civet
|
|
21633
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\worker-pool.civet.jsx
|
|
21556
21634
|
var WorkerPool = class {
|
|
21557
21635
|
idle;
|
|
21558
21636
|
spawned;
|
|
@@ -21648,7 +21726,7 @@ var WorkerPool = class {
|
|
|
21648
21726
|
}
|
|
21649
21727
|
};
|
|
21650
21728
|
|
|
21651
|
-
// unplugin-civet
|
|
21729
|
+
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\main.civet.jsx
|
|
21652
21730
|
var { SourceMap: SourceMap2 } = sourcemap_civet_exports;
|
|
21653
21731
|
var ParseErrors = class extends Error {
|
|
21654
21732
|
name = "ParseErrors";
|
|
@@ -21708,7 +21786,32 @@ var uncacheable = /* @__PURE__ */ new Set([
|
|
|
21708
21786
|
"RestorePipeline"
|
|
21709
21787
|
]);
|
|
21710
21788
|
var workerPool;
|
|
21789
|
+
function decode(src) {
|
|
21790
|
+
if (typeof src === "string") {
|
|
21791
|
+
return src;
|
|
21792
|
+
}
|
|
21793
|
+
if (typeof Buffer === "undefined") {
|
|
21794
|
+
return src;
|
|
21795
|
+
}
|
|
21796
|
+
if (!Buffer?.isBuffer(src)) {
|
|
21797
|
+
return src;
|
|
21798
|
+
}
|
|
21799
|
+
if (src[0] === 239 && src[1] === 187 && src[2] === 191) {
|
|
21800
|
+
return src.toString("utf8", 3);
|
|
21801
|
+
} else if (src[0] === 255 && src[1] === 254) {
|
|
21802
|
+
return src.toString("utf16le", 2);
|
|
21803
|
+
} else if (src[0] === 254 && src[1] === 255) {
|
|
21804
|
+
for (let end = src.length - 2, i1 = 2; i1 <= end; i1 += 2) {
|
|
21805
|
+
const i = i1;
|
|
21806
|
+
[src[i], src[i + 1]] = [src[i + 1], src[i]];
|
|
21807
|
+
}
|
|
21808
|
+
return src.toString("utf16le", 2);
|
|
21809
|
+
} else {
|
|
21810
|
+
return src.toString("utf8");
|
|
21811
|
+
}
|
|
21812
|
+
}
|
|
21711
21813
|
function compile(src, options) {
|
|
21814
|
+
src = decode(src);
|
|
21712
21815
|
if (!(process.env.CIVET_THREADS == 0)) {
|
|
21713
21816
|
const threads = parseInt(options?.threads ?? process.env.CIVET_THREADS, 10);
|
|
21714
21817
|
if (threads === 0) {
|
|
@@ -21806,7 +21909,8 @@ ${counts}`;
|
|
|
21806
21909
|
const code = generate_civet_default(ast2, options);
|
|
21807
21910
|
checkErrors();
|
|
21808
21911
|
if (options.inlineMap) {
|
|
21809
|
-
return
|
|
21912
|
+
return `${code}
|
|
21913
|
+
${options.sourceMap.comment(filename2, filename2 + ".tsx")}`;
|
|
21810
21914
|
} else {
|
|
21811
21915
|
return {
|
|
21812
21916
|
code,
|
|
@@ -21904,6 +22008,7 @@ var main_civet_default = { parse, parseProgram, ParseError: import_lib2.ParseErr
|
|
|
21904
22008
|
ParseErrors,
|
|
21905
22009
|
SourceMap,
|
|
21906
22010
|
compile,
|
|
22011
|
+
decode,
|
|
21907
22012
|
generate,
|
|
21908
22013
|
isCompileError,
|
|
21909
22014
|
lib,
|