@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,1175 +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
- function addCommandAliases(aliases) {
280
- Object.assign(COMMAND_ALIASES, aliases);
281
- }
282
- function addEventAliases(aliases) {
283
- Object.assign(EVENT_ALIASES, aliases);
284
- }
285
-
286
- class HybridParser {
287
- constructor(code) {
288
- this.pos = 0;
289
- this.cmdMap = {
290
- toggle: () => this.parseToggle(),
291
- add: () => this.parseAdd(),
292
- remove: () => this.parseRemove(),
293
- put: () => this.parsePut(),
294
- append: () => this.parseInsertion('append'),
295
- prepend: () => this.parseInsertion('prepend'),
296
- set: () => this.parseSet(),
297
- get: () => this.parseGet(),
298
- call: () => this.parseCall(),
299
- log: () => this.parseLog(),
300
- send: () => this.parseSend('to'),
301
- trigger: () => this.parseSend('on'),
302
- wait: () => this.parseWait(),
303
- show: () => this.parseShow(),
304
- hide: () => this.parseHide(),
305
- take: () => this.parseTake(),
306
- empty: () => this.parseEmpty(),
307
- increment: () => this.parseIncDec('increment'),
308
- decrement: () => this.parseIncDec('decrement'),
309
- focus: () => this.parseFocusBlur('focus'),
310
- blur: () => this.parseFocusBlur('blur'),
311
- go: () => this.parseGo(),
312
- return: () => this.parseReturn(),
313
- transition: () => this.parseTransition(),
314
- halt: () => this.parseHalt(),
315
- copy: () => this.parseCopy(),
316
- beep: () => this.parseBeep(),
317
- push: () => this.parseUrlCommand('push'),
318
- replace: () => this.parseUrlCommand('replace'),
319
- morph: () => this.parseMorph(),
320
- js: () => this.parseJs(),
321
- throw: () => this.parseThrow(),
322
- break: () => this.parseBare('break'),
323
- continue: () => this.parseBare('continue'),
324
- exit: () => this.parseBare('exit'),
325
- };
326
- this.source = code;
327
- this.tokens = tokenize(code);
328
- }
329
- peek(offset = 0) {
330
- return this.tokens[Math.min(this.pos + offset, this.tokens.length - 1)];
331
- }
332
- advance() {
333
- return this.tokens[this.pos++];
334
- }
335
- match(...values) {
336
- const token = this.peek();
337
- return values.some(v => token.value.toLowerCase() === v.toLowerCase());
338
- }
339
- matchType(...types) {
340
- return types.includes(this.peek().type);
341
- }
342
- expect(value) {
343
- if (!this.match(value) && normalizeCommand(this.peek().value) !== value) {
344
- throw new Error(`Expected '${value}', got '${this.peek().value}'`);
345
- }
346
- return this.advance();
347
- }
348
- isAtEnd() {
349
- return this.peek().type === 'eof';
350
- }
351
- parse() {
352
- if (this.match('on'))
353
- return this.parseEventHandler();
354
- if (this.match('init')) {
355
- this.advance();
356
- return { type: 'event', event: 'init', modifiers: {}, body: this.parseCommandSequence() };
357
- }
358
- if (this.match('every'))
359
- return this.parseEveryHandler();
360
- return { type: 'sequence', commands: this.parseCommandSequence() };
361
- }
362
- parseEventHandler() {
363
- this.expect('on');
364
- const eventName = this.advance().value;
365
- const modifiers = {};
366
- let filter;
367
- while (this.peek().value === '.') {
368
- this.advance();
369
- const mod = this.advance().value.toLowerCase();
370
- if (mod === 'once')
371
- modifiers.once = true;
372
- else if (mod === 'prevent')
373
- modifiers.prevent = true;
374
- else if (mod === 'stop')
375
- modifiers.stop = true;
376
- else if (mod === 'debounce' || mod === 'throttle') {
377
- if (this.peek().value === '(') {
378
- this.advance();
379
- const num = this.advance().value;
380
- this.expect(')');
381
- if (mod === 'debounce')
382
- modifiers.debounce = parseInt(num) || 100;
383
- else
384
- modifiers.throttle = parseInt(num) || 100;
385
- }
386
- }
387
- }
388
- if (this.match('from')) {
389
- this.advance();
390
- filter = this.parseExpression();
391
- }
392
- return {
393
- type: 'event',
394
- event: normalizeEvent(eventName),
395
- filter,
396
- modifiers,
397
- body: this.parseCommandSequence(),
398
- };
399
- }
400
- parseEveryHandler() {
401
- this.expect('every');
402
- const interval = this.advance().value;
403
- return {
404
- type: 'event',
405
- event: `interval:${interval}`,
406
- modifiers: {},
407
- body: this.parseCommandSequence(),
408
- };
409
- }
410
- parseCommandSequence() {
411
- const commands = [];
412
- while (!this.isAtEnd() && !this.match('end', 'else')) {
413
- const cmd = this.parseCommand();
414
- if (cmd)
415
- commands.push(cmd);
416
- if (this.match('then', 'and'))
417
- this.advance();
418
- }
419
- return commands;
420
- }
421
- parseCommand() {
422
- if (this.match('if', 'unless'))
423
- return this.parseIf();
424
- if (this.match('repeat'))
425
- return this.parseRepeat();
426
- if (this.match('for'))
427
- return this.parseFor();
428
- if (this.match('while'))
429
- return this.parseWhile();
430
- if (this.match('fetch'))
431
- return this.parseFetchBlock();
432
- const normalized = normalizeCommand(this.peek().value);
433
- if (this.cmdMap[normalized]) {
434
- return this.cmdMap[normalized]();
435
- }
436
- if (this.match('catch', 'finally')) {
437
- throw new Error(`'${this.peek().value}' needs the full parser (use hyperfixi.js)`);
438
- }
439
- const stray = this.peek();
440
- if (!this.isAtEnd() &&
441
- (stray.type === 'identifier' || stray.type === 'keyword') &&
442
- !this.match('then', 'and', 'end', 'else')) {
443
- throw new Error(`'${stray.value}' needs the full parser (use hyperfixi.js)`);
444
- }
445
- if (!this.isAtEnd() && !this.match('then', 'and', 'end', 'else')) {
446
- this.advance();
447
- }
448
- return null;
449
- }
450
- parseIf() {
451
- const isUnless = this.match('unless');
452
- this.advance();
453
- const condition = this.parseExpression();
454
- const body = this.parseCommandSequence();
455
- let elseBody;
456
- if (this.match('else')) {
457
- this.advance();
458
- elseBody = this.parseCommandSequence();
459
- }
460
- if (this.match('end'))
461
- this.advance();
462
- return {
463
- type: 'if',
464
- condition: isUnless ? { type: 'unary', operator: 'not', operand: condition } : condition,
465
- body,
466
- elseBody,
467
- };
468
- }
469
- parseRepeat() {
470
- this.expect('repeat');
471
- let count;
472
- if (!this.match('until', 'while', 'forever')) {
473
- count = this.parseExpression();
474
- if (this.match('times'))
475
- this.advance();
476
- }
477
- const body = this.parseCommandSequence();
478
- if (this.match('end'))
479
- this.advance();
480
- return { type: 'repeat', condition: count, body };
481
- }
482
- parseFor() {
483
- this.expect('for');
484
- if (this.match('each'))
485
- this.advance();
486
- const variable = this.advance().value;
487
- this.expect('in');
488
- const iterable = this.parseExpression();
489
- const body = this.parseCommandSequence();
490
- if (this.match('end'))
491
- this.advance();
492
- return { type: 'for', condition: { type: 'forCondition', variable, iterable }, body };
493
- }
494
- parseWhile() {
495
- this.expect('while');
496
- const condition = this.parseExpression();
497
- const body = this.parseCommandSequence();
498
- if (this.match('end'))
499
- this.advance();
500
- return { type: 'while', condition, body };
501
- }
502
- parseNakedUrl() {
503
- const tok = this.peek();
504
- const isSlash = tok.type === 'operator' && tok.value === '/';
505
- const isScheme = (tok.value === 'http' || tok.value === 'https') &&
506
- this.source.slice(tok.pos + tok.value.length, tok.pos + tok.value.length + 3) === '://';
507
- if (!isSlash && !isScheme)
508
- return null;
509
- let end = tok.pos;
510
- while (end < this.source.length && !/\s/.test(this.source[end]))
511
- end++;
512
- while (!this.isAtEnd() && this.peek().pos < end)
513
- this.advance();
514
- return { type: 'literal', value: this.source.slice(tok.pos, end) };
515
- }
516
- parseFetchBlock() {
517
- this.expect('fetch');
518
- const url = this.parseNakedUrl() ?? this.parseExpression();
519
- let responseType = { type: 'literal', value: 'text' };
520
- let options;
521
- let method;
522
- if (this.match('{')) {
523
- this.pos--;
524
- options = this.parseExpression();
525
- }
526
- for (let i = 0; i < 3; i++) {
527
- if (this.match('via') && !method) {
528
- this.advance();
529
- method = this.parseExpression();
530
- continue;
531
- }
532
- if (this.match('as')) {
533
- this.advance();
534
- if (this.match('a') || this.match('an'))
535
- this.advance();
536
- responseType = this.parseExpression();
537
- continue;
538
- }
539
- if (this.match('with') && !options) {
540
- this.advance();
541
- options = this.parseExpression();
542
- continue;
543
- }
544
- break;
545
- }
546
- if (this.match('then'))
547
- this.advance();
548
- const body = this.parseCommandSequence();
549
- return {
550
- type: 'fetch',
551
- condition: { type: 'fetchConfig', url, responseType, options, method },
552
- body,
553
- };
554
- }
555
- parseToggle() {
556
- this.expect('toggle');
557
- const what = this.parseExpression();
558
- let target;
559
- if (this.match('on')) {
560
- this.advance();
561
- target = this.parseExpression();
562
- }
563
- return { type: 'command', name: 'toggle', args: [what], target };
564
- }
565
- parseAdd() {
566
- this.expect('add');
567
- const what = this.parseExpression();
568
- let target;
569
- if (this.match('to')) {
570
- this.advance();
571
- target = this.parseExpression();
572
- }
573
- return { type: 'command', name: 'add', args: [what], target };
574
- }
575
- parseRemove() {
576
- this.expect('remove');
577
- if (this.matchType('selector') && /^[.@]/.test(this.peek().value)) {
578
- const what = this.parseExpression();
579
- let target;
580
- if (this.match('from')) {
581
- this.advance();
582
- target = this.parseExpression();
583
- }
584
- return { type: 'command', name: 'removeClass', args: [what], target };
585
- }
586
- const target = this.parseExpression();
587
- return { type: 'command', name: 'remove', args: [], target };
588
- }
589
- parsePut() {
590
- this.expect('put');
591
- const content = this.parseExpression();
592
- let modifier = 'into';
593
- if (this.match('into', 'before', 'after', 'at')) {
594
- modifier = this.advance().value;
595
- if (modifier === 'at') {
596
- const pos = this.advance().value;
597
- this.expect('of');
598
- modifier = `at ${pos} of`;
599
- }
600
- }
601
- const target = this.parseExpression();
602
- return { type: 'command', name: 'put', args: [content], target, modifier };
603
- }
604
- parseInsertion(name) {
605
- this.expect(name);
606
- const content = this.parseExpression();
607
- let target;
608
- if (this.match('to')) {
609
- this.advance();
610
- target = this.parseExpression();
611
- }
612
- return { type: 'command', name, args: [content], target };
613
- }
614
- parseSet() {
615
- this.expect('set');
616
- const target = this.parseExpression();
617
- if (this.match('to')) {
618
- this.advance();
619
- const value = this.parseExpression();
620
- return { type: 'command', name: 'set', args: [target, value] };
621
- }
622
- return { type: 'command', name: 'set', args: [target] };
623
- }
624
- parseGet() {
625
- this.expect('get');
626
- return { type: 'command', name: 'get', args: [this.parseExpression()] };
627
- }
628
- parseCall() {
629
- this.expect('call');
630
- return { type: 'command', name: 'call', args: [this.parseExpression()] };
631
- }
632
- parseLog() {
633
- this.expect('log');
634
- const args = [];
635
- while (!this.isAtEnd() && !this.match('then', 'and', 'end', 'else')) {
636
- args.push(this.parseExpression());
637
- if (this.match(','))
638
- this.advance();
639
- else
640
- break;
641
- }
642
- return { type: 'command', name: 'log', args };
643
- }
644
- parseSend(marker) {
645
- this.advance();
646
- const first = this.advance();
647
- let event = first.value;
648
- let end = first.pos + first.value.length;
649
- while (!this.isAtEnd() && this.peek().type === 'localVar' && this.peek().pos === end) {
650
- const piece = this.advance();
651
- event += piece.value;
652
- end = piece.pos + piece.value.length;
653
- }
654
- let target;
655
- if (this.match(marker)) {
656
- this.advance();
657
- target = this.parseExpression();
658
- }
659
- return { type: 'command', name: 'send', args: [{ type: 'literal', value: event }], target };
660
- }
661
- parseWait() {
662
- this.expect('wait');
663
- if (this.match('for')) {
664
- this.advance();
665
- const event = this.advance().value;
666
- let target;
667
- if (this.match('from')) {
668
- this.advance();
669
- target = this.parseExpression();
670
- }
671
- return {
672
- type: 'command',
673
- name: 'waitFor',
674
- args: [{ type: 'literal', value: event }],
675
- target,
676
- };
677
- }
678
- return { type: 'command', name: 'wait', args: [this.parseExpression()] };
679
- }
680
- parseShow() {
681
- this.expect('show');
682
- let target;
683
- const modifiers = {};
684
- if (!this.isAtEnd() && !this.match('then', 'and', 'end', 'else', 'when', 'where')) {
685
- target = this.parseExpression();
686
- }
687
- if (!this.isAtEnd() && this.match('when', 'where')) {
688
- const keyword = this.advance().value;
689
- modifiers[keyword] = this.parseExpression();
690
- }
691
- return { type: 'command', name: 'show', args: [], target, modifiers };
692
- }
693
- parseHide() {
694
- this.expect('hide');
695
- let target;
696
- const modifiers = {};
697
- if (!this.isAtEnd() && !this.match('then', 'and', 'end', 'else', 'when', 'where')) {
698
- target = this.parseExpression();
699
- }
700
- if (!this.isAtEnd() && this.match('when', 'where')) {
701
- const keyword = this.advance().value;
702
- modifiers[keyword] = this.parseExpression();
703
- }
704
- return { type: 'command', name: 'hide', args: [], target, modifiers };
705
- }
706
- parseTake() {
707
- this.expect('take');
708
- const what = this.parseExpression();
709
- let from;
710
- if (this.match('from')) {
711
- this.advance();
712
- from = this.parseExpression();
713
- }
714
- return { type: 'command', name: 'take', args: [what], target: from };
715
- }
716
- parseIncDec(name) {
717
- this.advance();
718
- const target = this.parseExpression();
719
- let amount = { type: 'literal', value: 1 };
720
- if (this.match('by')) {
721
- this.advance();
722
- amount = this.parseExpression();
723
- }
724
- return { type: 'command', name, args: [target, amount] };
725
- }
726
- parseFocusBlur(name) {
727
- this.advance();
728
- let target;
729
- if (!this.isAtEnd() && !this.match('then', 'and', 'end', 'else')) {
730
- target = this.parseExpression();
731
- }
732
- return { type: 'command', name, args: [], target };
733
- }
734
- parseGo() {
735
- this.expect('go');
736
- if (this.match('to'))
737
- this.advance();
738
- if (this.match('url'))
739
- this.advance();
740
- const dest = this.parseExpression();
741
- return { type: 'command', name: 'go', args: [dest] };
742
- }
743
- parseReturn() {
744
- this.expect('return');
745
- let value;
746
- if (!this.isAtEnd() && !this.match('then', 'and', 'end', 'else')) {
747
- value = this.parseExpression();
748
- }
749
- return { type: 'command', name: 'return', args: value ? [value] : [] };
750
- }
751
- parseEmpty() {
752
- this.expect('empty');
753
- let target;
754
- if (!this.isAtEnd() && !this.match('then', 'and', 'end', 'else')) {
755
- target = this.parseExpression();
756
- }
757
- return { type: 'command', name: 'empty', args: [], target };
758
- }
759
- parseCopy() {
760
- this.expect('copy');
761
- return { type: 'command', name: 'copy', args: [this.parseExpression()] };
762
- }
763
- parseBeep() {
764
- this.advance();
765
- if (this.match('!'))
766
- this.advance();
767
- const args = [];
768
- while (!this.isAtEnd() && !this.match('then', 'and', 'end', 'else')) {
769
- args.push(this.parseExpression());
770
- if (this.match(','))
771
- this.advance();
772
- else
773
- break;
774
- }
775
- return { type: 'command', name: 'beep', args };
776
- }
777
- parseUrlCommand(name) {
778
- this.advance();
779
- if (this.match('url'))
780
- this.advance();
781
- const url = this.parseExpression();
782
- const modifiers = {};
783
- if (this.match('with')) {
784
- this.advance();
785
- if (this.match('title')) {
786
- this.advance();
787
- modifiers.title = this.parseExpression();
788
- }
789
- }
790
- return { type: 'command', name, args: [url], modifiers };
791
- }
792
- parseMorph() {
793
- this.expect('morph');
794
- let modifier;
795
- if (this.match('over')) {
796
- this.advance();
797
- modifier = 'over';
798
- }
799
- const target = this.parseExpression();
800
- if (this.match('with', 'to', 'into'))
801
- this.advance();
802
- const content = this.parseExpression();
803
- return { type: 'command', name: 'morph', args: [content], target, modifier };
804
- }
805
- parseJs() {
806
- this.advance();
807
- if (this.match('(')) {
808
- while (!this.isAtEnd() && !this.match(')'))
809
- this.advance();
810
- if (this.match(')'))
811
- this.advance();
812
- }
813
- const start = this.peek().pos;
814
- while (!this.isAtEnd() && !this.match('end'))
815
- this.advance();
816
- const stop = this.peek().pos;
817
- if (this.match('end'))
818
- this.advance();
819
- const code = this.source.slice(start, stop).trim();
820
- return { type: 'command', name: 'js', args: [{ type: 'literal', value: code }] };
821
- }
822
- parseThrow() {
823
- this.expect('throw');
824
- let value;
825
- if (!this.isAtEnd() && !this.match('then', 'and', 'end', 'else')) {
826
- value = this.parseExpression();
827
- }
828
- return { type: 'command', name: 'throw', args: value ? [value] : [] };
829
- }
830
- parseBare(name) {
831
- this.advance();
832
- return { type: 'command', name, args: [] };
833
- }
834
- parseHalt() {
835
- this.expect('halt');
836
- if (this.match('the'))
837
- this.advance();
838
- if (this.match('event', 'default'))
839
- this.advance();
840
- return { type: 'command', name: 'halt', args: [] };
841
- }
842
- parseTransition() {
843
- this.expect('transition');
844
- let target;
845
- if (this.match('my', 'its')) {
846
- const ref = this.advance().value;
847
- target = { type: 'identifier', value: ref === 'my' ? 'me' : 'it' };
848
- }
849
- else if (this.matchType('selector')) {
850
- const expr = this.parseExpression();
851
- if (expr.type === 'possessive') {
852
- return this.parseTransitionRest(expr.object, expr.property);
853
- }
854
- target = expr;
855
- }
856
- const propToken = this.peek();
857
- let property;
858
- if (propToken.type === 'styleProperty') {
859
- property = this.advance().value;
860
- }
861
- else if (propToken.type === 'identifier' || propToken.type === 'keyword') {
862
- property = this.advance().value;
863
- }
864
- else {
865
- property = 'opacity';
866
- }
867
- return this.parseTransitionRest(target, property);
868
- }
869
- parseTransitionRest(target, property) {
870
- let toValue = { type: 'literal', value: 1 };
871
- if (this.match('to')) {
872
- this.advance();
873
- toValue = this.parseExpression();
874
- }
875
- let duration = { type: 'literal', value: 300 };
876
- if (this.match('over')) {
877
- this.advance();
878
- duration = this.parseExpression();
879
- }
880
- return {
881
- type: 'command',
882
- name: 'transition',
883
- args: [{ type: 'literal', value: property }, toValue, duration],
884
- target,
885
- };
886
- }
887
- parseExpression() {
888
- return this.parseOr();
889
- }
890
- parseOr() {
891
- let left = this.parseAnd();
892
- while (this.match('or', '||')) {
893
- this.advance();
894
- left = { type: 'binary', operator: 'or', left, right: this.parseAnd() };
895
- }
896
- return left;
897
- }
898
- parseAnd() {
899
- let left = this.parseEquality();
900
- while (this.match('and', '&&') && !this.isCommandKeyword(this.peek(1))) {
901
- this.advance();
902
- left = { type: 'binary', operator: 'and', left, right: this.parseEquality() };
903
- }
904
- return left;
905
- }
906
- isCommandKeyword(token) {
907
- const cmds = [
908
- 'toggle',
909
- 'add',
910
- 'remove',
911
- 'set',
912
- 'put',
913
- 'log',
914
- 'send',
915
- 'wait',
916
- 'show',
917
- 'hide',
918
- 'increment',
919
- 'decrement',
920
- 'focus',
921
- 'blur',
922
- 'go',
923
- ];
924
- return cmds.includes(normalizeCommand(token.value));
925
- }
926
- parseEquality() {
927
- let left = this.parseComparison();
928
- while (this.match('==', '!=', 'is', 'matches', 'contains', 'includes', 'has')) {
929
- const op = this.advance().value;
930
- if (op.toLowerCase() === 'is' && this.match('not')) {
931
- this.advance();
932
- left = { type: 'binary', operator: 'is not', left, right: this.parseComparison() };
933
- }
934
- else {
935
- left = { type: 'binary', operator: op, left, right: this.parseComparison() };
936
- }
937
- }
938
- return left;
939
- }
940
- parseComparison() {
941
- let left = this.parseAdditive();
942
- while (this.match('<', '>', '<=', '>=')) {
943
- const op = this.advance().value;
944
- left = { type: 'binary', operator: op, left, right: this.parseAdditive() };
945
- }
946
- return left;
947
- }
948
- parseAdditive() {
949
- let left = this.parseMultiplicative();
950
- while (this.match('+', '-')) {
951
- const op = this.advance().value;
952
- left = { type: 'binary', operator: op, left, right: this.parseMultiplicative() };
953
- }
954
- return left;
955
- }
956
- parseMultiplicative() {
957
- let left = this.parseUnary();
958
- while (this.match('*', '/', '%')) {
959
- const op = this.advance().value;
960
- left = { type: 'binary', operator: op, left, right: this.parseUnary() };
961
- }
962
- return left;
963
- }
964
- parseUnary() {
965
- if (this.match('beep') && this.peek(1).value === '!') {
966
- throw new Error(`'beep!' needs the full parser (use hyperfixi.js)`);
967
- }
968
- if (this.match('not', '!')) {
969
- this.advance();
970
- return { type: 'unary', operator: 'not', operand: this.parseUnary() };
971
- }
972
- if (this.match('-') && this.peek(1).type === 'number') {
973
- this.advance();
974
- const num = this.advance();
975
- return { type: 'literal', value: -parseFloat(num.value) };
976
- }
977
- return this.parsePostfix();
978
- }
979
- parsePostfix() {
980
- let left = this.parsePrimary();
981
- while (true) {
982
- if (this.match("'s")) {
983
- this.advance();
984
- const next = this.peek();
985
- const prop = next.type === 'styleProperty' ? this.advance().value : this.advance().value;
986
- left = { type: 'possessive', object: left, property: prop };
987
- }
988
- else if (this.peek().type === 'styleProperty') {
989
- const prop = this.advance().value;
990
- left = { type: 'possessive', object: left, property: prop };
991
- }
992
- else if (this.peek().value === '.') {
993
- this.advance();
994
- const prop = this.advance().value;
995
- left = { type: 'member', object: left, property: prop };
996
- }
997
- else if (this.peek().type === 'selector' && this.peek().value.startsWith('.')) {
998
- const prop = this.advance().value.slice(1);
999
- left = { type: 'member', object: left, property: prop };
1000
- }
1001
- else if (this.peek().value === '(') {
1002
- this.advance();
1003
- const args = [];
1004
- while (!this.match(')')) {
1005
- args.push(this.parseExpression());
1006
- if (this.match(','))
1007
- this.advance();
1008
- }
1009
- this.expect(')');
1010
- left = { type: 'call', callee: left, args };
1011
- }
1012
- else if (this.peek().value === '[' && left.type !== 'selector') {
1013
- this.advance();
1014
- const index = this.parseExpression();
1015
- this.expect(']');
1016
- left = { type: 'member', object: left, property: index, computed: true };
1017
- }
1018
- else {
1019
- break;
1020
- }
1021
- }
1022
- return left;
1023
- }
1024
- parsePrimary() {
1025
- const token = this.peek();
1026
- if (token.value === '(') {
1027
- this.advance();
1028
- const expr = this.parseExpression();
1029
- this.expect(')');
1030
- return expr;
1031
- }
1032
- if (token.value === '{')
1033
- return this.parseObjectLiteral();
1034
- if (token.value === '[')
1035
- return this.parseArrayLiteral();
1036
- if (token.type === 'number') {
1037
- this.advance();
1038
- const val = token.value;
1039
- if (val.endsWith('ms'))
1040
- return { type: 'literal', value: parseInt(val), unit: 'ms' };
1041
- if (val.endsWith('s'))
1042
- return { type: 'literal', value: parseFloat(val) * 1000, unit: 'ms' };
1043
- return { type: 'literal', value: parseFloat(val) };
1044
- }
1045
- if (token.type === 'string') {
1046
- this.advance();
1047
- return { type: 'literal', value: token.value.slice(1, -1) };
1048
- }
1049
- if (this.match('true')) {
1050
- this.advance();
1051
- return { type: 'literal', value: true };
1052
- }
1053
- if (this.match('false')) {
1054
- this.advance();
1055
- return { type: 'literal', value: false };
1056
- }
1057
- if (this.match('null')) {
1058
- this.advance();
1059
- return { type: 'literal', value: null };
1060
- }
1061
- if (this.match('undefined')) {
1062
- this.advance();
1063
- return { type: 'literal', value: undefined };
1064
- }
1065
- if (token.type === 'localVar') {
1066
- this.advance();
1067
- return { type: 'variable', name: token.value, scope: 'local' };
1068
- }
1069
- if (token.type === 'globalVar') {
1070
- this.advance();
1071
- return { type: 'variable', name: token.value, scope: 'global' };
1072
- }
1073
- if (token.type === 'selector') {
1074
- this.advance();
1075
- return { type: 'selector', value: token.value };
1076
- }
1077
- if (this.match('my')) {
1078
- this.advance();
1079
- const next = this.peek();
1080
- if ((next.type === 'identifier' || next.type === 'keyword') && !this.isCommandKeyword(next)) {
1081
- const prop = this.advance().value;
1082
- return { type: 'possessive', object: { type: 'identifier', value: 'me' }, property: prop };
1083
- }
1084
- return { type: 'identifier', value: 'me' };
1085
- }
1086
- if (this.match('its')) {
1087
- this.advance();
1088
- const next = this.peek();
1089
- if ((next.type === 'identifier' || next.type === 'keyword') && !this.isCommandKeyword(next)) {
1090
- const prop = this.advance().value;
1091
- return { type: 'possessive', object: { type: 'identifier', value: 'it' }, property: prop };
1092
- }
1093
- return { type: 'identifier', value: 'it' };
1094
- }
1095
- if (this.match('me')) {
1096
- this.advance();
1097
- return { type: 'identifier', value: 'me' };
1098
- }
1099
- if (this.match('it')) {
1100
- this.advance();
1101
- return { type: 'identifier', value: 'it' };
1102
- }
1103
- if (this.match('you')) {
1104
- this.advance();
1105
- return { type: 'identifier', value: 'you' };
1106
- }
1107
- if (this.match('the', 'a', 'an')) {
1108
- this.advance();
1109
- if (this.match('first', 'last', 'next', 'previous', 'closest', 'parent')) {
1110
- const position = this.advance().value;
1111
- const target = this.parsePositionalTarget();
1112
- return { type: 'positional', position, target };
1113
- }
1114
- return this.parsePrimary();
1115
- }
1116
- if (this.match('first', 'last', 'next', 'previous', 'closest', 'parent')) {
1117
- const position = this.advance().value;
1118
- const target = this.parsePositionalTarget();
1119
- return { type: 'positional', position, target };
1120
- }
1121
- if (this.match('values')) {
1122
- this.advance();
1123
- if (this.match('of')) {
1124
- this.advance();
1125
- const target = this.parseExpression();
1126
- return { type: 'valuesOf', target };
1127
- }
1128
- return { type: 'identifier', value: token.value };
1129
- }
1130
- if (token.type === 'identifier' || token.type === 'keyword') {
1131
- this.advance();
1132
- return { type: 'identifier', value: token.value };
1133
- }
1134
- this.advance();
1135
- return { type: 'identifier', value: token.value };
1136
- }
1137
- parseObjectLiteral() {
1138
- this.expect('{');
1139
- const properties = [];
1140
- while (!this.match('}')) {
1141
- const key = this.advance().value;
1142
- this.expect(':');
1143
- const value = this.parseExpression();
1144
- properties.push({ key, value });
1145
- if (this.match(','))
1146
- this.advance();
1147
- }
1148
- this.expect('}');
1149
- return { type: 'object', properties };
1150
- }
1151
- parseArrayLiteral() {
1152
- this.expect('[');
1153
- const elements = [];
1154
- while (!this.match(']')) {
1155
- elements.push(this.parseExpression());
1156
- if (this.match(','))
1157
- this.advance();
1158
- }
1159
- this.expect(']');
1160
- return { type: 'array', elements };
1161
- }
1162
- parsePositionalTarget() {
1163
- const token = this.peek();
1164
- if (token.type === 'selector') {
1165
- return { type: 'selector', value: this.advance().value };
1166
- }
1167
- if (token.type === 'identifier' || token.type === 'keyword') {
1168
- return { type: 'identifier', value: this.advance().value };
1169
- }
1170
- return this.parseExpression();
1171
- }
1172
- }
1173
-
1174
- export { COMMAND_ALIASES, EVENT_ALIASES, HybridParser, KEYWORDS, addCommandAliases, addEventAliases, normalizeCommand, normalizeEvent, tokenize };
1175
- //# sourceMappingURL=index.mjs.map