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