@soundscript/soundscript 0.1.12 → 0.1.15

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 (441) hide show
  1. package/package.json +15 -6
  2. package/project-transform/index.js +2 -0
  3. package/project-transform/index.ts +8 -0
  4. package/project-transform/src/annotation_syntax.js +948 -0
  5. package/project-transform/src/annotation_syntax.ts +1217 -0
  6. package/project-transform/src/build_package.js +475 -0
  7. package/project-transform/src/build_package.ts +683 -0
  8. package/project-transform/src/bundled/portable-web-globals.d.ts +153 -0
  9. package/project-transform/src/bundled/runtime_externs.js +220 -0
  10. package/project-transform/src/bundled/runtime_externs.ts +237 -0
  11. package/project-transform/src/bundled/sound-libs/lib.decorators.d.ts +385 -0
  12. package/project-transform/src/bundled/sound-libs/lib.decorators.legacy.d.ts +22 -0
  13. package/project-transform/src/bundled/sound-libs/lib.dom.asynciterable.d.ts +42 -0
  14. package/project-transform/src/bundled/sound-libs/lib.dom.d.ts +39440 -0
  15. package/project-transform/src/bundled/sound-libs/lib.es2015.collection.d.ts +149 -0
  16. package/project-transform/src/bundled/sound-libs/lib.es2015.core.d.ts +657 -0
  17. package/project-transform/src/bundled/sound-libs/lib.es2015.d.ts +28 -0
  18. package/project-transform/src/bundled/sound-libs/lib.es2015.generator.d.ts +77 -0
  19. package/project-transform/src/bundled/sound-libs/lib.es2015.iterable.d.ts +616 -0
  20. package/project-transform/src/bundled/sound-libs/lib.es2015.promise.d.ts +80 -0
  21. package/project-transform/src/bundled/sound-libs/lib.es2015.proxy.d.ts +128 -0
  22. package/project-transform/src/bundled/sound-libs/lib.es2015.reflect.d.ts +144 -0
  23. package/project-transform/src/bundled/sound-libs/lib.es2015.symbol.d.ts +46 -0
  24. package/project-transform/src/bundled/sound-libs/lib.es2015.symbol.wellknown.d.ts +170 -0
  25. package/project-transform/src/bundled/sound-libs/lib.es2016.array.include.d.ts +116 -0
  26. package/project-transform/src/bundled/sound-libs/lib.es2016.d.ts +21 -0
  27. package/project-transform/src/bundled/sound-libs/lib.es2017.arraybuffer.d.ts +21 -0
  28. package/project-transform/src/bundled/sound-libs/lib.es2017.d.ts +26 -0
  29. package/project-transform/src/bundled/sound-libs/lib.es2017.date.d.ts +31 -0
  30. package/project-transform/src/bundled/sound-libs/lib.es2017.object.d.ts +49 -0
  31. package/project-transform/src/bundled/sound-libs/lib.es2017.string.d.ts +45 -0
  32. package/project-transform/src/bundled/sound-libs/lib.es2017.typedarrays.d.ts +53 -0
  33. package/project-transform/src/bundled/sound-libs/lib.es2018.asyncgenerator.d.ts +77 -0
  34. package/project-transform/src/bundled/sound-libs/lib.es2018.asynciterable.d.ts +57 -0
  35. package/project-transform/src/bundled/sound-libs/lib.es2018.d.ts +24 -0
  36. package/project-transform/src/bundled/sound-libs/lib.es2018.promise.d.ts +30 -0
  37. package/project-transform/src/bundled/sound-libs/lib.es2018.regexp.d.ts +37 -0
  38. package/project-transform/src/bundled/sound-libs/lib.es2019.array.d.ts +79 -0
  39. package/project-transform/src/bundled/sound-libs/lib.es2019.d.ts +24 -0
  40. package/project-transform/src/bundled/sound-libs/lib.es2019.object.d.ts +47 -0
  41. package/project-transform/src/bundled/sound-libs/lib.es2019.string.d.ts +37 -0
  42. package/project-transform/src/bundled/sound-libs/lib.es2019.symbol.d.ts +24 -0
  43. package/project-transform/src/bundled/sound-libs/lib.es2020.bigint.d.ts +765 -0
  44. package/project-transform/src/bundled/sound-libs/lib.es2020.d.ts +27 -0
  45. package/project-transform/src/bundled/sound-libs/lib.es2020.date.d.ts +42 -0
  46. package/project-transform/src/bundled/sound-libs/lib.es2020.number.d.ts +28 -0
  47. package/project-transform/src/bundled/sound-libs/lib.es2020.promise.d.ts +49 -0
  48. package/project-transform/src/bundled/sound-libs/lib.es2020.string.d.ts +44 -0
  49. package/project-transform/src/bundled/sound-libs/lib.es2020.symbol.wellknown.d.ts +41 -0
  50. package/project-transform/src/bundled/sound-libs/lib.es2021.d.ts +23 -0
  51. package/project-transform/src/bundled/sound-libs/lib.es2021.promise.d.ts +48 -0
  52. package/project-transform/src/bundled/sound-libs/lib.es2021.string.d.ts +33 -0
  53. package/project-transform/src/bundled/sound-libs/lib.es2021.weakref.d.ts +78 -0
  54. package/project-transform/src/bundled/sound-libs/lib.es2022.array.d.ts +121 -0
  55. package/project-transform/src/bundled/sound-libs/lib.es2022.d.ts +25 -0
  56. package/project-transform/src/bundled/sound-libs/lib.es2022.error.d.ts +75 -0
  57. package/project-transform/src/bundled/sound-libs/lib.es2022.object.d.ts +26 -0
  58. package/project-transform/src/bundled/sound-libs/lib.es2022.regexp.d.ts +39 -0
  59. package/project-transform/src/bundled/sound-libs/lib.es2022.string.d.ts +25 -0
  60. package/project-transform/src/bundled/sound-libs/lib.es2023.array.d.ts +924 -0
  61. package/project-transform/src/bundled/sound-libs/lib.es2023.collection.d.ts +21 -0
  62. package/project-transform/src/bundled/sound-libs/lib.es2023.d.ts +22 -0
  63. package/project-transform/src/bundled/sound-libs/lib.es2024.arraybuffer.d.ts +65 -0
  64. package/project-transform/src/bundled/sound-libs/lib.es2024.collection.d.ts +29 -0
  65. package/project-transform/src/bundled/sound-libs/lib.es2024.d.ts +26 -0
  66. package/project-transform/src/bundled/sound-libs/lib.es2024.object.d.ts +33 -0
  67. package/project-transform/src/bundled/sound-libs/lib.es2024.promise.d.ts +35 -0
  68. package/project-transform/src/bundled/sound-libs/lib.es2024.regexp.d.ts +25 -0
  69. package/project-transform/src/bundled/sound-libs/lib.es2024.string.d.ts +29 -0
  70. package/project-transform/src/bundled/sound-libs/lib.es5.d.ts +4924 -0
  71. package/project-transform/src/bundled/sound_stdlib.js +142 -0
  72. package/project-transform/src/bundled/sound_stdlib.ts +180 -0
  73. package/project-transform/src/checker/analyze_project.js +1361 -0
  74. package/project-transform/src/checker/analyze_project.ts +2246 -0
  75. package/project-transform/src/checker/diagnostics.js +112 -0
  76. package/project-transform/src/checker/diagnostics.ts +222 -0
  77. package/project-transform/src/checker/engine/context.js +235 -0
  78. package/project-transform/src/checker/engine/context.ts +340 -0
  79. package/project-transform/src/checker/engine/diagnostic_codes.js +72 -0
  80. package/project-transform/src/checker/engine/diagnostic_codes.ts +95 -0
  81. package/project-transform/src/checker/engine/facts.js +35 -0
  82. package/project-transform/src/checker/engine/facts.ts +48 -0
  83. package/project-transform/src/checker/engine/types.js +1 -0
  84. package/project-transform/src/checker/engine/types.ts +485 -0
  85. package/project-transform/src/checker/proof_escape_hatch_diagnostics.js +104 -0
  86. package/project-transform/src/checker/proof_escape_hatch_diagnostics.ts +173 -0
  87. package/project-transform/src/checker/rules/async_surface.js +231 -0
  88. package/project-transform/src/checker/rules/async_surface.ts +335 -0
  89. package/project-transform/src/checker/rules/class_lifecycle.js +798 -0
  90. package/project-transform/src/checker/rules/class_lifecycle.ts +1276 -0
  91. package/project-transform/src/checker/rules/directive_validation.js +571 -0
  92. package/project-transform/src/checker/rules/directive_validation.ts +938 -0
  93. package/project-transform/src/checker/rules/directives.js +23 -0
  94. package/project-transform/src/checker/rules/directives.ts +25 -0
  95. package/project-transform/src/checker/rules/flow.js +202 -0
  96. package/project-transform/src/checker/rules/flow.ts +333 -0
  97. package/project-transform/src/checker/rules/flow_facts.js +601 -0
  98. package/project-transform/src/checker/rules/flow_facts.ts +978 -0
  99. package/project-transform/src/checker/rules/flow_invalidation.js +1119 -0
  100. package/project-transform/src/checker/rules/flow_invalidation.ts +2150 -0
  101. package/project-transform/src/checker/rules/flow_shared.js +2822 -0
  102. package/project-transform/src/checker/rules/flow_shared.ts +4383 -0
  103. package/project-transform/src/checker/rules/foreign_boundary.js +120 -0
  104. package/project-transform/src/checker/rules/foreign_boundary.ts +196 -0
  105. package/project-transform/src/checker/rules/foreign_projection.js +279 -0
  106. package/project-transform/src/checker/rules/foreign_projection.ts +425 -0
  107. package/project-transform/src/checker/rules/generated_helpers.js +13 -0
  108. package/project-transform/src/checker/rules/generated_helpers.ts +18 -0
  109. package/project-transform/src/checker/rules/index.js +35 -0
  110. package/project-transform/src/checker/rules/index.ts +49 -0
  111. package/project-transform/src/checker/rules/namespace_object.js +845 -0
  112. package/project-transform/src/checker/rules/namespace_object.ts +1224 -0
  113. package/project-transform/src/checker/rules/non_ordinary_recovery.js +1328 -0
  114. package/project-transform/src/checker/rules/non_ordinary_recovery.ts +2391 -0
  115. package/project-transform/src/checker/rules/null_prototype.js +3 -0
  116. package/project-transform/src/checker/rules/null_prototype.ts +6 -0
  117. package/project-transform/src/checker/rules/overloads.js +181 -0
  118. package/project-transform/src/checker/rules/overloads.ts +317 -0
  119. package/project-transform/src/checker/rules/predicate_verification.js +691 -0
  120. package/project-transform/src/checker/rules/predicate_verification.ts +1088 -0
  121. package/project-transform/src/checker/rules/prototype_hardening.js +237 -0
  122. package/project-transform/src/checker/rules/prototype_hardening.ts +343 -0
  123. package/project-transform/src/checker/rules/receiver_discipline.js +263 -0
  124. package/project-transform/src/checker/rules/receiver_discipline.ts +356 -0
  125. package/project-transform/src/checker/rules/relations.js +6861 -0
  126. package/project-transform/src/checker/rules/relations.ts +12158 -0
  127. package/project-transform/src/checker/rules/resolved_builtins.js +274 -0
  128. package/project-transform/src/checker/rules/resolved_builtins.ts +438 -0
  129. package/project-transform/src/checker/rules/trust.js +217 -0
  130. package/project-transform/src/checker/rules/trust.ts +301 -0
  131. package/project-transform/src/checker/rules/type_guards.js +173 -0
  132. package/project-transform/src/checker/rules/type_guards.ts +257 -0
  133. package/project-transform/src/checker/rules/universal.js +17 -0
  134. package/project-transform/src/checker/rules/universal.ts +22 -0
  135. package/project-transform/src/checker/rules/unsafe_value_origin.js +80 -0
  136. package/project-transform/src/checker/rules/unsafe_value_origin.ts +125 -0
  137. package/project-transform/src/checker/rules/unsound_imports.js +218 -0
  138. package/project-transform/src/checker/rules/unsound_imports.ts +301 -0
  139. package/project-transform/src/checker/rules/unsound_syntax.js +1695 -0
  140. package/project-transform/src/checker/rules/unsound_syntax.ts +2540 -0
  141. package/project-transform/src/checker/rules/value_types.js +206 -0
  142. package/project-transform/src/checker/rules/value_types.ts +407 -0
  143. package/project-transform/src/checker/timing.js +43 -0
  144. package/project-transform/src/checker/timing.ts +78 -0
  145. package/project-transform/src/checker/unsupported_feature_messages.js +337 -0
  146. package/project-transform/src/checker/unsupported_feature_messages.ts +531 -0
  147. package/project-transform/src/cli.js +892 -0
  148. package/project-transform/src/cli.ts +1476 -0
  149. package/project-transform/src/compiler/compile_project.js +319 -0
  150. package/project-transform/src/compiler/compile_project.ts +508 -0
  151. package/project-transform/src/compiler/errors.js +10 -0
  152. package/project-transform/src/compiler/errors.ts +29 -0
  153. package/project-transform/src/compiler/ir.js +1 -0
  154. package/project-transform/src/compiler/ir.ts +1526 -0
  155. package/project-transform/src/compiler/lower.js +30550 -0
  156. package/project-transform/src/compiler/lower.ts +43645 -0
  157. package/project-transform/src/compiler/lower_arrays.js +140 -0
  158. package/project-transform/src/compiler/lower_arrays.ts +190 -0
  159. package/project-transform/src/compiler/lower_strings.js +121 -0
  160. package/project-transform/src/compiler/lower_strings.ts +198 -0
  161. package/project-transform/src/compiler/lower_tagged.js +329 -0
  162. package/project-transform/src/compiler/lower_tagged.ts +427 -0
  163. package/project-transform/src/compiler/lower_views.js +171 -0
  164. package/project-transform/src/compiler/lower_views.ts +251 -0
  165. package/project-transform/src/compiler/object_keys.js +25 -0
  166. package/project-transform/src/compiler/object_keys.ts +35 -0
  167. package/project-transform/src/compiler/runtime_ir.js +30 -0
  168. package/project-transform/src/compiler/runtime_ir.ts +727 -0
  169. package/project-transform/src/compiler/tagged_boundary.js +18 -0
  170. package/project-transform/src/compiler/tagged_boundary.ts +37 -0
  171. package/project-transform/src/compiler/toolchain.js +170 -0
  172. package/project-transform/src/compiler/toolchain.ts +229 -0
  173. package/project-transform/src/compiler/unicode_case_data.js +2102 -0
  174. package/project-transform/src/compiler/unicode_case_data.ts +2112 -0
  175. package/project-transform/src/compiler/wasm_js_host_runtime.js +656 -0
  176. package/project-transform/src/compiler/wasm_js_host_runtime.ts +762 -0
  177. package/project-transform/src/compiler/wat_arrays.js +3132 -0
  178. package/project-transform/src/compiler/wat_arrays.ts +3768 -0
  179. package/project-transform/src/compiler/wat_emitter.js +17952 -0
  180. package/project-transform/src/compiler/wat_emitter.ts +22812 -0
  181. package/project-transform/src/compiler/wat_strings.js +129 -0
  182. package/project-transform/src/compiler/wat_strings.ts +187 -0
  183. package/project-transform/src/compiler/wat_tagged.js +548 -0
  184. package/project-transform/src/compiler/wat_tagged.ts +674 -0
  185. package/project-transform/src/compiler_generator_runner.js +153 -0
  186. package/project-transform/src/compiler_generator_runner.ts +171 -0
  187. package/project-transform/src/compiler_object_test_helpers.js +69 -0
  188. package/project-transform/src/compiler_object_test_helpers.ts +96 -0
  189. package/project-transform/src/compiler_promise_runner.js +2116 -0
  190. package/project-transform/src/compiler_promise_runner.ts +2184 -0
  191. package/project-transform/src/compiler_test_helpers.js +854 -0
  192. package/project-transform/src/compiler_test_helpers.ts +1087 -0
  193. package/project-transform/src/config.js +568 -0
  194. package/project-transform/src/config.ts +892 -0
  195. package/project-transform/src/diagnostic_metadata.js +67 -0
  196. package/project-transform/src/diagnostic_metadata.ts +99 -0
  197. package/project-transform/src/diagnostic_reference.js +1368 -0
  198. package/project-transform/src/diagnostic_reference.ts +1523 -0
  199. package/project-transform/src/editor_diagnostics_worker.js +176 -0
  200. package/project-transform/src/editor_diagnostics_worker.ts +250 -0
  201. package/project-transform/src/editor_projection.js +224 -0
  202. package/project-transform/src/editor_projection.ts +421 -0
  203. package/project-transform/src/frontend/builtin_expanded_program_test_cleanup.js +47 -0
  204. package/project-transform/src/frontend/builtin_expanded_program_test_cleanup.ts +72 -0
  205. package/project-transform/src/frontend/builtin_macro_support.js +842 -0
  206. package/project-transform/src/frontend/builtin_macro_support.ts +1386 -0
  207. package/project-transform/src/frontend/builtin_macros.js +409 -0
  208. package/project-transform/src/frontend/builtin_macros.ts +542 -0
  209. package/project-transform/src/frontend/component_poc_runtime.js +279 -0
  210. package/project-transform/src/frontend/component_poc_runtime.ts +372 -0
  211. package/project-transform/src/frontend/css_macro.js +148 -0
  212. package/project-transform/src/frontend/css_macro.ts +222 -0
  213. package/project-transform/src/frontend/derive_macros.js +2072 -0
  214. package/project-transform/src/frontend/derive_macros.ts +3188 -0
  215. package/project-transform/src/frontend/embedded_fragment_support.js +106 -0
  216. package/project-transform/src/frontend/embedded_fragment_support.ts +172 -0
  217. package/project-transform/src/frontend/error_normalization.js +403 -0
  218. package/project-transform/src/frontend/error_normalization.ts +832 -0
  219. package/project-transform/src/frontend/error_stdlib_support.js +1 -0
  220. package/project-transform/src/frontend/error_stdlib_support.ts +6 -0
  221. package/project-transform/src/frontend/expand_project.js +169 -0
  222. package/project-transform/src/frontend/expand_project.ts +248 -0
  223. package/project-transform/src/frontend/format_soundscript.js +297 -0
  224. package/project-transform/src/frontend/format_soundscript.ts +582 -0
  225. package/project-transform/src/frontend/graphql_macro.js +174 -0
  226. package/project-transform/src/frontend/graphql_macro.ts +253 -0
  227. package/project-transform/src/frontend/hash_context.js +83 -0
  228. package/project-transform/src/frontend/hash_context.ts +113 -0
  229. package/project-transform/src/frontend/hkt_macro.js +448 -0
  230. package/project-transform/src/frontend/hkt_macro.ts +897 -0
  231. package/project-transform/src/frontend/import_binding_usage.js +190 -0
  232. package/project-transform/src/frontend/import_binding_usage.ts +277 -0
  233. package/project-transform/src/frontend/macro_advanced_backend_adapter.js +58 -0
  234. package/project-transform/src/frontend/macro_advanced_backend_adapter.ts +123 -0
  235. package/project-transform/src/frontend/macro_advanced_context.js +826 -0
  236. package/project-transform/src/frontend/macro_advanced_context.ts +1102 -0
  237. package/project-transform/src/frontend/macro_advanced_output.js +21 -0
  238. package/project-transform/src/frontend/macro_advanced_output.ts +41 -0
  239. package/project-transform/src/frontend/macro_api.js +353 -0
  240. package/project-transform/src/frontend/macro_api.ts +1722 -0
  241. package/project-transform/src/frontend/macro_api_internal.js +35 -0
  242. package/project-transform/src/frontend/macro_api_internal.ts +80 -0
  243. package/project-transform/src/frontend/macro_api_module_support.js +39 -0
  244. package/project-transform/src/frontend/macro_api_module_support.ts +65 -0
  245. package/project-transform/src/frontend/macro_backend_adapter.js +272 -0
  246. package/project-transform/src/frontend/macro_backend_adapter.ts +420 -0
  247. package/project-transform/src/frontend/macro_context.js +816 -0
  248. package/project-transform/src/frontend/macro_context.ts +1105 -0
  249. package/project-transform/src/frontend/macro_debug.js +99 -0
  250. package/project-transform/src/frontend/macro_debug.ts +157 -0
  251. package/project-transform/src/frontend/macro_definition_support.js +28 -0
  252. package/project-transform/src/frontend/macro_definition_support.ts +73 -0
  253. package/project-transform/src/frontend/macro_errors.js +40 -0
  254. package/project-transform/src/frontend/macro_errors.ts +70 -0
  255. package/project-transform/src/frontend/macro_expander.js +919 -0
  256. package/project-transform/src/frontend/macro_expander.ts +1611 -0
  257. package/project-transform/src/frontend/macro_factory_support.js +176 -0
  258. package/project-transform/src/frontend/macro_factory_support.ts +263 -0
  259. package/project-transform/src/frontend/macro_host_ast_internal.js +64 -0
  260. package/project-transform/src/frontend/macro_host_ast_internal.ts +109 -0
  261. package/project-transform/src/frontend/macro_index.js +27 -0
  262. package/project-transform/src/frontend/macro_index.ts +50 -0
  263. package/project-transform/src/frontend/macro_loader.js +281 -0
  264. package/project-transform/src/frontend/macro_loader.ts +506 -0
  265. package/project-transform/src/frontend/macro_operand_semantics.js +838 -0
  266. package/project-transform/src/frontend/macro_operand_semantics.ts +1489 -0
  267. package/project-transform/src/frontend/macro_output.js +54 -0
  268. package/project-transform/src/frontend/macro_output.ts +123 -0
  269. package/project-transform/src/frontend/macro_parser.js +611 -0
  270. package/project-transform/src/frontend/macro_parser.ts +832 -0
  271. package/project-transform/src/frontend/macro_resolver.js +69 -0
  272. package/project-transform/src/frontend/macro_resolver.ts +125 -0
  273. package/project-transform/src/frontend/macro_rewrite.js +285 -0
  274. package/project-transform/src/frontend/macro_rewrite.ts +442 -0
  275. package/project-transform/src/frontend/macro_runtime_support.js +232 -0
  276. package/project-transform/src/frontend/macro_runtime_support.ts +324 -0
  277. package/project-transform/src/frontend/macro_scanner.js +393 -0
  278. package/project-transform/src/frontend/macro_scanner.ts +455 -0
  279. package/project-transform/src/frontend/macro_semantic_backend_adapter.js +87 -0
  280. package/project-transform/src/frontend/macro_semantic_backend_adapter.ts +166 -0
  281. package/project-transform/src/frontend/macro_semantic_context.js +5 -0
  282. package/project-transform/src/frontend/macro_semantic_context.ts +12 -0
  283. package/project-transform/src/frontend/macro_semantic_output.js +24 -0
  284. package/project-transform/src/frontend/macro_semantic_output.ts +47 -0
  285. package/project-transform/src/frontend/macro_semantic_types.js +1 -0
  286. package/project-transform/src/frontend/macro_semantic_types.ts +98 -0
  287. package/project-transform/src/frontend/macro_semantics.js +1172 -0
  288. package/project-transform/src/frontend/macro_semantics.ts +1502 -0
  289. package/project-transform/src/frontend/macro_site_kind_support.js +164 -0
  290. package/project-transform/src/frontend/macro_site_kind_support.ts +255 -0
  291. package/project-transform/src/frontend/macro_syntax_internal.js +1950 -0
  292. package/project-transform/src/frontend/macro_syntax_internal.ts +3338 -0
  293. package/project-transform/src/frontend/macro_templates.js +57 -0
  294. package/project-transform/src/frontend/macro_templates.ts +143 -0
  295. package/project-transform/src/frontend/macro_test_helpers.js +82 -0
  296. package/project-transform/src/frontend/macro_test_helpers.ts +136 -0
  297. package/project-transform/src/frontend/macro_types.js +1 -0
  298. package/project-transform/src/frontend/macro_types.ts +103 -0
  299. package/project-transform/src/frontend/macro_vm.js +39 -0
  300. package/project-transform/src/frontend/macro_vm.ts +113 -0
  301. package/project-transform/src/frontend/match_macro.js +885 -0
  302. package/project-transform/src/frontend/match_macro.ts +1220 -0
  303. package/project-transform/src/frontend/numeric_normalization.js +824 -0
  304. package/project-transform/src/frontend/numeric_normalization.ts +1380 -0
  305. package/project-transform/src/frontend/numeric_prelude.js +278 -0
  306. package/project-transform/src/frontend/numeric_prelude.ts +370 -0
  307. package/project-transform/src/frontend/project_frontend.js +2396 -0
  308. package/project-transform/src/frontend/project_frontend.ts +3776 -0
  309. package/project-transform/src/frontend/project_macro_support.js +1401 -0
  310. package/project-transform/src/frontend/project_macro_support.ts +2137 -0
  311. package/project-transform/src/frontend/sql_macro.js +175 -0
  312. package/project-transform/src/frontend/sql_macro.ts +254 -0
  313. package/project-transform/src/frontend/sql_stdlib_support.js +1 -0
  314. package/project-transform/src/frontend/sql_stdlib_support.ts +6 -0
  315. package/project-transform/src/frontend/std_package_support.js +228 -0
  316. package/project-transform/src/frontend/std_package_support.ts +400 -0
  317. package/project-transform/src/frontend/value_normalization.js +306 -0
  318. package/project-transform/src/frontend/value_normalization.ts +599 -0
  319. package/project-transform/src/lsp/project_service.js +4771 -0
  320. package/project-transform/src/lsp/project_service.ts +7580 -0
  321. package/project-transform/src/lsp/protocol.js +9 -0
  322. package/project-transform/src/lsp/protocol.ts +38 -0
  323. package/project-transform/src/lsp/server.js +355 -0
  324. package/project-transform/src/lsp/server.ts +671 -0
  325. package/project-transform/src/lsp/session.js +49 -0
  326. package/project-transform/src/lsp/session.ts +48 -0
  327. package/project-transform/src/lsp/timing.js +43 -0
  328. package/project-transform/src/lsp/timing.ts +76 -0
  329. package/project-transform/src/lsp/transport.js +205 -0
  330. package/project-transform/src/lsp/transport.ts +253 -0
  331. package/project-transform/src/lsp_main.js +5 -0
  332. package/project-transform/src/lsp_main.ts +7 -0
  333. package/project-transform/src/macros.d.ts +1 -0
  334. package/project-transform/src/macros.js +1 -0
  335. package/project-transform/src/macros.ts +1 -0
  336. package/project-transform/src/main.js +24 -0
  337. package/project-transform/src/main.ts +28 -0
  338. package/project-transform/src/platform/host.js +264 -0
  339. package/project-transform/src/platform/host.ts +343 -0
  340. package/project-transform/src/platform/path.js +8 -0
  341. package/project-transform/src/platform/path.ts +20 -0
  342. package/project-transform/src/public_macro_api/macro_api.d.ts +1054 -0
  343. package/project-transform/src/public_macro_api/macro_semantic_types.d.ts +66 -0
  344. package/project-transform/src/public_macro_api/macro_types.d.ts +70 -0
  345. package/project-transform/src/run_program.js +14 -0
  346. package/project-transform/src/run_program.ts +33 -0
  347. package/project-transform/src/runtime/materialize.js +371 -0
  348. package/project-transform/src/runtime/materialize.ts +502 -0
  349. package/project-transform/src/runtime/on_demand.js +203 -0
  350. package/project-transform/src/runtime/on_demand.ts +305 -0
  351. package/project-transform/src/runtime/source_maps.js +205 -0
  352. package/project-transform/src/runtime/source_maps.ts +297 -0
  353. package/project-transform/src/runtime/transform.js +148 -0
  354. package/project-transform/src/runtime/transform.ts +295 -0
  355. package/project-transform/src/service/types.js +1 -0
  356. package/project-transform/src/service/types.ts +22 -0
  357. package/project-transform/src/soundscript_packages.js +477 -0
  358. package/project-transform/src/soundscript_packages.ts +754 -0
  359. package/project-transform/src/soundscript_runtime_specifiers.js +88 -0
  360. package/project-transform/src/soundscript_runtime_specifiers.ts +96 -0
  361. package/project-transform/src/stdlib/async.d.ts +81 -0
  362. package/project-transform/src/stdlib/async.js +213 -0
  363. package/project-transform/src/stdlib/async.ts +315 -0
  364. package/project-transform/src/stdlib/codec.d.ts +32 -0
  365. package/project-transform/src/stdlib/codec.js +30 -0
  366. package/project-transform/src/stdlib/codec.ts +76 -0
  367. package/project-transform/src/stdlib/compare.d.ts +28 -0
  368. package/project-transform/src/stdlib/compare.js +115 -0
  369. package/project-transform/src/stdlib/compare.ts +151 -0
  370. package/project-transform/src/stdlib/css.d.ts +16 -0
  371. package/project-transform/src/stdlib/css.js +9 -0
  372. package/project-transform/src/stdlib/css.ts +28 -0
  373. package/project-transform/src/stdlib/debug.d.ts +2 -0
  374. package/project-transform/src/stdlib/debug.js +9 -0
  375. package/project-transform/src/stdlib/debug.ts +10 -0
  376. package/project-transform/src/stdlib/decode.d.ts +86 -0
  377. package/project-transform/src/stdlib/decode.js +254 -0
  378. package/project-transform/src/stdlib/decode.ts +390 -0
  379. package/project-transform/src/stdlib/derive.d.ts +6 -0
  380. package/project-transform/src/stdlib/derive.js +7 -0
  381. package/project-transform/src/stdlib/derive.ts +7 -0
  382. package/project-transform/src/stdlib/encode.d.ts +100 -0
  383. package/project-transform/src/stdlib/encode.js +130 -0
  384. package/project-transform/src/stdlib/encode.ts +259 -0
  385. package/project-transform/src/stdlib/failures.d.ts +23 -0
  386. package/project-transform/src/stdlib/failures.js +41 -0
  387. package/project-transform/src/stdlib/failures.ts +64 -0
  388. package/project-transform/src/stdlib/fetch.d.ts +67 -0
  389. package/project-transform/src/stdlib/fetch.js +5 -0
  390. package/project-transform/src/stdlib/fetch.ts +11 -0
  391. package/project-transform/src/stdlib/graphql.d.ts +16 -0
  392. package/project-transform/src/stdlib/graphql.js +9 -0
  393. package/project-transform/src/stdlib/graphql.ts +28 -0
  394. package/project-transform/src/stdlib/hash.d.ts +34 -0
  395. package/project-transform/src/stdlib/hash.js +110 -0
  396. package/project-transform/src/stdlib/hash.ts +188 -0
  397. package/project-transform/src/stdlib/hkt.d.ts +40 -0
  398. package/project-transform/src/stdlib/hkt.js +3 -0
  399. package/project-transform/src/stdlib/hkt.ts +41 -0
  400. package/project-transform/src/stdlib/index.d.ts +9 -0
  401. package/project-transform/src/stdlib/index.js +15 -0
  402. package/project-transform/src/stdlib/index.ts +23 -0
  403. package/project-transform/src/stdlib/json.d.ts +125 -0
  404. package/project-transform/src/stdlib/json.js +764 -0
  405. package/project-transform/src/stdlib/json.ts +1034 -0
  406. package/project-transform/src/stdlib/match.d.ts +11 -0
  407. package/project-transform/src/stdlib/match.js +13 -0
  408. package/project-transform/src/stdlib/match.ts +26 -0
  409. package/project-transform/src/stdlib/numerics.d.ts +523 -0
  410. package/project-transform/src/stdlib/numerics.js +1356 -0
  411. package/project-transform/src/stdlib/numerics.ts +1937 -0
  412. package/project-transform/src/stdlib/random.d.ts +19 -0
  413. package/project-transform/src/stdlib/random.js +3 -0
  414. package/project-transform/src/stdlib/random.ts +5 -0
  415. package/project-transform/src/stdlib/result.d.ts +68 -0
  416. package/project-transform/src/stdlib/result.js +139 -0
  417. package/project-transform/src/stdlib/result.ts +248 -0
  418. package/project-transform/src/stdlib/sql.d.ts +22 -0
  419. package/project-transform/src/stdlib/sql.js +23 -0
  420. package/project-transform/src/stdlib/sql.ts +53 -0
  421. package/project-transform/src/stdlib/text.d.ts +24 -0
  422. package/project-transform/src/stdlib/text.js +3 -0
  423. package/project-transform/src/stdlib/text.ts +4 -0
  424. package/project-transform/src/stdlib/thunk.d.ts +2 -0
  425. package/project-transform/src/stdlib/thunk.js +9 -0
  426. package/project-transform/src/stdlib/thunk.ts +15 -0
  427. package/project-transform/src/stdlib/typeclasses.d.ts +57 -0
  428. package/project-transform/src/stdlib/typeclasses.js +78 -0
  429. package/project-transform/src/stdlib/typeclasses.ts +173 -0
  430. package/project-transform/src/stdlib/url.d.ts +37 -0
  431. package/project-transform/src/stdlib/url.js +3 -0
  432. package/project-transform/src/stdlib/url.ts +4 -0
  433. package/project-transform/src/stdlib/value.d.ts +9 -0
  434. package/project-transform/src/stdlib/value.js +104 -0
  435. package/project-transform/src/stdlib/value.ts +133 -0
  436. package/project-transform/src/test_installed_stdlib.js +147 -0
  437. package/project-transform/src/test_installed_stdlib.ts +245 -0
  438. package/project-transform/src/test_macro_package_fixture.js +50 -0
  439. package/project-transform/src/test_macro_package_fixture.ts +68 -0
  440. package/project-transform/src/value_deep_safe.js +191 -0
  441. package/project-transform/src/value_deep_safe.ts +273 -0
@@ -0,0 +1,948 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7
+ if (kind === "m") throw new TypeError("Private method is not writable");
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
+ };
12
+ var _AnnotationValueParser_index;
13
+ import ts from 'typescript';
14
+ const ANNOTATION_COMMENT_PATTERN = /^\/\/\s*#\[/u;
15
+ export const BUILTIN_DIRECTIVE_NAMES = new Set([
16
+ 'extern',
17
+ 'interop',
18
+ 'newtype',
19
+ 'unsafe',
20
+ 'value',
21
+ 'variance',
22
+ ]);
23
+ function isIdentifierStart(character) {
24
+ return character !== undefined && /[\p{ID_Start}_$]/u.test(character);
25
+ }
26
+ function isIdentifierPart(character) {
27
+ return character !== undefined && /[\p{ID_Continue}_$\u200C\u200D-]/u.test(character);
28
+ }
29
+ function isDigit(character) {
30
+ return character !== undefined && /[0-9]/u.test(character);
31
+ }
32
+ function trimRange(text, start, end) {
33
+ let nextStart = start;
34
+ let nextEnd = end;
35
+ while (nextStart < nextEnd && /\s/u.test(text[nextStart] ?? '')) {
36
+ nextStart += 1;
37
+ }
38
+ while (nextEnd > nextStart && /\s/u.test(text[nextEnd - 1] ?? '')) {
39
+ nextEnd -= 1;
40
+ }
41
+ return {
42
+ end: nextEnd,
43
+ start: nextStart,
44
+ text: text.slice(nextStart, nextEnd),
45
+ };
46
+ }
47
+ function skipWhitespace(text, index) {
48
+ let nextIndex = index;
49
+ while (nextIndex < text.length && /\s/u.test(text[nextIndex] ?? '')) {
50
+ nextIndex += 1;
51
+ }
52
+ return nextIndex;
53
+ }
54
+ function readStringLiteral(text, start) {
55
+ const quote = text[start];
56
+ if (quote !== '"' && quote !== "'") {
57
+ return 'Expected a string literal.';
58
+ }
59
+ let index = start + 1;
60
+ while (index < text.length) {
61
+ const character = text[index];
62
+ if (character === '\\') {
63
+ index += 2;
64
+ continue;
65
+ }
66
+ if (character === quote) {
67
+ return index + 1;
68
+ }
69
+ index += 1;
70
+ }
71
+ return 'String literals in annotation arguments must terminate before the annotation closes.';
72
+ }
73
+ function parseIdentifierName(text, start, allowDots) {
74
+ if (!isIdentifierStart(text[start])) {
75
+ return 'Annotation names must use identifier-like segments such as `unsafe`, `variance`, or `_hkt_`.';
76
+ }
77
+ let index = start + 1;
78
+ while (isIdentifierPart(text[index])) {
79
+ index += 1;
80
+ }
81
+ while (allowDots && text[index] === '.') {
82
+ const segmentStart = index + 1;
83
+ if (!isIdentifierStart(text[segmentStart])) {
84
+ return 'Annotation names must use identifier-like dotted segments such as `layout.value`.';
85
+ }
86
+ index = segmentStart + 1;
87
+ while (isIdentifierPart(text[index])) {
88
+ index += 1;
89
+ }
90
+ }
91
+ return {
92
+ end: index,
93
+ name: text.slice(start, index),
94
+ };
95
+ }
96
+ class AnnotationValueParser {
97
+ constructor(text) {
98
+ this.text = text;
99
+ _AnnotationValueParser_index.set(this, 0);
100
+ }
101
+ parseArguments() {
102
+ const args = [];
103
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, skipWhitespace(this.text, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f")), "f");
104
+ if (__classPrivateFieldGet(this, _AnnotationValueParser_index, "f") >= this.text.length) {
105
+ return args;
106
+ }
107
+ while (__classPrivateFieldGet(this, _AnnotationValueParser_index, "f") < this.text.length) {
108
+ const argument = this.parseArgument();
109
+ if (typeof argument === 'string') {
110
+ return argument;
111
+ }
112
+ args.push(argument);
113
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, skipWhitespace(this.text, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f")), "f");
114
+ if (__classPrivateFieldGet(this, _AnnotationValueParser_index, "f") >= this.text.length) {
115
+ return args;
116
+ }
117
+ if (this.text[__classPrivateFieldGet(this, _AnnotationValueParser_index, "f")] !== ',') {
118
+ return 'Annotation argument lists must separate items with commas.';
119
+ }
120
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f") + 1, "f");
121
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, skipWhitespace(this.text, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f")), "f");
122
+ if (__classPrivateFieldGet(this, _AnnotationValueParser_index, "f") >= this.text.length) {
123
+ return 'Annotation argument lists do not allow trailing commas.';
124
+ }
125
+ }
126
+ return args;
127
+ }
128
+ parseValue() {
129
+ return this.parseValueAtCurrentIndex();
130
+ }
131
+ parseArgument() {
132
+ const start = __classPrivateFieldGet(this, _AnnotationValueParser_index, "f");
133
+ const namedArgument = this.tryParseNamedArgument();
134
+ if (typeof namedArgument !== 'string' || __classPrivateFieldGet(this, _AnnotationValueParser_index, "f") !== start) {
135
+ return namedArgument;
136
+ }
137
+ const value = this.parseValueAtCurrentIndex();
138
+ if (typeof value === 'string') {
139
+ return value;
140
+ }
141
+ return {
142
+ kind: 'positional',
143
+ text: this.text.slice(start, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f")),
144
+ value,
145
+ };
146
+ }
147
+ parseArrayValue() {
148
+ const start = __classPrivateFieldGet(this, _AnnotationValueParser_index, "f");
149
+ if (this.text[__classPrivateFieldGet(this, _AnnotationValueParser_index, "f")] !== '[') {
150
+ return 'Expected an array literal.';
151
+ }
152
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f") + 1, "f");
153
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, skipWhitespace(this.text, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f")), "f");
154
+ const elements = [];
155
+ if (this.text[__classPrivateFieldGet(this, _AnnotationValueParser_index, "f")] === ']') {
156
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f") + 1, "f");
157
+ return {
158
+ elements,
159
+ kind: 'array',
160
+ text: this.text.slice(start, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f")),
161
+ };
162
+ }
163
+ while (__classPrivateFieldGet(this, _AnnotationValueParser_index, "f") < this.text.length) {
164
+ const value = this.parseValueAtCurrentIndex();
165
+ if (typeof value === 'string') {
166
+ return value;
167
+ }
168
+ elements.push(value);
169
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, skipWhitespace(this.text, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f")), "f");
170
+ if (this.text[__classPrivateFieldGet(this, _AnnotationValueParser_index, "f")] === ']') {
171
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f") + 1, "f");
172
+ return {
173
+ elements,
174
+ kind: 'array',
175
+ text: this.text.slice(start, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f")),
176
+ };
177
+ }
178
+ if (this.text[__classPrivateFieldGet(this, _AnnotationValueParser_index, "f")] !== ',') {
179
+ return 'Array literals in annotation arguments must separate elements with commas.';
180
+ }
181
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f") + 1, "f");
182
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, skipWhitespace(this.text, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f")), "f");
183
+ if (this.text[__classPrivateFieldGet(this, _AnnotationValueParser_index, "f")] === ']') {
184
+ return 'Array literals in annotation arguments do not allow trailing commas.';
185
+ }
186
+ }
187
+ return 'Array literals in annotation arguments must close with `]`.';
188
+ }
189
+ parseBooleanOrIdentifierValue() {
190
+ const parsedName = parseIdentifierName(this.text, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f"), true);
191
+ if (typeof parsedName === 'string') {
192
+ return parsedName;
193
+ }
194
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, parsedName.end, "f");
195
+ if (parsedName.name === 'true' || parsedName.name === 'false') {
196
+ return {
197
+ kind: 'boolean',
198
+ text: parsedName.name,
199
+ value: parsedName.name === 'true',
200
+ };
201
+ }
202
+ return {
203
+ kind: 'identifier',
204
+ name: parsedName.name,
205
+ text: parsedName.name,
206
+ };
207
+ }
208
+ parseNumberValue() {
209
+ const remaining = this.text.slice(__classPrivateFieldGet(this, _AnnotationValueParser_index, "f"));
210
+ const match = /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?/u.exec(remaining);
211
+ if (!match) {
212
+ return 'Expected a number literal.';
213
+ }
214
+ const numberText = match[0] ?? '';
215
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f") + numberText.length, "f");
216
+ return {
217
+ kind: 'number',
218
+ text: numberText,
219
+ value: Number(numberText),
220
+ };
221
+ }
222
+ parseObjectValue() {
223
+ const start = __classPrivateFieldGet(this, _AnnotationValueParser_index, "f");
224
+ if (this.text[__classPrivateFieldGet(this, _AnnotationValueParser_index, "f")] !== '{') {
225
+ return 'Expected an object literal.';
226
+ }
227
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f") + 1, "f");
228
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, skipWhitespace(this.text, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f")), "f");
229
+ const properties = [];
230
+ if (this.text[__classPrivateFieldGet(this, _AnnotationValueParser_index, "f")] === '}') {
231
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f") + 1, "f");
232
+ return {
233
+ kind: 'object',
234
+ properties,
235
+ text: this.text.slice(start, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f")),
236
+ };
237
+ }
238
+ while (__classPrivateFieldGet(this, _AnnotationValueParser_index, "f") < this.text.length) {
239
+ const propertyStart = __classPrivateFieldGet(this, _AnnotationValueParser_index, "f");
240
+ const parsedName = parseIdentifierName(this.text, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f"), false);
241
+ if (typeof parsedName === 'string') {
242
+ return 'Object literals in annotation arguments require identifier property names.';
243
+ }
244
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, parsedName.end, "f");
245
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, skipWhitespace(this.text, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f")), "f");
246
+ if (this.text[__classPrivateFieldGet(this, _AnnotationValueParser_index, "f")] !== ':') {
247
+ return `Object literal property \`${parsedName.name}\` must use \`name: value\` syntax.`;
248
+ }
249
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f") + 1, "f");
250
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, skipWhitespace(this.text, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f")), "f");
251
+ const value = this.parseValueAtCurrentIndex();
252
+ if (typeof value === 'string') {
253
+ return value;
254
+ }
255
+ properties.push({
256
+ name: parsedName.name,
257
+ text: this.text.slice(propertyStart, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f")),
258
+ value,
259
+ });
260
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, skipWhitespace(this.text, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f")), "f");
261
+ if (this.text[__classPrivateFieldGet(this, _AnnotationValueParser_index, "f")] === '}') {
262
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f") + 1, "f");
263
+ return {
264
+ kind: 'object',
265
+ properties,
266
+ text: this.text.slice(start, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f")),
267
+ };
268
+ }
269
+ if (this.text[__classPrivateFieldGet(this, _AnnotationValueParser_index, "f")] !== ',') {
270
+ return 'Object literals in annotation arguments must separate properties with commas.';
271
+ }
272
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f") + 1, "f");
273
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, skipWhitespace(this.text, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f")), "f");
274
+ if (this.text[__classPrivateFieldGet(this, _AnnotationValueParser_index, "f")] === '}') {
275
+ return 'Object literals in annotation arguments do not allow trailing commas.';
276
+ }
277
+ }
278
+ return 'Object literals in annotation arguments must close with `}`.';
279
+ }
280
+ parseStringValue() {
281
+ const start = __classPrivateFieldGet(this, _AnnotationValueParser_index, "f");
282
+ const end = readStringLiteral(this.text, start);
283
+ if (typeof end === 'string') {
284
+ return end;
285
+ }
286
+ const literalText = this.text.slice(start, end);
287
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, end, "f");
288
+ try {
289
+ return {
290
+ kind: 'string',
291
+ text: literalText,
292
+ value: JSON.parse(literalText.replace(/^'/u, '"').replace(/'$/u, '"')),
293
+ };
294
+ }
295
+ catch {
296
+ const quote = literalText[0];
297
+ const innerText = literalText.slice(1, -1);
298
+ const normalized = quote === "'"
299
+ ? `"${innerText.replace(/\\/gu, '\\\\').replace(/"/gu, '\\"')}"`
300
+ : literalText;
301
+ return {
302
+ kind: 'string',
303
+ text: literalText,
304
+ value: JSON.parse(normalized),
305
+ };
306
+ }
307
+ }
308
+ parseValueAtCurrentIndex() {
309
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, skipWhitespace(this.text, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f")), "f");
310
+ const character = this.text[__classPrivateFieldGet(this, _AnnotationValueParser_index, "f")];
311
+ if (character === '"' || character === "'") {
312
+ return this.parseStringValue();
313
+ }
314
+ if (character === '[') {
315
+ return this.parseArrayValue();
316
+ }
317
+ if (character === '{') {
318
+ return this.parseObjectValue();
319
+ }
320
+ if (character === '-' || isDigit(character)) {
321
+ return this.parseNumberValue();
322
+ }
323
+ if (isIdentifierStart(character)) {
324
+ return this.parseBooleanOrIdentifierValue();
325
+ }
326
+ return 'Annotation arguments must use identifiers, strings, numbers, booleans, arrays, or objects.';
327
+ }
328
+ tryParseNamedArgument() {
329
+ const start = __classPrivateFieldGet(this, _AnnotationValueParser_index, "f");
330
+ const parsedName = parseIdentifierName(this.text, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f"), false);
331
+ if (typeof parsedName === 'string') {
332
+ return parsedName;
333
+ }
334
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, parsedName.end, "f");
335
+ const afterName = skipWhitespace(this.text, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f"));
336
+ if (this.text[afterName] !== ':') {
337
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, start, "f");
338
+ return 'not-a-named-argument';
339
+ }
340
+ __classPrivateFieldSet(this, _AnnotationValueParser_index, skipWhitespace(this.text, afterName + 1), "f");
341
+ const value = this.parseValueAtCurrentIndex();
342
+ if (typeof value === 'string') {
343
+ return value;
344
+ }
345
+ return {
346
+ kind: 'named',
347
+ name: parsedName.name,
348
+ text: this.text.slice(start, __classPrivateFieldGet(this, _AnnotationValueParser_index, "f")),
349
+ value,
350
+ };
351
+ }
352
+ }
353
+ _AnnotationValueParser_index = new WeakMap();
354
+ function splitAnnotationItems(innerText) {
355
+ const items = [];
356
+ let itemStart = 0;
357
+ let parenDepth = 0;
358
+ let bracketDepth = 0;
359
+ let braceDepth = 0;
360
+ for (let index = 0; index < innerText.length; index += 1) {
361
+ const character = innerText[index];
362
+ if (character === '"' || character === "'") {
363
+ const stringEnd = readStringLiteral(innerText, index);
364
+ if (typeof stringEnd === 'string') {
365
+ return stringEnd;
366
+ }
367
+ index = stringEnd - 1;
368
+ continue;
369
+ }
370
+ if (character === '(') {
371
+ parenDepth += 1;
372
+ continue;
373
+ }
374
+ if (character === ')') {
375
+ if (parenDepth === 0) {
376
+ return 'Annotation arguments contain an unexpected closing parenthesis.';
377
+ }
378
+ parenDepth -= 1;
379
+ continue;
380
+ }
381
+ if (character === '[') {
382
+ bracketDepth += 1;
383
+ continue;
384
+ }
385
+ if (character === ']') {
386
+ if (bracketDepth === 0) {
387
+ return 'Annotation arguments contain an unexpected closing bracket.';
388
+ }
389
+ bracketDepth -= 1;
390
+ continue;
391
+ }
392
+ if (character === '{') {
393
+ braceDepth += 1;
394
+ continue;
395
+ }
396
+ if (character === '}') {
397
+ if (braceDepth === 0) {
398
+ return 'Annotation arguments contain an unexpected closing brace.';
399
+ }
400
+ braceDepth -= 1;
401
+ continue;
402
+ }
403
+ if (character === ',' && parenDepth === 0 && bracketDepth === 0 && braceDepth === 0) {
404
+ const trimmed = trimRange(innerText, itemStart, index);
405
+ if (trimmed.text.length === 0) {
406
+ return 'Annotation lists do not allow empty items.';
407
+ }
408
+ items.push(trimmed);
409
+ itemStart = index + 1;
410
+ }
411
+ }
412
+ if (parenDepth !== 0) {
413
+ return 'Annotation arguments must use balanced parentheses.';
414
+ }
415
+ if (bracketDepth !== 0) {
416
+ return 'Annotation arguments must use balanced brackets.';
417
+ }
418
+ if (braceDepth !== 0) {
419
+ return 'Annotation arguments must use balanced braces.';
420
+ }
421
+ const trimmed = trimRange(innerText, itemStart, innerText.length);
422
+ if (trimmed.text.length === 0) {
423
+ return 'Annotation lists do not allow empty items.';
424
+ }
425
+ items.push(trimmed);
426
+ return items;
427
+ }
428
+ export function parseAnnotationArgumentsText(argumentsText) {
429
+ return new AnnotationValueParser(argumentsText).parseArguments();
430
+ }
431
+ export function parseAnnotationItemText(itemText) {
432
+ const trimmed = itemText.trim();
433
+ const parsedName = parseIdentifierName(trimmed, 0, true);
434
+ if (typeof parsedName === 'string') {
435
+ return parsedName;
436
+ }
437
+ let index = skipWhitespace(trimmed, parsedName.end);
438
+ if (index >= trimmed.length) {
439
+ return {
440
+ name: parsedName.name,
441
+ text: trimmed,
442
+ };
443
+ }
444
+ if (trimmed[index] !== '(') {
445
+ return 'Annotation items may only contain a name and an optional argument list.';
446
+ }
447
+ const argumentsStart = index + 1;
448
+ let parenDepth = 1;
449
+ let bracketDepth = 0;
450
+ let braceDepth = 0;
451
+ index += 1;
452
+ while (index < trimmed.length) {
453
+ const character = trimmed[index];
454
+ if (character === '"' || character === "'") {
455
+ const stringEnd = readStringLiteral(trimmed, index);
456
+ if (typeof stringEnd === 'string') {
457
+ return stringEnd;
458
+ }
459
+ index = stringEnd;
460
+ continue;
461
+ }
462
+ if (character === '(') {
463
+ parenDepth += 1;
464
+ index += 1;
465
+ continue;
466
+ }
467
+ if (character === ')') {
468
+ parenDepth -= 1;
469
+ if (parenDepth === 0) {
470
+ break;
471
+ }
472
+ if (parenDepth < 0) {
473
+ return 'Annotation arguments contain an unexpected closing parenthesis.';
474
+ }
475
+ index += 1;
476
+ continue;
477
+ }
478
+ if (character === '[') {
479
+ bracketDepth += 1;
480
+ index += 1;
481
+ continue;
482
+ }
483
+ if (character === ']') {
484
+ if (bracketDepth === 0) {
485
+ return 'Annotation arguments contain an unexpected closing bracket.';
486
+ }
487
+ bracketDepth -= 1;
488
+ index += 1;
489
+ continue;
490
+ }
491
+ if (character === '{') {
492
+ braceDepth += 1;
493
+ index += 1;
494
+ continue;
495
+ }
496
+ if (character === '}') {
497
+ if (braceDepth === 0) {
498
+ return 'Annotation arguments contain an unexpected closing brace.';
499
+ }
500
+ braceDepth -= 1;
501
+ index += 1;
502
+ continue;
503
+ }
504
+ index += 1;
505
+ }
506
+ if (index >= trimmed.length || parenDepth !== 0) {
507
+ return 'Annotation arguments must use balanced parentheses.';
508
+ }
509
+ if (bracketDepth !== 0) {
510
+ return 'Annotation arguments must use balanced brackets.';
511
+ }
512
+ if (braceDepth !== 0) {
513
+ return 'Annotation arguments must use balanced braces.';
514
+ }
515
+ if (trimmed.slice(index + 1).trim().length > 0) {
516
+ return 'Annotation items may only contain a name and an optional argument list.';
517
+ }
518
+ const argumentsText = trimmed.slice(argumentsStart, index).trim();
519
+ const parsedArguments = parseAnnotationArgumentsText(argumentsText);
520
+ if (typeof parsedArguments === 'string') {
521
+ return parsedArguments;
522
+ }
523
+ return {
524
+ arguments: parsedArguments.length === 0 ? [] : parsedArguments,
525
+ argumentsText,
526
+ name: parsedName.name,
527
+ text: trimmed,
528
+ };
529
+ }
530
+ export function parseAnnotationCommentText(commentText) {
531
+ if (!ANNOTATION_COMMENT_PATTERN.test(commentText)) {
532
+ return null;
533
+ }
534
+ const openMarkerText = commentText.match(ANNOTATION_COMMENT_PATTERN)?.[0];
535
+ if (!openMarkerText) {
536
+ return null;
537
+ }
538
+ const bodyStart = openMarkerText.length;
539
+ let closingBracketIndex = -1;
540
+ let parenDepth = 0;
541
+ let bracketDepth = 0;
542
+ let braceDepth = 0;
543
+ for (let index = bodyStart; index < commentText.length; index += 1) {
544
+ const character = commentText[index];
545
+ if (character === '"' || character === "'") {
546
+ const stringEnd = readStringLiteral(commentText, index);
547
+ if (typeof stringEnd === 'string') {
548
+ return stringEnd;
549
+ }
550
+ index = stringEnd - 1;
551
+ continue;
552
+ }
553
+ if (character === '(') {
554
+ parenDepth += 1;
555
+ continue;
556
+ }
557
+ if (character === ')') {
558
+ if (parenDepth === 0) {
559
+ return 'Annotation arguments contain an unexpected closing parenthesis.';
560
+ }
561
+ parenDepth -= 1;
562
+ continue;
563
+ }
564
+ if (character === '[') {
565
+ bracketDepth += 1;
566
+ continue;
567
+ }
568
+ if (character === ']') {
569
+ if (parenDepth === 0 && bracketDepth === 0 && braceDepth === 0) {
570
+ closingBracketIndex = index;
571
+ break;
572
+ }
573
+ if (bracketDepth === 0) {
574
+ return 'Annotation arguments contain an unexpected closing bracket.';
575
+ }
576
+ bracketDepth -= 1;
577
+ continue;
578
+ }
579
+ if (character === '{') {
580
+ braceDepth += 1;
581
+ continue;
582
+ }
583
+ if (character === '}') {
584
+ if (braceDepth === 0) {
585
+ return 'Annotation arguments contain an unexpected closing brace.';
586
+ }
587
+ braceDepth -= 1;
588
+ continue;
589
+ }
590
+ }
591
+ if (closingBracketIndex === -1) {
592
+ return 'Annotation comments must close with `]`.';
593
+ }
594
+ if (parenDepth !== 0) {
595
+ return 'Annotation arguments must use balanced parentheses.';
596
+ }
597
+ if (bracketDepth !== 0) {
598
+ return 'Annotation arguments must use balanced brackets.';
599
+ }
600
+ if (braceDepth !== 0) {
601
+ return 'Annotation arguments must use balanced braces.';
602
+ }
603
+ const trimmedBody = trimRange(commentText, bodyStart, closingBracketIndex);
604
+ const innerText = trimmedBody.text;
605
+ if (innerText.length === 0) {
606
+ return 'Annotation comments must contain at least one annotation item.';
607
+ }
608
+ const splitItems = splitAnnotationItems(innerText);
609
+ if (typeof splitItems === 'string') {
610
+ return splitItems;
611
+ }
612
+ const annotations = [];
613
+ for (const item of splitItems) {
614
+ const parsedAnnotation = parseAnnotationItemText(item.text);
615
+ if (typeof parsedAnnotation === 'string') {
616
+ return parsedAnnotation;
617
+ }
618
+ const parsedName = parseIdentifierName(item.text, 0, true);
619
+ if (typeof parsedName === 'string') {
620
+ return parsedName;
621
+ }
622
+ const absoluteStart = trimmedBody.start + item.start;
623
+ annotations.push({
624
+ ...parsedAnnotation,
625
+ nameRange: {
626
+ start: absoluteStart,
627
+ end: absoluteStart + parsedName.end,
628
+ },
629
+ range: {
630
+ start: absoluteStart,
631
+ end: trimmedBody.start + item.end,
632
+ },
633
+ });
634
+ }
635
+ return {
636
+ annotations,
637
+ text: commentText.trim(),
638
+ };
639
+ }
640
+ function isAnnotationTargetNode(node) {
641
+ return ts.isStatement(node) ||
642
+ ts.isBindingElement(node) ||
643
+ ts.isClassDeclaration(node) ||
644
+ ts.isClassElement(node) ||
645
+ ts.isEnumDeclaration(node) ||
646
+ ts.isEnumMember(node) ||
647
+ ts.isFunctionDeclaration(node) ||
648
+ ts.isImportClause(node) ||
649
+ ts.isInterfaceDeclaration(node) ||
650
+ ts.isModuleDeclaration(node) ||
651
+ ts.isParameter(node) ||
652
+ ts.isPropertyAssignment(node) ||
653
+ ts.isShorthandPropertyAssignment(node) ||
654
+ ts.isTypeAliasDeclaration(node) ||
655
+ ts.isTypeElement(node);
656
+ }
657
+ function getNodeStartLine(node) {
658
+ const sourceFile = node.getSourceFile();
659
+ return sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + 1;
660
+ }
661
+ function parseTypeScriptPragma(commentText) {
662
+ if (commentText.startsWith('//')) {
663
+ const match = commentText.match(/^\/\/\s*(@ts-[a-z-]+)\b/u);
664
+ return match?.[1];
665
+ }
666
+ if (!commentText.startsWith('/*')) {
667
+ return undefined;
668
+ }
669
+ const withoutOpen = commentText.replace(/^\/\*+\s?/u, '');
670
+ const withoutClose = withoutOpen.replace(/\*\/\s*$/u, '');
671
+ for (const rawLine of withoutClose.split(/\r?\n/u)) {
672
+ const line = rawLine.trimStart().replace(/^\*\s?/u, '');
673
+ if (line.length === 0) {
674
+ continue;
675
+ }
676
+ const match = line.match(/^(@ts-[a-z-]+)\b/u);
677
+ return match?.[1];
678
+ }
679
+ return undefined;
680
+ }
681
+ function createAnnotationParseError(line, text, message) {
682
+ return {
683
+ kind: 'annotation-parse-error',
684
+ line,
685
+ message,
686
+ text,
687
+ };
688
+ }
689
+ function absolutizeAnnotationComment(comment, absoluteStart, line, range) {
690
+ return {
691
+ annotations: comment.annotations.map((annotation) => ({
692
+ ...annotation,
693
+ nameRange: annotation.nameRange
694
+ ? {
695
+ start: absoluteStart + annotation.nameRange.start,
696
+ end: absoluteStart + annotation.nameRange.end,
697
+ }
698
+ : undefined,
699
+ range: annotation.range
700
+ ? {
701
+ start: absoluteStart + annotation.range.start,
702
+ end: absoluteStart + annotation.range.end,
703
+ }
704
+ : undefined,
705
+ })),
706
+ kind: 'annotation',
707
+ line,
708
+ range,
709
+ text: comment.text,
710
+ };
711
+ }
712
+ function parseAnnotationEntry(commentText, line, standalone, absoluteStart, range) {
713
+ if (ANNOTATION_COMMENT_PATTERN.test(commentText)) {
714
+ if (!standalone) {
715
+ return createAnnotationParseError(line, commentText.trim(), 'Annotation comments must appear on their own line.');
716
+ }
717
+ const parsedComment = parseAnnotationCommentText(commentText);
718
+ if (typeof parsedComment === 'string') {
719
+ return createAnnotationParseError(line, commentText.trim(), parsedComment);
720
+ }
721
+ if (parsedComment) {
722
+ return absolutizeAnnotationComment(parsedComment, absoluteStart, line, range);
723
+ }
724
+ }
725
+ const tsPragmaText = parseTypeScriptPragma(commentText);
726
+ if (tsPragmaText) {
727
+ return {
728
+ kind: 'banned-ts-pragma',
729
+ line,
730
+ text: tsPragmaText,
731
+ };
732
+ }
733
+ return undefined;
734
+ }
735
+ function traverseNode(node, visitor) {
736
+ visitor(node);
737
+ ts.forEachChild(node, (child) => traverseNode(child, visitor));
738
+ }
739
+ export function createAnnotationLookup(sourceFile) {
740
+ const entriesByLine = new Map();
741
+ const entries = [];
742
+ const scannedComments = [];
743
+ const candidateNodesByStartLine = new Map();
744
+ const blocksByTargetNode = new WeakMap();
745
+ const scanner = ts.createScanner(ts.ScriptTarget.Latest, false, sourceFile.languageVariant, sourceFile.text);
746
+ const lineStarts = sourceFile.getLineStarts();
747
+ traverseNode(sourceFile, (node) => {
748
+ if (!isAnnotationTargetNode(node)) {
749
+ return;
750
+ }
751
+ const startLine = getNodeStartLine(node);
752
+ const lineNodes = candidateNodesByStartLine.get(startLine);
753
+ if (lineNodes) {
754
+ lineNodes.push(node);
755
+ }
756
+ else {
757
+ candidateNodesByStartLine.set(startLine, [node]);
758
+ }
759
+ });
760
+ if (sourceFile.isDeclarationFile) {
761
+ const sourceLines = sourceFile.text.split(/\r?\n/u);
762
+ let absoluteLineStart = 0;
763
+ for (let lineIndex = 0; lineIndex < sourceLines.length; lineIndex += 1) {
764
+ const rawLine = sourceLines[lineIndex] ?? '';
765
+ const trimmedStart = rawLine.trimStart();
766
+ if (!trimmedStart.startsWith('//')) {
767
+ absoluteLineStart += rawLine.length + 1;
768
+ continue;
769
+ }
770
+ const trimmedOffset = rawLine.indexOf(trimmedStart);
771
+ const start = absoluteLineStart + Math.max(trimmedOffset, 0);
772
+ const end = absoluteLineStart + rawLine.length;
773
+ const line = lineIndex + 1;
774
+ const range = { start, end };
775
+ const entry = parseAnnotationEntry(trimmedStart, line, true, start, range);
776
+ scannedComments.push({
777
+ endLine: line,
778
+ entry,
779
+ kind: entry?.kind ?? 'other-comment',
780
+ range,
781
+ standalone: true,
782
+ startLine: line,
783
+ });
784
+ if (entry) {
785
+ const lineEntries = entriesByLine.get(line);
786
+ if (lineEntries) {
787
+ lineEntries.push(entry);
788
+ }
789
+ else {
790
+ entriesByLine.set(line, [entry]);
791
+ }
792
+ entries.push(entry);
793
+ }
794
+ absoluteLineStart += rawLine.length + 1;
795
+ }
796
+ }
797
+ while (true) {
798
+ const token = scanner.scan();
799
+ if (token === ts.SyntaxKind.EndOfFileToken) {
800
+ break;
801
+ }
802
+ if (token !== ts.SyntaxKind.MultiLineCommentTrivia &&
803
+ !(token === ts.SyntaxKind.SingleLineCommentTrivia && !sourceFile.isDeclarationFile)) {
804
+ continue;
805
+ }
806
+ const tokenStart = scanner.getTokenPos();
807
+ const tokenText = scanner.getTokenText();
808
+ const tokenEnd = tokenStart + tokenText.length;
809
+ const startLineInfo = sourceFile.getLineAndCharacterOfPosition(tokenStart);
810
+ const endLineInfo = sourceFile.getLineAndCharacterOfPosition(tokenEnd);
811
+ const line = startLineInfo.line + 1;
812
+ const endLine = endLineInfo.line + 1;
813
+ const lineStart = lineStarts[startLineInfo.line] ?? tokenStart;
814
+ const standalone = sourceFile.text.slice(lineStart, tokenStart).trim().length === 0;
815
+ const range = { start: tokenStart, end: tokenEnd };
816
+ const entry = parseAnnotationEntry(tokenText, line, standalone, tokenStart, range);
817
+ scannedComments.push({
818
+ endLine,
819
+ entry,
820
+ kind: entry?.kind ?? 'other-comment',
821
+ range,
822
+ standalone,
823
+ startLine: line,
824
+ });
825
+ if (!entry) {
826
+ continue;
827
+ }
828
+ const lineEntries = entriesByLine.get(line);
829
+ if (lineEntries) {
830
+ lineEntries.push(entry);
831
+ }
832
+ else {
833
+ entriesByLine.set(line, [entry]);
834
+ }
835
+ entries.push(entry);
836
+ }
837
+ if (sourceFile.languageVariant === ts.LanguageVariant.JSX) {
838
+ const existingCommentRanges = new Set(scannedComments.map((comment) => `${comment.range.start}:${comment.range.end}`));
839
+ const sourceLines = sourceFile.text.split(/\r?\n/u);
840
+ let absoluteLineStart = 0;
841
+ for (let lineIndex = 0; lineIndex < sourceLines.length; lineIndex += 1) {
842
+ const rawLine = sourceLines[lineIndex] ?? '';
843
+ const trimmedStart = rawLine.trimStart();
844
+ if (!trimmedStart.startsWith('//')) {
845
+ absoluteLineStart += rawLine.length + 1;
846
+ continue;
847
+ }
848
+ const trimmedOffset = rawLine.indexOf(trimmedStart);
849
+ const start = absoluteLineStart + Math.max(trimmedOffset, 0);
850
+ const end = absoluteLineStart + rawLine.length;
851
+ const rangeKey = `${start}:${end}`;
852
+ if (existingCommentRanges.has(rangeKey)) {
853
+ absoluteLineStart += rawLine.length + 1;
854
+ continue;
855
+ }
856
+ const line = lineIndex + 1;
857
+ const range = { start, end };
858
+ const entry = parseAnnotationEntry(trimmedStart, line, true, start, range);
859
+ scannedComments.push({
860
+ endLine: line,
861
+ entry,
862
+ kind: entry?.kind ?? 'other-comment',
863
+ range,
864
+ standalone: true,
865
+ startLine: line,
866
+ });
867
+ if (entry) {
868
+ const lineEntries = entriesByLine.get(line);
869
+ if (lineEntries) {
870
+ lineEntries.push(entry);
871
+ }
872
+ else {
873
+ entriesByLine.set(line, [entry]);
874
+ }
875
+ entries.push(entry);
876
+ }
877
+ absoluteLineStart += rawLine.length + 1;
878
+ }
879
+ scannedComments.sort((left, right) => left.range.start - right.range.start);
880
+ }
881
+ const annotationBlocks = [];
882
+ for (let index = 0; index < scannedComments.length; index += 1) {
883
+ const scannedComment = scannedComments[index];
884
+ if (scannedComment.kind !== 'annotation' || !scannedComment.standalone) {
885
+ continue;
886
+ }
887
+ const previousComment = scannedComments[index - 1];
888
+ if (previousComment &&
889
+ previousComment.kind === 'annotation' &&
890
+ previousComment.standalone &&
891
+ previousComment.endLine + 1 === scannedComment.startLine) {
892
+ continue;
893
+ }
894
+ const blockComments = [scannedComment];
895
+ let currentIndex = index + 1;
896
+ while (currentIndex < scannedComments.length) {
897
+ const candidate = scannedComments[currentIndex];
898
+ const previousBlockComment = blockComments[blockComments.length - 1];
899
+ if (candidate.kind !== 'annotation' ||
900
+ !candidate.standalone ||
901
+ previousBlockComment.endLine + 1 !== candidate.startLine) {
902
+ break;
903
+ }
904
+ blockComments.push(candidate);
905
+ currentIndex += 1;
906
+ }
907
+ const annotations = blockComments.flatMap((comment) => comment.entry?.kind === 'annotation' ? comment.entry.annotations : []);
908
+ const startLine = blockComments[0]?.startLine ?? scannedComment.startLine;
909
+ const endLine = blockComments[blockComments.length - 1]?.endLine ?? scannedComment.endLine;
910
+ const targetNode = candidateNodesByStartLine.get(endLine + 1)?.[0];
911
+ const block = {
912
+ annotations,
913
+ endLine,
914
+ range: {
915
+ start: blockComments[0]?.range.start ?? scannedComment.range.start,
916
+ end: blockComments[blockComments.length - 1]?.range.end ?? scannedComment.range.end,
917
+ },
918
+ startLine,
919
+ targetNode,
920
+ text: blockComments.map((comment) => comment.entry?.text ?? '').join('\n'),
921
+ };
922
+ annotationBlocks.push(block);
923
+ if (targetNode) {
924
+ blocksByTargetNode.set(targetNode, block);
925
+ }
926
+ }
927
+ return {
928
+ getAttachedAnnotationBlock(node) {
929
+ return blocksByTargetNode.get(node);
930
+ },
931
+ getAttachedAnnotations(node) {
932
+ return blocksByTargetNode.get(node)?.annotations ?? [];
933
+ },
934
+ getBlocks() {
935
+ return annotationBlocks;
936
+ },
937
+ getEntries() {
938
+ return entries;
939
+ },
940
+ getEntriesForLine(line) {
941
+ return entriesByLine.get(line) ?? [];
942
+ },
943
+ hasAttachedAnnotation(node, name) {
944
+ return blocksByTargetNode.get(node)?.annotations.some((annotation) => annotation.name === name) ??
945
+ false;
946
+ },
947
+ };
948
+ }