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