funkscript 0.2.6 → 0.2.7

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 (171) hide show
  1. package/README.md +1 -1
  2. package/dist/cli/build-watch.d.ts.map +1 -1
  3. package/dist/cli/build-watch.js +4 -24
  4. package/dist/cli/build-watch.js.map +1 -1
  5. package/dist/cli/build.d.ts.map +1 -1
  6. package/dist/cli/build.js +3 -58
  7. package/dist/cli/build.js.map +1 -1
  8. package/dist/cli/check-policy.d.ts +9 -0
  9. package/dist/cli/check-policy.d.ts.map +1 -0
  10. package/dist/cli/check-policy.js +39 -0
  11. package/dist/cli/check-policy.js.map +1 -0
  12. package/dist/cli/check.d.ts.map +1 -1
  13. package/dist/cli/check.js +16 -30
  14. package/dist/cli/check.js.map +1 -1
  15. package/dist/cli/commands.d.ts.map +1 -1
  16. package/dist/cli/commands.js +11 -0
  17. package/dist/cli/commands.js.map +1 -1
  18. package/dist/cli/doctor.d.ts.map +1 -1
  19. package/dist/cli/doctor.js +2 -6
  20. package/dist/cli/doctor.js.map +1 -1
  21. package/dist/cli/index.js +3 -0
  22. package/dist/cli/index.js.map +1 -1
  23. package/dist/cli/query.d.ts +3 -0
  24. package/dist/cli/query.d.ts.map +1 -0
  25. package/dist/cli/query.js +152 -0
  26. package/dist/cli/query.js.map +1 -0
  27. package/dist/cli/run.d.ts.map +1 -1
  28. package/dist/cli/run.js +2 -29
  29. package/dist/cli/run.js.map +1 -1
  30. package/dist/cli/tsc.d.ts.map +1 -1
  31. package/dist/cli/tsc.js +2 -6
  32. package/dist/cli/tsc.js.map +1 -1
  33. package/dist/compiler/check.d.ts.map +1 -1
  34. package/dist/compiler/check.js +18 -28
  35. package/dist/compiler/check.js.map +1 -1
  36. package/dist/compiler/diagnostics-json.d.ts +73 -0
  37. package/dist/compiler/diagnostics-json.d.ts.map +1 -0
  38. package/dist/compiler/diagnostics-json.js +957 -0
  39. package/dist/compiler/diagnostics-json.js.map +1 -0
  40. package/dist/compiler/escape-audit.d.ts +46 -0
  41. package/dist/compiler/escape-audit.d.ts.map +1 -0
  42. package/dist/compiler/escape-audit.js +682 -0
  43. package/dist/compiler/escape-audit.js.map +1 -0
  44. package/dist/compiler/modules/output-plan.d.ts.map +1 -1
  45. package/dist/compiler/modules/output-plan.js +10 -5
  46. package/dist/compiler/modules/output-plan.js.map +1 -1
  47. package/dist/compiler/modules/source-files.d.ts +2 -0
  48. package/dist/compiler/modules/source-files.d.ts.map +1 -1
  49. package/dist/compiler/modules/source-files.js +8 -0
  50. package/dist/compiler/modules/source-files.js.map +1 -1
  51. package/dist/compiler/numeric-comparisons.d.ts.map +1 -1
  52. package/dist/compiler/numeric-comparisons.js +13 -7
  53. package/dist/compiler/numeric-comparisons.js.map +1 -1
  54. package/dist/compiler/pipelines/resolution.d.ts.map +1 -1
  55. package/dist/compiler/pipelines/resolution.js +24 -23
  56. package/dist/compiler/pipelines/resolution.js.map +1 -1
  57. package/dist/compiler/query.d.ts +53 -0
  58. package/dist/compiler/query.d.ts.map +1 -0
  59. package/dist/compiler/query.js +781 -0
  60. package/dist/compiler/query.js.map +1 -0
  61. package/dist/compiler/source-map.d.ts.map +1 -1
  62. package/dist/compiler/source-map.js +2 -7
  63. package/dist/compiler/source-map.js.map +1 -1
  64. package/dist/compiler/type-view-paths.d.ts +2 -0
  65. package/dist/compiler/type-view-paths.d.ts.map +1 -1
  66. package/dist/compiler/type-view-paths.js +8 -0
  67. package/dist/compiler/type-view-paths.js.map +1 -1
  68. package/dist/compiler/typescript-context.d.ts.map +1 -1
  69. package/dist/compiler/typescript-context.js +5 -7
  70. package/dist/compiler/typescript-context.js.map +1 -1
  71. package/dist/emitter/assemblyscript.d.ts.map +1 -1
  72. package/dist/emitter/assemblyscript.js +120 -136
  73. package/dist/emitter/assemblyscript.js.map +1 -1
  74. package/dist/formatter/index.d.ts +9 -0
  75. package/dist/formatter/index.d.ts.map +1 -1
  76. package/dist/formatter/index.js +158 -2
  77. package/dist/formatter/index.js.map +1 -1
  78. package/dist/index.d.ts +3 -0
  79. package/dist/index.d.ts.map +1 -1
  80. package/dist/index.js +3 -0
  81. package/dist/index.js.map +1 -1
  82. package/dist/lsp/completion.d.ts +25 -0
  83. package/dist/lsp/completion.d.ts.map +1 -1
  84. package/dist/lsp/completion.js +1114 -51
  85. package/dist/lsp/completion.js.map +1 -1
  86. package/dist/lsp/definition.d.ts +2 -0
  87. package/dist/lsp/definition.d.ts.map +1 -1
  88. package/dist/lsp/definition.js +52 -58
  89. package/dist/lsp/definition.js.map +1 -1
  90. package/dist/lsp/hover.d.ts +5 -1
  91. package/dist/lsp/hover.d.ts.map +1 -1
  92. package/dist/lsp/hover.js +1000 -41
  93. package/dist/lsp/hover.js.map +1 -1
  94. package/dist/lsp/imports.d.ts +2 -0
  95. package/dist/lsp/imports.d.ts.map +1 -1
  96. package/dist/lsp/imports.js +35 -20
  97. package/dist/lsp/imports.js.map +1 -1
  98. package/dist/lsp/navigation.d.ts +1 -1
  99. package/dist/lsp/navigation.d.ts.map +1 -1
  100. package/dist/lsp/navigation.js +30 -12
  101. package/dist/lsp/navigation.js.map +1 -1
  102. package/dist/lsp/range-format.d.ts +4 -0
  103. package/dist/lsp/range-format.d.ts.map +1 -0
  104. package/dist/lsp/range-format.js +88 -0
  105. package/dist/lsp/range-format.js.map +1 -0
  106. package/dist/lsp/schema-import-hover.d.ts +8 -0
  107. package/dist/lsp/schema-import-hover.d.ts.map +1 -0
  108. package/dist/lsp/schema-import-hover.js +52 -0
  109. package/dist/lsp/schema-import-hover.js.map +1 -0
  110. package/dist/lsp/server.d.ts +1 -0
  111. package/dist/lsp/server.d.ts.map +1 -1
  112. package/dist/lsp/server.js +53 -48
  113. package/dist/lsp/server.js.map +1 -1
  114. package/dist/lsp/workspace.d.ts +3 -1
  115. package/dist/lsp/workspace.d.ts.map +1 -1
  116. package/dist/lsp/workspace.js +66 -10
  117. package/dist/lsp/workspace.js.map +1 -1
  118. package/dist/plugins/bun.d.ts +2 -18
  119. package/dist/plugins/bun.d.ts.map +1 -1
  120. package/dist/plugins/bun.js +5 -30
  121. package/dist/plugins/bun.js.map +1 -1
  122. package/dist/plugins/esbuild.d.ts +1 -1
  123. package/dist/plugins/esbuild.d.ts.map +1 -1
  124. package/dist/plugins/esbuild.js +10 -36
  125. package/dist/plugins/esbuild.js.map +1 -1
  126. package/dist/plugins/server-boundary.d.ts +14 -0
  127. package/dist/plugins/server-boundary.d.ts.map +1 -0
  128. package/dist/plugins/server-boundary.js +25 -0
  129. package/dist/plugins/server-boundary.js.map +1 -0
  130. package/dist/plugins/vite.d.ts +2 -18
  131. package/dist/plugins/vite.d.ts.map +1 -1
  132. package/dist/plugins/vite.js +4 -29
  133. package/dist/plugins/vite.js.map +1 -1
  134. package/package.json +1 -1
  135. package/src/cli/build-watch.ts +4 -26
  136. package/src/cli/build.ts +9 -60
  137. package/src/cli/check-policy.ts +54 -0
  138. package/src/cli/check.ts +19 -31
  139. package/src/cli/commands.ts +13 -0
  140. package/src/cli/doctor.ts +2 -5
  141. package/src/cli/index.ts +3 -0
  142. package/src/cli/query.ts +191 -0
  143. package/src/cli/run.ts +5 -30
  144. package/src/cli/tsc.ts +2 -5
  145. package/src/compiler/check.ts +28 -48
  146. package/src/compiler/diagnostics-json.ts +1205 -0
  147. package/src/compiler/escape-audit.ts +913 -0
  148. package/src/compiler/modules/output-plan.ts +11 -9
  149. package/src/compiler/modules/source-files.ts +9 -0
  150. package/src/compiler/numeric-comparisons.ts +14 -8
  151. package/src/compiler/pipelines/resolution.ts +30 -26
  152. package/src/compiler/query.ts +1177 -0
  153. package/src/compiler/source-map.ts +3 -7
  154. package/src/compiler/type-view-paths.ts +7 -0
  155. package/src/compiler/typescript-context.ts +6 -7
  156. package/src/emitter/assemblyscript.ts +101 -147
  157. package/src/formatter/index.ts +229 -2
  158. package/src/index.ts +3 -0
  159. package/src/lsp/completion.ts +1452 -66
  160. package/src/lsp/definition.ts +50 -58
  161. package/src/lsp/hover.ts +1442 -40
  162. package/src/lsp/imports.ts +55 -21
  163. package/src/lsp/navigation.ts +41 -22
  164. package/src/lsp/range-format.ts +102 -0
  165. package/src/lsp/schema-import-hover.ts +76 -0
  166. package/src/lsp/server.ts +69 -69
  167. package/src/lsp/workspace.ts +63 -9
  168. package/src/plugins/bun.ts +14 -66
  169. package/src/plugins/esbuild.ts +16 -55
  170. package/src/plugins/server-boundary.ts +41 -0
  171. package/src/plugins/vite.ts +12 -62
@@ -10,6 +10,8 @@ import type {
10
10
  BlockStatement,
11
11
  Expression,
12
12
  FunctionBody,
13
+ JSXAttribute,
14
+ JSXTagName,
13
15
  NodeBase,
14
16
  Pattern,
15
17
  Program,
@@ -756,35 +758,10 @@ export class DefinitionFinder {
756
758
  }
757
759
 
758
760
  case "JSXElement": {
759
- if (expr.openingElement.name.kind === "MemberExpression") {
760
- this.visitExpression(expr.openingElement.name, scope);
761
- } else if (this.isCursorIn(expr.openingElement.name)) {
762
- const sym = scope.lookup(expr.openingElement.name.name);
763
- if (sym) {
764
- this.found = {
765
- originNode: expr.openingElement.name,
766
- declarationNode: sym.declarationNode,
767
- targetIdentifierNode: sym.identifierNode,
768
- };
769
- return;
770
- }
771
- }
772
- for (const attr of expr.openingElement.attributes) {
773
- if (attr.kind === "JSXSpreadAttribute") {
774
- this.visitExpression(attr.argument, scope);
775
- continue;
776
- }
777
- if (attr.value) {
778
- if (attr.value.kind === "JSXExpressionContainer") {
779
- this.visitExpression(attr.value.expression, scope);
780
- } else if (
781
- attr.value.kind === "Identifier" ||
782
- attr.value.kind === "UpperIdentifier"
783
- ) {
784
- this.visitExpression(attr.value, scope);
785
- }
786
- }
787
- }
761
+ this.visitJsxTagName(expr.openingElement.name, scope);
762
+ if (this.found) return;
763
+ this.visitJsxAttributes(expr.openingElement.attributes, scope);
764
+ if (this.found) return;
788
765
  for (const child of expr.children) {
789
766
  if (
790
767
  child.kind === "JSXElement" ||
@@ -794,40 +771,18 @@ export class DefinitionFinder {
794
771
  } else if (child.kind === "JSXExpressionContainer") {
795
772
  this.visitExpression(child.expression, scope);
796
773
  }
774
+ if (this.found) return;
775
+ }
776
+ if (expr.closingElement) {
777
+ this.visitJsxTagName(expr.closingElement.name, scope);
797
778
  }
798
779
  break;
799
780
  }
800
781
 
801
782
  case "JSXSelfClosingElement": {
802
- if (expr.name.kind === "MemberExpression") {
803
- this.visitExpression(expr.name, scope);
804
- } else if (this.isCursorIn(expr.name)) {
805
- const sym = scope.lookup(expr.name.name);
806
- if (sym) {
807
- this.found = {
808
- originNode: expr.name,
809
- declarationNode: sym.declarationNode,
810
- targetIdentifierNode: sym.identifierNode,
811
- };
812
- return;
813
- }
814
- }
815
- for (const attr of expr.attributes) {
816
- if (attr.kind === "JSXSpreadAttribute") {
817
- this.visitExpression(attr.argument, scope);
818
- continue;
819
- }
820
- if (attr.value) {
821
- if (attr.value.kind === "JSXExpressionContainer") {
822
- this.visitExpression(attr.value.expression, scope);
823
- } else if (
824
- attr.value.kind === "Identifier" ||
825
- attr.value.kind === "UpperIdentifier"
826
- ) {
827
- this.visitExpression(attr.value, scope);
828
- }
829
- }
830
- }
783
+ this.visitJsxTagName(expr.name, scope);
784
+ if (this.found) return;
785
+ this.visitJsxAttributes(expr.attributes, scope);
831
786
  break;
832
787
  }
833
788
 
@@ -864,6 +819,43 @@ export class DefinitionFinder {
864
819
  }
865
820
  }
866
821
 
822
+ private visitJsxTagName(tagName: JSXTagName, scope: Scope): void {
823
+ if (this.found) return;
824
+ if (tagName.kind === "MemberExpression") {
825
+ this.visitExpression(tagName, scope);
826
+ return;
827
+ }
828
+ if (this.isCursorIn(tagName)) {
829
+ const sym = scope.lookup(tagName.name);
830
+ if (sym) {
831
+ this.found = {
832
+ originNode: tagName,
833
+ declarationNode: sym.declarationNode,
834
+ targetIdentifierNode: sym.identifierNode,
835
+ };
836
+ }
837
+ }
838
+ }
839
+
840
+ private visitJsxAttributes(attributes: JSXAttribute[], scope: Scope): void {
841
+ for (const attr of attributes) {
842
+ if (this.found) return;
843
+ if (attr.kind === "JSXSpreadAttribute") {
844
+ this.visitExpression(attr.argument, scope);
845
+ continue;
846
+ }
847
+ if (!attr.value) continue;
848
+ if (attr.value.kind === "JSXExpressionContainer") {
849
+ this.visitExpression(attr.value.expression, scope);
850
+ } else if (
851
+ attr.value.kind === "Identifier" ||
852
+ attr.value.kind === "UpperIdentifier"
853
+ ) {
854
+ this.visitExpression(attr.value, scope);
855
+ }
856
+ }
857
+ }
858
+
867
859
  private visitFunctionBody(body: FunctionBody, scope: Scope): void {
868
860
  if (this.found) return;
869
861
  if (body.kind === "BlockStatement") {