@adaas/are-html 0.0.3 → 0.0.5

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 (63) hide show
  1. package/README.md +4 -4
  2. package/dist/browser/index.d.mts +12 -4
  3. package/dist/browser/index.mjs +47 -20
  4. package/dist/browser/index.mjs.map +1 -1
  5. package/dist/node/engine/AreHTML.compiler.js +10 -0
  6. package/dist/node/engine/AreHTML.compiler.js.map +1 -1
  7. package/dist/node/engine/AreHTML.compiler.mjs +10 -0
  8. package/dist/node/engine/AreHTML.compiler.mjs.map +1 -1
  9. package/dist/node/engine/AreHTML.constants.d.mts +10 -1
  10. package/dist/node/engine/AreHTML.constants.d.ts +10 -1
  11. package/dist/node/engine/AreHTML.constants.js +21 -0
  12. package/dist/node/engine/AreHTML.constants.js.map +1 -1
  13. package/dist/node/engine/AreHTML.constants.mjs +20 -1
  14. package/dist/node/engine/AreHTML.constants.mjs.map +1 -1
  15. package/dist/node/engine/AreHTML.engine.js +8 -0
  16. package/dist/node/engine/AreHTML.engine.js.map +1 -1
  17. package/dist/node/engine/AreHTML.engine.mjs +8 -0
  18. package/dist/node/engine/AreHTML.engine.mjs.map +1 -1
  19. package/dist/node/engine/AreHTML.interpreter.js +1 -0
  20. package/dist/node/engine/AreHTML.interpreter.js.map +1 -1
  21. package/dist/node/engine/AreHTML.interpreter.mjs +1 -0
  22. package/dist/node/engine/AreHTML.interpreter.mjs.map +1 -1
  23. package/dist/node/engine/AreHTML.lifecycle.d.mts +1 -2
  24. package/dist/node/engine/AreHTML.lifecycle.d.ts +1 -2
  25. package/dist/node/engine/AreHTML.lifecycle.js +2 -11
  26. package/dist/node/engine/AreHTML.lifecycle.js.map +1 -1
  27. package/dist/node/engine/AreHTML.lifecycle.mjs +2 -11
  28. package/dist/node/engine/AreHTML.lifecycle.mjs.map +1 -1
  29. package/dist/node/index.d.mts +2 -2
  30. package/dist/node/index.d.ts +2 -2
  31. package/dist/node/index.js +3 -3
  32. package/dist/node/index.mjs +1 -1
  33. package/dist/node/lib/AreRoot/AreRoot.component.js +2 -3
  34. package/dist/node/lib/AreRoot/AreRoot.component.js.map +1 -1
  35. package/dist/node/lib/AreRoot/AreRoot.component.mjs +2 -3
  36. package/dist/node/lib/AreRoot/AreRoot.component.mjs.map +1 -1
  37. package/dist/node/lib/{AreWatcher/AreWatcher.component.d.mts → AreRouteWatcher/AreRouteWatcher.component.d.mts} +2 -2
  38. package/dist/node/lib/{AreWatcher/AreWatcher.component.d.ts → AreRouteWatcher/AreRouteWatcher.component.d.ts} +2 -2
  39. package/dist/node/lib/{AreWatcher/AreWatcher.component.js → AreRouteWatcher/AreRouteWatcher.component.js} +6 -6
  40. package/dist/node/lib/AreRouteWatcher/AreRouteWatcher.component.js.map +1 -0
  41. package/dist/node/lib/{AreWatcher/AreWatcher.component.mjs → AreRouteWatcher/AreRouteWatcher.component.mjs} +7 -7
  42. package/dist/node/lib/AreRouteWatcher/AreRouteWatcher.component.mjs.map +1 -0
  43. package/dist/node/signals/AreRoute.signal.js +1 -1
  44. package/dist/node/signals/AreRoute.signal.js.map +1 -1
  45. package/dist/node/signals/AreRoute.signal.mjs +1 -1
  46. package/dist/node/signals/AreRoute.signal.mjs.map +1 -1
  47. package/examples/dashboard/dist/index.html +1 -1
  48. package/examples/dashboard/dist/{mpioi5ab-8c3oa9.js → mpm5e2oi-ghokyu.js} +2 -2
  49. package/examples/jumpstart/dist/mor90p6y-0plg7g.js +8 -8
  50. package/examples/jumpstart/dist/mor90p7p-1898bz.js +8 -8
  51. package/jest.config.ts +1 -1
  52. package/package.json +1 -1
  53. package/src/engine/AreHTML.compiler.ts +19 -1
  54. package/src/engine/AreHTML.constants.ts +16 -0
  55. package/src/engine/AreHTML.engine.ts +10 -0
  56. package/src/engine/AreHTML.interpreter.ts +3 -0
  57. package/src/engine/AreHTML.lifecycle.ts +13 -12
  58. package/src/index.ts +2 -2
  59. package/src/lib/AreRoot/AreRoot.component.ts +5 -6
  60. package/src/lib/{AreWatcher/AreWatcher.component.ts → AreRouteWatcher/AreRouteWatcher.component.ts} +2 -2
  61. package/src/signals/AreRoute.signal.ts +1 -1
  62. package/dist/node/lib/AreWatcher/AreWatcher.component.js.map +0 -1
  63. package/dist/node/lib/AreWatcher/AreWatcher.component.mjs.map +0 -1
package/README.md CHANGED
@@ -615,12 +615,12 @@ Route-driven rendering uses `AreSignalsContext` / `AreSignalsMeta` to select the
615
615
 
616
616
  ## Watcher
617
617
 
618
- `AreWatcher` observes browser navigation events (`pushState`, `replaceState`, `popstate`, `hashchange`) and notifies handlers on URL change:
618
+ `AreRouteWatcher` observes browser navigation events (`pushState`, `replaceState`, `popstate`, `hashchange`) and notifies handlers on URL change:
619
619
 
620
620
  ```typescript
621
- import { AreWatcher } from '@adaas/are-html';
621
+ import { AreRouteWatcher } from '@adaas/are-html';
622
622
 
623
- const watcher = new AreWatcher();
623
+ const watcher = new AreRouteWatcher();
624
624
  const unsubscribe = watcher.onChange((url: URL) => {
625
625
  console.log('Navigated to:', url.pathname);
626
626
  });
@@ -659,7 +659,7 @@ watcher.destroy();
659
659
  | `AreDirective` | Base class for custom directives |
660
660
  | `AreDirectiveContext` | Per-item scope context for directives |
661
661
  | `AreRoot` | `<are-root>` component |
662
- | `AreWatcher` | Browser navigation observer |
662
+ | `AreRouteWatcher` | Browser navigation observer |
663
663
  | `AreRoute` | Client-side routing signal |
664
664
  | `AddElementInstruction` | DOM element creation instruction |
665
665
  | `AddTextInstruction` | Text node instruction |
@@ -311,6 +311,15 @@ declare class AreRoute extends AreSignal<A_Route> {
311
311
  compare(other: A_Signal<A_Route>): boolean;
312
312
  }
313
313
 
314
+ /**
315
+ * Void HTML elements that cannot have children and must not have a closing tag.
316
+ * Per the HTML5 spec these are treated as self-closing even when written as
317
+ * `<input>` (without the trailing slash `/>`).
318
+ *
319
+ * Reference: https://html.spec.whatwg.org/multipage/syntax.html#void-elements
320
+ */
321
+ declare const VOID_ELEMENTS: Set<string>;
322
+ declare function isVoidElement(tagName: string): boolean;
314
323
  /**
315
324
  * Boolean HTML attributes whose presence (regardless of value) implies "true",
316
325
  * and whose absence implies "false". Setting these via `setAttribute(name, value)`
@@ -531,8 +540,7 @@ declare class AreHTMLInterpreter extends AreInterpreter {
531
540
  }
532
541
 
533
542
  declare class AreHTMLLifecycle extends AreLifecycle {
534
- initComponent(node: AreHTMLNode, scope: A_Scope, context: AreHTMLEngineContext, logger?: A_Logger, ...args: any[]): void;
535
- initRoot(node: AreHTMLNode, scope: A_Scope, context: AreHTMLEngineContext, signalsContext?: AreSignalsContext, logger?: A_Logger, ...args: any[]): void;
543
+ initComponent(node: AreHTMLNode, scope: A_Scope, context: AreHTMLEngineContext, signalsContext?: AreSignalsContext, logger?: A_Logger, ...args: any[]): void;
536
544
  initText(node: AreHTMLNode, scope: A_Scope, context: AreHTMLEngineContext, logger?: A_Logger, ...args: any[]): void;
537
545
  initInterpolation(node: AreHTMLNode, scope: A_Scope, context: AreHTMLEngineContext, logger?: A_Logger, ...args: any[]): void;
538
546
  updateDirectiveAttribute(directive: AreDirectiveAttribute, scope: A_Scope, feature: A_Feature, logger?: A_Logger, ...args: any[]): void;
@@ -586,7 +594,7 @@ declare class AreRoot extends Are {
586
594
  }>, logger: A_Logger, signalsContext?: AreSignalsContext): Promise<void>;
587
595
  }
588
596
 
589
- declare class AreWatcher extends A_Component {
597
+ declare class AreRouteWatcher extends A_Component {
590
598
  private readonly handlers;
591
599
  private current;
592
600
  constructor();
@@ -601,4 +609,4 @@ declare class AreWatcher extends A_Component {
601
609
  private notify;
602
610
  }
603
611
 
604
- export { AddAttributeInstruction, AddElementInstruction, AddInterpolationInstruction, AddListenerInstruction, AddStyleInstruction, AddTextInstruction, AreBindingAttribute, AreComment, AreComponentNode, AreDirective, AreDirectiveAttribute, AreDirectiveContext, AreDirectiveFeatures, AreDirectiveFor, AreDirectiveIf, AreDirectiveMeta, type AreDirectiveOrderDecoratorParameters, AreEventAttribute, AreHTMLAttribute, AreHTMLCompiler, type AreHTMLContextConstructor, AreHTMLEngine, AreHTMLEngineContext, AreHTMLInstructions, AreHTMLInterpreter, AreHTMLLifecycle, AreHTMLNode, AreHTMLTokenizer, AreHTMLTransformer, type AreHtmlAddAttributeInstructionPayload, type AreHtmlAddCommentInstructionPayload, type AreHtmlAddElementInstructionPayload, type AreHtmlAddInterpolationInstructionPayload, type AreHtmlAddListenerInstructionPayload, type AreHtmlAddStyleInstructionPayload, type AreHtmlAddTextInstructionPayload, AreInterpolation, AreRoot, AreRootNode, AreRoute, AreStaticAttribute, AreStyle, AreText, AreWatcher, BOOLEAN_ATTRIBUTES, IDL_FORM_PROPERTIES, LISTENER_OPTION_MODIFIERS, type ParsedEventName, isBooleanAttribute, isIDLFormProperty, normalizeClassValue, normalizeStyleValue, parseEventName, toDOMString };
612
+ export { AddAttributeInstruction, AddElementInstruction, AddInterpolationInstruction, AddListenerInstruction, AddStyleInstruction, AddTextInstruction, AreBindingAttribute, AreComment, AreComponentNode, AreDirective, AreDirectiveAttribute, AreDirectiveContext, AreDirectiveFeatures, AreDirectiveFor, AreDirectiveIf, AreDirectiveMeta, type AreDirectiveOrderDecoratorParameters, AreEventAttribute, AreHTMLAttribute, AreHTMLCompiler, type AreHTMLContextConstructor, AreHTMLEngine, AreHTMLEngineContext, AreHTMLInstructions, AreHTMLInterpreter, AreHTMLLifecycle, AreHTMLNode, AreHTMLTokenizer, AreHTMLTransformer, type AreHtmlAddAttributeInstructionPayload, type AreHtmlAddCommentInstructionPayload, type AreHtmlAddElementInstructionPayload, type AreHtmlAddInterpolationInstructionPayload, type AreHtmlAddListenerInstructionPayload, type AreHtmlAddStyleInstructionPayload, type AreHtmlAddTextInstructionPayload, AreInterpolation, AreRoot, AreRootNode, AreRoute, AreRouteWatcher, AreStaticAttribute, AreStyle, AreText, BOOLEAN_ATTRIBUTES, IDL_FORM_PROPERTIES, LISTENER_OPTION_MODIFIERS, type ParsedEventName, VOID_ELEMENTS, isBooleanAttribute, isIDLFormProperty, isVoidElement, normalizeClassValue, normalizeStyleValue, parseEventName, toDOMString };
@@ -816,11 +816,30 @@ var AreRoute = class extends AreSignal {
816
816
  AreRoute = __decorateClass([
817
817
  A_Frame.Define({
818
818
  namespace: "a-are-html",
819
- description: "ARE signal that carries an A_Route value. Dispatched by AreWatcher on client-side navigation events (pushState, replaceState, popstate). The signal bus delivers it to all subscribed root nodes, triggering route-based conditional rendering across the component tree."
819
+ description: "ARE signal that carries an A_Route value. Dispatched by AreRouteWatcher on client-side navigation events (pushState, replaceState, popstate). The signal bus delivers it to all subscribed root nodes, triggering route-based conditional rendering across the component tree."
820
820
  })
821
821
  ], AreRoute);
822
822
 
823
823
  // src/engine/AreHTML.constants.ts
824
+ var VOID_ELEMENTS = /* @__PURE__ */ new Set([
825
+ "area",
826
+ "base",
827
+ "br",
828
+ "col",
829
+ "embed",
830
+ "hr",
831
+ "img",
832
+ "input",
833
+ "link",
834
+ "meta",
835
+ "param",
836
+ "source",
837
+ "track",
838
+ "wbr"
839
+ ]);
840
+ function isVoidElement(tagName) {
841
+ return VOID_ELEMENTS.has(tagName.toLowerCase());
842
+ }
824
843
  var BOOLEAN_ATTRIBUTES = /* @__PURE__ */ new Set([
825
844
  "allowfullscreen",
826
845
  "async",
@@ -1102,6 +1121,16 @@ var AreHTMLCompiler = class extends AreCompiler {
1102
1121
  title: "Scene Host Not Found",
1103
1122
  description: `No host found for the scene with id: ${scene.id}. Please ensure that the scene is properly initialized and has a host before compiling binding attributes.`
1104
1123
  });
1124
+ const content = attribute.content;
1125
+ if (content.includes("{{")) {
1126
+ const transformed = '"' + content.replace(/\{\{([^}]+)\}\}/g, '"+($1)+"') + '"';
1127
+ scene.plan(new AddAttributeInstruction(scene.host, {
1128
+ name: attribute.name,
1129
+ content: transformed,
1130
+ evaluate: true
1131
+ }));
1132
+ return;
1133
+ }
1105
1134
  scene.plan(new AddAttributeInstruction(scene.host, {
1106
1135
  name: attribute.name,
1107
1136
  content: attribute.content
@@ -1409,6 +1438,7 @@ var AreHTMLInterpreter = class extends AreInterpreter {
1409
1438
  event.set("args", effectiveArgs);
1410
1439
  event.set("element", element);
1411
1440
  event.set("instruction", mutation);
1441
+ if (liveEvent) event.set("native", liveEvent);
1412
1442
  mutation.owner.emit(event);
1413
1443
  };
1414
1444
  handlerScope[`$${handler}`] = handlerFn;
@@ -1725,10 +1755,7 @@ AreHTMLTokenizer = __decorateClass([
1725
1755
  })
1726
1756
  ], AreHTMLTokenizer);
1727
1757
  var AreHTMLLifecycle = class extends AreLifecycle {
1728
- initComponent(node, scope, context, logger, ...args) {
1729
- super.init(node, scope, context, logger, ...args);
1730
- }
1731
- initRoot(node, scope, context, signalsContext, logger, ...args) {
1758
+ initComponent(node, scope, context, signalsContext, logger, ...args) {
1732
1759
  signalsContext?.subscribe(node);
1733
1760
  super.init(node, scope, context, logger, ...args);
1734
1761
  }
@@ -1750,19 +1777,13 @@ var AreHTMLLifecycle = class extends AreLifecycle {
1750
1777
  };
1751
1778
  __decorateClass([
1752
1779
  AreLifecycle.Init(AreComponentNode),
1753
- __decorateParam(0, A_Inject(A_Caller)),
1754
- __decorateParam(1, A_Inject(A_Scope)),
1755
- __decorateParam(2, A_Inject(AreHTMLEngineContext)),
1756
- __decorateParam(3, A_Inject(A_Logger))
1757
- ], AreHTMLLifecycle.prototype, "initComponent", 1);
1758
- __decorateClass([
1759
1780
  AreLifecycle.Init(AreRootNode),
1760
1781
  __decorateParam(0, A_Inject(A_Caller)),
1761
1782
  __decorateParam(1, A_Inject(A_Scope)),
1762
1783
  __decorateParam(2, A_Inject(AreHTMLEngineContext)),
1763
1784
  __decorateParam(3, A_Inject(AreSignalsContext)),
1764
1785
  __decorateParam(4, A_Inject(A_Logger))
1765
- ], AreHTMLLifecycle.prototype, "initRoot", 1);
1786
+ ], AreHTMLLifecycle.prototype, "initComponent", 1);
1766
1787
  __decorateClass([
1767
1788
  AreLifecycle.Init(AreText),
1768
1789
  __decorateParam(0, A_Inject(A_Caller)),
@@ -1920,6 +1941,13 @@ var AreHTMLEngine = class extends AreEngine {
1920
1941
  match2.payload = { entity: tagName, selfClose: true, id };
1921
1942
  return match2;
1922
1943
  }
1944
+ if (isVoidElement(tagName)) {
1945
+ const raw = source.slice(tagStart, openingTagEnd + 1);
1946
+ const content2 = source.slice(tagStart + tagNameMatch[0].length, openingTagEnd);
1947
+ const match2 = build(raw, content2, tagStart, ">");
1948
+ match2.payload = { entity: tagName, selfClose: true, id };
1949
+ return match2;
1950
+ }
1923
1951
  const closingTag = `</${tagName}>`;
1924
1952
  let level = 0;
1925
1953
  let searchIndex = openingTagEnd + 1;
@@ -2014,8 +2042,8 @@ var AreRoot = class extends Are {
2014
2042
  }
2015
2043
  }
2016
2044
  if (!componentName) {
2017
- const defaultAttr = root.attributes.find((attr) => attr.name === "default");
2018
- componentName = defaultAttr?.content;
2045
+ const defaultMatch = root.markup?.match(/\bdefault=["']([^"']*)["']/);
2046
+ componentName = defaultMatch?.[1];
2019
2047
  }
2020
2048
  if (!componentName) {
2021
2049
  logger.warning('AreRoot: No component found for initial render. Please ensure a route condition or "default" attribute is set.');
@@ -2024,7 +2052,6 @@ var AreRoot = class extends Are {
2024
2052
  root.setContent(`<${componentName}></${componentName}>`);
2025
2053
  }
2026
2054
  async onSignal(root, vector, store, logger, signalsContext) {
2027
- console.log("Received signal vector in AreRoot:", root, vector);
2028
2055
  const rootId = root.id;
2029
2056
  if (signalsContext && !signalsContext.hasRoot(rootId)) {
2030
2057
  return;
@@ -2080,7 +2107,7 @@ AreRoot = __decorateClass([
2080
2107
  description: "The AreRoot component serves as the foundational entry point for the A-Concept Rendering Engine (ARE). It is responsible for initializing the rendering process, managing the root node of the component tree, and handling signal-based rendering logic. The AreRoot component processes incoming signals to determine which child components to render, allowing for dynamic and responsive UI updates based on application state and user interactions."
2081
2108
  })
2082
2109
  ], AreRoot);
2083
- var AreWatcher = class extends A_Component {
2110
+ var AreRouteWatcher = class extends A_Component {
2084
2111
  constructor() {
2085
2112
  super();
2086
2113
  this.handlers = /* @__PURE__ */ new Set();
@@ -2136,13 +2163,13 @@ var AreWatcher = class extends A_Component {
2136
2163
  }
2137
2164
  }
2138
2165
  };
2139
- AreWatcher = __decorateClass([
2166
+ AreRouteWatcher = __decorateClass([
2140
2167
  A_Frame.Define({
2141
2168
  namespace: "a-are-html",
2142
- description: "AreWatcher is a component that observes browser navigation events (history pushState, replaceState, and popstate) and notifies registered handlers when the URL changes, enabling client-side routing and reactive route-based rendering within the ARE framework."
2169
+ description: "AreRouteWatcher is a component that observes browser navigation events (history pushState, replaceState, and popstate) and notifies registered handlers when the URL changes, enabling client-side routing and reactive route-based rendering within the ARE framework."
2143
2170
  })
2144
- ], AreWatcher);
2171
+ ], AreRouteWatcher);
2145
2172
 
2146
- export { AddAttributeInstruction, AddElementInstruction, AddInterpolationInstruction, AddListenerInstruction, AddStyleInstruction, AddTextInstruction, AreBindingAttribute, AreComment, AreComponentNode, AreDirective, AreDirectiveAttribute, AreDirectiveContext, AreDirectiveFeatures, AreDirectiveFor, AreDirectiveIf, AreDirectiveMeta, AreEventAttribute, AreHTMLAttribute, AreHTMLCompiler, AreHTMLEngine, AreHTMLEngineContext, AreHTMLInstructions, AreHTMLInterpreter, AreHTMLLifecycle, AreHTMLNode, AreHTMLTokenizer, AreHTMLTransformer, AreInterpolation, AreRoot, AreRootNode, AreRoute, AreStaticAttribute, AreStyle, AreText, AreWatcher, BOOLEAN_ATTRIBUTES, IDL_FORM_PROPERTIES, LISTENER_OPTION_MODIFIERS, isBooleanAttribute, isIDLFormProperty, normalizeClassValue, normalizeStyleValue, parseEventName, toDOMString };
2173
+ export { AddAttributeInstruction, AddElementInstruction, AddInterpolationInstruction, AddListenerInstruction, AddStyleInstruction, AddTextInstruction, AreBindingAttribute, AreComment, AreComponentNode, AreDirective, AreDirectiveAttribute, AreDirectiveContext, AreDirectiveFeatures, AreDirectiveFor, AreDirectiveIf, AreDirectiveMeta, AreEventAttribute, AreHTMLAttribute, AreHTMLCompiler, AreHTMLEngine, AreHTMLEngineContext, AreHTMLInstructions, AreHTMLInterpreter, AreHTMLLifecycle, AreHTMLNode, AreHTMLTokenizer, AreHTMLTransformer, AreInterpolation, AreRoot, AreRootNode, AreRoute, AreRouteWatcher, AreStaticAttribute, AreStyle, AreText, BOOLEAN_ATTRIBUTES, IDL_FORM_PROPERTIES, LISTENER_OPTION_MODIFIERS, VOID_ELEMENTS, isBooleanAttribute, isIDLFormProperty, isVoidElement, normalizeClassValue, normalizeStyleValue, parseEventName, toDOMString };
2147
2174
  //# sourceMappingURL=index.mjs.map
2148
2175
  //# sourceMappingURL=index.mjs.map