@hyperfixi/core 3.3.0 → 4.0.1

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