@jay-framework/compiler 0.23.0 → 0.23.1
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/dist/index.d.ts +1 -1
- package/dist/index.js +59 -118
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -201,7 +201,7 @@ declare class SourceFileStatementDependencies {
|
|
|
201
201
|
constructor(sourceFile: ts.SourceFile, bindingResolver: SourceFileBindingResolver);
|
|
202
202
|
getDependsOn(statement: ts.Statement): Set<StatementDependencies>;
|
|
203
203
|
getIsDependencyFor(statement: ts.Statement): Set<StatementDependencies>;
|
|
204
|
-
getAllStatements():
|
|
204
|
+
getAllStatements(): MapIterator<StatementDependencies>;
|
|
205
205
|
getStatementDependencies(statement: ts.Statement): StatementDependencies;
|
|
206
206
|
}
|
|
207
207
|
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) =>
|
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
4
|
import { JAY_COMPONENT, WithValidations, getModeFileExtension, MAKE_JAY_COMPONENT, JAY_SECURE, RuntimeMode, withOriginalTrace, JAY_QUERY_WORKER_TRUSTED, hasExtension, JAY_QUERY_MAIN_SANDBOX, JAY_QUERY_WORKER_SANDBOX, JayUnknown, JAY_EXTENSION, withoutExtension, JAY_TS_EXTENSION, SourceFileFormat, GenerateTarget } from "@jay-framework/compiler-shared";
|
|
8
5
|
import { createRequire } from "module";
|
|
9
6
|
import { capitalCase } from "change-case";
|
|
@@ -104,8 +101,7 @@ function findComponentConstructorsBlock(componentFunctionExpressions, sourceFile
|
|
|
104
101
|
);
|
|
105
102
|
function visit(node) {
|
|
106
103
|
if (isFunctionDeclaration$2(node)) {
|
|
107
|
-
if (namedConstructors.has(node?.name.text))
|
|
108
|
-
foundConstructors.push(node);
|
|
104
|
+
if (namedConstructors.has(node?.name.text)) foundConstructors.push(node);
|
|
109
105
|
} else if (isVariableStatement$3(node)) {
|
|
110
106
|
node.declarationList.declarations.forEach((declaration) => {
|
|
111
107
|
if (isIdentifier$a(declaration.name) && namedConstructors.has(declaration.name.text) && declaration.initializer && isArrowFunction$3(declaration.initializer))
|
|
@@ -211,12 +207,9 @@ const getAccessedByProperty = (binding, accessedFrom, propertyName) => {
|
|
|
211
207
|
return accessedFrom ? propertyName ? isIdentifier$9(propertyName) ? propertyName.text : void 0 : binding.text : void 0;
|
|
212
208
|
};
|
|
213
209
|
function findDeclaringStatement(node) {
|
|
214
|
-
if (!node)
|
|
215
|
-
|
|
216
|
-
else
|
|
217
|
-
return node;
|
|
218
|
-
else
|
|
219
|
-
return findDeclaringStatement(node.parent);
|
|
210
|
+
if (!node) return void 0;
|
|
211
|
+
else if (isStatement$3(node)) return node;
|
|
212
|
+
else return findDeclaringStatement(node.parent);
|
|
220
213
|
}
|
|
221
214
|
function tsBindingNameToVariable(binding, accessedFrom, assignedFrom, propertyName, root) {
|
|
222
215
|
if (isIdentifier$9(binding)) {
|
|
@@ -275,8 +268,7 @@ class NameBindingResolver {
|
|
|
275
268
|
mkParameterVariableRoot(param, paramIndex)
|
|
276
269
|
);
|
|
277
270
|
paramVariables.forEach((variable) => {
|
|
278
|
-
if (variable.name)
|
|
279
|
-
this.variables.set(variable.name, variable);
|
|
271
|
+
if (variable.name) this.variables.set(variable.name, variable);
|
|
280
272
|
});
|
|
281
273
|
});
|
|
282
274
|
}
|
|
@@ -377,8 +369,7 @@ class NameBindingResolver {
|
|
|
377
369
|
let resolved;
|
|
378
370
|
while ((resolved = nameResolver.getVariable(variableName)) === UNKNOWN_VARIABLE && nameResolver.parentNameResolver)
|
|
379
371
|
nameResolver = nameResolver.parentNameResolver;
|
|
380
|
-
if (resolved === UNKNOWN_VARIABLE)
|
|
381
|
-
return { root: mkGlobalVariableRoot(variableName) };
|
|
372
|
+
if (resolved === UNKNOWN_VARIABLE) return { root: mkGlobalVariableRoot(variableName) };
|
|
382
373
|
return resolved;
|
|
383
374
|
}
|
|
384
375
|
addImportDeclaration(node) {
|
|
@@ -429,8 +420,7 @@ class NameBindingResolver {
|
|
|
429
420
|
}
|
|
430
421
|
}
|
|
431
422
|
function flattenVariable(variable, path2 = []) {
|
|
432
|
-
if (variable.assignedFrom)
|
|
433
|
-
return flattenVariable(variable.assignedFrom, path2);
|
|
423
|
+
if (variable.assignedFrom) return flattenVariable(variable.assignedFrom, path2);
|
|
434
424
|
else if (variable.accessedFrom) {
|
|
435
425
|
return flattenVariable(variable.accessedFrom, [variable.accessedByProperty, ...path2]);
|
|
436
426
|
} else if (variable.properties && !!variable.properties.find((_) => _.name === path2[0])) {
|
|
@@ -438,8 +428,7 @@ function flattenVariable(variable, path2 = []) {
|
|
|
438
428
|
variable.properties.find((_) => _.name === path2[0]),
|
|
439
429
|
path2.slice(1)
|
|
440
430
|
);
|
|
441
|
-
} else
|
|
442
|
-
return { path: path2, root: variable.root };
|
|
431
|
+
} else return { path: path2, root: variable.root };
|
|
443
432
|
}
|
|
444
433
|
const { isIdentifier: isIdentifier$8, isPropertyAccessExpression: isPropertyAccessExpression$4 } = c;
|
|
445
434
|
function isIdentifierOrPropertyAccessExpression(node) {
|
|
@@ -564,12 +553,8 @@ class UnionResolvedType {
|
|
|
564
553
|
if (rightSide instanceof UnionResolvedType) {
|
|
565
554
|
for (const item1 of this.types)
|
|
566
555
|
for (const item2 of rightSide.types)
|
|
567
|
-
if (item1.canBeAssignedFrom(item2))
|
|
568
|
-
|
|
569
|
-
} else
|
|
570
|
-
for (const item1 of this.types)
|
|
571
|
-
if (item1.canBeAssignedFrom(rightSide))
|
|
572
|
-
return true;
|
|
556
|
+
if (item1.canBeAssignedFrom(item2)) return true;
|
|
557
|
+
} else for (const item1 of this.types) if (item1.canBeAssignedFrom(rightSide)) return true;
|
|
573
558
|
return false;
|
|
574
559
|
}
|
|
575
560
|
}
|
|
@@ -605,15 +590,11 @@ class SourceFileBindingResolver {
|
|
|
605
590
|
return node;
|
|
606
591
|
};
|
|
607
592
|
const visitor = (node) => {
|
|
608
|
-
if (isFunctionDeclaration$1(node))
|
|
609
|
-
|
|
610
|
-
if (
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
nbResolversQueue[0].addImportDeclaration(node);
|
|
614
|
-
else if (isBlock$2(node))
|
|
615
|
-
return doWithChildBindingResolver(node, () => {
|
|
616
|
-
});
|
|
593
|
+
if (isFunctionDeclaration$1(node)) nbResolversQueue[0].addFunctionDeclaration(node);
|
|
594
|
+
if (isVariableStatement$2(node)) nbResolversQueue[0].addVariableStatement(node);
|
|
595
|
+
else if (isImportDeclaration$3(node)) nbResolversQueue[0].addImportDeclaration(node);
|
|
596
|
+
else if (isBlock$2(node)) return doWithChildBindingResolver(node, () => {
|
|
597
|
+
});
|
|
617
598
|
else if (isFunctionLikeDeclarationBase(node)) {
|
|
618
599
|
return doWithChildBindingResolver(
|
|
619
600
|
node,
|
|
@@ -646,8 +627,7 @@ class SourceFileBindingResolver {
|
|
|
646
627
|
}
|
|
647
628
|
findBindingResolver(node) {
|
|
648
629
|
let found;
|
|
649
|
-
while (!(found = this.nameBindingResolvers.get(node)) && node.parent)
|
|
650
|
-
node = node.parent;
|
|
630
|
+
while (!(found = this.nameBindingResolvers.get(node)) && node.parent) node = node.parent;
|
|
651
631
|
return found;
|
|
652
632
|
}
|
|
653
633
|
explain(identifier) {
|
|
@@ -658,8 +638,7 @@ class SourceFileBindingResolver {
|
|
|
658
638
|
if (isImportModuleVariableRoot(flattened.root) && isStringLiteral$7(flattened.root.module)) {
|
|
659
639
|
return new ImportFromModuleResolvedType(flattened.root.module.text, flattened.path);
|
|
660
640
|
}
|
|
661
|
-
} else
|
|
662
|
-
return void 0;
|
|
641
|
+
} else return void 0;
|
|
663
642
|
}
|
|
664
643
|
explainType(type) {
|
|
665
644
|
if (type) {
|
|
@@ -669,10 +648,8 @@ class SourceFileBindingResolver {
|
|
|
669
648
|
let resolved = this.findBindingResolver(typeName).resolveIdentifier(typeName);
|
|
670
649
|
let flattened = flattenVariable(resolved);
|
|
671
650
|
let typeFromFlattened = this.explainFlattenedVariableType(flattened);
|
|
672
|
-
if (typeFromFlattened)
|
|
673
|
-
|
|
674
|
-
if (builtInType(typeName.text))
|
|
675
|
-
return new BuiltInResolvedType(typeName.text);
|
|
651
|
+
if (typeFromFlattened) return typeFromFlattened;
|
|
652
|
+
if (builtInType(typeName.text)) return new BuiltInResolvedType(typeName.text);
|
|
676
653
|
}
|
|
677
654
|
} else if (type.kind === SyntaxKind$4.StringKeyword)
|
|
678
655
|
return new BuiltInResolvedType("string");
|
|
@@ -680,10 +657,8 @@ class SourceFileBindingResolver {
|
|
|
680
657
|
return new BuiltInResolvedType("number");
|
|
681
658
|
else if (type.kind === SyntaxKind$4.BooleanKeyword)
|
|
682
659
|
return new BuiltInResolvedType("boolean");
|
|
683
|
-
else if (type.kind === SyntaxKind$4.AnyKeyword)
|
|
684
|
-
|
|
685
|
-
else if (type.kind === SyntaxKind$4.VoidKeyword)
|
|
686
|
-
return new BuiltInResolvedType("void");
|
|
660
|
+
else if (type.kind === SyntaxKind$4.AnyKeyword) return new BuiltInResolvedType("any");
|
|
661
|
+
else if (type.kind === SyntaxKind$4.VoidKeyword) return new BuiltInResolvedType("void");
|
|
687
662
|
else if (isArrayTypeNode(type))
|
|
688
663
|
return new ArrayResolvedType(this.explainType(type.elementType));
|
|
689
664
|
else if (isFunctionTypeNode(type)) {
|
|
@@ -728,8 +703,7 @@ var CompilePatternType = /* @__PURE__ */ ((CompilePatternType2) => {
|
|
|
728
703
|
return CompilePatternType2;
|
|
729
704
|
})(CompilePatternType || {});
|
|
730
705
|
function areCompatiblePatternTypes(type1, type2) {
|
|
731
|
-
if (type1 === type2)
|
|
732
|
-
return true;
|
|
706
|
+
if (type1 === type2) return true;
|
|
733
707
|
if (type1 === 1 && type2 === 2)
|
|
734
708
|
return true;
|
|
735
709
|
return type1 === 2 && type2 === 1;
|
|
@@ -744,12 +718,10 @@ var JayTargetEnv = /* @__PURE__ */ ((JayTargetEnv2) => {
|
|
|
744
718
|
return JayTargetEnv2;
|
|
745
719
|
})(JayTargetEnv || {});
|
|
746
720
|
function intersectJayTargetEnv(a, b) {
|
|
747
|
-
if (a === b && a === 1)
|
|
748
|
-
return 1;
|
|
721
|
+
if (a === b && a === 1) return 1;
|
|
749
722
|
if (a === 0 && b === 0 || a === 0 && b === 1 || a === 1 && b === 0)
|
|
750
723
|
return 0;
|
|
751
|
-
else
|
|
752
|
-
return 2;
|
|
724
|
+
else return 2;
|
|
753
725
|
}
|
|
754
726
|
function extractArgumentType(argument, sourceFileBinding, node) {
|
|
755
727
|
if (isIdentifierOrPropertyAccessExpression(argument)) {
|
|
@@ -876,19 +848,15 @@ function visitWithContext(node, initialContext, contextualVisitor) {
|
|
|
876
848
|
function visitWithContext2(node, initialContext, transformationContext, contextualVisitor) {
|
|
877
849
|
let contexts = [initialContext];
|
|
878
850
|
const visitChild = (node2, childContext) => {
|
|
879
|
-
if (childContext)
|
|
880
|
-
contexts.push(childContext);
|
|
851
|
+
if (childContext) contexts.push(childContext);
|
|
881
852
|
let visitedNode = visitNode$3(node2, visitor);
|
|
882
|
-
if (childContext)
|
|
883
|
-
contexts.pop();
|
|
853
|
+
if (childContext) contexts.pop();
|
|
884
854
|
return visitedNode;
|
|
885
855
|
};
|
|
886
856
|
const _visitEachChild = (node2, childContext) => {
|
|
887
|
-
if (childContext)
|
|
888
|
-
contexts.push(childContext);
|
|
857
|
+
if (childContext) contexts.push(childContext);
|
|
889
858
|
let visitedNode = visitEachChild$3(node2, visitor, transformationContext);
|
|
890
|
-
if (childContext)
|
|
891
|
-
contexts.pop();
|
|
859
|
+
if (childContext) contexts.pop();
|
|
892
860
|
return visitedNode;
|
|
893
861
|
};
|
|
894
862
|
const visitor = (node2) => {
|
|
@@ -946,8 +914,7 @@ ${returnedObjectProperties.length > 0 ? ` return ({${returnedObjectProperties}})
|
|
|
946
914
|
if (matchedReturnPatterns.length > 0) {
|
|
947
915
|
let handlerCode = `({ event }: JayEvent<any, any>) => ({${returnedObjectProperties}})`;
|
|
948
916
|
return { handlerCode, key: constCode };
|
|
949
|
-
} else
|
|
950
|
-
return { key: void 0, handlerCode: void 0 };
|
|
917
|
+
} else return { key: void 0, handlerCode: void 0 };
|
|
951
918
|
}
|
|
952
919
|
const mkTransformEventHandlerStatementVisitor = (factory, context, bindingResolver, analyzer) => {
|
|
953
920
|
let sideEffects = {
|
|
@@ -1016,8 +983,7 @@ const mkTransformEventHandlerStatementVisitor = (factory, context, bindingResolv
|
|
|
1016
983
|
sideEffects.matchedConstants.push(`const ${node.text} = ${constantValue}`);
|
|
1017
984
|
}
|
|
1018
985
|
return node;
|
|
1019
|
-
} else
|
|
1020
|
-
return node;
|
|
986
|
+
} else return node;
|
|
1021
987
|
let replacementPattern = `event.$${patternKey}`;
|
|
1022
988
|
sideEffects.wasEventHandlerTransformed = true;
|
|
1023
989
|
return codeToAst(replacementPattern, context)[0].expression;
|
|
@@ -1229,8 +1195,7 @@ class ScopedSourceFileStatementAnalyzer {
|
|
|
1229
1195
|
targetEnv: JayTargetEnv.sandbox,
|
|
1230
1196
|
matchedPatterns: []
|
|
1231
1197
|
});
|
|
1232
|
-
} else
|
|
1233
|
-
this.analyzedStatements.get(statement).targetEnv = JayTargetEnv.sandbox;
|
|
1198
|
+
} else this.analyzedStatements.get(statement).targetEnv = JayTargetEnv.sandbox;
|
|
1234
1199
|
}
|
|
1235
1200
|
analyze(analysisScope) {
|
|
1236
1201
|
let RoleInParent;
|
|
@@ -1283,8 +1248,7 @@ class ScopedSourceFileStatementAnalyzer {
|
|
|
1283
1248
|
isScopedVariableAccess = isParamVariableRoot(flattened.root) && isChildOf(flattened.root.param, analysisScope);
|
|
1284
1249
|
}
|
|
1285
1250
|
const paramMatching = patternTypeMatchArgumentType || isLiteral || isScopedVariableAccess;
|
|
1286
|
-
if (!paramMatching)
|
|
1287
|
-
this.markStatementSandbox(statement);
|
|
1251
|
+
if (!paramMatching) this.markStatementSandbox(statement);
|
|
1288
1252
|
return paramMatching;
|
|
1289
1253
|
};
|
|
1290
1254
|
const analyzeCallOrNewExpression = (node, visitChild, statement, roleInParent) => {
|
|
@@ -1317,8 +1281,7 @@ class ScopedSourceFileStatementAnalyzer {
|
|
|
1317
1281
|
});
|
|
1318
1282
|
this.markStatementSandbox(statement);
|
|
1319
1283
|
}
|
|
1320
|
-
} else
|
|
1321
|
-
this.markStatementSandbox(statement);
|
|
1284
|
+
} else this.markStatementSandbox(statement);
|
|
1322
1285
|
};
|
|
1323
1286
|
visitWithContext(
|
|
1324
1287
|
this.sourceFile,
|
|
@@ -1327,8 +1290,7 @@ class ScopedSourceFileStatementAnalyzer {
|
|
|
1327
1290
|
/* none */
|
|
1328
1291
|
},
|
|
1329
1292
|
(node, { statement, roleInParent }, visitChild) => {
|
|
1330
|
-
if (isStatement$1(node))
|
|
1331
|
-
statement = node;
|
|
1293
|
+
if (isStatement$1(node)) statement = node;
|
|
1332
1294
|
if (roleInParent === 1 || roleInParent === 2) {
|
|
1333
1295
|
if (isIdentifierOrPropertyAccessExpression(node))
|
|
1334
1296
|
analyzePropertyExpression(node, visitChild, statement, roleInParent);
|
|
@@ -1496,12 +1458,11 @@ class ScopedSourceFileStatementAnalyzer {
|
|
|
1496
1458
|
matchType: 0
|
|
1497
1459
|
/* FULL */
|
|
1498
1460
|
};
|
|
1499
|
-
else
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
};
|
|
1461
|
+
else return {
|
|
1462
|
+
matchedPatterns: [],
|
|
1463
|
+
matchType: 2
|
|
1464
|
+
/* NONE */
|
|
1465
|
+
};
|
|
1505
1466
|
}
|
|
1506
1467
|
if (currentVariableType) {
|
|
1507
1468
|
let currentPosition = 0;
|
|
@@ -1578,13 +1539,9 @@ class ScopedSourceFileStatementAnalyzer {
|
|
|
1578
1539
|
}
|
|
1579
1540
|
}
|
|
1580
1541
|
function isChildOf(node, parent) {
|
|
1581
|
-
if (node === parent)
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
return false;
|
|
1585
|
-
for (const sibling of node.parent.getChildren())
|
|
1586
|
-
if (sibling === node)
|
|
1587
|
-
return true;
|
|
1542
|
+
if (node === parent) return false;
|
|
1543
|
+
if (!node.parent) return false;
|
|
1544
|
+
for (const sibling of node.parent.getChildren()) if (sibling === node) return true;
|
|
1588
1545
|
return isChildOf(node.parent, parent);
|
|
1589
1546
|
}
|
|
1590
1547
|
const { isCallExpression: isCallExpression$1, isIdentifier: isIdentifier$2, isStringLiteral: isStringLiteral$6, isVariableStatement, forEachChild: forEachChild$1 } = c;
|
|
@@ -1648,15 +1605,13 @@ class FunctionRepositoryBuilder {
|
|
|
1648
1605
|
__publicField(this, "nextIndex", 0);
|
|
1649
1606
|
}
|
|
1650
1607
|
addFunction(handlerCode) {
|
|
1651
|
-
if (!handlerCode)
|
|
1652
|
-
return void 0;
|
|
1608
|
+
if (!handlerCode) return void 0;
|
|
1653
1609
|
const key = `${this.nextIndex++}`;
|
|
1654
1610
|
this.fragments.push({ key, handlerCode });
|
|
1655
1611
|
return key;
|
|
1656
1612
|
}
|
|
1657
1613
|
addConst(constCode) {
|
|
1658
|
-
if (!constCode)
|
|
1659
|
-
return;
|
|
1614
|
+
if (!constCode) return;
|
|
1660
1615
|
this.consts.push(constCode);
|
|
1661
1616
|
}
|
|
1662
1617
|
generate() {
|
|
@@ -1712,10 +1667,8 @@ function analyzeGlobalExec$(context, analyzer, functionRepositoryBuilder, foundE
|
|
|
1712
1667
|
}
|
|
1713
1668
|
return node;
|
|
1714
1669
|
};
|
|
1715
|
-
if (isArrowFunction(foundExec$.arguments[0]))
|
|
1716
|
-
|
|
1717
|
-
if (foundUnsafeExpression)
|
|
1718
|
-
return { foundExec$, wasTransformed: false };
|
|
1670
|
+
if (isArrowFunction(foundExec$.arguments[0])) visitNode$1(foundExec$.arguments[0].body, visitor);
|
|
1671
|
+
if (foundUnsafeExpression) return { foundExec$, wasTransformed: false };
|
|
1719
1672
|
else {
|
|
1720
1673
|
const key = functionRepositoryBuilder.addFunction(astToCode(foundExec$.arguments[0]));
|
|
1721
1674
|
const transformedExec$ = codeToAst(`exec$(funcGlobal$('${key}'))`, context).map(
|
|
@@ -1745,8 +1698,7 @@ function generateComponentConstructorCalls(context, componentConstructorCalls, h
|
|
|
1745
1698
|
if (transformedConstructors.length > 0) {
|
|
1746
1699
|
let declarationCode = `export const ${transformedConstructors.join(", ")}`;
|
|
1747
1700
|
return codeToAst(declarationCode, context)[0];
|
|
1748
|
-
} else
|
|
1749
|
-
return void 0;
|
|
1701
|
+
} else return void 0;
|
|
1750
1702
|
}
|
|
1751
1703
|
function getRenderImportSpecifier(node) {
|
|
1752
1704
|
const namedBindings = node.importClause?.namedBindings;
|
|
@@ -1775,10 +1727,8 @@ function transformImport(node, importerMode, context, hasFunctionRepository) {
|
|
|
1775
1727
|
context
|
|
1776
1728
|
)[0];
|
|
1777
1729
|
}
|
|
1778
|
-
if (node.moduleSpecifier.text === "@jay-framework/runtime")
|
|
1779
|
-
|
|
1780
|
-
if (node.moduleSpecifier.text.endsWith(".css") && !node.importClause)
|
|
1781
|
-
return node;
|
|
1730
|
+
if (node.moduleSpecifier.text === "@jay-framework/runtime") return node;
|
|
1731
|
+
if (node.moduleSpecifier.text.endsWith(".css") && !node.importClause) return node;
|
|
1782
1732
|
return void 0;
|
|
1783
1733
|
}
|
|
1784
1734
|
return void 0;
|
|
@@ -1791,12 +1741,10 @@ function transformSourceFile(sourceFile, factory, context, importerMode, compone
|
|
|
1791
1741
|
hasFunctionRepository
|
|
1792
1742
|
);
|
|
1793
1743
|
let transformedStatements = sourceFile.statements.map((statement) => {
|
|
1794
|
-
if (isInterfaceDeclaration(statement))
|
|
1795
|
-
return statement;
|
|
1744
|
+
if (isInterfaceDeclaration(statement)) return statement;
|
|
1796
1745
|
else if (isImportDeclaration$2(statement))
|
|
1797
1746
|
return transformImport(statement, importerMode, context, hasFunctionRepository);
|
|
1798
|
-
else
|
|
1799
|
-
return void 0;
|
|
1747
|
+
else return void 0;
|
|
1800
1748
|
}).filter((_) => !!_);
|
|
1801
1749
|
const funcRepositoryStatements = hasFunctionRepository ? codeToAst(functionRepository, context) : [];
|
|
1802
1750
|
let allStatements = [
|
|
@@ -1859,11 +1807,9 @@ function transformComponentBridge(importerMode, patterns = [], globalFunctionRep
|
|
|
1859
1807
|
}
|
|
1860
1808
|
const { isStringLiteral: isStringLiteral$3 } = c;
|
|
1861
1809
|
function transformImportModeFileExtension(node, factory, importerMode) {
|
|
1862
|
-
if (!isStringLiteral$3(node.moduleSpecifier))
|
|
1863
|
-
return void 0;
|
|
1810
|
+
if (!isStringLiteral$3(node.moduleSpecifier)) return void 0;
|
|
1864
1811
|
const originalTarget = node.moduleSpecifier.text;
|
|
1865
|
-
if (!isRelativeImport(originalTarget))
|
|
1866
|
-
return node;
|
|
1812
|
+
if (!isRelativeImport(originalTarget)) return node;
|
|
1867
1813
|
return factory.updateImportDeclaration(
|
|
1868
1814
|
node,
|
|
1869
1815
|
node.modifiers,
|
|
@@ -1875,8 +1821,7 @@ function transformImportModeFileExtension(node, factory, importerMode) {
|
|
|
1875
1821
|
const { isImportDeclaration: isImportDeclaration$1 } = c;
|
|
1876
1822
|
function findAfterImportStatementIndex(statements) {
|
|
1877
1823
|
let lastIndex = 0;
|
|
1878
|
-
while (isImportDeclaration$1(statements[lastIndex]))
|
|
1879
|
-
lastIndex += 1;
|
|
1824
|
+
while (isImportDeclaration$1(statements[lastIndex])) lastIndex += 1;
|
|
1880
1825
|
return lastIndex;
|
|
1881
1826
|
}
|
|
1882
1827
|
function transformComponentImports(needsHandler$, needsFunc$, needsFuncGlobal$, transformedSourceFile, context, factory, sourceFile) {
|
|
@@ -1897,8 +1842,7 @@ function transformComponentImports(needsHandler$, needsFunc$, needsFuncGlobal$,
|
|
|
1897
1842
|
...statements.slice(afterImportStatementIndex)
|
|
1898
1843
|
];
|
|
1899
1844
|
return factory.updateSourceFile(sourceFile, allStatements);
|
|
1900
|
-
} else
|
|
1901
|
-
return transformedSourceFile;
|
|
1845
|
+
} else return transformedSourceFile;
|
|
1902
1846
|
}
|
|
1903
1847
|
const { visitEachChild, transform, isStringLiteral: isStringLiteral$2, isImportDeclaration } = c;
|
|
1904
1848
|
function isCssImport(node) {
|
|
@@ -1950,10 +1894,8 @@ function mkComponentTransformer(sftContext) {
|
|
|
1950
1894
|
return visitEachChild(node, visitor, context);
|
|
1951
1895
|
}
|
|
1952
1896
|
if (isImportDeclaration(node)) {
|
|
1953
|
-
if (isCssImport(node))
|
|
1954
|
-
|
|
1955
|
-
else
|
|
1956
|
-
return transformImportModeFileExtension(node, factory, RuntimeMode.WorkerSandbox);
|
|
1897
|
+
if (isCssImport(node)) return void 0;
|
|
1898
|
+
else return transformImportModeFileExtension(node, factory, RuntimeMode.WorkerSandbox);
|
|
1957
1899
|
}
|
|
1958
1900
|
return visitEachChild(node, visitor, context);
|
|
1959
1901
|
};
|
|
@@ -2064,8 +2006,7 @@ class SourceFileStatementDependencies {
|
|
|
2064
2006
|
}
|
|
2065
2007
|
}
|
|
2066
2008
|
node.getChildren().forEach((child) => visitNode(child, visitor));
|
|
2067
|
-
if (isStatement(node))
|
|
2068
|
-
parents.pop();
|
|
2009
|
+
if (isStatement(node)) parents.pop();
|
|
2069
2010
|
return node;
|
|
2070
2011
|
};
|
|
2071
2012
|
visitNode(sourceFile, visitor);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jay-framework/compiler",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
},
|
|
26
26
|
"author": "",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@jay-framework/compiler-analyze-exported-types": "^0.23.
|
|
29
|
-
"@jay-framework/compiler-jay-html": "^0.23.
|
|
30
|
-
"@jay-framework/compiler-shared": "^0.23.
|
|
31
|
-
"@jay-framework/component": "^0.23.
|
|
32
|
-
"@jay-framework/runtime": "^0.23.
|
|
33
|
-
"@jay-framework/secure": "^0.23.
|
|
28
|
+
"@jay-framework/compiler-analyze-exported-types": "^0.23.1",
|
|
29
|
+
"@jay-framework/compiler-jay-html": "^0.23.1",
|
|
30
|
+
"@jay-framework/compiler-shared": "^0.23.1",
|
|
31
|
+
"@jay-framework/component": "^0.23.1",
|
|
32
|
+
"@jay-framework/runtime": "^0.23.1",
|
|
33
|
+
"@jay-framework/secure": "^0.23.1",
|
|
34
34
|
"@types/js-yaml": "^4.0.9",
|
|
35
35
|
"change-case": "^4.1.2",
|
|
36
36
|
"js-yaml": "^4.1.0",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@caiogondim/strip-margin": "^1.0.0",
|
|
44
|
-
"@jay-framework/dev-environment": "^0.23.
|
|
44
|
+
"@jay-framework/dev-environment": "^0.23.1",
|
|
45
45
|
"@testing-library/jest-dom": "^6.2.0",
|
|
46
46
|
"@types/js-beautify": "^1",
|
|
47
47
|
"@types/node": "^20.11.5",
|