@danielx/civet 0.8.7 → 0.8.8
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 +6 -0
- package/dist/browser.js +101 -23
- package/dist/main.js +101 -23
- package/dist/main.mjs +101 -23
- package/dist/types.d.ts +1 -0
- package/dist/unplugin/unplugin.js +47 -22
- package/dist/unplugin/unplugin.mjs +47 -22
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,12 @@ This changelog is generated automatically by [`build/changelog.civet`](build/cha
|
|
|
4
4
|
For each version of Civet, it lists and links to all incorporated PRs,
|
|
5
5
|
as well as a full diff and commit list.
|
|
6
6
|
|
|
7
|
+
## 0.8.8 (2024-10-24, [diff](https://github.com/DanielXMoore/Civet/compare/v0.8.7...v0.8.8), [commits](https://github.com/DanielXMoore/Civet/commits/v0.8.8))
|
|
8
|
+
* `:symbol` shorthand for `Symbol.symbol` or `Symbol.for("symbol")` [[#1498](https://github.com/DanielXMoore/Civet/pull/1498)]
|
|
9
|
+
* preventExtensions on comptime functions [[#1494](https://github.com/DanielXMoore/Civet/pull/1494)]
|
|
10
|
+
* Fix unplugin's webpack mode: `resolve.alias`, virtual modules [[#1501](https://github.com/DanielXMoore/Civet/pull/1501)]
|
|
11
|
+
* `for` loops can filter via `when` conditions (not just in CoffeeScript mode) [[#1502](https://github.com/DanielXMoore/Civet/pull/1502)]
|
|
12
|
+
|
|
7
13
|
## 0.8.7 (2024-10-22, [diff](https://github.com/DanielXMoore/Civet/compare/v0.8.6...v0.8.7), [commits](https://github.com/DanielXMoore/Civet/commits/v0.8.7))
|
|
8
14
|
* Fix one-line arrow functions with `@` arguments [[#1490](https://github.com/DanielXMoore/Civet/pull/1490)]
|
|
9
15
|
* Fix `Promise<void>` detection with implicit type arguments [[#1491](https://github.com/DanielXMoore/Civet/pull/1491)]
|
package/dist/browser.js
CHANGED
|
@@ -2165,6 +2165,9 @@ ${js}`
|
|
|
2165
2165
|
throw new TypeError("cannot serialize native function");
|
|
2166
2166
|
}
|
|
2167
2167
|
if (/^class[\s{]/u.test(string)) {
|
|
2168
|
+
if (!Object.isExtensible(val)) {
|
|
2169
|
+
string = `Object.preventExtensions(${string})`;
|
|
2170
|
+
}
|
|
2168
2171
|
return string;
|
|
2169
2172
|
}
|
|
2170
2173
|
if (stack.has(val)) {
|
|
@@ -2192,6 +2195,9 @@ ${js}`
|
|
|
2192
2195
|
}
|
|
2193
2196
|
string = `Object.defineProperties(${string},${recurse(props)})`;
|
|
2194
2197
|
}
|
|
2198
|
+
if (!Object.isExtensible(val)) {
|
|
2199
|
+
string = `Object.preventExtensions(${string})`;
|
|
2200
|
+
}
|
|
2195
2201
|
stack.delete(val);
|
|
2196
2202
|
return string;
|
|
2197
2203
|
} else if (typeof val === "symbol") {
|
|
@@ -7585,6 +7591,8 @@ ${js}`
|
|
|
7585
7591
|
BooleanLiteral,
|
|
7586
7592
|
_BooleanLiteral,
|
|
7587
7593
|
CoffeeScriptBooleanLiteral,
|
|
7594
|
+
SymbolLiteral,
|
|
7595
|
+
SymbolElement,
|
|
7588
7596
|
Identifier,
|
|
7589
7597
|
IdentifierName,
|
|
7590
7598
|
IdentifierReference,
|
|
@@ -7685,6 +7693,7 @@ ${js}`
|
|
|
7685
7693
|
WhileClause,
|
|
7686
7694
|
ForStatement,
|
|
7687
7695
|
ForClause,
|
|
7696
|
+
ForStatementControlWithWhen,
|
|
7688
7697
|
ForStatementControl,
|
|
7689
7698
|
WhenCondition,
|
|
7690
7699
|
CoffeeForStatementParameters,
|
|
@@ -9419,8 +9428,9 @@ ${js}`
|
|
|
9419
9428
|
var PrimaryExpression$8 = RegularExpressionLiteral;
|
|
9420
9429
|
var PrimaryExpression$9 = ParenthesizedExpression;
|
|
9421
9430
|
var PrimaryExpression$10 = Placeholder;
|
|
9422
|
-
var PrimaryExpression$11 =
|
|
9423
|
-
var PrimaryExpression
|
|
9431
|
+
var PrimaryExpression$11 = SymbolLiteral;
|
|
9432
|
+
var PrimaryExpression$12 = JSXImplicitFragment;
|
|
9433
|
+
var PrimaryExpression$$ = [PrimaryExpression$0, PrimaryExpression$1, PrimaryExpression$2, PrimaryExpression$3, PrimaryExpression$4, PrimaryExpression$5, PrimaryExpression$6, PrimaryExpression$7, PrimaryExpression$8, PrimaryExpression$9, PrimaryExpression$10, PrimaryExpression$11, PrimaryExpression$12];
|
|
9424
9434
|
function PrimaryExpression(ctx, state2) {
|
|
9425
9435
|
return (0, import_lib4.$EVENT_C)(ctx, state2, "PrimaryExpression", PrimaryExpression$$);
|
|
9426
9436
|
}
|
|
@@ -10249,7 +10259,7 @@ ${js}`
|
|
|
10249
10259
|
function PropertyAccessModifier(ctx, state2) {
|
|
10250
10260
|
return (0, import_lib4.$EVENT_C)(ctx, state2, "PropertyAccessModifier", PropertyAccessModifier$$);
|
|
10251
10261
|
}
|
|
10252
|
-
var PropertyAccess$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(AccessStart, (0, import_lib4.$C)(TemplateLiteral, StringLiteral, IntegerLiteral)), function($skip, $loc, $0, $1, $2) {
|
|
10262
|
+
var PropertyAccess$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(AccessStart, (0, import_lib4.$C)(TemplateLiteral, StringLiteral, IntegerLiteral, SymbolLiteral)), function($skip, $loc, $0, $1, $2) {
|
|
10253
10263
|
var dot = $1;
|
|
10254
10264
|
var literal = $2;
|
|
10255
10265
|
return {
|
|
@@ -11793,6 +11803,40 @@ ${js}`
|
|
|
11793
11803
|
function CoffeeScriptBooleanLiteral(ctx, state2) {
|
|
11794
11804
|
return (0, import_lib4.$EVENT_C)(ctx, state2, "CoffeeScriptBooleanLiteral", CoffeeScriptBooleanLiteral$$);
|
|
11795
11805
|
}
|
|
11806
|
+
var SymbolLiteral$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(Colon, IdentifierName), function($skip, $loc, $0, $1, $2) {
|
|
11807
|
+
var colon = $1;
|
|
11808
|
+
var id = $2;
|
|
11809
|
+
const { name, children: [token] } = id;
|
|
11810
|
+
if (config.symbols.includes(name)) {
|
|
11811
|
+
return {
|
|
11812
|
+
type: "SymbolLiteral",
|
|
11813
|
+
children: [
|
|
11814
|
+
{ ...colon, token: "Symbol." },
|
|
11815
|
+
token
|
|
11816
|
+
],
|
|
11817
|
+
name
|
|
11818
|
+
};
|
|
11819
|
+
} else {
|
|
11820
|
+
return {
|
|
11821
|
+
type: "SymbolLiteral",
|
|
11822
|
+
children: [
|
|
11823
|
+
{ ...colon, token: 'Symbol.for("' },
|
|
11824
|
+
token,
|
|
11825
|
+
'")'
|
|
11826
|
+
],
|
|
11827
|
+
name
|
|
11828
|
+
};
|
|
11829
|
+
}
|
|
11830
|
+
});
|
|
11831
|
+
function SymbolLiteral(ctx, state2) {
|
|
11832
|
+
return (0, import_lib4.$EVENT)(ctx, state2, "SymbolLiteral", SymbolLiteral$0);
|
|
11833
|
+
}
|
|
11834
|
+
var SymbolElement$0 = (0, import_lib4.$T)((0, import_lib4.$S)(SymbolLiteral), function(value) {
|
|
11835
|
+
return ["[", value[0], "]"];
|
|
11836
|
+
});
|
|
11837
|
+
function SymbolElement(ctx, state2) {
|
|
11838
|
+
return (0, import_lib4.$EVENT)(ctx, state2, "SymbolElement", SymbolElement$0);
|
|
11839
|
+
}
|
|
11796
11840
|
var Identifier$0 = (0, import_lib4.$T)((0, import_lib4.$S)((0, import_lib4.$EXPECT)($R17, "Identifier /(?=\\p{ID_Start}|[_$])/"), (0, import_lib4.$N)(ReservedWord), IdentifierName), function(value) {
|
|
11797
11841
|
var id = value[2];
|
|
11798
11842
|
return id;
|
|
@@ -12540,7 +12584,8 @@ ${js}`
|
|
|
12540
12584
|
});
|
|
12541
12585
|
var PropertyName$4 = IdentifierName;
|
|
12542
12586
|
var PropertyName$5 = LengthShorthand;
|
|
12543
|
-
var PropertyName
|
|
12587
|
+
var PropertyName$6 = SymbolElement;
|
|
12588
|
+
var PropertyName$$ = [PropertyName$0, PropertyName$1, PropertyName$2, PropertyName$3, PropertyName$4, PropertyName$5, PropertyName$6];
|
|
12544
12589
|
function PropertyName(ctx, state2) {
|
|
12545
12590
|
return (0, import_lib4.$EVENT_C)(ctx, state2, "PropertyName", PropertyName$$);
|
|
12546
12591
|
}
|
|
@@ -12802,7 +12847,8 @@ ${js}`
|
|
|
12802
12847
|
var ClassElementName$0 = PropertyName;
|
|
12803
12848
|
var ClassElementName$1 = LengthShorthand;
|
|
12804
12849
|
var ClassElementName$2 = PrivateIdentifier;
|
|
12805
|
-
var ClassElementName
|
|
12850
|
+
var ClassElementName$3 = SymbolElement;
|
|
12851
|
+
var ClassElementName$$ = [ClassElementName$0, ClassElementName$1, ClassElementName$2, ClassElementName$3];
|
|
12806
12852
|
function ClassElementName(ctx, state2) {
|
|
12807
12853
|
return (0, import_lib4.$EVENT_C)(ctx, state2, "ClassElementName", ClassElementName$$);
|
|
12808
12854
|
}
|
|
@@ -13759,7 +13805,7 @@ ${js}`
|
|
|
13759
13805
|
function ForStatement(ctx, state2) {
|
|
13760
13806
|
return (0, import_lib4.$EVENT)(ctx, state2, "ForStatement", ForStatement$0);
|
|
13761
13807
|
}
|
|
13762
|
-
var ForClause$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(For, (0, import_lib4.$E)((0, import_lib4.$S)((0, import_lib4.$E)(_), Star)), __,
|
|
13808
|
+
var ForClause$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(For, (0, import_lib4.$E)((0, import_lib4.$S)((0, import_lib4.$E)(_), Star)), __, ForStatementControlWithWhen), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
13763
13809
|
var generator = $2;
|
|
13764
13810
|
var c = $4;
|
|
13765
13811
|
const { children, declaration } = c;
|
|
@@ -13776,26 +13822,41 @@ ${js}`
|
|
|
13776
13822
|
function ForClause(ctx, state2) {
|
|
13777
13823
|
return (0, import_lib4.$EVENT)(ctx, state2, "ForClause", ForClause$0);
|
|
13778
13824
|
}
|
|
13825
|
+
var ForStatementControlWithWhen$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(ForStatementControl, (0, import_lib4.$E)(WhenCondition)), function($skip, $loc, $0, $1, $2) {
|
|
13826
|
+
var control = $1;
|
|
13827
|
+
var condition = $2;
|
|
13828
|
+
if (!condition)
|
|
13829
|
+
return control;
|
|
13830
|
+
const expressions = [["", {
|
|
13831
|
+
type: "ContinueStatement",
|
|
13832
|
+
children: ["continue"]
|
|
13833
|
+
}]];
|
|
13834
|
+
const block = {
|
|
13835
|
+
type: "BlockStatement",
|
|
13836
|
+
expressions,
|
|
13837
|
+
children: [expressions],
|
|
13838
|
+
bare: true
|
|
13839
|
+
};
|
|
13840
|
+
return {
|
|
13841
|
+
...control,
|
|
13842
|
+
blockPrefix: [
|
|
13843
|
+
...control.blockPrefix,
|
|
13844
|
+
["", {
|
|
13845
|
+
type: "IfStatement",
|
|
13846
|
+
then: block,
|
|
13847
|
+
children: ["if (!", makeLeftHandSideExpression(trimFirstSpace(condition)), ") ", block]
|
|
13848
|
+
}, ";"]
|
|
13849
|
+
]
|
|
13850
|
+
};
|
|
13851
|
+
});
|
|
13852
|
+
function ForStatementControlWithWhen(ctx, state2) {
|
|
13853
|
+
return (0, import_lib4.$EVENT)(ctx, state2, "ForStatementControlWithWhen", ForStatementControlWithWhen$0);
|
|
13854
|
+
}
|
|
13779
13855
|
var ForStatementControl$0 = (0, import_lib4.$T)((0, import_lib4.$S)((0, import_lib4.$N)(CoffeeForLoopsEnabled), ForStatementParameters), function(value) {
|
|
13780
13856
|
return value[1];
|
|
13781
13857
|
});
|
|
13782
|
-
var ForStatementControl$1 = (0, import_lib4.$
|
|
13783
|
-
|
|
13784
|
-
if (condition) {
|
|
13785
|
-
const block = "continue";
|
|
13786
|
-
$2 = {
|
|
13787
|
-
...$2,
|
|
13788
|
-
blockPrefix: [
|
|
13789
|
-
...$2.blockPrefix,
|
|
13790
|
-
["", {
|
|
13791
|
-
type: "IfStatement",
|
|
13792
|
-
then: block,
|
|
13793
|
-
children: ["if (!(", trimFirstSpace(condition), ")) ", block]
|
|
13794
|
-
}, ";"]
|
|
13795
|
-
]
|
|
13796
|
-
};
|
|
13797
|
-
}
|
|
13798
|
-
return $2;
|
|
13858
|
+
var ForStatementControl$1 = (0, import_lib4.$T)((0, import_lib4.$S)(CoffeeForLoopsEnabled, CoffeeForStatementParameters), function(value) {
|
|
13859
|
+
return value[1];
|
|
13799
13860
|
});
|
|
13800
13861
|
var ForStatementControl$$ = [ForStatementControl$0, ForStatementControl$1];
|
|
13801
13862
|
function ForStatementControl(ctx, state2) {
|
|
@@ -18572,6 +18633,7 @@ ${js}`
|
|
|
18572
18633
|
value = 0;
|
|
18573
18634
|
break;
|
|
18574
18635
|
case "globals":
|
|
18636
|
+
case "symbols":
|
|
18575
18637
|
value = value.split(",").filter(Boolean);
|
|
18576
18638
|
break;
|
|
18577
18639
|
}
|
|
@@ -18947,6 +19009,7 @@ ${js}`
|
|
|
18947
19009
|
repl: false,
|
|
18948
19010
|
rewriteTsImports: true,
|
|
18949
19011
|
server: false,
|
|
19012
|
+
symbols: wellKnownSymbols,
|
|
18950
19013
|
tab: void 0,
|
|
18951
19014
|
// default behavior = same as space
|
|
18952
19015
|
verbose: false
|
|
@@ -19243,6 +19306,21 @@ ${js}`
|
|
|
19243
19306
|
});
|
|
19244
19307
|
}
|
|
19245
19308
|
}
|
|
19309
|
+
var wellKnownSymbols = [
|
|
19310
|
+
"asyncIterator",
|
|
19311
|
+
"hasInstance",
|
|
19312
|
+
"isConcatSpreadable",
|
|
19313
|
+
"iterator",
|
|
19314
|
+
"match",
|
|
19315
|
+
"matchAll",
|
|
19316
|
+
"replace",
|
|
19317
|
+
"search",
|
|
19318
|
+
"species",
|
|
19319
|
+
"split",
|
|
19320
|
+
"toPrimitive",
|
|
19321
|
+
"toStringTag",
|
|
19322
|
+
"unscopables"
|
|
19323
|
+
];
|
|
19246
19324
|
|
|
19247
19325
|
// source/sourcemap.civet
|
|
19248
19326
|
var sourcemap_exports = {};
|
package/dist/main.js
CHANGED
|
@@ -2141,6 +2141,9 @@ function serialize(value, context) {
|
|
|
2141
2141
|
throw new TypeError("cannot serialize native function");
|
|
2142
2142
|
}
|
|
2143
2143
|
if (/^class[\s{]/u.test(string)) {
|
|
2144
|
+
if (!Object.isExtensible(val)) {
|
|
2145
|
+
string = `Object.preventExtensions(${string})`;
|
|
2146
|
+
}
|
|
2144
2147
|
return string;
|
|
2145
2148
|
}
|
|
2146
2149
|
if (stack.has(val)) {
|
|
@@ -2168,6 +2171,9 @@ function serialize(value, context) {
|
|
|
2168
2171
|
}
|
|
2169
2172
|
string = `Object.defineProperties(${string},${recurse(props)})`;
|
|
2170
2173
|
}
|
|
2174
|
+
if (!Object.isExtensible(val)) {
|
|
2175
|
+
string = `Object.preventExtensions(${string})`;
|
|
2176
|
+
}
|
|
2171
2177
|
stack.delete(val);
|
|
2172
2178
|
return string;
|
|
2173
2179
|
} else if (typeof val === "symbol") {
|
|
@@ -7561,6 +7567,8 @@ var grammar = {
|
|
|
7561
7567
|
BooleanLiteral,
|
|
7562
7568
|
_BooleanLiteral,
|
|
7563
7569
|
CoffeeScriptBooleanLiteral,
|
|
7570
|
+
SymbolLiteral,
|
|
7571
|
+
SymbolElement,
|
|
7564
7572
|
Identifier,
|
|
7565
7573
|
IdentifierName,
|
|
7566
7574
|
IdentifierReference,
|
|
@@ -7661,6 +7669,7 @@ var grammar = {
|
|
|
7661
7669
|
WhileClause,
|
|
7662
7670
|
ForStatement,
|
|
7663
7671
|
ForClause,
|
|
7672
|
+
ForStatementControlWithWhen,
|
|
7664
7673
|
ForStatementControl,
|
|
7665
7674
|
WhenCondition,
|
|
7666
7675
|
CoffeeForStatementParameters,
|
|
@@ -9395,8 +9404,9 @@ var PrimaryExpression$7 = ClassExpression;
|
|
|
9395
9404
|
var PrimaryExpression$8 = RegularExpressionLiteral;
|
|
9396
9405
|
var PrimaryExpression$9 = ParenthesizedExpression;
|
|
9397
9406
|
var PrimaryExpression$10 = Placeholder;
|
|
9398
|
-
var PrimaryExpression$11 =
|
|
9399
|
-
var PrimaryExpression
|
|
9407
|
+
var PrimaryExpression$11 = SymbolLiteral;
|
|
9408
|
+
var PrimaryExpression$12 = JSXImplicitFragment;
|
|
9409
|
+
var PrimaryExpression$$ = [PrimaryExpression$0, PrimaryExpression$1, PrimaryExpression$2, PrimaryExpression$3, PrimaryExpression$4, PrimaryExpression$5, PrimaryExpression$6, PrimaryExpression$7, PrimaryExpression$8, PrimaryExpression$9, PrimaryExpression$10, PrimaryExpression$11, PrimaryExpression$12];
|
|
9400
9410
|
function PrimaryExpression(ctx, state2) {
|
|
9401
9411
|
return (0, import_lib4.$EVENT_C)(ctx, state2, "PrimaryExpression", PrimaryExpression$$);
|
|
9402
9412
|
}
|
|
@@ -10225,7 +10235,7 @@ var PropertyAccessModifier$$ = [PropertyAccessModifier$0, PropertyAccessModifier
|
|
|
10225
10235
|
function PropertyAccessModifier(ctx, state2) {
|
|
10226
10236
|
return (0, import_lib4.$EVENT_C)(ctx, state2, "PropertyAccessModifier", PropertyAccessModifier$$);
|
|
10227
10237
|
}
|
|
10228
|
-
var PropertyAccess$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(AccessStart, (0, import_lib4.$C)(TemplateLiteral, StringLiteral, IntegerLiteral)), function($skip, $loc, $0, $1, $2) {
|
|
10238
|
+
var PropertyAccess$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(AccessStart, (0, import_lib4.$C)(TemplateLiteral, StringLiteral, IntegerLiteral, SymbolLiteral)), function($skip, $loc, $0, $1, $2) {
|
|
10229
10239
|
var dot = $1;
|
|
10230
10240
|
var literal = $2;
|
|
10231
10241
|
return {
|
|
@@ -11769,6 +11779,40 @@ var CoffeeScriptBooleanLiteral$$ = [CoffeeScriptBooleanLiteral$0, CoffeeScriptBo
|
|
|
11769
11779
|
function CoffeeScriptBooleanLiteral(ctx, state2) {
|
|
11770
11780
|
return (0, import_lib4.$EVENT_C)(ctx, state2, "CoffeeScriptBooleanLiteral", CoffeeScriptBooleanLiteral$$);
|
|
11771
11781
|
}
|
|
11782
|
+
var SymbolLiteral$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(Colon, IdentifierName), function($skip, $loc, $0, $1, $2) {
|
|
11783
|
+
var colon = $1;
|
|
11784
|
+
var id = $2;
|
|
11785
|
+
const { name, children: [token] } = id;
|
|
11786
|
+
if (config.symbols.includes(name)) {
|
|
11787
|
+
return {
|
|
11788
|
+
type: "SymbolLiteral",
|
|
11789
|
+
children: [
|
|
11790
|
+
{ ...colon, token: "Symbol." },
|
|
11791
|
+
token
|
|
11792
|
+
],
|
|
11793
|
+
name
|
|
11794
|
+
};
|
|
11795
|
+
} else {
|
|
11796
|
+
return {
|
|
11797
|
+
type: "SymbolLiteral",
|
|
11798
|
+
children: [
|
|
11799
|
+
{ ...colon, token: 'Symbol.for("' },
|
|
11800
|
+
token,
|
|
11801
|
+
'")'
|
|
11802
|
+
],
|
|
11803
|
+
name
|
|
11804
|
+
};
|
|
11805
|
+
}
|
|
11806
|
+
});
|
|
11807
|
+
function SymbolLiteral(ctx, state2) {
|
|
11808
|
+
return (0, import_lib4.$EVENT)(ctx, state2, "SymbolLiteral", SymbolLiteral$0);
|
|
11809
|
+
}
|
|
11810
|
+
var SymbolElement$0 = (0, import_lib4.$T)((0, import_lib4.$S)(SymbolLiteral), function(value) {
|
|
11811
|
+
return ["[", value[0], "]"];
|
|
11812
|
+
});
|
|
11813
|
+
function SymbolElement(ctx, state2) {
|
|
11814
|
+
return (0, import_lib4.$EVENT)(ctx, state2, "SymbolElement", SymbolElement$0);
|
|
11815
|
+
}
|
|
11772
11816
|
var Identifier$0 = (0, import_lib4.$T)((0, import_lib4.$S)((0, import_lib4.$EXPECT)($R17, "Identifier /(?=\\p{ID_Start}|[_$])/"), (0, import_lib4.$N)(ReservedWord), IdentifierName), function(value) {
|
|
11773
11817
|
var id = value[2];
|
|
11774
11818
|
return id;
|
|
@@ -12516,7 +12560,8 @@ var PropertyName$3 = (0, import_lib4.$TV)((0, import_lib4.$TEXT)((0, import_lib4
|
|
|
12516
12560
|
});
|
|
12517
12561
|
var PropertyName$4 = IdentifierName;
|
|
12518
12562
|
var PropertyName$5 = LengthShorthand;
|
|
12519
|
-
var PropertyName
|
|
12563
|
+
var PropertyName$6 = SymbolElement;
|
|
12564
|
+
var PropertyName$$ = [PropertyName$0, PropertyName$1, PropertyName$2, PropertyName$3, PropertyName$4, PropertyName$5, PropertyName$6];
|
|
12520
12565
|
function PropertyName(ctx, state2) {
|
|
12521
12566
|
return (0, import_lib4.$EVENT_C)(ctx, state2, "PropertyName", PropertyName$$);
|
|
12522
12567
|
}
|
|
@@ -12778,7 +12823,8 @@ function MethodSignature(ctx, state2) {
|
|
|
12778
12823
|
var ClassElementName$0 = PropertyName;
|
|
12779
12824
|
var ClassElementName$1 = LengthShorthand;
|
|
12780
12825
|
var ClassElementName$2 = PrivateIdentifier;
|
|
12781
|
-
var ClassElementName
|
|
12826
|
+
var ClassElementName$3 = SymbolElement;
|
|
12827
|
+
var ClassElementName$$ = [ClassElementName$0, ClassElementName$1, ClassElementName$2, ClassElementName$3];
|
|
12782
12828
|
function ClassElementName(ctx, state2) {
|
|
12783
12829
|
return (0, import_lib4.$EVENT_C)(ctx, state2, "ClassElementName", ClassElementName$$);
|
|
12784
12830
|
}
|
|
@@ -13735,7 +13781,7 @@ var ForStatement$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(ForClause, BlockOr
|
|
|
13735
13781
|
function ForStatement(ctx, state2) {
|
|
13736
13782
|
return (0, import_lib4.$EVENT)(ctx, state2, "ForStatement", ForStatement$0);
|
|
13737
13783
|
}
|
|
13738
|
-
var ForClause$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(For, (0, import_lib4.$E)((0, import_lib4.$S)((0, import_lib4.$E)(_), Star)), __,
|
|
13784
|
+
var ForClause$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(For, (0, import_lib4.$E)((0, import_lib4.$S)((0, import_lib4.$E)(_), Star)), __, ForStatementControlWithWhen), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
13739
13785
|
var generator = $2;
|
|
13740
13786
|
var c = $4;
|
|
13741
13787
|
const { children, declaration } = c;
|
|
@@ -13752,26 +13798,41 @@ var ForClause$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(For, (0, import_lib4.
|
|
|
13752
13798
|
function ForClause(ctx, state2) {
|
|
13753
13799
|
return (0, import_lib4.$EVENT)(ctx, state2, "ForClause", ForClause$0);
|
|
13754
13800
|
}
|
|
13801
|
+
var ForStatementControlWithWhen$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(ForStatementControl, (0, import_lib4.$E)(WhenCondition)), function($skip, $loc, $0, $1, $2) {
|
|
13802
|
+
var control = $1;
|
|
13803
|
+
var condition = $2;
|
|
13804
|
+
if (!condition)
|
|
13805
|
+
return control;
|
|
13806
|
+
const expressions = [["", {
|
|
13807
|
+
type: "ContinueStatement",
|
|
13808
|
+
children: ["continue"]
|
|
13809
|
+
}]];
|
|
13810
|
+
const block = {
|
|
13811
|
+
type: "BlockStatement",
|
|
13812
|
+
expressions,
|
|
13813
|
+
children: [expressions],
|
|
13814
|
+
bare: true
|
|
13815
|
+
};
|
|
13816
|
+
return {
|
|
13817
|
+
...control,
|
|
13818
|
+
blockPrefix: [
|
|
13819
|
+
...control.blockPrefix,
|
|
13820
|
+
["", {
|
|
13821
|
+
type: "IfStatement",
|
|
13822
|
+
then: block,
|
|
13823
|
+
children: ["if (!", makeLeftHandSideExpression(trimFirstSpace(condition)), ") ", block]
|
|
13824
|
+
}, ";"]
|
|
13825
|
+
]
|
|
13826
|
+
};
|
|
13827
|
+
});
|
|
13828
|
+
function ForStatementControlWithWhen(ctx, state2) {
|
|
13829
|
+
return (0, import_lib4.$EVENT)(ctx, state2, "ForStatementControlWithWhen", ForStatementControlWithWhen$0);
|
|
13830
|
+
}
|
|
13755
13831
|
var ForStatementControl$0 = (0, import_lib4.$T)((0, import_lib4.$S)((0, import_lib4.$N)(CoffeeForLoopsEnabled), ForStatementParameters), function(value) {
|
|
13756
13832
|
return value[1];
|
|
13757
13833
|
});
|
|
13758
|
-
var ForStatementControl$1 = (0, import_lib4.$
|
|
13759
|
-
|
|
13760
|
-
if (condition) {
|
|
13761
|
-
const block = "continue";
|
|
13762
|
-
$2 = {
|
|
13763
|
-
...$2,
|
|
13764
|
-
blockPrefix: [
|
|
13765
|
-
...$2.blockPrefix,
|
|
13766
|
-
["", {
|
|
13767
|
-
type: "IfStatement",
|
|
13768
|
-
then: block,
|
|
13769
|
-
children: ["if (!(", trimFirstSpace(condition), ")) ", block]
|
|
13770
|
-
}, ";"]
|
|
13771
|
-
]
|
|
13772
|
-
};
|
|
13773
|
-
}
|
|
13774
|
-
return $2;
|
|
13834
|
+
var ForStatementControl$1 = (0, import_lib4.$T)((0, import_lib4.$S)(CoffeeForLoopsEnabled, CoffeeForStatementParameters), function(value) {
|
|
13835
|
+
return value[1];
|
|
13775
13836
|
});
|
|
13776
13837
|
var ForStatementControl$$ = [ForStatementControl$0, ForStatementControl$1];
|
|
13777
13838
|
function ForStatementControl(ctx, state2) {
|
|
@@ -18548,6 +18609,7 @@ var CivetOption$0 = (0, import_lib4.$TR)((0, import_lib4.$EXPECT)($R96, "CivetOp
|
|
|
18548
18609
|
value = 0;
|
|
18549
18610
|
break;
|
|
18550
18611
|
case "globals":
|
|
18612
|
+
case "symbols":
|
|
18551
18613
|
value = value.split(",").filter(Boolean);
|
|
18552
18614
|
break;
|
|
18553
18615
|
}
|
|
@@ -18923,6 +18985,7 @@ var Reset$0 = (0, import_lib4.$TV)((0, import_lib4.$EXPECT)($L0, 'Reset ""'), fu
|
|
|
18923
18985
|
repl: false,
|
|
18924
18986
|
rewriteTsImports: true,
|
|
18925
18987
|
server: false,
|
|
18988
|
+
symbols: wellKnownSymbols,
|
|
18926
18989
|
tab: void 0,
|
|
18927
18990
|
// default behavior = same as space
|
|
18928
18991
|
verbose: false
|
|
@@ -19219,6 +19282,21 @@ function parseProgram(input, options) {
|
|
|
19219
19282
|
});
|
|
19220
19283
|
}
|
|
19221
19284
|
}
|
|
19285
|
+
var wellKnownSymbols = [
|
|
19286
|
+
"asyncIterator",
|
|
19287
|
+
"hasInstance",
|
|
19288
|
+
"isConcatSpreadable",
|
|
19289
|
+
"iterator",
|
|
19290
|
+
"match",
|
|
19291
|
+
"matchAll",
|
|
19292
|
+
"replace",
|
|
19293
|
+
"search",
|
|
19294
|
+
"species",
|
|
19295
|
+
"split",
|
|
19296
|
+
"toPrimitive",
|
|
19297
|
+
"toStringTag",
|
|
19298
|
+
"unscopables"
|
|
19299
|
+
];
|
|
19222
19300
|
|
|
19223
19301
|
// source/sourcemap.civet
|
|
19224
19302
|
var sourcemap_exports = {};
|
package/dist/main.mjs
CHANGED
|
@@ -2121,6 +2121,9 @@ function serialize(value, context) {
|
|
|
2121
2121
|
throw new TypeError("cannot serialize native function");
|
|
2122
2122
|
}
|
|
2123
2123
|
if (/^class[\s{]/u.test(string)) {
|
|
2124
|
+
if (!Object.isExtensible(val)) {
|
|
2125
|
+
string = `Object.preventExtensions(${string})`;
|
|
2126
|
+
}
|
|
2124
2127
|
return string;
|
|
2125
2128
|
}
|
|
2126
2129
|
if (stack.has(val)) {
|
|
@@ -2148,6 +2151,9 @@ function serialize(value, context) {
|
|
|
2148
2151
|
}
|
|
2149
2152
|
string = `Object.defineProperties(${string},${recurse(props)})`;
|
|
2150
2153
|
}
|
|
2154
|
+
if (!Object.isExtensible(val)) {
|
|
2155
|
+
string = `Object.preventExtensions(${string})`;
|
|
2156
|
+
}
|
|
2151
2157
|
stack.delete(val);
|
|
2152
2158
|
return string;
|
|
2153
2159
|
} else if (typeof val === "symbol") {
|
|
@@ -7541,6 +7547,8 @@ var grammar = {
|
|
|
7541
7547
|
BooleanLiteral,
|
|
7542
7548
|
_BooleanLiteral,
|
|
7543
7549
|
CoffeeScriptBooleanLiteral,
|
|
7550
|
+
SymbolLiteral,
|
|
7551
|
+
SymbolElement,
|
|
7544
7552
|
Identifier,
|
|
7545
7553
|
IdentifierName,
|
|
7546
7554
|
IdentifierReference,
|
|
@@ -7641,6 +7649,7 @@ var grammar = {
|
|
|
7641
7649
|
WhileClause,
|
|
7642
7650
|
ForStatement,
|
|
7643
7651
|
ForClause,
|
|
7652
|
+
ForStatementControlWithWhen,
|
|
7644
7653
|
ForStatementControl,
|
|
7645
7654
|
WhenCondition,
|
|
7646
7655
|
CoffeeForStatementParameters,
|
|
@@ -9375,8 +9384,9 @@ var PrimaryExpression$7 = ClassExpression;
|
|
|
9375
9384
|
var PrimaryExpression$8 = RegularExpressionLiteral;
|
|
9376
9385
|
var PrimaryExpression$9 = ParenthesizedExpression;
|
|
9377
9386
|
var PrimaryExpression$10 = Placeholder;
|
|
9378
|
-
var PrimaryExpression$11 =
|
|
9379
|
-
var PrimaryExpression
|
|
9387
|
+
var PrimaryExpression$11 = SymbolLiteral;
|
|
9388
|
+
var PrimaryExpression$12 = JSXImplicitFragment;
|
|
9389
|
+
var PrimaryExpression$$ = [PrimaryExpression$0, PrimaryExpression$1, PrimaryExpression$2, PrimaryExpression$3, PrimaryExpression$4, PrimaryExpression$5, PrimaryExpression$6, PrimaryExpression$7, PrimaryExpression$8, PrimaryExpression$9, PrimaryExpression$10, PrimaryExpression$11, PrimaryExpression$12];
|
|
9380
9390
|
function PrimaryExpression(ctx, state2) {
|
|
9381
9391
|
return (0, import_lib4.$EVENT_C)(ctx, state2, "PrimaryExpression", PrimaryExpression$$);
|
|
9382
9392
|
}
|
|
@@ -10205,7 +10215,7 @@ var PropertyAccessModifier$$ = [PropertyAccessModifier$0, PropertyAccessModifier
|
|
|
10205
10215
|
function PropertyAccessModifier(ctx, state2) {
|
|
10206
10216
|
return (0, import_lib4.$EVENT_C)(ctx, state2, "PropertyAccessModifier", PropertyAccessModifier$$);
|
|
10207
10217
|
}
|
|
10208
|
-
var PropertyAccess$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(AccessStart, (0, import_lib4.$C)(TemplateLiteral, StringLiteral, IntegerLiteral)), function($skip, $loc, $0, $1, $2) {
|
|
10218
|
+
var PropertyAccess$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(AccessStart, (0, import_lib4.$C)(TemplateLiteral, StringLiteral, IntegerLiteral, SymbolLiteral)), function($skip, $loc, $0, $1, $2) {
|
|
10209
10219
|
var dot = $1;
|
|
10210
10220
|
var literal = $2;
|
|
10211
10221
|
return {
|
|
@@ -11749,6 +11759,40 @@ var CoffeeScriptBooleanLiteral$$ = [CoffeeScriptBooleanLiteral$0, CoffeeScriptBo
|
|
|
11749
11759
|
function CoffeeScriptBooleanLiteral(ctx, state2) {
|
|
11750
11760
|
return (0, import_lib4.$EVENT_C)(ctx, state2, "CoffeeScriptBooleanLiteral", CoffeeScriptBooleanLiteral$$);
|
|
11751
11761
|
}
|
|
11762
|
+
var SymbolLiteral$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(Colon, IdentifierName), function($skip, $loc, $0, $1, $2) {
|
|
11763
|
+
var colon = $1;
|
|
11764
|
+
var id = $2;
|
|
11765
|
+
const { name, children: [token] } = id;
|
|
11766
|
+
if (config.symbols.includes(name)) {
|
|
11767
|
+
return {
|
|
11768
|
+
type: "SymbolLiteral",
|
|
11769
|
+
children: [
|
|
11770
|
+
{ ...colon, token: "Symbol." },
|
|
11771
|
+
token
|
|
11772
|
+
],
|
|
11773
|
+
name
|
|
11774
|
+
};
|
|
11775
|
+
} else {
|
|
11776
|
+
return {
|
|
11777
|
+
type: "SymbolLiteral",
|
|
11778
|
+
children: [
|
|
11779
|
+
{ ...colon, token: 'Symbol.for("' },
|
|
11780
|
+
token,
|
|
11781
|
+
'")'
|
|
11782
|
+
],
|
|
11783
|
+
name
|
|
11784
|
+
};
|
|
11785
|
+
}
|
|
11786
|
+
});
|
|
11787
|
+
function SymbolLiteral(ctx, state2) {
|
|
11788
|
+
return (0, import_lib4.$EVENT)(ctx, state2, "SymbolLiteral", SymbolLiteral$0);
|
|
11789
|
+
}
|
|
11790
|
+
var SymbolElement$0 = (0, import_lib4.$T)((0, import_lib4.$S)(SymbolLiteral), function(value) {
|
|
11791
|
+
return ["[", value[0], "]"];
|
|
11792
|
+
});
|
|
11793
|
+
function SymbolElement(ctx, state2) {
|
|
11794
|
+
return (0, import_lib4.$EVENT)(ctx, state2, "SymbolElement", SymbolElement$0);
|
|
11795
|
+
}
|
|
11752
11796
|
var Identifier$0 = (0, import_lib4.$T)((0, import_lib4.$S)((0, import_lib4.$EXPECT)($R17, "Identifier /(?=\\p{ID_Start}|[_$])/"), (0, import_lib4.$N)(ReservedWord), IdentifierName), function(value) {
|
|
11753
11797
|
var id = value[2];
|
|
11754
11798
|
return id;
|
|
@@ -12496,7 +12540,8 @@ var PropertyName$3 = (0, import_lib4.$TV)((0, import_lib4.$TEXT)((0, import_lib4
|
|
|
12496
12540
|
});
|
|
12497
12541
|
var PropertyName$4 = IdentifierName;
|
|
12498
12542
|
var PropertyName$5 = LengthShorthand;
|
|
12499
|
-
var PropertyName
|
|
12543
|
+
var PropertyName$6 = SymbolElement;
|
|
12544
|
+
var PropertyName$$ = [PropertyName$0, PropertyName$1, PropertyName$2, PropertyName$3, PropertyName$4, PropertyName$5, PropertyName$6];
|
|
12500
12545
|
function PropertyName(ctx, state2) {
|
|
12501
12546
|
return (0, import_lib4.$EVENT_C)(ctx, state2, "PropertyName", PropertyName$$);
|
|
12502
12547
|
}
|
|
@@ -12758,7 +12803,8 @@ function MethodSignature(ctx, state2) {
|
|
|
12758
12803
|
var ClassElementName$0 = PropertyName;
|
|
12759
12804
|
var ClassElementName$1 = LengthShorthand;
|
|
12760
12805
|
var ClassElementName$2 = PrivateIdentifier;
|
|
12761
|
-
var ClassElementName
|
|
12806
|
+
var ClassElementName$3 = SymbolElement;
|
|
12807
|
+
var ClassElementName$$ = [ClassElementName$0, ClassElementName$1, ClassElementName$2, ClassElementName$3];
|
|
12762
12808
|
function ClassElementName(ctx, state2) {
|
|
12763
12809
|
return (0, import_lib4.$EVENT_C)(ctx, state2, "ClassElementName", ClassElementName$$);
|
|
12764
12810
|
}
|
|
@@ -13715,7 +13761,7 @@ var ForStatement$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(ForClause, BlockOr
|
|
|
13715
13761
|
function ForStatement(ctx, state2) {
|
|
13716
13762
|
return (0, import_lib4.$EVENT)(ctx, state2, "ForStatement", ForStatement$0);
|
|
13717
13763
|
}
|
|
13718
|
-
var ForClause$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(For, (0, import_lib4.$E)((0, import_lib4.$S)((0, import_lib4.$E)(_), Star)), __,
|
|
13764
|
+
var ForClause$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(For, (0, import_lib4.$E)((0, import_lib4.$S)((0, import_lib4.$E)(_), Star)), __, ForStatementControlWithWhen), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
13719
13765
|
var generator = $2;
|
|
13720
13766
|
var c = $4;
|
|
13721
13767
|
const { children, declaration } = c;
|
|
@@ -13732,26 +13778,41 @@ var ForClause$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(For, (0, import_lib4.
|
|
|
13732
13778
|
function ForClause(ctx, state2) {
|
|
13733
13779
|
return (0, import_lib4.$EVENT)(ctx, state2, "ForClause", ForClause$0);
|
|
13734
13780
|
}
|
|
13781
|
+
var ForStatementControlWithWhen$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(ForStatementControl, (0, import_lib4.$E)(WhenCondition)), function($skip, $loc, $0, $1, $2) {
|
|
13782
|
+
var control = $1;
|
|
13783
|
+
var condition = $2;
|
|
13784
|
+
if (!condition)
|
|
13785
|
+
return control;
|
|
13786
|
+
const expressions = [["", {
|
|
13787
|
+
type: "ContinueStatement",
|
|
13788
|
+
children: ["continue"]
|
|
13789
|
+
}]];
|
|
13790
|
+
const block = {
|
|
13791
|
+
type: "BlockStatement",
|
|
13792
|
+
expressions,
|
|
13793
|
+
children: [expressions],
|
|
13794
|
+
bare: true
|
|
13795
|
+
};
|
|
13796
|
+
return {
|
|
13797
|
+
...control,
|
|
13798
|
+
blockPrefix: [
|
|
13799
|
+
...control.blockPrefix,
|
|
13800
|
+
["", {
|
|
13801
|
+
type: "IfStatement",
|
|
13802
|
+
then: block,
|
|
13803
|
+
children: ["if (!", makeLeftHandSideExpression(trimFirstSpace(condition)), ") ", block]
|
|
13804
|
+
}, ";"]
|
|
13805
|
+
]
|
|
13806
|
+
};
|
|
13807
|
+
});
|
|
13808
|
+
function ForStatementControlWithWhen(ctx, state2) {
|
|
13809
|
+
return (0, import_lib4.$EVENT)(ctx, state2, "ForStatementControlWithWhen", ForStatementControlWithWhen$0);
|
|
13810
|
+
}
|
|
13735
13811
|
var ForStatementControl$0 = (0, import_lib4.$T)((0, import_lib4.$S)((0, import_lib4.$N)(CoffeeForLoopsEnabled), ForStatementParameters), function(value) {
|
|
13736
13812
|
return value[1];
|
|
13737
13813
|
});
|
|
13738
|
-
var ForStatementControl$1 = (0, import_lib4.$
|
|
13739
|
-
|
|
13740
|
-
if (condition) {
|
|
13741
|
-
const block = "continue";
|
|
13742
|
-
$2 = {
|
|
13743
|
-
...$2,
|
|
13744
|
-
blockPrefix: [
|
|
13745
|
-
...$2.blockPrefix,
|
|
13746
|
-
["", {
|
|
13747
|
-
type: "IfStatement",
|
|
13748
|
-
then: block,
|
|
13749
|
-
children: ["if (!(", trimFirstSpace(condition), ")) ", block]
|
|
13750
|
-
}, ";"]
|
|
13751
|
-
]
|
|
13752
|
-
};
|
|
13753
|
-
}
|
|
13754
|
-
return $2;
|
|
13814
|
+
var ForStatementControl$1 = (0, import_lib4.$T)((0, import_lib4.$S)(CoffeeForLoopsEnabled, CoffeeForStatementParameters), function(value) {
|
|
13815
|
+
return value[1];
|
|
13755
13816
|
});
|
|
13756
13817
|
var ForStatementControl$$ = [ForStatementControl$0, ForStatementControl$1];
|
|
13757
13818
|
function ForStatementControl(ctx, state2) {
|
|
@@ -18528,6 +18589,7 @@ var CivetOption$0 = (0, import_lib4.$TR)((0, import_lib4.$EXPECT)($R96, "CivetOp
|
|
|
18528
18589
|
value = 0;
|
|
18529
18590
|
break;
|
|
18530
18591
|
case "globals":
|
|
18592
|
+
case "symbols":
|
|
18531
18593
|
value = value.split(",").filter(Boolean);
|
|
18532
18594
|
break;
|
|
18533
18595
|
}
|
|
@@ -18903,6 +18965,7 @@ var Reset$0 = (0, import_lib4.$TV)((0, import_lib4.$EXPECT)($L0, 'Reset ""'), fu
|
|
|
18903
18965
|
repl: false,
|
|
18904
18966
|
rewriteTsImports: true,
|
|
18905
18967
|
server: false,
|
|
18968
|
+
symbols: wellKnownSymbols,
|
|
18906
18969
|
tab: void 0,
|
|
18907
18970
|
// default behavior = same as space
|
|
18908
18971
|
verbose: false
|
|
@@ -19199,6 +19262,21 @@ function parseProgram(input, options) {
|
|
|
19199
19262
|
});
|
|
19200
19263
|
}
|
|
19201
19264
|
}
|
|
19265
|
+
var wellKnownSymbols = [
|
|
19266
|
+
"asyncIterator",
|
|
19267
|
+
"hasInstance",
|
|
19268
|
+
"isConcatSpreadable",
|
|
19269
|
+
"iterator",
|
|
19270
|
+
"match",
|
|
19271
|
+
"matchAll",
|
|
19272
|
+
"replace",
|
|
19273
|
+
"search",
|
|
19274
|
+
"species",
|
|
19275
|
+
"split",
|
|
19276
|
+
"toPrimitive",
|
|
19277
|
+
"toStringTag",
|
|
19278
|
+
"unscopables"
|
|
19279
|
+
];
|
|
19202
19280
|
|
|
19203
19281
|
// source/sourcemap.civet
|
|
19204
19282
|
var sourcemap_exports = {};
|
package/dist/types.d.ts
CHANGED
|
@@ -105,6 +105,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
105
105
|
const transformTS = options.emitDeclaration || options.typecheck;
|
|
106
106
|
const outExt = options.outputExtension ?? (options.ts === "preserve" ? ".tsx" : ".jsx");
|
|
107
107
|
const implicitExtension = options.implicitExtension ?? true;
|
|
108
|
+
let aliasResolver;
|
|
108
109
|
let fsMap = /* @__PURE__ */ new Map();
|
|
109
110
|
const sourceMaps = /* @__PURE__ */ new Map();
|
|
110
111
|
let compilerOptions, compilerOptionsWithSourceMap;
|
|
@@ -121,7 +122,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
121
122
|
};
|
|
122
123
|
};
|
|
123
124
|
const cache = options.cache ? /* @__PURE__ */ new Map() : void 0;
|
|
124
|
-
|
|
125
|
+
const plugin = {
|
|
125
126
|
name: "unplugin-civet",
|
|
126
127
|
enforce: "pre",
|
|
127
128
|
async buildStart() {
|
|
@@ -375,8 +376,14 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
375
376
|
}
|
|
376
377
|
},
|
|
377
378
|
resolveId(id, importer, options2) {
|
|
379
|
+
if (aliasResolver != null) {
|
|
380
|
+
id = aliasResolver(id);
|
|
381
|
+
}
|
|
378
382
|
if (/\0/.test(id))
|
|
379
383
|
return null;
|
|
384
|
+
if (plugin.__virtualModulePrefix && importer?.startsWith(plugin.__virtualModulePrefix)) {
|
|
385
|
+
importer = decodeURIComponent(importer.slice(plugin.__virtualModulePrefix.length));
|
|
386
|
+
}
|
|
380
387
|
let postfix;
|
|
381
388
|
({ id, postfix } = cleanCivetId(id));
|
|
382
389
|
let ref1;
|
|
@@ -519,35 +526,28 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
519
526
|
config.resolve.extensions ??= DEFAULT_EXTENSIONS;
|
|
520
527
|
config.resolve.extensions.push(".civet");
|
|
521
528
|
}
|
|
522
|
-
;
|
|
523
|
-
return;
|
|
524
529
|
},
|
|
525
530
|
async transformIndexHtml(html) {
|
|
526
|
-
return html.replace(
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
return name.toLowerCase() === "src" && value ? attr.replace(
|
|
536
|
-
/(\.civet)(['"]?)$/,
|
|
537
|
-
(_, extension, endQuote) => {
|
|
538
|
-
return `${extension}${outExt}?transform${endQuote}`;
|
|
539
|
-
}
|
|
540
|
-
) : attr;
|
|
531
|
+
return html.replace(/<!--[^]*?-->|<[^<>]*>/g, (tag) => {
|
|
532
|
+
return tag.replace(/<\s*script\b[^<>]*>/gi, (script) => {
|
|
533
|
+
return script.replace(
|
|
534
|
+
/([:_\p{ID_Start}][:\p{ID_Continue}]*)(\s*=\s*("[^"]*"|'[^']*'|[^\s"'=<>`]*))?/gu,
|
|
535
|
+
(attr, name, value) => {
|
|
536
|
+
return name.toLowerCase() === "src" && value ? attr.replace(
|
|
537
|
+
/(\.civet)(['"]?)$/,
|
|
538
|
+
(_, extension, endQuote) => {
|
|
539
|
+
return `${extension}${outExt}?transform${endQuote}`;
|
|
541
540
|
}
|
|
542
|
-
);
|
|
541
|
+
) : attr;
|
|
543
542
|
}
|
|
544
543
|
);
|
|
545
|
-
}
|
|
546
|
-
);
|
|
544
|
+
});
|
|
545
|
+
});
|
|
547
546
|
},
|
|
548
547
|
handleHotUpdate({ file, server, modules }) {
|
|
549
|
-
if (!file.endsWith(".civet"))
|
|
548
|
+
if (!file.endsWith(".civet")) {
|
|
550
549
|
return;
|
|
550
|
+
}
|
|
551
551
|
const resolvedId = slash(import_path.default.resolve(file) + outExt);
|
|
552
552
|
const module2 = server.moduleGraph.getModuleById(resolvedId);
|
|
553
553
|
if (module2) {
|
|
@@ -556,8 +556,33 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
556
556
|
}
|
|
557
557
|
return modules;
|
|
558
558
|
}
|
|
559
|
+
},
|
|
560
|
+
webpack(compiler) {
|
|
561
|
+
if (implicitExtension) {
|
|
562
|
+
compiler.options.resolve.extensions.unshift(".civet");
|
|
563
|
+
}
|
|
564
|
+
return aliasResolver = (id) => {
|
|
565
|
+
let ref2;
|
|
566
|
+
for (const key in ref2 = compiler.options.resolve.alias) {
|
|
567
|
+
const value = ref2[key];
|
|
568
|
+
if (key.endsWith("$")) {
|
|
569
|
+
if (id === key.slice(0, -1)) {
|
|
570
|
+
return typeof value === "string" ? value : "\0";
|
|
571
|
+
}
|
|
572
|
+
} else {
|
|
573
|
+
if (id === key || id.startsWith(key + "/")) {
|
|
574
|
+
if (!(typeof value === "string")) {
|
|
575
|
+
return "\0";
|
|
576
|
+
}
|
|
577
|
+
return value + id.slice(key.length);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
return id;
|
|
582
|
+
};
|
|
559
583
|
}
|
|
560
584
|
};
|
|
585
|
+
return plugin;
|
|
561
586
|
};
|
|
562
587
|
var unplugin = (0, import_unplugin.createUnplugin)(rawPlugin);
|
|
563
588
|
var unplugin_civet_default = unplugin;
|
|
@@ -73,6 +73,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
73
73
|
const transformTS = options.emitDeclaration || options.typecheck;
|
|
74
74
|
const outExt = options.outputExtension ?? (options.ts === "preserve" ? ".tsx" : ".jsx");
|
|
75
75
|
const implicitExtension = options.implicitExtension ?? true;
|
|
76
|
+
let aliasResolver;
|
|
76
77
|
let fsMap = /* @__PURE__ */ new Map();
|
|
77
78
|
const sourceMaps = /* @__PURE__ */ new Map();
|
|
78
79
|
let compilerOptions, compilerOptionsWithSourceMap;
|
|
@@ -89,7 +90,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
89
90
|
};
|
|
90
91
|
};
|
|
91
92
|
const cache = options.cache ? /* @__PURE__ */ new Map() : void 0;
|
|
92
|
-
|
|
93
|
+
const plugin = {
|
|
93
94
|
name: "unplugin-civet",
|
|
94
95
|
enforce: "pre",
|
|
95
96
|
async buildStart() {
|
|
@@ -343,8 +344,14 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
343
344
|
}
|
|
344
345
|
},
|
|
345
346
|
resolveId(id, importer, options2) {
|
|
347
|
+
if (aliasResolver != null) {
|
|
348
|
+
id = aliasResolver(id);
|
|
349
|
+
}
|
|
346
350
|
if (/\0/.test(id))
|
|
347
351
|
return null;
|
|
352
|
+
if (plugin.__virtualModulePrefix && importer?.startsWith(plugin.__virtualModulePrefix)) {
|
|
353
|
+
importer = decodeURIComponent(importer.slice(plugin.__virtualModulePrefix.length));
|
|
354
|
+
}
|
|
348
355
|
let postfix;
|
|
349
356
|
({ id, postfix } = cleanCivetId(id));
|
|
350
357
|
let ref1;
|
|
@@ -487,35 +494,28 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
487
494
|
config.resolve.extensions ??= DEFAULT_EXTENSIONS;
|
|
488
495
|
config.resolve.extensions.push(".civet");
|
|
489
496
|
}
|
|
490
|
-
;
|
|
491
|
-
return;
|
|
492
497
|
},
|
|
493
498
|
async transformIndexHtml(html) {
|
|
494
|
-
return html.replace(
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
return name.toLowerCase() === "src" && value ? attr.replace(
|
|
504
|
-
/(\.civet)(['"]?)$/,
|
|
505
|
-
(_, extension, endQuote) => {
|
|
506
|
-
return `${extension}${outExt}?transform${endQuote}`;
|
|
507
|
-
}
|
|
508
|
-
) : attr;
|
|
499
|
+
return html.replace(/<!--[^]*?-->|<[^<>]*>/g, (tag) => {
|
|
500
|
+
return tag.replace(/<\s*script\b[^<>]*>/gi, (script) => {
|
|
501
|
+
return script.replace(
|
|
502
|
+
/([:_\p{ID_Start}][:\p{ID_Continue}]*)(\s*=\s*("[^"]*"|'[^']*'|[^\s"'=<>`]*))?/gu,
|
|
503
|
+
(attr, name, value) => {
|
|
504
|
+
return name.toLowerCase() === "src" && value ? attr.replace(
|
|
505
|
+
/(\.civet)(['"]?)$/,
|
|
506
|
+
(_, extension, endQuote) => {
|
|
507
|
+
return `${extension}${outExt}?transform${endQuote}`;
|
|
509
508
|
}
|
|
510
|
-
);
|
|
509
|
+
) : attr;
|
|
511
510
|
}
|
|
512
511
|
);
|
|
513
|
-
}
|
|
514
|
-
);
|
|
512
|
+
});
|
|
513
|
+
});
|
|
515
514
|
},
|
|
516
515
|
handleHotUpdate({ file, server, modules }) {
|
|
517
|
-
if (!file.endsWith(".civet"))
|
|
516
|
+
if (!file.endsWith(".civet")) {
|
|
518
517
|
return;
|
|
518
|
+
}
|
|
519
519
|
const resolvedId = slash(path.resolve(file) + outExt);
|
|
520
520
|
const module = server.moduleGraph.getModuleById(resolvedId);
|
|
521
521
|
if (module) {
|
|
@@ -524,8 +524,33 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
524
524
|
}
|
|
525
525
|
return modules;
|
|
526
526
|
}
|
|
527
|
+
},
|
|
528
|
+
webpack(compiler) {
|
|
529
|
+
if (implicitExtension) {
|
|
530
|
+
compiler.options.resolve.extensions.unshift(".civet");
|
|
531
|
+
}
|
|
532
|
+
return aliasResolver = (id) => {
|
|
533
|
+
let ref2;
|
|
534
|
+
for (const key in ref2 = compiler.options.resolve.alias) {
|
|
535
|
+
const value = ref2[key];
|
|
536
|
+
if (key.endsWith("$")) {
|
|
537
|
+
if (id === key.slice(0, -1)) {
|
|
538
|
+
return typeof value === "string" ? value : "\0";
|
|
539
|
+
}
|
|
540
|
+
} else {
|
|
541
|
+
if (id === key || id.startsWith(key + "/")) {
|
|
542
|
+
if (!(typeof value === "string")) {
|
|
543
|
+
return "\0";
|
|
544
|
+
}
|
|
545
|
+
return value + id.slice(key.length);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
return id;
|
|
550
|
+
};
|
|
527
551
|
}
|
|
528
552
|
};
|
|
553
|
+
return plugin;
|
|
529
554
|
};
|
|
530
555
|
var unplugin = createUnplugin(rawPlugin);
|
|
531
556
|
var unplugin_civet_default = unplugin;
|