@jay-framework/compiler 0.6.10 → 0.8.0

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.
Files changed (2) hide show
  1. package/dist/index.js +119 -148
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -10,24 +10,27 @@ import { capitalCase } from "change-case";
10
10
  import path from "node:path";
11
11
  import { generateElementFile as generateElementFile$1, generateElementFileReactTarget } from "@jay-framework/compiler-jay-html";
12
12
  import { generateElementDefinitionFile } from "@jay-framework/compiler-jay-html";
13
- const require$n = createRequire(import.meta.url);
14
- const tsModule$m = require$n("typescript");
13
+ const s = createRequire(import.meta.url), e = s("typescript"), c = new Proxy(e, {
14
+ get(t, r) {
15
+ return t[r];
16
+ }
17
+ });
15
18
  const {
19
+ visitEachChild: visitEachChild$5,
16
20
  isArrowFunction: isArrowFunction$4,
17
- isConstructorDeclaration,
18
- isFunctionDeclaration: isFunctionDeclaration$3,
19
21
  isFunctionExpression: isFunctionExpression$1,
20
- isGetAccessorDeclaration,
22
+ createSourceFile: createSourceFile$1,
23
+ ScriptTarget: ScriptTarget$1,
24
+ isFunctionDeclaration: isFunctionDeclaration$3,
21
25
  isMethodDeclaration,
26
+ isConstructorDeclaration,
27
+ isGetAccessorDeclaration,
22
28
  isSetAccessorDeclaration,
23
29
  createPrinter,
30
+ NewLineKind,
24
31
  EmitHint,
25
- createSourceFile: createSourceFile$1,
26
- ScriptTarget: ScriptTarget$1,
27
- setTextRange,
28
- visitEachChild: visitEachChild$5,
29
- NewLineKind
30
- } = tsModule$m;
32
+ setTextRange
33
+ } = c;
31
34
  const printer = createPrinter({
32
35
  newLine: NewLineKind.LineFeed
33
36
  });
@@ -45,8 +48,6 @@ function codeToAst(code, context) {
45
48
  function isFunctionLikeDeclarationBase(node) {
46
49
  return isFunctionExpression$1(node) || isArrowFunction$4(node) || isFunctionDeclaration$3(node) || isMethodDeclaration(node) || isConstructorDeclaration(node) || isGetAccessorDeclaration(node) || isSetAccessorDeclaration(node);
47
50
  }
48
- const require$m = createRequire(import.meta.url);
49
- require$m("typescript");
50
51
  function mkTransformer(fileTransformer, config) {
51
52
  return (context) => {
52
53
  const { factory } = context;
@@ -55,9 +56,7 @@ function mkTransformer(fileTransformer, config) {
55
56
  };
56
57
  };
57
58
  }
58
- const require$l = createRequire(import.meta.url);
59
- const tsModule$l = require$l("typescript");
60
- const { forEachChild: forEachChild$4, isImportDeclaration: isImportDeclaration$5, isNamedImports: isNamedImports$1, isStringLiteral: isStringLiteral$9 } = tsModule$l;
59
+ const { isStringLiteral: isStringLiteral$9, isImportDeclaration: isImportDeclaration$5, forEachChild: forEachChild$4, isNamedImports: isNamedImports$1 } = c;
61
60
  function extractImportDeclarations(sourceFile) {
62
61
  const importDeclarations = [];
63
62
  function visit(node) {
@@ -82,9 +81,7 @@ function getImportSpecifiers(importDeclaration) {
82
81
  function getImportName(importSpecifier) {
83
82
  return importSpecifier.propertyName?.text ?? importSpecifier.name.text;
84
83
  }
85
- const require$k = createRequire(import.meta.url);
86
- const tsModule$k = require$k("typescript");
87
- const { forEachChild: forEachChild$3, isImportDeclaration: isImportDeclaration$4, isStringLiteral: isStringLiteral$8 } = tsModule$k;
84
+ const { isStringLiteral: isStringLiteral$8, forEachChild: forEachChild$3, isImportDeclaration: isImportDeclaration$4 } = c;
88
85
  function findMakeJayComponentImport(makeJayComponentName, node) {
89
86
  if (isImportDeclaration$4(node) && isStringLiteral$8(node.moduleSpecifier) && node.moduleSpecifier.text === JAY_COMPONENT) {
90
87
  let importSpecifier = getImportSpecifiers(node)?.find(
@@ -96,13 +93,11 @@ function findMakeJayComponentImport(makeJayComponentName, node) {
96
93
  }
97
94
  return void 0;
98
95
  }
99
- const require$j = createRequire(import.meta.url);
100
- const tsModule$j = require$j("typescript");
101
- const { forEachChild: forEachChild$2, isArrowFunction: isArrowFunction$3, isFunctionDeclaration: isFunctionDeclaration$2, isIdentifier: isIdentifier$7, isVariableStatement: isVariableStatement$3 } = tsModule$j;
96
+ const { isIdentifier: isIdentifier$9, isArrowFunction: isArrowFunction$3, isFunctionDeclaration: isFunctionDeclaration$2, isVariableStatement: isVariableStatement$3, forEachChild: forEachChild$2 } = c;
102
97
  function findComponentConstructorsBlock(componentFunctionExpressions, sourceFile) {
103
98
  const foundConstructors = [];
104
99
  const namedConstructors = new Set(
105
- componentFunctionExpressions.filter((expression) => isIdentifier$7(expression)).map((expression) => isIdentifier$7(expression) && expression.text)
100
+ componentFunctionExpressions.filter((expression) => isIdentifier$9(expression)).map((expression) => isIdentifier$9(expression) && expression.text)
106
101
  );
107
102
  const inlineConstructors = componentFunctionExpressions.filter(
108
103
  isFunctionLikeDeclarationBase
@@ -113,7 +108,7 @@ function findComponentConstructorsBlock(componentFunctionExpressions, sourceFile
113
108
  foundConstructors.push(node);
114
109
  } else if (isVariableStatement$3(node)) {
115
110
  node.declarationList.declarations.forEach((declaration) => {
116
- if (isIdentifier$7(declaration.name) && namedConstructors.has(declaration.name.text) && declaration.initializer && isArrowFunction$3(declaration.initializer))
111
+ if (isIdentifier$9(declaration.name) && namedConstructors.has(declaration.name.text) && declaration.initializer && isArrowFunction$3(declaration.initializer))
117
112
  foundConstructors.push(declaration.initializer);
118
113
  });
119
114
  }
@@ -122,32 +117,30 @@ function findComponentConstructorsBlock(componentFunctionExpressions, sourceFile
122
117
  forEachChild$2(sourceFile, visit);
123
118
  return [...foundConstructors, ...inlineConstructors];
124
119
  }
125
- const require$i = createRequire(import.meta.url);
126
- const tsModule$i = require$i("typescript");
127
120
  const {
128
- isElementAccessExpression: isElementAccessExpression$1,
129
- isIdentifier: isIdentifier$6,
121
+ isIdentifier: isIdentifier$8,
122
+ isStatement: isStatement$2,
130
123
  isObjectBindingPattern,
131
- isPropertyAccessExpression: isPropertyAccessExpression$5,
132
- isStringLiteral: isStringLiteral$7,
133
- isObjectLiteralExpression,
134
- isPropertyAssignment,
135
- isShorthandPropertyAssignment,
136
124
  isArrayBindingPattern,
137
125
  isBindingElement,
126
+ isPropertyAccessExpression: isPropertyAccessExpression$5,
127
+ isElementAccessExpression: isElementAccessExpression$1,
128
+ isStringLiteral: isStringLiteral$7,
138
129
  isParenthesizedExpression,
139
130
  isAsExpression,
140
- isArrowFunction: isArrowFunction$2,
141
- isFunctionExpression,
142
- isStatement: isStatement$2,
131
+ isObjectLiteralExpression,
132
+ isPropertyAssignment: isPropertyAssignment$1,
133
+ isShorthandPropertyAssignment,
134
+ isNumericLiteral,
135
+ isToken,
143
136
  isNamespaceImport,
144
137
  isNamedImports,
138
+ isArrowFunction: isArrowFunction$2,
139
+ isFunctionExpression,
145
140
  isCallExpression: isCallExpression$6,
146
- isNumericLiteral,
147
- isToken,
148
- SyntaxKind: SyntaxKind$5,
149
- NodeFlags
150
- } = tsModule$i;
141
+ NodeFlags,
142
+ SyntaxKind: SyntaxKind$5
143
+ } = c;
151
144
  function mkParameterVariableRoot(param, paramIndex) {
152
145
  return { kind: 0, param, paramIndex };
153
146
  }
@@ -197,7 +190,7 @@ function mkVariable(members) {
197
190
  }
198
191
  const UNKNOWN_VARIABLE = {};
199
192
  const getAccessedByProperty = (binding, accessedFrom, propertyName) => {
200
- return accessedFrom ? propertyName ? isIdentifier$6(propertyName) ? propertyName.text : void 0 : binding.text : void 0;
193
+ return accessedFrom ? propertyName ? isIdentifier$8(propertyName) ? propertyName.text : void 0 : binding.text : void 0;
201
194
  };
202
195
  function findDeclaringStatement(node) {
203
196
  if (!node)
@@ -208,7 +201,7 @@ function findDeclaringStatement(node) {
208
201
  return findDeclaringStatement(node.parent);
209
202
  }
210
203
  function tsBindingNameToVariable(binding, accessedFrom, assignedFrom, propertyName, root) {
211
- if (isIdentifier$6(binding)) {
204
+ if (isIdentifier$8(binding)) {
212
205
  return [
213
206
  mkVariable({
214
207
  name: binding.text,
@@ -222,7 +215,7 @@ function tsBindingNameToVariable(binding, accessedFrom, assignedFrom, propertyNa
222
215
  } else if (isObjectBindingPattern(binding)) {
223
216
  let variable = mkVariable({
224
217
  accessedFrom,
225
- accessedByProperty: propertyName ? isIdentifier$6(propertyName) ? propertyName.text : void 0 : void 0,
218
+ accessedByProperty: propertyName ? isIdentifier$8(propertyName) ? propertyName.text : void 0 : void 0,
226
219
  assignedFrom,
227
220
  root,
228
221
  definingStatement: findDeclaringStatement(binding)
@@ -233,7 +226,7 @@ function tsBindingNameToVariable(binding, accessedFrom, assignedFrom, propertyNa
233
226
  } else if (isArrayBindingPattern(binding)) {
234
227
  let variable = mkVariable({
235
228
  accessedFrom,
236
- accessedByProperty: propertyName ? isIdentifier$6(propertyName) ? propertyName.text : void 0 : void 0,
229
+ accessedByProperty: propertyName ? isIdentifier$8(propertyName) ? propertyName.text : void 0 : void 0,
237
230
  assignedFrom,
238
231
  root,
239
232
  definingStatement: findDeclaringStatement(binding)
@@ -309,7 +302,7 @@ class NameBindingResolver {
309
302
  const name = expression.argumentExpression.text;
310
303
  const identifiersFromObject = this.resolvePropertyAccessChain(expression.expression);
311
304
  return { accessedFrom: identifiersFromObject, accessedByProperty: name };
312
- } else if (isIdentifier$6(expression)) {
305
+ } else if (isIdentifier$8(expression)) {
313
306
  return this.resolveIdentifier(expression);
314
307
  } else if (isParenthesizedExpression(expression)) {
315
308
  return this.resolvePropertyAccessChain(expression.expression);
@@ -318,8 +311,8 @@ class NameBindingResolver {
318
311
  } else if (isObjectLiteralExpression(expression)) {
319
312
  return {
320
313
  properties: expression.properties.map((property) => {
321
- if (isPropertyAssignment(property) && (isStringLiteral$7(property.name) || isIdentifier$6(property.name))) {
322
- if (isIdentifier$6(property.initializer))
314
+ if (isPropertyAssignment$1(property) && (isStringLiteral$7(property.name) || isIdentifier$8(property.name))) {
315
+ if (isIdentifier$8(property.initializer))
323
316
  return {
324
317
  name: property.name.text,
325
318
  assignedFrom: this.resolveIdentifier(property.initializer)
@@ -430,24 +423,20 @@ function flattenVariable(variable, path2 = []) {
430
423
  } else
431
424
  return { path: path2, root: variable.root };
432
425
  }
433
- const require$h = createRequire(import.meta.url);
434
- const tsModule$h = require$h("typescript");
435
- const { isIdentifier: isIdentifier$5, isPropertyAccessExpression: isPropertyAccessExpression$4 } = tsModule$h;
426
+ const { isIdentifier: isIdentifier$7, isPropertyAccessExpression: isPropertyAccessExpression$4 } = c;
436
427
  function isIdentifierOrPropertyAccessExpression(node) {
437
- return isIdentifier$5(node) || isPropertyAccessExpression$4(node);
428
+ return isIdentifier$7(node) || isPropertyAccessExpression$4(node);
438
429
  }
439
430
  function byAnd() {
440
431
  return (agg, value) => agg && value;
441
432
  }
442
- const require$g = createRequire(import.meta.url);
443
- const tsModule$g = require$g("typescript");
444
433
  const {
445
- isBlock: isBlock$3,
446
434
  isCallExpression: isCallExpression$5,
447
435
  isExpressionStatement: isExpressionStatement$1,
448
- isIdentifier: isIdentifier$4,
449
- isPropertyAccessExpression: isPropertyAccessExpression$3
450
- } = tsModule$g;
436
+ isIdentifier: isIdentifier$6,
437
+ isPropertyAccessExpression: isPropertyAccessExpression$3,
438
+ isBlock: isBlock$3
439
+ } = c;
451
440
  function findEventHandlersBlock(functionDeclaration, bindingResolver) {
452
441
  const foundEventHandlers = [];
453
442
  const foundEventHandlerFunctionsToHandlerIndex = /* @__PURE__ */ new Map();
@@ -466,7 +455,7 @@ function findEventHandlersBlock(functionDeclaration, bindingResolver) {
466
455
  eventHandlerCallStatement: statement,
467
456
  handlerIndex: nextEventHandlerIndex++
468
457
  });
469
- else if (isIdentifier$4(handler) || isPropertyAccessExpression$3(handler)) {
458
+ else if (isIdentifier$6(handler) || isPropertyAccessExpression$3(handler)) {
470
459
  let flattenedHandler = flattenVariable(
471
460
  bindingResolver.explain(handler)
472
461
  );
@@ -486,26 +475,24 @@ function findEventHandlersBlock(functionDeclaration, bindingResolver) {
486
475
  }
487
476
  return foundEventHandlers;
488
477
  }
489
- const require$f = createRequire(import.meta.url);
490
- const tsModule$f = require$f("typescript");
491
478
  const {
479
+ isIdentifier: isIdentifier$5,
480
+ SyntaxKind: SyntaxKind$4,
481
+ isStringLiteral: isStringLiteral$6,
492
482
  visitNode: visitNode$3,
493
- isArrayTypeNode,
483
+ isFunctionDeclaration: isFunctionDeclaration$1,
484
+ isVariableStatement: isVariableStatement$2,
485
+ isImportDeclaration: isImportDeclaration$3,
494
486
  isBlock: isBlock$2,
487
+ isForStatement: isForStatement$1,
488
+ isVariableDeclarationList,
495
489
  isForInStatement: isForInStatement$1,
496
490
  isForOfStatement: isForOfStatement$1,
497
- isForStatement: isForStatement$1,
498
- isFunctionDeclaration: isFunctionDeclaration$1,
499
- isFunctionTypeNode,
500
- isIdentifier: isIdentifier$3,
501
- isImportDeclaration: isImportDeclaration$3,
502
- isStringLiteral: isStringLiteral$6,
503
491
  isTypeReferenceNode: isTypeReferenceNode$1,
504
- isUnionTypeNode,
505
- isVariableDeclarationList,
506
- isVariableStatement: isVariableStatement$2,
507
- SyntaxKind: SyntaxKind$4
508
- } = tsModule$f;
492
+ isArrayTypeNode,
493
+ isFunctionTypeNode,
494
+ isUnionTypeNode
495
+ } = c;
509
496
  const BUILT_IN_TYPES = ["RegExp", "Date"];
510
497
  function builtInType(text) {
511
498
  return BUILT_IN_TYPES.findIndex((_) => _ === text) > -1;
@@ -621,7 +608,7 @@ class SourceFileBindingResolver {
621
608
  node.initializer
622
609
  )
623
610
  );
624
- } else if ((isForInStatement$1(node) || isForOfStatement$1(node)) && isVariableDeclarationList(node.initializer) && node.initializer.declarations.length === 1 && isIdentifier$3(node.initializer.declarations[0].name)) {
611
+ } else if ((isForInStatement$1(node) || isForOfStatement$1(node)) && isVariableDeclarationList(node.initializer) && node.initializer.declarations.length === 1 && isIdentifier$5(node.initializer.declarations[0].name)) {
625
612
  return doWithChildBindingResolver(node, () => {
626
613
  let name = node.initializer.declarations[0].name.text;
627
614
  nbResolversQueue[0].addVariable(
@@ -660,7 +647,7 @@ class SourceFileBindingResolver {
660
647
  if (type) {
661
648
  if (isTypeReferenceNode$1(type)) {
662
649
  let typeName = type.typeName;
663
- if (isIdentifier$3(typeName)) {
650
+ if (isIdentifier$5(typeName)) {
664
651
  let resolved = this.findBindingResolver(typeName).resolveIdentifier(typeName);
665
652
  let flattened = flattenVariable(resolved);
666
653
  let typeFromFlattened = this.explainFlattenedVariableType(flattened);
@@ -697,23 +684,21 @@ class SourceFileBindingResolver {
697
684
  function areResolvedTypesCompatible(type1, type2) {
698
685
  return type1.canBeAssignedFrom(type2);
699
686
  }
700
- const require$e = createRequire(import.meta.url);
701
- const tsModule$e = require$e("typescript");
702
687
  const {
703
- visitEachChild: visitEachChild$4,
704
- isBinaryExpression: isBinaryExpression$1,
705
- isCallExpression: isCallExpression$4,
706
- isDecorator,
707
- isExpressionStatement,
688
+ isSpreadElement,
708
689
  isFunctionDeclaration,
709
- isIdentifier: isIdentifier$2,
710
- isNewExpression: isNewExpression$1,
690
+ isDecorator,
691
+ isCallExpression: isCallExpression$4,
692
+ isIdentifier: isIdentifier$4,
711
693
  isPropertyAccessExpression: isPropertyAccessExpression$2,
712
694
  isReturnStatement,
713
- isSpreadElement,
695
+ isNewExpression: isNewExpression$1,
696
+ isExpressionStatement,
697
+ isBinaryExpression: isBinaryExpression$1,
714
698
  SyntaxKind: SyntaxKind$3,
715
- transform
716
- } = tsModule$e;
699
+ transform: transform$5,
700
+ visitEachChild: visitEachChild$4
701
+ } = c;
717
702
  var CompilePatternType = /* @__PURE__ */ ((CompilePatternType2) => {
718
703
  CompilePatternType2[CompilePatternType2["RETURN"] = 0] = "RETURN";
719
704
  CompilePatternType2[CompilePatternType2["CALL"] = 1] = "CALL";
@@ -777,7 +762,7 @@ function compileFunctionSplitPatternsBlock(patternFiles) {
777
762
  if (isFunctionDeclaration(node)) {
778
763
  let declaredTargetEnv = 0;
779
764
  node.modifiers && node.modifiers.forEach((modifier) => {
780
- if (isDecorator(modifier) && isCallExpression$4(modifier.expression) && isIdentifier$2(modifier.expression.expression) && modifier.expression.expression.text === "JayPattern" && modifier.expression.arguments.length === 1 && isPropertyAccessExpression$2(modifier.expression.arguments[0]) && isIdentifier$2(modifier.expression.arguments[0].expression) && modifier.expression.arguments[0].expression.text === "JayTargetEnv" && modifier.expression.arguments[0].name.text === "any")
765
+ if (isDecorator(modifier) && isCallExpression$4(modifier.expression) && isIdentifier$4(modifier.expression.expression) && modifier.expression.expression.text === "JayPattern" && modifier.expression.arguments.length === 1 && isPropertyAccessExpression$2(modifier.expression.arguments[0]) && isIdentifier$4(modifier.expression.arguments[0].expression) && modifier.expression.arguments[0].expression.text === "JayTargetEnv" && modifier.expression.arguments[0].name.text === "any")
781
766
  declaredTargetEnv = 1;
782
767
  });
783
768
  let name = node.name.text;
@@ -814,7 +799,7 @@ function compileFunctionSplitPatternsBlock(patternFiles) {
814
799
  sourceFileBinding,
815
800
  node
816
801
  );
817
- } else if (isExpressionStatement(statement) && isBinaryExpression$1(statement.expression) && isPropertyAccessExpression$2(statement.expression.left) && statement.expression.operatorToken.kind === SyntaxKind$3.EqualsToken && isIdentifier$2(statement.expression.right)) {
802
+ } else if (isExpressionStatement(statement) && isBinaryExpression$1(statement.expression) && isPropertyAccessExpression$2(statement.expression.left) && statement.expression.operatorToken.kind === SyntaxKind$3.EqualsToken && isIdentifier$4(statement.expression.right)) {
818
803
  patternType = 3;
819
804
  leftHandSide = statement.expression.left;
820
805
  callArgumentTypes = [
@@ -857,7 +842,7 @@ function compileFunctionSplitPatternsBlock(patternFiles) {
857
842
  }
858
843
  return node;
859
844
  };
860
- transform(patternsFile, [
845
+ transform$5(patternsFile, [
861
846
  mkTransformer(({ context, sourceFile }) => {
862
847
  visitEachChild$4(patternsFile, findPatternFunctions, context);
863
848
  return sourceFile;
@@ -866,9 +851,7 @@ function compileFunctionSplitPatternsBlock(patternFiles) {
866
851
  });
867
852
  return new WithValidations(compiledPatterns, validations);
868
853
  }
869
- const require$d = createRequire(import.meta.url);
870
- const tsModule$d = require$d("typescript");
871
- const { visitEachChild: visitEachChild$3, visitNode: visitNode$2 } = tsModule$d;
854
+ const { visitEachChild: visitEachChild$3, transform: transform$4, visitNode: visitNode$2 } = c;
872
855
  function visitWithContext(node, initialContext, contextualVisitor) {
873
856
  return visitWithContext2(node, initialContext, void 0, contextualVisitor);
874
857
  }
@@ -895,9 +878,7 @@ function visitWithContext2(node, initialContext, transformationContext, contextu
895
878
  };
896
879
  return visitNode$2(node, visitor);
897
880
  }
898
- const require$c = createRequire(import.meta.url);
899
- const tsModule$c = require$c("typescript");
900
- const { isTypeReferenceNode } = tsModule$c;
881
+ const { isTypeReferenceNode } = c;
901
882
  function isFirstParamJayEvent(eventHandler, bindingResolver) {
902
883
  if (eventHandler.parameters.length > 0 && eventHandler.parameters[0].type) {
903
884
  const explainedType = bindingResolver.explainType(eventHandler.parameters[0].type);
@@ -912,18 +893,17 @@ function filterEventHandlersToHaveJayEventType(foundEventHandlers, bindingResolv
912
893
  return isFirstParamJayEvent(eventHandler, bindingResolver);
913
894
  });
914
895
  }
915
- const require$b = createRequire(import.meta.url);
916
- const tsModule$b = require$b("typescript");
917
896
  const {
918
- SyntaxKind: SyntaxKind$2,
919
897
  visitEachChild: visitEachChild$2,
920
- visitNode: visitNode$1,
898
+ isIdentifier: isIdentifier$3,
899
+ SyntaxKind: SyntaxKind$2,
900
+ transform: transform$3,
901
+ isStatement: isStatement$1,
921
902
  isBlock: isBlock$1,
922
903
  isExpression: isExpression$1,
923
- isIdentifier: isIdentifier$1,
924
904
  isLiteralExpression: isLiteralExpression$1,
925
- isStatement: isStatement$1
926
- } = tsModule$b;
905
+ visitNode: visitNode$1
906
+ } = c;
927
907
  function generateFunctionRepository(matchedReturnPatterns, matchedVariableReads, matchedConstants, safeStatements) {
928
908
  const constCode = [...new Set(matchedConstants)].join("\n");
929
909
  let readPatternsReturnProperties = matchedReturnPatterns.map(
@@ -1007,9 +987,9 @@ const mkTransformEventHandlerStatementVisitor = (factory, context, bindingResolv
1007
987
  let patternKey = getPatternIndex(pattern);
1008
988
  if (pattern.patternType === CompilePatternType.RETURN)
1009
989
  sideEffects.matchedReturnPatterns.push({ pattern, patternKey });
1010
- else if (pattern.patternType === CompilePatternType.KNOWN_VARIABLE_READ && isIdentifier$1(node))
990
+ else if (pattern.patternType === CompilePatternType.KNOWN_VARIABLE_READ && isIdentifier$3(node))
1011
991
  sideEffects.matchedVariableReads.push({ variable: node, patternKey });
1012
- else if (pattern.patternType === CompilePatternType.CONST_READ && isIdentifier$1(node)) {
992
+ else if (pattern.patternType === CompilePatternType.CONST_READ && isIdentifier$3(node)) {
1013
993
  let constant = bindingResolver.explain(node);
1014
994
  let flattenedConstant = flattenVariable(constant);
1015
995
  let literal = flattenedConstant.root.literal;
@@ -1090,9 +1070,7 @@ const analyzeEventHandlerByPatternBlock = (context, bindingResolver, analyzer, f
1090
1070
  wasEventHandlerTransformed: false
1091
1071
  };
1092
1072
  };
1093
- const require$a = createRequire(import.meta.url);
1094
- const tsModule$a = require$a("typescript");
1095
- const { visitEachChild: visitEachChild$1, isCallExpression: isCallExpression$3, isPropertyAccessExpression: isPropertyAccessExpression$1 } = tsModule$a;
1073
+ const { visitEachChild: visitEachChild$1, isCallExpression: isCallExpression$3, isPropertyAccessExpression: isPropertyAccessExpression$1 } = c;
1096
1074
  const analyzeEventHandlerCall = (context, factory, handlerKey) => (node) => {
1097
1075
  if (isCallExpression$3(node) && isPropertyAccessExpression$1(node.expression)) {
1098
1076
  return factory.createCallExpression(
@@ -1160,27 +1138,27 @@ function analyzeEventHandlers(context, bindingResolver, analyzer, factory, found
1160
1138
  };
1161
1139
  });
1162
1140
  }
1163
- const require$9 = createRequire(import.meta.url);
1164
- const tsModule$9 = require$9("typescript");
1165
1141
  const {
1166
- isArrowFunction: isArrowFunction$1,
1167
1142
  isBinaryExpression,
1168
- isBlock,
1169
1143
  isCallExpression: isCallExpression$2,
1170
- isDoStatement,
1171
- isElementAccessExpression,
1172
- isForInStatement,
1173
- isForOfStatement,
1174
- isForStatement,
1175
- isIfStatement,
1176
- isLiteralExpression,
1144
+ isIdentifier: isIdentifier$2,
1177
1145
  isNewExpression,
1178
1146
  isPropertyAccessExpression,
1147
+ SyntaxKind: SyntaxKind$1,
1148
+ isArrowFunction: isArrowFunction$1,
1149
+ isLiteralExpression,
1179
1150
  isStatement,
1180
1151
  isVariableStatement: isVariableStatement$1,
1152
+ isBlock,
1153
+ isIfStatement,
1154
+ isForStatement,
1155
+ isForOfStatement,
1156
+ isForInStatement,
1181
1157
  isWhileStatement,
1182
- SyntaxKind: SyntaxKind$1
1183
- } = tsModule$9;
1158
+ isDoStatement,
1159
+ isElementAccessExpression,
1160
+ isPropertyAssignment
1161
+ } = c;
1184
1162
  class SourceFileStatementAnalyzer {
1185
1163
  constructor(sourceFile, bindingResolver, compiledPatterns) {
1186
1164
  this.sourceFile = sourceFile;
@@ -1362,6 +1340,17 @@ class ScopedSourceFileStatementAnalyzer {
1362
1340
  );
1363
1341
  if (this.getStatementStatus(node)?.targetEnv === JayTargetEnv.any)
1364
1342
  this.getStatementStatus(node).targetEnv = JayTargetEnv.main;
1343
+ } else if (isPropertyAssignment(node)) {
1344
+ visitChild(node.initializer, {
1345
+ statement,
1346
+ roleInParent: 1
1347
+ /* read */
1348
+ });
1349
+ visitChild(node.name, {
1350
+ statement,
1351
+ roleInParent: 0
1352
+ /* none */
1353
+ });
1365
1354
  } else if (isArrowFunction$1(node) && !isBlock(node.body)) {
1366
1355
  visitChild(node.body, {
1367
1356
  statement,
@@ -1580,9 +1569,7 @@ function isChildOf(node, parent) {
1580
1569
  return true;
1581
1570
  return isChildOf(node.parent, parent);
1582
1571
  }
1583
- const require$8 = createRequire(import.meta.url);
1584
- const tsModule$8 = require$8("typescript");
1585
- const { forEachChild: forEachChild$1, isCallExpression: isCallExpression$1, isStringLiteral: isStringLiteral$5, isVariableStatement } = tsModule$8;
1572
+ const { isCallExpression: isCallExpression$1, isIdentifier: isIdentifier$1, isStringLiteral: isStringLiteral$5, isVariableStatement, forEachChild: forEachChild$1 } = c;
1586
1573
  var FindComponentConstructorType = /* @__PURE__ */ ((FindComponentConstructorType2) => {
1587
1574
  FindComponentConstructorType2["makeJayComponent"] = "makeJayComponent";
1588
1575
  FindComponentConstructorType2["makeJayTsxComponent"] = "makeJayTsxComponent";
@@ -1679,9 +1666,7 @@ export ${_}`
1679
1666
  );
1680
1667
  }
1681
1668
  }
1682
- const require$7 = createRequire(import.meta.url);
1683
- const tsModule$7 = require$7("typescript");
1684
- const { forEachChild, isCallExpression, isIdentifier, isStringLiteral: isStringLiteral$4 } = tsModule$7;
1669
+ const { isCallExpression, isIdentifier, isStringLiteral: isStringLiteral$4, forEachChild } = c;
1685
1670
  function findExec$(bindingResolver, sourceFile) {
1686
1671
  const foundExec$ = [];
1687
1672
  function visit(node) {
@@ -1696,9 +1681,7 @@ function findExec$(bindingResolver, sourceFile) {
1696
1681
  forEachChild(sourceFile, visit);
1697
1682
  return foundExec$;
1698
1683
  }
1699
- const require$6 = createRequire(import.meta.url);
1700
- const tsModule$6 = require$6("typescript");
1701
- const { visitNode, isArrowFunction, isExpression } = tsModule$6;
1684
+ const { transform: transform$2, isArrowFunction, isExpression, visitNode } = c;
1702
1685
  function analyzeGlobalExec$(context, analyzer, functionRepositoryBuilder, foundExec$) {
1703
1686
  const scopedAnalyzer = analyzer.analyzeForScope(foundExec$);
1704
1687
  let foundUnsafeExpression = false;
@@ -1735,9 +1718,7 @@ function transformedGlobalExec$toReplaceMap(transformedGlobalExec$s) {
1735
1718
  });
1736
1719
  return map;
1737
1720
  }
1738
- const require$5 = createRequire(import.meta.url);
1739
- const tsModule$5 = require$5("typescript");
1740
- const { SyntaxKind, isImportDeclaration: isImportDeclaration$2, isStringLiteral: isStringLiteral$3, isInterfaceDeclaration } = tsModule$5;
1721
+ const { SyntaxKind, transform: transform$1, isStringLiteral: isStringLiteral$3, isInterfaceDeclaration, isImportDeclaration: isImportDeclaration$2 } = c;
1741
1722
  function generateComponentConstructorCalls(context, componentConstructorCalls, hasFunctionRepository) {
1742
1723
  let optionsParam = hasFunctionRepository ? ", { funcRepository }" : "";
1743
1724
  let transformedConstructors = componentConstructorCalls.map(({ name, render }) => {
@@ -1858,9 +1839,7 @@ function transformComponentBridge(importerMode, patterns = [], globalFunctionRep
1858
1839
  globalFunctionRepository
1859
1840
  });
1860
1841
  }
1861
- const require$4 = createRequire(import.meta.url);
1862
- const tsModule$4 = require$4("typescript");
1863
- const { isStringLiteral: isStringLiteral$2 } = tsModule$4;
1842
+ const { isStringLiteral: isStringLiteral$2 } = c;
1864
1843
  function transformImportModeFileExtension(node, factory, importerMode) {
1865
1844
  if (!isStringLiteral$2(node.moduleSpecifier))
1866
1845
  return void 0;
@@ -1875,9 +1854,7 @@ function transformImportModeFileExtension(node, factory, importerMode) {
1875
1854
  node.attributes
1876
1855
  );
1877
1856
  }
1878
- const require$3 = createRequire(import.meta.url);
1879
- const tsModule$3 = require$3("typescript");
1880
- const { isImportDeclaration: isImportDeclaration$1 } = tsModule$3;
1857
+ const { isImportDeclaration: isImportDeclaration$1 } = c;
1881
1858
  function findAfterImportStatementIndex(statements) {
1882
1859
  let lastIndex = 0;
1883
1860
  while (isImportDeclaration$1(statements[lastIndex]))
@@ -1905,9 +1882,7 @@ function transformComponentImports(needsHandler$, needsFunc$, needsFuncGlobal$,
1905
1882
  } else
1906
1883
  return transformedSourceFile;
1907
1884
  }
1908
- const require$2 = createRequire(import.meta.url);
1909
- const tsModule$2 = require$2("typescript");
1910
- const { isImportDeclaration, isStringLiteral: isStringLiteral$1, visitEachChild } = tsModule$2;
1885
+ const { visitEachChild, transform, isStringLiteral: isStringLiteral$1, isImportDeclaration } = c;
1911
1886
  function isCssImport(node) {
1912
1887
  return isStringLiteral$1(node.moduleSpecifier) && node.moduleSpecifier.text.endsWith(".css");
1913
1888
  }
@@ -1978,9 +1953,7 @@ function mkComponentTransformer(sftContext) {
1978
1953
  function transformComponent(patterns = [], globalFunctionRepository) {
1979
1954
  return mkTransformer(mkComponentTransformer, { patterns, globalFunctionRepository });
1980
1955
  }
1981
- const require$1 = createRequire(import.meta.url);
1982
- const tsModule$1 = require$1("typescript");
1983
- const { ScriptTarget, createSourceFile, ScriptKind } = tsModule$1;
1956
+ const { createSourceFile, ScriptTarget, ScriptKind } = c;
1984
1957
  function createTsSourceFileFromSource(filePath, sourceCode, scriptKind = ScriptKind.TS) {
1985
1958
  try {
1986
1959
  return createSourceFile(filePath, sourceCode, ScriptTarget.Latest, true, scriptKind);
@@ -2001,9 +1974,7 @@ function generateImportsFileFromJayFile(jayFile) {
2001
1974
  function fromImportModules(modules) {
2002
1975
  return modules.filter(isRelativeImport).map((module) => `import '${module}${JAY_QUERY_WORKER_TRUSTED}'`).join("\n");
2003
1976
  }
2004
- const require2 = createRequire(import.meta.url);
2005
- const tsModule = require2("typescript");
2006
- const { isStringLiteral } = tsModule;
1977
+ const { isStringLiteral } = c;
2007
1978
  function parseImportLinks(sourceFile) {
2008
1979
  const importDeclarations = extractImportDeclarations(sourceFile).filter(
2009
1980
  (importDeclaration) => isStringLiteral(importDeclaration.moduleSpecifier)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/compiler",
3
- "version": "0.6.10",
3
+ "version": "0.8.0",
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.6.10",
29
- "@jay-framework/compiler-jay-html": "^0.6.10",
30
- "@jay-framework/compiler-shared": "^0.6.10",
31
- "@jay-framework/component": "^0.6.10",
32
- "@jay-framework/runtime": "^0.6.10",
33
- "@jay-framework/secure": "^0.6.10",
28
+ "@jay-framework/compiler-analyze-exported-types": "^0.8.0",
29
+ "@jay-framework/compiler-jay-html": "^0.8.0",
30
+ "@jay-framework/compiler-shared": "^0.8.0",
31
+ "@jay-framework/component": "^0.8.0",
32
+ "@jay-framework/runtime": "^0.8.0",
33
+ "@jay-framework/secure": "^0.8.0",
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.6.10",
44
+ "@jay-framework/dev-environment": "^0.8.0",
45
45
  "@testing-library/jest-dom": "^6.2.0",
46
46
  "@types/js-beautify": "^1",
47
47
  "@types/node": "^20.11.5",