@danielx/civet 0.10.4 → 0.10.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -1
- package/dist/browser.js +146 -95
- package/dist/civet +1 -0
- package/dist/main.js +192 -139
- package/dist/main.mjs +192 -139
- package/dist/unplugin/unplugin.js +2 -2
- package/dist/unplugin/unplugin.mjs +2 -2
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -515,6 +515,8 @@ __export(lib_civet_exports, {
|
|
|
515
515
|
blockWithPrefix: () => blockWithPrefix,
|
|
516
516
|
braceBlock: () => braceBlock,
|
|
517
517
|
bracedBlock: () => bracedBlock,
|
|
518
|
+
convertArrowFunctionToMethod: () => convertArrowFunctionToMethod,
|
|
519
|
+
convertFunctionToMethod: () => convertFunctionToMethod,
|
|
518
520
|
convertNamedImportsToObject: () => convertNamedImportsToObject,
|
|
519
521
|
convertObjectToJSXAttributes: () => convertObjectToJSXAttributes,
|
|
520
522
|
convertWithClause: () => convertWithClause,
|
|
@@ -6799,7 +6801,7 @@ function createVarDecs(block, scopes, pushVar) {
|
|
|
6799
6801
|
findAssignments(assignmentStatements2.map((s) => s.children), decs2)
|
|
6800
6802
|
);
|
|
6801
6803
|
}
|
|
6802
|
-
return assignmentStatements2;
|
|
6804
|
+
return assignmentStatements2.filter(($4) => !($4.parent?.type === "CoffeeClassPublic"));
|
|
6803
6805
|
}
|
|
6804
6806
|
pushVar ??= (name) => {
|
|
6805
6807
|
varIds.push(name);
|
|
@@ -6810,7 +6812,7 @@ function createVarDecs(block, scopes, pushVar) {
|
|
|
6810
6812
|
scopes.push(decs);
|
|
6811
6813
|
const varIds = [];
|
|
6812
6814
|
const assignmentStatements = findAssignments(statements, scopes);
|
|
6813
|
-
const undeclaredIdentifiers = assignmentStatements.flatMap(($
|
|
6815
|
+
const undeclaredIdentifiers = assignmentStatements.flatMap(($5) => $5?.names || []);
|
|
6814
6816
|
undeclaredIdentifiers.filter((x, i, a) => {
|
|
6815
6817
|
if (!hasDec(x)) return a.indexOf(x) === i;
|
|
6816
6818
|
return;
|
|
@@ -7688,6 +7690,45 @@ function convertMethodToFunction(method) {
|
|
|
7688
7690
|
block
|
|
7689
7691
|
};
|
|
7690
7692
|
}
|
|
7693
|
+
function convertFunctionToMethod(id, exp) {
|
|
7694
|
+
const fnTokenIndex = exp.children.findIndex(function(c) {
|
|
7695
|
+
return c?.token?.startsWith("function");
|
|
7696
|
+
});
|
|
7697
|
+
const children = exp.children.slice();
|
|
7698
|
+
if (exp.generator) {
|
|
7699
|
+
children.splice(fnTokenIndex, 2, children[fnTokenIndex + 1], id);
|
|
7700
|
+
} else {
|
|
7701
|
+
children.splice(fnTokenIndex, 1, id);
|
|
7702
|
+
}
|
|
7703
|
+
return {
|
|
7704
|
+
...exp,
|
|
7705
|
+
type: "MethodDefinition",
|
|
7706
|
+
name: id.name,
|
|
7707
|
+
signature: { ...exp.signature, id, name: id.name },
|
|
7708
|
+
children
|
|
7709
|
+
};
|
|
7710
|
+
}
|
|
7711
|
+
function convertArrowFunctionToMethod(id, exp) {
|
|
7712
|
+
const block = { ...exp.block };
|
|
7713
|
+
const children = exp.children.filter(function(c) {
|
|
7714
|
+
return !(Array.isArray(c) && c[c.length - 1]?.token?.includes("=>"));
|
|
7715
|
+
}).map(function(c) {
|
|
7716
|
+
return c === exp.block ? block : c;
|
|
7717
|
+
});
|
|
7718
|
+
children.unshift(id);
|
|
7719
|
+
exp = {
|
|
7720
|
+
...exp,
|
|
7721
|
+
type: "MethodDefinition",
|
|
7722
|
+
name: id.name,
|
|
7723
|
+
signature: { ...exp.signature, id, name: id.name },
|
|
7724
|
+
block,
|
|
7725
|
+
children,
|
|
7726
|
+
autoBind: true
|
|
7727
|
+
};
|
|
7728
|
+
block.parent = exp;
|
|
7729
|
+
braceBlock(block);
|
|
7730
|
+
return exp;
|
|
7731
|
+
}
|
|
7691
7732
|
function convertNamedImportsToObject(node, pattern) {
|
|
7692
7733
|
const properties = node.specifiers.map((specifier) => {
|
|
7693
7734
|
if (specifier.ts) {
|
|
@@ -8472,7 +8513,17 @@ function processCoffeeClasses(statements) {
|
|
|
8472
8513
|
})()
|
|
8473
8514
|
);
|
|
8474
8515
|
}
|
|
8475
|
-
const
|
|
8516
|
+
const public_static_function_assignments = expressions.filter(($15) => $15[1]?.type === "CoffeeClassPublic" && $15[1].assignment?.expression?.type === "FunctionExpression").map(($16) => $16[1].assignment);
|
|
8517
|
+
for (const public_static_function_assignment of public_static_function_assignments) {
|
|
8518
|
+
const id = public_static_function_assignment.lhs[0][1];
|
|
8519
|
+
replaceNode(public_static_function_assignment, convertFunctionToMethod(id, public_static_function_assignment.expression));
|
|
8520
|
+
}
|
|
8521
|
+
const public_static_arrow_function_assignments = expressions.filter(($17) => $17[1]?.type === "CoffeeClassPublic" && $17[1].assignment?.expression?.type === "ArrowFunction").map(($18) => $18[1].assignment);
|
|
8522
|
+
for (const public_static_arrow_function_assignment of public_static_arrow_function_assignments) {
|
|
8523
|
+
const id = public_static_arrow_function_assignment.lhs[0][1];
|
|
8524
|
+
replaceNode(public_static_arrow_function_assignment, convertArrowFunctionToMethod(id, public_static_arrow_function_assignment.expression));
|
|
8525
|
+
}
|
|
8526
|
+
const privates = expressions.filter(($19) => $19[1]?.type === "CoffeeClassPrivate");
|
|
8476
8527
|
if (!privates.length) {
|
|
8477
8528
|
continue;
|
|
8478
8529
|
}
|
|
@@ -8537,7 +8588,7 @@ function processProgram(root) {
|
|
|
8537
8588
|
root.topLevelYield ? "*" : void 0
|
|
8538
8589
|
);
|
|
8539
8590
|
statements = [["", rootIIFE]];
|
|
8540
|
-
root.children = root.children.map(($
|
|
8591
|
+
root.children = root.children.map(($20) => $20 === root.expressions ? statements : $20);
|
|
8541
8592
|
root.expressions = statements;
|
|
8542
8593
|
}
|
|
8543
8594
|
hoistRefDecs(statements);
|
|
@@ -8568,9 +8619,9 @@ async function processProgramAsync(root) {
|
|
|
8568
8619
|
await processComptime(statements);
|
|
8569
8620
|
}
|
|
8570
8621
|
function processRepl(root, rootIIFE) {
|
|
8571
|
-
const topBlock = gatherRecursive(rootIIFE, ($
|
|
8622
|
+
const topBlock = gatherRecursive(rootIIFE, ($21) => $21.type === "BlockStatement")[0];
|
|
8572
8623
|
let i = 0;
|
|
8573
|
-
for (let ref23 = gatherRecursiveWithinFunction(topBlock, ($
|
|
8624
|
+
for (let ref23 = gatherRecursiveWithinFunction(topBlock, ($22) => $22.type === "Declaration"), i14 = 0, len11 = ref23.length; i14 < len11; i14++) {
|
|
8574
8625
|
const decl = ref23[i14];
|
|
8575
8626
|
if (!decl.names?.length) {
|
|
8576
8627
|
continue;
|
|
@@ -8584,7 +8635,7 @@ function processRepl(root, rootIIFE) {
|
|
|
8584
8635
|
root.expressions.splice(i++, 0, ["", `var ${decl.names.join(",")}`, ";"]);
|
|
8585
8636
|
}
|
|
8586
8637
|
}
|
|
8587
|
-
for (let ref24 = gatherRecursive(topBlock, ($
|
|
8638
|
+
for (let ref24 = gatherRecursive(topBlock, ($23) => $23.type === "FunctionExpression"), i15 = 0, len12 = ref24.length; i15 < len12; i15++) {
|
|
8588
8639
|
const func = ref24[i15];
|
|
8589
8640
|
if (func.name && func.parent?.type === "BlockStatement") {
|
|
8590
8641
|
if (func.parent === topBlock) {
|
|
@@ -8597,7 +8648,7 @@ function processRepl(root, rootIIFE) {
|
|
|
8597
8648
|
}
|
|
8598
8649
|
}
|
|
8599
8650
|
}
|
|
8600
|
-
for (let ref25 = gatherRecursiveWithinFunction(topBlock, ($
|
|
8651
|
+
for (let ref25 = gatherRecursiveWithinFunction(topBlock, ($24) => $24.type === "ClassExpression"), i16 = 0, len13 = ref25.length; i16 < len13; i16++) {
|
|
8601
8652
|
const classExp = ref25[i16];
|
|
8602
8653
|
let m8;
|
|
8603
8654
|
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 +8660,7 @@ function processRepl(root, rootIIFE) {
|
|
|
8609
8660
|
function processPlaceholders(statements) {
|
|
8610
8661
|
const placeholderMap = /* @__PURE__ */ new Map();
|
|
8611
8662
|
const liftedIfs = /* @__PURE__ */ new Set();
|
|
8612
|
-
for (let ref26 = gatherRecursiveAll(statements, ($
|
|
8663
|
+
for (let ref26 = gatherRecursiveAll(statements, ($25) => $25.type === "Placeholder"), i17 = 0, len14 = ref26.length; i17 < len14; i17++) {
|
|
8613
8664
|
const exp = ref26[i17];
|
|
8614
8665
|
let ancestor;
|
|
8615
8666
|
if (exp.subtype === ".") {
|
|
@@ -9011,6 +9062,7 @@ var grammar = {
|
|
|
9011
9062
|
AccessModifier,
|
|
9012
9063
|
FieldDefinition,
|
|
9013
9064
|
ThisLiteral,
|
|
9065
|
+
BasicThisLiteral,
|
|
9014
9066
|
HashThis,
|
|
9015
9067
|
LengthShorthand,
|
|
9016
9068
|
AtThis,
|
|
@@ -9996,7 +10048,7 @@ var $R9 = (0, import_lib2.$R)(new RegExp("(?=[\\/?])", "suy"));
|
|
|
9996
10048
|
var $R10 = (0, import_lib2.$R)(new RegExp("(?=[\\/\\[{?.!@#'\u2019:])", "suy"));
|
|
9997
10049
|
var $R11 = (0, import_lib2.$R)(new RegExp("%%?", "suy"));
|
|
9998
10050
|
var $R12 = (0, import_lib2.$R)(new RegExp("[.\\s]", "suy"));
|
|
9999
|
-
var $R13 = (0, import_lib2.$R)(new RegExp("[)}]", "suy"));
|
|
10051
|
+
var $R13 = (0, import_lib2.$R)(new RegExp("[)\\]}]", "suy"));
|
|
10000
10052
|
var $R14 = (0, import_lib2.$R)(new RegExp("[+-]", "suy"));
|
|
10001
10053
|
var $R15 = (0, import_lib2.$R)(new RegExp("\\+\\+|--|\u29FA|\u2014|[\\+\\-&]\\S", "suy"));
|
|
10002
10054
|
var $R16 = (0, import_lib2.$R)(new RegExp(`(?=[0-9.'"tfyno])`, "suy"));
|
|
@@ -11376,7 +11428,20 @@ var NestedClassElement$0 = (0, import_lib2.$S)(Nested, ClassElement, StatementDe
|
|
|
11376
11428
|
function NestedClassElement(ctx, state2) {
|
|
11377
11429
|
return (0, import_lib2.$EVENT)(ctx, state2, "NestedClassElement", NestedClassElement$0);
|
|
11378
11430
|
}
|
|
11379
|
-
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)(_))),
|
|
11431
|
+
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) {
|
|
11432
|
+
var decorators = $2;
|
|
11433
|
+
var declare = $3;
|
|
11434
|
+
var access = $4;
|
|
11435
|
+
var static_ = $5;
|
|
11436
|
+
var override = $6;
|
|
11437
|
+
var assignment = $7;
|
|
11438
|
+
return {
|
|
11439
|
+
type: static_ ? "CoffeeClassPublic" : "CoffeeClassPrivate",
|
|
11440
|
+
children: [decorators, declare, access, static_, override, assignment],
|
|
11441
|
+
assignment
|
|
11442
|
+
};
|
|
11443
|
+
});
|
|
11444
|
+
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) {
|
|
11380
11445
|
var decorators = $1;
|
|
11381
11446
|
var declare = $2;
|
|
11382
11447
|
var access = $3;
|
|
@@ -11402,14 +11467,14 @@ var ClassElement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E
|
|
|
11402
11467
|
children: [decorators, declare, access, static_, override, ...definition.children]
|
|
11403
11468
|
};
|
|
11404
11469
|
});
|
|
11405
|
-
var ClassElement$
|
|
11470
|
+
var ClassElement$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(Static, BracedBlock), function($skip, $loc, $0, $1, $2) {
|
|
11406
11471
|
return {
|
|
11407
11472
|
type: "ClassStaticBlock",
|
|
11408
11473
|
children: $0
|
|
11409
11474
|
};
|
|
11410
11475
|
});
|
|
11411
|
-
var ClassElement$
|
|
11412
|
-
var ClassElement$$ = [ClassElement$0, ClassElement$1, ClassElement$2];
|
|
11476
|
+
var ClassElement$3 = EmptyStatement;
|
|
11477
|
+
var ClassElement$$ = [ClassElement$0, ClassElement$1, ClassElement$2, ClassElement$3];
|
|
11413
11478
|
function ClassElement(ctx, state2) {
|
|
11414
11479
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "ClassElement", ClassElement$$);
|
|
11415
11480
|
}
|
|
@@ -11462,37 +11527,10 @@ var FieldDefinition$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(CoffeeClassesEn
|
|
|
11462
11527
|
var exp = $6;
|
|
11463
11528
|
switch (exp.type) {
|
|
11464
11529
|
case "FunctionExpression": {
|
|
11465
|
-
|
|
11466
|
-
const children = exp.children.slice();
|
|
11467
|
-
if (exp.generator) {
|
|
11468
|
-
children.splice(fnTokenIndex, 2, children[fnTokenIndex + 1], id);
|
|
11469
|
-
} else {
|
|
11470
|
-
children.splice(fnTokenIndex, 1, id);
|
|
11471
|
-
}
|
|
11472
|
-
return {
|
|
11473
|
-
...exp,
|
|
11474
|
-
type: "MethodDefinition",
|
|
11475
|
-
name: id.name,
|
|
11476
|
-
signature: { ...exp.signature, id, name: id.name },
|
|
11477
|
-
children
|
|
11478
|
-
};
|
|
11530
|
+
return convertFunctionToMethod(id, exp);
|
|
11479
11531
|
}
|
|
11480
11532
|
case "ArrowFunction": {
|
|
11481
|
-
|
|
11482
|
-
const children = exp.children.filter((c) => !(Array.isArray(c) && c[c.length - 1]?.token?.includes("=>"))).map((c) => c === exp.block ? block : c);
|
|
11483
|
-
children.unshift(id);
|
|
11484
|
-
exp = {
|
|
11485
|
-
...exp,
|
|
11486
|
-
type: "MethodDefinition",
|
|
11487
|
-
name: id.name,
|
|
11488
|
-
signature: { ...exp.signature, id, name: id.name },
|
|
11489
|
-
block,
|
|
11490
|
-
children,
|
|
11491
|
-
autoBind: true
|
|
11492
|
-
};
|
|
11493
|
-
block.parent = exp;
|
|
11494
|
-
braceBlock(block);
|
|
11495
|
-
return exp;
|
|
11533
|
+
return convertArrowFunctionToMethod(id, exp);
|
|
11496
11534
|
}
|
|
11497
11535
|
default:
|
|
11498
11536
|
return {
|
|
@@ -11519,15 +11557,7 @@ var FieldDefinition$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(InsertReadonly,
|
|
|
11519
11557
|
readonly
|
|
11520
11558
|
};
|
|
11521
11559
|
});
|
|
11522
|
-
var FieldDefinition$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(
|
|
11523
|
-
var assignment = $2;
|
|
11524
|
-
return {
|
|
11525
|
-
type: "CoffeeClassPrivate",
|
|
11526
|
-
children: [assignment],
|
|
11527
|
-
assignment
|
|
11528
|
-
};
|
|
11529
|
-
});
|
|
11530
|
-
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) {
|
|
11560
|
+
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) {
|
|
11531
11561
|
var abstract = $1;
|
|
11532
11562
|
var readonly = $2;
|
|
11533
11563
|
var id = $3;
|
|
@@ -11544,15 +11574,12 @@ var FieldDefinition$3 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2
|
|
|
11544
11574
|
initializer
|
|
11545
11575
|
};
|
|
11546
11576
|
});
|
|
11547
|
-
var FieldDefinition$$ = [FieldDefinition$0, FieldDefinition$1, FieldDefinition$2
|
|
11577
|
+
var FieldDefinition$$ = [FieldDefinition$0, FieldDefinition$1, FieldDefinition$2];
|
|
11548
11578
|
function FieldDefinition(ctx, state2) {
|
|
11549
11579
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "FieldDefinition", FieldDefinition$$);
|
|
11550
11580
|
}
|
|
11551
|
-
var ThisLiteral$0 =
|
|
11552
|
-
|
|
11553
|
-
});
|
|
11554
|
-
var ThisLiteral$1 = HashThis;
|
|
11555
|
-
var ThisLiteral$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(AtThis, (0, import_lib2.$TEXT)((0, import_lib2.$S)((0, import_lib2.$E)(Hash), IdentifierName))), function($skip, $loc, $0, $1, $2) {
|
|
11581
|
+
var ThisLiteral$0 = HashThis;
|
|
11582
|
+
var ThisLiteral$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(AtThis, (0, import_lib2.$TEXT)((0, import_lib2.$S)((0, import_lib2.$E)(Hash), IdentifierName))), function($skip, $loc, $0, $1, $2) {
|
|
11556
11583
|
var at = $1;
|
|
11557
11584
|
var id = $2;
|
|
11558
11585
|
return {
|
|
@@ -11571,11 +11598,19 @@ var ThisLiteral$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(AtThis, (0, import_
|
|
|
11571
11598
|
thisShorthand: true
|
|
11572
11599
|
};
|
|
11573
11600
|
});
|
|
11574
|
-
var ThisLiteral$
|
|
11575
|
-
var ThisLiteral$$ = [ThisLiteral$0, ThisLiteral$1, ThisLiteral$2
|
|
11601
|
+
var ThisLiteral$2 = BasicThisLiteral;
|
|
11602
|
+
var ThisLiteral$$ = [ThisLiteral$0, ThisLiteral$1, ThisLiteral$2];
|
|
11576
11603
|
function ThisLiteral(ctx, state2) {
|
|
11577
11604
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "ThisLiteral", ThisLiteral$$);
|
|
11578
11605
|
}
|
|
11606
|
+
var BasicThisLiteral$0 = (0, import_lib2.$T)((0, import_lib2.$S)(This), function(value) {
|
|
11607
|
+
return { "type": "Identifier", "name": "this", "children": [value[0]] };
|
|
11608
|
+
});
|
|
11609
|
+
var BasicThisLiteral$1 = AtThis;
|
|
11610
|
+
var BasicThisLiteral$$ = [BasicThisLiteral$0, BasicThisLiteral$1];
|
|
11611
|
+
function BasicThisLiteral(ctx, state2) {
|
|
11612
|
+
return (0, import_lib2.$EVENT_C)(ctx, state2, "BasicThisLiteral", BasicThisLiteral$$);
|
|
11613
|
+
}
|
|
11579
11614
|
var HashThis$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(AtThis), LengthShorthand, (0, import_lib2.$E)((0, import_lib2.$S)((0, import_lib2.$Y)((0, import_lib2.$S)(_, (0, import_lib2.$E)((0, import_lib2.$S)(Not, __)), ActualIn)), (0, import_lib2.$EXPECT)($L0, 'HashThis ""')))), function($skip, $loc, $0, $1, $2, $3) {
|
|
11580
11615
|
var at = $1;
|
|
11581
11616
|
var id = $2;
|
|
@@ -11612,7 +11647,7 @@ var HashThis$$ = [HashThis$0, HashThis$1, HashThis$2];
|
|
|
11612
11647
|
function HashThis(ctx, state2) {
|
|
11613
11648
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "HashThis", HashThis$$);
|
|
11614
11649
|
}
|
|
11615
|
-
var LengthShorthand$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Hash, NonIdContinue), function($skip, $loc, $0, $1, $2) {
|
|
11650
|
+
var LengthShorthand$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$N)(CoffeeCommentEnabled), Hash, NonIdContinue), function($skip, $loc, $0, $1, $2, $3) {
|
|
11616
11651
|
const id = "length";
|
|
11617
11652
|
return {
|
|
11618
11653
|
type: "Identifier",
|
|
@@ -12310,7 +12345,7 @@ function ParameterElement(ctx, state2) {
|
|
|
12310
12345
|
return (0, import_lib2.$EVENT)(ctx, state2, "ParameterElement", ParameterElement$0);
|
|
12311
12346
|
}
|
|
12312
12347
|
var ParameterElementDelimiter$0 = (0, import_lib2.$S)((0, import_lib2.$E)(_), Comma);
|
|
12313
|
-
var ParameterElementDelimiter$1 = (0, import_lib2.$Y)((0, import_lib2.$S)(__, (0, import_lib2.$R$0)((0, import_lib2.$EXPECT)($R13, "ParameterElementDelimiter /[)}]/"))));
|
|
12348
|
+
var ParameterElementDelimiter$1 = (0, import_lib2.$Y)((0, import_lib2.$S)(__, (0, import_lib2.$R$0)((0, import_lib2.$EXPECT)($R13, "ParameterElementDelimiter /[)\\]}]/"))));
|
|
12314
12349
|
var ParameterElementDelimiter$2 = (0, import_lib2.$T)((0, import_lib2.$S)((0, import_lib2.$Y)(EOS), InsertComma), function(value) {
|
|
12315
12350
|
return value[1];
|
|
12316
12351
|
});
|
|
@@ -14246,7 +14281,7 @@ function InlineObjectPropertyDelimiter(ctx, state2) {
|
|
|
14246
14281
|
return (0, import_lib2.$EVENT)(ctx, state2, "InlineObjectPropertyDelimiter", InlineObjectPropertyDelimiter$0);
|
|
14247
14282
|
}
|
|
14248
14283
|
var ObjectPropertyDelimiter$0 = (0, import_lib2.$S)((0, import_lib2.$E)(_), Comma);
|
|
14249
|
-
var ObjectPropertyDelimiter$1 = (0, import_lib2.$Y)((0, import_lib2.$S)(__, (0, import_lib2.$EXPECT)($
|
|
14284
|
+
var ObjectPropertyDelimiter$1 = (0, import_lib2.$Y)((0, import_lib2.$S)(__, (0, import_lib2.$R$0)((0, import_lib2.$EXPECT)($R13, "ObjectPropertyDelimiter /[)\\]}]/"))));
|
|
14250
14285
|
var ObjectPropertyDelimiter$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$Y)(EOS), InsertComma), function($skip, $loc, $0, $1, $2) {
|
|
14251
14286
|
return { ...$2, implicit: true };
|
|
14252
14287
|
});
|
|
@@ -19904,7 +19939,14 @@ var TypeIdentifier$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.
|
|
|
19904
19939
|
args
|
|
19905
19940
|
};
|
|
19906
19941
|
});
|
|
19907
|
-
var TypeIdentifier
|
|
19942
|
+
var TypeIdentifier$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), BasicThisLiteral), function($skip, $loc, $0, $1, $2) {
|
|
19943
|
+
return {
|
|
19944
|
+
type: "TypeIdentifier",
|
|
19945
|
+
children: $0,
|
|
19946
|
+
raw: $2.name
|
|
19947
|
+
};
|
|
19948
|
+
});
|
|
19949
|
+
var TypeIdentifier$$ = [TypeIdentifier$0, TypeIdentifier$1, TypeIdentifier$2];
|
|
19908
19950
|
function TypeIdentifier(ctx, state2) {
|
|
19909
19951
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "TypeIdentifier", TypeIdentifier$$);
|
|
19910
19952
|
}
|
|
@@ -21190,6 +21232,7 @@ var sourcemap_civet_exports = {};
|
|
|
21190
21232
|
__export(sourcemap_civet_exports, {
|
|
21191
21233
|
SourceMap: () => SourceMap,
|
|
21192
21234
|
base64Encode: () => base64Encode,
|
|
21235
|
+
decodeVLQ: () => decodeVLQ,
|
|
21193
21236
|
locationTable: () => locationTable,
|
|
21194
21237
|
lookupLineColumn: () => lookupLineColumn
|
|
21195
21238
|
});
|
|
@@ -21225,7 +21268,6 @@ var SourceMap = class {
|
|
|
21225
21268
|
// relative to previous entry
|
|
21226
21269
|
srcLine;
|
|
21227
21270
|
srcColumn;
|
|
21228
|
-
srcOffset;
|
|
21229
21271
|
srcTable;
|
|
21230
21272
|
source;
|
|
21231
21273
|
constructor(source1) {
|
|
@@ -21235,7 +21277,6 @@ var SourceMap = class {
|
|
|
21235
21277
|
this.colOffset = 0;
|
|
21236
21278
|
this.srcLine = 0;
|
|
21237
21279
|
this.srcColumn = 0;
|
|
21238
|
-
this.srcOffset = 0;
|
|
21239
21280
|
this.srcTable = locationTable(this.source);
|
|
21240
21281
|
}
|
|
21241
21282
|
renderMappings() {
|
|
@@ -21279,6 +21320,10 @@ var SourceMap = class {
|
|
|
21279
21320
|
}
|
|
21280
21321
|
};
|
|
21281
21322
|
}
|
|
21323
|
+
/** Generate a comment with the source mapping URL. */
|
|
21324
|
+
comment(srcFileName, outFileName) {
|
|
21325
|
+
return `//${"#"} sourceMappingURL=data:application/json;base64,${base64Encode(JSON.stringify(this.json(srcFileName, outFileName)))}`;
|
|
21326
|
+
}
|
|
21282
21327
|
updateSourceMap(outputStr, inputPos, colOffset = 0) {
|
|
21283
21328
|
const outLines = outputStr.split(EOL2);
|
|
21284
21329
|
let srcLine, srcCol;
|
|
@@ -21287,7 +21332,6 @@ var SourceMap = class {
|
|
|
21287
21332
|
srcCol += colOffset;
|
|
21288
21333
|
this.srcLine = srcLine;
|
|
21289
21334
|
this.srcColumn = srcCol;
|
|
21290
|
-
this.srcOffset = inputPos + outputStr.length;
|
|
21291
21335
|
}
|
|
21292
21336
|
for (let i3 = 0, len22 = outLines.length; i3 < len22; i3++) {
|
|
21293
21337
|
const i = i3;
|
|
@@ -21310,74 +21354,85 @@ var SourceMap = class {
|
|
|
21310
21354
|
}
|
|
21311
21355
|
return;
|
|
21312
21356
|
}
|
|
21313
|
-
|
|
21314
|
-
|
|
21315
|
-
|
|
21316
|
-
|
|
21317
|
-
|
|
21318
|
-
|
|
21319
|
-
|
|
21320
|
-
|
|
21321
|
-
|
|
21322
|
-
|
|
21323
|
-
const composedLines = composeLines(upstreamMap.lines, parsed.lines);
|
|
21324
|
-
upstreamMap.lines = composedLines;
|
|
21325
|
-
}
|
|
21326
|
-
const remappedSourceMapJSON = upstreamMap.json(sourcePath, targetPath);
|
|
21327
|
-
const newSourceMap = `${"sourceMapping"}URL=data:application/json;charset=utf-8;base64,${base64Encode(JSON.stringify(remappedSourceMapJSON))}`;
|
|
21328
|
-
const remappedCodeWithSourceMap = `${codeWithoutSourceMap}
|
|
21329
|
-
//# ${newSourceMap}`;
|
|
21330
|
-
return remappedCodeWithSourceMap;
|
|
21331
|
-
};
|
|
21332
|
-
var composeLines = function(upstreamMapping, lines) {
|
|
21333
|
-
return lines.map((line) => {
|
|
21334
|
-
return line.map((entry) => {
|
|
21335
|
-
if (entry.length === 1) {
|
|
21336
|
-
return entry;
|
|
21337
|
-
}
|
|
21338
|
-
const [colDelta, sourceFileIndex, srcLine, srcCol] = entry;
|
|
21339
|
-
const srcPos = remapPosition([srcLine, srcCol], upstreamMapping);
|
|
21340
|
-
if (!srcPos) {
|
|
21341
|
-
return [entry[0]];
|
|
21342
|
-
}
|
|
21343
|
-
const [upstreamLine, upstreamCol] = srcPos;
|
|
21344
|
-
if (entry.length === 4) {
|
|
21345
|
-
return [colDelta, sourceFileIndex, upstreamLine, upstreamCol];
|
|
21346
|
-
}
|
|
21347
|
-
return [colDelta, sourceFileIndex, upstreamLine, upstreamCol, entry[4]];
|
|
21357
|
+
/**
|
|
21358
|
+
Remap a string with compiled code and a source map to use a new source map
|
|
21359
|
+
referencing upstream source files.
|
|
21360
|
+
This modifies the upstream map in place.
|
|
21361
|
+
*/
|
|
21362
|
+
static remap = (codeWithSourceMap, upstreamMap, sourcePath, targetPath) => {
|
|
21363
|
+
let sourceMapText;
|
|
21364
|
+
const codeWithoutSourceMap = codeWithSourceMap.replace(smRegexp, (_match, sm) => {
|
|
21365
|
+
sourceMapText = sm;
|
|
21366
|
+
return "";
|
|
21348
21367
|
});
|
|
21349
|
-
|
|
21350
|
-
|
|
21351
|
-
|
|
21352
|
-
|
|
21353
|
-
let sourceLine = 0;
|
|
21354
|
-
let sourceColumn = 0;
|
|
21355
|
-
const lines = json.mappings.split(";").map((line) => {
|
|
21356
|
-
if (line.length === 0) {
|
|
21357
|
-
return [];
|
|
21368
|
+
if (sourceMapText) {
|
|
21369
|
+
const parsed = this.parseWithLines(sourceMapText);
|
|
21370
|
+
const composedLines = this.composeLines(upstreamMap.lines, parsed.lines);
|
|
21371
|
+
upstreamMap.lines = composedLines;
|
|
21358
21372
|
}
|
|
21359
|
-
|
|
21360
|
-
|
|
21361
|
-
|
|
21362
|
-
|
|
21363
|
-
|
|
21364
|
-
|
|
21365
|
-
|
|
21366
|
-
|
|
21373
|
+
const remappedCodeWithSourceMap = `${codeWithoutSourceMap}
|
|
21374
|
+
${upstreamMap.comment(sourcePath, targetPath)}`;
|
|
21375
|
+
return remappedCodeWithSourceMap;
|
|
21376
|
+
};
|
|
21377
|
+
/**
|
|
21378
|
+
Compose lines from an upstream source map with lines from a downstream source map.
|
|
21379
|
+
*/
|
|
21380
|
+
static composeLines = (upstreamMapping, lines) => {
|
|
21381
|
+
return lines.map((line) => {
|
|
21382
|
+
return line.map((entry) => {
|
|
21383
|
+
if (entry.length === 1) {
|
|
21384
|
+
return entry;
|
|
21367
21385
|
}
|
|
21368
|
-
|
|
21369
|
-
|
|
21386
|
+
const [colDelta, sourceFileIndex, srcLine, srcCol] = entry;
|
|
21387
|
+
const srcPos = remapPosition([srcLine, srcCol], upstreamMapping);
|
|
21388
|
+
if (!srcPos) {
|
|
21389
|
+
return [entry[0]];
|
|
21370
21390
|
}
|
|
21371
|
-
|
|
21372
|
-
|
|
21391
|
+
const [upstreamLine, upstreamCol] = srcPos;
|
|
21392
|
+
if (entry.length === 4) {
|
|
21393
|
+
return [colDelta, sourceFileIndex, upstreamLine, upstreamCol];
|
|
21373
21394
|
}
|
|
21395
|
+
return [colDelta, sourceFileIndex, upstreamLine, upstreamCol, entry[4]];
|
|
21396
|
+
});
|
|
21397
|
+
});
|
|
21398
|
+
};
|
|
21399
|
+
/**
|
|
21400
|
+
Parse a base64 encoded source map string into a SourceMapJSON object with lines.
|
|
21401
|
+
*/
|
|
21402
|
+
static parseWithLines = (base64encodedJSONstr) => {
|
|
21403
|
+
const json = JSON.parse(Buffer.from(base64encodedJSONstr, "base64").toString("utf8"));
|
|
21404
|
+
let sourceLine = 0;
|
|
21405
|
+
let sourceColumn = 0;
|
|
21406
|
+
const lines = json.mappings.split(";").map((line) => {
|
|
21407
|
+
if (line.length === 0) {
|
|
21408
|
+
return [];
|
|
21374
21409
|
}
|
|
21410
|
+
return line.split(",").map((entry) => {
|
|
21411
|
+
const result = decodeVLQ(entry);
|
|
21412
|
+
switch (result.length) {
|
|
21413
|
+
case 1: {
|
|
21414
|
+
;
|
|
21415
|
+
break;
|
|
21416
|
+
}
|
|
21417
|
+
case 4:
|
|
21418
|
+
case 5: {
|
|
21419
|
+
sourceLine += result[2];
|
|
21420
|
+
result[2] = sourceLine;
|
|
21421
|
+
sourceColumn += result[3];
|
|
21422
|
+
result[3] = sourceColumn;
|
|
21423
|
+
break;
|
|
21424
|
+
}
|
|
21425
|
+
default: {
|
|
21426
|
+
throw new Error(`Unknown source map entry ${JSON.stringify(result)}`);
|
|
21427
|
+
}
|
|
21428
|
+
}
|
|
21429
|
+
return result;
|
|
21430
|
+
});
|
|
21375
21431
|
});
|
|
21376
|
-
|
|
21377
|
-
|
|
21378
|
-
return json;
|
|
21432
|
+
return { ...json, lines };
|
|
21433
|
+
};
|
|
21379
21434
|
};
|
|
21380
|
-
|
|
21435
|
+
var smRegexp = /(?:\r?\n|\r)\/\/# sourceMappingURL=data:application\/json;(?:charset=[^;]*;)?base64,([+a-zA-Z0-9\/]*=?=?)(?:\s*)$/;
|
|
21381
21436
|
var VLQ_SHIFT = 5;
|
|
21382
21437
|
var VLQ_CONTINUATION_BIT = 1 << VLQ_SHIFT;
|
|
21383
21438
|
var VLQ_VALUE_MASK = VLQ_CONTINUATION_BIT - 1;
|
|
@@ -21394,21 +21449,18 @@ var encodeVlq = function(value) {
|
|
|
21394
21449
|
if (valueToEncode) {
|
|
21395
21450
|
nextChunk |= VLQ_CONTINUATION_BIT;
|
|
21396
21451
|
}
|
|
21397
|
-
answer +=
|
|
21452
|
+
answer += BASE64_CHARS[nextChunk];
|
|
21398
21453
|
}
|
|
21399
21454
|
return answer;
|
|
21400
21455
|
};
|
|
21401
21456
|
var BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
21402
|
-
var encodeBase64 = function(value) {
|
|
21403
|
-
return BASE64_CHARS[value] || (() => {
|
|
21404
|
-
throw new Error("Cannot Base64 encode value: ${value}");
|
|
21405
|
-
})();
|
|
21406
|
-
};
|
|
21407
21457
|
var base64Encode = function(src) {
|
|
21408
21458
|
if (typeof Buffer !== "undefined") {
|
|
21409
21459
|
return Buffer.from(src).toString("base64");
|
|
21410
21460
|
} else {
|
|
21411
|
-
|
|
21461
|
+
const bytes = new TextEncoder().encode(src);
|
|
21462
|
+
const binaryString = String.fromCodePoint(...bytes);
|
|
21463
|
+
return btoa(binaryString);
|
|
21412
21464
|
}
|
|
21413
21465
|
};
|
|
21414
21466
|
var vlqTable = new Uint8Array(128);
|
|
@@ -21430,7 +21482,7 @@ var vlqChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
|
|
|
21430
21482
|
var decodeError = function(message) {
|
|
21431
21483
|
throw new Error(message);
|
|
21432
21484
|
};
|
|
21433
|
-
var decodeVLQ =
|
|
21485
|
+
var decodeVLQ = (mapping) => {
|
|
21434
21486
|
let i = 0;
|
|
21435
21487
|
let l = mapping.length;
|
|
21436
21488
|
let result = [];
|
|
@@ -21444,11 +21496,11 @@ var decodeVLQ = function(mapping) {
|
|
|
21444
21496
|
}
|
|
21445
21497
|
const c = mapping.charCodeAt(i);
|
|
21446
21498
|
if ((c & 127) != c) {
|
|
21447
|
-
decodeError(
|
|
21499
|
+
decodeError(`Invalid mapping character: ${JSON.stringify(String.fromCharCode(c))}`);
|
|
21448
21500
|
}
|
|
21449
21501
|
const index = vlqTable[c & 127];
|
|
21450
21502
|
if (index === 255) {
|
|
21451
|
-
decodeError(
|
|
21503
|
+
decodeError(`Invalid mapping character: ${JSON.stringify(String.fromCharCode(c))}`);
|
|
21452
21504
|
}
|
|
21453
21505
|
i++;
|
|
21454
21506
|
vlq |= (index & 31) << shift;
|
|
@@ -21466,7 +21518,7 @@ var decodeVLQ = function(mapping) {
|
|
|
21466
21518
|
}
|
|
21467
21519
|
return result;
|
|
21468
21520
|
};
|
|
21469
|
-
var remapPosition =
|
|
21521
|
+
var remapPosition = (position, sourcemapLines) => {
|
|
21470
21522
|
const [line, character] = position;
|
|
21471
21523
|
const textLine = sourcemapLines[line];
|
|
21472
21524
|
if (!textLine?.length) {
|
|
@@ -21793,7 +21845,8 @@ ${counts}`;
|
|
|
21793
21845
|
const code = generate_civet_default(ast2, options);
|
|
21794
21846
|
checkErrors();
|
|
21795
21847
|
if (options.inlineMap) {
|
|
21796
|
-
return
|
|
21848
|
+
return `${code}
|
|
21849
|
+
${options.sourceMap.comment(filename2, filename2 + ".tsx")}`;
|
|
21797
21850
|
} else {
|
|
21798
21851
|
return {
|
|
21799
21852
|
code,
|