@hyperfixi/core 3.1.1 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/README.md +28 -36
  2. package/dist/ast/command-slots.d.ts +1 -1
  3. package/dist/ast/nodes.d.ts +2 -0
  4. package/dist/ast-utils/index.cjs +193 -48
  5. package/dist/ast-utils/index.mjs +193 -48
  6. package/dist/ast-utils/interchange/types.d.ts +19 -1
  7. package/dist/behaviors/index.cjs +19 -0
  8. package/dist/behaviors/index.mjs +19 -0
  9. package/dist/bundle-generator/index.cjs +36 -17
  10. package/dist/bundle-generator/index.mjs +36 -17
  11. package/dist/bundle-generator/parser-templates.d.ts +1 -1
  12. package/dist/chunks/bridge-CI9SOl8u.js +2 -0
  13. package/dist/chunks/browser-modular-7CpI5VF2.js +2 -0
  14. package/dist/chunks/index-BwXDEK0m.js +2 -0
  15. package/dist/chunks/index-DQi2o8Lk.js +2 -0
  16. package/dist/chunks/index-uCOQ8Qn0.js +2 -0
  17. package/dist/commands/animation/transition.d.ts +12 -6
  18. package/dist/commands/helpers/loop-executor.d.ts +2 -2
  19. package/dist/commands/helpers/numeric-target-parser.d.ts +1 -1
  20. package/dist/commands/helpers/variable-access.d.ts +5 -2
  21. package/dist/commands/helpers/write-target.d.ts +5 -0
  22. package/dist/commands/index.cjs +938 -425
  23. package/dist/commands/index.mjs +938 -425
  24. package/dist/commands/templates/render.d.ts +4 -4
  25. package/dist/commands/utility/beep.d.ts +0 -3
  26. package/dist/expressions/index.cjs +7 -13
  27. package/dist/expressions/index.mjs +7 -13
  28. package/dist/htmx/i18n-hooks.d.ts +4 -1
  29. package/dist/hyperfixi-browser-classic-i18n.js +1 -1
  30. package/dist/hyperfixi-browser.js +1 -1
  31. package/dist/hyperfixi-classic-i18n.js +1 -1
  32. package/dist/hyperfixi-hx-v4.js +1 -1
  33. package/dist/hyperfixi-hx.js +1 -1
  34. package/dist/hyperfixi-hybrid-complete.js +1 -1
  35. package/dist/hyperfixi-hybrid-hx.js +1 -1
  36. package/dist/hyperfixi-multilingual.js +1 -1
  37. package/dist/hyperfixi.js +1 -1
  38. package/dist/hyperfixi.mjs +1 -1
  39. package/dist/index.cjs +1149 -485
  40. package/dist/index.min.js +1 -1
  41. package/dist/index.mjs +1149 -485
  42. package/dist/lib/swap-executor.d.ts +1 -1
  43. package/dist/lokascript-browser-classic-i18n.js +1 -1
  44. package/dist/lokascript-browser.js +1 -1
  45. package/dist/lokascript-hybrid-complete.js +1 -1
  46. package/dist/lokascript-hybrid-hx.js +1 -1
  47. package/dist/lokascript-multilingual.js +1 -1
  48. package/dist/metadata.cjs +9 -9
  49. package/dist/metadata.d.ts +1 -1
  50. package/dist/metadata.mjs +9 -9
  51. package/dist/parser/command-grammar.d.ts +1 -0
  52. package/dist/parser/full-parser.cjs +396 -153
  53. package/dist/parser/full-parser.mjs +396 -153
  54. package/dist/parser/helpers/parsing-helpers.d.ts +3 -0
  55. package/dist/parser/hybrid/index.cjs +3 -0
  56. package/dist/parser/hybrid/index.mjs +3 -0
  57. package/dist/parser/hybrid/parser-core.cjs +3 -0
  58. package/dist/parser/hybrid/parser-core.mjs +3 -0
  59. package/dist/parser/hybrid-parser.cjs +3 -0
  60. package/dist/parser/hybrid-parser.mjs +3 -0
  61. package/dist/parser/parser-types.d.ts +2 -0
  62. package/dist/parser/parser.d.ts +9 -0
  63. package/dist/parser/pratt-parser.d.ts +2 -0
  64. package/dist/registry/index.cjs +535 -210
  65. package/dist/registry/index.mjs +535 -210
  66. package/dist/utils/beep.d.ts +8 -0
  67. package/dist/version.d.ts +1 -1
  68. package/package.json +21 -18
  69. package/vocab/htmx/ar.js +22 -20
  70. package/vocab/htmx/bn.js +21 -5
  71. package/vocab/htmx/de.js +33 -10
  72. package/vocab/htmx/en.js +4 -1
  73. package/vocab/htmx/es.js +28 -9
  74. package/vocab/htmx/fr.js +28 -8
  75. package/vocab/htmx/he.js +22 -1
  76. package/vocab/htmx/hi.js +28 -7
  77. package/vocab/htmx/id.js +29 -10
  78. package/vocab/htmx/it.js +26 -5
  79. package/vocab/htmx/ja.js +36 -11
  80. package/vocab/htmx/ko.js +27 -6
  81. package/vocab/htmx/ms.js +24 -1
  82. package/vocab/htmx/pl.js +27 -7
  83. package/vocab/htmx/pt.js +30 -9
  84. package/vocab/htmx/qu.js +32 -9
  85. package/vocab/htmx/ru.js +28 -6
  86. package/vocab/htmx/sw.js +28 -8
  87. package/vocab/htmx/th.js +19 -1
  88. package/vocab/htmx/tl.js +24 -1
  89. package/vocab/htmx/tr.js +34 -8
  90. package/vocab/htmx/uk.js +28 -6
  91. package/vocab/htmx/vi.js +27 -19
  92. package/vocab/htmx/zh.js +28 -9
  93. package/dist/chunks/bridge-D7qrHhV0.js +0 -2
  94. package/dist/chunks/browser-modular-C4LFxfoS.js +0 -2
  95. package/dist/chunks/index-C7lqD4mo.js +0 -2
  96. package/dist/chunks/index-CAPhqA6k.js +0 -2
  97. package/dist/chunks/index-CLdRyZaP.js +0 -2
@@ -14,16 +14,16 @@ export declare class RenderCommand {
14
14
  readonly name = "render";
15
15
  static readonly metadata: {
16
16
  readonly description: "Render templates with @if, @else, and @repeat directives";
17
- readonly syntax: readonly ["render <template>", "render <template> with <variables>", "render <template> with (key: value, ...)"];
18
- readonly examples: readonly ["render myTemplate", "render myTemplate with (name: \"Alice\")", "render \"<template>Hello ${name}!</template>\" with (name: \"World\")", "render template with (items: data)"];
17
+ readonly syntax: readonly ["render <template>", "render <template> with <name>: <value>, ..."];
18
+ readonly examples: readonly ["render myTemplate", "render myTemplate with name: \"Alice\"", "render \"<template>Hello ${name}!</template>\" with name: \"World\"", "render template with items: data"];
19
19
  readonly category: "templates";
20
20
  readonly compatibility: "standard";
21
21
  readonly sideEffects: readonly ["dom-creation", "template-execution"];
22
22
  };
23
23
  get metadata(): {
24
24
  readonly description: "Render templates with @if, @else, and @repeat directives";
25
- readonly syntax: readonly ["render <template>", "render <template> with <variables>", "render <template> with (key: value, ...)"];
26
- readonly examples: readonly ["render myTemplate", "render myTemplate with (name: \"Alice\")", "render \"<template>Hello ${name}!</template>\" with (name: \"World\")", "render template with (items: data)"];
25
+ readonly syntax: readonly ["render <template>", "render <template> with <name>: <value>, ..."];
26
+ readonly examples: readonly ["render myTemplate", "render myTemplate with name: \"Alice\"", "render \"<template>Hello ${name}!</template>\" with name: \"World\"", "render template with items: data"];
27
27
  readonly category: "templates";
28
28
  readonly compatibility: "standard";
29
29
  readonly sideEffects: readonly ["dom-creation", "template-execution"];
@@ -35,9 +35,6 @@ export declare class BeepCommand implements DecoratedCommand {
35
35
  parseInput(raw: CommandRaw<'beep'>, evaluator: ExpressionEvaluator, context: ExecutionContext): Promise<BeepCommandInput>;
36
36
  execute(input: BeepCommandInput, context: TypedExecutionContext): Promise<BeepCommandOutput>;
37
37
  private debugContext;
38
- private debugExpression;
39
- private getType;
40
- private getRepresentation;
41
38
  }
42
39
  export declare const createBeepCommand: () => BeepCommand;
43
40
  export default BeepCommand;
@@ -545,14 +545,15 @@ const closestExpression = {
545
545
  if (typeof selector !== 'string') {
546
546
  throw new Error('closest requires a string selector');
547
547
  }
548
- if (!context.me) {
548
+ const start = args.length > 1 ? args[1] : context.me;
549
+ if (!(start instanceof Element)) {
549
550
  return null;
550
551
  }
551
- return context.me.closest(selector);
552
+ return start.closest(selector);
552
553
  },
553
554
  validate(args) {
554
- if (args.length !== 1) {
555
- return 'closest requires exactly 1 argument (selector)';
555
+ if (args.length !== 1 && args.length !== 2) {
556
+ return 'closest requires a selector and, optionally, the element to start from';
556
557
  }
557
558
  const arg = args[0];
558
559
  if (typeof arg === 'string')
@@ -2066,7 +2067,7 @@ const isEmptyExpression = {
2066
2067
  else if (value instanceof Node || value instanceof Element)
2067
2068
  result = false;
2068
2069
  else if (isObject(value))
2069
- result = Object.keys(value).length === 0;
2070
+ result = value.length === 0;
2070
2071
  else
2071
2072
  result = false;
2072
2073
  return result;
@@ -3913,13 +3914,6 @@ function createCommonRegistry() {
3913
3914
  function isInputElement(el) {
3914
3915
  return (el !== null && typeof el === 'object' && 'tagName' in el && el.tagName === 'INPUT');
3915
3916
  }
3916
- function isFormElement(el) {
3917
- if (el === null || typeof el !== 'object' || !('tagName' in el)) {
3918
- return false;
3919
- }
3920
- const tag = el.tagName;
3921
- return tag === 'INPUT' || tag === 'SELECT' || tag === 'TEXTAREA';
3922
- }
3923
3917
  function isHTMLElement$1(el) {
3924
3918
  return (el !== null &&
3925
3919
  typeof el === 'object' &&
@@ -3976,7 +3970,7 @@ const SPECIAL_DOM_PROPERTIES = {
3976
3970
  innertext: el => el.textContent?.trim(),
3977
3971
  innerHTML: el => el.innerHTML,
3978
3972
  outerhtml: el => el.outerHTML,
3979
- value: el => (isFormElement(el) ? el.value : undefined),
3973
+ value: el => ('value' in el ? el.value : undefined),
3980
3974
  checked: el => (isInputElement(el) ? el.checked : undefined),
3981
3975
  disabled: el => ('disabled' in el ? el.disabled : undefined),
3982
3976
  selected: el => (isOptionElement(el) ? el.selected : undefined),
@@ -543,14 +543,15 @@ const closestExpression = {
543
543
  if (typeof selector !== 'string') {
544
544
  throw new Error('closest requires a string selector');
545
545
  }
546
- if (!context.me) {
546
+ const start = args.length > 1 ? args[1] : context.me;
547
+ if (!(start instanceof Element)) {
547
548
  return null;
548
549
  }
549
- return context.me.closest(selector);
550
+ return start.closest(selector);
550
551
  },
551
552
  validate(args) {
552
- if (args.length !== 1) {
553
- return 'closest requires exactly 1 argument (selector)';
553
+ if (args.length !== 1 && args.length !== 2) {
554
+ return 'closest requires a selector and, optionally, the element to start from';
554
555
  }
555
556
  const arg = args[0];
556
557
  if (typeof arg === 'string')
@@ -2064,7 +2065,7 @@ const isEmptyExpression = {
2064
2065
  else if (value instanceof Node || value instanceof Element)
2065
2066
  result = false;
2066
2067
  else if (isObject(value))
2067
- result = Object.keys(value).length === 0;
2068
+ result = value.length === 0;
2068
2069
  else
2069
2070
  result = false;
2070
2071
  return result;
@@ -3911,13 +3912,6 @@ function createCommonRegistry() {
3911
3912
  function isInputElement(el) {
3912
3913
  return (el !== null && typeof el === 'object' && 'tagName' in el && el.tagName === 'INPUT');
3913
3914
  }
3914
- function isFormElement(el) {
3915
- if (el === null || typeof el !== 'object' || !('tagName' in el)) {
3916
- return false;
3917
- }
3918
- const tag = el.tagName;
3919
- return tag === 'INPUT' || tag === 'SELECT' || tag === 'TEXTAREA';
3920
- }
3921
3915
  function isHTMLElement$1(el) {
3922
3916
  return (el !== null &&
3923
3917
  typeof el === 'object' &&
@@ -3974,7 +3968,7 @@ const SPECIAL_DOM_PROPERTIES = {
3974
3968
  innertext: el => el.textContent?.trim(),
3975
3969
  innerHTML: el => el.innerHTML,
3976
3970
  outerhtml: el => el.outerHTML,
3977
- value: el => (isFormElement(el) ? el.value : undefined),
3971
+ value: el => ('value' in el ? el.value : undefined),
3978
3972
  checked: el => (isInputElement(el) ? el.checked : undefined),
3979
3973
  disabled: el => ('disabled' in el ? el.disabled : undefined),
3980
3974
  selected: el => (isOptionElement(el) ? el.selected : undefined),
@@ -1,8 +1,11 @@
1
1
  export type AttrNamespace = 'hx' | 'sse' | 'ws';
2
+ export interface EventNameOptions {
3
+ fromAttrName?: boolean;
4
+ }
2
5
  export interface I18nHooks {
3
6
  nameOf(elt: Element, ns: AttrNamespace, key: string): string;
4
7
  selectorFor(ns: AttrNamespace, key: string): string;
5
- eventNameOf(elt: Element, value: string): string;
8
+ eventNameOf(elt: Element, value: string, opts?: EventNameOptions): string;
6
9
  }
7
10
  export declare function installHooks(hooks: I18nHooks): void;
8
11
  export declare function getHooks(): I18nHooks;