@hyperfixi/core 3.3.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (378) hide show
  1. package/README.md +57 -179
  2. package/dist/ast-utils/index.cjs +74 -806
  3. package/dist/ast-utils/index.d.ts +1 -1
  4. package/dist/ast-utils/index.mjs +74 -805
  5. package/dist/ast-utils/interchange/engine-positions.d.ts +3 -0
  6. package/dist/ast-utils/interchange/index.d.ts +1 -2
  7. package/dist/hyperfixi.js +19 -2
  8. package/dist/index.d.ts +2 -22
  9. package/dist/index.mjs +3 -29128
  10. package/dist/lsp-metadata.cjs +77 -73
  11. package/dist/lsp-metadata.d.ts +4 -4
  12. package/dist/lsp-metadata.mjs +77 -73
  13. package/dist/metadata.cjs +34 -266
  14. package/dist/metadata.d.ts +31 -26
  15. package/dist/metadata.mjs +34 -266
  16. package/dist/multilingual/index.cjs +16 -382
  17. package/dist/multilingual/index.d.ts +4 -32
  18. package/dist/multilingual/index.mjs +15 -377
  19. package/dist/reference/index.cjs +67 -216
  20. package/dist/reference/index.d.ts +0 -3
  21. package/dist/reference/index.mjs +68 -216
  22. package/dist/version.d.ts +1 -1
  23. package/package.json +13 -179
  24. package/dist/__test-utils__/context-builders.d.ts +0 -42
  25. package/dist/__test-utils__/error-testing.d.ts +0 -18
  26. package/dist/__test-utils__/index.d.ts +0 -6
  27. package/dist/__test-utils__/mock-types.d.ts +0 -57
  28. package/dist/__test-utils__/parser-context-mock.d.ts +0 -7
  29. package/dist/__test-utils__/parser-helpers.d.ts +0 -38
  30. package/dist/api/hyperscript-api.d.ts +0 -90
  31. package/dist/api/lokascript-api.d.ts +0 -9
  32. package/dist/ast/command-slots.d.ts +0 -140
  33. package/dist/ast/guards.d.ts +0 -15
  34. package/dist/ast/legacy.d.ts +0 -15
  35. package/dist/ast/nodes.d.ts +0 -243
  36. package/dist/ast-utils/interchange/from-core.d.ts +0 -12
  37. package/dist/ast-utils/interchange/to-core.d.ts +0 -8
  38. package/dist/behaviors/boosted.d.ts +0 -29
  39. package/dist/behaviors/history-swap.d.ts +0 -24
  40. package/dist/behaviors/index.cjs +0 -1155
  41. package/dist/behaviors/index.d.ts +0 -4
  42. package/dist/behaviors/index.mjs +0 -1145
  43. package/dist/bundle-generator/executor-core.d.ts +0 -4
  44. package/dist/bundle-generator/generator.d.ts +0 -4
  45. package/dist/bundle-generator/index.cjs +0 -2804
  46. package/dist/bundle-generator/index.d.ts +0 -6
  47. package/dist/bundle-generator/index.mjs +0 -2779
  48. package/dist/bundle-generator/parser-templates.d.ts +0 -6
  49. package/dist/bundle-generator/template-capabilities.d.ts +0 -12
  50. package/dist/bundle-generator/templates.d.ts +0 -12
  51. package/dist/bundle-generator/types.d.ts +0 -34
  52. package/dist/chunks/bridge-CI9SOl8u.js +0 -2
  53. package/dist/chunks/browser-modular-7CpI5VF2.js +0 -2
  54. package/dist/chunks/index-BwXDEK0m.js +0 -2
  55. package/dist/chunks/index-DQi2o8Lk.js +0 -2
  56. package/dist/chunks/index-uCOQ8Qn0.js +0 -2
  57. package/dist/commands/advanced/js.d.ts +0 -40
  58. package/dist/commands/animation/measure.d.ts +0 -43
  59. package/dist/commands/animation/settle.d.ts +0 -38
  60. package/dist/commands/animation/start-view-transition.d.ts +0 -38
  61. package/dist/commands/animation/take.d.ts +0 -41
  62. package/dist/commands/animation/transition.d.ts +0 -49
  63. package/dist/commands/async/fetch.d.ts +0 -61
  64. package/dist/commands/async/wait.d.ts +0 -51
  65. package/dist/commands/behaviors/install.d.ts +0 -40
  66. package/dist/commands/content/append.d.ts +0 -26
  67. package/dist/commands/content/insertion-base.d.ts +0 -60
  68. package/dist/commands/content/prepend.d.ts +0 -26
  69. package/dist/commands/control-flow/break.d.ts +0 -29
  70. package/dist/commands/control-flow/continue.d.ts +0 -29
  71. package/dist/commands/control-flow/exit.d.ts +0 -29
  72. package/dist/commands/control-flow/halt.d.ts +0 -39
  73. package/dist/commands/control-flow/if.d.ts +0 -58
  74. package/dist/commands/control-flow/repeat.d.ts +0 -50
  75. package/dist/commands/control-flow/return.d.ts +0 -33
  76. package/dist/commands/control-flow/signal-base.d.ts +0 -18
  77. package/dist/commands/control-flow/throw.d.ts +0 -34
  78. package/dist/commands/control-flow/unless.d.ts +0 -3
  79. package/dist/commands/data/clear.d.ts +0 -37
  80. package/dist/commands/data/decrement.d.ts +0 -3
  81. package/dist/commands/data/default.d.ts +0 -60
  82. package/dist/commands/data/get.d.ts +0 -35
  83. package/dist/commands/data/increment.d.ts +0 -42
  84. package/dist/commands/data/set.d.ts +0 -76
  85. package/dist/commands/decorators/index.d.ts +0 -14
  86. package/dist/commands/dom/add.d.ts +0 -44
  87. package/dist/commands/dom/close.d.ts +0 -32
  88. package/dist/commands/dom/dom-modification-base.d.ts +0 -48
  89. package/dist/commands/dom/empty.d.ts +0 -32
  90. package/dist/commands/dom/hide.d.ts +0 -28
  91. package/dist/commands/dom/make.d.ts +0 -34
  92. package/dist/commands/dom/open.d.ts +0 -34
  93. package/dist/commands/dom/process-partials.d.ts +0 -51
  94. package/dist/commands/dom/put.d.ts +0 -42
  95. package/dist/commands/dom/remove.d.ts +0 -46
  96. package/dist/commands/dom/reset.d.ts +0 -32
  97. package/dist/commands/dom/select.d.ts +0 -32
  98. package/dist/commands/dom/show.d.ts +0 -29
  99. package/dist/commands/dom/swap.d.ts +0 -65
  100. package/dist/commands/dom/toggle.d.ts +0 -69
  101. package/dist/commands/dom/visibility-base.d.ts +0 -22
  102. package/dist/commands/events/send.d.ts +0 -3
  103. package/dist/commands/events/trigger.d.ts +0 -49
  104. package/dist/commands/execution/blur.d.ts +0 -32
  105. package/dist/commands/execution/call.d.ts +0 -35
  106. package/dist/commands/execution/focus.d.ts +0 -32
  107. package/dist/commands/execution/pseudo-command.d.ts +0 -41
  108. package/dist/commands/helpers/attribute-manipulation.d.ts +0 -11
  109. package/dist/commands/helpers/attribute-target.d.ts +0 -9
  110. package/dist/commands/helpers/batch-dom-operations.d.ts +0 -12
  111. package/dist/commands/helpers/body-ops.d.ts +0 -10
  112. package/dist/commands/helpers/class-manipulation.d.ts +0 -11
  113. package/dist/commands/helpers/condition-helpers.d.ts +0 -4
  114. package/dist/commands/helpers/dom-mutation.d.ts +0 -16
  115. package/dist/commands/helpers/duration-parsing.d.ts +0 -8
  116. package/dist/commands/helpers/element-property-access.d.ts +0 -7
  117. package/dist/commands/helpers/element-resolution.d.ts +0 -16
  118. package/dist/commands/helpers/error-helpers.d.ts +0 -17
  119. package/dist/commands/helpers/event-helpers.d.ts +0 -13
  120. package/dist/commands/helpers/event-waiting.d.ts +0 -37
  121. package/dist/commands/helpers/index.d.ts +0 -32
  122. package/dist/commands/helpers/input-validator.d.ts +0 -23
  123. package/dist/commands/helpers/loop-executor.d.ts +0 -56
  124. package/dist/commands/helpers/numeric-target-parser.d.ts +0 -21
  125. package/dist/commands/helpers/property-target.d.ts +0 -20
  126. package/dist/commands/helpers/selector-type-detection.d.ts +0 -24
  127. package/dist/commands/helpers/slots.d.ts +0 -5
  128. package/dist/commands/helpers/smart-element.d.ts +0 -16
  129. package/dist/commands/helpers/style-manipulation.d.ts +0 -16
  130. package/dist/commands/helpers/target-elements.d.ts +0 -5
  131. package/dist/commands/helpers/temporal-modifiers.d.ts +0 -15
  132. package/dist/commands/helpers/url-argument-parser.d.ts +0 -13
  133. package/dist/commands/helpers/url-validation.d.ts +0 -7
  134. package/dist/commands/helpers/variable-access.d.ts +0 -13
  135. package/dist/commands/helpers/visibility-target-parser.d.ts +0 -15
  136. package/dist/commands/helpers/write-target.d.ts +0 -42
  137. package/dist/commands/index.cjs +0 -24168
  138. package/dist/commands/index.d.ts +0 -171
  139. package/dist/commands/index.mjs +0 -23981
  140. package/dist/commands/manifest.d.ts +0 -17
  141. package/dist/commands/navigation/go.d.ts +0 -58
  142. package/dist/commands/navigation/push-url.d.ts +0 -48
  143. package/dist/commands/navigation/replace-url.d.ts +0 -3
  144. package/dist/commands/navigation/scroll-to.d.ts +0 -43
  145. package/dist/commands/templates/render.d.ts +0 -47
  146. package/dist/commands/utility/beep.d.ts +0 -41
  147. package/dist/commands/utility/breakpoint.d.ts +0 -32
  148. package/dist/commands/utility/copy.d.ts +0 -41
  149. package/dist/commands/utility/log.d.ts +0 -36
  150. package/dist/commands/utility/pick.d.ts +0 -47
  151. package/dist/commands/utility/tell.d.ts +0 -39
  152. package/dist/compatibility/browser-bundle-classic.d.ts +0 -17
  153. package/dist/compatibility/browser-bundle-hybrid-complete.d.ts +0 -22
  154. package/dist/compatibility/browser-bundle-hybrid-hx.d.ts +0 -43
  155. package/dist/compatibility/browser-bundle-lite.d.ts +0 -15
  156. package/dist/compatibility/browser-bundle-modular.d.ts +0 -18
  157. package/dist/compatibility/browser-bundle-multilingual.d.ts +0 -19
  158. package/dist/compatibility/browser-bundle-semantic-complete.d.ts +0 -24
  159. package/dist/compatibility/browser-bundle-textshelf-minimal.d.ts +0 -16
  160. package/dist/compatibility/browser-bundle-textshelf-profile.d.ts +0 -18
  161. package/dist/compatibility/browser-modular.d.ts +0 -42
  162. package/dist/compatibility/browser-tests/helpers/semantic-page.d.ts +0 -3
  163. package/dist/compatibility/browser-tests/test-utils.d.ts +0 -21
  164. package/dist/compatibility/bundle-shell.d.ts +0 -13
  165. package/dist/compatibility/bundle-sources.d.ts +0 -4
  166. package/dist/compatibility/eval-hyperscript.d.ts +0 -16
  167. package/dist/compatibility/hyperscript-adapter.d.ts +0 -38
  168. package/dist/core/ast-property-utils.d.ts +0 -2
  169. package/dist/core/context.d.ts +0 -19
  170. package/dist/core/dom.d.ts +0 -15
  171. package/dist/core/evaluator-types.d.ts +0 -5
  172. package/dist/core/events.d.ts +0 -48
  173. package/dist/core/executor.d.ts +0 -34
  174. package/dist/core/expression-evaluator.d.ts +0 -6
  175. package/dist/core/expression-registry.d.ts +0 -8
  176. package/dist/core/scope-hooks.d.ts +0 -24
  177. package/dist/debug/debug-controller.d.ts +0 -62
  178. package/dist/debug/index.d.ts +0 -5
  179. package/dist/dom/attribute-processor.d.ts +0 -75
  180. package/dist/dom/detect-language.d.ts +0 -3
  181. package/dist/dom/minimal-attribute-processor.d.ts +0 -20
  182. package/dist/expressions/base-expression.d.ts +0 -27
  183. package/dist/expressions/bundles/common-expressions.d.ts +0 -10
  184. package/dist/expressions/bundles/core-expressions.d.ts +0 -8
  185. package/dist/expressions/bundles/full-expressions.d.ts +0 -11
  186. package/dist/expressions/bundles/index.d.ts +0 -7
  187. package/dist/expressions/collection/index.d.ts +0 -10
  188. package/dist/expressions/conversion/index.d.ts +0 -31
  189. package/dist/expressions/expression-tiers.d.ts +0 -13
  190. package/dist/expressions/index.cjs +0 -4331
  191. package/dist/expressions/index.d.ts +0 -13
  192. package/dist/expressions/index.mjs +0 -4312
  193. package/dist/expressions/logical/index.d.ts +0 -61
  194. package/dist/expressions/mathematical/index.d.ts +0 -80
  195. package/dist/expressions/positional/index.d.ts +0 -31
  196. package/dist/expressions/properties/index.d.ts +0 -27
  197. package/dist/expressions/property-access-utils.d.ts +0 -23
  198. package/dist/expressions/references/index.d.ts +0 -39
  199. package/dist/expressions/shared/comparison-utils.d.ts +0 -10
  200. package/dist/expressions/shared/index.d.ts +0 -10
  201. package/dist/expressions/shared/number-utils.d.ts +0 -8
  202. package/dist/expressions/shared/tracking.d.ts +0 -20
  203. package/dist/expressions/shared/validation-utils.d.ts +0 -13
  204. package/dist/expressions/special/index.d.ts +0 -78
  205. package/dist/expressions/type-helpers.d.ts +0 -11
  206. package/dist/expressions/type-registry.d.ts +0 -57
  207. package/dist/expressions/validation-helpers.d.ts +0 -15
  208. package/dist/htmx/hcon.d.ts +0 -9
  209. package/dist/htmx/htmx-attribute-processor.d.ts +0 -120
  210. package/dist/htmx/htmx-translator.d.ts +0 -22
  211. package/dist/htmx/i18n-hooks.d.ts +0 -18
  212. package/dist/htmx/i18n-orchestrator.d.ts +0 -16
  213. package/dist/htmx/index.d.ts +0 -3
  214. package/dist/htmx/lang-resolver.d.ts +0 -3
  215. package/dist/htmx/sse.d.ts +0 -60
  216. package/dist/htmx/ws.d.ts +0 -59
  217. package/dist/hyperfixi-browser-classic-i18n.js +0 -2
  218. package/dist/hyperfixi-browser.js +0 -2
  219. package/dist/hyperfixi-classic-i18n.js +0 -2
  220. package/dist/hyperfixi-hx-v4.js +0 -1
  221. package/dist/hyperfixi-hx.js +0 -1
  222. package/dist/hyperfixi-hybrid-complete.js +0 -1
  223. package/dist/hyperfixi-hybrid-hx.js +0 -1
  224. package/dist/hyperfixi-multilingual.js +0 -2
  225. package/dist/hyperfixi.mjs +0 -2
  226. package/dist/i18n/error-catalog.d.ts +0 -12
  227. package/dist/index.cjs +0 -29159
  228. package/dist/index.min.js +0 -2
  229. package/dist/lib/dom-globals-shim.d.ts +0 -2
  230. package/dist/lib/index.d.ts +0 -4
  231. package/dist/lib/morph-adapter.d.ts +0 -9
  232. package/dist/lib/swap-executor.d.ts +0 -12
  233. package/dist/lib/view-transitions.d.ts +0 -7
  234. package/dist/lokascript-browser-classic-i18n.js +0 -2
  235. package/dist/lokascript-browser.js +0 -2
  236. package/dist/lokascript-hybrid-complete.js +0 -1
  237. package/dist/lokascript-hybrid-hx.js +0 -1
  238. package/dist/lokascript-multilingual.js +0 -2
  239. package/dist/lse/index.cjs +0 -84
  240. package/dist/lse/index.d.ts +0 -15
  241. package/dist/lse/index.mjs +0 -71
  242. package/dist/multilingual/bridge.d.ts +0 -38
  243. package/dist/multilingual/schema-roles.d.ts +0 -3
  244. package/dist/parser/__types__/test-helpers.d.ts +0 -25
  245. package/dist/parser/command-grammar.d.ts +0 -14
  246. package/dist/parser/command-node-builder.d.ts +0 -46
  247. package/dist/parser/command-parsers/animation-commands.d.ts +0 -6
  248. package/dist/parser/command-parsers/async-commands.d.ts +0 -5
  249. package/dist/parser/command-parsers/control-flow-commands.d.ts +0 -7
  250. package/dist/parser/command-parsers/declared-commands.d.ts +0 -6
  251. package/dist/parser/command-parsers/dom-commands.d.ts +0 -11
  252. package/dist/parser/command-parsers/event-commands.d.ts +0 -4
  253. package/dist/parser/command-parsers/navigation-commands.d.ts +0 -6
  254. package/dist/parser/command-parsers/utility-commands.d.ts +0 -14
  255. package/dist/parser/command-parsers/variable-commands.d.ts +0 -12
  256. package/dist/parser/error-handler.d.ts +0 -34
  257. package/dist/parser/extensions.d.ts +0 -43
  258. package/dist/parser/full-parser.cjs +0 -7943
  259. package/dist/parser/full-parser.d.ts +0 -4
  260. package/dist/parser/full-parser.mjs +0 -7940
  261. package/dist/parser/helpers/ast-helpers.d.ts +0 -24
  262. package/dist/parser/helpers/parsing-helpers.d.ts +0 -19
  263. package/dist/parser/helpers/token-helpers.d.ts +0 -28
  264. package/dist/parser/hybrid/aliases.cjs +0 -44
  265. package/dist/parser/hybrid/aliases.d.ts +0 -7
  266. package/dist/parser/hybrid/aliases.mjs +0 -37
  267. package/dist/parser/hybrid/ast-types.cjs +0 -3
  268. package/dist/parser/hybrid/ast-types.d.ts +0 -97
  269. package/dist/parser/hybrid/ast-types.mjs +0 -2
  270. package/dist/parser/hybrid/index.cjs +0 -1185
  271. package/dist/parser/hybrid/index.d.ts +0 -6
  272. package/dist/parser/hybrid/index.mjs +0 -1175
  273. package/dist/parser/hybrid/parser-core.cjs +0 -1171
  274. package/dist/parser/hybrid/parser-core.d.ts +0 -69
  275. package/dist/parser/hybrid/parser-core.mjs +0 -1169
  276. package/dist/parser/hybrid/tokenizer.cjs +0 -255
  277. package/dist/parser/hybrid/tokenizer.d.ts +0 -9
  278. package/dist/parser/hybrid/tokenizer.mjs +0 -252
  279. package/dist/parser/hybrid-parser.cjs +0 -1249
  280. package/dist/parser/hybrid-parser.d.ts +0 -10
  281. package/dist/parser/hybrid-parser.mjs +0 -1242
  282. package/dist/parser/parser-constants.d.ts +0 -100
  283. package/dist/parser/parser-interface.d.ts +0 -12
  284. package/dist/parser/parser-types.d.ts +0 -164
  285. package/dist/parser/parser.d.ts +0 -165
  286. package/dist/parser/pratt-parser.d.ts +0 -41
  287. package/dist/parser/regex-parser.cjs +0 -422
  288. package/dist/parser/regex-parser.d.ts +0 -4
  289. package/dist/parser/regex-parser.mjs +0 -419
  290. package/dist/parser/runtime.d.ts +0 -14
  291. package/dist/parser/semantic-integration.d.ts +0 -17
  292. package/dist/parser/token-consumer.d.ts +0 -34
  293. package/dist/parser/token-predicates.d.ts +0 -77
  294. package/dist/parser/tokenizer.d.ts +0 -28
  295. package/dist/parser/types.d.ts +0 -105
  296. package/dist/performance/expression-cache.d.ts +0 -78
  297. package/dist/performance/integration.d.ts +0 -40
  298. package/dist/performance/production-monitor.d.ts +0 -67
  299. package/dist/registry/browser-types.cjs +0 -81
  300. package/dist/registry/browser-types.d.ts +0 -20
  301. package/dist/registry/browser-types.mjs +0 -76
  302. package/dist/registry/environment.cjs +0 -36
  303. package/dist/registry/environment.d.ts +0 -19
  304. package/dist/registry/environment.mjs +0 -30
  305. package/dist/registry/event-source-registry.d.ts +0 -54
  306. package/dist/registry/examples/server-commands.d.ts +0 -6
  307. package/dist/registry/examples/server-event-source.d.ts +0 -32
  308. package/dist/registry/index.cjs +0 -14055
  309. package/dist/registry/index.d.ts +0 -39
  310. package/dist/registry/index.mjs +0 -14039
  311. package/dist/registry/runtime-integration.d.ts +0 -23
  312. package/dist/registry/universal-types.cjs +0 -91
  313. package/dist/registry/universal-types.d.ts +0 -35
  314. package/dist/registry/universal-types.mjs +0 -86
  315. package/dist/runtime/cleanup-registry.d.ts +0 -47
  316. package/dist/runtime/command-adapter.d.ts +0 -69
  317. package/dist/runtime/environment.d.ts +0 -75
  318. package/dist/runtime/plugin.d.ts +0 -14
  319. package/dist/runtime/runtime-base.d.ts +0 -100
  320. package/dist/runtime/runtime-factory.d.ts +0 -29
  321. package/dist/runtime/runtime.d.ts +0 -20
  322. package/dist/runtime/temporal-modifiers.d.ts +0 -37
  323. package/dist/test-setup.d.ts +0 -28
  324. package/dist/test-utilities.d.ts +0 -39
  325. package/dist/types/base-types.d.ts +0 -231
  326. package/dist/types/code-fix.d.ts +0 -39
  327. package/dist/types/command-metadata.d.ts +0 -57
  328. package/dist/types/command-types.d.ts +0 -262
  329. package/dist/types/context-types.d.ts +0 -106
  330. package/dist/types/core-context.d.ts +0 -22
  331. package/dist/types/core.d.ts +0 -143
  332. package/dist/types/error-codes.d.ts +0 -207
  333. package/dist/types/expression-types.d.ts +0 -155
  334. package/dist/types/hooks.d.ts +0 -45
  335. package/dist/types/index.d.ts +0 -32
  336. package/dist/types/program.d.ts +0 -8
  337. package/dist/types/result.d.ts +0 -73
  338. package/dist/types/template-types.d.ts +0 -162
  339. package/dist/types/type-guards.d.ts +0 -24
  340. package/dist/types/unified-types.d.ts +0 -91
  341. package/dist/utils/beep.d.ts +0 -8
  342. package/dist/utils/debug-events.d.ts +0 -41
  343. package/dist/utils/debug.d.ts +0 -35
  344. package/dist/utils/dom-utils.d.ts +0 -16
  345. package/dist/utils/element-check.d.ts +0 -8
  346. package/dist/utils/keyboard-shortcuts.d.ts +0 -18
  347. package/dist/utils/performance.d.ts +0 -40
  348. package/dist/validation/command-pattern-validator.d.ts +0 -53
  349. package/dist/validation/common-validators.d.ts +0 -24
  350. package/dist/validation/lightweight-validators.d.ts +0 -113
  351. package/dist/validation/partial-validation-types.d.ts +0 -50
  352. package/dist/validation/partial-validator.d.ts +0 -6
  353. package/dist/validation/partial-warning-formatter.d.ts +0 -6
  354. package/dist/validation/validate-cli.d.ts +0 -41
  355. package/vocab/htmx/ar.js +0 -62
  356. package/vocab/htmx/bn.js +0 -65
  357. package/vocab/htmx/de.js +0 -83
  358. package/vocab/htmx/en.js +0 -24
  359. package/vocab/htmx/es.js +0 -79
  360. package/vocab/htmx/fr.js +0 -79
  361. package/vocab/htmx/he.js +0 -61
  362. package/vocab/htmx/hi.js +0 -81
  363. package/vocab/htmx/id.js +0 -76
  364. package/vocab/htmx/it.js +0 -79
  365. package/vocab/htmx/ja.js +0 -85
  366. package/vocab/htmx/ko.js +0 -81
  367. package/vocab/htmx/ms.js +0 -58
  368. package/vocab/htmx/pl.js +0 -80
  369. package/vocab/htmx/pt.js +0 -81
  370. package/vocab/htmx/qu.js +0 -83
  371. package/vocab/htmx/ru.js +0 -82
  372. package/vocab/htmx/sw.js +0 -79
  373. package/vocab/htmx/th.js +0 -67
  374. package/vocab/htmx/tl.js +0 -56
  375. package/vocab/htmx/tr.js +0 -86
  376. package/vocab/htmx/uk.js +0 -82
  377. package/vocab/htmx/vi.js +0 -59
  378. package/vocab/htmx/zh.js +0 -79
@@ -2187,819 +2187,88 @@ function minifyAST(ast) {
2187
2187
  return normalizeVisitResult(visitor.visit(ast, createVisitorContext()), ast);
2188
2188
  }
2189
2189
 
2190
- function fromCoreAST(node, options) {
2191
- return convertNode(node, options?.inferRoles ?? null);
2192
- }
2193
- function pos(node) {
2194
- const p = {};
2195
- if (typeof node.start === 'number')
2196
- p.start = node.start;
2197
- if (typeof node.end === 'number')
2198
- p.end = node.end;
2199
- if (typeof node.line === 'number')
2200
- p.line = node.line;
2201
- if (typeof node.column === 'number')
2202
- p.column = node.column;
2203
- return p;
2204
- }
2205
- function convertNode(node, infer) {
2206
- if (!node)
2207
- return { type: 'literal', value: null };
2208
- switch (node.type) {
2209
- case 'eventHandler':
2210
- return convertEventHandler(node, infer);
2211
- case 'command':
2212
- return convertCommand$1(node, infer);
2213
- case 'CommandSequence':
2214
- return convertCommandSequence(node, infer);
2215
- case 'Program': {
2216
- const statements = (node.statements ?? []);
2217
- if (statements.length === 0) {
2218
- return { type: 'literal', value: null, ...pos(node) };
2219
- }
2220
- if (statements.length === 1) {
2221
- return convertNode(statements[0], infer);
2222
- }
2223
- return convertNode(statements[0], infer);
2224
- }
2225
- case 'block':
2226
- return convertBlock(node, infer);
2227
- case 'errorCommand':
2228
- return {
2229
- type: 'error',
2230
- message: node.message ?? 'Parse error',
2231
- token: node.token ?? undefined,
2232
- ...pos(node),
2233
- };
2234
- case 'literal':
2235
- return {
2236
- type: 'literal',
2237
- value: node.value,
2238
- ...pos(node),
2239
- };
2240
- case 'string':
2241
- return { type: 'literal', value: node.value, ...pos(node) };
2242
- case 'selector':
2243
- return {
2244
- type: 'selector',
2245
- value: (node.value ?? node.selector ?? ''),
2246
- ...pos(node),
2247
- };
2248
- case 'contextReference':
2249
- return {
2250
- type: 'identifier',
2251
- value: (node.name ?? node.contextType ?? ''),
2252
- ...pos(node),
2253
- };
2254
- case 'identifier':
2255
- if (node.scope === 'element' || node.scope === 'local' || node.scope === 'global') {
2256
- return {
2257
- type: 'variable',
2258
- name: (node.name ?? ''),
2259
- scope: node.scope,
2260
- ...pos(node),
2261
- };
2262
- }
2263
- return {
2264
- type: 'identifier',
2265
- value: (node.name ?? node.value ?? ''),
2266
- name: (node.name ?? ''),
2267
- ...pos(node),
2268
- };
2269
- case 'propertyAccess':
2270
- case 'possessiveExpression':
2271
- return convertPossessive(node, infer);
2272
- case 'memberExpression':
2273
- return convertMember(node, infer);
2274
- case 'binaryExpression':
2275
- return convertBinary(node, infer);
2276
- case 'callExpression':
2277
- return convertCall(node, infer);
2278
- case 'unaryExpression':
2279
- return {
2280
- type: 'unary',
2281
- operator: node.operator,
2282
- operand: convertNode(node.argument ?? node.operand, infer),
2283
- ...pos(node),
2284
- };
2285
- case 'typeCheckExpression':
2286
- return {
2287
- type: 'typeCheck',
2288
- value: convertNode(node.value, infer),
2289
- typeName: String(node.typeName),
2290
- nullOk: node.nullOk !== false,
2291
- negated: node.negated === true,
2292
- ...pos(node),
2293
- };
2294
- case 'timeExpression':
2295
- return { type: 'literal', value: node.value, ...pos(node) };
2296
- case 'templateLiteral':
2297
- return { type: 'literal', value: (node.raw ?? ''), ...pos(node) };
2298
- case 'variable':
2299
- return {
2300
- type: 'variable',
2301
- name: (node.name ?? ''),
2302
- scope: (node.scope ?? 'local'),
2303
- ...pos(node),
2304
- };
2305
- case 'arrayLiteral':
2306
- return {
2307
- type: 'array',
2308
- elements: (node.elements ?? []).map(element => convertNode(element, infer)),
2309
- ...pos(node),
2310
- };
2311
- case 'attributeAccess':
2312
- return {
2313
- type: 'possessive',
2314
- object: { type: 'identifier', value: 'me' },
2315
- property: `@${node.attributeName}`,
2316
- ...pos(node),
2317
- };
2318
- case 'propertyOfExpression': {
2319
- const property = node.property;
2320
- return {
2321
- type: 'possessive',
2322
- object: convertNode(node.target, infer),
2323
- property: (property?.name ?? property?.value ?? ''),
2324
- ...pos(node),
2325
- };
2326
- }
2327
- case 'htmlSelector':
2328
- return {
2329
- type: 'selector',
2330
- value: (node.value ?? node.selector ?? ''),
2331
- ...pos(node),
2332
- };
2333
- case 'positional':
2334
- return {
2335
- type: 'positional',
2336
- position: node.position,
2337
- ...(node.target ? { target: convertNode(node.target, infer) } : {}),
2338
- ...pos(node),
2339
- };
2340
- case 'positionalExpression':
2341
- return {
2342
- type: 'positional',
2343
- position: node.operator,
2344
- ...(node.argument ? { target: convertNode(node.argument, infer) } : {}),
2345
- ...pos(node),
2346
- };
2347
- default:
2348
- return {
2349
- type: 'error',
2350
- message: `Unknown core AST node type: ${node.type}`,
2351
- ...pos(node),
2352
- };
2353
- }
2354
- }
2355
- function convertEventHandler(node, infer) {
2356
- const event = (node.event ?? 'click');
2357
- const commands = (node.commands ?? node.body ?? []);
2358
- const body = commands.map(cmd => convertNode(cmd, infer));
2359
- const modifiers = buildEventModifiers(node);
2360
- return { type: 'event', event, modifiers, body, ...pos(node) };
2361
- }
2362
- function convertCommand$1(node, infer) {
2363
- const name = node.name;
2364
- if (name === '__ERROR__') {
2365
- return {
2366
- type: 'error',
2367
- message: node.diagnostics?.[0]
2368
- ?.message ?? 'Parse error',
2369
- ...pos(node),
2370
- };
2371
- }
2372
- if (name === 'if' || name === 'unless') {
2373
- return convertIfCommand(node, infer);
2374
- }
2375
- if (name === 'repeat') {
2376
- return convertRepeatCommand(node, infer);
2377
- }
2378
- const original = node.originalCommand;
2379
- const sum = node.modifiers?.to;
2380
- const counted = node.args?.[0];
2381
- if (name === 'set' &&
2382
- (original === 'increment' || original === 'decrement') &&
2383
- sum?.type === 'binaryExpression' &&
2384
- counted) {
2385
- return convertCommand$1({
2386
- ...node,
2387
- name: original,
2388
- args: [counted],
2389
- modifiers: { by: sum.right },
2390
- originalCommand: undefined,
2391
- }, infer);
2392
- }
2393
- const args = (node.args ?? []).map(arg => convertNode(arg, infer));
2394
- const target = node.target ? convertNode(node.target, infer) : undefined;
2395
- const modifiers = node.modifiers
2396
- ? convertModifiers(node.modifiers, infer)
2397
- : undefined;
2398
- const roles = inferRoles(name, args, modifiers, target, infer);
2399
- return {
2400
- type: 'command',
2401
- name,
2402
- args,
2403
- ...(target ? { target } : {}),
2404
- ...(modifiers && Object.keys(modifiers).length > 0 ? { modifiers } : {}),
2405
- ...(roles ? { roles } : {}),
2406
- ...(node.partial ? { partial: true } : {}),
2407
- ...pos(node),
2408
- };
2409
- }
2410
- function convertIfCommand(node, infer) {
2411
- const args = (node.args ?? []);
2412
- let condition;
2413
- let thenBranch;
2414
- let elseBranch;
2415
- if (node.condition) {
2416
- condition = convertNode(node.condition, infer);
2417
- thenBranch = (node.thenBranch ?? node.then ?? []).map(n => convertNode(n, infer));
2418
- elseBranch = node.elseBranch
2419
- ? node.elseBranch.map(n => convertNode(n, infer))
2420
- : node.else
2421
- ? node.else.map(n => convertNode(n, infer))
2422
- : undefined;
2423
- }
2424
- else {
2425
- condition = args[0] ? convertNode(args[0], infer) : { type: 'literal', value: true };
2426
- thenBranch = extractBlockCommands(args[1], infer);
2427
- elseBranch = args[2] ? extractBlockCommands(args[2], infer) : undefined;
2428
- }
2429
- if (node.name === 'unless') {
2430
- condition = { type: 'unary', operator: 'not', operand: condition };
2431
- }
2432
- return {
2433
- type: 'if',
2434
- condition,
2435
- thenBranch,
2436
- ...(elseBranch ? { elseBranch } : {}),
2437
- ...pos(node),
2438
- };
2439
- }
2440
- function convertRepeatCommand(node, infer) {
2441
- const slots = (node.modifiers ?? {});
2442
- const form = slotText(slots.loopType);
2443
- if (form === undefined)
2444
- return convertPositionalRepeat(node, infer);
2445
- const [bodyBlock, elseBlock] = (node.args ?? []);
2446
- const body = extractBlockCommands(bodyBlock, infer);
2447
- const indexName = slotText(slots.index);
2448
- const shared = {
2449
- ...(indexName ? { indexName } : {}),
2450
- ...(elseBlock ? { elseBody: extractBlockCommands(elseBlock, infer) } : {}),
2451
- ...pos(node),
2452
- };
2453
- const operand = (slot) => (slot ? convertNode(slot, infer) : undefined);
2454
- switch (form) {
2455
- case 'for':
2456
- return {
2457
- type: 'foreach',
2458
- itemName: slotText(slots.for) ?? 'it',
2459
- collection: operand(slots.in) ?? { type: 'literal', value: null },
2460
- body,
2461
- ...shared,
2462
- };
2463
- case 'times':
2464
- return { type: 'repeat', count: operand(slots.times), body, ...shared };
2465
- case 'while':
2466
- case 'until': {
2467
- const test = operand(slots[form]) ?? { type: 'literal', value: form === 'until' };
2468
- return {
2469
- type: 'while',
2470
- condition: form === 'until' ? { type: 'unary', operator: 'not', operand: test } : test,
2471
- ...(slots.bottomTested?.value === true ? { bottomTested: true } : {}),
2472
- body,
2473
- ...shared,
2474
- };
2475
- }
2476
- case 'until-event': {
2477
- const event = slotText(slots.event);
2478
- if (!event) {
2479
- return { type: 'error', message: "'repeat until event' has no event name", ...pos(node) };
2480
- }
2481
- const target = operand(slots.from);
2482
- return {
2483
- type: 'repeat',
2484
- untilEvent: event,
2485
- ...(target ? { untilEventTarget: target } : {}),
2486
- body,
2487
- ...shared,
2488
- };
2489
- }
2490
- default:
2491
- return { type: 'repeat', body, ...shared };
2492
- }
2493
- }
2494
- function slotText(slot) {
2495
- const text = slot?.value ?? slot?.name;
2496
- return typeof text === 'string' ? text : undefined;
2497
- }
2498
- function convertPositionalRepeat(node, infer) {
2499
- const args = (node.args ?? []);
2500
- if (args.length === 0) {
2501
- return { type: 'repeat', body: [], ...pos(node) };
2502
- }
2503
- const loopTypeNode = args[0];
2504
- const loopType = (loopTypeNode?.name ?? loopTypeNode?.value ?? 'forever');
2505
- const bodyBlock = args[args.length - 1];
2506
- switch (loopType) {
2507
- case 'times': {
2508
- const count = args[1] ? convertNode(args[1], infer) : undefined;
2509
- return {
2510
- type: 'repeat',
2511
- count,
2512
- body: extractBlockCommands(bodyBlock, infer),
2513
- ...pos(node),
2514
- };
2515
- }
2516
- case 'for': {
2517
- const itemName = (args[1]?.value ?? 'item');
2518
- const collection = args[2]
2519
- ? convertNode(args[2], infer)
2520
- : { type: 'identifier', value: '[]' };
2521
- return {
2522
- type: 'foreach',
2523
- itemName,
2524
- collection,
2525
- body: extractBlockCommands(bodyBlock, infer),
2526
- ...pos(node),
2527
- };
2528
- }
2529
- case 'while': {
2530
- const condition = args[1]
2531
- ? convertNode(args[1], infer)
2532
- : { type: 'literal', value: true };
2533
- return {
2534
- type: 'while',
2535
- condition,
2536
- body: extractBlockCommands(bodyBlock, infer),
2537
- ...pos(node),
2538
- };
2539
- }
2540
- default:
2541
- return {
2542
- type: 'repeat',
2543
- body: extractBlockCommands(bodyBlock, infer),
2544
- ...pos(node),
2545
- };
2546
- }
2547
- }
2548
- function convertCommandSequence(node, infer) {
2549
- const commands = (node.commands ?? []);
2550
- if (commands.length === 1) {
2551
- return convertNode(commands[0], infer);
2552
- }
2553
- return {
2554
- type: 'event',
2555
- event: 'click',
2556
- body: commands.map(cmd => convertNode(cmd, infer)),
2557
- ...pos(node),
2558
- };
2559
- }
2560
- function convertBlock(node, infer) {
2561
- const commands = (node.commands ?? []);
2562
- if (commands.length === 1) {
2563
- return convertNode(commands[0], infer);
2564
- }
2565
- return {
2566
- type: 'event',
2567
- event: 'click',
2568
- body: commands.map(cmd => convertNode(cmd, infer)),
2569
- ...pos(node),
2570
- };
2571
- }
2572
- function convertPossessive(node, infer) {
2573
- const object = node.object
2574
- ? convertNode(node.object, infer)
2575
- : { type: 'identifier', value: 'me' };
2576
- const property = typeof node.property === 'string'
2577
- ? node.property
2578
- : (node.property?.name ?? node.property?.value ?? '');
2579
- return { type: 'possessive', object, property, ...pos(node) };
2580
- }
2581
- function convertMember(node, infer) {
2582
- const object = node.object
2583
- ? convertNode(node.object, infer)
2584
- : { type: 'identifier', value: 'me' };
2585
- const property = typeof node.property === 'string'
2586
- ? node.property
2587
- : node.property
2588
- ? convertNode(node.property, infer)
2589
- : { type: 'literal', value: '' };
2590
- return {
2591
- type: 'member',
2592
- object,
2593
- property,
2594
- computed: (node.computed ?? false),
2595
- ...pos(node),
2596
- };
2597
- }
2598
- function convertBinary(node, infer) {
2599
- return {
2600
- type: 'binary',
2601
- operator: (node.operator ?? ''),
2602
- left: convertNode(node.left, infer),
2603
- right: convertNode(node.right, infer),
2604
- ...pos(node),
2605
- };
2606
- }
2607
- function convertCall(node, infer) {
2608
- const callee = typeof node.callee === 'string'
2609
- ? { type: 'identifier', value: node.callee, name: node.callee }
2610
- : convertNode(node.callee, infer);
2611
- const args = (node.arguments ?? node.args ?? []).map(a => convertNode(a, infer));
2612
- return { type: 'call', callee, args, ...pos(node) };
2613
- }
2614
- function convertModifiers(modifiers, infer) {
2615
- const result = {};
2616
- for (const [key, value] of Object.entries(modifiers)) {
2617
- result[key] = convertNode(value, infer);
2618
- }
2619
- return result;
2620
- }
2621
- function buildEventModifiers(node) {
2622
- return {
2623
- ...(node.once ? { once: true } : {}),
2624
- ...(node.debounce ? { debounce: node.debounce } : {}),
2625
- ...(node.throttle ? { throttle: node.throttle } : {}),
2626
- ...(node.prevent ? { prevent: true } : {}),
2627
- ...(node.stop ? { stop: true } : {}),
2628
- ...(node.capture ? { capture: true } : {}),
2629
- ...(node.passive ? { passive: true } : {}),
2630
- ...(node.from ? { from: node.from } : {}),
2631
- ...(node.selector && !node.from ? { from: node.selector } : {}),
2632
- };
2633
- }
2634
- function extractBlockCommands(block, infer) {
2635
- if (!block)
2636
- return [];
2637
- if (block.type === 'block') {
2638
- return (block.commands ?? []).map(cmd => convertNode(cmd, infer));
2639
- }
2640
- return [convertNode(block, infer)];
2641
- }
2642
- function inferRoles(name, args, modifiers, target, infer) {
2643
- const roles = {};
2644
- switch (name) {
2645
- case 'set': {
2646
- const toVal = modifiers?.to;
2647
- const second = args[1];
2648
- const marksTo = second?.type === 'identifier' &&
2649
- String(second.name ?? second.value ?? '').toLowerCase() === 'to';
2650
- if (marksTo && !toVal) {
2651
- return infer
2652
- ? infer(name, args, modifiers, target)
2653
- : null;
2654
- }
2655
- if (args[0])
2656
- roles.destination = args[0];
2657
- if (toVal && typeof toVal === 'object' && 'type' in toVal) {
2658
- roles.patient = toVal;
2659
- }
2660
- else if (args[1]) {
2661
- roles.patient = args[1];
2662
- }
2663
- break;
2664
- }
2665
- case 'go': {
2666
- const kw = (n) => {
2667
- if (!n || typeof n !== 'object')
2668
- return undefined;
2669
- const v = n;
2670
- if (v.type === 'identifier') {
2671
- if (typeof v.name === 'string' && v.name !== '')
2672
- return v.name;
2673
- return typeof v.value === 'string' ? v.value : undefined;
2674
- }
2675
- if (v.type === 'literal' && typeof v.value === 'string')
2676
- return v.value;
2677
- return undefined;
2678
- };
2679
- const asNode = (x) => x && typeof x === 'object' && 'type' in x ? x : undefined;
2680
- let destination;
2681
- let method;
2682
- const onMod = asNode(modifiers?.on);
2683
- const slotUrl = asNode(modifiers?.url);
2684
- const slotOf = asNode(modifiers?.of);
2685
- const slotHistory = kw(asNode(modifiers?.back)) ?? kw(asNode(modifiers?.forward));
2686
- if (slotHistory === 'back' || slotHistory === 'forward') {
2687
- destination = { type: 'identifier', value: slotHistory, name: slotHistory };
2688
- }
2689
- else if (slotUrl) {
2690
- destination = slotUrl;
2691
- method = { type: 'literal', value: 'url' };
2692
- }
2693
- else if (slotOf) {
2694
- destination = slotOf;
2695
- }
2696
- else if (args.length === 0 && onMod) {
2697
- destination = onMod;
2698
- if (kw(asNode(modifiers?.method)) === 'url') {
2699
- method = { type: 'literal', value: 'url' };
2700
- }
2701
- }
2702
- else {
2703
- const words = args.map(kw);
2704
- const urlIdx = words.indexOf('url');
2705
- if (urlIdx !== -1 && args[urlIdx + 1]) {
2706
- destination = args[urlIdx + 1];
2707
- method = { type: 'literal', value: 'url' };
2708
- }
2709
- else {
2710
- const SKIP = new Set(['to', 'the']);
2711
- const POSITION = new Set([
2712
- 'top',
2713
- 'middle',
2714
- 'bottom',
2715
- 'left',
2716
- 'center',
2717
- 'right',
2718
- 'smoothly',
2719
- 'instantly',
2720
- 'in',
2721
- 'new',
2722
- 'window',
2723
- ]);
2724
- const headIdx = args.findIndex((_, i) => {
2725
- const w = words[i];
2726
- return w === undefined || !SKIP.has(w);
2727
- });
2728
- const headWord = headIdx !== -1 ? words[headIdx] : undefined;
2729
- const ofIdx = words.indexOf('of');
2730
- if (headWord === 'back' || headWord === 'forward') {
2731
- destination = { type: 'identifier', value: headWord, name: headWord };
2732
- }
2733
- else if (ofIdx !== -1 && args[ofIdx + 1]) {
2734
- destination = kw(args[ofIdx + 1]) === 'the' ? args[ofIdx + 2] : args[ofIdx + 1];
2735
- }
2736
- else if (headIdx !== -1 && !POSITION.has(headWord ?? '')) {
2737
- destination = args[headIdx];
2738
- }
2739
- }
2740
- }
2741
- const destWord = kw(destination);
2742
- if ((destWord === 'back' || destWord === 'forward') && destination?.type !== 'identifier') {
2743
- destination = { type: 'identifier', value: destWord, name: destWord };
2744
- }
2745
- if (!destination && target)
2746
- destination = target;
2747
- if (destination)
2748
- roles.destination = destination;
2749
- if (method)
2750
- roles.method = method;
2751
- break;
2752
- }
2753
- default:
2754
- return infer
2755
- ? infer(name, args, modifiers, target)
2756
- : null;
2757
- }
2758
- return Object.keys(roles).length > 0 ? roles : null;
2759
- }
2760
-
2761
- const POS = { start: 0, end: 0, line: 1, column: 0 };
2762
- function nodePos(node) {
2763
- return {
2764
- start: node.start ?? POS.start,
2765
- end: node.end ?? POS.end,
2766
- line: node.line ?? POS.line,
2767
- column: node.column ?? POS.column,
2768
- };
2769
- }
2770
- function toCoreAST(node) {
2771
- if (!node)
2772
- return { type: 'literal', value: null, raw: 'null', ...POS };
2190
+ const isRecord = (value) => typeof value === 'object' && value !== null;
2191
+ const isEngineSpan = (value) => isRecord(value) &&
2192
+ typeof value.type === 'string' &&
2193
+ typeof value.start === 'number' &&
2194
+ typeof value.end === 'number';
2195
+ const COMMAND_TYPES = {
2196
+ call: ['getCommand'],
2197
+ trigger: ['sendCommand'],
2198
+ toggle: ['toggleCommand', 'toggleElementCommand'],
2199
+ transition: ['transitionCommand', 'viewTransitionCommand'],
2200
+ };
2201
+ function engineTypesFor(node) {
2773
2202
  switch (node.type) {
2774
2203
  case 'event':
2775
- return convertEvent(node);
2776
- case 'command':
2777
- return convertCommand(node);
2204
+ return ['onFeature'];
2778
2205
  case 'if':
2779
- return convertIf(node);
2206
+ return ['ifCommand'];
2780
2207
  case 'repeat':
2781
- return convertRepeat(node);
2782
2208
  case 'foreach':
2783
- return convertForEach(node);
2784
2209
  case 'while':
2785
- return convertWhile(node);
2786
- case 'literal':
2787
- return {
2788
- type: 'literal',
2789
- value: node.value,
2790
- raw: node.value === null ? 'null' : node.value === undefined ? '' : String(node.value),
2791
- ...nodePos(node),
2792
- };
2793
- case 'identifier':
2794
- return { type: 'identifier', name: node.name ?? node.value, ...nodePos(node) };
2795
- case 'selector':
2796
- return { type: 'selector', value: node.value, ...nodePos(node) };
2797
- case 'variable':
2798
- return { type: 'identifier', name: node.name, scope: node.scope, ...nodePos(node) };
2799
- case 'binary':
2800
- return {
2801
- type: 'binaryExpression',
2802
- operator: node.operator,
2803
- left: toCoreAST(node.left),
2804
- right: toCoreAST(node.right),
2805
- ...nodePos(node),
2806
- };
2807
- case 'unary':
2808
- return {
2809
- type: 'unaryExpression',
2810
- operator: node.operator,
2811
- argument: toCoreAST(node.operand),
2812
- prefix: true,
2813
- ...nodePos(node),
2814
- };
2815
- case 'typeCheck':
2816
- return {
2817
- type: 'typeCheckExpression',
2818
- value: toCoreAST(node.value),
2819
- typeName: node.typeName,
2820
- nullOk: node.nullOk,
2821
- negated: node.negated,
2822
- ...nodePos(node),
2823
- };
2824
- case 'member':
2825
- return {
2826
- type: 'memberExpression',
2827
- object: toCoreAST(node.object),
2828
- property: typeof node.property === 'string'
2829
- ? { type: 'identifier', name: node.property, ...POS }
2830
- : toCoreAST(node.property),
2831
- computed: node.computed ?? false,
2832
- ...nodePos(node),
2833
- };
2834
- case 'array':
2835
- return {
2836
- type: 'arrayLiteral',
2837
- elements: node.elements.map(element => toCoreAST(element)),
2838
- ...nodePos(node),
2839
- };
2840
- case 'possessive':
2841
- return {
2842
- type: 'possessiveExpression',
2843
- object: toCoreAST(node.object),
2844
- property: { type: 'identifier', name: node.property, ...POS },
2845
- ...nodePos(node),
2846
- };
2847
- case 'call':
2848
- return {
2849
- type: 'callExpression',
2850
- callee: toCoreAST(node.callee),
2851
- arguments: (node.args ?? []).map(a => toCoreAST(a)),
2852
- ...nodePos(node),
2853
- };
2854
- case 'positional':
2855
- return {
2856
- type: 'callExpression',
2857
- callee: { type: 'identifier', name: node.position, ...POS },
2858
- arguments: node.target ? [toCoreAST(node.target)] : [],
2859
- ...nodePos(node),
2860
- };
2861
- case 'error':
2862
- return { type: 'literal', value: null, raw: 'null', ...POS };
2863
- default: {
2864
- return { type: 'literal', value: null, raw: 'null', ...POS };
2865
- }
2866
- }
2867
- }
2868
- function convertEvent(node) {
2869
- const commands = (node.body ?? []).map(cmd => toCoreAST(cmd));
2870
- const modifiers = flattenEventModifiers(node.modifiers);
2871
- return {
2872
- type: 'eventHandler',
2873
- event: node.event,
2874
- commands,
2875
- ...modifiers,
2876
- ...nodePos(node),
2877
- };
2878
- }
2879
- function convertCommand(node) {
2880
- const result = {
2881
- type: 'command',
2882
- name: node.name,
2883
- args: (node.args ?? []).map(a => toCoreAST(a)),
2884
- isBlocking: false,
2885
- ...nodePos(node),
2886
- };
2887
- if (node.target) {
2888
- result.target = toCoreAST(node.target);
2889
- }
2890
- if (node.modifiers && Object.keys(node.modifiers).length > 0) {
2891
- const convertedModifiers = {};
2892
- for (const [key, value] of Object.entries(node.modifiers)) {
2893
- convertedModifiers[key] =
2894
- value && typeof value === 'object' && 'type' in value
2895
- ? toCoreAST(value)
2896
- : value;
2210
+ return ['repeatCommand'];
2211
+ case 'command': {
2212
+ const name = typeof node.name === 'string' ? node.name : '';
2213
+ return COMMAND_TYPES[name] ?? [`${name}Command`];
2897
2214
  }
2898
- result.modifiers = convertedModifiers;
2899
- }
2900
- return result;
2901
- }
2902
- function block(nodes) {
2903
- return { type: 'block', commands: nodes.map(n => toCoreAST(n)), ...POS };
2904
- }
2905
- function convertIf(node) {
2906
- const [elseIf, ...laterElseIfs] = node.elseIfBranches ?? [];
2907
- const elseBranch = elseIf
2908
- ? [
2909
- {
2910
- type: 'if',
2911
- condition: elseIf.condition,
2912
- thenBranch: elseIf.body,
2913
- elseIfBranches: laterElseIfs,
2914
- ...(node.elseBranch ? { elseBranch: node.elseBranch } : {}),
2915
- },
2916
- ]
2917
- : node.elseBranch;
2918
- return {
2919
- type: 'command',
2920
- name: 'if',
2921
- isBlocking: true,
2922
- args: [
2923
- toCoreAST(node.condition),
2924
- block(node.thenBranch),
2925
- ...(elseBranch ? [block(elseBranch)] : []),
2926
- ],
2927
- ...nodePos(node),
2215
+ default:
2216
+ return [];
2217
+ }
2218
+ }
2219
+ function engineSpans(tree, out = []) {
2220
+ if (Array.isArray(tree)) {
2221
+ for (const item of tree)
2222
+ engineSpans(item, out);
2223
+ return out;
2224
+ }
2225
+ if (!isRecord(tree))
2226
+ return out;
2227
+ if (isEngineSpan(tree) && /(Command|Feature)$/.test(tree.type))
2228
+ out.push(tree);
2229
+ for (const value of Object.values(tree)) {
2230
+ if (typeof value === 'object' && value !== null)
2231
+ engineSpans(value, out);
2232
+ }
2233
+ return out;
2234
+ }
2235
+ function withEnginePositions(nodes, source, engineTree) {
2236
+ const spans = engineSpans(engineTree);
2237
+ let cursor = 0;
2238
+ const lineStarts = [0];
2239
+ for (let i = 0; i < source.length; i++)
2240
+ if (source[i] === '\n')
2241
+ lineStarts.push(i + 1);
2242
+ const lineAndColumn = (offset) => {
2243
+ let line = 0;
2244
+ while (line + 1 < lineStarts.length && (lineStarts[line + 1] ?? Infinity) <= offset)
2245
+ line++;
2246
+ return { line: line + 1, column: offset - (lineStarts[line] ?? 0) };
2928
2247
  };
2929
- }
2930
- function loopCommand(node, form, operands) {
2931
- const modifiers = { loopType: slotString(form) };
2932
- for (const [slot, value] of Object.entries(operands)) {
2933
- if (value)
2934
- modifiers[slot] = value;
2935
- }
2936
- if (node.indexName)
2937
- modifiers.index = slotString(node.indexName);
2938
- return {
2939
- type: 'command',
2940
- name: 'repeat',
2941
- isBlocking: true,
2942
- args: [block(node.body), ...(node.elseBody ? [block(node.elseBody)] : [])],
2943
- modifiers,
2944
- ...nodePos(node),
2248
+ const place = (value) => {
2249
+ if (Array.isArray(value))
2250
+ return value.map(place);
2251
+ if (!isRecord(value) || typeof value.type !== 'string')
2252
+ return value;
2253
+ let span = typeof value.start === 'number' && typeof value.end === 'number'
2254
+ ? { start: value.start, end: value.end }
2255
+ : undefined;
2256
+ const kinds = engineTypesFor(value);
2257
+ if (kinds.length > 0) {
2258
+ const index = spans.findIndex((s, i) => i >= cursor && kinds.includes(s.type));
2259
+ const match = spans[index];
2260
+ if (match) {
2261
+ span = { start: match.start, end: match.end };
2262
+ cursor = index + 1;
2263
+ }
2264
+ }
2265
+ const out = {};
2266
+ for (const [key, child] of Object.entries(value)) {
2267
+ out[key] = typeof child === 'object' ? place(child) : child;
2268
+ }
2269
+ return span ? { ...out, ...span, ...lineAndColumn(span.start) } : out;
2945
2270
  };
2946
- }
2947
- function slotString(value) {
2948
- return { type: 'string', value, ...POS };
2949
- }
2950
- function convertRepeat(node) {
2951
- if (node.count !== undefined) {
2952
- const times = typeof node.count === 'number'
2953
- ? { type: 'literal', value: node.count, raw: String(node.count), ...POS }
2954
- : toCoreAST(node.count);
2955
- return loopCommand(node, 'times', { times });
2956
- }
2957
- if (node.whileCondition !== undefined) {
2958
- return loopCommand(node, 'while', { while: toCoreAST(node.whileCondition) });
2959
- }
2960
- if (node.untilEvent !== undefined) {
2961
- return loopCommand(node, 'until-event', {
2962
- event: slotString(node.untilEvent),
2963
- from: node.untilEventTarget ? toCoreAST(node.untilEventTarget) : undefined,
2964
- });
2965
- }
2966
- return loopCommand(node, 'forever', {});
2967
- }
2968
- function convertForEach(node) {
2969
- return loopCommand(node, 'for', {
2970
- for: slotString(node.itemName),
2971
- in: toCoreAST(node.collection),
2972
- });
2973
- }
2974
- function convertWhile(node) {
2975
- return loopCommand(node, 'while', {
2976
- while: toCoreAST(node.condition),
2977
- bottomTested: node.bottomTested
2978
- ? { type: 'literal', value: true, raw: 'true', ...POS }
2979
- : undefined,
2980
- });
2981
- }
2982
- function flattenEventModifiers(modifiers) {
2983
- if (!modifiers)
2984
- return {};
2985
- const flat = {};
2986
- if (modifiers.once)
2987
- flat.once = true;
2988
- if (modifiers.prevent)
2989
- flat.prevent = true;
2990
- if (modifiers.stop)
2991
- flat.stop = true;
2992
- if (modifiers.capture)
2993
- flat.capture = true;
2994
- if (modifiers.passive)
2995
- flat.passive = true;
2996
- if (modifiers.debounce)
2997
- flat.debounce = modifiers.debounce;
2998
- if (modifiers.throttle)
2999
- flat.throttle = modifiers.throttle;
3000
- if (modifiers.from)
3001
- flat.from = modifiers.from;
3002
- return flat;
2271
+ return nodes.map(node => place(node));
3003
2272
  }
3004
2273
 
3005
2274
  var DiagnosticSeverity;
@@ -3625,5 +2894,5 @@ function extractBodySymbols(body) {
3625
2894
  return symbols;
3626
2895
  }
3627
2896
 
3628
- export { ASTVisitor, analyzeDependencies, analyzeMetrics, analyzePatterns, applyOptimizationPasses, calculateCognitive, calculateComplexity, calculateCyclomatic, countNodeTypes, createOptimizationPass, createTypeCollector, createVisitorContext, detectCodeSmells, extractCommonExpressions, findDeadCode, findFirst, findNodes, format, fromCoreAST, generate, generateCommand, generateDocumentation, generateExpression, generateHTML, generateJSON, generateMarkdown, generateWithMetadata, getAncestors, inlineVariables, interchangeToLSPCompletions, interchangeToLSPDiagnostics, interchangeToLSPHover, interchangeToLSPSymbols, measureDepth, minify, normalize, optimize, parseSelector, query, queryAll, queryXPath, suggestOptimizations, toCoreAST, transform, visit };
2897
+ export { ASTVisitor, analyzeDependencies, analyzeMetrics, analyzePatterns, applyOptimizationPasses, calculateCognitive, calculateComplexity, calculateCyclomatic, countNodeTypes, createOptimizationPass, createTypeCollector, createVisitorContext, detectCodeSmells, extractCommonExpressions, findDeadCode, findFirst, findNodes, format, generate, generateCommand, generateDocumentation, generateExpression, generateHTML, generateJSON, generateMarkdown, generateWithMetadata, getAncestors, inlineVariables, interchangeToLSPCompletions, interchangeToLSPDiagnostics, interchangeToLSPHover, interchangeToLSPSymbols, measureDepth, minify, normalize, optimize, parseSelector, query, queryAll, queryXPath, suggestOptimizations, transform, visit, withEnginePositions };
3629
2898
  //# sourceMappingURL=index.mjs.map