@hyperfixi/core 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (381) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +218 -0
  3. package/dist/__test-utils__/context-builders.d.ts +42 -0
  4. package/dist/__test-utils__/error-testing.d.ts +18 -0
  5. package/dist/__test-utils__/index.d.ts +6 -0
  6. package/dist/__test-utils__/mock-types.d.ts +57 -0
  7. package/dist/__test-utils__/parser-context-mock.d.ts +7 -0
  8. package/dist/__test-utils__/parser-helpers.d.ts +38 -0
  9. package/dist/api/dom-processor.d.ts +17 -0
  10. package/dist/api/hyperscript-api.d.ts +68 -0
  11. package/dist/api/lokascript-api.d.ts +9 -0
  12. package/dist/ast-utils/analyzer.d.ts +19 -0
  13. package/dist/ast-utils/documentation.d.ts +8 -0
  14. package/dist/ast-utils/generator.d.ts +9 -0
  15. package/dist/ast-utils/index.d.ts +12 -0
  16. package/dist/ast-utils/index.js +3366 -0
  17. package/dist/ast-utils/index.mjs +3320 -0
  18. package/dist/ast-utils/interchange/from-core.d.ts +8 -0
  19. package/dist/ast-utils/interchange/index.d.ts +6 -0
  20. package/dist/ast-utils/interchange/lsp.d.ts +108 -0
  21. package/dist/ast-utils/interchange/to-core.d.ts +8 -0
  22. package/dist/ast-utils/interchange/types.d.ts +113 -0
  23. package/dist/ast-utils/query.d.ts +25 -0
  24. package/dist/ast-utils/transformer.d.ts +14 -0
  25. package/dist/ast-utils/types.d.ts +162 -0
  26. package/dist/ast-utils/visitor.d.ts +40 -0
  27. package/dist/behaviors/boosted.d.ts +29 -0
  28. package/dist/behaviors/history-swap.d.ts +24 -0
  29. package/dist/behaviors/index.d.ts +4 -0
  30. package/dist/behaviors/index.js +1149 -0
  31. package/dist/behaviors/index.mjs +1139 -0
  32. package/dist/bundle-generator/generator.d.ts +4 -0
  33. package/dist/bundle-generator/index.d.ts +6 -0
  34. package/dist/bundle-generator/index.js +2294 -0
  35. package/dist/bundle-generator/index.mjs +2271 -0
  36. package/dist/bundle-generator/parser-templates.d.ts +6 -0
  37. package/dist/bundle-generator/template-capabilities.d.ts +10 -0
  38. package/dist/bundle-generator/templates.d.ts +11 -0
  39. package/dist/bundle-generator/types.d.ts +34 -0
  40. package/dist/bundles/test-minimal.d.ts +3 -0
  41. package/dist/bundles/test-standard.d.ts +3 -0
  42. package/dist/chunks/bridge-I6ceoWxV.js +2 -0
  43. package/dist/chunks/browser-modular-Dv6PAV3c.js +2 -0
  44. package/dist/chunks/feature-eventsource-DWb514fy.js +2 -0
  45. package/dist/chunks/feature-sockets-3PFuvCVY.js +2 -0
  46. package/dist/chunks/feature-webworker-DTm_eh-E.js +2 -0
  47. package/dist/commands/advanced/async.d.ts +28 -0
  48. package/dist/commands/advanced/js.d.ts +28 -0
  49. package/dist/commands/animation/measure.d.ts +31 -0
  50. package/dist/commands/animation/settle.d.ts +26 -0
  51. package/dist/commands/animation/take.d.ts +28 -0
  52. package/dist/commands/animation/transition.d.ts +31 -0
  53. package/dist/commands/async/fetch.d.ts +44 -0
  54. package/dist/commands/async/wait.d.ts +41 -0
  55. package/dist/commands/behaviors/install.d.ts +41 -0
  56. package/dist/commands/content/append.d.ts +27 -0
  57. package/dist/commands/control-flow/break.d.ts +15 -0
  58. package/dist/commands/control-flow/continue.d.ts +15 -0
  59. package/dist/commands/control-flow/exit.d.ts +15 -0
  60. package/dist/commands/control-flow/halt.d.ts +25 -0
  61. package/dist/commands/control-flow/if.d.ts +45 -0
  62. package/dist/commands/control-flow/repeat.d.ts +35 -0
  63. package/dist/commands/control-flow/return.d.ts +23 -0
  64. package/dist/commands/control-flow/signal-base.d.ts +25 -0
  65. package/dist/commands/control-flow/throw.d.ts +22 -0
  66. package/dist/commands/control-flow/unless.d.ts +3 -0
  67. package/dist/commands/data/decrement.d.ts +3 -0
  68. package/dist/commands/data/default.d.ts +31 -0
  69. package/dist/commands/data/get.d.ts +23 -0
  70. package/dist/commands/data/increment.d.ts +25 -0
  71. package/dist/commands/data/set.d.ts +56 -0
  72. package/dist/commands/decorators/index.d.ts +30 -0
  73. package/dist/commands/dom/__tests__/add-standalone-helpers.d.ts +11 -0
  74. package/dist/commands/dom/add.d.ts +31 -0
  75. package/dist/commands/dom/dom-modification-base.d.ts +48 -0
  76. package/dist/commands/dom/hide.d.ts +12 -0
  77. package/dist/commands/dom/make.d.ts +21 -0
  78. package/dist/commands/dom/process-partials.d.ts +39 -0
  79. package/dist/commands/dom/put.d.ts +31 -0
  80. package/dist/commands/dom/remove.d.ts +33 -0
  81. package/dist/commands/dom/show.d.ts +13 -0
  82. package/dist/commands/dom/swap.d.ts +38 -0
  83. package/dist/commands/dom/toggle.d.ts +55 -0
  84. package/dist/commands/dom/visibility-base.d.ts +20 -0
  85. package/dist/commands/events/send.d.ts +3 -0
  86. package/dist/commands/events/trigger.d.ts +36 -0
  87. package/dist/commands/execution/call.d.ts +24 -0
  88. package/dist/commands/execution/pseudo-command.d.ts +42 -0
  89. package/dist/commands/helpers/attribute-manipulation.d.ts +11 -0
  90. package/dist/commands/helpers/batch-dom-operations.d.ts +12 -0
  91. package/dist/commands/helpers/class-manipulation.d.ts +11 -0
  92. package/dist/commands/helpers/condition-helpers.d.ts +4 -0
  93. package/dist/commands/helpers/dom-mutation.d.ts +15 -0
  94. package/dist/commands/helpers/duration-parsing.d.ts +8 -0
  95. package/dist/commands/helpers/element-property-access.d.ts +7 -0
  96. package/dist/commands/helpers/element-resolution.d.ts +17 -0
  97. package/dist/commands/helpers/error-helpers.d.ts +17 -0
  98. package/dist/commands/helpers/event-helpers.d.ts +13 -0
  99. package/dist/commands/helpers/event-waiting.d.ts +37 -0
  100. package/dist/commands/helpers/index.d.ts +32 -0
  101. package/dist/commands/helpers/input-validator.d.ts +23 -0
  102. package/dist/commands/helpers/loop-executor.d.ts +53 -0
  103. package/dist/commands/helpers/numeric-target-parser.d.ts +14 -0
  104. package/dist/commands/helpers/property-target.d.ts +30 -0
  105. package/dist/commands/helpers/selector-type-detection.d.ts +24 -0
  106. package/dist/commands/helpers/smart-element.d.ts +16 -0
  107. package/dist/commands/helpers/style-manipulation.d.ts +16 -0
  108. package/dist/commands/helpers/temporal-modifiers.d.ts +15 -0
  109. package/dist/commands/helpers/url-argument-parser.d.ts +10 -0
  110. package/dist/commands/helpers/url-validation.d.ts +7 -0
  111. package/dist/commands/helpers/variable-access.d.ts +10 -0
  112. package/dist/commands/helpers/visibility-target-parser.d.ts +11 -0
  113. package/dist/commands/index.d.ts +139 -0
  114. package/dist/commands/index.js +9186 -0
  115. package/dist/commands/index.mjs +9032 -0
  116. package/dist/commands/navigation/go.d.ts +35 -0
  117. package/dist/commands/navigation/push-url.d.ts +35 -0
  118. package/dist/commands/navigation/replace-url.d.ts +3 -0
  119. package/dist/commands/templates/render.d.ts +48 -0
  120. package/dist/commands/utility/beep.d.ts +32 -0
  121. package/dist/commands/utility/copy.d.ts +29 -0
  122. package/dist/commands/utility/log.d.ts +24 -0
  123. package/dist/commands/utility/pick.d.ts +26 -0
  124. package/dist/commands/utility/tell.d.ts +26 -0
  125. package/dist/compatibility/browser-bundle-animation-generated.d.ts +16 -0
  126. package/dist/compatibility/browser-bundle-classic-i18n.d.ts +63 -0
  127. package/dist/compatibility/browser-bundle-classic.d.ts +17 -0
  128. package/dist/compatibility/browser-bundle-forms-generated.d.ts +16 -0
  129. package/dist/compatibility/browser-bundle-hybrid-complete.d.ts +28 -0
  130. package/dist/compatibility/browser-bundle-hybrid-hx.d.ts +43 -0
  131. package/dist/compatibility/browser-bundle-lite-plus.d.ts +25 -0
  132. package/dist/compatibility/browser-bundle-lite.d.ts +23 -0
  133. package/dist/compatibility/browser-bundle-minimal-generated.d.ts +16 -0
  134. package/dist/compatibility/browser-bundle-minimal-v2.d.ts +17 -0
  135. package/dist/compatibility/browser-bundle-minimal.d.ts +8 -0
  136. package/dist/compatibility/browser-bundle-modular.d.ts +18 -0
  137. package/dist/compatibility/browser-bundle-multilingual.d.ts +19 -0
  138. package/dist/compatibility/browser-bundle-semantic-complete.d.ts +24 -0
  139. package/dist/compatibility/browser-bundle-standard-v2.d.ts +17 -0
  140. package/dist/compatibility/browser-bundle-standard.d.ts +8 -0
  141. package/dist/compatibility/browser-bundle-textshelf-minimal.d.ts +16 -0
  142. package/dist/compatibility/browser-bundle-textshelf-profile.d.ts +18 -0
  143. package/dist/compatibility/browser-bundle.d.ts +140 -0
  144. package/dist/compatibility/browser-modular.d.ts +53 -0
  145. package/dist/compatibility/browser-tests/test-utils.d.ts +21 -0
  146. package/dist/compatibility/eval-hyperscript.d.ts +15 -0
  147. package/dist/compatibility/feature-loader.d.ts +8 -0
  148. package/dist/compatibility/hyperscript-adapter.d.ts +38 -0
  149. package/dist/compatibility/hyperscript-tests/test-adapter.d.ts +13 -0
  150. package/dist/core/ast-property-utils.d.ts +2 -0
  151. package/dist/core/base-expression-evaluator.d.ts +70 -0
  152. package/dist/core/binary-expression-evaluator.d.ts +7 -0
  153. package/dist/core/call-expression-evaluator.d.ts +7 -0
  154. package/dist/core/configurable-expression-evaluator.d.ts +5 -0
  155. package/dist/core/context.d.ts +15 -0
  156. package/dist/core/dom.d.ts +15 -0
  157. package/dist/core/evaluator-types.d.ts +5 -0
  158. package/dist/core/events.d.ts +48 -0
  159. package/dist/core/executor.d.ts +34 -0
  160. package/dist/core/expression-evaluator.d.ts +6 -0
  161. package/dist/core/lazy-expression-evaluator.d.ts +22 -0
  162. package/dist/core/parser.d.ts +21 -0
  163. package/dist/core/selector-evaluator.d.ts +15 -0
  164. package/dist/core/template-literal-evaluator.d.ts +5 -0
  165. package/dist/dom/attribute-processor.d.ts +40 -0
  166. package/dist/dom/minimal-attribute-processor.d.ts +20 -0
  167. package/dist/experimental/binary-tree/accessor.d.ts +10 -0
  168. package/dist/experimental/binary-tree/ast-serializer.d.ts +26 -0
  169. package/dist/experimental/binary-tree/benchmark.d.ts +24 -0
  170. package/dist/experimental/binary-tree/buffer-context.d.ts +27 -0
  171. package/dist/experimental/binary-tree/deserializer.d.ts +17 -0
  172. package/dist/experimental/binary-tree/index.d.ts +22 -0
  173. package/dist/experimental/binary-tree/serializer.d.ts +4 -0
  174. package/dist/experimental/binary-tree/types.d.ts +54 -0
  175. package/dist/expressions/base-expression.d.ts +27 -0
  176. package/dist/expressions/bundles/common-expressions.d.ts +9 -0
  177. package/dist/expressions/bundles/core-expressions.d.ts +7 -0
  178. package/dist/expressions/bundles/full-expressions.d.ts +10 -0
  179. package/dist/expressions/bundles/index.d.ts +7 -0
  180. package/dist/expressions/comparison/index.d.ts +80 -0
  181. package/dist/expressions/comparison/utils.d.ts +2 -0
  182. package/dist/expressions/conversion/impl/bridge.d.ts +117 -0
  183. package/dist/expressions/conversion/impl/index.d.ts +59 -0
  184. package/dist/expressions/conversion/index.d.ts +23 -0
  185. package/dist/expressions/expression-tiers.d.ts +13 -0
  186. package/dist/expressions/index.d.ts +11 -0
  187. package/dist/expressions/index.js +6930 -0
  188. package/dist/expressions/index.mjs +6912 -0
  189. package/dist/expressions/logical/impl/index.d.ts +54 -0
  190. package/dist/expressions/logical/impl/pattern-matching.d.ts +58 -0
  191. package/dist/expressions/logical/index.d.ts +59 -0
  192. package/dist/expressions/mathematical/index.d.ts +69 -0
  193. package/dist/expressions/positional/impl/bridge.d.ts +95 -0
  194. package/dist/expressions/positional/impl/index.d.ts +73 -0
  195. package/dist/expressions/positional/index.d.ts +26 -0
  196. package/dist/expressions/properties/impl/index.d.ts +105 -0
  197. package/dist/expressions/properties/index.d.ts +26 -0
  198. package/dist/expressions/property/index.d.ts +55 -0
  199. package/dist/expressions/property-access-utils.d.ts +23 -0
  200. package/dist/expressions/references/impl/bridge.d.ts +54 -0
  201. package/dist/expressions/references/impl/index.d.ts +65 -0
  202. package/dist/expressions/references/index.d.ts +40 -0
  203. package/dist/expressions/shared/comparison-utils.d.ts +10 -0
  204. package/dist/expressions/shared/index.d.ts +9 -0
  205. package/dist/expressions/shared/number-utils.d.ts +7 -0
  206. package/dist/expressions/shared/validation-utils.d.ts +13 -0
  207. package/dist/expressions/special/index.d.ts +104 -0
  208. package/dist/expressions/type-helpers.d.ts +11 -0
  209. package/dist/expressions/type-registry.d.ts +57 -0
  210. package/dist/expressions/validation-helpers.d.ts +15 -0
  211. package/dist/extensions/index.d.ts +3 -0
  212. package/dist/extensions/tailwind.d.ts +22 -0
  213. package/dist/features/behaviors.d.ts +153 -0
  214. package/dist/features/def.d.ts +135 -0
  215. package/dist/features/eventsource.d.ts +140 -0
  216. package/dist/features/init.d.ts +135 -0
  217. package/dist/features/on.d.ts +131 -0
  218. package/dist/features/predefined-behaviors/dropdown-behavior.d.ts +20 -0
  219. package/dist/features/predefined-behaviors/index.d.ts +12 -0
  220. package/dist/features/predefined-behaviors/modal-behavior.d.ts +18 -0
  221. package/dist/features/predefined-behaviors/toggle-group-behavior.d.ts +23 -0
  222. package/dist/features/predefined-behaviors/types.d.ts +14 -0
  223. package/dist/features/sockets.d.ts +162 -0
  224. package/dist/features/webworker.d.ts +135 -0
  225. package/dist/htmx/htmx-attribute-processor.d.ts +84 -0
  226. package/dist/htmx/htmx-translator.d.ts +19 -0
  227. package/dist/htmx/index.d.ts +3 -0
  228. package/dist/hyperfixi-classic-i18n.js +2 -0
  229. package/dist/hyperfixi-hx.js +1 -0
  230. package/dist/hyperfixi-hybrid-complete.js +1 -0
  231. package/dist/hyperfixi-lite-plus.js +1 -0
  232. package/dist/hyperfixi-lite.js +1 -0
  233. package/dist/hyperfixi-minimal.js +1 -0
  234. package/dist/hyperfixi-multilingual.js +2 -0
  235. package/dist/hyperfixi-standard.js +2 -0
  236. package/dist/hyperfixi.js +2 -0
  237. package/dist/hyperfixi.mjs +2 -0
  238. package/dist/index.d.ts +25 -0
  239. package/dist/index.js +65387 -0
  240. package/dist/index.min.js +2 -0
  241. package/dist/index.mjs +65343 -0
  242. package/dist/lib/index.d.ts +4 -0
  243. package/dist/lib/morph-adapter.d.ts +22 -0
  244. package/dist/lib/swap-executor.d.ts +22 -0
  245. package/dist/lib/view-transitions.d.ts +33 -0
  246. package/dist/lokascript-browser-classic-i18n.js +2 -0
  247. package/dist/lokascript-browser-minimal.js +1 -0
  248. package/dist/lokascript-browser-standard.js +2 -0
  249. package/dist/lokascript-browser.js +2 -0
  250. package/dist/lokascript-hybrid-complete.js +1 -0
  251. package/dist/lokascript-hybrid-hx.js +1 -0
  252. package/dist/lokascript-lite-plus.js +1 -0
  253. package/dist/lokascript-lite.js +1 -0
  254. package/dist/lokascript-multilingual.js +2 -0
  255. package/dist/lsp-metadata.d.ts +25 -0
  256. package/dist/lsp-metadata.js +680 -0
  257. package/dist/lsp-metadata.mjs +670 -0
  258. package/dist/metadata.d.ts +213 -0
  259. package/dist/metadata.js +378 -0
  260. package/dist/metadata.mjs +368 -0
  261. package/dist/mod.d.ts +63 -0
  262. package/dist/multilingual/bridge.d.ts +36 -0
  263. package/dist/multilingual/index.d.ts +32 -0
  264. package/dist/multilingual/index.js +285 -0
  265. package/dist/multilingual/index.mjs +278 -0
  266. package/dist/parser/__types__/test-helpers.d.ts +25 -0
  267. package/dist/parser/command-node-builder.d.ts +45 -0
  268. package/dist/parser/command-parsers/animation-commands.d.ts +5 -0
  269. package/dist/parser/command-parsers/async-commands.d.ts +5 -0
  270. package/dist/parser/command-parsers/control-flow-commands.d.ts +7 -0
  271. package/dist/parser/command-parsers/dom-commands.d.ts +8 -0
  272. package/dist/parser/command-parsers/event-commands.d.ts +4 -0
  273. package/dist/parser/command-parsers/utility-commands.d.ts +9 -0
  274. package/dist/parser/command-parsers/variable-commands.d.ts +12 -0
  275. package/dist/parser/error-handler.d.ts +34 -0
  276. package/dist/parser/expression-parser.d.ts +6 -0
  277. package/dist/parser/full-parser.d.ts +4 -0
  278. package/dist/parser/full-parser.js +6532 -0
  279. package/dist/parser/full-parser.mjs +6529 -0
  280. package/dist/parser/helpers/ast-helpers.d.ts +22 -0
  281. package/dist/parser/helpers/parsing-helpers.d.ts +19 -0
  282. package/dist/parser/helpers/token-helpers.d.ts +28 -0
  283. package/dist/parser/hybrid/aliases.d.ts +7 -0
  284. package/dist/parser/hybrid/aliases.js +44 -0
  285. package/dist/parser/hybrid/aliases.mjs +37 -0
  286. package/dist/parser/hybrid/ast-types.d.ts +97 -0
  287. package/dist/parser/hybrid/ast-types.js +3 -0
  288. package/dist/parser/hybrid/ast-types.mjs +2 -0
  289. package/dist/parser/hybrid/index.d.ts +6 -0
  290. package/dist/parser/hybrid/index.js +1015 -0
  291. package/dist/parser/hybrid/index.mjs +1005 -0
  292. package/dist/parser/hybrid/parser-core.d.ts +57 -0
  293. package/dist/parser/hybrid/parser-core.js +1001 -0
  294. package/dist/parser/hybrid/parser-core.mjs +999 -0
  295. package/dist/parser/hybrid/tokenizer.d.ts +9 -0
  296. package/dist/parser/hybrid/tokenizer.js +242 -0
  297. package/dist/parser/hybrid/tokenizer.mjs +239 -0
  298. package/dist/parser/hybrid-parser.d.ts +10 -0
  299. package/dist/parser/hybrid-parser.js +1078 -0
  300. package/dist/parser/hybrid-parser.mjs +1071 -0
  301. package/dist/parser/parser-constants.d.ts +102 -0
  302. package/dist/parser/parser-interface.d.ts +11 -0
  303. package/dist/parser/parser-types.d.ts +175 -0
  304. package/dist/parser/parser.d.ts +146 -0
  305. package/dist/parser/regex-parser.d.ts +4 -0
  306. package/dist/parser/regex-parser.js +412 -0
  307. package/dist/parser/regex-parser.mjs +409 -0
  308. package/dist/parser/runtime.d.ts +3 -0
  309. package/dist/parser/semantic-integration.d.ts +61 -0
  310. package/dist/parser/token-consumer.d.ts +35 -0
  311. package/dist/parser/token-predicates.d.ts +77 -0
  312. package/dist/parser/tokenizer.d.ts +57 -0
  313. package/dist/parser/types.d.ts +118 -0
  314. package/dist/performance/expression-cache.d.ts +78 -0
  315. package/dist/performance/integration.d.ts +40 -0
  316. package/dist/performance/production-monitor.d.ts +67 -0
  317. package/dist/reference/index.d.ts +41 -0
  318. package/dist/reference/index.js +586 -0
  319. package/dist/reference/index.mjs +577 -0
  320. package/dist/registry/browser-types.d.ts +20 -0
  321. package/dist/registry/browser-types.js +81 -0
  322. package/dist/registry/browser-types.mjs +76 -0
  323. package/dist/registry/context-provider-registry.d.ts +38 -0
  324. package/dist/registry/environment.d.ts +19 -0
  325. package/dist/registry/environment.js +36 -0
  326. package/dist/registry/environment.mjs +30 -0
  327. package/dist/registry/event-source-registry.d.ts +54 -0
  328. package/dist/registry/examples/server-commands.d.ts +6 -0
  329. package/dist/registry/examples/server-event-source.d.ts +32 -0
  330. package/dist/registry/index.d.ts +54 -0
  331. package/dist/registry/index.js +7636 -0
  332. package/dist/registry/index.mjs +7612 -0
  333. package/dist/registry/multilingual/examples.d.ts +16 -0
  334. package/dist/registry/multilingual/index.d.ts +68 -0
  335. package/dist/registry/runtime-integration.d.ts +30 -0
  336. package/dist/registry/universal-types.d.ts +34 -0
  337. package/dist/registry/universal-types.js +91 -0
  338. package/dist/registry/universal-types.mjs +86 -0
  339. package/dist/runtime/cleanup-registry.d.ts +47 -0
  340. package/dist/runtime/command-adapter.d.ts +63 -0
  341. package/dist/runtime/environment.d.ts +75 -0
  342. package/dist/runtime/runtime-base.d.ts +78 -0
  343. package/dist/runtime/runtime-experimental.d.ts +18 -0
  344. package/dist/runtime/runtime-factory.d.ts +30 -0
  345. package/dist/runtime/runtime.d.ts +19 -0
  346. package/dist/runtime/temporal-modifiers.d.ts +37 -0
  347. package/dist/scripts/code-generator.d.ts +64 -0
  348. package/dist/scripts/generate-missing-commands.d.ts +4 -0
  349. package/dist/test-setup.d.ts +45 -0
  350. package/dist/test-utilities.d.ts +52 -0
  351. package/dist/tokenizer.d.ts +49 -0
  352. package/dist/types/base-types.d.ts +336 -0
  353. package/dist/types/code-fix.d.ts +39 -0
  354. package/dist/types/command-metadata.d.ts +57 -0
  355. package/dist/types/command-types.d.ts +272 -0
  356. package/dist/types/context-types.d.ts +106 -0
  357. package/dist/types/core-context.d.ts +21 -0
  358. package/dist/types/core.d.ts +203 -0
  359. package/dist/types/error-codes.d.ts +207 -0
  360. package/dist/types/expression-types.d.ts +155 -0
  361. package/dist/types/feature-types.d.ts +81 -0
  362. package/dist/types/hooks.d.ts +45 -0
  363. package/dist/types/index.d.ts +32 -0
  364. package/dist/types/result.d.ts +72 -0
  365. package/dist/types/template-types.d.ts +162 -0
  366. package/dist/types/type-guards.d.ts +24 -0
  367. package/dist/types/unified-types.d.ts +99 -0
  368. package/dist/utils/debug-events.d.ts +41 -0
  369. package/dist/utils/debug.d.ts +35 -0
  370. package/dist/utils/dom-utils.d.ts +16 -0
  371. package/dist/utils/element-check.d.ts +7 -0
  372. package/dist/utils/keyboard-shortcuts.d.ts +18 -0
  373. package/dist/utils/performance.d.ts +40 -0
  374. package/dist/validation/command-pattern-validator.d.ts +53 -0
  375. package/dist/validation/common-validators.d.ts +24 -0
  376. package/dist/validation/lightweight-validators.d.ts +113 -0
  377. package/dist/validation/partial-validation-types.d.ts +50 -0
  378. package/dist/validation/partial-validator.d.ts +6 -0
  379. package/dist/validation/partial-warning-formatter.d.ts +6 -0
  380. package/dist/validation/validate-cli.d.ts +41 -0
  381. package/package.json +292 -0
@@ -0,0 +1,1071 @@
1
+ const KEYWORDS = new Set([
2
+ 'on',
3
+ 'from',
4
+ 'to',
5
+ 'into',
6
+ 'before',
7
+ 'after',
8
+ 'in',
9
+ 'of',
10
+ 'at',
11
+ 'with',
12
+ 'if',
13
+ 'else',
14
+ 'unless',
15
+ 'end',
16
+ 'then',
17
+ 'and',
18
+ 'or',
19
+ 'not',
20
+ 'repeat',
21
+ 'times',
22
+ 'for',
23
+ 'each',
24
+ 'while',
25
+ 'until',
26
+ 'toggle',
27
+ 'add',
28
+ 'remove',
29
+ 'put',
30
+ 'set',
31
+ 'get',
32
+ 'call',
33
+ 'return',
34
+ 'append',
35
+ 'log',
36
+ 'send',
37
+ 'trigger',
38
+ 'wait',
39
+ 'settle',
40
+ 'fetch',
41
+ 'as',
42
+ 'show',
43
+ 'hide',
44
+ 'take',
45
+ 'increment',
46
+ 'decrement',
47
+ 'focus',
48
+ 'blur',
49
+ 'go',
50
+ 'transition',
51
+ 'over',
52
+ 'the',
53
+ 'a',
54
+ 'an',
55
+ 'my',
56
+ 'its',
57
+ 'me',
58
+ 'it',
59
+ 'you',
60
+ 'first',
61
+ 'last',
62
+ 'next',
63
+ 'previous',
64
+ 'closest',
65
+ 'parent',
66
+ 'true',
67
+ 'false',
68
+ 'null',
69
+ 'undefined',
70
+ 'is',
71
+ 'matches',
72
+ 'contains',
73
+ 'includes',
74
+ 'exists',
75
+ 'has',
76
+ 'init',
77
+ 'every',
78
+ 'by',
79
+ ]);
80
+ function tokenize(code) {
81
+ const tokens = [];
82
+ let pos = 0;
83
+ while (pos < code.length) {
84
+ if (/\s/.test(code[pos])) {
85
+ pos++;
86
+ continue;
87
+ }
88
+ if (code.slice(pos, pos + 2) === '--') {
89
+ while (pos < code.length && code[pos] !== '\n')
90
+ pos++;
91
+ continue;
92
+ }
93
+ const start = pos;
94
+ if (code[pos] === '<' && /[a-zA-Z]/.test(code[pos + 1] || '')) {
95
+ pos++;
96
+ while (pos < code.length && code[pos] !== '>')
97
+ pos++;
98
+ if (code[pos] === '>')
99
+ pos++;
100
+ const val = code.slice(start, pos);
101
+ if (val.endsWith('/>') || val.endsWith('>')) {
102
+ const normalized = val.slice(1).replace(/\/?>$/, '');
103
+ tokens.push({ type: 'selector', value: normalized, pos: start });
104
+ continue;
105
+ }
106
+ }
107
+ if (code.slice(pos, pos + 2) === "'s" && !/[a-zA-Z]/.test(code[pos + 2] || '')) {
108
+ tokens.push({ type: 'operator', value: "'s", pos: start });
109
+ pos += 2;
110
+ continue;
111
+ }
112
+ if (code[pos] === '"' || code[pos] === "'") {
113
+ const quote = code[pos++];
114
+ while (pos < code.length && code[pos] !== quote) {
115
+ if (code[pos] === '\\')
116
+ pos++;
117
+ pos++;
118
+ }
119
+ pos++;
120
+ tokens.push({ type: 'string', value: code.slice(start, pos), pos: start });
121
+ continue;
122
+ }
123
+ if (/\d/.test(code[pos]) || (code[pos] === '-' && /\d/.test(code[pos + 1] || ''))) {
124
+ if (code[pos] === '-')
125
+ pos++;
126
+ while (pos < code.length && /[\d.]/.test(code[pos]))
127
+ pos++;
128
+ if (code.slice(pos, pos + 2) === 'ms')
129
+ pos += 2;
130
+ else if (code[pos] === 's' && !/[a-zA-Z]/.test(code[pos + 1] || ''))
131
+ pos++;
132
+ else if (code.slice(pos, pos + 2) === 'px')
133
+ pos += 2;
134
+ tokens.push({ type: 'number', value: code.slice(start, pos), pos: start });
135
+ continue;
136
+ }
137
+ if (code[pos] === ':') {
138
+ pos++;
139
+ while (pos < code.length && /[\w]/.test(code[pos]))
140
+ pos++;
141
+ tokens.push({ type: 'localVar', value: code.slice(start, pos), pos: start });
142
+ continue;
143
+ }
144
+ if (code[pos] === '$') {
145
+ pos++;
146
+ while (pos < code.length && /[\w]/.test(code[pos]))
147
+ pos++;
148
+ tokens.push({ type: 'globalVar', value: code.slice(start, pos), pos: start });
149
+ continue;
150
+ }
151
+ if (code[pos] === '#' || code[pos] === '.') {
152
+ if (code[pos] === '.') {
153
+ const afterDot = code.slice(pos + 1).match(/^(once|prevent|stop|debounce|throttle)\b/i);
154
+ if (afterDot) {
155
+ tokens.push({ type: 'symbol', value: '.', pos: start });
156
+ pos++;
157
+ continue;
158
+ }
159
+ }
160
+ pos++;
161
+ while (pos < code.length && /[\w-]/.test(code[pos]))
162
+ pos++;
163
+ tokens.push({ type: 'selector', value: code.slice(start, pos), pos: start });
164
+ continue;
165
+ }
166
+ if (code[pos] === '[') {
167
+ let lookahead = pos + 1;
168
+ while (lookahead < code.length && /\s/.test(code[lookahead]))
169
+ lookahead++;
170
+ const nextChar = code[lookahead] || '';
171
+ const isArrayLiteral = /['"\d\[\]:\$\-]/.test(nextChar) || nextChar === '';
172
+ if (isArrayLiteral) {
173
+ tokens.push({ type: 'symbol', value: '[', pos: start });
174
+ pos++;
175
+ continue;
176
+ }
177
+ else {
178
+ pos++;
179
+ let depth = 1;
180
+ while (pos < code.length && depth > 0) {
181
+ if (code[pos] === '[')
182
+ depth++;
183
+ if (code[pos] === ']')
184
+ depth--;
185
+ pos++;
186
+ }
187
+ tokens.push({ type: 'selector', value: code.slice(start, pos), pos: start });
188
+ continue;
189
+ }
190
+ }
191
+ if (code[pos] === ']') {
192
+ tokens.push({ type: 'symbol', value: ']', pos: start });
193
+ pos++;
194
+ continue;
195
+ }
196
+ if (code.slice(pos, pos + 2) === "'s") {
197
+ tokens.push({ type: 'operator', value: "'s", pos: start });
198
+ pos += 2;
199
+ continue;
200
+ }
201
+ const twoChar = code.slice(pos, pos + 2);
202
+ if (['==', '!=', '<=', '>=', '&&', '||'].includes(twoChar)) {
203
+ tokens.push({ type: 'operator', value: twoChar, pos: start });
204
+ pos += 2;
205
+ continue;
206
+ }
207
+ if (code[pos] === '*' && /[a-zA-Z]/.test(code[pos + 1] || '')) {
208
+ pos++;
209
+ while (pos < code.length && /[\w-]/.test(code[pos]))
210
+ pos++;
211
+ tokens.push({ type: 'styleProperty', value: code.slice(start, pos), pos: start });
212
+ continue;
213
+ }
214
+ if ('+-*/%<>!'.includes(code[pos])) {
215
+ tokens.push({ type: 'operator', value: code[pos], pos: start });
216
+ pos++;
217
+ continue;
218
+ }
219
+ if ('()[]{},.'.includes(code[pos])) {
220
+ tokens.push({ type: 'symbol', value: code[pos], pos: start });
221
+ pos++;
222
+ continue;
223
+ }
224
+ if (/[a-zA-Z_]/.test(code[pos])) {
225
+ while (pos < code.length && /[\w-]/.test(code[pos]))
226
+ pos++;
227
+ const value = code.slice(start, pos);
228
+ const type = KEYWORDS.has(value.toLowerCase()) ? 'keyword' : 'identifier';
229
+ tokens.push({ type, value, pos: start });
230
+ continue;
231
+ }
232
+ pos++;
233
+ }
234
+ tokens.push({ type: 'eof', value: '', pos: code.length });
235
+ return tokens;
236
+ }
237
+
238
+ const COMMAND_ALIASES = {
239
+ flip: 'toggle',
240
+ switch: 'toggle',
241
+ display: 'show',
242
+ reveal: 'show',
243
+ conceal: 'hide',
244
+ increase: 'increment',
245
+ decrease: 'decrement',
246
+ fire: 'trigger',
247
+ dispatch: 'send',
248
+ navigate: 'go',
249
+ goto: 'go',
250
+ };
251
+ const EVENT_ALIASES = {
252
+ clicked: 'click',
253
+ pressed: 'keydown',
254
+ changed: 'change',
255
+ submitted: 'submit',
256
+ loaded: 'load',
257
+ };
258
+ function normalizeCommand(name) {
259
+ const lower = name.toLowerCase();
260
+ return COMMAND_ALIASES[lower] || lower;
261
+ }
262
+ function normalizeEvent(name) {
263
+ const lower = name.toLowerCase();
264
+ return EVENT_ALIASES[lower] || lower;
265
+ }
266
+ function addCommandAliases$1(aliases) {
267
+ Object.assign(COMMAND_ALIASES, aliases);
268
+ }
269
+ function addEventAliases$1(aliases) {
270
+ Object.assign(EVENT_ALIASES, aliases);
271
+ }
272
+
273
+ class HybridParser {
274
+ constructor(code) {
275
+ this.pos = 0;
276
+ this.tokens = tokenize(code);
277
+ }
278
+ peek(offset = 0) {
279
+ return this.tokens[Math.min(this.pos + offset, this.tokens.length - 1)];
280
+ }
281
+ advance() {
282
+ return this.tokens[this.pos++];
283
+ }
284
+ match(...values) {
285
+ const token = this.peek();
286
+ return values.some(v => token.value.toLowerCase() === v.toLowerCase());
287
+ }
288
+ matchType(...types) {
289
+ return types.includes(this.peek().type);
290
+ }
291
+ expect(value) {
292
+ if (!this.match(value) && normalizeCommand(this.peek().value) !== value) {
293
+ throw new Error(`Expected '${value}', got '${this.peek().value}'`);
294
+ }
295
+ return this.advance();
296
+ }
297
+ isAtEnd() {
298
+ return this.peek().type === 'eof';
299
+ }
300
+ parse() {
301
+ if (this.match('on'))
302
+ return this.parseEventHandler();
303
+ if (this.match('init')) {
304
+ this.advance();
305
+ return { type: 'event', event: 'init', modifiers: {}, body: this.parseCommandSequence() };
306
+ }
307
+ if (this.match('every'))
308
+ return this.parseEveryHandler();
309
+ return { type: 'sequence', commands: this.parseCommandSequence() };
310
+ }
311
+ parseEventHandler() {
312
+ this.expect('on');
313
+ const eventName = this.advance().value;
314
+ const modifiers = {};
315
+ let filter;
316
+ while (this.peek().value === '.') {
317
+ this.advance();
318
+ const mod = this.advance().value.toLowerCase();
319
+ if (mod === 'once')
320
+ modifiers.once = true;
321
+ else if (mod === 'prevent')
322
+ modifiers.prevent = true;
323
+ else if (mod === 'stop')
324
+ modifiers.stop = true;
325
+ else if (mod === 'debounce' || mod === 'throttle') {
326
+ if (this.peek().value === '(') {
327
+ this.advance();
328
+ const num = this.advance().value;
329
+ this.expect(')');
330
+ if (mod === 'debounce')
331
+ modifiers.debounce = parseInt(num) || 100;
332
+ else
333
+ modifiers.throttle = parseInt(num) || 100;
334
+ }
335
+ }
336
+ }
337
+ if (this.match('from')) {
338
+ this.advance();
339
+ filter = this.parseExpression();
340
+ }
341
+ return {
342
+ type: 'event',
343
+ event: normalizeEvent(eventName),
344
+ filter,
345
+ modifiers,
346
+ body: this.parseCommandSequence(),
347
+ };
348
+ }
349
+ parseEveryHandler() {
350
+ this.expect('every');
351
+ const interval = this.advance().value;
352
+ return {
353
+ type: 'event',
354
+ event: `interval:${interval}`,
355
+ modifiers: {},
356
+ body: this.parseCommandSequence(),
357
+ };
358
+ }
359
+ parseCommandSequence() {
360
+ const commands = [];
361
+ while (!this.isAtEnd() && !this.match('end', 'else')) {
362
+ const cmd = this.parseCommand();
363
+ if (cmd)
364
+ commands.push(cmd);
365
+ if (this.match('then', 'and'))
366
+ this.advance();
367
+ }
368
+ return commands;
369
+ }
370
+ parseCommand() {
371
+ if (this.match('if', 'unless'))
372
+ return this.parseIf();
373
+ if (this.match('repeat'))
374
+ return this.parseRepeat();
375
+ if (this.match('for'))
376
+ return this.parseFor();
377
+ if (this.match('while'))
378
+ return this.parseWhile();
379
+ if (this.match('fetch'))
380
+ return this.parseFetchBlock();
381
+ const cmdMap = {
382
+ toggle: () => this.parseToggle(),
383
+ add: () => this.parseAdd(),
384
+ remove: () => this.parseRemove(),
385
+ put: () => this.parsePut(),
386
+ append: () => this.parseAppend(),
387
+ set: () => this.parseSet(),
388
+ get: () => this.parseGet(),
389
+ call: () => this.parseCall(),
390
+ log: () => this.parseLog(),
391
+ send: () => this.parseSend(),
392
+ trigger: () => this.parseSend(),
393
+ wait: () => this.parseWait(),
394
+ show: () => this.parseShow(),
395
+ hide: () => this.parseHide(),
396
+ take: () => this.parseTake(),
397
+ increment: () => this.parseIncDec('increment'),
398
+ decrement: () => this.parseIncDec('decrement'),
399
+ focus: () => this.parseFocusBlur('focus'),
400
+ blur: () => this.parseFocusBlur('blur'),
401
+ go: () => this.parseGo(),
402
+ return: () => this.parseReturn(),
403
+ transition: () => this.parseTransition(),
404
+ };
405
+ const normalized = normalizeCommand(this.peek().value);
406
+ if (cmdMap[normalized]) {
407
+ return cmdMap[normalized]();
408
+ }
409
+ if (!this.isAtEnd() && !this.match('then', 'and', 'end', 'else')) {
410
+ this.advance();
411
+ }
412
+ return null;
413
+ }
414
+ parseIf() {
415
+ const isUnless = this.match('unless');
416
+ this.advance();
417
+ const condition = this.parseExpression();
418
+ const body = this.parseCommandSequence();
419
+ let elseBody;
420
+ if (this.match('else')) {
421
+ this.advance();
422
+ elseBody = this.parseCommandSequence();
423
+ }
424
+ if (this.match('end'))
425
+ this.advance();
426
+ return {
427
+ type: 'if',
428
+ condition: isUnless ? { type: 'unary', operator: 'not', operand: condition } : condition,
429
+ body,
430
+ elseBody,
431
+ };
432
+ }
433
+ parseRepeat() {
434
+ this.expect('repeat');
435
+ let count;
436
+ if (!this.match('until', 'while', 'forever')) {
437
+ count = this.parseExpression();
438
+ if (this.match('times'))
439
+ this.advance();
440
+ }
441
+ const body = this.parseCommandSequence();
442
+ if (this.match('end'))
443
+ this.advance();
444
+ return { type: 'repeat', condition: count, body };
445
+ }
446
+ parseFor() {
447
+ this.expect('for');
448
+ if (this.match('each'))
449
+ this.advance();
450
+ const variable = this.advance().value;
451
+ this.expect('in');
452
+ const iterable = this.parseExpression();
453
+ const body = this.parseCommandSequence();
454
+ if (this.match('end'))
455
+ this.advance();
456
+ return { type: 'for', condition: { type: 'forCondition', variable, iterable }, body };
457
+ }
458
+ parseWhile() {
459
+ this.expect('while');
460
+ const condition = this.parseExpression();
461
+ const body = this.parseCommandSequence();
462
+ if (this.match('end'))
463
+ this.advance();
464
+ return { type: 'while', condition, body };
465
+ }
466
+ parseFetchBlock() {
467
+ this.expect('fetch');
468
+ const url = this.parseExpression();
469
+ let responseType = { type: 'literal', value: 'text' };
470
+ let options;
471
+ if (this.match('{')) {
472
+ this.pos--;
473
+ options = this.parseExpression();
474
+ }
475
+ for (let i = 0; i < 2; i++) {
476
+ if (this.match('as')) {
477
+ this.advance();
478
+ if (this.match('a') || this.match('an'))
479
+ this.advance();
480
+ responseType = this.parseExpression();
481
+ continue;
482
+ }
483
+ if (this.match('with') && !options) {
484
+ this.advance();
485
+ options = this.parseExpression();
486
+ continue;
487
+ }
488
+ break;
489
+ }
490
+ if (this.match('then'))
491
+ this.advance();
492
+ const body = this.parseCommandSequence();
493
+ return { type: 'fetch', condition: { type: 'fetchConfig', url, responseType, options }, body };
494
+ }
495
+ parseToggle() {
496
+ this.expect('toggle');
497
+ const what = this.parseExpression();
498
+ let target;
499
+ if (this.match('on')) {
500
+ this.advance();
501
+ target = this.parseExpression();
502
+ }
503
+ return { type: 'command', name: 'toggle', args: [what], target };
504
+ }
505
+ parseAdd() {
506
+ this.expect('add');
507
+ const what = this.parseExpression();
508
+ let target;
509
+ if (this.match('to')) {
510
+ this.advance();
511
+ target = this.parseExpression();
512
+ }
513
+ return { type: 'command', name: 'add', args: [what], target };
514
+ }
515
+ parseRemove() {
516
+ this.expect('remove');
517
+ if (this.matchType('selector')) {
518
+ const what = this.parseExpression();
519
+ let target;
520
+ if (this.match('from')) {
521
+ this.advance();
522
+ target = this.parseExpression();
523
+ }
524
+ return { type: 'command', name: 'removeClass', args: [what], target };
525
+ }
526
+ const target = this.parseExpression();
527
+ return { type: 'command', name: 'remove', args: [], target };
528
+ }
529
+ parsePut() {
530
+ this.expect('put');
531
+ const content = this.parseExpression();
532
+ let modifier = 'into';
533
+ if (this.match('into', 'before', 'after', 'at')) {
534
+ modifier = this.advance().value;
535
+ if (modifier === 'at') {
536
+ const pos = this.advance().value;
537
+ this.expect('of');
538
+ modifier = `at ${pos} of`;
539
+ }
540
+ }
541
+ const target = this.parseExpression();
542
+ return { type: 'command', name: 'put', args: [content], target, modifier };
543
+ }
544
+ parseAppend() {
545
+ this.expect('append');
546
+ const content = this.parseExpression();
547
+ let target;
548
+ if (this.match('to')) {
549
+ this.advance();
550
+ target = this.parseExpression();
551
+ }
552
+ return { type: 'command', name: 'append', args: [content], target };
553
+ }
554
+ parseSet() {
555
+ this.expect('set');
556
+ const target = this.parseExpression();
557
+ if (this.match('to')) {
558
+ this.advance();
559
+ const value = this.parseExpression();
560
+ return { type: 'command', name: 'set', args: [target, value] };
561
+ }
562
+ return { type: 'command', name: 'set', args: [target] };
563
+ }
564
+ parseGet() {
565
+ this.expect('get');
566
+ return { type: 'command', name: 'get', args: [this.parseExpression()] };
567
+ }
568
+ parseCall() {
569
+ this.expect('call');
570
+ return { type: 'command', name: 'call', args: [this.parseExpression()] };
571
+ }
572
+ parseLog() {
573
+ this.expect('log');
574
+ const args = [];
575
+ while (!this.isAtEnd() && !this.match('then', 'and', 'end', 'else')) {
576
+ args.push(this.parseExpression());
577
+ if (this.match(','))
578
+ this.advance();
579
+ else
580
+ break;
581
+ }
582
+ return { type: 'command', name: 'log', args };
583
+ }
584
+ parseSend() {
585
+ this.advance();
586
+ const event = this.advance().value;
587
+ let target;
588
+ if (this.match('to')) {
589
+ this.advance();
590
+ target = this.parseExpression();
591
+ }
592
+ return { type: 'command', name: 'send', args: [{ type: 'literal', value: event }], target };
593
+ }
594
+ parseWait() {
595
+ this.expect('wait');
596
+ if (this.match('for')) {
597
+ this.advance();
598
+ const event = this.advance().value;
599
+ let target;
600
+ if (this.match('from')) {
601
+ this.advance();
602
+ target = this.parseExpression();
603
+ }
604
+ return {
605
+ type: 'command',
606
+ name: 'waitFor',
607
+ args: [{ type: 'literal', value: event }],
608
+ target,
609
+ };
610
+ }
611
+ return { type: 'command', name: 'wait', args: [this.parseExpression()] };
612
+ }
613
+ parseShow() {
614
+ this.expect('show');
615
+ let target;
616
+ const modifiers = {};
617
+ if (!this.isAtEnd() && !this.match('then', 'and', 'end', 'else', 'when', 'where')) {
618
+ target = this.parseExpression();
619
+ }
620
+ if (!this.isAtEnd() && this.match('when', 'where')) {
621
+ const keyword = this.advance().value;
622
+ modifiers[keyword] = this.parseExpression();
623
+ }
624
+ return { type: 'command', name: 'show', args: [], target, modifiers };
625
+ }
626
+ parseHide() {
627
+ this.expect('hide');
628
+ let target;
629
+ const modifiers = {};
630
+ if (!this.isAtEnd() && !this.match('then', 'and', 'end', 'else', 'when', 'where')) {
631
+ target = this.parseExpression();
632
+ }
633
+ if (!this.isAtEnd() && this.match('when', 'where')) {
634
+ const keyword = this.advance().value;
635
+ modifiers[keyword] = this.parseExpression();
636
+ }
637
+ return { type: 'command', name: 'hide', args: [], target, modifiers };
638
+ }
639
+ parseTake() {
640
+ this.expect('take');
641
+ const what = this.parseExpression();
642
+ let from;
643
+ if (this.match('from')) {
644
+ this.advance();
645
+ from = this.parseExpression();
646
+ }
647
+ return { type: 'command', name: 'take', args: [what], target: from };
648
+ }
649
+ parseIncDec(name) {
650
+ this.advance();
651
+ const target = this.parseExpression();
652
+ let amount = { type: 'literal', value: 1 };
653
+ if (this.match('by')) {
654
+ this.advance();
655
+ amount = this.parseExpression();
656
+ }
657
+ return { type: 'command', name, args: [target, amount] };
658
+ }
659
+ parseFocusBlur(name) {
660
+ this.advance();
661
+ let target;
662
+ if (!this.isAtEnd() && !this.match('then', 'and', 'end', 'else')) {
663
+ target = this.parseExpression();
664
+ }
665
+ return { type: 'command', name, args: [], target };
666
+ }
667
+ parseGo() {
668
+ this.expect('go');
669
+ if (this.match('to'))
670
+ this.advance();
671
+ if (this.match('url'))
672
+ this.advance();
673
+ const dest = this.parseExpression();
674
+ return { type: 'command', name: 'go', args: [dest] };
675
+ }
676
+ parseReturn() {
677
+ this.expect('return');
678
+ let value;
679
+ if (!this.isAtEnd() && !this.match('then', 'and', 'end', 'else')) {
680
+ value = this.parseExpression();
681
+ }
682
+ return { type: 'command', name: 'return', args: value ? [value] : [] };
683
+ }
684
+ parseTransition() {
685
+ this.expect('transition');
686
+ let target;
687
+ if (this.match('my', 'its')) {
688
+ const ref = this.advance().value;
689
+ target = { type: 'identifier', value: ref === 'my' ? 'me' : 'it' };
690
+ }
691
+ else if (this.matchType('selector')) {
692
+ const expr = this.parseExpression();
693
+ if (expr.type === 'possessive') {
694
+ return this.parseTransitionRest(expr.object, expr.property);
695
+ }
696
+ target = expr;
697
+ }
698
+ const propToken = this.peek();
699
+ let property;
700
+ if (propToken.type === 'styleProperty') {
701
+ property = this.advance().value;
702
+ }
703
+ else if (propToken.type === 'identifier' || propToken.type === 'keyword') {
704
+ property = this.advance().value;
705
+ }
706
+ else {
707
+ property = 'opacity';
708
+ }
709
+ return this.parseTransitionRest(target, property);
710
+ }
711
+ parseTransitionRest(target, property) {
712
+ let toValue = { type: 'literal', value: 1 };
713
+ if (this.match('to')) {
714
+ this.advance();
715
+ toValue = this.parseExpression();
716
+ }
717
+ let duration = { type: 'literal', value: 300 };
718
+ if (this.match('over')) {
719
+ this.advance();
720
+ duration = this.parseExpression();
721
+ }
722
+ return {
723
+ type: 'command',
724
+ name: 'transition',
725
+ args: [{ type: 'literal', value: property }, toValue, duration],
726
+ target,
727
+ };
728
+ }
729
+ parseExpression() {
730
+ return this.parseOr();
731
+ }
732
+ parseOr() {
733
+ let left = this.parseAnd();
734
+ while (this.match('or', '||')) {
735
+ this.advance();
736
+ left = { type: 'binary', operator: 'or', left, right: this.parseAnd() };
737
+ }
738
+ return left;
739
+ }
740
+ parseAnd() {
741
+ let left = this.parseEquality();
742
+ while (this.match('and', '&&') && !this.isCommandKeyword(this.peek(1))) {
743
+ this.advance();
744
+ left = { type: 'binary', operator: 'and', left, right: this.parseEquality() };
745
+ }
746
+ return left;
747
+ }
748
+ isCommandKeyword(token) {
749
+ const cmds = [
750
+ 'toggle',
751
+ 'add',
752
+ 'remove',
753
+ 'set',
754
+ 'put',
755
+ 'log',
756
+ 'send',
757
+ 'wait',
758
+ 'show',
759
+ 'hide',
760
+ 'increment',
761
+ 'decrement',
762
+ 'focus',
763
+ 'blur',
764
+ 'go',
765
+ ];
766
+ return cmds.includes(normalizeCommand(token.value));
767
+ }
768
+ parseEquality() {
769
+ let left = this.parseComparison();
770
+ while (this.match('==', '!=', 'is', 'matches', 'contains', 'includes', 'has')) {
771
+ const op = this.advance().value;
772
+ if (op.toLowerCase() === 'is' && this.match('not')) {
773
+ this.advance();
774
+ left = { type: 'binary', operator: 'is not', left, right: this.parseComparison() };
775
+ }
776
+ else {
777
+ left = { type: 'binary', operator: op, left, right: this.parseComparison() };
778
+ }
779
+ }
780
+ return left;
781
+ }
782
+ parseComparison() {
783
+ let left = this.parseAdditive();
784
+ while (this.match('<', '>', '<=', '>=')) {
785
+ const op = this.advance().value;
786
+ left = { type: 'binary', operator: op, left, right: this.parseAdditive() };
787
+ }
788
+ return left;
789
+ }
790
+ parseAdditive() {
791
+ let left = this.parseMultiplicative();
792
+ while (this.match('+', '-')) {
793
+ const op = this.advance().value;
794
+ left = { type: 'binary', operator: op, left, right: this.parseMultiplicative() };
795
+ }
796
+ return left;
797
+ }
798
+ parseMultiplicative() {
799
+ let left = this.parseUnary();
800
+ while (this.match('*', '/', '%')) {
801
+ const op = this.advance().value;
802
+ left = { type: 'binary', operator: op, left, right: this.parseUnary() };
803
+ }
804
+ return left;
805
+ }
806
+ parseUnary() {
807
+ if (this.match('not', '!')) {
808
+ this.advance();
809
+ return { type: 'unary', operator: 'not', operand: this.parseUnary() };
810
+ }
811
+ if (this.match('-') && this.peek(1).type === 'number') {
812
+ this.advance();
813
+ const num = this.advance();
814
+ return { type: 'literal', value: -parseFloat(num.value) };
815
+ }
816
+ return this.parsePostfix();
817
+ }
818
+ parsePostfix() {
819
+ let left = this.parsePrimary();
820
+ while (true) {
821
+ if (this.match("'s")) {
822
+ this.advance();
823
+ const next = this.peek();
824
+ const prop = next.type === 'styleProperty' ? this.advance().value : this.advance().value;
825
+ left = { type: 'possessive', object: left, property: prop };
826
+ }
827
+ else if (this.peek().type === 'styleProperty') {
828
+ const prop = this.advance().value;
829
+ left = { type: 'possessive', object: left, property: prop };
830
+ }
831
+ else if (this.peek().value === '.') {
832
+ this.advance();
833
+ const prop = this.advance().value;
834
+ left = { type: 'member', object: left, property: prop };
835
+ }
836
+ else if (this.peek().type === 'selector' && this.peek().value.startsWith('.')) {
837
+ const prop = this.advance().value.slice(1);
838
+ left = { type: 'member', object: left, property: prop };
839
+ }
840
+ else if (this.peek().value === '(') {
841
+ this.advance();
842
+ const args = [];
843
+ while (!this.match(')')) {
844
+ args.push(this.parseExpression());
845
+ if (this.match(','))
846
+ this.advance();
847
+ }
848
+ this.expect(')');
849
+ left = { type: 'call', callee: left, args };
850
+ }
851
+ else if (this.peek().value === '[' && left.type !== 'selector') {
852
+ this.advance();
853
+ const index = this.parseExpression();
854
+ this.expect(']');
855
+ left = { type: 'member', object: left, property: index, computed: true };
856
+ }
857
+ else {
858
+ break;
859
+ }
860
+ }
861
+ return left;
862
+ }
863
+ parsePrimary() {
864
+ const token = this.peek();
865
+ if (token.value === '(') {
866
+ this.advance();
867
+ const expr = this.parseExpression();
868
+ this.expect(')');
869
+ return expr;
870
+ }
871
+ if (token.value === '{')
872
+ return this.parseObjectLiteral();
873
+ if (token.value === '[')
874
+ return this.parseArrayLiteral();
875
+ if (token.type === 'number') {
876
+ this.advance();
877
+ const val = token.value;
878
+ if (val.endsWith('ms'))
879
+ return { type: 'literal', value: parseInt(val), unit: 'ms' };
880
+ if (val.endsWith('s'))
881
+ return { type: 'literal', value: parseFloat(val) * 1000, unit: 'ms' };
882
+ return { type: 'literal', value: parseFloat(val) };
883
+ }
884
+ if (token.type === 'string') {
885
+ this.advance();
886
+ return { type: 'literal', value: token.value.slice(1, -1) };
887
+ }
888
+ if (this.match('true')) {
889
+ this.advance();
890
+ return { type: 'literal', value: true };
891
+ }
892
+ if (this.match('false')) {
893
+ this.advance();
894
+ return { type: 'literal', value: false };
895
+ }
896
+ if (this.match('null')) {
897
+ this.advance();
898
+ return { type: 'literal', value: null };
899
+ }
900
+ if (this.match('undefined')) {
901
+ this.advance();
902
+ return { type: 'literal', value: undefined };
903
+ }
904
+ if (token.type === 'localVar') {
905
+ this.advance();
906
+ return { type: 'variable', name: token.value, scope: 'local' };
907
+ }
908
+ if (token.type === 'globalVar') {
909
+ this.advance();
910
+ return { type: 'variable', name: token.value, scope: 'global' };
911
+ }
912
+ if (token.type === 'selector') {
913
+ this.advance();
914
+ return { type: 'selector', value: token.value };
915
+ }
916
+ if (this.match('my')) {
917
+ this.advance();
918
+ const next = this.peek();
919
+ if ((next.type === 'identifier' || next.type === 'keyword') && !this.isCommandKeyword(next)) {
920
+ const prop = this.advance().value;
921
+ return { type: 'possessive', object: { type: 'identifier', value: 'me' }, property: prop };
922
+ }
923
+ return { type: 'identifier', value: 'me' };
924
+ }
925
+ if (this.match('its')) {
926
+ this.advance();
927
+ const next = this.peek();
928
+ if ((next.type === 'identifier' || next.type === 'keyword') && !this.isCommandKeyword(next)) {
929
+ const prop = this.advance().value;
930
+ return { type: 'possessive', object: { type: 'identifier', value: 'it' }, property: prop };
931
+ }
932
+ return { type: 'identifier', value: 'it' };
933
+ }
934
+ if (this.match('me')) {
935
+ this.advance();
936
+ return { type: 'identifier', value: 'me' };
937
+ }
938
+ if (this.match('it')) {
939
+ this.advance();
940
+ return { type: 'identifier', value: 'it' };
941
+ }
942
+ if (this.match('you')) {
943
+ this.advance();
944
+ return { type: 'identifier', value: 'you' };
945
+ }
946
+ if (this.match('the', 'a', 'an')) {
947
+ this.advance();
948
+ if (this.match('first', 'last', 'next', 'previous', 'closest', 'parent')) {
949
+ const position = this.advance().value;
950
+ const target = this.parsePositionalTarget();
951
+ return { type: 'positional', position, target };
952
+ }
953
+ return this.parsePrimary();
954
+ }
955
+ if (this.match('first', 'last', 'next', 'previous', 'closest', 'parent')) {
956
+ const position = this.advance().value;
957
+ const target = this.parsePositionalTarget();
958
+ return { type: 'positional', position, target };
959
+ }
960
+ if (token.type === 'identifier' || token.type === 'keyword') {
961
+ this.advance();
962
+ return { type: 'identifier', value: token.value };
963
+ }
964
+ this.advance();
965
+ return { type: 'identifier', value: token.value };
966
+ }
967
+ parseObjectLiteral() {
968
+ this.expect('{');
969
+ const properties = [];
970
+ while (!this.match('}')) {
971
+ const key = this.advance().value;
972
+ this.expect(':');
973
+ const value = this.parseExpression();
974
+ properties.push({ key, value });
975
+ if (this.match(','))
976
+ this.advance();
977
+ }
978
+ this.expect('}');
979
+ return { type: 'object', properties };
980
+ }
981
+ parseArrayLiteral() {
982
+ this.expect('[');
983
+ const elements = [];
984
+ while (!this.match(']')) {
985
+ elements.push(this.parseExpression());
986
+ if (this.match(','))
987
+ this.advance();
988
+ }
989
+ this.expect(']');
990
+ return { type: 'array', elements };
991
+ }
992
+ parsePositionalTarget() {
993
+ const token = this.peek();
994
+ if (token.type === 'selector') {
995
+ return { type: 'selector', value: this.advance().value };
996
+ }
997
+ if (token.type === 'identifier' || token.type === 'keyword') {
998
+ return { type: 'identifier', value: this.advance().value };
999
+ }
1000
+ return this.parseExpression();
1001
+ }
1002
+ }
1003
+
1004
+ class HybridParserImpl {
1005
+ constructor() {
1006
+ this.name = 'hybrid';
1007
+ this.supportedCommands = [
1008
+ 'toggle',
1009
+ 'add',
1010
+ 'remove',
1011
+ 'put',
1012
+ 'append',
1013
+ 'set',
1014
+ 'get',
1015
+ 'call',
1016
+ 'log',
1017
+ 'send',
1018
+ 'trigger',
1019
+ 'wait',
1020
+ 'show',
1021
+ 'hide',
1022
+ 'transition',
1023
+ 'take',
1024
+ 'increment',
1025
+ 'decrement',
1026
+ 'focus',
1027
+ 'blur',
1028
+ 'go',
1029
+ 'return',
1030
+ 'if',
1031
+ 'else',
1032
+ 'unless',
1033
+ 'repeat',
1034
+ 'for',
1035
+ 'while',
1036
+ 'fetch',
1037
+ ];
1038
+ }
1039
+ parse(code) {
1040
+ const parser = new HybridParser(code);
1041
+ return parser.parse();
1042
+ }
1043
+ parseCommands(code) {
1044
+ const parser = new HybridParser(code);
1045
+ const result = parser.parse();
1046
+ if (Array.isArray(result)) {
1047
+ return result;
1048
+ }
1049
+ return [result];
1050
+ }
1051
+ supports(syntax) {
1052
+ const firstWord = syntax.trim().split(/\s+/)[0]?.toLowerCase();
1053
+ if (firstWord === 'on' || firstWord === 'every' || firstWord === 'init') {
1054
+ return true;
1055
+ }
1056
+ return this.supportedCommands.includes(firstWord);
1057
+ }
1058
+ }
1059
+ const hybridParser = new HybridParserImpl();
1060
+ function createHybridParser() {
1061
+ return new HybridParserImpl();
1062
+ }
1063
+ function addCommandAliases(aliases) {
1064
+ addCommandAliases$1(aliases);
1065
+ }
1066
+ function addEventAliases(aliases) {
1067
+ addEventAliases$1(aliases);
1068
+ }
1069
+
1070
+ export { HybridParser, addCommandAliases, addEventAliases, createHybridParser, hybridParser, tokenize };
1071
+ //# sourceMappingURL=hybrid-parser.mjs.map