funkscript 0.2.4 → 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 (447) hide show
  1. package/README.md +23 -5
  2. package/dist/ast/types.d.ts.map +1 -1
  3. package/dist/ast/types.js.map +1 -1
  4. package/dist/ast/walk.d.ts.map +1 -1
  5. package/dist/ast/walk.js.map +1 -1
  6. package/dist/cli/build-bun.d.ts.map +1 -1
  7. package/dist/cli/build-bun.js.map +1 -1
  8. package/dist/cli/build-watch.d.ts.map +1 -1
  9. package/dist/cli/build-watch.js +9 -27
  10. package/dist/cli/build-watch.js.map +1 -1
  11. package/dist/cli/build.d.ts +1 -1
  12. package/dist/cli/build.d.ts.map +1 -1
  13. package/dist/cli/build.js +3 -58
  14. package/dist/cli/build.js.map +1 -1
  15. package/dist/cli/check-policy.d.ts +9 -0
  16. package/dist/cli/check-policy.d.ts.map +1 -0
  17. package/dist/cli/check-policy.js +39 -0
  18. package/dist/cli/check-policy.js.map +1 -0
  19. package/dist/cli/check.d.ts.map +1 -1
  20. package/dist/cli/check.js +16 -30
  21. package/dist/cli/check.js.map +1 -1
  22. package/dist/cli/commands.d.ts.map +1 -1
  23. package/dist/cli/commands.js +11 -0
  24. package/dist/cli/commands.js.map +1 -1
  25. package/dist/cli/doc.d.ts.map +1 -1
  26. package/dist/cli/doc.js.map +1 -1
  27. package/dist/cli/doctor.d.ts.map +1 -1
  28. package/dist/cli/doctor.js +5 -7
  29. package/dist/cli/doctor.js.map +1 -1
  30. package/dist/cli/emit.d.ts +1 -1
  31. package/dist/cli/emit.d.ts.map +1 -1
  32. package/dist/cli/emit.js.map +1 -1
  33. package/dist/cli/explain.d.ts.map +1 -1
  34. package/dist/cli/explain.js.map +1 -1
  35. package/dist/cli/fmt.d.ts.map +1 -1
  36. package/dist/cli/fmt.js.map +1 -1
  37. package/dist/cli/index.d.ts.map +1 -1
  38. package/dist/cli/index.js +3 -0
  39. package/dist/cli/index.js.map +1 -1
  40. package/dist/cli/init.d.ts +1 -1
  41. package/dist/cli/init.d.ts.map +1 -1
  42. package/dist/cli/init.js +66 -21
  43. package/dist/cli/init.js.map +1 -1
  44. package/dist/cli/io.d.ts.map +1 -1
  45. package/dist/cli/io.js.map +1 -1
  46. package/dist/cli/pipeline-style.d.ts.map +1 -1
  47. package/dist/cli/pipeline-style.js.map +1 -1
  48. package/dist/cli/query.d.ts +3 -0
  49. package/dist/cli/query.d.ts.map +1 -0
  50. package/dist/cli/query.js +152 -0
  51. package/dist/cli/query.js.map +1 -0
  52. package/dist/cli/repl.d.ts.map +1 -1
  53. package/dist/cli/repl.js.map +1 -1
  54. package/dist/cli/run.d.ts.map +1 -1
  55. package/dist/cli/run.js +2 -29
  56. package/dist/cli/run.js.map +1 -1
  57. package/dist/cli/test.d.ts +1 -1
  58. package/dist/cli/test.d.ts.map +1 -1
  59. package/dist/cli/test.js.map +1 -1
  60. package/dist/cli/tsc.d.ts.map +1 -1
  61. package/dist/cli/tsc.js +6 -8
  62. package/dist/cli/tsc.js.map +1 -1
  63. package/dist/cli/typecheck.d.ts.map +1 -1
  64. package/dist/cli/typecheck.js.map +1 -1
  65. package/dist/compiler/ast-inspection.d.ts.map +1 -1
  66. package/dist/compiler/ast-inspection.js.map +1 -1
  67. package/dist/compiler/boolean-operators.d.ts.map +1 -1
  68. package/dist/compiler/boolean-operators.js +12 -2
  69. package/dist/compiler/boolean-operators.js.map +1 -1
  70. package/dist/compiler/check.d.ts.map +1 -1
  71. package/dist/compiler/check.js +113 -131
  72. package/dist/compiler/check.js.map +1 -1
  73. package/dist/compiler/diagnostics-json.d.ts +73 -0
  74. package/dist/compiler/diagnostics-json.d.ts.map +1 -0
  75. package/dist/compiler/diagnostics-json.js +957 -0
  76. package/dist/compiler/diagnostics-json.js.map +1 -0
  77. package/dist/compiler/diagnostics.d.ts.map +1 -1
  78. package/dist/compiler/diagnostics.js.map +1 -1
  79. package/dist/compiler/effect-mutation-rule.d.ts.map +1 -1
  80. package/dist/compiler/effect-mutation-rule.js.map +1 -1
  81. package/dist/compiler/entry-rules.d.ts.map +1 -1
  82. package/dist/compiler/entry-rules.js.map +1 -1
  83. package/dist/compiler/escape-audit.d.ts +46 -0
  84. package/dist/compiler/escape-audit.d.ts.map +1 -0
  85. package/dist/compiler/escape-audit.js +682 -0
  86. package/dist/compiler/escape-audit.js.map +1 -0
  87. package/dist/compiler/incremental-build.d.ts.map +1 -1
  88. package/dist/compiler/incremental-build.js.map +1 -1
  89. package/dist/compiler/incremental-dependencies.d.ts.map +1 -1
  90. package/dist/compiler/incremental-dependencies.js.map +1 -1
  91. package/dist/compiler/js-interop-nullability.d.ts.map +1 -1
  92. package/dist/compiler/js-interop-nullability.js.map +1 -1
  93. package/dist/compiler/modules/output-collisions.d.ts.map +1 -1
  94. package/dist/compiler/modules/output-collisions.js.map +1 -1
  95. package/dist/compiler/modules/output-plan.d.ts.map +1 -1
  96. package/dist/compiler/modules/output-plan.js +10 -5
  97. package/dist/compiler/modules/output-plan.js.map +1 -1
  98. package/dist/compiler/modules/resolution.d.ts.map +1 -1
  99. package/dist/compiler/modules/resolution.js +2 -1
  100. package/dist/compiler/modules/resolution.js.map +1 -1
  101. package/dist/compiler/modules/source-files.d.ts +5 -0
  102. package/dist/compiler/modules/source-files.d.ts.map +1 -0
  103. package/dist/compiler/modules/source-files.js +13 -0
  104. package/dist/compiler/modules/source-files.js.map +1 -0
  105. package/dist/compiler/numeric-comparisons.d.ts.map +1 -1
  106. package/dist/compiler/numeric-comparisons.js +13 -7
  107. package/dist/compiler/numeric-comparisons.js.map +1 -1
  108. package/dist/compiler/optional-arguments.d.ts.map +1 -1
  109. package/dist/compiler/optional-arguments.js.map +1 -1
  110. package/dist/compiler/package-fingerprint.d.ts.map +1 -1
  111. package/dist/compiler/package-fingerprint.js.map +1 -1
  112. package/dist/compiler/package-record-contracts.d.ts.map +1 -1
  113. package/dist/compiler/package-record-contracts.js.map +1 -1
  114. package/dist/compiler/pipelines/catalog.d.ts.map +1 -1
  115. package/dist/compiler/pipelines/catalog.js.map +1 -1
  116. package/dist/compiler/pipelines/companions.d.ts.map +1 -1
  117. package/dist/compiler/pipelines/companions.js.map +1 -1
  118. package/dist/compiler/pipelines/resolution.d.ts.map +1 -1
  119. package/dist/compiler/pipelines/resolution.js +24 -23
  120. package/dist/compiler/pipelines/resolution.js.map +1 -1
  121. package/dist/compiler/project-config.d.ts.map +1 -1
  122. package/dist/compiler/project-config.js +29 -19
  123. package/dist/compiler/project-config.js.map +1 -1
  124. package/dist/compiler/query.d.ts +53 -0
  125. package/dist/compiler/query.d.ts.map +1 -0
  126. package/dist/compiler/query.js +781 -0
  127. package/dist/compiler/query.js.map +1 -0
  128. package/dist/compiler/record-contracts.d.ts.map +1 -1
  129. package/dist/compiler/record-contracts.js.map +1 -1
  130. package/dist/compiler/rules/control-flow.d.ts.map +1 -1
  131. package/dist/compiler/rules/control-flow.js.map +1 -1
  132. package/dist/compiler/rules/diagnostic.d.ts.map +1 -1
  133. package/dist/compiler/rules/diagnostic.js.map +1 -1
  134. package/dist/compiler/rules/module-scope-refs.d.ts.map +1 -1
  135. package/dist/compiler/rules/module-scope-refs.js.map +1 -1
  136. package/dist/compiler/rules/resource-escape.d.ts +7 -0
  137. package/dist/compiler/rules/resource-escape.d.ts.map +1 -0
  138. package/dist/compiler/rules/resource-escape.js +146 -0
  139. package/dist/compiler/rules/resource-escape.js.map +1 -0
  140. package/dist/compiler/rules/resource-providers.d.ts +19 -0
  141. package/dist/compiler/rules/resource-providers.d.ts.map +1 -0
  142. package/dist/compiler/rules/resource-providers.js +222 -0
  143. package/dist/compiler/rules/resource-providers.js.map +1 -0
  144. package/dist/compiler/schemas/analysis.d.ts.map +1 -1
  145. package/dist/compiler/schemas/analysis.js.map +1 -1
  146. package/dist/compiler/schemas/imported-record-functions.d.ts.map +1 -1
  147. package/dist/compiler/schemas/imported-record-functions.js.map +1 -1
  148. package/dist/compiler/schemas/imported-schemas.d.ts.map +1 -1
  149. package/dist/compiler/schemas/imported-schemas.js.map +1 -1
  150. package/dist/compiler/source-map.d.ts.map +1 -1
  151. package/dist/compiler/source-map.js +2 -7
  152. package/dist/compiler/source-map.js.map +1 -1
  153. package/dist/compiler/type-view-paths.d.ts +6 -0
  154. package/dist/compiler/type-view-paths.d.ts.map +1 -0
  155. package/dist/compiler/type-view-paths.js +12 -0
  156. package/dist/compiler/type-view-paths.js.map +1 -0
  157. package/dist/compiler/typescript-context.d.ts.map +1 -1
  158. package/dist/compiler/typescript-context.js +5 -7
  159. package/dist/compiler/typescript-context.js.map +1 -1
  160. package/dist/compiler.d.ts.map +1 -1
  161. package/dist/compiler.js.map +1 -1
  162. package/dist/emitter/assemblyscript.d.ts.map +1 -1
  163. package/dist/emitter/assemblyscript.js +120 -136
  164. package/dist/emitter/assemblyscript.js.map +1 -1
  165. package/dist/emitter/declarations.d.ts.map +1 -1
  166. package/dist/emitter/declarations.js.map +1 -1
  167. package/dist/emitter/emitter.d.ts +3 -1
  168. package/dist/emitter/emitter.d.ts.map +1 -1
  169. package/dist/emitter/emitter.js +10 -1
  170. package/dist/emitter/emitter.js.map +1 -1
  171. package/dist/emitter/imports.d.ts.map +1 -1
  172. package/dist/emitter/imports.js.map +1 -1
  173. package/dist/emitter/indent.d.ts.map +1 -1
  174. package/dist/emitter/indent.js.map +1 -1
  175. package/dist/emitter/jsx.d.ts.map +1 -1
  176. package/dist/emitter/jsx.js.map +1 -1
  177. package/dist/emitter/local-bindings.d.ts.map +1 -1
  178. package/dist/emitter/local-bindings.js.map +1 -1
  179. package/dist/emitter/match.d.ts.map +1 -1
  180. package/dist/emitter/match.js.map +1 -1
  181. package/dist/emitter/runtime-helpers.d.ts.map +1 -1
  182. package/dist/emitter/runtime-helpers.js.map +1 -1
  183. package/dist/emitter/schemas.d.ts.map +1 -1
  184. package/dist/emitter/schemas.js.map +1 -1
  185. package/dist/emitter/statements.d.ts +1 -0
  186. package/dist/emitter/statements.d.ts.map +1 -1
  187. package/dist/emitter/statements.js +1 -0
  188. package/dist/emitter/statements.js.map +1 -1
  189. package/dist/emitter/tagged-match.d.ts.map +1 -1
  190. package/dist/emitter/tagged-match.js.map +1 -1
  191. package/dist/emitter/types.d.ts.map +1 -1
  192. package/dist/emitter/types.js.map +1 -1
  193. package/dist/errors.d.ts.map +1 -1
  194. package/dist/errors.js.map +1 -1
  195. package/dist/formatter/comments.d.ts.map +1 -1
  196. package/dist/formatter/comments.js +13 -0
  197. package/dist/formatter/comments.js.map +1 -1
  198. package/dist/formatter/index.d.ts +9 -0
  199. package/dist/formatter/index.d.ts.map +1 -1
  200. package/dist/formatter/index.js +215 -5
  201. package/dist/formatter/index.js.map +1 -1
  202. package/dist/formatter/operator-precedence.d.ts.map +1 -1
  203. package/dist/formatter/operator-precedence.js.map +1 -1
  204. package/dist/formatter/prettier.d.ts.map +1 -1
  205. package/dist/formatter/prettier.js.map +1 -1
  206. package/dist/index.d.ts +3 -0
  207. package/dist/index.d.ts.map +1 -1
  208. package/dist/index.js +3 -0
  209. package/dist/index.js.map +1 -1
  210. package/dist/interop/callback.d.ts.map +1 -1
  211. package/dist/interop/callback.js.map +1 -1
  212. package/dist/interop/js.d.ts.map +1 -1
  213. package/dist/interop/js.js.map +1 -1
  214. package/dist/interop/record.d.ts.map +1 -1
  215. package/dist/interop/record.js.map +1 -1
  216. package/dist/interop/valibot.d.ts.map +1 -1
  217. package/dist/interop/valibot.js.map +1 -1
  218. package/dist/interop/zod.d.ts.map +1 -1
  219. package/dist/interop/zod.js.map +1 -1
  220. package/dist/lexer/lexer.d.ts +1 -0
  221. package/dist/lexer/lexer.d.ts.map +1 -1
  222. package/dist/lexer/lexer.js +26 -10
  223. package/dist/lexer/lexer.js.map +1 -1
  224. package/dist/lexer/tokens.d.ts.map +1 -1
  225. package/dist/lexer/tokens.js.map +1 -1
  226. package/dist/lsp/code-action-worker.d.ts.map +1 -1
  227. package/dist/lsp/code-action-worker.js.map +1 -1
  228. package/dist/lsp/completion.d.ts +25 -0
  229. package/dist/lsp/completion.d.ts.map +1 -1
  230. package/dist/lsp/completion.js +1114 -51
  231. package/dist/lsp/completion.js.map +1 -1
  232. package/dist/lsp/definition.d.ts +2 -0
  233. package/dist/lsp/definition.d.ts.map +1 -1
  234. package/dist/lsp/definition.js +52 -58
  235. package/dist/lsp/definition.js.map +1 -1
  236. package/dist/lsp/diagnostics-worker.d.ts.map +1 -1
  237. package/dist/lsp/diagnostics-worker.js +1 -1
  238. package/dist/lsp/diagnostics-worker.js.map +1 -1
  239. package/dist/lsp/docs.d.ts +1 -1
  240. package/dist/lsp/docs.d.ts.map +1 -1
  241. package/dist/lsp/docs.js +4 -3
  242. package/dist/lsp/docs.js.map +1 -1
  243. package/dist/lsp/error-channel.d.ts.map +1 -1
  244. package/dist/lsp/error-channel.js.map +1 -1
  245. package/dist/lsp/hover.d.ts +5 -1
  246. package/dist/lsp/hover.d.ts.map +1 -1
  247. package/dist/lsp/hover.js +1016 -46
  248. package/dist/lsp/hover.js.map +1 -1
  249. package/dist/lsp/imports.d.ts +2 -0
  250. package/dist/lsp/imports.d.ts.map +1 -1
  251. package/dist/lsp/imports.js +45 -21
  252. package/dist/lsp/imports.js.map +1 -1
  253. package/dist/lsp/index.d.ts.map +1 -1
  254. package/dist/lsp/index.js.map +1 -1
  255. package/dist/lsp/inlay-hints.d.ts.map +1 -1
  256. package/dist/lsp/inlay-hints.js.map +1 -1
  257. package/dist/lsp/interop-rename.d.ts.map +1 -1
  258. package/dist/lsp/interop-rename.js.map +1 -1
  259. package/dist/lsp/match-arms.d.ts.map +1 -1
  260. package/dist/lsp/match-arms.js.map +1 -1
  261. package/dist/lsp/navigation.d.ts +1 -1
  262. package/dist/lsp/navigation.d.ts.map +1 -1
  263. package/dist/lsp/navigation.js +30 -12
  264. package/dist/lsp/navigation.js.map +1 -1
  265. package/dist/lsp/parsed-documents.d.ts.map +1 -1
  266. package/dist/lsp/parsed-documents.js.map +1 -1
  267. package/dist/lsp/range-format.d.ts +4 -0
  268. package/dist/lsp/range-format.d.ts.map +1 -0
  269. package/dist/lsp/range-format.js +88 -0
  270. package/dist/lsp/range-format.js.map +1 -0
  271. package/dist/lsp/rename-worker.d.ts.map +1 -1
  272. package/dist/lsp/rename-worker.js.map +1 -1
  273. package/dist/lsp/schema-import-hover.d.ts +8 -0
  274. package/dist/lsp/schema-import-hover.d.ts.map +1 -0
  275. package/dist/lsp/schema-import-hover.js +52 -0
  276. package/dist/lsp/schema-import-hover.js.map +1 -0
  277. package/dist/lsp/server.d.ts +3 -1
  278. package/dist/lsp/server.d.ts.map +1 -1
  279. package/dist/lsp/server.js +73 -48
  280. package/dist/lsp/server.js.map +1 -1
  281. package/dist/lsp/signature-help.d.ts +6 -0
  282. package/dist/lsp/signature-help.d.ts.map +1 -0
  283. package/dist/lsp/signature-help.js +183 -0
  284. package/dist/lsp/signature-help.js.map +1 -0
  285. package/dist/lsp/thunk-pipeline.d.ts.map +1 -1
  286. package/dist/lsp/thunk-pipeline.js.map +1 -1
  287. package/dist/lsp/validation.d.ts.map +1 -1
  288. package/dist/lsp/validation.js +3 -2
  289. package/dist/lsp/validation.js.map +1 -1
  290. package/dist/lsp/workspace.d.ts +3 -1
  291. package/dist/lsp/workspace.d.ts.map +1 -1
  292. package/dist/lsp/workspace.js +66 -10
  293. package/dist/lsp/workspace.js.map +1 -1
  294. package/dist/parser/declarations.d.ts.map +1 -1
  295. package/dist/parser/declarations.js +22 -1
  296. package/dist/parser/declarations.js.map +1 -1
  297. package/dist/parser/errors.d.ts.map +1 -1
  298. package/dist/parser/errors.js.map +1 -1
  299. package/dist/parser/jsx.d.ts.map +1 -1
  300. package/dist/parser/jsx.js.map +1 -1
  301. package/dist/parser/operator-expressions.d.ts.map +1 -1
  302. package/dist/parser/operator-expressions.js.map +1 -1
  303. package/dist/parser/parser.d.ts.map +1 -1
  304. package/dist/parser/parser.js.map +1 -1
  305. package/dist/parser/patterns.d.ts.map +1 -1
  306. package/dist/parser/patterns.js.map +1 -1
  307. package/dist/parser/pipeline-expressions.d.ts.map +1 -1
  308. package/dist/parser/pipeline-expressions.js.map +1 -1
  309. package/dist/parser/scope.d.ts.map +1 -1
  310. package/dist/parser/scope.js.map +1 -1
  311. package/dist/parser/statements.d.ts.map +1 -1
  312. package/dist/parser/statements.js.map +1 -1
  313. package/dist/parser/types.d.ts.map +1 -1
  314. package/dist/parser/types.js.map +1 -1
  315. package/dist/plugins/bun-preload.d.ts.map +1 -1
  316. package/dist/plugins/bun-preload.js.map +1 -1
  317. package/dist/plugins/bun.d.ts +2 -18
  318. package/dist/plugins/bun.d.ts.map +1 -1
  319. package/dist/plugins/bun.js +5 -30
  320. package/dist/plugins/bun.js.map +1 -1
  321. package/dist/plugins/esbuild.d.ts +1 -1
  322. package/dist/plugins/esbuild.d.ts.map +1 -1
  323. package/dist/plugins/esbuild.js +10 -36
  324. package/dist/plugins/esbuild.js.map +1 -1
  325. package/dist/plugins/server-boundary.d.ts +14 -0
  326. package/dist/plugins/server-boundary.d.ts.map +1 -0
  327. package/dist/plugins/server-boundary.js +25 -0
  328. package/dist/plugins/server-boundary.js.map +1 -0
  329. package/dist/plugins/type-view.d.ts.map +1 -1
  330. package/dist/plugins/type-view.js +5 -3
  331. package/dist/plugins/type-view.js.map +1 -1
  332. package/dist/plugins/vite.d.ts +2 -18
  333. package/dist/plugins/vite.d.ts.map +1 -1
  334. package/dist/plugins/vite.js +4 -29
  335. package/dist/plugins/vite.js.map +1 -1
  336. package/dist/testing/index.d.ts.map +1 -1
  337. package/dist/testing/index.js.map +1 -1
  338. package/dist/tooling/doc.d.ts.map +1 -1
  339. package/dist/tooling/doc.js.map +1 -1
  340. package/dist/tooling/idiomatic.d.ts.map +1 -1
  341. package/dist/tooling/idiomatic.js.map +1 -1
  342. package/dist/tooling/pipeline-style.d.ts.map +1 -1
  343. package/dist/tooling/pipeline-style.js.map +1 -1
  344. package/dist/version.d.ts.map +1 -1
  345. package/dist/version.js.map +1 -1
  346. package/package.json +13 -6
  347. package/src/cli/build-watch.ts +10 -29
  348. package/src/cli/build.ts +9 -60
  349. package/src/cli/check-policy.ts +54 -0
  350. package/src/cli/check.ts +19 -31
  351. package/src/cli/commands.ts +13 -0
  352. package/src/cli/doctor.ts +10 -7
  353. package/src/cli/index.ts +3 -0
  354. package/src/cli/init.ts +66 -21
  355. package/src/cli/query.ts +191 -0
  356. package/src/cli/run.ts +5 -30
  357. package/src/cli/tsc.ts +10 -8
  358. package/src/compiler/boolean-operators.ts +11 -2
  359. package/src/compiler/check.ts +152 -180
  360. package/src/compiler/diagnostics-json.ts +1205 -0
  361. package/src/compiler/escape-audit.ts +913 -0
  362. package/src/compiler/modules/output-plan.ts +11 -9
  363. package/src/compiler/modules/resolution.ts +2 -1
  364. package/src/compiler/modules/source-files.ts +13 -0
  365. package/src/compiler/numeric-comparisons.ts +14 -8
  366. package/src/compiler/pipelines/resolution.ts +30 -26
  367. package/src/compiler/project-config.ts +30 -19
  368. package/src/compiler/query.ts +1177 -0
  369. package/src/compiler/rules/resource-escape.ts +223 -0
  370. package/src/compiler/rules/resource-providers.ts +293 -0
  371. package/src/compiler/source-map.ts +3 -7
  372. package/src/compiler/type-view-paths.ts +10 -0
  373. package/src/compiler/typescript-context.ts +6 -7
  374. package/src/emitter/assemblyscript.ts +101 -147
  375. package/src/emitter/emitter.ts +13 -1
  376. package/src/emitter/statements.ts +2 -0
  377. package/src/formatter/comments.ts +14 -0
  378. package/src/formatter/index.ts +299 -4
  379. package/src/index.ts +3 -0
  380. package/src/lexer/lexer.ts +39 -20
  381. package/src/lsp/completion.ts +1452 -66
  382. package/src/lsp/definition.ts +50 -58
  383. package/src/lsp/diagnostics-worker.ts +1 -4
  384. package/src/lsp/docs.ts +4 -3
  385. package/src/lsp/hover.ts +1465 -44
  386. package/src/lsp/imports.ts +75 -22
  387. package/src/lsp/navigation.ts +41 -22
  388. package/src/lsp/range-format.ts +102 -0
  389. package/src/lsp/schema-import-hover.ts +76 -0
  390. package/src/lsp/server.ts +99 -69
  391. package/src/lsp/signature-help.ts +226 -0
  392. package/src/lsp/validation.ts +3 -2
  393. package/src/lsp/workspace.ts +63 -9
  394. package/src/parser/declarations.ts +27 -1
  395. package/src/plugins/bun.ts +14 -66
  396. package/src/plugins/esbuild.ts +16 -55
  397. package/src/plugins/server-boundary.ts +41 -0
  398. package/src/plugins/type-view.ts +11 -3
  399. package/src/plugins/vite.ts +12 -62
  400. package/dist/Widget.tsx +0 -9
  401. package/dist/cli/output-collisions.d.ts +0 -2
  402. package/dist/cli/output-collisions.d.ts.map +0 -1
  403. package/dist/cli/output-collisions.js +0 -39
  404. package/dist/cli/output-collisions.js.map +0 -1
  405. package/dist/compiler/imported-record-functions.d.ts +0 -4
  406. package/dist/compiler/imported-record-functions.d.ts.map +0 -1
  407. package/dist/compiler/imported-record-functions.js +0 -706
  408. package/dist/compiler/imported-record-functions.js.map +0 -1
  409. package/dist/compiler/imported-schemas.d.ts +0 -21
  410. package/dist/compiler/imported-schemas.d.ts.map +0 -1
  411. package/dist/compiler/imported-schemas.js +0 -461
  412. package/dist/compiler/imported-schemas.js.map +0 -1
  413. package/dist/compiler/module-resolution.d.ts +0 -6
  414. package/dist/compiler/module-resolution.d.ts.map +0 -1
  415. package/dist/compiler/module-resolution.js +0 -44
  416. package/dist/compiler/module-resolution.js.map +0 -1
  417. package/dist/compiler/pipeline-companions.d.ts +0 -18
  418. package/dist/compiler/pipeline-companions.d.ts.map +0 -1
  419. package/dist/compiler/pipeline-companions.js +0 -1042
  420. package/dist/compiler/pipeline-companions.js.map +0 -1
  421. package/dist/compiler/providers.d.ts +0 -4
  422. package/dist/compiler/providers.d.ts.map +0 -1
  423. package/dist/compiler/providers.js +0 -101
  424. package/dist/compiler/providers.js.map +0 -1
  425. package/dist/emitter/pipeline-catalog.d.ts +0 -15
  426. package/dist/emitter/pipeline-catalog.d.ts.map +0 -1
  427. package/dist/emitter/pipeline-catalog.js +0 -55
  428. package/dist/emitter/pipeline-catalog.js.map +0 -1
  429. package/dist/emitter/pipeline-resolution.d.ts +0 -38
  430. package/dist/emitter/pipeline-resolution.d.ts.map +0 -1
  431. package/dist/emitter/pipeline-resolution.js +0 -571
  432. package/dist/emitter/pipeline-resolution.js.map +0 -1
  433. package/dist/interop/index.d.ts +0 -6
  434. package/dist/interop/index.d.ts.map +0 -1
  435. package/dist/interop/index.js +0 -6
  436. package/dist/interop/index.js.map +0 -1
  437. package/dist/math.ts +0 -1
  438. package/dist/parser/index.d.ts +0 -9
  439. package/dist/parser/index.d.ts.map +0 -1
  440. package/dist/parser/index.js +0 -9
  441. package/dist/parser/index.js.map +0 -1
  442. package/dist/service.ts +0 -3
  443. package/dist/service.ts.map +0 -1
  444. package/dist/tooling/migrate.d.ts +0 -62
  445. package/dist/tooling/migrate.d.ts.map +0 -1
  446. package/dist/tooling/migrate.js +0 -608
  447. package/dist/tooling/migrate.js.map +0 -1
@@ -1,5 +1,10 @@
1
1
  import { checkControlFlowRules } from "./rules/control-flow.js";
2
2
  import { checkModuleScopeRefs } from "./rules/module-scope-refs.js";
3
+ import { findScopedResourceEscape } from "./rules/resource-escape.js";
4
+ import {
5
+ createResourceProviderResolver,
6
+ effectImportNames,
7
+ } from "./rules/resource-providers.js";
3
8
  import { isEntryModule, getEffectRunnerName } from "./entry-rules.js";
4
9
  export { isEntryModule } from "./entry-rules.js";
5
10
  import { checkCapturedMutInEffect } from "./effect-mutation-rule.js";
@@ -1970,56 +1975,36 @@ export const typeCheckVirtualFiles = (
1970
1975
  return false;
1971
1976
  };
1972
1977
 
1978
+ let succeedCallee: AstInspectNode | null = null;
1979
+ let succeedValue: AstInspectNode | null = null;
1973
1980
  if (node.kind === "CallExpression") {
1974
- const callee = astChild(node, "callee");
1975
- const calleeMember = getMemberNames(callee);
1976
- const isSucceed =
1977
- (calleeMember?.object === "Effect" &&
1978
- calleeMember.property === "succeed") ||
1979
- (callee?.kind === "Identifier" &&
1980
- astName(callee) === "succeed");
1981
- const args = astChildren(node, "args");
1982
- if (isSucceed && args.length > 0) {
1983
- const arg = args[0];
1984
- if (
1985
- (arg.kind === "CallExpression" &&
1986
- !isPureDataConstructor(arg)) ||
1987
- arg.kind === "NewExpression"
1988
- ) {
1989
- addAstDiag(
1990
- arg.span || node.span,
1991
- "EAGER_SUCCEED",
1992
- "`Effect.succeed` evaluates its argument eagerly at construction time. If the expression contains function calls or side effects, use `Effect.sync(() => ...)` for deferred evaluation.",
1993
- "warning",
1994
- "Passing a function call or constructor to Effect.succeed executes it immediately upon effect construction, not when the effect runs.",
1995
- "Use `Effect.sync(() => ...)` or `Effect.try(...)` to defer evaluation until the effect is executed.",
1996
- );
1997
- }
1998
- }
1981
+ succeedCallee = astChild(node, "callee");
1982
+ succeedValue = astChildren(node, "args")[0] ?? null;
1999
1983
  } else if (node.kind === "PipelineExpression") {
2000
- const r = astChild(node, "right");
2001
- const rMember = getMemberNames(r);
2002
- const isSucceed =
2003
- (rMember?.object === "Effect" &&
2004
- rMember.property === "succeed") ||
2005
- (r?.kind === "Identifier" && astName(r) === "succeed");
2006
- if (isSucceed) {
2007
- const left = astChild(node, "left");
2008
- if (
2009
- (left?.kind === "CallExpression" &&
2010
- !isPureDataConstructor(left)) ||
2011
- left?.kind === "NewExpression"
2012
- ) {
2013
- addAstDiag(
2014
- left.span || node.span,
2015
- "EAGER_SUCCEED",
2016
- "`Effect.succeed` evaluates its argument eagerly at construction time. If the expression contains function calls or side effects, use `Effect.sync(() => ...)` for deferred evaluation.",
2017
- "warning",
2018
- "Passing a function call or constructor to Effect.succeed executes it immediately upon effect construction, not when the effect runs.",
2019
- "Use `Effect.sync(() => ...)` or `Effect.try(...)` to defer evaluation until the effect is executed.",
2020
- );
2021
- }
2022
- }
1984
+ succeedCallee = astChild(node, "right");
1985
+ succeedValue = astChild(node, "left");
1986
+ }
1987
+ const succeedMember = getMemberNames(succeedCallee);
1988
+ const isSucceed =
1989
+ (succeedMember?.object === "Effect" &&
1990
+ succeedMember.property === "succeed") ||
1991
+ (succeedCallee?.kind === "Identifier" &&
1992
+ astName(succeedCallee) === "succeed");
1993
+ if (
1994
+ isSucceed &&
1995
+ succeedValue &&
1996
+ ((succeedValue.kind === "CallExpression" &&
1997
+ !isPureDataConstructor(succeedValue)) ||
1998
+ succeedValue.kind === "NewExpression")
1999
+ ) {
2000
+ addAstDiag(
2001
+ succeedValue.span || node.span,
2002
+ "EAGER_SUCCEED",
2003
+ "`Effect.succeed` evaluates its argument eagerly at construction time. If the expression contains function calls or side effects, use `Effect.sync(() => ...)` for deferred evaluation.",
2004
+ "warning",
2005
+ "Passing a function call or constructor to Effect.succeed executes it immediately upon effect construction, not when the effect runs.",
2006
+ "Use `Effect.sync(() => ...)` or `Effect.try(...)` to defer evaluation until the effect is executed.",
2007
+ );
2023
2008
  }
2024
2009
 
2025
2010
  if (
@@ -2100,8 +2085,85 @@ export const typeCheckVirtualFiles = (
2100
2085
  (finalExpr?.kind === "Identifier" ||
2101
2086
  finalExpr?.kind === "UpperIdentifier") &&
2102
2087
  astName(finalExpr) === "Void";
2088
+ const isIndependentLiteral = (
2089
+ expr: AstInspectNode | null,
2090
+ ): boolean => {
2091
+ if (!expr) return false;
2092
+ if (
2093
+ [
2094
+ "NumberLiteral",
2095
+ "StringLiteral",
2096
+ "BooleanLiteral",
2097
+ "TemplateLiteral",
2098
+ ].includes(expr.kind)
2099
+ )
2100
+ return true;
2101
+ if (expr.kind === "ArrayExpression")
2102
+ return astChildren(expr, "elements").every(
2103
+ isIndependentLiteral,
2104
+ );
2105
+ if (expr.kind === "RecordExpression")
2106
+ return astChildren(expr, "entries").every(
2107
+ (entry) =>
2108
+ (entry.kind === "FieldEntry" ||
2109
+ entry.kind === "DotPathEntry") &&
2110
+ isIndependentLiteral(astChild(entry, "value")),
2111
+ );
2112
+ return false;
2113
+ };
2103
2114
 
2104
- if (!isUnit) {
2115
+ if (!isUnit && !isIndependentLiteral(finalExpr)) {
2116
+ // Function parameters shadow module bindings, including
2117
+ // inside nested functions. Never follow a shadowed name.
2118
+ const shadowed = new Set<string>();
2119
+ const collectEnclosingParams = (
2120
+ candidate: AstInspectNode,
2121
+ ): void => {
2122
+ if (
2123
+ !candidate.span ||
2124
+ !node.span ||
2125
+ candidate.span.start.offset > node.span.start.offset ||
2126
+ candidate.span.end.offset < node.span.end.offset
2127
+ )
2128
+ return;
2129
+ if (candidate.kind === "FunctionExpression") {
2130
+ for (const param of astChildren(candidate, "params")) {
2131
+ for (const name of collectPatternVars(
2132
+ astChild(param, "name"),
2133
+ ))
2134
+ shadowed.add(name);
2135
+ }
2136
+ }
2137
+ for (const [key, value] of Object.entries(
2138
+ asRecord(candidate),
2139
+ )) {
2140
+ if (key === "span") continue;
2141
+ if (Array.isArray(value)) {
2142
+ for (const item of value)
2143
+ if (isAstNode(item)) collectEnclosingParams(item);
2144
+ } else if (isAstNode(value))
2145
+ collectEnclosingParams(value);
2146
+ }
2147
+ };
2148
+ if (meta.ast) collectEnclosingParams(meta.ast);
2149
+ for (const statement of astChildren(node, "body")) {
2150
+ if (
2151
+ statement.kind === "BindingDeclaration" ||
2152
+ statement.kind === "EffectBindStatement"
2153
+ ) {
2154
+ for (const name of collectPatternVars(
2155
+ astChild(statement, "id"),
2156
+ ))
2157
+ shadowed.add(name);
2158
+ }
2159
+ }
2160
+ const imports = effectImportNames(meta.ast);
2161
+ for (const name of shadowed) {
2162
+ imports.effect.delete(name);
2163
+ imports.scope.delete(name);
2164
+ imports.acquire.delete(name);
2165
+ imports.finalizer.delete(name);
2166
+ }
2105
2167
  const findFinalizer = (
2106
2168
  n: unknown,
2107
2169
  allowAcquire: boolean,
@@ -2121,7 +2183,8 @@ export const typeCheckVirtualFiles = (
2121
2183
  callee.property as { name?: string } | undefined
2122
2184
  )?.name;
2123
2185
  if (
2124
- (obj === "Effect" || obj === "Scope") &&
2186
+ !!obj &&
2187
+ (imports.effect.has(obj) || imports.scope.has(obj)) &&
2125
2188
  (prop === "addFinalizer" ||
2126
2189
  (allowAcquire && prop === "acquireRelease"))
2127
2190
  ) {
@@ -2133,8 +2196,10 @@ export const typeCheckVirtualFiles = (
2133
2196
  } else if (callee?.kind === "Identifier") {
2134
2197
  const calleeName = (callee as { name?: string }).name;
2135
2198
  if (
2136
- calleeName === "addFinalizer" ||
2137
- (allowAcquire && calleeName === "acquireRelease")
2199
+ (!!calleeName && imports.finalizer.has(calleeName)) ||
2200
+ (allowAcquire &&
2201
+ !!calleeName &&
2202
+ imports.acquire.has(calleeName))
2138
2203
  ) {
2139
2204
  return {
2140
2205
  name: calleeName,
@@ -2175,10 +2240,11 @@ export const typeCheckVirtualFiles = (
2175
2240
  detectedCall = findFinalizer(finalExpr, false);
2176
2241
  }
2177
2242
 
2178
- // Follow simple local aliases and providers only
2179
- // when the acquired value itself is returned from this scope.
2180
- // Derived values (e.g. resource.fd) remain valid consumers.
2181
- if (!detectedCall && finalExpr?.kind === "Identifier") {
2243
+ // Follow resources through aliases, returned containers and
2244
+ // captured closures. An eagerly read property can be an
2245
+ // independent value, but a closure reading it captures the
2246
+ // resource itself for later use.
2247
+ if (!detectedCall && finalExpr) {
2182
2248
  const bindings = new Map<string, AstInspectNode>();
2183
2249
  for (const item of meta.ast?.body ?? []) {
2184
2250
  const decl =
@@ -2192,39 +2258,6 @@ export const typeCheckVirtualFiles = (
2192
2258
  bindings.set(decl.id.name, decl.init);
2193
2259
  }
2194
2260
  }
2195
- // Function parameters shadow module bindings, including
2196
- // inside nested functions. Never follow a shadowed name.
2197
- const shadowed = new Set<string>();
2198
- const collectEnclosingParams = (
2199
- candidate: AstInspectNode,
2200
- ): void => {
2201
- if (
2202
- !candidate.span ||
2203
- !node.span ||
2204
- candidate.span.start.offset > node.span.start.offset ||
2205
- candidate.span.end.offset < node.span.end.offset
2206
- )
2207
- return;
2208
- if (candidate.kind === "FunctionExpression") {
2209
- for (const param of astChildren(candidate, "params")) {
2210
- for (const name of collectPatternVars(
2211
- astChild(param, "name"),
2212
- ))
2213
- shadowed.add(name);
2214
- }
2215
- }
2216
- for (const [key, value] of Object.entries(
2217
- asRecord(candidate),
2218
- )) {
2219
- if (key === "span") continue;
2220
- if (Array.isArray(value)) {
2221
- for (const item of value)
2222
- if (isAstNode(item)) collectEnclosingParams(item);
2223
- } else if (isAstNode(value))
2224
- collectEnclosingParams(value);
2225
- }
2226
- };
2227
- if (meta.ast) collectEnclosingParams(meta.ast);
2228
2261
  for (const name of shadowed) bindings.delete(name);
2229
2262
  for (const stmt of astChildren(node, "body")) {
2230
2263
  if (stmt.kind === "BindingDeclaration") {
@@ -2233,96 +2266,33 @@ export const typeCheckVirtualFiles = (
2233
2266
  if (name && init) bindings.set(name, init);
2234
2267
  }
2235
2268
  }
2236
- const resolveReturned = (
2237
- name: string | undefined,
2238
- seen: Set<string>,
2239
- ): AstInspectNode | undefined => {
2240
- if (!name || seen.has(name)) return undefined;
2241
- const stmts = astChildren(node, "body");
2242
- const bind = stmts.find(
2243
- (stmt) =>
2244
- stmt.kind === "EffectBindStatement" &&
2245
- astName(astChild(stmt, "id")) === name,
2246
- );
2247
- if (bind) return bind;
2248
- const alias = stmts.find(
2249
- (stmt) =>
2250
- stmt.kind === "BindingDeclaration" &&
2251
- astName(astChild(stmt, "id")) === name,
2252
- );
2253
- const init = astChild(alias, "init");
2254
- return init?.kind === "Identifier"
2255
- ? resolveReturned(
2256
- astName(init),
2257
- new Set([...seen, name]),
2258
- )
2259
- : undefined;
2260
- };
2261
- const bind = resolveReturned(astName(finalExpr), new Set());
2262
- const source = astChild(bind, "effect");
2263
- const followsAcquire = (
2264
- expr: AstInspectNode | null,
2265
- seen: Set<string>,
2266
- ): boolean => {
2267
- if (!expr) return false;
2268
- if (expr.kind === "Identifier") {
2269
- const name = astName(expr);
2270
- if (!name || seen.has(name)) return false;
2271
- const next = bindings.get(name);
2272
- if (!next) return false;
2273
- return followsAcquire(next, new Set([...seen, name]));
2274
- }
2275
- if (expr.kind === "FunctionExpression") {
2276
- const nestedSeen = new Set(seen);
2277
- for (const param of astChildren(expr, "params")) {
2278
- for (const name of collectPatternVars(
2279
- astChild(param, "name"),
2280
- ))
2281
- nestedSeen.add(name);
2282
- }
2283
- return followsAcquire(
2284
- astChild(expr, "body"),
2285
- nestedSeen,
2286
- );
2287
- }
2288
- if (expr.kind === "BlockStatement") {
2289
- return followsAcquire(
2290
- astChild(expr, "finalExpression"),
2291
- seen,
2269
+ const programs = new Map<string, Program>();
2270
+ for (const entry of virtualSourceMap.values()) {
2271
+ if (entry.ast)
2272
+ programs.set(
2273
+ path.resolve(cwd, entry.funPath),
2274
+ entry.ast,
2292
2275
  );
2293
- }
2294
- if (
2295
- expr.kind === "EffectBlockExpression" &&
2296
- astBool(expr, "unscoped")
2297
- ) {
2298
- const result = astChild(expr, "finalExpression");
2299
- if (result?.kind !== "Identifier") return false;
2300
- const bind = astChildren(expr, "body").find(
2301
- (stmt) =>
2302
- stmt.kind === "EffectBindStatement" &&
2303
- astName(astChild(stmt, "id")) === astName(result),
2304
- );
2305
- return followsAcquire(astChild(bind, "effect"), seen);
2306
- }
2307
- if (expr.kind === "CallExpression") {
2308
- const callee = astChild(expr, "callee");
2309
- const member = getMemberNames(callee);
2310
- if (
2311
- (member?.object === "Effect" &&
2312
- member.property === "acquireRelease") ||
2313
- (callee?.kind === "Identifier" &&
2314
- astName(callee) === "acquireRelease")
2315
- )
2316
- return true;
2317
- if (callee?.kind === "Identifier") {
2318
- return followsAcquire(callee, seen);
2319
- }
2320
- }
2321
- return false;
2322
- };
2323
- if (source && followsAcquire(source, new Set())) {
2276
+ }
2277
+ const followsAcquire = createResourceProviderResolver({
2278
+ rootFile: path.resolve(cwd, meta.funPath),
2279
+ rootAst: meta.ast!,
2280
+ rootBindings: bindings,
2281
+ rootImports: imports,
2282
+ shadowed,
2283
+ sources: virtualSources,
2284
+ programs,
2285
+ });
2286
+ const source = findScopedResourceEscape(
2287
+ node,
2288
+ finalExpr,
2289
+ sf,
2290
+ checker,
2291
+ followsAcquire,
2292
+ );
2293
+ if (source) {
2324
2294
  detectedCall = {
2325
- name: "Effect.acquireRelease (through an alias)",
2295
+ name: "a scope-bound provider",
2326
2296
  span: source.span ?? node.span!,
2327
2297
  };
2328
2298
  }
@@ -2333,10 +2303,12 @@ export const typeCheckVirtualFiles = (
2333
2303
  addAstDiag(
2334
2304
  callInfo.span,
2335
2305
  "PREMATURE_FINALIZER_CLOSE",
2336
- `Finalizer registered with '${callInfo.name}' in a scoped effect block will execute immediately when this function returns, closing the returned resource.`,
2306
+ callInfo.name === "a scope-bound provider"
2307
+ ? "A scope-bound resource escapes this effect through the returned value. Its scope closes before the caller can use it."
2308
+ : `Finalizer registered with '${callInfo.name}' in a scoped effect block will execute immediately when this function returns, closing the returned resource or a resource it captures.`,
2337
2309
  "error",
2338
- "By default, 'effect' blocks create a scoped boundary ('Effect.scoped'). Any finalizer registered via 'Effect.addFinalizer' or 'Effect.acquireRelease' executes as soon as the block returns, tearing down the resource before the caller can use it.",
2339
- "Change 'effect' to 'effect (unscoped)' so the resource's lifetime is bound to the caller's scope, or return 'Void' if all work is completed inside this block.",
2310
+ "By default, 'effect' blocks create a scoped boundary ('Effect.scoped'). Scope-bound resources are finalized as soon as the block returns, before the caller can use them.",
2311
+ "Change 'effect' to 'effect (unscoped)' so the resource's lifetime is bound to the caller's scope, or finish using the resource inside this block and return an independent value.",
2340
2312
  );
2341
2313
  }
2342
2314
  }