@danielx/civet 0.6.87 → 0.6.89
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/README.md +3 -4
- package/dist/browser.js +251 -48
- package/dist/civet +117 -10
- package/dist/esm.mjs +0 -11
- package/dist/main.js +251 -48
- package/dist/main.mjs +251 -48
- package/dist/types.d.ts +6 -1
- package/package.json +2 -2
- package/register.js +20 -4
package/dist/main.js
CHANGED
|
@@ -227,6 +227,9 @@ function hasAwait(exp) {
|
|
|
227
227
|
function hasYield(exp) {
|
|
228
228
|
return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Yield").length > 0;
|
|
229
229
|
}
|
|
230
|
+
function hasImportDeclaration(exp) {
|
|
231
|
+
return gatherRecursiveWithinFunction(exp, ({ type }) => type === "ImportDeclaration").length > 0;
|
|
232
|
+
}
|
|
230
233
|
function deepCopy(node) {
|
|
231
234
|
if (node == null)
|
|
232
235
|
return node;
|
|
@@ -388,9 +391,10 @@ function parenthesizeType(type) {
|
|
|
388
391
|
}
|
|
389
392
|
return ["(", type, ")"];
|
|
390
393
|
}
|
|
391
|
-
function wrapIIFE(expressions,
|
|
394
|
+
function wrapIIFE(expressions, asyncFlag) {
|
|
392
395
|
let prefix;
|
|
393
|
-
|
|
396
|
+
let async;
|
|
397
|
+
if (asyncFlag) {
|
|
394
398
|
async = "async ";
|
|
395
399
|
} else if (hasAwait(expressions)) {
|
|
396
400
|
async = "async ";
|
|
@@ -578,16 +582,16 @@ function blockWithPrefix(prefixStatements, block) {
|
|
|
578
582
|
expressions,
|
|
579
583
|
children: block.children === block.expressions ? expressions : block.children.map((c) => c === block.expressions ? expressions : c)
|
|
580
584
|
};
|
|
581
|
-
|
|
582
|
-
block.children = [[" {"], ...block.children, "}"];
|
|
583
|
-
block.bare = false;
|
|
584
|
-
}
|
|
585
|
+
braceBlock(block);
|
|
585
586
|
updateParentPointers(block);
|
|
586
587
|
}
|
|
587
588
|
return block;
|
|
588
589
|
}
|
|
589
590
|
function braceBlock(block) {
|
|
590
591
|
if (block.bare) {
|
|
592
|
+
if (block.children === block.expressions) {
|
|
593
|
+
block.children = [block.expressions];
|
|
594
|
+
}
|
|
591
595
|
block.children.unshift(" {");
|
|
592
596
|
block.children.push("}");
|
|
593
597
|
return block.bare = false;
|
|
@@ -597,8 +601,13 @@ function braceBlock(block) {
|
|
|
597
601
|
}
|
|
598
602
|
function duplicateBlock(block) {
|
|
599
603
|
const expressions = [...block.expressions];
|
|
600
|
-
|
|
601
|
-
|
|
604
|
+
let children;
|
|
605
|
+
if (block.children === block.expressions) {
|
|
606
|
+
children = expressions;
|
|
607
|
+
} else {
|
|
608
|
+
children = [...block.children];
|
|
609
|
+
children.splice(children.indexOf(block.expressions), 1, expressions);
|
|
610
|
+
}
|
|
602
611
|
return {
|
|
603
612
|
...block,
|
|
604
613
|
expressions,
|
|
@@ -1704,7 +1713,11 @@ function patternAsValue(pattern) {
|
|
|
1704
1713
|
}
|
|
1705
1714
|
case "Identifier":
|
|
1706
1715
|
case "BindingProperty": {
|
|
1707
|
-
const children = [
|
|
1716
|
+
const children = [
|
|
1717
|
+
// { name: value } = ... declares value, not name
|
|
1718
|
+
pattern.value ?? pattern.name,
|
|
1719
|
+
pattern.delim
|
|
1720
|
+
];
|
|
1708
1721
|
if (isWhitespaceOrEmpty(pattern.children[0])) {
|
|
1709
1722
|
children.unshift(pattern.children[0]);
|
|
1710
1723
|
}
|
|
@@ -2011,8 +2024,7 @@ function expressionizeIteration(exp) {
|
|
|
2011
2024
|
throw new Error("Could not find iteration statement in iteration expression");
|
|
2012
2025
|
}
|
|
2013
2026
|
if (subtype === "DoStatement") {
|
|
2014
|
-
|
|
2015
|
-
children.splice(i, 1, ...wrapIIFE(["", statement, void 0], async));
|
|
2027
|
+
children.splice(i, 1, ...wrapIIFE([["", statement, void 0]], async));
|
|
2016
2028
|
updateParentPointers(exp);
|
|
2017
2029
|
return;
|
|
2018
2030
|
}
|
|
@@ -2312,6 +2324,111 @@ function processDeclarationConditionStatement(s, getRef) {
|
|
|
2312
2324
|
}
|
|
2313
2325
|
}
|
|
2314
2326
|
}
|
|
2327
|
+
function dynamizeFromClause(from) {
|
|
2328
|
+
from = from.slice(1);
|
|
2329
|
+
from = insertTrimmingSpace(from, "");
|
|
2330
|
+
if (from.at(-1)?.type === "ImportAssertion") {
|
|
2331
|
+
const assert2 = from.pop();
|
|
2332
|
+
from.push(", {", assert2.keyword, ":", assert2.object, "}");
|
|
2333
|
+
}
|
|
2334
|
+
return ["(", ...from, ")"];
|
|
2335
|
+
}
|
|
2336
|
+
function dynamizeImportDeclaration(decl) {
|
|
2337
|
+
const { imports } = decl;
|
|
2338
|
+
let { star, binding, specifiers } = imports;
|
|
2339
|
+
const justDefault = binding && !specifiers && !star;
|
|
2340
|
+
const pattern = (() => {
|
|
2341
|
+
{
|
|
2342
|
+
if (binding) {
|
|
2343
|
+
if (specifiers) {
|
|
2344
|
+
return makeRef();
|
|
2345
|
+
} else {
|
|
2346
|
+
return binding;
|
|
2347
|
+
}
|
|
2348
|
+
} else {
|
|
2349
|
+
return convertNamedImportsToObject(imports, true);
|
|
2350
|
+
}
|
|
2351
|
+
}
|
|
2352
|
+
})();
|
|
2353
|
+
const c = "const";
|
|
2354
|
+
const initializer = [
|
|
2355
|
+
" = ",
|
|
2356
|
+
justDefault ? "(" : void 0,
|
|
2357
|
+
{ type: "Await", children: ["await"] },
|
|
2358
|
+
" ",
|
|
2359
|
+
decl.children[0],
|
|
2360
|
+
// import
|
|
2361
|
+
dynamizeFromClause(decl.from),
|
|
2362
|
+
justDefault ? ").default" : void 0
|
|
2363
|
+
];
|
|
2364
|
+
const bindings = [{
|
|
2365
|
+
type: "Binding",
|
|
2366
|
+
names: pattern.names,
|
|
2367
|
+
pattern,
|
|
2368
|
+
initializer,
|
|
2369
|
+
children: [pattern, initializer]
|
|
2370
|
+
}];
|
|
2371
|
+
if (binding && specifiers) {
|
|
2372
|
+
const pattern2 = binding;
|
|
2373
|
+
const initializer2 = [
|
|
2374
|
+
" = ",
|
|
2375
|
+
pattern,
|
|
2376
|
+
".default"
|
|
2377
|
+
];
|
|
2378
|
+
bindings.push({
|
|
2379
|
+
type: "Binding",
|
|
2380
|
+
names: binding.names,
|
|
2381
|
+
pattern: pattern2,
|
|
2382
|
+
initializer: initializer2,
|
|
2383
|
+
children: [pattern2, initializer2]
|
|
2384
|
+
});
|
|
2385
|
+
const pattern3 = convertNamedImportsToObject(imports.children.at(-1), true);
|
|
2386
|
+
const initializer3 = [
|
|
2387
|
+
" = ",
|
|
2388
|
+
pattern
|
|
2389
|
+
];
|
|
2390
|
+
bindings.push({
|
|
2391
|
+
type: "Binding",
|
|
2392
|
+
names: specifiers.names,
|
|
2393
|
+
pattern: pattern3,
|
|
2394
|
+
initializer: initializer3,
|
|
2395
|
+
children: [pattern3, initializer3]
|
|
2396
|
+
});
|
|
2397
|
+
}
|
|
2398
|
+
return {
|
|
2399
|
+
type: "Declaration",
|
|
2400
|
+
names: imports.names,
|
|
2401
|
+
bindings,
|
|
2402
|
+
decl: c,
|
|
2403
|
+
children: [
|
|
2404
|
+
c,
|
|
2405
|
+
" ",
|
|
2406
|
+
bindings.flatMap((binding2, i) => i > 0 ? [", ", binding2] : [binding2])
|
|
2407
|
+
]
|
|
2408
|
+
};
|
|
2409
|
+
}
|
|
2410
|
+
function dynamizeImportDeclarationExpression($0) {
|
|
2411
|
+
const [imp, ws1, named, ws2, from] = $0;
|
|
2412
|
+
const object = convertNamedImportsToObject(named);
|
|
2413
|
+
const dot = ".";
|
|
2414
|
+
return processCallMemberExpression({
|
|
2415
|
+
type: "CallExpression",
|
|
2416
|
+
children: [
|
|
2417
|
+
{ type: "Await", children: "await" },
|
|
2418
|
+
" ",
|
|
2419
|
+
imp,
|
|
2420
|
+
insertTrimmingSpace(ws2, ""),
|
|
2421
|
+
dynamizeFromClause(from),
|
|
2422
|
+
{
|
|
2423
|
+
type: "PropertyGlob",
|
|
2424
|
+
dot,
|
|
2425
|
+
object,
|
|
2426
|
+
children: [ws1, dot, object],
|
|
2427
|
+
reversed: true
|
|
2428
|
+
}
|
|
2429
|
+
]
|
|
2430
|
+
});
|
|
2431
|
+
}
|
|
2315
2432
|
var init_declaration = __esm({
|
|
2316
2433
|
"source/parser/declaration.civet"() {
|
|
2317
2434
|
"use strict";
|
|
@@ -2321,6 +2438,7 @@ var init_declaration = __esm({
|
|
|
2321
2438
|
init_util();
|
|
2322
2439
|
init_function();
|
|
2323
2440
|
init_binding();
|
|
2441
|
+
init_lib();
|
|
2324
2442
|
}
|
|
2325
2443
|
});
|
|
2326
2444
|
|
|
@@ -3137,21 +3255,28 @@ __export(lib_exports, {
|
|
|
3137
3255
|
adjustIndexAccess: () => adjustIndexAccess,
|
|
3138
3256
|
attachPostfixStatementAsExpression: () => attachPostfixStatementAsExpression,
|
|
3139
3257
|
blockWithPrefix: () => blockWithPrefix,
|
|
3258
|
+
convertNamedImportsToObject: () => convertNamedImportsToObject,
|
|
3140
3259
|
convertObjectToJSXAttributes: () => convertObjectToJSXAttributes,
|
|
3141
3260
|
dedentBlockString: () => dedentBlockString,
|
|
3142
3261
|
dedentBlockSubstitutions: () => dedentBlockSubstitutions,
|
|
3143
3262
|
deepCopy: () => deepCopy,
|
|
3263
|
+
dynamizeImportDeclaration: () => dynamizeImportDeclaration,
|
|
3264
|
+
dynamizeImportDeclarationExpression: () => dynamizeImportDeclarationExpression,
|
|
3144
3265
|
expressionizeTypeIf: () => expressionizeTypeIf,
|
|
3145
3266
|
forRange: () => forRange,
|
|
3146
3267
|
gatherBindingCode: () => gatherBindingCode,
|
|
3147
3268
|
gatherRecursive: () => gatherRecursive,
|
|
3269
|
+
gatherRecursiveAll: () => gatherRecursiveAll,
|
|
3270
|
+
gatherRecursiveWithinFunction: () => gatherRecursiveWithinFunction,
|
|
3148
3271
|
getIndentLevel: () => getIndentLevel,
|
|
3149
3272
|
getPrecedence: () => getPrecedence,
|
|
3150
3273
|
getTrimmingSpace: () => getTrimmingSpace,
|
|
3151
3274
|
hasAwait: () => hasAwait,
|
|
3275
|
+
hasImportDeclaration: () => hasImportDeclaration,
|
|
3152
3276
|
hasYield: () => hasYield,
|
|
3153
3277
|
insertTrimmingSpace: () => insertTrimmingSpace,
|
|
3154
3278
|
isEmptyBareBlock: () => isEmptyBareBlock,
|
|
3279
|
+
isFunction: () => isFunction,
|
|
3155
3280
|
isWhitespaceOrEmpty: () => isWhitespaceOrEmpty,
|
|
3156
3281
|
lastAccessInCallExpression: () => lastAccessInCallExpression,
|
|
3157
3282
|
literalValue: () => literalValue,
|
|
@@ -3412,9 +3537,13 @@ function processCallMemberExpression(node) {
|
|
|
3412
3537
|
throw new Error(`Glob pattern must have call or member expression value, found ${JSON.stringify(part.value)}`);
|
|
3413
3538
|
}
|
|
3414
3539
|
let suppressPrefix = false;
|
|
3415
|
-
let
|
|
3540
|
+
let name = part.name;
|
|
3541
|
+
let value = part.value ?? name;
|
|
3416
3542
|
const wValue = getTrimmingSpace(part.value);
|
|
3417
3543
|
[value, suppressPrefix] = handleThisPrivateShorthands(value);
|
|
3544
|
+
if (glob.reversed) {
|
|
3545
|
+
[name, value] = [value, name];
|
|
3546
|
+
}
|
|
3418
3547
|
if (!suppressPrefix) {
|
|
3419
3548
|
value = prefix.concat(insertTrimmingSpace(value, ""));
|
|
3420
3549
|
}
|
|
@@ -3432,13 +3561,13 @@ function processCallMemberExpression(node) {
|
|
|
3432
3561
|
} else {
|
|
3433
3562
|
parts.push({
|
|
3434
3563
|
type: part.type === "Identifier" ? "Property" : part.type,
|
|
3435
|
-
name
|
|
3564
|
+
name,
|
|
3436
3565
|
value,
|
|
3437
3566
|
delim: part.delim,
|
|
3438
3567
|
names: part.names,
|
|
3439
3568
|
children: [
|
|
3440
3569
|
isWhitespaceOrEmpty(part.children[0]) && part.children[0],
|
|
3441
|
-
|
|
3570
|
+
name,
|
|
3442
3571
|
isWhitespaceOrEmpty(part.children[2]) && part.children[2],
|
|
3443
3572
|
part.children[3]?.token === ":" ? part.children[3] : ":",
|
|
3444
3573
|
value,
|
|
@@ -3583,6 +3712,35 @@ function convertMethodToFunction(method) {
|
|
|
3583
3712
|
block
|
|
3584
3713
|
};
|
|
3585
3714
|
}
|
|
3715
|
+
function convertNamedImportsToObject(node, pattern) {
|
|
3716
|
+
const properties = node.specifiers.map((specifier) => {
|
|
3717
|
+
if (specifier.ts) {
|
|
3718
|
+
return { type: "Error", message: "cannot use `type` in dynamic import" };
|
|
3719
|
+
} else {
|
|
3720
|
+
const { source, binding } = specifier;
|
|
3721
|
+
const delim = specifier.children.at(-1);
|
|
3722
|
+
return {
|
|
3723
|
+
type: pattern ? "BindingProperty" : "Property",
|
|
3724
|
+
name: source,
|
|
3725
|
+
value: !(source === binding) ? binding : void 0,
|
|
3726
|
+
delim,
|
|
3727
|
+
children: source === binding ? [source, delim] : [source, ":", binding, delim]
|
|
3728
|
+
};
|
|
3729
|
+
}
|
|
3730
|
+
});
|
|
3731
|
+
return {
|
|
3732
|
+
type: pattern ? "ObjectBindingPattern" : "ObjectExpression",
|
|
3733
|
+
names: node.names,
|
|
3734
|
+
properties,
|
|
3735
|
+
children: [
|
|
3736
|
+
node.children[0],
|
|
3737
|
+
// {
|
|
3738
|
+
properties,
|
|
3739
|
+
node.children.at(-1)
|
|
3740
|
+
// }
|
|
3741
|
+
]
|
|
3742
|
+
};
|
|
3743
|
+
}
|
|
3586
3744
|
function convertObjectToJSXAttributes(obj) {
|
|
3587
3745
|
const { properties } = obj;
|
|
3588
3746
|
const parts = [];
|
|
@@ -7058,14 +7216,17 @@ var require_parser = __commonJS({
|
|
|
7058
7216
|
children: [$1, ...$2, ...rest.flat()]
|
|
7059
7217
|
});
|
|
7060
7218
|
});
|
|
7061
|
-
var CallExpression$1 = $TS($S(
|
|
7219
|
+
var CallExpression$1 = $TS($S(Import, _, NamedImports, __, FromClause), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
7220
|
+
return dynamizeImportDeclarationExpression($0);
|
|
7221
|
+
});
|
|
7222
|
+
var CallExpression$2 = $TS($S($EXPECT($L20, 'CallExpression "import"'), ArgumentsWithTrailingMemberExpressions, $Q(CallExpressionRest)), function($skip, $loc, $0, $1, $2, $3) {
|
|
7062
7223
|
var rest = $3;
|
|
7063
7224
|
return processCallMemberExpression({
|
|
7064
7225
|
type: "CallExpression",
|
|
7065
7226
|
children: [$1, ...$2, ...rest.flat()]
|
|
7066
7227
|
});
|
|
7067
7228
|
});
|
|
7068
|
-
var CallExpression$
|
|
7229
|
+
var CallExpression$3 = $TS($S(MemberExpression, AllowedTrailingMemberExpressions, $Q(CallExpressionRest)), function($skip, $loc, $0, $1, $2, $3) {
|
|
7069
7230
|
var member = $1;
|
|
7070
7231
|
var trailing = $2;
|
|
7071
7232
|
var rest = $3;
|
|
@@ -7078,7 +7239,7 @@ var require_parser = __commonJS({
|
|
|
7078
7239
|
}
|
|
7079
7240
|
return member;
|
|
7080
7241
|
});
|
|
7081
|
-
var CallExpression$$ = [CallExpression$0, CallExpression$1, CallExpression$2];
|
|
7242
|
+
var CallExpression$$ = [CallExpression$0, CallExpression$1, CallExpression$2, CallExpression$3];
|
|
7082
7243
|
function CallExpression(ctx, state) {
|
|
7083
7244
|
return $EVENT_C(ctx, state, "CallExpression", CallExpression$$);
|
|
7084
7245
|
}
|
|
@@ -8660,11 +8821,14 @@ var require_parser = __commonJS({
|
|
|
8660
8821
|
});
|
|
8661
8822
|
var NonSingleBracedBlock$1 = ImplicitNestedBlock;
|
|
8662
8823
|
var NonSingleBracedBlock$2 = $TS($S(InsertOpenBrace, NestedImplicitObjectLiteral, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3) {
|
|
8824
|
+
var o = $1;
|
|
8663
8825
|
var s = $2;
|
|
8826
|
+
var c = $3;
|
|
8827
|
+
const expressions = [s];
|
|
8664
8828
|
return {
|
|
8665
8829
|
type: "BlockStatement",
|
|
8666
|
-
expressions
|
|
8667
|
-
children:
|
|
8830
|
+
expressions,
|
|
8831
|
+
children: [o, expressions, c]
|
|
8668
8832
|
};
|
|
8669
8833
|
});
|
|
8670
8834
|
var NonSingleBracedBlock$$ = [NonSingleBracedBlock$0, NonSingleBracedBlock$1, NonSingleBracedBlock$2];
|
|
@@ -11342,28 +11506,31 @@ var require_parser = __commonJS({
|
|
|
11342
11506
|
};
|
|
11343
11507
|
});
|
|
11344
11508
|
var ImportDeclaration$1 = $T($S(Import, __, TypeKeyword, __, ImportClause, __, FromClause), function(value) {
|
|
11345
|
-
|
|
11509
|
+
var imports = value[4];
|
|
11510
|
+
var from = value[6];
|
|
11511
|
+
return { "type": "ImportDeclaration", "ts": true, "children": value, "imports": imports, "from": from };
|
|
11346
11512
|
});
|
|
11347
11513
|
var ImportDeclaration$2 = $T($S(Import, __, ImportClause, __, FromClause), function(value) {
|
|
11348
|
-
|
|
11514
|
+
var imports = value[2];
|
|
11515
|
+
var from = value[4];
|
|
11516
|
+
return { "type": "ImportDeclaration", "children": value, "imports": imports, "from": from };
|
|
11349
11517
|
});
|
|
11350
11518
|
var ImportDeclaration$3 = $T($S(Import, __, ModuleSpecifier), function(value) {
|
|
11351
|
-
|
|
11519
|
+
var module4 = value[2];
|
|
11520
|
+
return { "type": "ImportDeclaration", "children": value, "module": module4 };
|
|
11352
11521
|
});
|
|
11353
11522
|
var ImportDeclaration$4 = $TS($S(ImpliedImport, $E($S(TypeKeyword, __)), ImportClause, __, FromClause), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
11354
11523
|
var i = $1;
|
|
11355
11524
|
var t = $2;
|
|
11356
|
-
var
|
|
11525
|
+
var imports = $3;
|
|
11357
11526
|
var w = $4;
|
|
11358
|
-
var
|
|
11527
|
+
var from = $5;
|
|
11359
11528
|
i.$loc = {
|
|
11360
|
-
pos:
|
|
11361
|
-
length:
|
|
11529
|
+
pos: from[0].$loc.pos - 1,
|
|
11530
|
+
length: from[0].$loc.length + 1
|
|
11362
11531
|
};
|
|
11363
|
-
const children = [i, t,
|
|
11364
|
-
|
|
11365
|
-
return children;
|
|
11366
|
-
return { type: "ImportDeclaration", ts: true, children };
|
|
11532
|
+
const children = [i, t, imports, w, from];
|
|
11533
|
+
return { type: "ImportDeclaration", ts: !!t, children, imports, from };
|
|
11367
11534
|
});
|
|
11368
11535
|
var ImportDeclaration$$ = [ImportDeclaration$0, ImportDeclaration$1, ImportDeclaration$2, ImportDeclaration$3, ImportDeclaration$4];
|
|
11369
11536
|
function ImportDeclaration(ctx, state) {
|
|
@@ -11381,14 +11548,17 @@ var require_parser = __commonJS({
|
|
|
11381
11548
|
if (rest) {
|
|
11382
11549
|
return {
|
|
11383
11550
|
type: "Declaration",
|
|
11384
|
-
children:
|
|
11385
|
-
names: [...binding.names, ...rest[3].names]
|
|
11551
|
+
children: [binding, ...rest],
|
|
11552
|
+
names: [...binding.names, ...rest[3].names],
|
|
11553
|
+
binding,
|
|
11554
|
+
specifiers: rest[3].specifiers
|
|
11386
11555
|
};
|
|
11387
11556
|
}
|
|
11388
11557
|
return {
|
|
11389
11558
|
type: "Declaration",
|
|
11390
|
-
children:
|
|
11391
|
-
names: binding.names
|
|
11559
|
+
children: [binding],
|
|
11560
|
+
names: binding.names,
|
|
11561
|
+
binding
|
|
11392
11562
|
};
|
|
11393
11563
|
});
|
|
11394
11564
|
var ImportClause$1 = NameSpaceImport;
|
|
@@ -11398,11 +11568,14 @@ var require_parser = __commonJS({
|
|
|
11398
11568
|
return $EVENT_C(ctx, state, "ImportClause", ImportClause$$);
|
|
11399
11569
|
}
|
|
11400
11570
|
var NameSpaceImport$0 = $TS($S(Star, ImportAsToken, __, ImportedBinding), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
11571
|
+
var star = $1;
|
|
11401
11572
|
var binding = $4;
|
|
11402
11573
|
return {
|
|
11403
11574
|
type: "Declaration",
|
|
11404
11575
|
children: $0,
|
|
11405
|
-
names: binding.names
|
|
11576
|
+
names: binding.names,
|
|
11577
|
+
binding,
|
|
11578
|
+
star
|
|
11406
11579
|
};
|
|
11407
11580
|
});
|
|
11408
11581
|
function NameSpaceImport(ctx, state) {
|
|
@@ -11414,17 +11587,32 @@ var require_parser = __commonJS({
|
|
|
11414
11587
|
return {
|
|
11415
11588
|
type: "Declaration",
|
|
11416
11589
|
children: $0,
|
|
11417
|
-
names
|
|
11590
|
+
names,
|
|
11591
|
+
specifiers
|
|
11418
11592
|
};
|
|
11419
11593
|
});
|
|
11420
11594
|
function NamedImports(ctx, state) {
|
|
11421
11595
|
return $EVENT(ctx, state, "NamedImports", NamedImports$0);
|
|
11422
11596
|
}
|
|
11423
|
-
var FromClause$0 = $S(From, __, ModuleSpecifier)
|
|
11597
|
+
var FromClause$0 = $TS($S(From, __, ModuleSpecifier), function($skip, $loc, $0, $1, $2, $3) {
|
|
11598
|
+
var module4 = $3;
|
|
11599
|
+
if (!Array.isArray(module4))
|
|
11600
|
+
return $0;
|
|
11601
|
+
return [$1, $2, ...module4];
|
|
11602
|
+
});
|
|
11424
11603
|
function FromClause(ctx, state) {
|
|
11425
11604
|
return $EVENT(ctx, state, "FromClause", FromClause$0);
|
|
11426
11605
|
}
|
|
11427
|
-
var ImportAssertion$0 = $S($E(_), $C($EXPECT($L117, 'ImportAssertion "with"'), $EXPECT($L118, 'ImportAssertion "assert"')), NonIdContinue, $E(_), ObjectLiteral)
|
|
11606
|
+
var ImportAssertion$0 = $TS($S($E(_), $C($EXPECT($L117, 'ImportAssertion "with"'), $EXPECT($L118, 'ImportAssertion "assert"')), NonIdContinue, $E(_), ObjectLiteral), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
11607
|
+
var keyword = $2;
|
|
11608
|
+
var object = $5;
|
|
11609
|
+
return {
|
|
11610
|
+
type: "ImportAssertion",
|
|
11611
|
+
keyword,
|
|
11612
|
+
object,
|
|
11613
|
+
children: $0
|
|
11614
|
+
};
|
|
11615
|
+
});
|
|
11428
11616
|
function ImportAssertion(ctx, state) {
|
|
11429
11617
|
return $EVENT(ctx, state, "ImportAssertion", ImportAssertion$0);
|
|
11430
11618
|
}
|
|
@@ -11454,8 +11642,10 @@ var require_parser = __commonJS({
|
|
|
11454
11642
|
return $EVENT_C(ctx, state, "TypeAndImportSpecifier", TypeAndImportSpecifier$$);
|
|
11455
11643
|
}
|
|
11456
11644
|
var ImportSpecifier$0 = $TS($S(__, ModuleExportName, ImportAsToken, __, ImportedBinding, ObjectPropertyDelimiter), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
11645
|
+
var source = $2;
|
|
11457
11646
|
var binding = $5;
|
|
11458
11647
|
return {
|
|
11648
|
+
source,
|
|
11459
11649
|
binding,
|
|
11460
11650
|
children: $0
|
|
11461
11651
|
};
|
|
@@ -11463,6 +11653,7 @@ var require_parser = __commonJS({
|
|
|
11463
11653
|
var ImportSpecifier$1 = $TS($S(__, ImportedBinding, ObjectPropertyDelimiter), function($skip, $loc, $0, $1, $2, $3) {
|
|
11464
11654
|
var binding = $2;
|
|
11465
11655
|
return {
|
|
11656
|
+
source: binding,
|
|
11466
11657
|
binding,
|
|
11467
11658
|
children: $0
|
|
11468
11659
|
};
|
|
@@ -11654,9 +11845,18 @@ var require_parser = __commonJS({
|
|
|
11654
11845
|
function ImplicitExportSpecifier(ctx, state) {
|
|
11655
11846
|
return $EVENT(ctx, state, "ImplicitExportSpecifier", ImplicitExportSpecifier$0);
|
|
11656
11847
|
}
|
|
11657
|
-
var Declaration$0 =
|
|
11658
|
-
|
|
11659
|
-
|
|
11848
|
+
var Declaration$0 = $TV(ImportDeclaration, function($skip, $loc, $0, $1) {
|
|
11849
|
+
var decl = $0;
|
|
11850
|
+
if (decl.ts || decl.module || !decl.imports || !decl.from)
|
|
11851
|
+
return $skip;
|
|
11852
|
+
const { imports } = decl;
|
|
11853
|
+
if (!imports.binding && !imports.specifiers)
|
|
11854
|
+
return $skip;
|
|
11855
|
+
return dynamizeImportDeclaration(decl);
|
|
11856
|
+
});
|
|
11857
|
+
var Declaration$1 = HoistableDeclaration;
|
|
11858
|
+
var Declaration$2 = ClassDeclaration;
|
|
11859
|
+
var Declaration$3 = $TV(LexicalDeclaration, function($skip, $loc, $0, $1) {
|
|
11660
11860
|
var d = $0;
|
|
11661
11861
|
if (d.thisAssignments?.length)
|
|
11662
11862
|
return {
|
|
@@ -11670,11 +11870,11 @@ var require_parser = __commonJS({
|
|
|
11670
11870
|
};
|
|
11671
11871
|
return d;
|
|
11672
11872
|
});
|
|
11673
|
-
var Declaration$
|
|
11674
|
-
var Declaration$
|
|
11675
|
-
var Declaration$
|
|
11676
|
-
var Declaration$
|
|
11677
|
-
var Declaration$$ = [Declaration$0, Declaration$1, Declaration$2, Declaration$3, Declaration$4, Declaration$5, Declaration$6];
|
|
11873
|
+
var Declaration$4 = TypeDeclaration;
|
|
11874
|
+
var Declaration$5 = EnumDeclaration;
|
|
11875
|
+
var Declaration$6 = OperatorDeclaration;
|
|
11876
|
+
var Declaration$7 = UsingDeclaration;
|
|
11877
|
+
var Declaration$$ = [Declaration$0, Declaration$1, Declaration$2, Declaration$3, Declaration$4, Declaration$5, Declaration$6, Declaration$7];
|
|
11678
11878
|
function Declaration(ctx, state) {
|
|
11679
11879
|
return $EVENT_C(ctx, state, "Declaration", Declaration$$);
|
|
11680
11880
|
}
|
|
@@ -16428,10 +16628,13 @@ function compile(src, options) {
|
|
|
16428
16628
|
let ast;
|
|
16429
16629
|
try {
|
|
16430
16630
|
import_parser.parse.config = options.parseOptions || {};
|
|
16431
|
-
ast =
|
|
16631
|
+
ast = (0, import_parser.parse)(src, {
|
|
16432
16632
|
filename,
|
|
16433
16633
|
events
|
|
16434
|
-
})
|
|
16634
|
+
});
|
|
16635
|
+
if (!(options.ast === "raw")) {
|
|
16636
|
+
ast = prune(ast);
|
|
16637
|
+
}
|
|
16435
16638
|
} finally {
|
|
16436
16639
|
if (hits || trace) {
|
|
16437
16640
|
import("fs").then(function({ writeFileSync }) {
|