import { A_Caller, A_Feature, A_Inject } from "@adaas/a-concept"; import { A_Logger } from "@adaas/a-utils/a-logger"; import { AreNodeFeatures, AreNode, AreTokenizer, AreAttribute_Init, AreContext } from "@adaas/are"; import { AreComponentNode } from "@adaas/are-html/nodes/AreComponent"; import { AreRootNode } from "@adaas/are-html/nodes/AreRoot"; import { AreDirectiveAttribute } from "@adaas/are-html/attributes/AreDirective.attribute"; import { AreEventAttribute } from "@adaas/are-html/attributes/AreEvent.attribute"; import { AreBindingAttribute } from "@adaas/are-html/attributes/AreBinding.attribute"; import { AreStaticAttribute } from "@adaas/are-html/attributes/AreStatic.attribute"; import { AreHTMLAttribute } from "../lib/AreHTMLAttribute/AreHTML.attribute"; import { AreHTMLNode } from "../lib/AreHTMLNode/AreHTMLNode"; import { isStaticMarkup } from "./AreHTML.constants"; import { A_Frame } from "@adaas/a-frame/core"; @A_Frame.Define({ namespace: 'a-are-html', description: 'HTML-specific tokenizer extending AreTokenizer. Parses raw HTML template strings into AreHTMLNode trees by scanning element tags and resolving directive ($), event (@), binding (:), and static attributes to their typed attribute classes, constructing AreComponentNode and AreRootNode instances where required.' }) export class AreHTMLTokenizer extends AreTokenizer { ATTR_PATTERN = /([$:@]?[\w.-]+(?::[\w.-]+)?)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>/"'=]+)))?/g @A_Feature.Extend({ name: AreNodeFeatures.onTokenize, scope: [AreComponentNode, AreRootNode] }) tokenize( @A_Inject(A_Caller) node: AreNode, @A_Inject(AreContext) context: AreContext, @A_Inject(A_Logger) logger?: A_Logger ): void { /** * Static-island fast path. * * When a node's entire inner subtree is fully static — no `{{ }}` * interpolations, no dynamic (`$`/`:`/`@`) attributes and only standard * HTML tags — we skip exploding it into one child AreNode per element / * text run and instead capture the inner markup verbatim. The interpreter * later materialises it in a single pass (browser-parsed innerHTML / * cached `