export interface BaseImmutableNode { /** * @description * This method searches for all elements within the current node's subtree that match the specified selector. * For HTML nodes, the selector syntax follows the browser's standard querySelectorAll. * For CSS nodes, the selector syntax allows specific CSS-related queries: * * @{max-width:100px} - media, exact match. * * @*{max-width:100px} - media, should include text in { }. * * #test.class-2 - selector,exact match. * * *#test - selector, should include test. * * {display} - attribute, exact match. * * &{test comment text} - comment, exact match. * * &*{test comment} - comment, should include text in { }. * * selector examples: * @example * @{media all and (max-width: 100px)} h1.class#id {display} * @{media all and (max-width: 100px)} > h1.class#id > {display} * h1.class#id &{comment inside h1.class#id} * * @param selector - A string representing the CSS selector to query. * @returns The first matching node as `T`, or `undefined` if no match is found. * * @summary Searches for a single matching child element within the node's subtree, * delegating the query to appropriate HTML or CSS node query helpers based on the node type. */ querySelector(selector: string): T | undefined; /** * Retrieves all matching child elements within the node's subtree based on the provided selector. * * @description * This method searches for all elements within the current node's subtree that match the specified selector. * For HTML nodes, the selector syntax follows the browser's standard querySelectorAll. * For CSS nodes, the selector syntax allows specific CSS-related queries: * * for html nodes the selector syntax is similar to browser querySelector. * * for css nodes the syntax is: * * @{max-width:100px} - media, exact match. * * @*{max-width:100px} - media, should include text in { }. * * #test.class-2 - selector,exact match. * * *#test - selector, should include test. * * {display} - attribute, exact match. * * &{test comment text} - comment, exact match. * * &*{test comment} - comment, should include text in { }. * * selector examples: * @example * @{media all and (max-width: 100px)} h1.class#id {display} * @{media all and (max-width: 100px)} > h1.class#id > {display} * h1.class#id &{comment inside h1.class#id} * * @param selector - A string representing the CSS selector to query. * @returns An array of matching nodes as `T[],` or an empty array if no match is found. * * @summary Returns all matching elements within the current node's subtree, * delegating the query operation to either the HTML or CSS query helpers * based on the node type. */ querySelectorAll(selector: string): T[]; /** * Finds the closest ancestor of the current node that matches the provided selector. * * @description * This method searches for the nearest parent node of the current node that matches * the specified selector. The query is delegated to different helper objects * based on whether the current node belongs to the HTML or CSS node type. * * For HTML nodes, the selector syntax follows the browser's standard querySelectorAll. * For CSS nodes, the selector syntax allows specific CSS-related queries: * * for html nodes the selector syntax is similar to browser querySelector. * * for css nodes the syntax is: * * @{max-width:100px} - media, exact match. * * @*{max-width:100px} - media, should include text in { }. * * #test.class-2 - selector,exact match. * * *#test - selector, should include test. * * {display} - attribute, exact match. * * &{test comment text} - comment, exact match. * * &*{test comment} - comment, should include text in { }. * * selector examples: * @example * @{media all and (max-width: 100px)} h1.class#id {display} * @{media all and (max-width: 100px)} > h1.class#id > {display} * h1.class#id &{comment inside h1.class#id} * * @param selector - A string representing the selector to match the parent node. * @returns The closest matching parent node as `T`. * Returns `undefined` if no matching parent is found. * * @summary Searches for the closest parent element matching the selector, * utilizing appropriate query helpers based on whether the current node is HTML or CSS type. */ closest(selector: string): T | undefined; /** * @description * Retrieves the parent node of the current HTML or CSS node. * * @returns The parent node as an instance of `T`, or `undefined` if no parent exists. * * @throws {Error} If the node is not found during the operation or an internal error occurs. * * @summary Returns the parent node of the current node, using appropriate logic * based on whether the node is of HTML or CSS type. */ parent(): T | undefined; /** * Retrieves the child nodes of the current HTML or CSS node. * @returns An array of ImmutableNode instances representing the children. * @throws {Error} If the node is not found. */ children(): T[]; /** * Retrieves the child nodes of the current node. * * @description * This method fetches all child nodes of the current node, distinguishing * between HTML and CSS nodes to use the appropriate query methods. * * @returns An array of child nodes as `T[]`. * * @throws {Error} If the node is not found or an internal error occurs during retrieval. * * @summary Fetches all child nodes */ childNodes(): T[]; /** * Retrieves the sibling nodes of the current HTML or CSS node. * @returns An array of ImmutableNode instances representing the siblings. * @throws {Error} If the node is not found. */ siblings(): T[]; /** * Retrieves the type of the HTML node associated with the current object. * * for HTML node return type values are 'element', 'text', 'comment', 'document', 'doctype', 'documentFragment' * * for CSS node return type values are 'attr', 'comment', 'rule', 'media', 'document' * * @return {string} The type of the HTML node. * @throws {Error} If the node cannot be found. */ getType(): string | undefined; /** * Retrieves the next sibling of the current node. * * @description * This method finds and returns the next sibling of the current node in the document structure. * * @returns The next sibling node as `T`, or `undefined` if no next sibling exists. * * @throws {Error} If the node is not found or an internal error occurs during sibling lookup. * * @summary Fetches the next sibling node in the hierarchy, * distinguishing between HTML and CSS node types for querying. */ nextSibling(): T | undefined; /** * @description * Retrieves the next sibling of the current node that is an element. * * @returns The next element sibling as an instance, or `undefined` if no next element sibling exists. * * @throws {Error} If the node or its position is not found during the execution. * * @summary Locates and returns the next sibling that is an element node, taking into account the node type * (HTML or CSS). */ nextElementSibling(): T | undefined; /** * Retrieves the previous sibling of the current node that is an element. * * @description * This method locates and returns the closest previous sibling that is an element node. * * @returns The previous element sibling as an instance of `T`, or `undefined` if no such sibling exists. * * @throws {Error} If the node or its position is not found during the operation. * * @summary Finds and retrieves the previous sibling element node by traversing the node hierarchy, * using appropriate querying methods for HTML or CSS nodes. */ previousElementSibling(): T | undefined; /** * Retrieves the previous sibling of the current node. * * @description * This method finds and returns the previous sibling of the current node in the document structure. * * @returns The previous sibling node, or `undefined` if no previous sibling exists. * * @throws {Error} If the node is not found or an internal error occurs during sibling lookup. * * @summary Finds and retrieves the previous sibling node by querying the node hierarchy, * identifying whether the node belongs to the HTML or CSS domain. */ previousSibling(): T | undefined; /** * Retrieves the configuration object of the current node. * * @description * This method provides access to the config object associated with the current node. * The configuration can be set and modified by the user via the TemplateModifier * and utilized in future operations. * * @returns {Record} The configuration object of the current node. */ getNodeConfig(): Record; } /*********************************************************************************/ export interface BaseImmutableHtmlNode extends BaseImmutableNode { /** * Retrieves the closest module ID associated with the current node. * * @description * This method traverses up the node tree to find the closest ancestor (or itself) * that has a moduleId in its node configuration. * * @returns {number | undefined} The module ID of the closest module element, or undefined if not found. */ getClosestModuleId(): number | undefined; /** * Retrieves the closest module element associated with the current node. * * @description * This method traverses up the node tree to find the closest ancestor (or itself) * that has a moduleId in its node configuration and returns it as an ImmutableHtmlNode. * * @returns {ImmutableHtmlNode | undefined} The closest module element, or undefined if not found. */ getClosestModuleElement(): ImmutableHtmlNode | undefined; /** * Converts the current node to an instance of ImmutableHtmlTextNode. * * @description * This method casts the current object as an instance of the ImmutableHtmlTextNode class. * It is used to explicitly interpret the current node as a text node. * * @returns {ImmutableHtmlTextNode} The current node casted to ImmutableHtmlTextNode. * * * @summary Casts the current node to ImmutableHtmlTextNode type, enabling text node-specific operations. */ asText(): ImmutableHtmlTextNode; /** * Converts the current node to an instance of ImmutableHtmlElementNode. * * @description * This method casts the current object as an instance of the ImmutableHtmlElementNode class. * It is used to explicitly interpret the current node as an HTML element node. * * @returns {ImmutableHtmlElementNode} The current node casted to ImmutableHtmlElementNode. * * @summary Casts the current node to ImmutableHtmlElementNode type, enabling operations specific to HTML element nodes. */ asElement(): ImmutableHtmlElementNode; /** * Retrieves module elements by their module ID. * * @description * This method searches for all elements within the current node's subtree that have * the specified module ID in their node configuration. Modules are identified by * having a `moduleId` property in their node config. * * @param id - The module ID to search for. * @returns An array of module elements matching the specified ID, or an empty array if no modules are found. */ getModuleElementsById(id: number): ImmutableHtmlNode[]; /** * Retrieves all module elements within the document. * * @description * This method searches for all elements within the current node's subtree that have * a module ID in their node configuration. A module element is any element that has * a `moduleId` property set in its node config. * * @returns An array of all module elements, or an empty array if no modules are found. */ getModuleElements(): ImmutableHtmlNode[]; } export interface ImmutableHtmlTextNode extends BaseImmutableHtmlNode { /** * Retrieves the text content of the current HTML node. * * @returns {string} The text content of the node. * @throws {Error} If the specified node not found. */ getTextContent(): string; } /** DisplayCondition is a condition for displaying a node */ export interface DisplayCondition { /** ID of the condition */ id: number; /** name of the condition */ name: string; /** description of the condition */ description: string; /** script to run before the condition */ beforeScript: string; /** script to run after the condition */ afterScript: string; /** extra custom data, can be set by user */ extraData?: string; conditionsCount?: number; } export interface ImmutableHtmlElementNode extends ImmutableHtmlTextNode { /** * Retrieves the value of the specified attribute for the current HTML node. name is case-sensitive * @param name The name of the attribute to retrieve. * @returns The attribute value as a string or null if not found. * @throws {Error} If the node is not found. */ getAttribute(name: string): string | null; /** * Checks if the current HTML element has a specific CSS class applied. * @param className The name of the CSS class to check for. * @returns {boolean} True if the class is applied, otherwise false. * @throws {Error} If the node is not found. */ hasClass(className: string): boolean; /** * Retrieves the bounding client rectangle of the current HTML node. * * @returns {DOMRect} The bounding client rectangle of the element. * @throws {Error} If the node is not found. * @throws {Error} If the HTML element is not found. */ getBoundingClientRect(): DOMRect; /** * Retrieves the computed style value of the specified CSS property for the current HTML node. name is case-sensitive * @param name The name of the CSS property. * @returns The computed style value as a string or undefined if not found. * @throws {Error} If the node is not found. */ getComputedStyle(name: string): string | undefined; /** * Retrieves the list of CSS classes applied to the current HTML node. * @returns An array of class names as strings. * @throws {Error} If the node is not found. */ getClassList(): string[]; /** * Retrieves the tag name of the current HTML node. * @returns The tag name as a lowercase string. * @throws {Error} If the node is not found. */ getTagName(): string; /** * Retrieves the value attribute of the current HTML node. * @returns The value as a string. * @throws {Error} If the node is not found. */ getValue(): string; /** * Retrieves the inner HTML content of the current HTML node. * @returns The inner HTML as a string. * @throws {Error} If the node is not found. */ getInnerHTML(): string; /** * Retrieves the outer HTML content of the current HTML node. * @returns The outer HTML as a string. * @throws {Error} If the node is not found. */ getOuterHTML(): string; /** * Retrieves the inner text content of the current HTML node and its descendants. * This method concatenates the text content of the node and all its child nodes recursively. * * @returns {string} The inner text of the node and its descendants. * @throws {Error} If the node with the specified ID is not found. */ getInnerText(): string; /** * Retrieves the value of the specified style property for the current HTML node. name is case-sensitive. * @param name The name of the style property. * @returns The style value as a string or undefined if not found. * @throws {Error} If the node is not found or the property name is undefined. */ getStyle(name: string): string | undefined; getDisplayCondition(): DisplayCondition; } export type ImmutableHtmlNode = ImmutableHtmlElementNode | ImmutableHtmlTextNode; /*********************************************************************************/ export interface BaseImmutableCssNode extends BaseImmutableNode { /** * Checks if the current CSS node is commented. * * @description * This method determines if the current node has a commented property set to true. * It leverages the underlying API and node for the check. * * @returns {boolean} True if the node is commented, false otherwise. * * @throws {Error} If the API or node associated with the current object is not found. * * @summary Determines if the current node is commented, providing support for node inspection. */ isCommented(): boolean; /** * Converts the current node to an instance of ImmutableCssDocumentNode. * * @description * This method casts the current object as an instance of the ImmutableCssDocumentNode class. * It is used to explicitly interpret the current node as a CSS document node. * * @returns {ImmutableCssDocumentNode} The current node casted to ImmutableCssDocumentNode. * * @summary Casts the current node to ImmutableCssDocumentNode type, enabling CSS document-specific operations. */ asDocument(): ImmutableCssDocumentNode; /** * Converts the current node to an instance of ImmutableCssRuleNode. * * @description * This method casts the current object as an instance of the ImmutableCssRuleNode class. * It is used to explicitly interpret the current node as a CSS rule node. * * @returns {ImmutableCssRuleNode} The current node casted to ImmutableCssRuleNode. * * @summary Casts the current node to ImmutableCssRuleNode type, enabling CSS rule-specific operations. */ asRule(): ImmutableCssRuleNode; /** * Converts the current node to an instance of ImmutableCssAttributeNode. * * @description * This method casts the current object as an instance of the ImmutableCssAttributeNode class. * It is used to explicitly interpret the current node as a CSS attribute node. * * @returns {ImmutableCssAttributeNode} The current node casted to ImmutableCssAttributeNode. * * @summary Casts the current node to ImmutableCssAttributeNode type, enabling CSS attribute-specific operations. */ asAttribute(): ImmutableCssAttributeNode; /** * Converts the current node to an instance of ImmutableCssCommentNode. * * @description * This method casts the current object as an instance of the ImmutableCssCommentNode class. * It is used to explicitly interpret the current node as a CSS comment node. * * @returns {ImmutableCssCommentNode} The current node casted to ImmutableCssCommentNode. * * @summary Casts the current node to ImmutableCssCommentNode type, enabling CSS comment-specific operations. */ asComment(): ImmutableCssCommentNode; } export type ImmutableCssDocumentNode = BaseImmutableCssNode; export interface ImmutableCssCommentNode extends BaseImmutableCssNode { /** * Retrieves the text content of the current CSS comment node. * * @description * This method fetches the text content of the current CSS comment node * using the associated API and node details. * * @returns {string} - The text content of the CSS comment node. * * @throws {Error} - If the API or node associated with the current object is not found. * * @summary Fetches the text content of the CSS comment node for inspection or processing. */ getTextContent(): string; } export interface ImmutableCssAttributeNode extends BaseImmutableCssNode { /** * Retrieves the name of the CSS attribute for the current node. * * @description * This method fetches the name of the attribute associated with the current CSS node. * * @returns {string} - The name of the CSS attribute. * * @throws {Error} - If the API or node associated with the current object cannot be found. * * @summary Fetches the name of the CSS attribute for inspection or usage. */ getAttributeName(): string; /** * Retrieves the value of the CSS attribute for the current node. * * @description * This method fetches the value of the attribute associated with the current CSS node. * * @returns {string} - The value of the CSS attribute. * * @throws {Error} - If the API or node associated with the current object cannot be found. * * @summary Fetches the value of the CSS attribute for inspection or usage. */ getAttributeValue(): string; } export interface ImmutableCssRuleNode extends BaseImmutableCssNode { /** * Retrieves the selector string of the current CSS rule node. * * @description * This method fetches the selector assigned to the current CSS rule node * by utilizing the associated API and node details. The selector represents * the CSS rule's matching criteria, such as a class, ID, or element name. * * @returns {string} - The selector string of the CSS rule node. * * @throws {Error} - If the node associated with the current object cannot be found. * * @summary Fetches the selector of the CSS rule node for inspection or usage. */ getSelector(): string; } export type ImmutableCssNode = ImmutableCssCommentNode | ImmutableCssAttributeNode | ImmutableCssRuleNode | ImmutableCssDocumentNode;