coralite 0.37.0 → 0.37.2

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../lib/utils/server/html.js", "../../lib/collection.js", "../../lib/utils/errors.js", "../../lib/utils/server/parse.js", "../../lib/utils/server/dom.js", "../../lib/utils/tags.js", "../../lib/script-manager.js", "../../lib/utils/core.js", "../../lib/utils/server/server.js", "../../lib/utils/types.js", "../../lib/plugin.js", "../../plugins/metadata.js", "../../plugins/static-assets.js", "../../plugins/testing.js", "../../lib/coralite.js", "../../lib/utils/server/errors.js", "../../lib/parser.js", "../../lib/compiler.js", "../../lib/hooks.js", "../../lib/component-setup.js", "../../lib/plugin-setup.js", "../../lib/collection-handlers.js", "../../lib/renderer.js", "../../lib/utils/server/render.js", "../../lib/utils/client/runtime.js", "../../lib/utils/server/style.js", "../../lib/utils/server/manifest.js", "../../lib/config.js", "../../lib/index.js"],
4
- "sourcesContent": ["import { dirname, extname, join } from 'node:path'\nimport { readdir, readFile } from 'node:fs/promises'\nimport { readFileSync } from 'node:fs'\nimport { availableParallelism } from 'node:os'\nimport pLimit from 'p-limit'\nimport CoraliteCollection from '../../collection.js'\nimport { CoraliteError } from '../errors.js'\n\n/**\n * @import {\n * CoraliteCollectionEventSet,\n * CoraliteCollectionEventUpdate,\n * CoraliteCollectionEventDelete } from '../../../types/index.js'\n * @import { LimitFunction } from 'p-limit'\n */\n\n/**\n * Get HTML\n * @param {Object} options - Options for searching HTML files\n * @param {string} options.path - Path to the directory containing HTML files\n * @param {'page' | 'component'} options.type - Document types\n * @param {boolean} [options.recursive=false] - Whether to search recursively in subdirectories\n * @param {string[]} [options.exclude=[]] - Files or directories to exclude from search\n * @param {CoraliteCollectionEventSet} [options.onFileSet] - The callback triggered when a file is set in the collection.\n * @param {CoraliteCollectionEventUpdate} [options.onFileUpdate] - The callback triggered when a file is updated in the collection.\n * @param {CoraliteCollectionEventDelete} [options.onFileDelete] - The callback triggered when a file is deleted from the collection.\n * @param {CoraliteCollection} [options.collection] - Optional collection instance to populate\n * @param {LimitFunction} [options.limit] - Optional concurrency limiter\n * @param {boolean} [options.discoverOnly=false] - Whether to skip reading file content and only discover paths\n * @returns {Promise<CoraliteCollection>} Array of HTML file data including parent path, name, and content\n *\n * @example\n * // example usage:\n * const htmlFiles = await getHtmlFiles({\n * path: 'src',\n * recursive: true,\n * exclude: ['index.html', 'subdir/file2.html']\n * })\n */\nexport async function getHtmlFiles ({\n path,\n type,\n recursive = false,\n exclude = [],\n discoverOnly = false,\n onFileSet,\n onFileUpdate,\n onFileDelete,\n collection,\n limit\n}) {\n const resultCollection = collection || new CoraliteCollection({\n rootDir: path,\n onSet: onFileSet,\n onUpdate: onFileUpdate,\n onDelete: onFileDelete\n })\n\n if (!limit) {\n limit = pLimit(availableParallelism())\n }\n\n const entries = await readdir(path, { withFileTypes: true })\n const tasks = []\n\n for (let i = 0; i < entries.length; i++) {\n const entry = entries[i]\n\n // Skip hidden files/directories starting with dot\n if (entry.name.startsWith('.')) {\n continue\n }\n\n const pathname = join(entry.parentPath, entry.name)\n\n // Calculate relative path from root for exclusion checking\n const relativePath = pathname.replace(path + '/', '')\n\n // Check if entry should be excluded by: name, relative path, or full path\n const shouldExclude = exclude.includes(entry.name) ||\n exclude.includes(relativePath) ||\n exclude.includes(pathname) ||\n exclude.some(excludePath => {\n // Handle directory-based exclusions\n const excludeDir = excludePath.endsWith('/') ? excludePath.slice(0, -1) : excludePath\n return relativePath.startsWith(excludeDir + '/')\n })\n\n if (shouldExclude) {\n continue\n }\n\n if (entry.isDirectory() && recursive) {\n tasks.push(getHtmlFiles({\n path: pathname,\n type,\n recursive,\n exclude,\n discoverOnly,\n onFileSet,\n onFileUpdate,\n onFileDelete,\n collection: resultCollection,\n limit\n }))\n } else if (entry.isFile() && extname(entry.name).toLowerCase() === '.html') {\n tasks.push(limit(async () => {\n const content = discoverOnly ? undefined : await readFile(pathname, { encoding: 'utf8' })\n\n await resultCollection.setItem({\n type,\n content,\n virtual: false,\n path: {\n pathname: pathname,\n filename: entry.name,\n dirname: dirname(pathname)\n }\n })\n }))\n }\n }\n\n await Promise.all(tasks)\n\n return resultCollection\n}\n\n/**\n * Generator that yields HTML files found in a directory.\n * Useful for lazy discovery and memory-efficient processing of many files.\n *\n * @param {Object} options - Options for searching HTML files\n * @param {string} options.path - Path to the directory containing HTML files\n * @param {'page' | 'component'} options.type - Document types\n * @param {boolean} [options.recursive=false] - Whether to search recursively\n * @param {string[]} [options.exclude=[]] - Files or directories to exclude\n * @param {boolean} [options.discoverOnly=false] - Whether to skip reading file content\n * @yields {Promise<{ type: 'page' | 'component', content: string | undefined, path: { pathname: string, filename: string, dirname: string } }>}\n */\nexport async function* discoverHtmlFiles ({\n path,\n type,\n recursive = false,\n exclude = [],\n discoverOnly = false\n}) {\n const entries = await readdir(path, { withFileTypes: true })\n\n for (let i = 0; i < entries.length; i++) {\n const entry = entries[i]\n\n if (entry.name.startsWith('.')) {\n continue\n }\n\n const pathname = join(entry.parentPath, entry.name)\n const relativePath = pathname.replace(path + '/', '')\n\n const shouldExclude = exclude.includes(entry.name) ||\n exclude.includes(relativePath) ||\n exclude.includes(pathname) ||\n exclude.some(excludePath => {\n const excludeDir = excludePath.endsWith('/') ? excludePath.slice(0, -1) : excludePath\n return relativePath.startsWith(excludeDir + '/')\n })\n\n if (shouldExclude) {\n continue\n }\n\n if (entry.isDirectory() && recursive) {\n yield* discoverHtmlFiles({\n path: pathname,\n type,\n recursive,\n exclude,\n discoverOnly\n })\n } else if (entry.isFile() && extname(entry.name).toLowerCase() === '.html') {\n const content = discoverOnly ? undefined : await readFile(pathname, { encoding: 'utf8' })\n\n yield {\n type,\n content,\n virtual: false,\n path: {\n pathname: pathname,\n filename: entry.name,\n dirname: dirname(pathname)\n }\n }\n }\n }\n}\n\n/**\n * Reads an HTML file and returns its content as a string.\n * @param {string} pathname - The path to the HTML file.\n * @throws {Error} If the file cannot be read.\n */\nexport function getHtmlFileSync (pathname) {\n try {\n const extension = extname(pathname).toLowerCase()\n\n if (extension === '.html') {\n return readFileSync(pathname, 'utf8')\n }\n\n throw new CoraliteError('Unexpected filename extension \"' + extension +'\"', {\n filePath: pathname\n })\n } catch (err) {\n throw err\n }\n}\n\n/**\n * Reads an HTML file and returns its content as a string.\n * @param {string} pathname - The path to the HTML file.\n * @throws {Error} If the file cannot be read.\n */\nexport async function getHtmlFile (pathname) {\n try {\n const extension = extname(pathname).toLowerCase()\n\n if (extension === '.html') {\n return await readFile(pathname, 'utf8')\n }\n\n throw new CoraliteError('Unexpected filename extension \"' + extension +'\"', {\n filePath: pathname\n })\n } catch (err) {\n throw err\n }\n}\n", "import path from 'node:path'\nimport { getHtmlFile } from './utils/server/html.js'\nimport { CoraliteError } from './utils/errors.js'\nimport { access } from 'node:fs/promises'\nimport { existsSync } from 'node:fs'\n\n/**\n * @import {\n * CoraliteCollectionEventDelete,\n * CoraliteCollectionEventSet,\n * CoraliteCollectionEventUpdate,\n * CoraliteCollectionItem,\n * HTMLData } from '../types/index.js'\n */\n\n/**\n * Represents a collection of documents with methods to organize and retrieve them.\n * Maintains three views: flat list, path-based grouping, and ID lookup.\n * @class\n * @param {Object} [options={}] - Options for configuring the collection\n * @param {string} [options.rootDir=''] - The root directory path for the collection\n * @param {CoraliteCollectionEventSet} [options.onSet] - Event handler for when documents are set\n * @param {CoraliteCollectionEventUpdate} [options.onUpdate] - Event handler for when documents are updated\n * @param {CoraliteCollectionEventDelete} [options.onDelete] - Event handler for when documents are deleted\n */\nfunction CoraliteCollection (options = { rootDir: '' }) {\n /**\n * Root directory where collection items are located\n */\n this.rootDir = path.join(options.rootDir)\n\n if (!existsSync(this.rootDir)) {\n throw new CoraliteError('Root directory was not found: ' + this.rootDir, {\n filePath: this.rootDir\n })\n }\n\n /**\n * An array of HTMLData objects representing the list of documents.\n * @type {CoraliteCollectionItem[]}\n */\n this.list = []\n\n /**\n * An object mapping paths to arrays of HTMLData objects.\n * Used for grouping documents by their file path.\n * @type {Object.<string, CoraliteCollectionItem[]>}\n */\n this.listByPath = Object.create(null)\n\n /**\n * An object mapping unique identifiers to HTMLData objects.\n * Used for quick lookup of documents by their identifier.\n * @type {Object.<string, CoraliteCollectionItem>}\n */\n this.collection = Object.create(null)\n\n /**\n * Callback triggered when setting a new item\n * @type {CoraliteCollectionEventSet | undefined}\n */\n this._onSet = options.onSet\n\n /**\n * Callback triggered when updating an existing item\n * @type {CoraliteCollectionEventUpdate | undefined}\n */\n this._onUpdate = options.onUpdate\n\n /**\n * Callback triggered when deleting an item\n * @type {CoraliteCollectionEventDelete | undefined}\n */\n this._onDelete = options.onDelete\n}\n\n/**\n * Adds or updates an HTMLData object in the collection and associated lists.\n * If the item already exists, it will be updated in all views.\n * @param {HTMLData|string} value - The HTMLData object to be added or updated.\n * @returns {Promise<CoraliteCollectionItem>} The modified document\n */\nCoraliteCollection.prototype.setItem = async function (value) {\n if (typeof value === 'string') {\n value = await this._loadByPath(value)\n }\n\n if (!value || !value.path) {\n throw new CoraliteError('Valid HTMLData object must be provided')\n }\n\n const pathname = value.path.pathname\n const dirname = value.path.dirname\n const originalValue = this.collection[pathname]\n\n /** @type {CoraliteCollectionItem} */\n const documentValue = value\n\n if (!originalValue) {\n // handle pre-set hook if defined\n if (typeof this._onSet === 'function') {\n const result = await this._onSet(value)\n\n // abort adding item\n if (!result) {\n return\n }\n\n documentValue.result = result.value\n\n if (result.state) {\n documentValue.state = result.state\n }\n\n if (result.type === 'page' || result.type === 'component') {\n documentValue.type = result.type\n }\n\n // update collection using ID from hook result if available\n if (typeof result.id === 'string' && result.id) {\n this.collection[result.id] = documentValue\n }\n\n if (documentValue.result && typeof documentValue.result === 'object') {\n documentValue.result.path = documentValue.path\n }\n }\n\n // always update the collection with current pathname\n this.collection[pathname] = documentValue\n\n // initialize directory list if it doesn't exist\n if (!this.listByPath[dirname]) {\n this.listByPath[dirname] = []\n }\n\n // add to both directory-specific and general lists\n // check if already added to avoid duplicates\n if (!this.listByPath[dirname].includes(documentValue)) {\n this.listByPath[dirname].push(documentValue)\n }\n if (!this.list.includes(documentValue)) {\n this.list.push(documentValue)\n }\n } else {\n return await this.updateItem(value)\n }\n\n return documentValue\n}\n\n/**\n * Removes an HTMLData object from the collection and associated lists.\n * Accepts either an HTMLData object or a pathname string.\n * @param {HTMLData | string} value - The HTMLData object or a pathname to be removed.\n * @throws {Error} If invalid input is provided\n */\nCoraliteCollection.prototype.deleteItem = async function (value) {\n if (!value) {\n throw new CoraliteError('Valid pathname must be provided')\n }\n\n let pathname\n let dirname\n let valuesByPath\n let originalValue\n\n if (typeof value !== 'string' && value.path) {\n // if the input is an HTMLData object, extract its pathname and directory name\n pathname = value.path.pathname\n dirname = value.path.dirname\n valuesByPath = this.listByPath[dirname]\n originalValue = value\n } else if (typeof value === 'string') {\n // if the input is a string, use it as the pathname and determine the directory name\n pathname = value\n dirname = path.dirname(pathname)\n valuesByPath = this.listByPath[dirname]\n originalValue = this.collection[pathname]\n } else {\n throw new CoraliteError('Valid pathname must be provided')\n }\n\n if (!originalValue) {\n // item not found, nothing to delete\n return\n }\n\n if (!valuesByPath) {\n // directory list doesn't exist, but we still need to clean up collection\n // This can happen if the item was stored under a different ID\n for (const key in this.collection) {\n if (this.collection[key] === originalValue) {\n delete this.collection[key]\n }\n }\n return\n }\n\n if (typeof this._onDelete === 'function') {\n await this._onDelete(originalValue)\n }\n\n // remove the document from the collection\n // also check if it's stored under a different ID (from hook result)\n for (const key in this.collection) {\n if (this.collection[key] === originalValue) {\n delete this.collection[key]\n }\n }\n\n // find and remove the document from the list and by-path grouping\n const listIndex = this.list.indexOf(originalValue)\n const pathIndex = valuesByPath.indexOf(originalValue)\n\n if (listIndex !== -1) {\n this.list.splice(listIndex, 1)\n }\n if (pathIndex !== -1) {\n valuesByPath.splice(pathIndex, 1)\n }\n\n // clean up empty directory arrays\n if (valuesByPath.length === 0) {\n delete this.listByPath[dirname]\n }\n}\n\n/**\n * Updates an existing HTMLData object in the collection.\n * If the document does not exist, it will be added using the set method.\n * @param {CoraliteCollectionItem|string} value - The HTMLData object to be updated or added.\n * @throws {Error} If invalid input is provided\n */\nCoraliteCollection.prototype.updateItem = async function (value) {\n if (typeof value === 'string') {\n value = await this._loadByPath(value)\n }\n\n if (!value || !value.path) {\n throw new CoraliteError('Valid HTMLData object must be provided')\n }\n\n const pathname = value.path.pathname\n const originalValue = this.collection[pathname]\n\n if (!originalValue) {\n // if the document does not exist, add it using the set method\n return await this.setItem(value)\n }\n\n if (typeof this._onUpdate === 'function') {\n const result = await this._onUpdate(value, originalValue)\n\n // abort update\n if (!result) {\n return originalValue\n }\n\n // handle callback result\n if (result && typeof result === 'object') {\n // if result has a value property, use it\n if (result.value !== undefined) {\n originalValue.result = result.value\n } else {\n originalValue.result = result\n }\n\n // update type if provided\n if (result.type === 'page' || result.type === 'component') {\n originalValue.type = result.type\n }\n } else {\n originalValue.result = result\n }\n }\n\n // update core state\n if (value.content !== undefined) {\n originalValue.content = value.content\n }\n\n // update path information if it changed\n if (value.path && value.path !== originalValue.path) {\n originalValue.path = value.path\n }\n\n // update type if explicitly set\n if (value.type) {\n originalValue.type = value.type\n }\n\n // update any additional state\n if (value.state !== undefined) {\n originalValue.state = value.state\n }\n\n // update ISR related fields\n if (value.cacheKey !== undefined) {\n originalValue.cacheKey = value.cacheKey\n }\n if (value.volatile !== undefined) {\n originalValue.volatile = value.volatile\n }\n if (value.virtual !== undefined) {\n originalValue.virtual = value.virtual\n }\n\n if (originalValue.result && typeof originalValue.result === 'object') {\n originalValue.result.path = originalValue.path\n }\n\n return originalValue\n}\n\n/**\n * Retrieves an item by its unique identifier\n * @param {string} id - Unique identifier of the item\n * @returns {CoraliteCollectionItem | undefined} The found item or undefined\n */\nCoraliteCollection.prototype.getItem = function (id) {\n if (!this.collection[id] && id.endsWith('html')) {\n id = path.join(this.rootDir, id)\n }\n\n return this.collection[id]\n}\n\n/**\n * Retrieves a list of items grouped by directory path\n * @param {string} dirname - Directory name to look up\n * @returns {CoraliteCollectionItem[] | undefined} A copy of the item list or undefined\n */\nCoraliteCollection.prototype.getListByPath = function (dirname) {\n const list = this.listByPath[dirname]\n\n if (list) {\n return list.slice()\n }\n}\n\n/**\n * Loads a collection item by its file path.\n *\n * @param {string} filepath - The path to the collection item file\n * @returns {Promise<HTMLData>} A promise that resolves to the loaded item object\n * @throws {Error} If the file cannot be found at either the provided path or within the root directory\n */\nCoraliteCollection.prototype._loadByPath = async function (filepath) {\n try {\n await access(filepath)\n } catch {\n try {\n filepath = path.join(this.rootDir, filepath)\n\n await access(filepath)\n } catch {\n throw new CoraliteError('Could not find collection item: ' + filepath, {\n filePath: filepath\n })\n }\n }\n\n const content = await getHtmlFile(filepath)\n\n return {\n type: 'page',\n content,\n path: {\n pathname: filepath,\n dirname: path.dirname(filepath),\n filename: path.basename(filepath)\n }\n }\n}\n\nexport default CoraliteCollection\n", "\n/**\n * @import { CoraliteErrorData } from '../../types/index.js'\n */\n\n/**\n * Base error class for all Coralite-related errors.\n */\nexport class CoraliteError extends Error {\n /**\n * @param {string} message - The error message.\n * @param {Object} [options] - Additional options for the error.\n * @param {string} [options.componentId] - The ID of the component where the error occurred.\n * @param {string} [options.filePath] - The path to the file where the error occurred.\n * @param {string} [options.instanceId] - The unique ID of the component instance.\n * @param {string} [options.pagePath] - The path to the page being rendered.\n * @param {number} [options.line] - The line number where the error occurred.\n * @param {number} [options.column] - The column number where the error occurred.\n * @param {string} [options.stackFile] - The file name from the stack trace.\n * @param {Error} [options.cause] - The original error that caused this error.\n */\n constructor (message, options = {}) {\n super(message, options)\n this.name = 'CoraliteError'\n this.isCoraliteError = true\n this.componentId = options.componentId\n this.filePath = options.filePath\n this.instanceId = options.instanceId\n this.pagePath = options.pagePath\n this.line = options.line\n this.column = options.column\n this.stackFile = options.stackFile\n\n // Polyfill cause if necessary (node version differences)\n if (options.cause && !this.cause) {\n this.cause = options.cause\n }\n }\n}\n\n/**\n * Default error handler.\n * @param {CoraliteErrorData} data - The data object containing error details.\n */\nexport function defaultOnError ({ level, message, error }) {\n if (level === 'ERR') {\n if (error) {\n throw error\n }\n throw new CoraliteError(message)\n } else if (level === 'WARN') {\n console.warn(message)\n } else {\n console.log(message)\n }\n}\n\n/**\n * Handles errors using an optional callback or the default handler.\n * @param {Object} options - The options for handling the error.\n * @param {Function} [options.onErrorCallback] - The optional custom error callback function.\n * @param {CoraliteErrorData} options.data - The error data to be handled.\n */\nexport function handleError ({ onErrorCallback, data }) {\n const error = data.error\n if (error && 'isCoraliteError' in error && error.isCoraliteError) {\n const coraliteError = error\n // @ts-ignore\n data.componentId = data.componentId || coraliteError.componentId\n // @ts-ignore\n data.filePath = data.filePath || coraliteError.filePath\n // @ts-ignore\n data.instanceId = data.instanceId || coraliteError.instanceId\n // @ts-ignore\n data.pagePath = data.pagePath || coraliteError.pagePath\n // @ts-ignore\n data.line = data.line || coraliteError.line\n // @ts-ignore\n data.column = data.column || coraliteError.column\n // @ts-ignore\n data.stackFile = data.stackFile || coraliteError.stackFile\n }\n\n if (onErrorCallback) {\n onErrorCallback(data)\n } else {\n defaultOnError(data)\n }\n}\n", "import { Parser } from 'htmlparser2'\nimport {\n createCoraliteElement,\n createCoraliteTextNode,\n createCoraliteComment,\n createCoraliteDirective,\n createCoraliteComponent,\n relinkChildren\n} from './dom.js'\nimport { isValidCustomElementName, VALID_TAGS } from '../tags.js'\nimport { CoraliteError } from '../errors.js'\n\n\n/**\n * @internal\n * @param {CoraliteElement} element - The element being parsed\n * @param {Record<string, string>} attributes - A dictionary of element attributes\n * @param {Array<string | Attribute>} skipRenderByAttribute - Keys to search for skip flag\n */\nfunction applySkipRenderAttribute (element, attributes, skipRenderByAttribute) {\n if (skipRenderByAttribute && skipRenderByAttribute.length > 0) {\n for (let i = 0; i < skipRenderByAttribute.length; i++) {\n const skipItem = skipRenderByAttribute[i]\n if (typeof skipItem === 'string') {\n if (Object.prototype.hasOwnProperty.call(attributes, skipItem)) {\n element.skipRender = true\n break\n }\n } else if (skipItem && typeof skipItem === 'object') {\n if (Object.prototype.hasOwnProperty.call(attributes, skipItem.name) && attributes[skipItem.name].includes(skipItem.value)) {\n element.skipRender = true\n break\n }\n }\n }\n }\n}\n\nfunction handleTemplateOpenTag (attributes) {\n if (!attributes.id) {\n throw new CoraliteError('Template requires an \"id\"')\n }\n if (!isValidCustomElementName(attributes.id)) {\n throw new CoraliteError('Invalid template id: \"' + attributes.id + '\" it must match following the pattern https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name')\n }\n return attributes.id\n}\n\n/**\n * @internal\n * @param {CoraliteElement} element - The slot element node\n * @param {Record<string, string>} attributes - A dictionary of element attributes\n * @param {string} templateId - Current template definition id\n * @param {Object.<string, Object.<string, CoraliteModuleSlotElement>>} slotElements - State containing slot lists\n */\nfunction handleSlotOpenTag (element, attributes, templateId, slotElements) {\n const name = attributes.name || 'default'\n if (slotElements[templateId] && slotElements[templateId][name]) {\n throw new CoraliteError('Slot names must be unique: \"' + name + '\"', {\n componentId: templateId\n })\n }\n const slot = {\n name,\n element\n }\n if (!slotElements[templateId]) {\n slotElements[templateId] = { [name]: slot }\n } else {\n slotElements[templateId][name] = slot\n }\n}\n\n/**\n * @import {\n * CoraliteToken,\n * CoraliteModule,\n * CoraliteTextNode,\n * CoraliteElement,\n * CoraliteModuleSlotElement,\n * CoraliteComponentValues,\n * CoraliteComponentRoot,\n * CoraliteContentNode,\n * Attribute,\n * ParseHTMLResult,\n * CoraliteOnError} from '../../../types/index.js'\n */\n\n/**\n * Parse HTML content and return a CoraliteComponent object representing the parsed component structure\n *\n * @param {string} string - HTML content to parse as string input type textual data\n * @param {Array<string | Attribute>} [ignoreByAttribute] - Ignore element with attribute name value pair\n * @param {Array<string | Attribute>} [skipRenderByAttribute] - Parse element but remove before final render\n * @param {CoraliteOnError} [onError] - Callback function for error and warning handling\n * @returns {ParseHTMLResult}\n * @example parseHTML('<h1>Hello world!</h1>')\n */\nexport function parseHTML (string, ignoreByAttribute, skipRenderByAttribute, onError) {\n // root element reference\n const root = createCoraliteComponent({\n type: 'root',\n children: []\n })\n\n // stack to keep track of current element hierarchy\n /** @type {CoraliteContentNode[]} */\n const stack = [root]\n const customElements = []\n /** @type {CoraliteElement[]} */\n const tempElements = []\n /** @type {CoraliteElement[]} */\n const skipRenderElements = []\n\n const ignoreAttributeMap = getIgnoreAttributeMap(ignoreByAttribute)\n\n const parser = new Parser({\n onprocessinginstruction (name, data) {\n root.children.push(createCoraliteDirective({\n type: 'directive',\n name,\n data\n }))\n },\n onopentag (originalName, attributes) {\n const name = originalName.toLowerCase()\n const parent = stack[stack.length - 1]\n const element = createElement({\n name,\n attributes,\n parent,\n ignoreByAttribute: ignoreAttributeMap,\n onError\n })\n\n applySkipRenderAttribute(element, attributes, skipRenderByAttribute)\n\n if (element.slots) {\n // store custom element\n customElements.push(element)\n }\n\n // push element to stack as it may have children\n stack.push(element)\n },\n ontext (text) {\n const parent = stack[stack.length - 1]\n\n createTextNode(text, parent)\n },\n onclosetag () {\n const element = stack[stack.length - 1]\n\n if (element.type === 'tag') {\n if (element._markedForRemoval) {\n // store element for removal\n // @ts-ignore\n tempElements.push(element.parent.children[element.parent.children.length - 1])\n } else if (element.skipRender) {\n // @ts-ignore\n skipRenderElements.push(element.parent.children[element.parent.children.length - 1])\n }\n }\n\n // remove current element from stack as we're done with its children\n stack.pop()\n },\n oncomment (data) {\n const parent = stack[stack.length - 1]\n\n parent.children.push(createCoraliteComment({\n type: 'comment',\n data,\n parent\n }))\n }\n }, { decodeEntities: false })\n\n parser.write(string)\n parser.end()\n\n relinkChildren(root)\n sortSlottedChildren(customElements)\n\n return {\n root,\n customElements,\n tempElements,\n skipRenderElements\n }\n}\n\n/**\n * Processes custom elements to organize their children by slot name.\n * @param {CoraliteElement[]} elements - Array of custom element objects with `children` and `attribs`.\n */\nfunction sortSlottedChildren (elements) {\n for (let i = 0; i < elements.length; i++) {\n const element = elements[i]\n\n for (let k = 0; k < element.children.length; k++) {\n const childNode = element.children[k]\n let slotName = 'default'\n\n if (childNode.type === 'tag'\n && childNode.attribs\n && childNode.attribs.slot) {\n slotName = childNode.attribs.slot\n\n // clean up slot attribute\n delete childNode.attribs.slot\n }\n\n element.slots.push({\n name: slotName,\n node: childNode\n })\n }\n }\n}\n\n/**\n * Parses HTML string containing meta tags or generates Coralite module structure from markup.\n *\n * @param {string} string - HTML content containing meta tags or module markup\n * @param {Object} options - The options for parsing the module.\n * @param {Array<string | Attribute>} options.ignoreByAttribute - An array of attribute names and values to ignore during parsing\n * @param {Array<string | Attribute>} [options.skipRenderByAttribute] - An array of attributes that exclude element from rendering\n * @param {CoraliteOnError} [options.onError] - Callback function for error and warning handling\n * @returns {CoraliteModule} - Parsed module information, including template, script, tokens, and slot configurations\n *\n * @example\n * ```\n * // example usage:\n * const html = `<template id=\"home\">\n * <slot name=\"default\">Hello</slot>\n * </template>`;\n * const module = parseModule(html, { ignoreByAttribute: [] });\n *\n * // module object structure will be:\n * //{\n * // id: 'home',\n * // template: { ... },\n * // tokens: [],\n * // customElements: [],\n * // slotElements: {\n * // default: {\n * // name: 'slot',\n * // element: {}\n * // }\n * // }\n * //}\n * ```\n */\nexport function parseModule (string, { ignoreByAttribute, skipRenderByAttribute, onError }) {\n // root element reference\n const root = createCoraliteComponent({\n type: 'root',\n children: []\n })\n // stack to keep track of current element hierarchy\n /** @type {CoraliteContentNode[]} */\n const stack = [root]\n const customElements = []\n /** @type {Object.<string, Object.<string,CoraliteModuleSlotElement>>} */\n const slotElements = {}\n /** @type {CoraliteComponentValues} */\n const documentValues = {\n refs: [],\n attributes: [],\n textNodes: []\n }\n const styles = []\n let isScript = false\n let isTemplate = false\n let templateId = ''\n const rootClasses = new Set()\n const descendantClasses = new Set()\n\n const ignoreAttributeMap = getIgnoreAttributeMap(ignoreByAttribute)\n\n const parser = new Parser({\n onopentag (originalName, attributes) {\n const parent = stack[stack.length - 1]\n const element = createElement({\n name: originalName,\n attributes,\n parent,\n ignoreByAttribute: ignoreAttributeMap,\n onError\n })\n\n applySkipRenderAttribute(element, attributes, skipRenderByAttribute)\n\n if (element.slots) {\n customElements.push(element)\n }\n\n // push element to stack as it may have children\n stack.push(element)\n\n if (element.name === 'script') {\n isScript = true\n } else if (element.name === 'template') {\n isTemplate = true\n templateId = handleTemplateOpenTag(attributes)\n } else if (element.name === 'slot') {\n handleSlotOpenTag(element, attributes, templateId, slotElements)\n } else if (isTemplate) {\n const attributeNames = Object.keys(attributes)\n\n // Collect classes\n if (attributes.class && parent.type !== 'root') {\n const classes = attributes.class.trim().split(/\\s+/)\n const isRoot = parent.name === 'template'\n\n for (const className of classes) {\n if (className) {\n if (isRoot) {\n rootClasses.add(className)\n } else {\n descendantClasses.add(className)\n }\n }\n }\n }\n\n // collect tokens inside template tag\n if (attributeNames.length) {\n for (let i = 0; i < attributeNames.length; i++) {\n const name = attributeNames[i]\n const value = attributes[name]\n const tokens = getTokensFromString(value)\n\n // store attribute tokens\n if (tokens.length) {\n documentValues.attributes.push({\n name,\n tokens,\n element\n })\n }\n\n if (name === 'ref') {\n documentValues.refs.push({\n name: value,\n element\n })\n }\n }\n }\n }\n },\n ontext (text) {\n const parent = stack[stack.length - 1]\n\n if (isTemplate && !isScript && text.trim()) {\n const topLevelTokens = getTokensFromString(text, true)\n\n if (topLevelTokens.length) {\n let lastIndex = 0\n for (const token of topLevelTokens) {\n const index = text.indexOf(token.content, lastIndex)\n\n if (index > lastIndex) {\n createTextNode(text.substring(lastIndex, index), parent)\n }\n\n const cToken = createCoraliteElement({\n type: 'tag',\n name: 'c-token',\n parent,\n attribs: {},\n children: []\n })\n parent.children.push(cToken)\n\n const tokenNode = createTextNode(token.content, cToken)\n documentValues.textNodes.push({\n tokens: getTokensFromString(token.content),\n textNode: tokenNode,\n type: 'html'\n })\n\n lastIndex = index + token.content.length\n }\n\n if (lastIndex < text.length) {\n createTextNode(text.substring(lastIndex), parent)\n }\n return\n }\n }\n\n createTextNode(text, parent)\n },\n onclosetag (name) {\n const element = stack[stack.length - 1]\n\n if (element.type === 'tag' && element._markedForRemoval) {\n // remove element from tree\n element.parent.children.pop()\n }\n\n if (name === 'template') {\n // exit template tag\n isTemplate = false\n } else if (name === 'script') {\n isScript = false\n }\n\n // remove current element from stack as we're done with its children\n stack.pop()\n },\n oncdatastart () {\n },\n\n oncomment (data) {\n stack[stack.length - 1].children.push(createCoraliteComment({\n type: 'comment',\n data,\n parent: stack[stack.length - 1]\n }))\n }\n }, { decodeEntities: false })\n\n parser.write(string)\n parser.end()\n\n relinkChildren(root)\n\n /** @type {CoraliteElement} */\n let template\n let script\n\n for (let i = 0; i < root.children.length; i++) {\n const node = root.children[i]\n\n if (node.type === 'tag') {\n if (node.name === 'template') {\n if (template) {\n throw new CoraliteError('One template element is permitted', {\n componentId: templateId\n })\n }\n\n // @ts-ignore\n template = node\n\n } else if (node.name === 'script') {\n if (node.attribs.type !== 'module') {\n throw new CoraliteError('Template \"' + templateId + '\" script tag must contain the `type=\"module\"` attribute', {\n componentId: templateId\n })\n }\n const scriptString = node.children[0]\n\n if (scriptString.type !== 'text') {\n throw new CoraliteError('Script tag must contain text', {\n componentId: templateId\n })\n }\n\n script = scriptString.data\n } else if (node.name === 'style') {\n const styleContent = node.children[0]\n\n if (styleContent && styleContent.type === 'text') {\n styles.push(styleContent.data)\n }\n }\n }\n }\n\n if (!template) {\n return {\n isTemplate: false\n }\n }\n\n const scriptIndex = string.indexOf('<script')\n const scriptTagEnd = string.indexOf('>', scriptIndex) + 1\n const stringHead = string.substring(0, scriptTagEnd)\n const lineOffset = stringHead.split(/\\r\\n|\\r|\\n/).length - 1\n\n return {\n id: template.attribs.id,\n template,\n script,\n styles,\n values: documentValues,\n lineOffset,\n customElements,\n slotElements,\n isTemplate: true,\n rootClasses,\n descendantClasses\n }\n}\n\n/**\n * Creates an element within the component structure based on provided parameters.\n * @param {Object} data - An object containing details needed to create the element.\n * @param {string} data.name - The tag name of the new element.\n * @param {Object.<string, string>} data.attributes - Attributes for the new element.\n * @param {CoraliteElement | CoraliteComponentRoot} data.parent - Parent element or component root where this element will be attached.\n * @param {Array<string | Attribute> | Map<string, string[]>} [data.ignoreByAttribute] - Optional parameter used for ignoring elements based on attributes.\n * @param {CoraliteOnError} [data.onError] - Callback function for error and warning handling\n * @returns {CoraliteElement} The newly created element with its parent reference and position in the parent's children list.\n */\nexport function createElement ({\n name,\n attributes,\n parent,\n ignoreByAttribute,\n onError\n}) {\n const sanitisedName = name.toLowerCase()\n const element = createCoraliteElement({\n type: 'tag',\n name: sanitisedName,\n attribs: attributes,\n children: [],\n parent,\n parentChildIndex: parent.children.length\n })\n\n if (ignoreByAttribute) {\n const ignore = findAttributesToIgnore(ignoreByAttribute, attributes)\n\n if (ignore) {\n element._markedForRemoval = true\n }\n }\n\n if (!VALID_TAGS[sanitisedName]) {\n const specUrl = 'https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name'\n\n try {\n element.name = name\n\n // check if the tag name matches the regex for valid custom elements\n if (isValidCustomElementName(name)) {\n // store custom elements\n element.slots = []\n } else {\n const message = 'Invalid custom element tag name: \"' + name + '\" (' + specUrl + ')'\n if (typeof onError === 'function') {\n onError({\n level: 'WARN',\n message\n })\n } else {\n console.warn(message)\n }\n }\n } catch (error) {\n const message = error.message + ' (' + specUrl + ')'\n if (typeof onError === 'function') {\n onError({\n level: 'WARN',\n message,\n error\n })\n } else {\n console.warn(message)\n }\n }\n }\n\n // add element to its parent's children\n parent.children.push(element)\n\n return element\n}\n\n/**\n * @param {string} data - The text content to create a text node\n * @param {CoraliteElement | CoraliteComponentRoot} parent - parent node\n * @returns {CoraliteTextNode}\n *\n * @example\n * const textNode = createTextNode('Hello World', parentNode);\n */\nexport function createTextNode (data, parent) {\n /** @type {CoraliteTextNode} */\n const textNode = createCoraliteTextNode({\n type: 'text',\n data,\n parent\n })\n\n // @ts-ignore\n parent.children.push(textNode)\n\n return textNode\n}\n\n/**\n * Find attributes to be ignored by the parser.\n *\n * @param {Array<string | Attribute> | Map<string, Array<string | null>>} ignoreByAttribute - An array of attribute pairs/strings or a map to be ignored by the parser\n * @param {Object<string, string>} attributes - The HTML attribute object to be parsed by the parser\n * @returns {boolean}\n */\nfunction findAttributesToIgnore (ignoreByAttribute, attributes) {\n if (Array.isArray(ignoreByAttribute)) {\n for (let i = 0; i < ignoreByAttribute.length; i++) {\n const item = ignoreByAttribute[i]\n if (typeof item === 'string') {\n if (Object.prototype.hasOwnProperty.call(attributes, item)) {\n return true\n }\n } else {\n const { name, value } = item\n if (attributes[name] && attributes[name].includes(value)) {\n return true\n }\n }\n }\n return false\n }\n\n // Handle Map optimization\n for (const name in attributes) {\n if (Object.prototype.hasOwnProperty.call(attributes, name)) {\n if (ignoreByAttribute.has(name)) {\n const values = ignoreByAttribute.get(name)\n const attributeValue = attributes[name]\n\n for (let i = 0; i < values.length; i++) {\n if (values[i] === null) {\n return true\n } else if (attributeValue.includes(values[i])) {\n return true\n }\n }\n }\n }\n }\n\n return false\n}\n\n/**\n * Create a map from ignoreByAttribute array.\n * @param {Array<string | Attribute> | Map<string, Array<string | null>>} ignoreByAttribute - The ignore configurations\n * @returns {Map<string, Array<string | null>>} The generated map\n */\nfunction getIgnoreAttributeMap (ignoreByAttribute) {\n if (!ignoreByAttribute) {\n return\n }\n\n if (!Array.isArray(ignoreByAttribute)) {\n return ignoreByAttribute\n }\n\n const map = new Map()\n\n for (let i = 0; i < ignoreByAttribute.length; i++) {\n const item = ignoreByAttribute[i]\n let name, value\n if (typeof item === 'string') {\n name = item\n value = null\n } else {\n name = item.name\n value = item.value\n }\n\n if (!map.has(name)) {\n map.set(name, [])\n }\n map.get(name).push(value)\n }\n\n return map\n}\n\n/**\n * Extract tokens from string\n * @param {string} string - The string to extract tokens from\n * @returns {CoraliteToken[]} The array of tokens extracted from the string\n *\n * @example\n * getTokensFromString('Hello {{ name }} and {{ age }}')\n * // Returns: [{ name: 'name', content: '{{ name }}' }, { name: 'age', content: '{{ age }}' }]\n *\n * Handles:\n * - Multiple tokens in one string\n * - Nested braces: {{ {{nested}} }} extracts both\n * - Complex token names: {{ user.name }}, {{ items[0] }}\n * - Empty tokens: {{}} (returns empty name)\n * - Malformed tokens: {{unclosed, {{extra}} braces}}\n */\nfunction getTokensFromString (string, topLevelOnly = false) {\n const result = []\n let i = 0\n\n while (i < string.length) {\n if (string[i] === '{' && string[i + 1] === '{') {\n const tokenStart = i\n i += 2\n\n // Track brace depth for nested tokens\n let depth = 1\n let tokenEnd = -1\n\n // Scan until we find matching closing braces\n while (i < string.length && depth > 0) {\n if (string[i] === '{' && string[i + 1] === '{') {\n depth++\n i += 2\n } else if (string[i] === '}' && string[i + 1] === '}') {\n depth--\n if (depth === 0) {\n tokenEnd = i + 2\n break\n }\n i += 2\n } else {\n i++\n }\n }\n\n // If we found a complete token\n if (tokenEnd > 0) {\n const fullToken = string.slice(tokenStart, tokenEnd)\n const tokenContent = fullToken.slice(2, -2).trim()\n\n // Add the full token\n result.push({\n name: tokenContent,\n content: fullToken\n })\n\n if (!topLevelOnly) {\n // Also extract any nested tokens from the content\n // This handles cases like {{ {{nested}} }} which should extract both\n const nestedTokens = getTokensFromString(tokenContent)\n\n // Add nested tokens that are different from the full token\n for (const nested of nestedTokens) {\n // Only add if it's not the same as what we just added\n if (nested.content !== fullToken) {\n result.push(nested)\n }\n }\n }\n\n // Continue scanning after this token\n continue\n }\n\n // If token is unclosed, treat it as literal text and continue\n i = tokenStart + 2\n } else {\n i++\n }\n }\n\n return result\n}\n", "/**\n * @import {\n * CoraliteElement,\n * CoraliteTextNode,\n * CoraliteAnyNode,\n * CoraliteComponentRoot,\n * CoraliteComment,\n * CoraliteDirective,\n * RawCoraliteElement,\n * RawCoraliteTextNode,\n * RawCoraliteComment,\n * RawCoraliteDirective,\n * RawCoraliteComponentRoot\n * } from '../../../types/index.js'\n */\n\nconst ELEMENT_NODE = 1\nconst TEXT_NODE = 3\nconst COMMENT_NODE = 8\nconst DOCUMENT_NODE = 9\nconst DOCUMENT_TYPE_NODE = 10\n\nconst nodeTypes = {\n tag: ELEMENT_NODE,\n script: ELEMENT_NODE,\n style: ELEMENT_NODE,\n text: TEXT_NODE,\n comment: COMMENT_NODE,\n root: DOCUMENT_NODE,\n directive: DOCUMENT_TYPE_NODE\n}\n\nconst PARENT_SYM = Symbol('parent')\nconst PREV_SYM = Symbol('prev')\nconst NEXT_SYM = Symbol('next')\nconst SLOTS_SYM = Symbol('slots')\n\n/**\n * Ensures circular properties are non-enumerable to prevent serialization issues.\n * @param {any} node - The node to enhance\n */\nfunction makeCircularPropertiesNonEnumerable (node) {\n for (const key of ['parent', 'prev', 'next', 'slots']) {\n if (Object.hasOwn(node, key)) {\n const val = node[key]\n delete node[key]\n if (val !== undefined) {\n node[key] = val\n }\n }\n }\n}\n\n/**\n * Base prototype for all Coralite nodes.\n */\nconst CoraliteNodePrototype = {\n /**\n * Removes the node from its parent's children list and updates siblings.\n */\n remove () {\n if (this.parent && this.parent.children) {\n const index = this.parent.children.indexOf(this)\n if (index > -1) {\n this.parent.children.splice(index, 1)\n }\n }\n\n // Re-stitch the linked list\n if (this.prev) {\n this.prev.next = this.next\n }\n if (this.next) {\n this.next.prev = this.prev\n }\n\n this.parent = null\n this.next = null\n this.prev = null\n }\n}\n\nObject.defineProperties(CoraliteNodePrototype, {\n nodeType: {\n get () {\n return nodeTypes[this.type] || ELEMENT_NODE\n }\n },\n parent: {\n get () {\n return this[PARENT_SYM] || null\n },\n set (v) {\n this[PARENT_SYM] = v\n },\n enumerable: false\n },\n prev: {\n get () {\n return this[PREV_SYM] || null\n },\n set (v) {\n this[PREV_SYM] = v\n },\n enumerable: false\n },\n next: {\n get () {\n return this[NEXT_SYM] || null\n },\n set (v) {\n this[NEXT_SYM] = v\n },\n enumerable: false\n },\n slots: {\n get () {\n return this[SLOTS_SYM] || null\n },\n set (v) {\n this[SLOTS_SYM] = v\n },\n enumerable: false\n },\n parentNode: {\n get () {\n return this.parent || null\n },\n set (value) {\n this.parent = value\n }\n },\n parentElement: {\n get () {\n return this.parent || null\n },\n set (value) {\n this.parent = value\n }\n },\n previousSibling: {\n get () {\n return this.prev || null\n }\n },\n nextSibling: {\n get () {\n return this.next || null\n }\n }\n})\n\n/**\n * Prototype for Coralite Elements.\n */\nconst CoraliteElementPrototype = Object.create(CoraliteNodePrototype)\n\n/**\n * Returns the value of a specified attribute on the element.\n * @param {string} name - The name of the attribute\n * @returns {string | null}\n */\nCoraliteElementPrototype.getAttribute = function (name) {\n return this.attribs && Object.hasOwn(this.attribs, name) ? this.attribs[name] : null\n}\n\n/**\n * Sets the value of an attribute on the element.\n * @param {string} name - The name of the attribute\n * @param {any} value - The value to set\n */\nCoraliteElementPrototype.setAttribute = function (name, value) {\n if (!this.attribs) {\n this.attribs = {}\n }\n this.attribs[name] = String(value)\n}\n\n/**\n * Returns a boolean value indicating whether the specified element has the specified attribute or not.\n * @param {string} name - The name of the attribute\n * @returns {boolean}\n */\nCoraliteElementPrototype.hasAttribute = function (name) {\n return !!(this.attribs && Object.hasOwn(this.attribs, name))\n}\n\n/**\n * Removes an attribute from the element.\n * @param {string} name - The name of the attribute\n */\nCoraliteElementPrototype.removeAttribute = function (name) {\n if (this.attribs) {\n delete this.attribs[name]\n }\n}\n\n/**\n * Adds a node to the end of the list of children of a specified parent node.\n * @param {any} node - The node to append\n * @returns {any}\n */\nCoraliteElementPrototype.appendChild = function (node) {\n if (node.parent) {\n node.remove()\n }\n\n if (!this.children) {\n this.children = []\n }\n\n const lastChild = this.children[this.children.length - 1]\n if (lastChild) {\n lastChild.next = node\n node.prev = lastChild\n } else {\n node.prev = null\n }\n\n node.next = null\n node.parent = this\n this.children.push(node)\n\n return node\n}\n\n/**\n * Inserts a set of Node objects or string objects after the last child of the Element.\n * @param {...(any)} nodes - The nodes or strings to append\n */\nCoraliteElementPrototype.append = function (...nodes) {\n for (let node of nodes) {\n if (typeof node === 'string') {\n node = createCoraliteTextNode({\n type: 'text',\n data: node\n })\n }\n this.appendChild(node)\n }\n}\n\nObject.defineProperties(CoraliteElementPrototype, {\n nodeName: {\n get () {\n return (this.name || '').toUpperCase()\n }\n },\n tagName: {\n get () {\n return (this.name || '').toUpperCase()\n },\n set (value) {\n this.name = (value || '').toLowerCase()\n }\n },\n nodeValue: {\n get () {\n return null\n },\n set () {\n // Elements do not have nodeValue\n }\n },\n attributes: {\n get () {\n return this.attribs\n },\n set (value) {\n this.attribs = value\n }\n },\n childNodes: {\n get () {\n return this.children || []\n },\n set (value) {\n this.children = value\n }\n },\n firstChild: {\n get () {\n return (this.children && this.children[0]) || null\n }\n },\n lastChild: {\n get () {\n return (this.children && this.children[this.children.length - 1]) || null\n }\n },\n textContent: {\n get () {\n if (this.children) {\n return this.children.map(child => child.textContent).join('')\n }\n return ''\n },\n set (value) {\n if (this.children) {\n for (const child of this.children) {\n child.parent = null\n child.prev = null\n child.next = null\n }\n }\n\n const textNode = createCoraliteTextNode({\n type: 'text',\n data: value,\n parent: this,\n prev: null,\n next: null\n })\n this.children = [textNode]\n }\n },\n id: {\n get () {\n return this.attribs ? this.attribs.id : ''\n },\n set (value) {\n if (!this.attribs) {\n this.attribs = {}\n }\n this.attribs.id = value\n }\n },\n className: {\n get () {\n return this.attribs ? this.attribs.class : ''\n },\n set (value) {\n if (!this.attribs) {\n this.attribs = {}\n }\n this.attribs.class = value\n }\n },\n classList: {\n get () {\n if (!this._classList) {\n const self = this\n const classList = {\n add (...classes) {\n const current = self.className ? self.className.split(/\\s+/).filter(Boolean) : []\n const set = new Set(current)\n classes.forEach(c => set.add(c))\n self.className = Array.from(set).join(' ')\n },\n remove (...classes) {\n const current = self.className ? self.className.split(/\\s+/).filter(Boolean) : []\n const set = new Set(current)\n classes.forEach(c => set.delete(c))\n self.className = Array.from(set).join(' ')\n },\n contains (cls) {\n const current = self.className ? self.className.split(/\\s+/).filter(Boolean) : []\n return current.includes(cls)\n },\n toggle (cls, force) {\n const current = self.className ? self.className.split(/\\s+/).filter(Boolean) : []\n const set = new Set(current)\n if (force !== undefined) {\n if (force) {\n set.add(cls)\n } else {\n set.delete(cls)\n }\n } else {\n if (set.has(cls)) {\n set.delete(cls)\n } else {\n set.add(cls)\n }\n }\n self.className = Array.from(set).join(' ')\n return set.has(cls)\n },\n get value () {\n return self.className\n }\n }\n Object.defineProperty(this, '_classList', {\n value: classList,\n enumerable: false,\n writable: true,\n configurable: true\n })\n }\n return this._classList\n }\n }\n})\n\n/**\n * Prototype for Coralite Text Nodes.\n */\nconst CoraliteTextNodePrototype = Object.create(CoraliteNodePrototype)\n\nObject.defineProperties(CoraliteTextNodePrototype, {\n nodeName: {\n get () {\n return '#text'\n }\n },\n nodeValue: {\n get () {\n return this.data\n },\n set (value) {\n this.data = value\n }\n },\n textContent: {\n get () {\n return this.data\n },\n set (value) {\n this.data = value\n }\n }\n})\n\n/**\n * Prototype for Coralite Comment Nodes.\n */\nconst CoraliteCommentPrototype = Object.create(CoraliteNodePrototype)\n\nObject.defineProperties(CoraliteCommentPrototype, {\n nodeName: {\n get () {\n return '#comment'\n }\n },\n nodeValue: {\n get () {\n return this.data\n },\n set (value) {\n this.data = value\n }\n },\n textContent: {\n get () {\n return this.data\n },\n set (value) {\n this.data = value\n }\n }\n})\n\n/**\n * Prototype for Coralite Directive Nodes.\n */\nconst CoraliteDirectivePrototype = Object.create(CoraliteNodePrototype)\n\nObject.defineProperties(CoraliteDirectivePrototype, {\n nodeName: {\n get () {\n return this.name\n }\n },\n nodeValue: {\n get () {\n return this.data\n },\n set (value) {\n this.data = value\n }\n }\n})\n\n/**\n * Prototype for Coralite Component Roots (Document).\n */\nconst CoraliteComponentPrototype = Object.create(CoraliteNodePrototype)\n\nObject.defineProperties(CoraliteComponentPrototype, {\n nodeName: {\n get () {\n return '#document'\n }\n },\n nodeValue: {\n get () {\n return null\n }\n },\n childNodes: {\n get () {\n return this.children || []\n },\n set (value) {\n this.children = value\n }\n },\n firstChild: {\n get () {\n return (this.children && this.children[0]) || null\n }\n },\n lastChild: {\n get () {\n return (this.children && this.children[this.children.length - 1]) || null\n }\n },\n textContent: {\n get () {\n return null\n }\n }\n})\n\n/**\n * Internal helper to get prototype based on node type.\n */\nfunction getPrototypeForType (type) {\n switch (type) {\n case 'tag':\n case 'script':\n case 'style':\n return CoraliteElementPrototype\n case 'text':\n return CoraliteTextNodePrototype\n case 'comment':\n return CoraliteCommentPrototype\n case 'directive':\n return CoraliteDirectivePrototype\n case 'root':\n return CoraliteComponentPrototype\n default:\n return CoraliteNodePrototype\n }\n}\n\n/**\n * Enhances a raw node by applying the correct prototype based on its type.\n * @param {any} node - The node to enhance\n * @returns {any} The enhanced node\n */\nexport function enhanceNode (node) {\n if (!node || node.__coralite_enhanced__) {\n return node\n }\n\n const prototype = getPrototypeForType(node.type)\n Object.setPrototypeOf(node, prototype)\n makeCircularPropertiesNonEnumerable(node)\n\n Object.defineProperty(node, '__coralite_enhanced__', {\n value: true,\n enumerable: false,\n configurable: true\n })\n\n return node\n}\n\n/**\n * Re-links all children of a parent node, ensuring parent, prev, and next pointers are correct.\n * @param {any} parent - The parent node whose children should be re-linked\n */\nexport function relinkChildren (parent) {\n if (!parent || !parent.children || !Array.isArray(parent.children)) {\n return\n }\n\n for (let i = 0; i < parent.children.length; i++) {\n const child = parent.children[i]\n if (!child) {\n continue\n }\n\n enhanceNode(child)\n child.parent = parent\n child.prev = parent.children[i - 1] || null\n child.next = parent.children[i + 1] || null\n\n if (child.children) {\n relinkChildren(child)\n }\n }\n}\n\n/**\n * Creates an enhanced Coralite Element\n * @param {RawCoraliteElement} node - The raw element node\n * @returns {CoraliteElement} The enhanced Coralite Element\n */\nexport function createCoraliteElement (node) {\n node.type = node.type || 'tag'\n return enhanceNode(node)\n}\n\n/**\n * Creates an enhanced Coralite Text Node\n * @param {RawCoraliteTextNode} node - The raw text node\n * @returns {CoraliteTextNode} The enhanced Coralite Text Node\n */\nexport function createCoraliteTextNode (node) {\n node.type = 'text'\n return enhanceNode(node)\n}\n\n/**\n * Creates an enhanced Coralite Comment Node\n * @param {RawCoraliteComment} node - The raw comment node\n * @returns {CoraliteComment} The enhanced Coralite Comment Node\n */\nexport function createCoraliteComment (node) {\n node.type = 'comment'\n return enhanceNode(node)\n}\n\n/**\n * Creates an enhanced Coralite Directive Node (e.g. DOCTYPE)\n * @param {RawCoraliteDirective} node - The raw directive node\n * @returns {CoraliteDirective} The enhanced Coralite Directive Node\n */\nexport function createCoraliteDirective (node) {\n node.type = 'directive'\n return enhanceNode(node)\n}\n\n/**\n * Creates an enhanced Coralite Document Root\n * @param {RawCoraliteComponentRoot} node - The raw document node\n * @returns {CoraliteComponentRoot} The enhanced Coralite Document Root\n */\nexport function createCoraliteComponent (node) {\n node.type = 'root'\n return enhanceNode(node)\n}\n", "import { CoraliteError } from './errors.js'\n\nexport const BOOLEAN_ATTRIBUTES = new Set([\n 'allowfullscreen',\n 'async',\n 'autofocus',\n 'autoplay',\n 'checked',\n 'controls',\n 'default',\n 'defer',\n 'disabled',\n 'formnovalidate',\n 'hidden',\n 'inert',\n 'ismap',\n 'itemscope',\n 'loop',\n 'multiple',\n 'muted',\n 'nomodule',\n 'novalidate',\n 'open',\n 'playsinline',\n 'readonly',\n 'required',\n 'reversed',\n 'selected',\n 'truespeed'\n])\n\nexport const VALID_TAGS = {\n a: true,\n abbr: true,\n acronym: true,\n address: true,\n area: true,\n article: true,\n aside: true,\n audio: true,\n b: true,\n base: true,\n bdi: true,\n bdo: true,\n big: true,\n blockquote: true,\n body: true,\n br: true,\n button: true,\n canvas: true,\n caption: true,\n center: true,\n cite: true,\n code: true,\n col: true,\n colgroup: true,\n data: true,\n datalist: true,\n dd: true,\n del: true,\n details: true,\n dfn: true,\n dialog: true,\n dir: true,\n div: true,\n dl: true,\n dt: true,\n em: true,\n embed: true,\n fencedframe: true,\n fieldset: true,\n figcaption: true,\n figure: true,\n font: true,\n footer: true,\n form: true,\n frame: true,\n frameset: true,\n h1: true,\n h2: true,\n h3: true,\n h4: true,\n h5: true,\n h6: true,\n head: true,\n header: true,\n hgroup: true,\n hr: true,\n html: true,\n i: true,\n iframe: true,\n img: true,\n input: true,\n ins: true,\n kbd: true,\n label: true,\n legend: true,\n li: true,\n link: true,\n main: true,\n map: true,\n mark: true,\n marquee: true,\n menu: true,\n meta: true,\n meter: true,\n nav: true,\n nobr: true,\n noembed: true,\n noframes: true,\n noscript: true,\n object: true,\n ol: true,\n optgroup: true,\n option: true,\n output: true,\n p: true,\n param: true,\n picture: true,\n plaintext: true,\n portal: true,\n pre: true,\n progress: true,\n q: true,\n rb: true,\n rp: true,\n rt: true,\n rtc: true,\n ruby: true,\n s: true,\n samp: true,\n script: true,\n search: true,\n section: true,\n select: true,\n slot: true,\n small: true,\n source: true,\n span: true,\n strike: true,\n strong: true,\n style: true,\n sub: true,\n summary: true,\n sup: true,\n table: true,\n tbody: true,\n td: true,\n template: true,\n textarea: true,\n tfoot: true,\n th: true,\n thead: true,\n time: true,\n title: true,\n tr: true,\n track: true,\n tt: true,\n u: true,\n ul: true,\n var: true,\n video: true,\n wbr: true,\n xmp: true,\n // svg\n svg: true,\n animate: true,\n animatemotion: true,\n animatetransform: true,\n circle: true,\n clippath: true,\n defs: true,\n desc: true,\n ellipse: true,\n feblend: true,\n fecolormatrix: true,\n fecomponenttransfer: true,\n fecomposite: true,\n feconvolvematrix: true,\n fediffuselighting: true,\n fedisplacementmap: true,\n fedistantlight: true,\n fedropshadow: true,\n feflood: true,\n fefunca: true,\n fefuncb: true,\n fefuncg: true,\n fefuncr: true,\n fegaussianblur: true,\n feimage: true,\n femerge: true,\n femergenode: true,\n femorphology: true,\n feoffset: true,\n fepointlight: true,\n fespecularlighting: true,\n fespotlight: true,\n fetile: true,\n feturbulence: true,\n filter: true,\n foreignobject: true,\n g: true,\n image: true,\n line: true,\n lineargradient: true,\n marker: true,\n mask: true,\n metadata: true,\n mpath: true,\n path: true,\n pattern: true,\n polygon: true,\n polyline: true,\n radialgradient: true,\n rect: true,\n set: true,\n stop: true,\n switch: true,\n symbol: true,\n text: true,\n textpath: true,\n tspan: true,\n use: true,\n view: true\n}\n\nexport const RESERVED_ELEMENT_NAMES = {\n 'annotation-xml': true,\n 'color-profile': true,\n 'font-face': true,\n 'font-face-src': true,\n 'font-face-uri': true,\n 'font-face-format': true,\n 'font-face-name': true,\n 'missing-glyph': true\n}\n\nconst CUSTOM_ELEMENT_TAG = /^[a-z](?:[-.\\w\\u00B7\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u203F-\\u2040\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD])*?-(?:[-.\\w\\u00B7\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u203F-\\u2040\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD])*$/\n\n/**\n * Validates a custom element name\n * @param {string} name - The custom element name to validate\n * @param {number} [maxLength=100] - Max length of the tag name\n * @returns {boolean} - True if valid, false otherwise\n * @throws {Error} - If the element name is reserved\n */\nexport function isValidCustomElementName (name, maxLength = 100) {\n // Check if string is empty or not a string\n if (!name || typeof name !== 'string') {\n return false\n }\n\n // Check against reserved names first (case-insensitive)\n if (RESERVED_ELEMENT_NAMES[name.toLowerCase()]) {\n throw new CoraliteError('Element name is reserved: \"'+ name +'\"')\n }\n\n // Length check to prevent ReDoS\n if (name.length > maxLength) {\n return false\n }\n\n // check for obviously invalid patterns that could cause backtracking\n if (name.includes('--') || name.startsWith('-') || name.endsWith('-')) {\n return false\n }\n\n // Test against the regex\n return CUSTOM_ELEMENT_TAG.test(name)\n}\n", "import { build } from 'esbuild'\nimport serialize from 'serialize-javascript'\nimport { parse as parseJS } from 'acorn'\nimport { simple as walkJS } from 'acorn-walk'\nimport { normalizeFunction, normalizeObjectFunctions, hasObjectKeys, mergeUniqueObjects, addComponentAndDependencies, cleanAST, cleanValues, generateHydrationMap } from './utils/core.js'\nimport { findAndExtractImperativeComponents, astTransformer } from './utils/server/server.js'\nimport { CoraliteError } from './utils/errors.js'\nimport { pathToFileURL, fileURLToPath } from 'node:url'\nimport { resolve, parse, dirname, relative } from 'node:path'\nimport { nodeModulesPolyfillPlugin } from 'esbuild-plugins-node-modules-polyfill'\nimport render from 'dom-serializer'\n\n/**\n * Script Manager for Coralite\n * Manages shared functions across component instances and provides plugin extensibility\n * @import { ScriptPlugin, InstanceContext } from '../types/index.js'\n * @import { ScriptContent } from '../types/script.js'\n */\n\n/**\n * ScriptManager constructor function\n * @class\n * @param {Object} options - The configuration options for the script manager.\n */\nexport function ScriptManager (options = {}) {\n this.sharedFunctions = Object.create(null)\n this.contextProps = Object.create(null)\n this.plugins = []\n this.scriptModules = []\n this.options = options\n}\n\n/**\n * Register a plugin\n * @param {ScriptPlugin} plugin - Plugin object or setup function\n * @returns {Promise<ScriptManager>} - Returns this for method chaining\n */\nScriptManager.prototype.use = async function (plugin) {\n // Register script modules (client plugins)\n if (\n plugin\n && typeof plugin !== 'function'\n ) {\n if (plugin.context\n || typeof plugin.setup === 'function'\n || typeof plugin.onBeforeComponentRender === 'function'\n || typeof plugin.onAfterComponentRender === 'function'\n || typeof plugin.onDisconnected === 'function') {\n this.scriptModules.push(plugin)\n\n if (plugin.context) {\n let extractedComponents = []\n for (const key in plugin.context) {\n if (Object.hasOwn(plugin.context, key)) {\n const contextFn = plugin.context[key]\n const contextStr = typeof contextFn === 'function' ? `(${contextFn.toString()})` : serialize(contextFn)\n const foundComponents = findAndExtractImperativeComponents(contextStr)\n extractedComponents = extractedComponents.concat(foundComponents)\n }\n }\n if (extractedComponents.length > 0) {\n plugin._extractedComponents = Array.from(new Set(extractedComponents))\n }\n }\n }\n }\n\n this.plugins.push(plugin)\n return this\n}\n\n/**\n * Get context object content string\n * @returns {string} String containing all context as object state\n */\nScriptManager.prototype.getClientContextContent = function () {\n let contextPropsStr = ''\n\n for (const [key, value] of Object.entries(this.contextProps)) {\n contextPropsStr += `\"${key}\": async (globalContext) => {\n const phase1 = ${value};\n const phase2 = await phase1(globalContext);\n return (localContext) => phase2(localContext);\n },`\n }\n\n return contextPropsStr\n}\n\n/**\n * Add a context property function\n * @param {string} name - Property name\n * @param {function} method - The property function\n * @returns {Promise<ScriptManager>} - Returns this for method chaining\n */\nScriptManager.prototype.addContextProp = async function (name, method) {\n this.contextProps[name] = normalizeFunction(method)\n\n return this\n}\n\n/**\n * Register shared functions for a component\n * @param {Object} options - The options used to register the component.\n * @param {string} options.id - The component identifier.\n * @param {ScriptContent} [options.script={}] - The script content or function associated with the component.\n * @param {string} [options.filePath] - The source file path used to map back to the original source.\n * @param {Array<Object>|null} [options.templateAST=null] - The parsed HTML template AST for client-side rendering.\n * @param {Object|null} [options.templateValues=null] - The token positions for AST updates.\n * @param {Object} [options.defaultValues={}] - The initial default state from setup().\n * @param {Object} [options.getters={}] - The component getters.\n * @param {string} [options.styles=''] - The raw CSS string for the component.\n * @param {Object.<string, Function>} [options.slots={}] - The transformation functions for computed slots.\n * @param {boolean} [options.override=false] - Whether to override existing component definition.\n */\nScriptManager.prototype.registerComponent = function ({\n id,\n script = {},\n filePath,\n templateAST = null,\n templateValues = null,\n defaultValues = {},\n getters = {},\n styles = '',\n slots = {},\n override = false\n}) {\n // Initialize base object if it's the first time we are seeing this ID\n const isNew = !this.sharedFunctions[id]\n if (isNew) {\n this.sharedFunctions[id] = {\n id,\n components: [],\n filePath: `/component-${id}.js`\n }\n }\n\n const target = this.sharedFunctions[id]\n\n if (hasObjectKeys(script)) {\n if (isNew || override) {\n target.script = script\n }\n }\n\n if (hasObjectKeys(getters)) {\n if (isNew || override) {\n target.getters = getters\n }\n }\n\n if (templateAST) {\n if (isNew || override) {\n target.templateAST = templateAST\n }\n }\n\n if (templateValues) {\n if (isNew || override) {\n target.templateValues = templateValues\n }\n }\n\n if (styles) {\n if (isNew || override) {\n target.styles = styles\n }\n }\n\n if (filePath) {\n if (isNew || override) {\n target.filePath = resolve(filePath)\n }\n }\n\n\n if (hasObjectKeys(defaultValues)) {\n if (isNew || override) {\n target.defaultValues = defaultValues\n }\n }\n\n if (hasObjectKeys(slots)) {\n if (isNew || override) {\n target.slots = slots\n }\n }\n\n if (script) {\n if (script.components?.length) {\n if (isNew || override) {\n target.components = script.components\n } else {\n target.components = mergeUniqueObjects(target.components, script.components)\n }\n }\n }\n}\n\n/**\n * Generate instance-specific script wrapper\n * @param {string} id - component identifier\n * @param {InstanceContext} instanceContext - Instance context\n * @returns {string} Generated script\n */\nScriptManager.prototype.generateInstanceWrapper = function (id, instanceContext) {\n const state = instanceContext.state ? serialize(instanceContext.state) : '{}'\n const page = instanceContext.page ? serialize(instanceContext.page) : '{}'\n\n // Generate wrapper that calls shared functions with instance context\n return `await coraliteComponentFunctions[\"${id}\"]({\n state: ${state},\n page: ${page},\n ...pluginContexts,\n instanceId: '${instanceContext.instanceId}'\n });`\n}\n\n/**\n * Compile all instances for a component\n * @param {Object.<string, InstanceContext>} instances - Map of instanceId -> instance data\n * @param {string} mode - Build mode\n * @returns {Promise<any>} Compiled script\n */\nScriptManager.prototype.compileAllInstances = async function (instances, mode) {\n const entryCodeParts = []\n const moduleNamespace = 'coralite-script-module:'\n // Generate ESM imports for each script module\n for (let i = 0; i < this.scriptModules.length; i++) {\n entryCodeParts.push(`import { clientContextProps as clientContextProps_${i}, runSetup as runSetup_${i}, onBeforeComponentRender as onBeforeComponentRender_${i}, onAfterComponentRender as onAfterComponentRender_${i}, onDisconnected as onDisconnected_${i} } from \"${moduleNamespace}${i}\";\\n`)\n }\n\n // Setup client context state\n const contextParts = [\n ...this.scriptModules.map((_, i) => `...clientContextProps_${i}`),\n this.getClientContextContent()\n ].filter(Boolean).join(',\\n')\n\n entryCodeParts.push(`const coraliteComponentClientContextProps = {\n ${contextParts}\n };\\n`)\n\n entryCodeParts.push(`const getSetups = async (context) => {\n const state = {};\n for (const runSetup of [${this.scriptModules.map((_, i) => `runSetup_${i}`).join(', ')}]) {\n const result = await runSetup(context);\n if (result && typeof result === 'object') {\n Object.assign(state, result);\n }\n }\n return state;\n }\\n`)\n\n // Global setups initialization\n entryCodeParts.push('const globalContext = { values: {} };\\n')\n\n entryCodeParts.push(`const resolvedContextPropsPromise = (async () => {\n const setupValues = await getSetups(globalContext);\n Object.assign(globalContext.values, setupValues);\n\n const resolvedProps = {};\n const keys = Object.keys(coraliteComponentClientContextProps);\n for (const key of keys) {\n resolvedProps[key] = await coraliteComponentClientContextProps[key](globalContext);\n globalContext[key] = resolvedProps[key];\n }\n return resolvedProps;\n })();\\n`)\n\n entryCodeParts.push(`const getClientContext = async (context) => {\n const clientContextProps = {}\n const resolvedProps = await resolvedContextPropsPromise;\n for (const [key, resolvedProp] of Object.entries(resolvedProps)) {\n const bound = resolvedProp(context);\n clientContextProps[key] = bound;\n }\n return clientContextProps\n }\\n`)\n\n const instanceValues = Object.entries(instances)\n // Collect unique components\n /** @type {Record<string, boolean>} */\n const processedComponent = {}\n\n for (const instanceData of instanceValues) {\n addComponentAndDependencies(instanceData[1].componentId, processedComponent, this.sharedFunctions)\n }\n\n // Add plugin dependencies explicitly if they are standalone\n for (const plugin of this.plugins) {\n if (plugin && plugin._extractedComponents && Array.isArray(plugin._extractedComponents)) {\n for (const compPath of plugin._extractedComponents) {\n for (const id of Object.keys(this.sharedFunctions)) {\n if (compPath.endsWith(`/${id}.html`) || compPath.endsWith(`\\\\${id}.html`) || compPath === id || compPath.endsWith(`/${id}`)) {\n addComponentAndDependencies(id, processedComponent, this.sharedFunctions)\n }\n }\n }\n }\n }\n\n // Force inclusion of all components that evaluate something inside\n // This is required because if a parent is ONLY instantiated via script dynamically,\n // it might not be in instances or plugin explicit references.\n for (const [componentId, fnData] of Object.entries(this.sharedFunctions)) {\n // \"forcing all imperative components into the final chunks bundle, is fine, but it must not include the children of the imperative components since the imperative should load its own dependent components.\"\n if (fnData.script && fnData.script.content) {\n const scriptContent = fnData.script.content.replace(/\\s+/g, '')\n if (scriptContent !== 'function(){}') {\n processedComponent[componentId] = true\n }\n } else if (fnData.script && fnData.script.components && fnData.script.components.length > 0) {\n processedComponent[componentId] = true\n } else if (hasObjectKeys(fnData.defaultValues)) {\n processedComponent[componentId] = true\n }\n }\n\n const processedComponentKeys = Object.keys(processedComponent).sort()\n const regex = /[-.:]/g\n const namespace = 'coralite-component:'\n\n // Generate ESM imports for each component script\n for (const componentId of processedComponentKeys) {\n if (this.sharedFunctions[componentId]) {\n const safeId = componentId.replace(regex, '_')\n entryCodeParts.push(`import component_${safeId} from \"${namespace}${componentId}\";\\n`)\n }\n }\n\n // Map imports to the functions object\n entryCodeParts.push('const coraliteComponentFunctions = {\\n')\n for (const componentId of processedComponentKeys) {\n if (this.sharedFunctions[componentId]) {\n entryCodeParts.push(` \"${componentId}\": component_${componentId.replace(regex, '_')},\\n`)\n }\n }\n entryCodeParts.push('};\\n')\n\n entryCodeParts.push('const coraliteComponentDefaults = {\\n')\n for (const key of processedComponentKeys) {\n if (this.sharedFunctions[key] && this.sharedFunctions[key].defaultValues) {\n const normalizedDefaults = normalizeObjectFunctions(this.sharedFunctions[key].defaultValues, astTransformer)\n\n entryCodeParts.push(` \"${key}\": (() => {\\n`)\n entryCodeParts.push(` const defaults = ${serialize(normalizedDefaults)};\\n`)\n entryCodeParts.push(` return defaults;\\n`)\n entryCodeParts.push(` })(),\\n`)\n } else {\n entryCodeParts.push(` \"${key}\": {},\\n`)\n }\n }\n entryCodeParts.push('};\\n')\n\n entryCodeParts.push('const coraliteComponentStyles = {\\n')\n for (const key of processedComponentKeys) {\n if (this.sharedFunctions[key] && this.sharedFunctions[key].styles) {\n entryCodeParts.push(` \"${key}\": ${JSON.stringify(this.sharedFunctions[key].styles)},\\n`)\n }\n }\n entryCodeParts.push('};\\n')\n\n const coraliteElementPath = fileURLToPath(import.meta.resolve('./coralite-element.js'))\n\n entryCodeParts.push(`const globalClientHooks = {\n onBeforeComponentRender: [${this.scriptModules.map((_, i) => `onBeforeComponentRender_${i}`).join(', ')}].filter(Boolean),\n onAfterComponentRender: [${this.scriptModules.map((_, i) => `onAfterComponentRender_${i}`).join(', ')}].filter(Boolean),\n onDisconnected: [${this.scriptModules.map((_, i) => `onDisconnected_${i}`).join(', ')}].filter(Boolean)\n };\\n`)\n\n entryCodeParts.push(`import { createCoraliteClass } from ${JSON.stringify(coraliteElementPath)};\\n`)\n entryCodeParts.push('\\nexport { getClientContext, getSetups, createCoraliteClass, globalClientHooks };\\n')\n\n const entryPoints = {\n 'chunk-shared': entryCodeParts.join('').trimEnd()\n }\n\n // Create virtual entry points for each component\n for (const componentId of processedComponentKeys) {\n if (this.sharedFunctions[componentId]) {\n const safeId = componentId.replace(regex, '_')\n let componentEntryCode = ''\n\n const hasScript = this.sharedFunctions[componentId].script && this.sharedFunctions[componentId].script.content && this.sharedFunctions[componentId].script.content.trim() !== 'function(){}' && this.sharedFunctions[componentId].script.content.trim() !== 'function() {}' && this.sharedFunctions[componentId].script.content.trim() !== 'function() { }'\n const hasState = this.sharedFunctions[componentId].script && this.sharedFunctions[componentId].script.stateContent\n\n if (hasScript || hasState) {\n componentEntryCode += `import * as componentModule_${safeId} from \"${namespace}${componentId}\";\\n`\n }\n\n // Use a WeakMap to map original nodes to a unique index\n const nodeMap = new WeakMap()\n const state = { counter: 0 }\n\n cleanAST(this.sharedFunctions[componentId].templateAST, nodeMap, state)\n const templateHTML = serialize(this.sharedFunctions[componentId].templateAST ? render(this.sharedFunctions[componentId].templateAST, { decodeEntities: false }) : '')\n const templateValues = serialize(cleanValues(this.sharedFunctions[componentId].templateValues, nodeMap) || {\n attributes: [],\n textNodes: [],\n refs: []\n })\n const styles = JSON.stringify(this.sharedFunctions[componentId].styles || '')\n\n let normalizedDefaults = this.sharedFunctions[componentId].defaultValues || {}\n if (this.sharedFunctions[componentId].defaultValues) {\n normalizedDefaults = normalizeObjectFunctions(this.sharedFunctions[componentId].defaultValues, astTransformer)\n }\n const defaults = serialize(normalizedDefaults)\n const attributes = serialize(this.sharedFunctions[componentId].script?.attributes || {})\n const hydrationMap = serialize(generateHydrationMap(this.sharedFunctions[componentId].templateAST, this.sharedFunctions[componentId].templateValues))\n const getters = serialize(this.sharedFunctions[componentId].getters || this.sharedFunctions[componentId].script?.getters || {})\n const dependencies = JSON.stringify(this.sharedFunctions[componentId].components || [])\n\n let normalizedSlots = this.sharedFunctions[componentId].slots || {}\n if (this.sharedFunctions[componentId].slots) {\n normalizedSlots = normalizeObjectFunctions(this.sharedFunctions[componentId].slots, astTransformer)\n }\n const slots = serialize(normalizedSlots)\n\n componentEntryCode += `\nexport default {\n componentId: \"${componentId}\",\n templateHTML: ${templateHTML},\n templateValues: ${templateValues},\n styles: ${styles},\n attributes: ${attributes},\n hydrationMap: ${hydrationMap},\n getters: ${getters},\n defaultValues: (() => { const defaults = ${defaults}; return defaults; })(),\n slots: (() => { const slots = ${slots}; return slots; })(),\n dependencies: ${dependencies},\n imports: {},\n script: ${hasScript ? `componentModule_${safeId}.script` : 'null'},\n state: ${hasState ? `componentModule_${safeId}.state` : 'null'}\n};\n`\n entryPoints[componentId] = componentEntryCode\n }\n }\n\n const resolvedImportMap = {}\n\n // Use config's import map if available\n const userImportMap = this.options?.importMap || {}\n\n // Since we cannot pass raw code directly as values in the entryPoints object to esbuild,\n // we need to pass virtual paths.\n /** @type {Record<string, string>} */\n const virtualEntryPoints = {}\n for (const key of Object.keys(entryPoints)) {\n virtualEntryPoints[key] = `virtual-entry-point:${key}`\n }\n\n // Build and bundle\n const result = await build({\n entryPoints: virtualEntryPoints,\n bundle: true,\n write: false,\n treeShaking: true,\n splitting: true,\n metafile: true,\n minify: mode === 'production',\n sourcemap: mode === 'production' ? 'external' : 'inline',\n outdir: 'assets/js',\n entryNames: '[name]-[hash]',\n chunkNames: '[name]-[hash]',\n format: 'esm',\n sourceRoot: pathToFileURL(process.cwd()).href,\n define: {\n global: 'window',\n __dirname: '\"\"',\n __filename: '\"\"'\n },\n plugins: [\n nodeModulesPolyfillPlugin(),\n {\n name: 'coralite-import-map-resolver',\n setup: (pluginBuild) => {\n // Regex to catch bare specifiers (doesn't start with ., .., /, or http)\n const bareSpecifierRegex = /^[^.\\/]|^\\.[^.\\/]|^\\.\\.[^\\/]/\n\n pluginBuild.onResolve({ filter: bareSpecifierRegex }, (args) => {\n // Only intercept specifiers inside generated component scripts/files.\n // Do not externalize entry points themselves.\n if (args.kind === 'entry-point') {\n return null\n }\n\n // Do not externalize if the path resolves to a virtual module\n if (args.namespace === 'coralite-entry') {\n return null\n }\n\n // Check for Coralite internal modules first\n if (args.path.startsWith('coralite-component:') ||\n args.path.startsWith('coralite-script-module:') ||\n args.path === 'chunk-shared') {\n return null\n }\n\n if (args.path === 'coralite') {\n const utilsPath = fileURLToPath(import.meta.resolve('./utils/core.js'))\n const pluginPath = fileURLToPath(import.meta.resolve('./plugin.js'))\n\n return {\n path: 'coralite',\n namespace: 'coralite-entry',\n pluginData: {\n contents: `\n export { defineComponent } from '${utilsPath.replace(/\\\\/g, '/')}';\n export { definePlugin } from '${pluginPath.replace(/\\\\/g, '/')}';\n `\n }\n }\n }\n\n if (args.path === 'coralite/utils') {\n return {\n path: fileURLToPath(import.meta.resolve('./utils/index.js'))\n }\n }\n\n // Do not externalize if the entry point name actually matches a bare specifier\n if (Object.hasOwn(entryPoints, args.path)) {\n return null\n }\n\n // Ignore absolute URLs that are already explicitly defined\n if (args.path.startsWith('http')) {\n return {\n path: args.path,\n external: true\n }\n }\n\n // Check if the user provided an explicit override in coralite.config.js\n if (userImportMap[args.path]) {\n resolvedImportMap[args.path] = userImportMap[args.path]\n return {\n path: userImportMap[args.path],\n external: true\n }\n }\n })\n }\n },\n {\n name: 'coralite-virtual-modules',\n setup: (pluginBuild) => {\n pluginBuild.onResolve({ filter: /^virtual-entry-point:/ }, args => {\n const key = args.path.replace('virtual-entry-point:', '')\n if (entryPoints[key]) {\n return {\n path: key,\n namespace: 'coralite-entry'\n }\n }\n })\n\n pluginBuild.onLoad({\n filter: /.*/,\n namespace: 'coralite-entry'\n }, args => {\n if (args.pluginData && args.pluginData.contents) {\n return {\n contents: args.pluginData.contents,\n loader: 'js',\n resolveDir: process.cwd()\n }\n }\n\n if (entryPoints[args.path]) {\n return {\n contents: entryPoints[args.path],\n loader: 'js',\n resolveDir: process.cwd()\n }\n }\n })\n }\n },\n {\n name: 'coralite-component-resolver',\n setup: (pluginBuild) => {\n // Catch the script module, associate with real file paths\n const componentRegex = new RegExp(`^${namespace}`)\n\n pluginBuild.onResolve({ filter: componentRegex }, args => {\n const componentId = args.path.replace(namespace, '')\n const sharedFn = this.sharedFunctions[componentId]\n\n return {\n path: sharedFn.filePath,\n pluginData: { componentId }\n }\n })\n\n // Handle script modules\n const moduleRegex = new RegExp(`^${moduleNamespace}`)\n pluginBuild.onResolve({ filter: moduleRegex }, args => {\n const index = parseInt(args.path.replace(moduleNamespace, ''), 10)\n return {\n path: args.path,\n namespace: 'coralite-script-module',\n pluginData: { index }\n }\n })\n\n pluginBuild.onLoad({\n filter: /.*/,\n namespace: 'coralite-script-module'\n }, args => {\n const index = args.pluginData.index\n const module = this.scriptModules[index]\n let contents = ''\n\n // Generate config object\n const configContent = module.config\n ? `const pluginConfig = ${JSON.stringify(module.config)};`\n : 'const pluginConfig = {};'\n\n contents += configContent + '\\n'\n\n // Generate setup function\n const setupFn = module.setup ? normalizeFunction(module.setup) : 'null'\n contents += `export const runSetup = async (context) => {\n const setup = ${setupFn};\n if (!setup) return {};\n const contextObject = Object.create(context);\n contextObject.config = pluginConfig;\n return await setup(contextObject);\n };\\n`\n\n const beforeFn = module.onBeforeComponentRender ? normalizeFunction(module.onBeforeComponentRender) : 'null'\n contents += `export const onBeforeComponentRender = ${beforeFn};\\n`\n\n const afterFn = module.onAfterComponentRender ? normalizeFunction(module.onAfterComponentRender) : 'null'\n contents += `export const onAfterComponentRender = ${afterFn};\\n`\n\n const disconnectedFn = module.onDisconnected ? normalizeFunction(module.onDisconnected) : 'null'\n contents += `export const onDisconnected = ${disconnectedFn};\\n`\n\n // Generate client context state\n contents += 'export const clientContextProps = {\\n'\n if (module.context) {\n contents += ` \"${module.name}\": async (globalContext) => {\\n`\n contents += ' const props = {};\\n'\n for (const key in module.context) {\n if (Object.hasOwn(module.context, key)) {\n if (['id', 'state', 'page', 'root', 'signal'].includes(key)) {\n throw new CoraliteError(`Reserved context key '${key}' cannot be used in plugin context.`)\n }\n const fn = normalizeFunction(module.context[key])\n contents += ` props[\"${key}\"] = await (async (globalContext) => {\n const fn = ${fn};\n const pluginContext = new Proxy(globalContext, {\n get (target, prop) {\n if (prop === 'config') return pluginConfig;\n return target[prop];\n },\n set (target, prop, value) {\n return Reflect.set(target, prop, value);\n }\n });\n const phase2 = await fn(pluginContext);\n return (localContext) => phase2(localContext);\n })(globalContext);\\n`\n }\n }\n contents += ' const resolver = (localContext) => {\\n'\n contents += ' const bound = {};\\n'\n contents += ' for (const [key, fn] of Object.entries(props)) {\\n'\n contents += ' bound[key] = fn(localContext);\\n'\n contents += ' }\\n'\n contents += ' return bound;\\n'\n contents += ' };\\n'\n contents += ' Object.assign(resolver, props);\\n'\n contents += ' return resolver;\\n'\n contents += ' },\\n'\n }\n contents += '};\\n'\n\n return {\n contents,\n loader: 'js',\n resolveDir: module.rootDir || (module.filePath ? dirname(module.filePath) : process.cwd())\n }\n })\n\n // Provide the script content to esbuild when it loads those file paths\n pluginBuild.onLoad({\n filter: /.*/\n }, args => {\n if (!args.pluginData || !args.pluginData.componentId) {\n return\n }\n\n const sharedFn = this.sharedFunctions[args.pluginData.componentId]\n let contents = ''\n\n\n if (sharedFn.script && sharedFn.script.content) {\n const padding = '\\n'.repeat(Math.max(0, sharedFn.script.lineOffset || 0))\n\n // More robust way to strip 'data' from defineComponent call\n let strippedContent = sharedFn.script.content\n\n try {\n const ast = parseJS(strippedContent, {\n ecmaVersion: 'latest',\n sourceType: 'module'\n })\n let dataStart = -1\n let dataEnd = -1\n\n walkJS(ast, {\n CallExpression (node) {\n if (node.callee.type === 'Identifier' && node.callee.name === 'defineComponent') {\n const firstArg = node.arguments[0]\n if (firstArg && firstArg.type === 'ObjectExpression') {\n const dataProp = firstArg.properties.find(p => p.type === 'Property' && p.key?.type === 'Identifier' && p.key?.name === 'data')\n // @ts-ignore\n if (dataProp && dataProp.type === 'Property') {\n // @ts-ignore\n dataStart = dataProp.start\n // @ts-ignore\n dataEnd = dataProp.end\n }\n }\n }\n }\n })\n\n if (dataStart !== -1) {\n let start = dataStart\n let end = dataEnd\n\n // Handle comma to avoid syntax errors\n const afterContent = strippedContent.slice(end)\n const trailingComma = afterContent.match(/^\\s*,/)\n if (trailingComma) {\n end += trailingComma[0].length\n } else {\n const beforeContent = strippedContent.slice(0, start)\n const leadingComma = beforeContent.match(/,\\s*$/)\n if (leadingComma) {\n start -= leadingComma[0].length\n }\n }\n strippedContent = strippedContent.slice(0, start) + strippedContent.slice(end)\n }\n } catch {\n // Fallback to regex if AST parsing fails\n strippedContent = strippedContent.replace(/data\\s*:\\s*async\\s*function\\s*\\([^\\)]*\\)\\s*\\{[\\s\\S]*?\\}(?=\\s*,|\\s*\\})/, '/* data stripped */')\n strippedContent = strippedContent.replace(/async\\s*data\\s*\\([^\\)]*\\)\\s*\\{[\\s\\S]*?\\}(?=\\s*,|\\s*\\})/, '/* data stripped */')\n }\n\n contents += `${padding}export const script = ${strippedContent};\\n`\n contents += `export default script;\\n`\n } else {\n contents += `export const script = null;\\n`\n contents += `export default null;\\n`\n }\n\n if (sharedFn.script && sharedFn.script.stateContent) {\n const padding = '\\n'.repeat(Math.max(0, sharedFn.script.stateLineOffset || 0))\n contents += `${padding}export const state = ${sharedFn.script.stateContent};\\n`\n } else {\n contents += `export const state = null;\\n`\n }\n\n return {\n contents,\n loader: 'js',\n resolveDir: sharedFn.filePath ? dirname(sharedFn.filePath) : process.cwd()\n }\n })\n }\n }\n ]\n })\n\n const manifest = {}\n if (result.metafile && result.metafile.outputs) {\n for (const [outputPath, meta] of Object.entries(result.metafile.outputs)) {\n if (meta.entryPoint) {\n const entryPoint = meta.entryPoint\n const cleanEntry = entryPoint.includes(':') ? entryPoint.split(':').pop() : entryPoint\n\n // STRIP THE EXTENSION (Fixes E2E Bootstrapper Timeout)\n const tagName = parse(cleanEntry).name\n\n // USE RELATIVE PATHS (Fixes the chunks/ 404 issue)\n const relativePath = relative('assets/js', outputPath).replace(/\\\\/g, '/')\n\n manifest[tagName] = relativePath\n }\n }\n }\n\n const outdirAbs = resolve('assets/js')\n const outputFiles = {}\n\n if (result.outputFiles) {\n for (const file of result.outputFiles) {\n // Keep the relative path for the output file creation on disk\n const relativePath = relative(outdirAbs, file.path).replace(/\\\\/g, '/')\n\n outputFiles[relativePath] = {\n ...file,\n hashedPath: relativePath,\n text: file.text\n }\n }\n }\n\n return {\n manifest,\n outputFiles,\n importMap: resolvedImportMap\n }\n}\n", "import { CoraliteError } from './errors.js'\n\n/**\n * @import {\n * CoraliteModule,\n * CoraliteComponent,\n * CoraliteComponentResult,\n * } from '../../types/index.js'\n */\n\nconst KEBAB_REGEX = /[-|:]([a-z])/g\n\n/**\n * Converts a kebab-case string to camelCase\n * @param {string} str - The kebab-case string to convert\n * @returns {string} - The camelCase version of the string\n */\nexport function kebabToCamel (str) {\n // replace each dash followed by a letter with the uppercase version of the letter\n return str.replace(KEBAB_REGEX, function (match, letter) {\n return letter.toUpperCase()\n })\n}\n\n/**\n * Converts all keys in an object from kebab-case to camelCase\n * @template T\n * @param {Record<string, T>} object - The object with kebab-case keys\n * @returns {Record<string, T>} - A new object with camelCase keys\n */\nexport function cleanKeys (object) {\n /** @type {Record<string, T>} */\n const result = {}\n\n for (const [key, value] of Object.entries(object)) {\n result[key] = value\n\n const camelKey = kebabToCamel(key)\n if (camelKey !== key) {\n result[camelKey] = value\n }\n }\n\n return result\n}\n\n/**\n * Recursively clones an object or array and normalizes any function state\n * it finds into a string representation that preserves standard function syntax,\n * bypassing ES6 shorthand method serialization issues.\n * @param {any} target - The object or array to normalize.\n * @param {Function} [transform] - Optional transform function for each node.\n * @param {WeakMap} [seen=new WeakMap()] - Map of seen objects to handle circular references.\n * @returns {any} A deeply cloned object with normalized functions.\n */\nexport function normalizeObjectFunctions (target, transform = null, seen = new WeakMap()) {\n if (typeof transform === 'function') {\n const transformed = transform(target)\n if (transformed !== target) {\n return transformed\n }\n }\n\n if (typeof target !== 'object' || target === null) {\n return target\n }\n\n if (seen.has(target)) {\n return seen.get(target)\n }\n\n if (Array.isArray(target)) {\n const arr = []\n seen.set(target, arr)\n for (let i = 0; i < target.length; i++) {\n arr.push(normalizeObjectFunctions(target[i], transform, seen))\n }\n return arr\n }\n\n const obj = {}\n seen.set(target, obj)\n for (const key in target) {\n if (Object.hasOwn(target, key)) {\n if (typeof target[key] === 'function') {\n const normalizedString = normalizeFunction(target[key])\n const originalFunction = target[key]\n\n const wrapper = function () {\n return originalFunction.apply(this, arguments)\n }\n wrapper.toString = () => normalizedString\n obj[key] = wrapper\n } else {\n obj[key] = normalizeObjectFunctions(target[key], transform, seen)\n }\n }\n }\n\n return obj\n}\n\n/**\n * Checks whether the given object is an object and has at least one own key.\n * @param {any} obj - The object to check.\n * @returns {boolean} True if the object is truthy and has keys, otherwise false.\n */\nexport function hasObjectKeys (obj) {\n return obj && typeof obj === 'object' && Object.keys(obj).length > 0\n}\n\n/**\n * Merges two arrays, returning a new array with unique items.\n * Uses JSON.stringify for deep comparison of object elements, preserving object uniqueness correctly.\n * @param {Array<any>} [arr1] - The first array.\n * @param {Array<any>} [arr2] - The second array.\n * @returns {Array<any>} A new array with unique values from both input arrays.\n */\nexport function mergeUniqueObjects (arr1, arr2) {\n const all = [...(arr1 || []), ...(arr2 || [])]\n const seen = new Set()\n return all.filter(item => {\n const key = typeof item === 'object' ? JSON.stringify(item) : item\n if (seen.has(key)) {\n return false\n }\n seen.add(key)\n return true\n })\n}\n\n/**\n * Normalizes function declarations to ensure consistent formatting.\n * Converts shorthand method syntax to full function declarations where needed,\n * while preserving arrow functions and existing full declarations.\n *\n * @param {Function} func - The function to normalize\n * @returns {string} The normalized function string representation\n */\nexport function normalizeFunction (func) {\n const original = func.toString().trim()\n\n const firstBrace = original.indexOf('{')\n const firstArrow = original.indexOf('=>')\n\n const isArrow = firstArrow !== -1 && (firstBrace === -1 || firstArrow < firstBrace)\n\n if (isArrow) {\n return original\n }\n\n // For non-arrows, extract header to check for shorthand\n const header = firstBrace !== -1 ? original.slice(0, firstBrace).trim() : original\n\n const isStandard = header.startsWith('function') || header.startsWith('async function')\n\n if (isStandard) {\n return original\n }\n\n // Handle Method Shorthand\n if (header.startsWith('async ')) {\n if (header.startsWith('async get ') || header.startsWith('async set ')) {\n return original\n }\n\n return original.replace(/^async\\s+([$\\w]+)\\s*\\(/, 'async function(')\n } else {\n if (header.startsWith('get ') || header.startsWith('set ')) {\n return original\n }\n\n return original.replace(/^([$\\w]+)\\s*\\(/, 'function(')\n }\n}\n\n\n/**\n * Recursively clones an AST node and its children, ensuring that\n * inner references (like parents and slots) point to the newly cloned nodes.\n *\n * @param {Map<Object, Object>} nodeMap - A map tracking original nodes to their newly cloned counterparts.\n * @param {Object} node - The current AST node being cloned.\n * @param {Object} [parent] - The parent node reference to assign to the clone.\n * @returns {Object} The newly cloned node.\n */\nexport function cloneNode (nodeMap, node, parent) {\n const newNode = Object.create(Object.getPrototypeOf(node))\n\n // Copy all own enumerable properties\n Object.assign(newNode, node)\n\n if (parent) {\n newNode.parent = parent\n }\n\n if (newNode.attribs) {\n newNode.attribs = { ...newNode.attribs }\n }\n\n // Register in map\n nodeMap.set(node, newNode)\n\n // Recursively clone children\n if (node.children) {\n const children = node.children\n const length = children.length\n const clonedChildren = new Array(length)\n newNode.children = clonedChildren\n\n for (let i = 0; i < length; i++) {\n const clonedChild = cloneNode(nodeMap, children[i], newNode)\n clonedChildren[i] = clonedChild\n if (i > 0) {\n clonedChild.prev = clonedChildren[i - 1]\n clonedChildren[i - 1].next = clonedChild\n }\n }\n }\n\n // Update slot references to point to new cloned nodes\n if (node.slots) {\n const slots = node.slots\n const length = slots.length\n const clonedSlots = new Array(length)\n for (let i = 0; i < length; i++) {\n const slot = slots[i]\n const clonedSlot = { ...slot }\n if (slot.node) {\n const clonedNode = nodeMap.get(slot.node)\n if (clonedNode) {\n clonedSlot.node = clonedNode\n }\n }\n clonedSlots[i] = clonedSlot\n }\n newNode.slots = clonedSlots\n }\n\n // Preserve the enhanced flag without re-running enhanceNode\n Object.defineProperty(newNode, '__coralite_enhanced__', {\n value: true,\n enumerable: false,\n configurable: true\n })\n\n return newNode\n}\n\n/**\n * Creates a shallow copy of a CoraliteModule with a deep clone of its DOM tree (template) and re-linked internal references to enable safe independent mutation.\n *\n * Top-level non-DOM state (id, path, script, isTemplate, lineOffset) are shallow copied. Nested objects within these state (e.g., path) remain shared references. Only DOM-related structures undergo deep cloning and reference re-linking to isolate mutations from the original module.\n *\n * @param {CoraliteModule} originalModule - Module to clone.\n * @returns {CoraliteModule}\n */\nexport function cloneModuleInstance (originalModule) {\n const nodeMap = new Map()\n\n // Clone the main template tree\n const newTemplate = cloneNode(nodeMap, originalModule.template, null)\n\n // Reconstruct the 'values' object\n const newValues = {\n attributes: originalModule.values.attributes.map(item => ({\n ...item,\n element: nodeMap.get(item.element)\n })),\n textNodes: originalModule.values.textNodes.map(item => ({\n ...item,\n textNode: nodeMap.get(item.textNode)\n })),\n refs: originalModule.values.refs.map(item => ({\n ...item,\n element: nodeMap.get(item.element)\n }))\n }\n\n // Reconstruct customElements list\n const newCustomElements = originalModule.customElements.map(el => nodeMap.get(el))\n\n // Reconstruct slotElements\n const newSlotElements = {}\n if (originalModule.slotElements) {\n for (const modId in originalModule.slotElements) {\n newSlotElements[modId] = {}\n const slotGroup = originalModule.slotElements[modId]\n\n for (const slotName in slotGroup) {\n const slotItem = slotGroup[slotName]\n newSlotElements[modId][slotName] = {\n ...slotItem,\n element: nodeMap.get(slotItem.element)\n }\n }\n }\n }\n\n // Return the new module structure\n return {\n ...originalModule,\n template: newTemplate,\n values: newValues,\n customElements: newCustomElements,\n // @ts-ignore\n slotElements: newSlotElements\n }\n}\n\n/**\n * Creates a deep copy of a CoraliteComponent with re-linked internal references to enable safe independent mutation.\n *\n * @param {CoraliteComponent & CoraliteComponentResult} originalDocument - Document to clone.\n * @returns {CoraliteComponent & CoraliteComponentResult}\n */\nexport function cloneComponentInstance (originalDocument) {\n const nodeMap = new Map()\n const newRoot = cloneNode(nodeMap, originalDocument.root, null)\n\n const newCustomElements = originalDocument.customElements.map(el => nodeMap.get(el))\n const newTempElements = originalDocument.tempElements ? originalDocument.tempElements.map(el => nodeMap.get(el)) : []\n const newSkipRenderElements = originalDocument.skipRenderElements ? originalDocument.skipRenderElements.map(el => nodeMap.get(el)) : []\n\n return {\n ...originalDocument,\n state: { ...originalDocument.state },\n root: newRoot,\n customElements: newCustomElements,\n tempElements: newTempElements,\n skipRenderElements: newSkipRenderElements\n }\n}\n\n/**\n * Calculates the DOM path from a node to the root.\n * @param {Object} node - The node to calculate the path for.\n * @param {Object} root - The root node.\n * @returns {Array<number>} An array of indices representing the path.\n */\nexport function getNodePath (node, root) {\n const path = []\n let current = node\n while (current && current !== root) {\n const parent = current.parent\n if (!parent) {\n break\n }\n const index = parent.children.indexOf(current)\n if (index === -1) {\n break\n }\n path.unshift(index)\n current = parent\n }\n return path\n}\n\n/**\n * Generates a hydration map for the client.\n * @param {Array<Object>} templateNodes - The component's template nodes.\n * @param {Object} templateValues - The component's template values.\n * @returns {Object} The hydration map.\n */\nexport function generateHydrationMap (templateNodes, templateValues) {\n const map = {\n texts: [],\n attributes: [],\n refs: []\n }\n\n if (!templateNodes || !templateValues) {\n return map\n }\n\n const root = templateNodes.length > 0 ? templateNodes[0].parent : { children: templateNodes }\n\n if (templateValues.textNodes) {\n for (const item of templateValues.textNodes) {\n if (item.textNode) {\n const isHtml = item.type === 'html'\n const targetNode = isHtml ? item.textNode.parent : item.textNode\n\n map.texts.push({\n path: getNodePath(targetNode, root),\n template: item.textNode.data,\n type: isHtml ? 'html' : 'text'\n })\n }\n }\n }\n\n if (templateValues.attributes) {\n for (const item of templateValues.attributes) {\n if (item.element && item.element.attribs) {\n const originalValue = item.element.attribs[item.name]\n map.attributes.push({\n path: getNodePath(item.element, root),\n name: item.name,\n template: originalValue\n })\n }\n }\n }\n\n if (templateValues.refs) {\n for (const item of templateValues.refs) {\n if (item.element) {\n map.refs.push({\n path: getNodePath(item.element, root),\n name: item.name\n })\n }\n }\n }\n\n return map\n}\n\n/**\n * Recursively adds a component and its dependencies to a tracking object.\n *\n * @param {string} componentId - The ID of the component to add.\n * @param {Object.<string, boolean>} processed - The object tracking processed components.\n * @param {Object.<string, any>} sharedFunctions - The map of shared component functions.\n */\nexport function addComponentAndDependencies (componentId, processed, sharedFunctions) {\n if (!processed[componentId] && sharedFunctions[componentId]) {\n processed[componentId] = true\n\n // Add all dependencies of this component\n const dependencies = sharedFunctions[componentId].components || []\n for (const depId of dependencies) {\n addComponentAndDependencies(depId, processed, sharedFunctions)\n }\n }\n}\n\n/**\n * Recursively clones an AST node and its children, stripping circular references\n * and assigning unique IDs for client-side hydration.\n *\n * @param {Array<Object>} nodes - The nodes to clean.\n * @param {WeakMap} nodeMap - Map to track original nodes to their unique IDs.\n * @param {Object} state - Object containing the current node counter.\n * @returns {Array<Object>|null} The cleaned AST nodes.\n */\nexport function cleanAST (nodes, nodeMap, state) {\n if (!nodes) {\n return null\n }\n\n return nodes.map((node) => {\n const cloned = { ...node }\n // Assign unique ID for token mapping\n const id = state.counter++\n nodeMap.set(node, id)\n cloned._id = id\n\n // Remove circular references\n delete cloned.parent\n delete cloned.prev\n delete cloned.next\n delete cloned.slots\n\n if (cloned.children) {\n cloned.children = cleanAST(cloned.children, nodeMap, state)\n }\n return cloned\n })\n}\n\n/**\n * Cleans the template values object, mapping original node references to unique IDs.\n *\n * @param {Object} values - The values object to clean.\n * @param {WeakMap} nodeMap - Map of original nodes to their unique IDs.\n * @returns {Object|null} The cleaned values object.\n */\nexport function cleanValues (values, nodeMap) {\n if (!values) {\n return null\n }\n\n const result = { ...values }\n\n if (result.attributes) {\n result.attributes = result.attributes.map(item => {\n const cloned = { ...item }\n cloned.elementId = nodeMap.get(item.element)\n delete cloned.element\n return cloned\n })\n }\n\n if (result.textNodes) {\n result.textNodes = result.textNodes.map(item => {\n const cloned = { ...item }\n cloned.textNodeId = nodeMap.get(item.textNode)\n delete cloned.textNode\n return cloned\n })\n }\n\n if (result.refs) {\n result.refs = result.refs.map(item => {\n const cloned = { ...item }\n cloned.elementId = nodeMap.get(item.element)\n delete cloned.element\n return cloned\n })\n }\n return result\n}\n\n/**\n * Safely merges partial plugin updates into the main context object.\n * Deeply merges plain objects and overwrites other types (arrays, primitives, etc.).\n *\n * @param {any} current - The current state object.\n * @param {any} patch - The patch object containing updates.\n * @returns {any} The newly merged state object.\n */\nexport function mergePluginState (current, patch) {\n if (!patch || typeof patch !== 'object') {\n return current\n }\n\n const result = { ...current }\n\n for (const key of Object.keys(patch)) {\n const patchValue = patch[key]\n const currentValue = result[key]\n\n // If both are plain objects, merge them deeply\n if (\n patchValue && typeof patchValue === 'object' && !Array.isArray(patchValue) &&\n currentValue && typeof currentValue === 'object' && !Array.isArray(currentValue)\n ) {\n result[key] = mergePluginState(currentValue, patchValue)\n } else {\n // Otherwise, overwrite (Arrays, strings, numbers, etc.)\n result[key] = patchValue\n }\n }\n\n return result\n}\n\n/**\n * Creates a reactive proxy that triggers a callback on changes.\n * Supports deep reactivity via lazy proxying of nested objects.\n *\n * @param {Object} target - The object to proxy.\n * @param {Function} onChange - Callback triggered when a property is set or deleted.\n * @param {WeakMap} [proxies=new WeakMap()] - Cache for existing proxies to handle circular references and identity.\n * @returns {Proxy} The reactive proxy.\n */\nexport function createReactiveProxy (target, onChange, proxies = new WeakMap()) {\n if (proxies.has(target)) {\n return proxies.get(target)\n }\n\n const handler = {\n get (target, property, receiver) {\n const value = Reflect.get(target, property, receiver)\n if (value !== null && typeof value === 'object' && !(typeof Node !== 'undefined' && value instanceof Node)) {\n return createReactiveProxy(value, onChange, proxies)\n }\n return value\n },\n set (target, property, value, receiver) {\n const oldValue = target[property]\n if (oldValue === value && property in target) {\n return true\n }\n\n const result = Reflect.set(target, property, value, receiver)\n if (result) {\n onChange({\n property,\n value,\n oldValue,\n target\n })\n }\n return result\n },\n deleteProperty (target, property) {\n const hadProperty = Object.prototype.hasOwnProperty.call(target, property)\n const oldValue = target[property]\n const result = Reflect.deleteProperty(target, property)\n if (result && hadProperty) {\n onChange({\n property,\n value: undefined,\n oldValue,\n target,\n deleted: true\n })\n }\n return result\n }\n }\n\n const proxy = new Proxy(target, handler)\n proxies.set(target, proxy)\n return proxy\n}\n\n/**\n * Creates a read-only proxy that throws on mutation attempts.\n * @param {Object} target - The object to proxy.\n * @param {WeakMap} [proxies=new WeakMap()] - Cache for existing proxies.\n * @returns {Proxy} The read-only proxy.\n */\nexport function createReadOnlyProxy (target, proxies = new WeakMap()) {\n if (proxies.has(target)) {\n return proxies.get(target)\n }\n\n const handler = {\n get (target, property, receiver) {\n const value = Reflect.get(target, property, receiver)\n if (value !== null && typeof value === 'object' && !(typeof Node !== 'undefined' && value instanceof Node)) {\n return createReadOnlyProxy(value, proxies)\n }\n return value\n },\n set () {\n throw new CoraliteError('Cannot mutate state inside a getter. State is read-only here.')\n },\n deleteProperty () {\n throw new CoraliteError('Cannot delete state inside a getter. State is read-only here.')\n }\n }\n\n const proxy = new Proxy(target, handler)\n\n proxies.set(target, proxy)\n\n return proxy\n}\n\n/**\n * Defines a Coralite component.\n * On the client, this acts as an identity function for type safety and HRM.\n * @param {Object} options - Component options\n * @returns {Object} The component options\n */\nexport function defineComponent (options) {\n return options\n}\n", "import { parse as parseJS } from 'acorn'\nimport { simple as walkJS } from 'acorn-walk'\nimport render from 'dom-serializer'\nimport { sanitize } from 'isomorphic-dompurify'\nimport { parseHTML } from './parse.js'\nimport { isCoraliteNode } from '../types.js'\nimport { createCoraliteTextNode, relinkChildren } from './dom.js'\nimport { BOOLEAN_ATTRIBUTES } from '../tags.js'\n\n/**\n * @import {\n * CoraliteElement,\n * CoraliteModuleDefinition,\n * CoraliteTextNode,\n * ScriptContent\n * } from '../../../types/index.js'\n */\n\nconst astCache = new Map()\n\nfunction getAST (code, locations = false) {\n const cacheKey = `${code}_${locations}`\n if (astCache.has(cacheKey)) {\n return astCache.get(cacheKey)\n }\n const ast = parseJS(code, {\n ecmaVersion: 'latest',\n sourceType: 'module',\n locations\n })\n astCache.set(cacheKey, ast)\n return ast\n}\n\n/**\n * Extracts and normalizes the script content from a component definition.\n *\n * @param {string} code - The raw script content\n * @returns {ScriptContent | null}\n */\nexport function findAndExtractScript (code) {\n const ast = getAST(code, true)\n\n /** @type {ScriptContent | null} */\n let result = null\n const components = new Set()\n\n walkJS(ast, {\n CallExpression (node) {\n if (\n node.callee &&\n node.callee.type === 'Identifier' &&\n node.callee.name === 'defineComponent'\n ) {\n const firstArg = node.arguments[0]\n\n if (firstArg && firstArg.type === 'ObjectExpression') {\n const scriptProp = firstArg.properties.find(\n prop => prop.type === 'Property' &&\n prop.key && prop.key.type === 'Identifier' &&\n prop.key.name === 'script'\n )\n\n if (scriptProp && scriptProp.type === 'Property') {\n const { value, method } = scriptProp\n let startLine = value.loc.start.line - 1\n let prefix = ''\n let content = ''\n\n // Get source slice\n const source = code.slice(value.start, value.end)\n\n if (value.type === 'ArrowFunctionExpression') {\n content = prefix + source\n startLine = value.loc.start.line - 1\n } else if (value.type === 'FunctionExpression') {\n if (method) {\n const isAsync = value.async\n prefix += (isAsync ? 'async ' : '') + 'function script'\n content = prefix + source\n startLine = scriptProp.key.loc.start.line - 1\n } else {\n content = prefix + source\n startLine = value.loc.start.line - 1\n }\n }\n\n result = {\n content,\n lineOffset: startLine\n }\n }\n }\n } else if (\n node.callee &&\n node.callee.type === 'MemberExpression' &&\n node.callee.object &&\n node.callee.object.type === 'Identifier' &&\n node.callee.object.name === 'document' &&\n node.callee.property &&\n node.callee.property.type === 'Identifier' &&\n node.callee.property.name === 'createElement'\n ) {\n const arg = node.arguments[0]\n if (arg && arg.type === 'Literal' && typeof arg.value === 'string') {\n components.add(arg.value)\n }\n }\n }\n })\n\n if (result && components.size > 0) {\n result.components = Array.from(components)\n }\n\n return result\n}\n\n/**\n * Extracts and normalizes the state content from a component definition.\n *\n * @param {string} code - The raw script content\n * @returns {ScriptContent | null}\n */\nexport function findAndExtractProperties (code) {\n const ast = getAST(code, true)\n\n /** @type {ScriptContent | null} */\n let result = null\n\n walkJS(ast, {\n CallExpression (node) {\n if (\n node.callee &&\n node.callee.type === 'Identifier' &&\n node.callee.name === 'defineComponent'\n ) {\n const firstArg = node.arguments[0]\n\n if (firstArg && firstArg.type === 'ObjectExpression') {\n const stateProp = firstArg.properties.find(\n prop => prop.type === 'Property' &&\n prop.key && prop.key.type === 'Identifier' &&\n prop.key.name === 'state'\n )\n\n if (stateProp && stateProp.type === 'Property') {\n const { value, method } = stateProp\n let startLine = value.loc.start.line - 1\n let prefix = ''\n let content = ''\n\n // Get source slice\n const source = code.slice(value.start, value.end)\n\n if (value.type === 'ArrowFunctionExpression') {\n content = prefix + source\n startLine = value.loc.start.line - 1\n } else if (value.type === 'FunctionExpression') {\n if (method) {\n const isAsync = value.async\n prefix += (isAsync ? 'async ' : '') + 'function state'\n content = prefix + source\n startLine = stateProp.key.loc.start.line - 1\n } else {\n content = prefix + source\n startLine = value.loc.start.line - 1\n }\n } else if (value.type === 'ObjectExpression') {\n // Wrap object in a function returning that object\n content = `() => (${source})`\n startLine = value.loc.start.line - 1\n }\n\n result = {\n content,\n lineOffset: startLine\n }\n }\n }\n }\n }\n })\n\n return result\n}\n\n/**\n * Extracts all component tag names dynamically created via document.createElement.\n *\n * @param {string} code - The raw script content\n * @returns {Array<string>} - Array of identified imperative component tags\n */\nexport function findAndExtractImperativeComponents (code) {\n try {\n const ast = getAST(code)\n\n const components = new Set()\n\n walkJS(ast, {\n CallExpression (node) {\n if (\n node.callee &&\n node.callee.type === 'MemberExpression' &&\n node.callee.object &&\n node.callee.object.type === 'Identifier' &&\n node.callee.object.name === 'document' &&\n node.callee.property &&\n node.callee.property.type === 'Identifier' &&\n node.callee.property.name === 'createElement'\n ) {\n const arg = node.arguments[0]\n if (arg && arg.type === 'Literal' && typeof arg.value === 'string' && arg.value.includes('-')) {\n components.add(arg.value)\n }\n }\n }\n })\n\n return [...components]\n } catch {\n return []\n }\n}\n\n/**\n * Extracts global variable names from a module script code using Acorn parsing and AST walking.\n * @param {string} code - The raw script code\n * @returns {Array<string>} - Array of identified global variables\n */\nexport function extractGlobals (code) {\n try {\n const ast = getAST(code)\n\n const globals = new Set()\n walkJS(ast, {\n Identifier (node) {\n globals.add(node.name)\n }\n })\n\n return [...globals]\n } catch {\n return []\n }\n}\n\n/**\n * Transforms Coralite AST nodes into HTML strings for serialization.\n *\n * @param {any} target - The target to transform.\n * @returns {any} The transformed target.\n */\nexport function astTransformer (target) {\n if (isCoraliteNode(target)) {\n // @ts-ignore\n return render(target, { decodeEntities: false })\n }\n\n if (Array.isArray(target) && target.length > 0 && isCoraliteNode(target[0])) {\n // @ts-ignore\n return render(target, { decodeEntities: false })\n }\n\n return target\n}\n\n/**\n * Replaces a token in a Coralite node based on its type, attribute, and content.\n *\n * @param {Object} token - The token to replace.\n * @param {string} token.type - The type of the token ('attribute' or 'text').\n * @param {CoraliteElement|CoraliteTextNode} token.node - The node containing the token.\n * @param {string} [token.attribute] - The attribute name to replace within the node.\n * @param {string} token.content - The content of the token.\n * @param {CoraliteModuleDefinition} token.value - The definition associated with the token.\n */\nexport function replaceToken ({\n type,\n node,\n attribute,\n content,\n value\n}) {\n if (\n type === 'attribute'\n && node.type === 'tag'\n ) {\n if (BOOLEAN_ATTRIBUTES.has(attribute) && (node.attribs[attribute] || '').trim() === content) {\n // @ts-ignore\n const isFalsy = value === 'false' || value === 'null' || value === 'undefined' || value === '0' || value === 0 || value === '' || value === false || value === null || value === undefined\n\n if (isFalsy) {\n delete node.attribs[attribute]\n } else {\n node.attribs[attribute] = ''\n }\n } else if (typeof value === 'string') {\n node.attribs[attribute] = node.attribs[attribute].replace(content, value)\n }\n } else if (node.type === 'text') {\n if (typeof value === 'object' && value !== null) {\n if (Array.isArray(value) || value.type) {\n let nodesArray = Array.isArray(value) ? value : [value]\n\n // inject nodes\n const textSplit = node.data.split(content)\n const childIndex = node.parent.children.indexOf(node)\n const children = []\n\n // append computed tokens in between token split\n for (let i = 0; i < nodesArray.length; i++) {\n const child = nodesArray[i]\n\n if (typeof child !== 'string' && child.type !== 'directive' && typeof child === 'object' && child.type) {\n // update child parent\n // @ts-ignore\n child.parent = node.parent\n // @ts-ignore\n children.push(child)\n }\n }\n\n // replace computed token\n node.parent.children.splice(childIndex, 1,\n createCoraliteTextNode({\n type: 'text',\n data: textSplit[0],\n parent: node.parent\n }),\n // @ts-ignore\n ...children,\n createCoraliteTextNode({\n type: 'text',\n data: textSplit[1],\n parent: node.parent\n })\n )\n relinkChildren(node.parent)\n } else {\n // Handle object values like refs stringification\n node.data = node.data.replace(content, JSON.stringify(value))\n }\n } else {\n // replace token string\n // @ts-ignore\n const newVal = node.data.replace(content, value)\n const isHTML = /<[a-z][\\s\\S]*>/i.test(newVal)\n\n if (isHTML && node.parent\n && node.parent.type === 'tag'\n && node.parent.name === 'c-token'\n ) {\n const sanitized = sanitize(newVal)\n const parsed = parseHTML(sanitized)\n const children = parsed.root.children\n\n // Use the existing object-handling logic by recursing with the children array\n return replaceToken({\n type,\n node,\n attribute,\n content,\n value: children\n })\n }\n node.data = newVal\n }\n }\n}\n", "/**\n * @import {\n * CoraliteCollectionItem,\n * CoraliteComment,\n * CoraliteDirective,\n * CoraliteComponentRoot,\n * CoraliteElement,\n * CoraliteTextNode,\n * CoraliteAnyNode,\n * CoraliteSlotElement } from '../../types/index.js'\n */\n\n/**\n * Check if value is a non-null object\n * @param {any} obj - The value to check\n * @returns {boolean} True if the value is a non-null object\n */\nfunction isObject (obj) {\n return typeof obj === 'object' && obj !== null\n}\n\n/**\n * Checks if an object is a CoraliteElement.\n * @param {any} obj - The object to check.\n * @returns {obj is CoraliteElement} True if the object is a CoraliteElement, false otherwise.\n */\nfunction isCoraliteElement (obj) {\n return isObject(obj) && (obj.type === 'tag' || obj.type === 'script' || obj.type === 'style')\n}\n\n/**\n * Checks if an object is a CoraliteTextNode.\n * @param {any} obj - The object to check.\n * @returns {obj is CoraliteTextNode} True if the object is a CoraliteTextNode, false otherwise.\n */\nfunction isCoraliteTextNode (obj) {\n return isObject(obj) && obj.type === 'text'\n}\n\n/**\n * Checks if an object is a CoraliteComment.\n * @param {any} obj - The object to check.\n * @returns {obj is CoraliteComment} True if the object is a CoraliteComment, false otherwise.\n */\nfunction isCoraliteComment (obj) {\n return isObject(obj) && obj.type === 'comment'\n}\n\n/**\n * Checks if an object is a CoraliteDirective.\n * @param {any} obj - The object to check.\n * @returns {obj is CoraliteDirective} True if the object is a CoraliteDirective, false otherwise.\n */\nfunction isCoraliteDirective (obj) {\n return isObject(obj) && obj.type === 'directive'\n}\n\n/**\n * Checks if an object is a CoraliteComponentRoot.\n * @param {any} obj - The object to check.\n * @returns {obj is CoraliteComponentRoot} True if the object is a CoraliteComponentRoot, false otherwise.\n */\nfunction isCoraliteComponentRoot (obj) {\n return isObject(obj) && obj.type === 'root'\n}\n\n/**\n * Checks if an object is a CoraliteSlotElement.\n * @param {any} obj - The object to check.\n * @returns {obj is CoraliteSlotElement} True if the object is a CoraliteSlotElement, false otherwise.\n */\nfunction isCoraliteSlotElement (obj) {\n return isObject(obj) &&\n typeof obj.name === 'string' &&\n isCoraliteElement(obj.element) &&\n (obj.customElement === undefined || isCoraliteElement(obj.customElement))\n}\n\n/**\n * Determines whether the given object is a CoraliteCollectionItem.\n * @param {any} obj - The object to check.\n * @returns {obj is CoraliteCollectionItem} True if the object is a CoraliteCollectionItem, false otherwise.\n */\nfunction isCoraliteCollectionItem (obj) {\n return isObject(obj) &&\n 'path' in obj &&\n isObject(obj.path) &&\n typeof obj.path.pathname === 'string'\n}\n\n/**\n * Checks if an object is any Coralite node type (Element, TextNode, Comment, Directive, or DocumentRoot).\n * @param {any} obj - The object to check.\n * @returns {obj is CoraliteAnyNode | CoraliteDirective | CoraliteComponentRoot} True if the object is any Coralite node type.\n */\nfunction isCoraliteNode (obj) {\n return isCoraliteElement(obj) ||\n isCoraliteTextNode(obj) ||\n isCoraliteComment(obj) ||\n isCoraliteDirective(obj) ||\n isCoraliteComponentRoot(obj)\n}\n\n/**\n * Checks if an object has a valid CoraliteElement structure with required state.\n * @param {any} obj - The object to check.\n * @returns {boolean} True if the object has valid CoraliteElement structure.\n */\nfunction hasValidElementStructure (obj) {\n return isCoraliteElement(obj) &&\n typeof obj.name === 'string' &&\n isObject(obj.attribs) &&\n Array.isArray(obj.children)\n}\n\n/**\n * Checks if an object has a valid CoraliteTextNode structure with required state.\n * @param {any} obj - The object to check.\n * @returns {boolean} True if the object has valid CoraliteTextNode structure.\n */\nfunction hasValidTextNodeStructure (obj) {\n return isCoraliteTextNode(obj) &&\n typeof obj.data === 'string'\n}\n\n/**\n * Checks if an object has a valid CoraliteComment structure with required state.\n * @param {any} obj - The object to check.\n * @returns {boolean} True if the object has valid CoraliteComment structure.\n */\nfunction hasValidCommentStructure (obj) {\n return isCoraliteComment(obj) &&\n typeof obj.data === 'string'\n}\n\n/**\n * Safely checks if a value is a valid child node for a CoraliteElement.\n * @param {any} obj - The object to check.\n * @returns {boolean} True if the object is a valid child node.\n */\nfunction isValidChildNode (obj) {\n return isCoraliteElement(obj) ||\n isCoraliteTextNode(obj) ||\n isCoraliteComment(obj) ||\n isCoraliteDirective(obj)\n}\n\n/**\n * Checks if an object is a parent node (has children property).\n * @param {any} obj - The object to check.\n * @returns {boolean} True if the object has a children property.\n */\nfunction isParentNode (obj) {\n return isObject(obj) && Array.isArray(obj.children)\n}\n\n/**\n * Checks if an object is a removable node (has _markedForRemoval property set to true).\n * @param {any} obj - The object to check.\n * @returns {boolean} True if the object has _markedForRemoval property set to true.\n */\nfunction isRemovableNode (obj) {\n return isObject(obj) && obj._markedForRemoval === true\n}\n\nexport {\n // Core type guards\n isCoraliteElement,\n isCoraliteTextNode,\n isCoraliteComment,\n isCoraliteDirective,\n isCoraliteComponentRoot,\n isCoraliteSlotElement,\n isCoraliteCollectionItem,\n\n // Utility type guards\n isCoraliteNode,\n\n // Structure validation\n hasValidElementStructure,\n hasValidTextNodeStructure,\n hasValidCommentStructure,\n\n // Node property checks\n isValidChildNode,\n isParentNode,\n isRemovableNode\n}\n", "/**\n * @import { CoralitePlugin, HTMLData } from '../types/index.js'\n */\n\nimport { basename, dirname } from 'path'\nimport { CoraliteError } from './utils/errors.js'\n\n/**\n * Validates that a value is a non-empty string\n * @param {*} value - Value to validate\n * @param {string} paramName - Parameter name for error messages\n * @throws {Error} If value is not a valid non-empty string\n */\nfunction validateNonEmptyString (value, paramName) {\n if (typeof value !== 'string' || value.trim().length === 0) {\n throw new CoraliteError(\n `Coralite plugin validation failed: \"${paramName}\" must be a non-empty string, received ${typeof value}`\n )\n }\n}\n\n/**\n * Validates that a value is an array of strings (or empty array)\n * @param {*} value - Value to validate\n * @param {string} paramName - Parameter name for error messages\n * @throws {Error} If value is defined but not an array of strings\n */\nfunction validateStringArray (value, paramName) {\n if (!Array.isArray(value)) {\n throw new CoraliteError(\n `Coralite plugin validation failed: \"${paramName}\" must be an array, received ${typeof value}`\n )\n }\n\n for (let i = 0; i < value.length; i++) {\n if (typeof value[i] !== 'string') {\n throw new CoraliteError(\n `Coralite plugin validation failed: \"${paramName}[${i}]\" must be a string, received ${typeof value[i]}`\n )\n }\n }\n}\n\n/**\n * Processes a single components file with optional caching\n * @param {string} path - Template file path\n * @returns {HTMLData} Template data\n * @throws {Error} If components file cannot be read or is invalid\n */\nfunction processComponents (path) {\n try {\n const componentData = {\n path: {\n pathname: path,\n dirname: dirname(path),\n filename: basename(path)\n }\n }\n\n return componentData\n } catch (error) {\n throw new CoraliteError(\n `Coralite plugin component processing failed for \"${path}\": ${error.message}`,\n {\n cause: error,\n filePath: path\n }\n )\n }\n}\n\n/**\n * Creates a new Coralite plugin instance based on provided configuration options.\n * @param {CoralitePlugin & { server?: { components?: string[] } }} options - Plugin configuration object\n * @returns {CoralitePlugin} A configured plugin instance ready to be registered with Coralite\n * @example\n * // Basic plugin\n * const myPlugin = definePlugin({\n * name: 'my-plugin',\n * server: {\n * exports: {\n * getData: (context) => (options) => {\n * // Plugin logic implementation\n * return { ...context.state, custom: 'data', ...options }\n * }\n * }\n * }\n * })\n *\n * @example\n * // Plugin with components and metadata\n * const advancedPlugin = definePlugin({\n * name: 'advanced-plugin',\n * server: {\n * exports: {\n * process: (context) => async (options) => {\n * // Async plugin logic\n * return { ...context.state, processed: true, ...options }\n * }\n * },\n * components: ['src/components/header.html', 'src/components/footer.html'],\n * onPageSet: async (data) => {\n * console.log('Page created:', data.path.pathname)\n * }\n * }\n * })\n */\nexport function definePlugin ({\n name,\n server,\n client\n}) {\n validateNonEmptyString(name, 'name')\n\n let callerDir\n if (client != null && client.rootDir == null) {\n const stack = new Error().stack\n if (stack) {\n const callerLine = stack.split('\\n')[2]\n if (callerLine) {\n const match = callerLine.match(/file:\\/\\/(.+?):/)\n if (match) {\n callerDir = dirname(match[1])\n }\n }\n }\n }\n\n // Validate server plugin if provided\n if (server != null) {\n if (typeof server !== 'object') {\n throw new CoraliteError(\n `Coralite plugin validation failed: \"server\" must be an object, received ${typeof server}`\n )\n }\n\n server = { ...server }\n\n // Process component files with error handling\n if (server.components) {\n validateStringArray(server.components, 'server.components')\n\n const componentHTMLData = []\n try {\n // Process all components\n for (const path of server.components) {\n componentHTMLData.push(processComponents(path))\n }\n // @ts-ignore\n server.components = componentHTMLData\n } catch (error) {\n // Enhance error message with plugin context\n throw new CoraliteError(\n `Coralite plugin \"${name}\" failed to load components: ${error.message}`,\n { cause: error }\n )\n }\n }\n }\n\n // Validate client plugin if provided\n if (client != null) {\n if (typeof client !== 'object') {\n throw new CoraliteError(\n `Coralite plugin validation failed: \"client\" must be an object, received ${typeof client}`\n )\n }\n\n // Validate optional client state\n if (client.setup != null && typeof client.setup !== 'function') {\n throw new CoraliteError(\n `Coralite plugin validation failed: \"client.setup\" must be a function, received ${typeof client.setup}`\n )\n }\n\n if (client.config != null && typeof client.config !== 'object') {\n throw new CoraliteError(\n `Coralite plugin validation failed: \"client.config\" must be an object, received ${typeof client.config}`\n )\n }\n\n // append rootDir\n client.rootDir = client.rootDir || callerDir\n client.name = client.name || name\n }\n\n // Create the plugin object with all configured state\n return {\n name,\n server,\n client\n }\n}\n", "import { definePlugin } from '../lib/plugin.js'\n\n/**\n * @import { ParseHTMLResult } from '../types/index.js'\n * @import { CoraliteCollectionItem } from '../types/collection.js'\n * @import { CoraliteInstance, CoralitePage } from '../types/core.js'\n */\n\n/**\n * Processes a single element to extract metadata.\n */\nasync function processMetadataElement (element, context, index) {\n const { page, state, data, app, elements } = context\n\n if (element.type !== 'tag') {\n return\n }\n\n if (element.name === 'meta' && element.attribs?.name && element.attribs?.content) {\n page.meta[element.attribs.name] = element.attribs.content\n } else if (element.slots) {\n const componentElement = await app.createComponentElement({\n id: element.name,\n state,\n element,\n page,\n root: elements.root,\n contextId: data.path.pathname + index + element.name,\n index\n })\n\n if (componentElement) {\n for (let j = 0; j < componentElement.children.length; j++) {\n const child = componentElement.children[j]\n if (child.type === 'tag' && child.name === 'meta' && child.attribs?.name && child.attribs?.content) {\n page.meta[child.attribs.name] = child.attribs.content\n } else if (child.type === 'tag' && child.name === 'title' && child.children?.length && child.children[0].type === 'text') {\n page.meta.title = child.children[0].data\n }\n }\n }\n } else if (element.name === 'title' && element.children?.length && element.children[0].type === 'text') {\n page.meta.title = element.children[0].data\n }\n}\n\n/**\n * Extracts metadata tags from the parsed HTML root elements.\n * Supports static <title> and <meta> tags, as well as resolving dynamic custom\n * element slots inside the <head> segment to compute metadata.\n *\n * @param {Object} context - The context used to extract metadata from the document.\n * @param {ParseHTMLResult} context.elements - The parsed HTML elements including root\n * @param {CoralitePage} context.page - The global page object to store the extracted metadata\n * @param {Object.<string, any>} context.state - The global state object to store the extracted metadata\n * @param {CoraliteCollectionItem} context.data - The file data currently being evaluated\n * @param {CoraliteInstance} [context.app] - The global CoraliteInstance\n * @returns {Promise<void>}\n */\nasync function extractMetadata (context) {\n const { elements, page } = context\n page.meta.lang = ''\n\n for (let i = 0; i < elements.root.children.length; i++) {\n const rootNode = elements.root.children[i]\n\n if (rootNode.type === 'tag' && rootNode.name === 'html') {\n page.meta.lang = rootNode.attribs?.lang || ''\n\n for (let j = 0; j < rootNode.children.length; j++) {\n const node = rootNode.children[j]\n\n if (node.type === 'tag' && node.name === 'head') {\n for (let k = 0; k < node.children.length; k++) {\n await processMetadataElement(node.children[k], context, k)\n }\n return\n }\n }\n }\n }\n}\n\nexport const metadataPlugin = definePlugin({\n name: 'metadata',\n server: {\n async onPageSet ({ elements, state, page, data, app }) {\n await extractMetadata({\n elements,\n state,\n page,\n data,\n app\n })\n },\n async onPageUpdate ({ elements, page, newValue, app }) {\n await extractMetadata({\n elements,\n state: newValue.result.state,\n page,\n data: newValue,\n app\n })\n\n return {\n newValue: {\n result: {\n page\n }\n }\n }\n }\n }\n})\n", "import { definePlugin } from '../lib/plugin.js'\nimport { createRequire } from 'node:module'\nimport { dirname, join, parse } from 'node:path'\nimport { existsSync } from 'node:fs'\nimport { cp, mkdir } from 'node:fs/promises'\n\n/**\n * Finds the nearest package.json starting from a given directory.\n * @param {string} startDir - The directory to start searching from.\n * @returns {string} The path to the directory containing package.json.\n * @throws {Error} If package.json is not found up to the root.\n */\nfunction findPackageRoot (startDir) {\n let currentDir = startDir\n const rootDir = parse(currentDir).root\n\n while (currentDir !== rootDir) {\n if (existsSync(join(currentDir, 'package.json'))) {\n return currentDir\n }\n currentDir = dirname(currentDir)\n }\n\n throw new Error('package.json not found')\n}\n\n/**\n * @import { CoraliteStaticAsset } from '../types/index.js'\n */\n\n/**\n * Coralite plugin to copy static assets during build\n * @param {CoraliteStaticAsset[]} assets - Static assets to copy during build.\n */\nexport const staticAssetPlugin = (assets = []) => {\n return definePlugin({\n name: 'static-asset-plugin',\n server: {\n onBeforeBuild: async function (context) {\n const outputDir = context.app.options.output || join(process.cwd(), 'dist')\n\n for (const asset of assets) {\n if (!asset.dest) {\n throw new Error('staticAssetPlugin requires assets to have a dest property.')\n }\n\n const dest = join(outputDir, asset.dest)\n\n if (asset.src) {\n await mkdir(dirname(dest), { recursive: true })\n await cp(asset.src, dest, { recursive: true })\n continue\n }\n\n if (!asset.pkg || !asset.path) {\n throw new Error('staticAssetPlugin requires assets to have pkg and path state when src is not provided.')\n }\n\n const require = createRequire(join(process.cwd(), 'package.json'))\n let pkgPath\n\n try {\n pkgPath = dirname(require.resolve(`${asset.pkg}/package.json`))\n } catch {\n try {\n const resolvedPath = require.resolve(asset.pkg)\n pkgPath = findPackageRoot(dirname(resolvedPath))\n } catch {\n throw new Error(`staticAssetPlugin could not resolve package.json for package: ${asset.pkg}`)\n }\n }\n\n const src = join(pkgPath, asset.path)\n\n await mkdir(dirname(dest), { recursive: true })\n await cp(src, dest, { recursive: true })\n }\n }\n }\n })\n}\n", "import { definePlugin } from '../lib/plugin.js'\n\n/**\n * Traverses an AST recursively and duplicates 'ref' attributes to 'data-testid'.\n * Note: Modifying AST nodes in-place is required to preserve reference identity\n * for internal framework arrays (e.g. customElements, skipRenderElements).\n * @param {Array} children - The AST nodes to traverse.\n */\nfunction traverseAndAddTestId (children) {\n if (!Array.isArray(children)) {\n return\n }\n\n for (let i = 0; i < children.length; i++) {\n const node = children[i]\n\n if (node.type === 'tag' && node.attribs?.ref) {\n node.attribs['data-testid'] = node.attribs.ref\n }\n\n if (node.children?.length > 0) {\n traverseAndAddTestId(node.children)\n }\n }\n}\n\nexport const testingPlugin = definePlugin({\n name: 'testing',\n server: {\n onBeforeComponentRender: ({ instanceId, refs }) => {\n for (let i = 0; i < refs.length; i++) {\n const ref = refs[i]\n const uniqueRefValue = `${instanceId}__${ref.name}`\n\n if (ref.element.attribs) {\n ref.element.attribs['data-testid'] = uniqueRefValue\n }\n }\n },\n onComponentSet: ({ component }) => {\n const children = component?.template?.children\n if (children) {\n traverseAndAddTestId(children)\n }\n },\n onPageSet: ({ elements }) => {\n const children = elements?.root?.children\n if (children) {\n traverseAndAddTestId(children)\n }\n }\n },\n client: {\n onBeforeComponentRender: ({ instanceId, refs }) => {\n for (let i = 0; i < refs.length; i++) {\n const ref = refs[i]\n const uniqueRefValue = `${instanceId}__${ref.name}`\n\n if (ref.element && ref.element.setAttribute) {\n ref.element.setAttribute('data-testid', uniqueRefValue)\n }\n }\n }\n }\n})\n", "import { getHtmlFile, getHtmlFiles, discoverHtmlFiles } from './utils/server/html.js'\nimport { parseHTML, parseModule } from './utils/server/parse.js'\nimport { ScriptManager } from './script-manager.js'\nimport { metadataPlugin, staticAssetPlugin, testingPlugin } from '#plugins'\nimport { mkdir, writeFile } from 'node:fs/promises'\nimport { dirname, join, normalize, relative } from 'node:path'\nimport { handleError } from './utils/errors.js'\nimport { createExecutionError } from './utils/server/errors.js'\nimport { transformNode } from './parser.js'\nimport { evaluate } from './compiler.js'\nimport {\n triggerPluginAggregateHook,\n triggerPluginHook,\n bindPlugins\n} from './hooks.js'\nimport CoraliteCollection from './collection.js'\n\n// Refactored helper imports\nimport { createComponentDefinition, registerBaseComponent } from './component-setup.js'\nimport { setupPlugins } from './plugin-setup.js'\nimport { createPageHandlers } from './collection-handlers.js'\nimport { createRenderer } from './renderer.js'\nimport { initHasher } from './utils/server/manifest.js'\n\n/**\n * @import {\n * CoraliteConfig,\n * CoraliteInstance,\n * CoraliteBuildOptions,\n * CoraliteSaveResult\n * } from '../types/index.js'\n */\n\n/**\n * Factory function to create and initialize a Coralite instance.\n *\n * @param {CoraliteConfig} options - The configuration options for the Coralite instance.\n * @returns {Promise<CoraliteInstance>} A fully initialized Coralite instance.\n */\nexport async function createCoralite ({\n components,\n pages,\n plugins: userPlugins,\n assets,\n externalStyles,\n baseURL = '/',\n projectRoot = process.cwd(),\n ignoreByAttribute,\n skipRenderByAttribute,\n onError,\n mode = 'production',\n output\n}) {\n // Validate required parameters\n if (!components || typeof components !== 'string') {\n handleError({\n onErrorCallback: onError,\n data: {\n level: 'ERR',\n message: 'createCoralite requires \"components\" option to be defined as a string'\n }\n })\n }\n\n if (!pages || typeof pages !== 'string') {\n handleError({\n onErrorCallback: onError,\n data: {\n level: 'ERR',\n message: 'createCoralite requires \"pages\" option to be defined as a string'\n }\n })\n }\n\n const path = {\n components: normalize(components),\n pages: normalize(pages)\n }\n\n const normalizedOptions = {\n components,\n pages,\n plugins: [...(userPlugins || [])],\n assets,\n externalStyles,\n baseURL,\n projectRoot: normalize(projectRoot),\n ignoreByAttribute,\n skipRenderByAttribute,\n mode,\n path,\n output: output ? normalize(output) : undefined\n }\n\n /** @type {CoraliteInstance} */\n // @ts-ignore\n const app = {\n options: normalizedOptions,\n pages: null,\n components: null,\n build: null,\n save: null,\n transform: transformNode,\n addRenderQueue: null,\n getPagePathsUsingCustomElement: null,\n createComponentElement: null,\n _dependencyGraph: {\n pageCustomElements: {},\n childCustomElements: {}\n },\n _clearDependencies: () => {\n app._dependencyGraph.pageCustomElements = {}\n app._dependencyGraph.childCustomElements = {}\n }\n }\n\n // State\n const plugins = {\n components: [],\n hooks: {\n onPageSet: [],\n onPageUpdate: [],\n onPageDelete: [],\n onComponentSet: [],\n onComponentUpdate: [],\n onComponentDelete: [],\n onBeforePageRender: [],\n onAfterPageRender: [],\n onBeforeComponentRender: [],\n onAfterComponentRender: [],\n onBeforeBuild: [],\n onAfterBuild: []\n }\n }\n const scriptManager = new ScriptManager(normalizedOptions)\n // @ts-ignore\n const serverGlobalContext = { app }\n\n const _handleErrorLocal = (data) => handleError({\n onErrorCallback: onError,\n data\n })\n\n const source = {\n utils: {\n parseHTML: (string, ignore = normalizedOptions.ignoreByAttribute, skip = normalizedOptions.skipRenderByAttribute) => parseHTML(string, ignore, skip, _handleErrorLocal),\n parseModule: (string, opts) => parseModule(string, {\n ignoreByAttribute: normalizedOptions.ignoreByAttribute,\n skipRenderByAttribute: normalizedOptions.skipRenderByAttribute,\n onError: _handleErrorLocal,\n ...opts\n }),\n getHtmlFiles,\n getHtmlFile\n },\n plugins: {}\n }\n\n // @ts-ignore\n app.source = source\n\n // Helper to register a component via its ID\n const getComponent = (id) => app.components.getItem(id)\n\n const _triggerPluginHookLocal = (name, initialData) => triggerPluginHook({\n app,\n hooks: plugins.hooks,\n serverGlobalContext,\n name,\n initialData\n })\n\n const _triggerPluginAggregateHookLocal = (name, contextData) => triggerPluginAggregateHook({\n app,\n hooks: plugins.hooks,\n serverGlobalContext,\n name,\n contextData\n })\n\n const _bindPluginsLocal = (phase2Functions, instanceContext) => bindPlugins({\n serverGlobalContext,\n phase2Functions,\n instanceContext\n })\n\n const _defineComponent = createComponentDefinition({ app })\n\n const _evaluateLocal = (options) => evaluate({\n ...options,\n app,\n source,\n bindPlugins: _bindPluginsLocal,\n defineComponent: _defineComponent,\n createExecutionError,\n getComponent\n })\n\n // Instantiate the isolated rendering engine\n const renderer = createRenderer({\n app,\n scriptManager,\n source,\n evaluate: _evaluateLocal,\n handleError: _handleErrorLocal,\n hooks: {\n trigger: _triggerPluginHookLocal,\n triggerAggregate: _triggerPluginAggregateHookLocal,\n bind: _bindPluginsLocal\n },\n options: normalizedOptions,\n createExecutionError\n })\n\n // --- Public API Population ---\n\n Object.assign(app, {\n outputFiles: renderer.outputFiles,\n createComponentElement: renderer.createComponentElement,\n build: renderer.build,\n /**\n * Executes a full build and saves the generated pages to the configured output directory.\n *\n * @param {string | string[]} [savePath] - The target path or directory to build.\n * @param {CoraliteBuildOptions} [saveOptions={}] - Additional configuration for the save process.\n * @returns {Promise<CoraliteSaveResult[]>} A promise resolving to an array of all saved file results.\n */\n save: async (savePath, saveOptions = {}) => {\n const signal = saveOptions?.signal\n const createdDir = {}\n if (!app.options.output) {\n handleError({\n onErrorCallback: onError,\n data: {\n level: 'ERR',\n message: 'Coralite instance must be configured with an \"output\" option to use save()'\n }\n })\n }\n const outputDir = app.options.output\n const results = []\n await app.build(savePath, saveOptions, async (result) => {\n // @ts-ignore\n const relativeDir = relative(app.options.path.pages, result.path.dirname)\n const outDir = join(outputDir, relativeDir)\n const outFile = join(outDir, result.path.filename)\n\n if (result.status === 'skipped') {\n return undefined\n }\n\n if (!createdDir[outDir]) {\n await mkdir(outDir, { recursive: true }); createdDir[outDir] = true\n }\n\n await writeFile(outFile, result.content, { signal })\n\n results.push({\n path: outFile,\n duration: result.duration\n })\n\n return undefined\n })\n\n if (renderer.outputFiles) {\n const assetsDir = join(outputDir, 'assets', 'js')\n\n if (!createdDir[assetsDir]) {\n await mkdir(assetsDir, { recursive: true }); createdDir[assetsDir] = true\n }\n\n const assetWrites = Object.values(renderer.outputFiles).map(async (file) => {\n const outFile = join(assetsDir, file.hashedPath)\n const outDir = dirname(outFile)\n\n if (!createdDir[outDir]) {\n await mkdir(outDir, { recursive: true }); createdDir[outDir] = true\n }\n\n await writeFile(outFile, file.text, { signal })\n\n results.push({\n path: outFile,\n duration: 0\n })\n })\n await Promise.all(assetWrites)\n }\n return results\n },\n\n addRenderQueue: renderer.addRenderQueue,\n\n _triggerPluginAggregateHook: _triggerPluginAggregateHookLocal,\n _triggerPluginHook: _triggerPluginHookLocal,\n /**\n * Retrieves all page paths that utilize a specific custom element.\n *\n * @param {string} targetPath - The path or ID of the custom element (component) to search for.\n * @returns {string[]} An array of page pathnames that include the specified component.\n */\n getPagePathsUsingCustomElement: (targetPath) => {\n // @ts-ignore\n if (targetPath.startsWith(app.options.path.components)) {\n // @ts-ignore\n targetPath = targetPath.substring(app.options.path.components.length + 1)\n }\n const item = app.components.getItem(targetPath)\n const results = []\n if (item) {\n const id = app._dependencyGraph.childCustomElements[item.result.id] || item.result.id\n const pce = app._dependencyGraph.pageCustomElements[id]\n if (pce) {\n pce.forEach(p => results.push(p))\n }\n }\n return results\n }\n })\n\n // --- Initialization ---\n\n // Pre-initialization: load core plugins\n if (app.options.mode === 'development') {\n app.options.plugins.unshift(testingPlugin)\n }\n app.options.plugins.unshift(metadataPlugin)\n if (assets) {\n app.options.plugins.unshift(staticAssetPlugin(assets))\n }\n\n await Promise.all([\n initHasher(),\n setupPlugins({\n app,\n // @ts-ignore\n serverGlobalContext,\n plugins,\n scriptManager,\n source\n })\n ])\n\n const handlers = createPageHandlers({\n app,\n triggerHook: _triggerPluginHookLocal,\n handleError: _handleErrorLocal,\n evaluate: _evaluateLocal,\n scriptManager,\n createSession: renderer.createSession\n })\n\n app.components = await getHtmlFiles({\n path: app.options.components,\n recursive: true,\n type: 'component',\n onFileSet: handlers.onComponentSet,\n onFileUpdate: handlers.onComponentUpdate,\n onFileDelete: handlers.onComponentDelete\n })\n\n await Promise.all(plugins.components.map(c => app.components.setItem(c)))\n\n // Perform base evaluation for all discovered components\n for (const component of app.components.list) {\n await registerBaseComponent({\n component: component.result,\n evaluate: _evaluateLocal,\n scriptManager,\n createSession: renderer.createSession,\n mode: app.options.mode\n })\n }\n\n app.pages = new CoraliteCollection({\n rootDir: app.options.pages,\n onSet: handlers.onPageSet,\n onUpdate: handlers.onPageUpdate,\n onDelete: handlers.onPageDelete\n })\n\n if (app.options.mode === 'production') {\n for await (const file of discoverHtmlFiles({\n path: app.options.pages,\n recursive: true,\n type: 'page',\n discoverOnly: false\n })) {\n // @ts-ignore\n await app.pages.setItem(file)\n }\n } else {\n await getHtmlFiles({\n path: app.options.pages,\n recursive: true,\n type: 'page',\n discoverOnly: false,\n // @ts-ignore\n collection: app.pages\n })\n }\n\n return app\n}\n\nexport default createCoralite\n", "\nimport { parse as parseJS } from 'acorn'\nimport { CoraliteError } from '../errors.js'\n\n/**\n * @import { CoraliteModule, CoraliteCollectionItem, CoralitePage } from '../../../types/index.js'\n */\n\nconst CURRENT_FILE_URL = import.meta.url\n\n/**\n * Helper to create CoraliteError during component execution\n * @param {Error} error - The caught error\n * @param {CoraliteModule} module - The component module\n * @param {CoraliteCollectionItem} moduleComponent - The parent module component\n * @param {CoralitePage} page - The current page\n * @param {string} instanceId - The unique instance id\n * @returns {CoraliteError} The generated error object\n */\nexport function createExecutionError (error, module, moduleComponent, page, instanceId) {\n let line, column, stackFile\n const isSyntaxError = error instanceof SyntaxError\n const isImportError = error.message.includes('provide an export named')\n\n if (error.stack) {\n const stackLines = error.stack.split('\\n')\n\n for (let i = 1; i < stackLines.length; i++) {\n const stackLine = stackLines[i]\n if (stackLine.includes(CURRENT_FILE_URL) || stackLine.includes('packages/coralite/lib/errors.js')) {\n continue\n }\n const match = stackLine.match(/\\(([^)]*):(\\d+):(\\d+)\\)$/) || stackLine.match(/at\\s+(.*?):(\\d+):(\\d+)$/)\n if (match) {\n stackFile = match[1]\n line = parseInt(match[2], 10)\n column = parseInt(match[3], 10)\n\n\n if (stackFile === 'node:internal/vm/module') {\n stackFile = moduleComponent.path.pathname\n line = undefined\n column = undefined\n }\n break\n }\n }\n }\n\n // Attempt to recover location for SyntaxErrors or Linking errors that lost it\n if (isSyntaxError || isImportError) {\n stackFile = moduleComponent.path.pathname\n try {\n // Re-parse to find syntax error location if missing\n parseJS(module.script, {\n ecmaVersion: 'latest',\n sourceType: 'module',\n locations: true\n })\n } catch (e) {\n const errorToParse = e\n\n if (errorToParse.loc) {\n line = (module.lineOffset || 0) + errorToParse.loc.line\n column = errorToParse.loc.column + 1\n } else if (errorToParse.pos !== undefined) {\n const prefix = module.script.substring(0, errorToParse.pos)\n const lines = prefix.split('\\n')\n\n line = (module.lineOffset || 0) + lines.length\n column = lines[lines.length - 1].length + 1\n }\n }\n\n // Some SyntaxErrors from VM have line/column properties (though often 1-based and relative to script)\n // @ts-ignore\n if (!line && error.lineNumber !== undefined) {\n // @ts-ignore\n line = (module.lineOffset || 0) + error.lineNumber\n // @ts-ignore\n column = error.columnNumber || 1\n }\n\n // For import errors, try to find the problematic import line\n if (isImportError && !line && module.script) {\n const match = error.message.match(/module '([^']*)' does not provide an export named '([^']*)'/)\n\n if (match) {\n const [, moduleName, exportName] = match\n const lines = module.script.split('\\n')\n\n for (let i = 0; i < lines.length; i++) {\n if (lines[i].includes(moduleName) && lines[i].includes(exportName)) {\n line = (module.lineOffset || 0) + i + 1\n column = lines[i].indexOf(exportName) + 1\n break\n }\n }\n }\n }\n }\n\n return new CoraliteError(error.message, {\n cause: error,\n componentId: module.id,\n filePath: moduleComponent.path.pathname,\n pagePath: page?.file?.pathname,\n instanceId,\n line,\n column,\n stackFile\n })\n}\n", "import render from 'dom-serializer'\nimport { parseHTML } from './utils/server/parse.js'\nimport { relinkChildren } from './utils/server/dom.js'\n\n/**\n * @import { CoraliteElement, CoraliteAnyNode, CoraliteComponentRoot, Attribute, CoraliteModule, CoraliteSession } from '../types/index.js'\n * @import { DomSerializerOptions } from 'dom-serializer'\n */\n\n/**\n * Renders the provided node or array of nodes using the render function.\n *\n * @param {CoraliteComponentRoot | CoraliteAnyNode | CoraliteAnyNode[]} root - The node(s) to be rendered.\n * @param {DomSerializerOptions} [options] - Changes serialization behavior\n * @returns {string}\n */\nexport function transformNode (root, options) {\n // @ts-ignore\n return render(root, {\n decodeEntities: false,\n ...options\n })\n}\n\n/**\n * Replaces a custom element with its template content.\n * @param {CoraliteElement} coraliteElement - The custom element to be replaced.\n * @param {CoraliteElement} element - The target element to replace the tokens with.\n */\nexport function replaceCustomElementWithTemplate (coraliteElement, element) {\n coraliteElement.children = element.children\n relinkChildren(coraliteElement)\n}\n\n/**\n * Process a token value - parse HTML strings and handle custom elements\n * @param {any} value - The value to process\n * @param {Object} context - Processing context\n * @param {Attribute[]} [context.excludeByAttribute] - List of attribute name-value pairs to ignore\n * @param {Object} [context.state] - Replacement tokens for the component\n * @param {CoraliteModule} [context.module] - The component module\n * @param {Function} [context.createComponentElement] - The createComponentElement function\n * @param {CoraliteSession} [context.session] - The current build session\n * @param {boolean} [context.noHydration] - No hydration flag\n * @returns {Promise<any>} - Processed value\n */\nexport async function processTokenValue (value, context) {\n const { excludeByAttribute, state, module, createComponentElement, session, noHydration } = context\n // If not a string, return as-is\n if (typeof value !== 'string') {\n return value\n }\n\n // Parse HTML string\n const result = parseHTML(value, excludeByAttribute)\n\n // If no children, return undefined (for empty HTML)\n if (!result.root.children.length) {\n return undefined\n }\n\n // Process custom elements\n for (let i = 0; i < result.customElements.length; i++) {\n const customElement = result.customElements[i]\n const cid = `${module.path.pathname}${customElement.name}-${i}`\n const childNoHydration = noHydration || (customElement.attribs && 'no-hydration' in customElement.attribs)\n\n const componentElement = await createComponentElement({\n contextId: cid,\n id: customElement.name,\n state,\n element: customElement,\n module,\n index: i,\n session,\n noHydration: childNoHydration\n })\n\n if (componentElement) {\n if (childNoHydration) {\n const parent = customElement.parent\n if (parent && parent.children) {\n const elementIndex = parent.children.indexOf(customElement)\n if (elementIndex !== -1) {\n parent.children.splice(elementIndex, 1, ...componentElement.children)\n relinkChildren(parent)\n }\n }\n } else {\n customElement.children = componentElement.children\n relinkChildren(customElement)\n\n if (!customElement.attribs) {\n customElement.attribs = {}\n }\n customElement.attribs['data-cid'] = cid\n\n session.componentTags.add(customElement.name)\n }\n }\n }\n\n // For static strings, optimize single text nodes\n if (result.root.children.length === 1 && result.root.children[0].type === 'text') {\n return result.root.children[0].data\n }\n\n return result.root.children\n}\n", "import { pathToFileURL } from 'node:url'\nimport { resolve } from 'node:path'\nimport { createContext } from 'node:vm'\nimport { transform } from 'esbuild'\nimport { createRequire } from 'node:module'\nimport { extractGlobals } from './utils/server/server.js'\nimport { CoraliteError } from './utils/errors.js'\n\n/**\n * @import { CoraliteModule, CoraliteModuleDefinitions, CoralitePage, CoraliteSession, CoraliteFilePath, CoralitePluginContext } from '../types/index.js'\n * @import { Module } from 'node:vm'\n */\n\nlet SourceTextModuleCache = null\n\n/**\n * Generates a custom module linker callback for the Node.js VM context.\n *\n * @param {Object} options - The options used to create the module linker.\n * @param {CoraliteFilePath} options.path - The file path metadata of the component\n * @param {CoralitePluginContext} options.context - Contextual rendering data\n * @param {Object} options.source - Framework source context\n * @param {Object} options.plugins - Bound plugins\n * @param {Function} options.importModuleDynamically - The dynamic import callback\n * @returns {(specifier: string, referencingModule: Module, extra: { attributes: any }) => Promise<Module>}\n */\nexport function createModuleLinker ({ path, context, source, plugins, importModuleDynamically }) {\n const componentDirURL = pathToFileURL(resolve(path.dirname)).href\n\n return async (specifier, referencingModule, extra) => {\n if (!SourceTextModuleCache) {\n SourceTextModuleCache = (await import('node:vm')).SourceTextModule\n }\n\n const SourceTextModule = SourceTextModuleCache\n const originalSpecifier = specifier\n\n if (plugins[specifier]) {\n const plugin = plugins[specifier]\n let pluginExports = ''\n\n for (const key in plugin) {\n if (Object.prototype.hasOwnProperty.call(plugin, key)) {\n pluginExports += `export const ${key} = globalThis.__coralite_plugins__[\"${specifier}\"][\"${key}\"];\\n`\n }\n }\n\n return new SourceTextModule(pluginExports, {\n context: referencingModule.context,\n importModuleDynamically\n })\n } else if (specifier == 'coralite/utils') {\n const utils = source.utils\n let utilsExports = ''\n\n utilsExports = 'const utils = globalThis.__coralite_utils__; export default utils;'\n\n for (const key in utils) {\n if (Object.prototype.hasOwnProperty.call(utils, key)) {\n utilsExports += `export const ${key} = utils[\"${key}\"];\\n`\n }\n }\n\n return new SourceTextModule(utilsExports, {\n context: referencingModule.context,\n importModuleDynamically\n })\n } else if (specifier === 'coralite') {\n let coraliteExports = 'const context = globalThis.__coralite_context__; export default context;'\n\n for (const key in context) {\n if (Object.prototype.hasOwnProperty.call(context, key)) {\n coraliteExports += `export const ${key} = context[\"${key}\"];\\n`\n }\n }\n\n coraliteExports += 'export const defineComponent = globalThis.__coralite_define_component__;\\n'\n\n return new SourceTextModule(coraliteExports, {\n context: referencingModule.context,\n importModuleDynamically\n })\n } else if (specifier.startsWith('.')) {\n // handle relative path\n specifier = pathToFileURL(resolve(path.dirname, specifier)).href\n } else {\n // handle modules\n specifier = import.meta.resolve(specifier, componentDirURL)\n }\n\n try {\n let module\n if (extra.attributes && Object.keys(extra.attributes).length > 0) {\n module = await import(specifier, { with: extra.attributes })\n } else {\n module = await import(specifier)\n }\n let exportModule = ''\n\n for (const key in module) {\n if (Object.prototype.hasOwnProperty.call(module, key)) {\n const name = 'globalThis[\"' + originalSpecifier + '\"].'\n\n if (key === 'default') {\n exportModule += 'export default ' + name + key + ';\\n'\n } else {\n exportModule += 'export const ' + key + ' = ' + name + key + ';\\n'\n }\n }\n\n referencingModule.context[originalSpecifier] = module\n }\n\n return new SourceTextModule(exportModule, {\n context: referencingModule.context,\n importModuleDynamically\n })\n } catch (error) {\n throw new CoraliteError(error.message, {\n cause: error,\n filePath: specifier\n })\n }\n }\n}\n\n/**\n * Parses a Coralite module script and evaluates it using SourceTextModule.\n *\n * @param {Object} options - The options used for module evaluation in development mode.\n * @param {CoraliteModule} options.module - The Coralite module to parse\n * @param {CoraliteModuleDefinitions} options.state - Replacement tokens for the component\n * @param {CoralitePage} options.page - The global page object\n * @param {any} options.root - The Coralite module to parse\n * @param {string} options.contextId - Context Id\n * @param {CoraliteSession} options.session - Render Context\n * @param {boolean} options.noHydration - No hydration flag\n * @param {Object} options.app - The Coralite instance\n * @param {Object} options.source - Framework source context\n * @param {Function} options.bindPlugins - Function to bind plugins\n * @param {Function} options.defineComponent - Function to define component\n * @param {Function} options.createExecutionError - Function to create execution error\n * @param {Function} options.getComponent - Function to get component\n *\n * @returns {Promise<CoraliteModuleDefinitions>}\n */\nexport async function evaluateDevelopment ({\n module,\n state,\n page,\n root,\n contextId,\n session,\n noHydration,\n app,\n source,\n bindPlugins,\n defineComponent,\n createExecutionError,\n getComponent\n}) {\n if (!SourceTextModuleCache) {\n SourceTextModuleCache = (await import('node:vm')).SourceTextModule\n }\n const SourceTextModule = SourceTextModuleCache\n\n if (!SourceTextModule) {\n throw new CoraliteError('SourceTextModule is not available. Please run Node.js with --experimental-vm-modules to use Development mode.')\n }\n\n const context = {\n state: state || {},\n page,\n root,\n module,\n id: contextId,\n session,\n app,\n noHydration\n }\n\n const cachedBoundPlugins = await bindPlugins(source.plugins, context)\n\n session.source.currentSourceContextId = contextId\n session.source.contextInstances[contextId] = context\n\n const boundDefineComponent = (options) => defineComponent(options, context)\n\n const standardBuiltIns = new Set(['Object', 'Function', 'Array', 'String', 'Boolean', 'Number', 'Math', 'Date', 'RegExp', 'Error', 'EvalError', 'RangeError', 'ReferenceError', 'SyntaxError', 'TypeError', 'URIError', 'JSON', 'Promise', 'Proxy', 'Reflect', 'Map', 'Set', 'WeakMap', 'WeakSet', 'ArrayBuffer', 'SharedArrayBuffer', 'DataView', 'Atomics', 'Int8Array', 'Uint8Array', 'Uint8ClampedArray', 'Int16Array', 'Uint16Array', 'Int32Array', 'Uint32Array', 'Float32Array', 'Float64Array', 'BigInt', 'BigInt64Array', 'BigUint64Array', 'Symbol', 'Infinity', 'NaN', 'undefined', 'globalThis', 'decodeURI', 'decodeURIComponent', 'encodeURI', 'encodeURIComponent', 'escape', 'eval', 'isFinite', 'isNaN', 'parseFloat', 'parseInt', 'unescape'])\n if (!module._globalsCache) {\n module._globalsCache = extractGlobals(module.script)\n }\n const usedGlobals = module._globalsCache\n\n const contextGlobals = {\n __coralite_context__: context,\n __coralite_plugins__: cachedBoundPlugins,\n __coralite_utils__: source.utils,\n __coralite_define_component__: boundDefineComponent\n }\n\n for (const glob of usedGlobals) {\n if (!standardBuiltIns.has(glob) && glob in globalThis && globalThis[glob] !== undefined && !(glob in contextGlobals)) {\n contextGlobals[glob] = globalThis[glob]\n }\n }\n\n const contextifiedObject = createContext(contextGlobals)\n const moduleComponent = getComponent(module.id)\n\n let linker\n\n const importModuleDynamically = async (specifier, referencingModule, extra) => {\n const mod = await linker(specifier, referencingModule, extra)\n if (mod.status === 'unlinked') {\n await mod.link(linker)\n }\n if (mod.status === 'linked') {\n await mod.evaluate()\n }\n return mod\n }\n\n linker = createModuleLinker({\n path: moduleComponent.path,\n context,\n source,\n plugins: cachedBoundPlugins,\n importModuleDynamically\n })\n\n const script = new SourceTextModule(module.script, {\n initializeImportMeta (meta) {\n meta.url = pathToFileURL(resolve(moduleComponent.path.pathname)).href\n },\n importModuleDynamically,\n lineOffset: module.lineOffset || 0,\n identifier: pathToFileURL(resolve(moduleComponent.path.pathname)).href,\n context: contextifiedObject\n })\n\n await script.link(linker)\n\n try {\n await script.evaluate()\n } catch (error) {\n throw createExecutionError(error, module, moduleComponent, page, contextId)\n }\n\n // @ts-ignore\n if (script.namespace.default != null) {\n // @ts-ignore\n return await script.namespace.default\n }\n\n throw new CoraliteError(`Module \"${module.id}\" has no default export`, {\n componentId: module.id,\n filePath: moduleComponent.path.pathname\n })\n}\n\n/**\n * Parses a Coralite module script and compiles it into JavaScript using esbuild.\n *\n * @param {Object} options - The options used for module evaluation.\n * @param {CoraliteModule} options.module - The Coralite module to parse\n * @param {CoraliteModuleDefinitions} options.state - Replacement tokens for the component\n * @param {CoralitePage} options.page - The global page object\n * @param {any} options.root - The Coralite module to parse\n * @param {string} options.contextId - Context Id\n * @param {CoraliteSession} options.session - Render Context\n * @param {boolean} options.noHydration - No hydration flag\n * @param {Object} options.app - The Coralite instance\n * @param {Object} options.source - Framework source context\n * @param {Function} options.bindPlugins - Function to bind plugins\n * @param {Function} options.defineComponent - Function to define component\n * @param {Function} options.createExecutionError - Function to create execution error\n * @param {Function} options.getComponent - Function to get component\n *\n * @returns {Promise<CoraliteModuleDefinitions>}\n */\nexport async function evaluateProduction ({\n module,\n state,\n page,\n root,\n contextId,\n session,\n noHydration,\n app,\n source,\n bindPlugins,\n defineComponent,\n createExecutionError,\n getComponent\n}) {\n const context = {\n state: state || {},\n page,\n root,\n module,\n id: contextId,\n session,\n app,\n noHydration\n }\n\n session.source.currentSourceContextId = contextId\n session.source.contextInstances[contextId] = context\n\n const moduleComponent = getComponent(module.id)\n\n if (!moduleComponent.result._compiledCode) {\n const paddingCount = Math.max(0, (module.lineOffset - 1 || 0))\n const padding = '\\n'.repeat(paddingCount)\n\n const { code } = await transform(padding + module.script, {\n loader: 'js',\n format: 'cjs',\n target: 'node18',\n platform: 'node'\n })\n\n moduleComponent.result._compiledCode = `(async() => {${code}})();`\n }\n\n const fileRequire = createRequire(resolve(moduleComponent.path.pathname))\n const cachedBoundPlugins = await bindPlugins(source.plugins, context)\n\n const customRequire = (id) => {\n const isCoralite = id === 'coralite'\n const isUtils = id === 'coralite/utils'\n const isPlugin = source.plugins[id] !== undefined\n\n if (isCoralite || isUtils || isPlugin) {\n if (isCoralite) {\n return {\n ...context,\n defineComponent: (options) => defineComponent(options, context),\n default: {\n ...context,\n defineComponent: (options) => defineComponent(options, context)\n }\n }\n }\n\n if (isPlugin) {\n return {\n ...(cachedBoundPlugins[id] || {}),\n default: cachedBoundPlugins[id]\n }\n }\n\n if (isUtils) {\n return {\n ...source.utils,\n default: source.utils\n }\n }\n }\n\n return fileRequire(id)\n }\n\n const moduleMock = { exports: {} }\n\n if (!moduleComponent.result._compiledFunction) {\n moduleComponent.result._compiledFunction = new Function(\n 'module',\n 'exports',\n 'require',\n 'coralite',\n moduleComponent.result._compiledCode.trim()\n )\n }\n\n const fn = moduleComponent.result._compiledFunction\n\n try {\n await fn(moduleMock, moduleMock.exports, customRequire, context)\n } catch (error) {\n throw createExecutionError(error, module, moduleComponent, page, contextId)\n }\n\n if (moduleMock.exports.default != null) {\n return moduleMock.exports.default\n }\n\n throw new CoraliteError(`Module \"${module.id}\" has no default export`, {\n componentId: module.id,\n filePath: moduleComponent.path.pathname\n })\n}\n\n/**\n * Evaluates a Coralite module script using the appropriate engine for the current mode.\n * @param {any} options - The evaluation options for the module.\n */\nexport async function evaluate (options) {\n if (options.mode === 'development') {\n return evaluateDevelopment(options)\n }\n return evaluateProduction(options)\n}\n", "import { mergePluginState } from './utils/core.js'\nimport { CoraliteError } from './utils/errors.js'\n\n/**\n * Registers a callback function under the specified hook name.\n *\n * @param {Object} hooks - The hooks storage object\n * @param {'onPageSet'|'onPageUpdate'|'onPageDelete'|'onComponentSet'|'onComponentUpdate'|'onComponentDelete'|'onBeforePageRender'|'onAfterPageRender'|'onBeforeComponentRender'|'onAfterComponentRender'|'onBeforeBuild'|'onAfterBuild'} name - Hook name\n * @param {Function} callback - Callback function\n */\nexport function addPluginHook (hooks, name, callback) {\n if (typeof callback !== 'function') {\n throw new CoraliteError(`Plugin hook \"${name}\" must be a function`)\n }\n\n if (hooks[name]) {\n hooks[name].push(callback)\n }\n}\n\n/**\n * Executes a collecting plugin hook where the results are aggregated.\n *\n * @param {Object} options - The options used to trigger the aggregated plugin hook.\n * @param {Object} options.app - The global Coralite app instance.\n * @param {Object} options.hooks - The collection of registered plugin hooks.\n * @param {Object} options.serverGlobalContext - The global server-side context.\n * @param {string} options.name - The name of the hook to trigger.\n * @param {any} options.contextData - The data associated with the hook context.\n * @returns {Promise<any[]>} Aggregated results\n */\nexport async function triggerPluginAggregateHook ({ app, hooks, serverGlobalContext, name, contextData }) {\n const pluginHooks = hooks[name]\n const aggregatedResults = []\n\n if (!pluginHooks || pluginHooks.length === 0) {\n return aggregatedResults\n }\n\n for (let i = 0; i < pluginHooks.length; i++) {\n let result = pluginHooks[i](Object.assign({ app }, serverGlobalContext, contextData))\n\n if (result !== null && typeof result === 'object' && typeof result.then === 'function') {\n result = await result\n }\n\n if (result !== undefined && result !== null) {\n if (Array.isArray(result)) {\n aggregatedResults.push(...result)\n } else {\n aggregatedResults.push(result)\n }\n }\n }\n\n return aggregatedResults\n}\n\n/**\n * Executes all plugin callbacks registered under the specified hook name sequentially.\n *\n * @param {Object} options - The options used to trigger the plugin hook.\n * @param {Object} options.app - The global Coralite app instance.\n * @param {Object} options.hooks - The collection of registered plugin hooks.\n * @param {Object} options.serverGlobalContext - The global server-side context.\n * @param {string} options.name - The name of the hook to trigger.\n * @param {any} options.initialData - The initial data to be modified by the hooks.\n * @returns {Promise<any>} Merged data\n */\nexport async function triggerPluginHook ({ app, hooks, serverGlobalContext, name, initialData }) {\n const pluginHooks = hooks[name]\n\n if (!pluginHooks || pluginHooks.length === 0) {\n return initialData\n }\n\n let currentData = typeof initialData === 'object' && initialData !== null\n ? Object.assign({ app }, serverGlobalContext, initialData)\n : initialData\n\n for (let i = 0; i < pluginHooks.length; i++) {\n let result = pluginHooks[i](currentData)\n\n if (result !== null && typeof result === 'object' && typeof result.then === 'function') {\n result = await result\n }\n\n if (result !== undefined && result !== null) {\n currentData = mergePluginState(currentData, result)\n }\n }\n\n return currentData\n}\n\n/**\n * Executes Phase 2 of plugin exports with the given instance context.\n *\n * @param {Object} options - The options used to bind plugins.\n * @param {Object} options.serverGlobalContext - The global server-side context.\n * @param {Object} options.phase2Functions - The map of Phase 2 plugin functions to be bound.\n * @param {Object} options.instanceContext - The specific instance context to bind the functions to.\n * @returns {Promise<Object>} Bound plugins\n */\nexport async function bindPlugins ({ serverGlobalContext, phase2Functions, instanceContext }) {\n const boundPlugins = {}\n const globalContext = Object.assign({ app: serverGlobalContext.app }, instanceContext)\n\n for (const name in phase2Functions) {\n const pluginExports = phase2Functions[name]\n if (pluginExports !== null && typeof pluginExports === 'object') {\n const boundObj = {}\n for (const prop in pluginExports) {\n if (typeof pluginExports[prop] === 'function') {\n boundObj[prop] = await pluginExports[prop](globalContext)\n } else {\n boundObj[prop] = pluginExports[prop]\n }\n }\n boundPlugins[name] = boundObj\n } else {\n boundPlugins[name] = pluginExports\n }\n }\n\n return boundPlugins\n}\n", "import { createReadOnlyProxy } from './utils/core.js'\nimport { processTokenValue } from './parser.js'\nimport { CoraliteError } from './utils/errors.js'\nimport {\n isCoraliteElement,\n isCoraliteTextNode,\n isCoraliteComment\n} from './utils/types.js'\nimport { findAndExtractScript, findAndExtractProperties } from './utils/server/server.js'\n\n/**\n * @import {\n * CoralitePluginContext,\n * CoraliteInstance\n * } from '../types/index.js'\n */\n\n/**\n * Factory to create the component definition function.\n *\n * @param {Object} dependencies - The dependencies required to create the component definition.\n * @param {CoraliteInstance} dependencies.app - The global Coralite app instance.\n * @returns {Function}\n */\nexport function createComponentDefinition ({ app }) {\n /**\n * This function defines a component for the Coralite framework.\n * @param {Object} options - Configuration options for the component\n * @param {CoralitePluginContext} context - The evaluation context\n * @returns {Promise<Object>}\n */\n return async (options, context) => {\n const { attributes, data, getters, slots, script } = options\n const { state: initialState, module, root } = context\n\n if (attributes) {\n for (const [key, value] of Object.entries(attributes)) {\n if (value.type === Object || value.type === Array) {\n throw new CoraliteError(`Component \"${module.id}\" defines attribute \"${key}\" as ${value.type.name}. Object and Array types are blocked in attributes. Use data() for complex data.`, {\n componentId: module.id,\n filePath: module.path?.pathname\n })\n }\n }\n }\n\n const state = Object.assign({}, initialState)\n const serializableAttributes = {}\n if (attributes) {\n for (const [key, schema] of Object.entries(attributes)) {\n serializableAttributes[key] = {\n type: schema.type.name || schema.type,\n default: schema.default\n }\n }\n }\n\n const scriptDefaultValues = {}\n if (attributes) {\n for (const [key, schema] of Object.entries(attributes)) {\n if (schema.default !== undefined) {\n scriptDefaultValues[key] = schema.default\n }\n }\n }\n\n state.__script__ = {\n attributes: serializableAttributes,\n getters: getters || {},\n state: {},\n defaultValues: scriptDefaultValues,\n slots: slots || {}\n }\n\n if (attributes) {\n for (const [key, schema] of Object.entries(attributes)) {\n const typeName = schema.type.name || schema.type\n if (state[key] !== undefined) {\n const value = state[key]\n if (typeName === 'Number') {\n state[key] = Number(value)\n } else if (typeName === 'Boolean') {\n state[key] = value !== 'false' && value !== null && value !== ''\n } else if (typeName === 'String') {\n state[key] = String(value)\n }\n } else if (schema.default !== undefined) {\n state[key] = schema.default\n }\n }\n }\n\n if (typeof data === 'function') {\n const dataResult = await data({\n ...context,\n ...initialState\n })\n if (dataResult) {\n state.__script__.data = dataResult\n Object.assign(state, dataResult)\n Object.assign(state.__script__.state, dataResult)\n }\n }\n\n if (getters) {\n const roState = createReadOnlyProxy(state)\n for (const [key, getter] of Object.entries(getters)) {\n const result = getter(roState, { signal: new AbortController().signal })\n state[key] = (result && typeof result.then === 'function') ? await result : result\n if (state.__script__ && state.__script__.state) {\n state.__script__.state[key] = state[key]\n }\n }\n }\n\n if (slots) {\n for (const name in slots) {\n if (Object.prototype.hasOwnProperty.call(slots, name)) {\n const computedSlot = slots[name]\n const methodKey = `slots_method_${name}`\n state.__script__.defaultValues[methodKey] = computedSlot\n const slotContent = []\n const elementSlots = []\n\n if (root && 'slots' in root && Array.isArray(root.slots)) {\n for (let j = 0; j < root.slots.length; j++) {\n const slot = root.slots[j]\n\n if (slot.name === name) {\n slotContent.push(slot.node)\n } else {\n elementSlots.push(slot)\n }\n }\n }\n\n let result = computedSlot(slotContent, state)\n if (result === undefined) {\n result = slotContent\n }\n\n if (result === null || result === '' || (Array.isArray(result) && result.length === 0)) {\n if (root && 'slots' in root && Array.isArray(root.slots)) {\n root.slots = root.slots.filter(s => s.name !== name)\n }\n\n continue\n }\n\n if (typeof result === 'string') {\n const processedResult = await processTokenValue(result, {\n ...context,\n state,\n createComponentElement: app.createComponentElement,\n noHydration: context.noHydration\n })\n if (Array.isArray(processedResult)) {\n for (let j = 0; j < processedResult.length; j++) {\n elementSlots.push({\n name,\n node: processedResult[j]\n })\n }\n } else {\n elementSlots.push({\n name,\n node: {\n type: 'text',\n data: processedResult\n }\n })\n }\n } else if (Array.isArray(result)) {\n for (let index = 0; index < result.length; index++) {\n const node = result[index]\n if (isCoraliteElement(node) || isCoraliteTextNode(node) || isCoraliteComment(node)) {\n elementSlots.push({\n name,\n node\n })\n } else {\n throw new CoraliteError(`Unexpected slot value in \"${module.path.pathname}\"`, {\n componentId: module.id,\n filePath: module.path.pathname\n })\n }\n }\n }\n\n if (root && 'slots' in root && Array.isArray(root.slots)) {\n root.slots = elementSlots\n }\n }\n }\n }\n\n const hasScript = typeof script === 'function'\n const hasSlots = slots && Object.keys(slots).length > 0\n const hasGetters = getters && Object.keys(getters).length > 0\n const hasAttributes = attributes && Object.keys(attributes).length > 0\n const hasData = typeof data === 'function'\n\n if (hasScript || hasSlots || hasGetters || hasAttributes || hasData) {\n if (hasScript) {\n const scriptTextContent = script.toString().trim()\n const args = {}\n for (const key in state) {\n if (!Object.hasOwn(state, key)) {\n continue\n }\n\n if (scriptTextContent.includes(key) || key.startsWith('ref_')) {\n args[key] = state.__script__.defaultValues[key] !== undefined\n ? state.__script__.defaultValues[key]\n : state[key]\n }\n }\n Object.assign(state.__script__.state, args)\n }\n } else {\n delete state.__script__\n }\n\n return state\n }\n}\n\n/**\n * Performs base evaluation and registers a component in the script manager.\n * Used during discovery and updates to lock in the pristine component definition.\n *\n * @param {Object} options - The registration options.\n * @param {any} options.component - The component document.\n * @param {Function} options.evaluate - The evaluation function.\n * @param {any} options.scriptManager - The script manager instance.\n * @param {Function} options.createSession - The session creation function.\n * @param {string} options.mode - The current build mode.\n * @returns {Promise<void>}\n */\nexport async function registerBaseComponent ({\n component,\n evaluate,\n scriptManager,\n createSession,\n mode\n}) {\n if (!component || !component.script) {\n return\n }\n\n try {\n const baseSession = createSession('base-evaluation')\n const scriptResult = await evaluate({\n module: component,\n state: {},\n page: {\n url: { pathname: '' },\n file: { pathname: '' },\n meta: {}\n },\n root: null,\n contextId: `base-${component.id}`,\n session: baseSession,\n mode\n })\n\n if (scriptResult && scriptResult.__script__) {\n const scriptMeta = scriptResult.__script__\n const templateAST = component.template?.children || []\n const templateValues = component.values || {}\n const stylesHTML = component._processedCss || ''\n\n const scriptObj = {\n ...scriptMeta,\n content: 'function(){}',\n state: scriptMeta.state || {},\n slots: scriptMeta.slots || {}\n }\n let defaultValues = scriptMeta.defaultValues || {}\n let extractedComponents = []\n\n if (!component._extractedScript) {\n component._extractedScript = findAndExtractScript(component.script)\n }\n const extractedScript = component._extractedScript\n\n if (extractedScript) {\n scriptObj.content = extractedScript.content\n scriptObj.lineOffset = (component.lineOffset || 0) + extractedScript.lineOffset\n extractedComponents = extractedScript.components || []\n }\n\n if (!component._extractedProperties) {\n component._extractedProperties = findAndExtractProperties(component.script)\n }\n const extractedProperties = component._extractedProperties\n\n if (extractedProperties) {\n scriptObj.stateContent = extractedProperties.content\n scriptObj.stateLineOffset = (component.lineOffset || 0) + extractedProperties.lineOffset\n }\n\n const declarativeComponents = (component.customElements || []).map(el => el.name)\n const nestedComponents = [...new Set([...declarativeComponents, ...extractedComponents])]\n scriptObj.components = nestedComponents\n\n templateValues?.refs?.forEach(ref => {\n const refKey = `ref_${ref.name}`\n defaultValues[refKey] = ''\n scriptObj.state[refKey] = ''\n })\n scriptObj.defaultValues = defaultValues\n\n scriptManager.registerComponent({\n id: component.id,\n getters: scriptMeta.getters,\n script: scriptObj,\n filePath: component.filePath || (component.path && component.path.pathname),\n templateAST,\n templateValues,\n defaultValues,\n styles: stylesHTML,\n slots: scriptMeta.slots,\n override: true\n })\n }\n } catch {\n // Base evaluation is allowed to fail silently\n }\n}\n", "import { addPluginHook } from './hooks.js'\n\n/**\n * @import { CoraliteInstance, CoralitePluginContext } from '../types/index.js'\n * @import { ScriptManager } from './script-manager.js'\n */\n\n/**\n * Logic for initializing plugins.\n *\n * @param {Object} dependencies - The dependencies required to initialize the plugins.\n * @param {CoraliteInstance} dependencies.app - The global Coralite app instance.\n * @param {CoralitePluginContext} dependencies.serverGlobalContext - The global server context for plugins.\n * @param {Object} dependencies.plugins - The collection of registered plugins and hooks.\n * @param {ScriptManager} dependencies.scriptManager - The script manager for handling client-side scripts.\n * @param {Object} dependencies.source - The framework source utilities and context.\n * @returns {Promise<void>}\n */\nexport async function setupPlugins ({\n app,\n serverGlobalContext,\n plugins,\n scriptManager,\n source\n}) {\n const pluginsToInit = app.options.plugins\n const allExportNames = new Set()\n\n for (const plugin of pluginsToInit) {\n if (plugin.server) {\n if (plugin.server.exports) {\n // @ts-ignore\n const { app: _, ...restGlobalContext } = serverGlobalContext\n // @ts-ignore\n const pluginContext = new Proxy(Object.assign({ app: serverGlobalContext.app }, restGlobalContext), {\n get (target, prop) {\n if (prop === 'config') {\n return plugin.server.config || {}\n }\n return target[prop]\n },\n set (target, prop, value) {\n serverGlobalContext[prop] = value\n return Reflect.set(target, prop, value)\n }\n })\n\n const phase2Obj = {}\n for (const prop in plugin.server.exports) {\n if (allExportNames.has(prop)) {\n throw new Error(`Coralite Error: Plugin export name conflict. The export name \"${prop}\" from plugin \"${plugin.name}\" is already defined by another plugin.`)\n }\n\n allExportNames.add(prop)\n\n if (typeof plugin.server.exports[prop] === 'function') {\n // @ts-ignore\n phase2Obj[prop] = await plugin.server.exports[prop](pluginContext)\n } else {\n phase2Obj[prop] = plugin.server.exports[prop]\n }\n }\n source.plugins[plugin.name] = phase2Obj\n serverGlobalContext[plugin.name] = phase2Obj\n }\n if (plugin.server.components) {\n plugin.server.components.forEach(c => plugins.components.push(c))\n }\n const wrapHook = (hook) => (ctx) => {\n const hookContext = Object.create(ctx)\n hookContext.config = plugin.server.config || {}\n return hook(hookContext)\n }\n\n if (plugin.server.onPageSet) {\n addPluginHook(plugins.hooks, 'onPageSet', wrapHook(plugin.server.onPageSet))\n }\n if (plugin.server.onPageDelete) {\n addPluginHook(plugins.hooks, 'onPageDelete', wrapHook(plugin.server.onPageDelete))\n }\n if (plugin.server.onPageUpdate) {\n addPluginHook(plugins.hooks, 'onPageUpdate', wrapHook(plugin.server.onPageUpdate))\n }\n if (plugin.server.onComponentSet) {\n addPluginHook(plugins.hooks, 'onComponentSet', wrapHook(plugin.server.onComponentSet))\n }\n if (plugin.server.onComponentDelete) {\n addPluginHook(plugins.hooks, 'onComponentDelete', wrapHook(plugin.server.onComponentDelete))\n }\n if (plugin.server.onComponentUpdate) {\n addPluginHook(plugins.hooks, 'onComponentUpdate', wrapHook(plugin.server.onComponentUpdate))\n }\n if (plugin.server.onBeforePageRender) {\n addPluginHook(plugins.hooks, 'onBeforePageRender', wrapHook(plugin.server.onBeforePageRender))\n }\n if (plugin.server.onAfterPageRender) {\n addPluginHook(plugins.hooks, 'onAfterPageRender', wrapHook(plugin.server.onAfterPageRender))\n }\n if (plugin.server.onBeforeComponentRender) {\n addPluginHook(plugins.hooks, 'onBeforeComponentRender', wrapHook(plugin.server.onBeforeComponentRender))\n }\n if (plugin.server.onAfterComponentRender) {\n addPluginHook(plugins.hooks, 'onAfterComponentRender', wrapHook(plugin.server.onAfterComponentRender))\n }\n if (plugin.server.onBeforeBuild) {\n addPluginHook(plugins.hooks, 'onBeforeBuild', async (ctx) => {\n const hookContext = Object.create(ctx)\n hookContext.config = plugin.server.config || {}\n const res = await plugin.server.onBeforeBuild(hookContext)\n if (res && typeof res === 'object') {\n Object.assign(serverGlobalContext, res)\n }\n return res\n })\n }\n if (plugin.server.onAfterBuild) {\n addPluginHook(plugins.hooks, 'onAfterBuild', wrapHook(plugin.server.onAfterBuild))\n }\n }\n if (plugin.client) {\n plugin.client.name = plugin.client.name || plugin.name\n scriptManager.use(plugin.client)\n }\n }\n}\n", "import { dirname, join, relative } from 'node:path'\nimport { pathToFileURL } from 'node:url'\nimport { parseHTML, parseModule } from './utils/server/parse.js'\nimport { registerBaseComponent } from './component-setup.js'\n\n/**\n * @import {\n * CoraliteInstance,\n * CoraliteOnError\n * } from '../types/index.js'\n */\n\n/**\n * Factory for collection handlers.\n *\n * @param {Object} context - The context containing shared dependencies for the handlers.\n * @param {CoraliteInstance} context.app - The global Coralite app instance.\n * @param {Function} context.triggerHook - The function used to trigger plugin hooks.\n * @param {CoraliteOnError} context.handleError - The callback for handling errors during collection events.\n * @param {Function} [context.evaluate] - The evaluation function for components.\n * @param {any} [context.scriptManager] - The script manager for components.\n * @param {Function} [context.createSession] - The session creation function.\n * @returns {Object}\n */\nexport function createPageHandlers ({\n app,\n triggerHook,\n handleError,\n evaluate,\n scriptManager,\n createSession\n}) {\n const { pageCustomElements, childCustomElements } = app._dependencyGraph\n const onFileSetLocal = async (data) => {\n // @ts-ignore\n const rootPath = data.type === 'component' ? app.options.path.components : app.options.path.pages\n const urlPathname = pathToFileURL(join('/', relative(rootPath, data.path.pathname))).pathname\n const page = {\n url: {\n pathname: urlPathname,\n dirname: pathToFileURL(dirname(urlPathname)).pathname\n },\n file: {\n pathname: data.path.pathname,\n dirname: data.path.dirname,\n filename: data.path.filename\n },\n meta: data.state?.page?.meta || {}\n }\n\n const state = {\n ...data.state,\n page\n }\n\n if (data.content === undefined) {\n return ({\n type: 'page',\n value: {\n state,\n page,\n path: data.path\n }\n })\n }\n\n const elements = parseHTML(data.content, app.options.ignoreByAttribute, app.options.skipRenderByAttribute, handleError)\n\n if (true) {\n const customElementsList = elements && elements.customElements ? elements.customElements : []\n for (let i = 0; i < customElementsList.length; i++) {\n const name = customElementsList[i].name\n if (!pageCustomElements[name]) {\n pageCustomElements[name] = new Set()\n // Always track dependencies for ISR\n // @ts-ignore\n app._dependencyGraph.pageCustomElements[name] = pageCustomElements[name]\n const component = app.components.getItem(name)\n\n if (component && component.result && component.result.customElements && component.result.customElements.length) {\n const stack = [component.result.customElements]\n\n while (stack.length > 0) {\n const current = stack.pop()\n\n for (let i = 0; i < current.length; i++) {\n const element = current[i]\n\n if (!childCustomElements[element.name]) {\n childCustomElements[element.name] = name\n const comp = app.components.getItem(element.name)\n\n if (comp && comp.result && comp.result.customElements && comp.result.customElements.length) {\n stack.push(comp.result.customElements)\n }\n }\n }\n }\n }\n }\n\n /** @type {Set<string>} */\n const customElements = pageCustomElements[name]\n customElements.add(data.path.pathname)\n }\n }\n\n const mappedContext = await triggerHook('onPageSet', {\n elements,\n state,\n page,\n data,\n app\n })\n\n const isProduction = app.options.mode === 'production'\n if (isProduction && !data.virtual) {\n delete data.content\n }\n\n return {\n type: 'page',\n value: {\n state: mappedContext.state,\n page: mappedContext.page,\n path: mappedContext.data.path,\n root: isProduction ? null : mappedContext.elements.root,\n customElements: isProduction ? null : mappedContext.elements.customElements,\n tempElements: isProduction ? null : mappedContext.elements.tempElements,\n skipRenderElements: isProduction ? null : mappedContext.elements.skipRenderElements\n },\n state: mappedContext.state\n }\n }\n\n const onPageUpdateLocal = async (newValue, oldValue) => {\n if (app.options.mode === 'production') {\n return newValue.result\n }\n\n let newCustomElements\n\n if (!newValue.result) {\n const res = await onFileSetLocal(newValue); newValue.result = res.value; newCustomElements = res.value.customElements\n } else {\n newCustomElements = newValue.result.customElements\n }\n\n const oldElements = (oldValue.result.customElements || []).slice()\n const mappedContext = await triggerHook('onPageUpdate', {\n elements: newValue.result,\n page: newValue.result.page,\n newValue,\n oldValue,\n app\n })\n\n newValue.result = mappedContext.elements; newValue = mappedContext.newValue\n\n for (let i = 0; i < newCustomElements.length; i++) {\n const name = newCustomElements[i].name\n let hasElement = false\n for (let j = 0; j < oldElements.length; j++) {\n if (name === oldElements[j].name) {\n hasElement = true; oldElements.splice(j, 1); break\n }\n }\n\n if (!hasElement) {\n if (!pageCustomElements[name]) {\n pageCustomElements[name] = new Set()\n // Always track dependencies for ISR\n // @ts-ignore\n app._dependencyGraph.pageCustomElements[name] = pageCustomElements[name]\n }\n /** @type {Set<string>} */\n const customElements = pageCustomElements[name]\n customElements.add(newValue.path.pathname)\n }\n }\n oldElements.forEach(oe => {\n if (pageCustomElements[oe.name]) {\n // Track deletions for ISR\n /** @type {Set<string>} */\n const customElements = pageCustomElements[oe.name]\n customElements.delete(newValue.path.pathname)\n }\n })\n return newValue.result\n }\n\n const onPageDeleteLocal = async (value) => {\n if (app.options.mode === 'production') {\n return\n }\n\n const res = await triggerHook('onPageDelete', {\n data: value,\n app\n })\n\n value = res.data\n if (value?.result?.customElements) {\n value.result.customElements.forEach(ce => {\n const ceName = typeof ce === 'string' ? ce : ce.name\n if (pageCustomElements[ceName]) {\n // Track deletions for ISR\n /** @type {Set<string>} */\n const customElements = pageCustomElements[ceName]\n customElements.delete(value.path.pathname)\n }\n })\n }\n }\n\n const onComponentSetLocal = async (v) => {\n if (v.content === undefined) {\n v.content = await getHtmlFile(v.path.pathname)\n }\n\n const component = parseModule(v.content, {\n ignoreByAttribute: app.options.ignoreByAttribute,\n skipRenderByAttribute: app.options.skipRenderByAttribute,\n onError: handleError\n })\n\n if (!component.isTemplate) {\n return\n }\n\n const res = await triggerHook('onComponentSet', {\n component,\n app\n })\n\n return {\n type: 'component',\n id: res.component.id,\n value: res.component\n }\n }\n\n const onComponentUpdateLocal = async (v) => {\n if (v.content === undefined) {\n v.content = await getHtmlFile(v.path.pathname)\n }\n\n const component = parseModule(v.content, {\n ignoreByAttribute: app.options.ignoreByAttribute,\n skipRenderByAttribute: app.options.skipRenderByAttribute,\n onError: handleError\n })\n\n if (!component.isTemplate) {\n return\n }\n\n const res = await triggerHook('onComponentUpdate', {\n component,\n app\n })\n\n await registerBaseComponent({\n component: res.component,\n evaluate,\n scriptManager,\n createSession,\n mode: app.options.mode\n })\n\n return res.component\n }\n\n const onComponentDeleteLocal = async (v) => {\n await triggerHook('onComponentDelete', {\n component: v,\n app\n })\n }\n\n // Internal helper for reading HTML files\n async function getHtmlFile (pathname) {\n // @ts-ignore\n return app.source.utils.getHtmlFile(pathname)\n }\n\n return {\n onPageSet: onFileSetLocal,\n onPageUpdate: onPageUpdateLocal,\n onPageDelete: onPageDeleteLocal,\n onComponentSet: onComponentSetLocal,\n onComponentUpdate: onComponentUpdateLocal,\n onComponentDelete: onComponentDeleteLocal\n }\n}\n", "import { randomUUID } from 'node:crypto'\nimport { dirname, join } from 'node:path'\nimport { availableParallelism } from 'node:os'\nimport { readFile, writeFile, mkdir, rename } from 'node:fs/promises'\nimport pLimit from 'p-limit'\nimport {\n cleanKeys,\n cloneModuleInstance,\n cloneComponentInstance,\n normalizeObjectFunctions\n} from './utils/core.js'\nimport {\n replaceToken,\n findAndExtractScript,\n findAndExtractProperties,\n astTransformer\n} from './utils/server/server.js'\nimport { getHtmlFile } from './utils/server/html.js'\nimport { parseHTML } from './utils/server/parse.js'\nimport {\n findHeadAndBody,\n injectExternalStyles,\n injectStyles,\n injectReadinessScript,\n injectImportMap,\n removeElements,\n resolvePageQueue\n} from './utils/server/render.js'\nimport { generateClientRuntime } from './utils/client/runtime.js'\nimport { transformCss } from './utils/server/style.js'\nimport { transformNode } from './parser.js'\nimport { CoraliteError } from './utils/errors.js'\nimport { checkFileChange } from './utils/server/manifest.js'\nimport {\n isCoraliteElement,\n isCoraliteCollectionItem\n} from './utils/types.js'\nimport { createCoraliteElement, createCoraliteTextNode, relinkChildren } from './utils/server/dom.js'\n\n/**\n * @import {\n * CoraliteInstance,\n * CoraliteSession,\n * CoraliteBuildResult,\n * CoraliteBuildCallback,\n * CoraliteBuildOptions,\n * CoraliteOnError,\n * CoraliteAnyNode,\n * CoraliteCollectionItem,\n * ComponentElementOptions,\n * HTMLData\n * } from '../types/index.js'\n */\n\n/**\n * @import { InstanceContext } from '../types/script.js'\n * @import { ScriptManager } from './script-manager.js'\n */\n\n/**\n * Factory for the rendering pipeline.\n *\n * @param {Object} dependencies - The dependencies required to create the renderer.\n * @param {CoraliteInstance} dependencies.app - The global Coralite app instance.\n * @param {ScriptManager} dependencies.scriptManager - The script manager for handling client-side scripts.\n * @param {Object} dependencies.source - The framework source utilities and context.\n * @param {Function} dependencies.evaluate - The function used to evaluate component scripts.\n * @param {CoraliteOnError} dependencies.handleError - The callback for handling errors during rendering.\n * @param {Object} dependencies.hooks - The collection of bound plugin hooks.\n * @param {any} dependencies.options - The normalized configuration options for the framework.\n * @param {Function} dependencies.createExecutionError - The factory function for creating detailed execution errors.\n * @returns {Object}\n */\nexport function createRenderer ({\n app,\n scriptManager,\n source,\n evaluate,\n handleError,\n hooks,\n options: normalizedOptions,\n createExecutionError\n}) {\n const renderQueues = new Map()\n const sealedQueues = new Set()\n const outputFiles = {}\n const scriptResultCache = new Map()\n\n /**\n * Creates a new rendering session.\n * @param {string} [buildId] - Unique identifier for the build\n * @returns {CoraliteSession}\n */\n const _createSession = (buildId) => ({\n buildId,\n state: {},\n styles: new Map(),\n componentTags: new Set(),\n instanceCounters: {},\n generateId (prefix) {\n if (this.instanceCounters[prefix] === undefined) {\n this.instanceCounters[prefix] = 0\n }\n return `${prefix}-${this.instanceCounters[prefix]++}`\n },\n scripts: {\n content: {},\n add (id, item) {\n if (!this.content[id]) {\n this.content[id] = {}\n }\n this.content[id][item.id] = item\n }\n },\n source: {\n currentSourceContextId: '',\n contextInstances: {}\n }\n })\n\n const _replaceSlots = async (id, element, module, state, page, root, index, session, noHydration) => {\n const slots = module.slotElements ? module.slotElements[id] : null\n if (!slots) {\n return\n }\n\n const slotChildren = {}\n const slotNames = Object.keys(slots)\n for (let i = 0; i < slotNames.length; i++) {\n slotChildren[slotNames[i]] = []\n }\n\n if (element && element.slots) {\n for (let i = 0; i < element.slots.length; i++) {\n const elementSlotContent = element.slots[i]\n const slotName = elementSlotContent.name\n const slot = slots[slotName]\n if (slot) {\n if (elementSlotContent.node.attribs) {\n delete elementSlotContent.node.attribs.slot\n }\n slotChildren[slotName].push(elementSlotContent.node)\n }\n }\n }\n\n const slotTasks = []\n\n for (let i = 0; i < slotNames.length; i++) {\n const slotName = slotNames[i]\n let slotNodes = slotChildren[slotName]\n const slot = slots[slotName]\n\n if (!slot.element || !slot.element.parent || !slot.element.parent.children) {\n continue\n }\n const emptySlot = slotNodes.filter(node => node.type !== 'text' || (node.data && node.data.trim().length > 0))\n if (!emptySlot.length) {\n slotNodes = slot.element.children || []\n slot.element.children = slotNodes\n relinkChildren(slot.element)\n } else {\n const componentTasks = []\n for (let j = slotNodes.length - 1; j > -1; j--) {\n const node = slotNodes[j]\n if (node.name) {\n const slotComponentItem = app.components.getItem(node.name)\n\n if (slotComponentItem) {\n const slotContextId = session.generateId(node.name)\n const currentProperties = session.state[slotContextId] || {}\n const attribValues = cleanKeys(node.attribs)\n session.state[slotContextId] = typeof node.attribs === 'object'\n ? {\n ...currentProperties,\n ...state,\n ...attribValues\n }\n : Object.assign(currentProperties, state)\n\n const childNoHydration = noHydration || (node.attribs && 'no-hydration' in node.attribs)\n componentTasks.push(createComponentElement({\n id: node.name,\n state: session.state[slotContextId],\n element: node,\n page,\n root,\n contextId: slotContextId,\n index,\n session,\n noHydration: childNoHydration\n }, false).then(componentElement => ({\n componentElement,\n node,\n slotContextId,\n childNoHydration\n })))\n }\n }\n }\n\n slotTasks.push(Promise.all(componentTasks).then(results => {\n for (const { componentElement, node, slotContextId, childNoHydration } of results) {\n if (componentElement) {\n if (childNoHydration) {\n const parent = node.parent\n\n if (parent && Array.isArray(parent.children)) {\n const idx = parent.children.indexOf(node)\n if (idx !== -1) {\n let children = []\n\n if (Array.isArray(componentElement)) {\n children = componentElement\n } else if ('children' in componentElement && Array.isArray(componentElement.children)) {\n children = componentElement.children\n }\n\n parent.children.splice(idx, 1, ...children)\n relinkChildren(parent)\n }\n }\n } else {\n let children = []\n\n if (Array.isArray(componentElement)) {\n children = componentElement\n } else if ('children' in componentElement && Array.isArray(componentElement.children)) {\n children = componentElement.children\n }\n\n node.children = children\n relinkChildren(node)\n\n if (!node.attribs) {\n node.attribs = {}\n }\n\n node.attribs['data-cid'] = slotContextId\n session.componentTags.add(node.name)\n }\n }\n }\n slot.element.children = slotNodes\n relinkChildren(slot.element)\n }))\n }\n }\n await Promise.all(slotTasks)\n }\n\n const _processDependentComponents = async (componentIds, session, page, root, state = {}) => {\n if (!componentIds?.length) {\n return\n }\n for (const id of componentIds) {\n if (scriptManager.sharedFunctions[id]) {\n continue\n }\n const moduleComponent = app.components.getItem(id)\n if (!moduleComponent) {\n continue\n }\n const module = cloneModuleInstance(moduleComponent.result)\n\n let scriptResult = {}\n if (module.script) {\n try {\n scriptResult = await evaluate({\n module,\n state,\n page,\n root,\n contextId: `dependent-${id}`,\n session\n })\n } catch (error) {\n throw createExecutionError(error, module, moduleComponent, page, `dependent-${id}`)\n }\n }\n\n const scriptMeta = scriptResult.__script__ || {}\n const templateAST = moduleComponent.result.template?.children || []\n const templateValues = moduleComponent.result.values || {}\n\n if (module.styles?.length && !moduleComponent.result._processedCss) {\n const rawCss = module.styles.join('\\n')\n const { rootClasses, descendantClasses } = moduleComponent.result\n moduleComponent.result._processedCss = await transformCss(rawCss, rootClasses, descendantClasses, handleError)\n }\n const stylesHTML = moduleComponent.result._processedCss || ''\n\n const scriptObj = {\n content: 'function(){}',\n state: scriptMeta.state || {},\n slots: scriptMeta.slots || {}\n }\n let defaultValues = scriptMeta.defaultValues || {}\n let extractedComponents = []\n\n if (scriptResult.__script__) {\n if (!moduleComponent.result._extractedScript) {\n moduleComponent.result._extractedScript = findAndExtractScript(module.script)\n }\n const extractedScript = moduleComponent.result._extractedScript\n\n if (extractedScript) {\n scriptObj.content = extractedScript.content\n scriptObj.lineOffset = (module.lineOffset || 0) + extractedScript.lineOffset\n extractedComponents = extractedScript.components || []\n }\n\n if (!moduleComponent.result._extractedProperties) {\n moduleComponent.result._extractedProperties = findAndExtractProperties(module.script)\n }\n const extractedProperties = moduleComponent.result._extractedProperties\n\n if (extractedProperties) {\n scriptObj.stateContent = extractedProperties.content\n scriptObj.stateLineOffset = (module.lineOffset || 0) + extractedProperties.lineOffset\n }\n }\n\n const declarativeComponents = (module.customElements || []).map(el => el.name)\n const nestedComponents = [...new Set([...declarativeComponents, ...extractedComponents])]\n scriptObj.components = nestedComponents\n\n templateValues?.refs?.forEach(ref => {\n const refKey = `ref_${ref.name}`\n defaultValues[refKey] = ''\n scriptObj.state[refKey] = ''\n })\n scriptObj.defaultValues = defaultValues\n\n scriptManager.registerComponent({\n id: module.id,\n getters: scriptMeta.getters,\n script: scriptObj,\n filePath: moduleComponent.path.pathname,\n templateAST,\n templateValues,\n defaultValues,\n styles: stylesHTML,\n slots: scriptObj.slots\n })\n\n if (nestedComponents.length > 0) {\n const inheritedState = { ...state }\n // @ts-ignore\n delete inheritedState.__script__\n await _processDependentComponents(nestedComponents, session, page, root, inheritedState)\n }\n }\n }\n\n /**\n * Creates and initializes a component element from its definition and state.\n *\n * @param {ComponentElementOptions} options - Configuration and context for the component instance.\n * @param {boolean} [head=true] - Whether this component is being processed as a top-level head element.\n * @returns {Promise<CoraliteAnyNode | CoraliteAnyNode[] | void>} The rendered AST node(s) for the component.\n */\n const createComponentElement = async ({ id, state = {}, element, page, root, contextId, index, session, noHydration }, head = true) => {\n if (!session) {\n session = _createSession()\n }\n const moduleComponent = app.components.getItem(id)\n if (!moduleComponent || !moduleComponent.result) {\n return\n }\n const componentId = moduleComponent.result.id\n if (!contextId) {\n contextId = session.generateId(componentId)\n }\n const instanceId = contextId\n let componentState = { ...state }\n if (head) {\n // @ts-ignore\n if (element && element.attribs) {\n // @ts-ignore\n componentState = Object.assign(componentState, element.attribs)\n }\n componentState = cleanKeys(componentState)\n }\n\n const module = cloneModuleInstance(moduleComponent.result)\n\n if (module.values && module.values.refs) {\n for (let i = 0; i < module.values.refs.length; i++) {\n const ref = module.values.refs[i]\n const uniqueRefValue = `${instanceId}__${ref.name}`\n\n if (ref.element && ref.element.attribs) {\n ref.element.attribs.ref = uniqueRefValue\n }\n\n componentState[`ref_${ref.name}`] = uniqueRefValue\n }\n }\n\n const mappedComponentContext = await hooks.trigger('onBeforeComponentRender', {\n state: componentState,\n componentId: module.id,\n instanceId,\n refs: module.values.refs,\n textNodes: module.values.textNodes,\n attributes: module.values.attributes,\n page,\n element,\n session,\n app\n })\n componentState = mappedComponentContext.state\n const result = module.template\n\n if (module.styles.length) {\n const selector = module.id\n if (!moduleComponent.result._processedCss) {\n const rawCss = module.styles.join('\\n')\n const { rootClasses, descendantClasses } = moduleComponent.result\n moduleComponent.result._processedCss = await transformCss(rawCss, rootClasses, descendantClasses, handleError)\n }\n if (!session.styles.has(selector)) {\n session.styles.set(selector, moduleComponent.result._processedCss)\n }\n for (let i = 0; i < result.children.length; i++) {\n const child = result.children[i]\n if (child.type === 'tag') {\n if (!child.attribs) {\n child.attribs = {}\n }\n child.attribs['data-style-selector'] = selector\n }\n }\n }\n\n if (module.script) {\n let scriptResult = {}\n try {\n const evaluationState = { ...componentState }\n const pluginContext = {\n state: evaluationState,\n page,\n root: element || root,\n module,\n id: contextId,\n session,\n noHydration\n }\n\n await hooks.bind(source.plugins, pluginContext)\n\n scriptResult = await evaluate({\n module,\n element,\n state: evaluationState,\n page,\n root: element || root,\n contextId,\n session,\n noHydration,\n mode: app.options.mode\n })\n } catch (error) {\n throw createExecutionError(error, module, moduleComponent, page, contextId)\n }\n\n if (scriptResult && scriptResult.__script__ != null) {\n if (!moduleComponent.result._extractedScript) {\n moduleComponent.result._extractedScript = findAndExtractScript(module.script)\n }\n const extractedScript = moduleComponent.result._extractedScript\n\n let extractedComponents = []\n if (extractedScript) {\n scriptResult.__script__.lineOffset = (module.lineOffset || 0) + extractedScript.lineOffset\n scriptResult.__script__.content = extractedScript.content\n if (extractedScript.components) {\n extractedComponents = extractedScript.components\n }\n } else {\n scriptResult.__script__.lineOffset = module.lineOffset || 0\n scriptResult.__script__.content = 'function(){}'\n }\n\n const stylesHTML = moduleComponent.result._processedCss || ''\n const templateAST = moduleComponent.result.template.children\n const templateValues = moduleComponent.result.values\n const componentTokens = {}\n module.values.attributes.forEach(item => item.tokens.forEach(t => {\n componentTokens[t.name] = true\n }))\n module.values.textNodes.forEach(item => item.tokens.forEach(t => {\n componentTokens[t.name] = true\n }))\n\n const componentDefaultValues = scriptResult.__script__.defaultValues || {}\n\n const declarativeComponents = (module.customElements || []).map(el => el.name)\n const mergedComponents = Array.from(new Set([...declarativeComponents, ...extractedComponents]))\n if (scriptResult.__script__) {\n scriptResult.__script__.components = mergedComponents\n }\n\n scriptManager.registerComponent({\n id: module.id,\n getters: scriptResult.__script__.getters,\n script: scriptResult.__script__,\n filePath: moduleComponent.path.pathname,\n templateAST,\n templateValues,\n defaultValues: componentDefaultValues,\n styles: stylesHTML,\n slots: scriptResult.__script__.slots || {}\n })\n\n if (mergedComponents.length > 0) {\n const inheritedState = { ...state }\n // @ts-ignore\n delete inheritedState.__script__\n await _processDependentComponents(mergedComponents, session, page, root, inheritedState)\n }\n\n if (!scriptResult.__script__.state) {\n scriptResult.__script__.state = {}\n }\n if (!noHydration) {\n session.scripts.add(page.file.pathname, {\n id: contextId,\n componentId: module.id,\n page,\n state: scriptResult.__script__.state\n })\n }\n delete scriptResult.__script__\n }\n componentState = Object.assign(componentState, scriptResult)\n }\n\n session.state[contextId] = componentState\n\n module.values.attributes.forEach(item => item.tokens.forEach(token => {\n let value = componentState[token.name]\n if (value == null) {\n value = ''\n }\n replaceToken({\n type: 'attribute',\n node: item.element,\n attribute: item.name,\n content: token.content,\n value\n })\n }))\n\n module.values.textNodes.forEach(item => item.tokens.forEach(token => {\n let value = componentState[token.name]\n if (value == null) {\n value = ''\n }\n replaceToken({\n type: 'textNode',\n node: item.textNode,\n content: token.content,\n value\n })\n }))\n\n const customElements = module.customElements\n customElements.forEach(customElement => {\n if (customElement.children && customElement.children.length && !customElement.slots.length) {\n customElement.children.forEach(node => {\n const slotElement = {\n name: 'default',\n node\n }\n if (isCoraliteElement(node) && node.attribs.slot) {\n slotElement.name = node.attribs.slot\n }\n customElement.slots.push(slotElement)\n })\n }\n })\n\n const createComponentTasks = []\n customElements.forEach(customElement => {\n const parent = customElement.parent\n\n if (parent && 'slots' in parent && Array.isArray(parent.slots)) {\n return\n }\n\n const childContextId = session.generateId(customElement.name)\n const currentProperties = session.state[childContextId] || {}\n let childState = { ...state }\n if (typeof customElement.attribs === 'object') {\n const attribValues = cleanKeys(customElement.attribs)\n childState = {\n ...childState,\n ...currentProperties,\n ...attribValues\n }\n } else {\n childState = {\n ...childState,\n ...currentProperties\n }\n }\n session.state[childContextId] = childState\n const childNoHydration = noHydration || (customElement.attribs && 'no-hydration' in customElement.attribs)\n createComponentTasks.push(createComponentElement({\n id: customElement.name,\n state: childState,\n element: customElement,\n page,\n root,\n contextId: childContextId,\n index,\n session,\n noHydration: childNoHydration\n }, false).then(childComponentElement => ({\n childComponentElement,\n customElement,\n childContextId,\n noHydration: childNoHydration\n })))\n })\n\n const results = await Promise.all(createComponentTasks)\n\n results.forEach(({ childComponentElement, customElement, childContextId, noHydration: childNoHydration }) => {\n if (childComponentElement && typeof childComponentElement === 'object') {\n if (childNoHydration) {\n const parent = customElement.parent\n if (parent && parent.children) {\n const idx = parent.children.indexOf(customElement)\n if (idx !== -1) {\n // @ts-ignore\n const children = Array.isArray(childComponentElement) ? childComponentElement : childComponentElement.children\n parent.children.splice(idx, 1, ...children)\n relinkChildren(parent)\n }\n }\n } else {\n // @ts-ignore\n const children = Array.isArray(childComponentElement) ? childComponentElement : childComponentElement.children\n customElement.children = children\n relinkChildren(customElement)\n if (!customElement.attribs) {\n customElement.attribs = {}\n }\n customElement.attribs['data-cid'] = childContextId\n session.componentTags.add(customElement.name)\n }\n }\n })\n\n await _replaceSlots(id, element, module, componentState, page, root, index, session, noHydration)\n\n if (noHydration) {\n const stack = [...result.children]\n while (stack.length > 0) {\n const node = stack.pop()\n if (node.type === 'tag') {\n if (node.name === 'c-token') {\n const parent = node.parent\n if (parent && parent.children) {\n const idx = parent.children.indexOf(node)\n if (idx !== -1) {\n parent.children.splice(idx, 1, ...node.children)\n relinkChildren(parent)\n }\n }\n } else {\n stack.push(...(node.children || []))\n }\n }\n }\n }\n\n const mappedAfterContext = await hooks.trigger('onAfterComponentRender', {\n result,\n state: componentState,\n componentId: module.id,\n instanceId,\n refs: module.values.refs,\n textNodes: module.values.textNodes,\n attributes: module.values.attributes,\n page,\n element,\n session,\n app\n })\n return mappedAfterContext.result\n }\n\n const _processCustomElementsInPage = async (mappedComponent, originalDocument, state, mappedSessionObject, pageContext) => {\n const customElementsList = mappedComponent.customElements || []\n const tasks = []\n\n for (let i = 0; i < customElementsList.length; i++) {\n const customElement = customElementsList[i]\n const contextId = mappedSessionObject.generateId(customElement.name)\n const currentProperties = mappedSessionObject.state[contextId] || {}\n mappedSessionObject.state[contextId] = typeof customElement.attribs === 'object'\n ? {\n ...currentProperties,\n ...state,\n ...mappedComponent.state,\n ...customElement.attribs\n }\n : {\n ...currentProperties,\n ...state,\n ...mappedComponent.state\n }\n\n const noHydration = customElement.attribs && 'no-hydration' in customElement.attribs\n tasks.push(createComponentElement({\n id: customElement.name,\n state: mappedSessionObject.state[contextId],\n element: customElement,\n page: pageContext || originalDocument.page,\n root: mappedComponent.root,\n contextId,\n index: i,\n session: mappedSessionObject,\n noHydration\n }).then(componentElement => ({\n componentElement,\n customElement,\n contextId,\n noHydration\n })))\n }\n\n const results = await Promise.all(tasks)\n\n for (const { componentElement, customElement, contextId, noHydration } of results) {\n if (componentElement) {\n if (noHydration) {\n const parent = customElement.parent\n if (parent && parent.children) {\n const elementIndex = parent.children.indexOf(customElement)\n if (elementIndex !== -1) {\n // @ts-ignore\n const children = Array.isArray(componentElement) ? componentElement : componentElement.children\n parent.children.splice(elementIndex, 1, ...children)\n relinkChildren(parent)\n }\n }\n } else {\n // @ts-ignore\n const children = Array.isArray(componentElement) ? componentElement : componentElement.children\n customElement.children = children\n relinkChildren(customElement)\n if (!customElement.attribs) {\n customElement.attribs = {}\n }\n customElement.attribs['data-cid'] = contextId\n mappedSessionObject.componentTags.add(customElement.name)\n }\n }\n }\n }\n\n const _generatePages = async function* (activeQueue, buildId, state = {}) {\n const isProduction = normalizedOptions.mode === 'production'\n\n try {\n for (let q = 0; q < activeQueue.length; q++) {\n const pageItem = activeQueue[q]\n const startTime = performance.now()\n const originalDocument = pageItem.result\n let component\n let pageContext = originalDocument.page\n\n if (!originalDocument.root || pageItem.virtual) {\n let content = pageItem.content\n\n if (content === undefined) {\n try {\n content = await getHtmlFile(pageItem.path.pathname)\n } catch (e) {\n if (pageItem.virtual) {\n // If a virtual page is missing content, it's a critical error\n throw new CoraliteError(`Virtual page missing content: ${pageItem.path.pathname}`, {\n pagePath: pageItem.path.pathname\n })\n }\n content = pageItem.content !== undefined ? pageItem.content : (()=>{\n throw e\n })()\n }\n }\n pageItem.content = content\n const elements = parseHTML(content, normalizedOptions.ignoreByAttribute, normalizedOptions.skipRenderByAttribute, handleError)\n pageContext = {\n ...originalDocument.page,\n meta: { ...(originalDocument.page?.meta || {}) }\n }\n const pageState = {\n ...originalDocument.state,\n page: pageContext\n }\n const mappedContext = await hooks.trigger('onPageSet', {\n elements,\n state: pageState,\n page: pageContext,\n data: pageItem,\n app\n })\n // @ts-ignore\n const fullPath = Object.assign({}, mappedContext.data.path, {\n pages: normalizedOptions.path.pages,\n components: normalizedOptions.path.components\n })\n component = {\n state: { ...mappedContext.state },\n page: mappedContext.page,\n path: fullPath,\n root: mappedContext.elements.root,\n customElements: mappedContext.elements.customElements,\n tempElements: mappedContext.elements.tempElements,\n skipRenderElements: mappedContext.elements.skipRenderElements,\n ignoreByAttribute: normalizedOptions.ignoreByAttribute || []\n }\n } else {\n component = cloneComponentInstance(originalDocument)\n component.ignoreByAttribute = component.ignoreByAttribute || normalizedOptions.ignoreByAttribute || []\n pageContext = component.page\n }\n\n Object.assign(component.state, state)\n const session = _createSession(buildId)\n // @ts-ignore\n session.mode = normalizedOptions.mode\n const mappedSession = await hooks.trigger('onBeforePageRender', {\n component,\n state,\n page: pageContext,\n session,\n app\n })\n const mappedComponent = mappedSession.component\n const mappedSessionObject = mappedSession.session\n state = mappedSession.state\n // @ts-ignore\n mappedSessionObject.mode = normalizedOptions.mode\n removeElements(mappedComponent.tempElements, false)\n await _processCustomElementsInPage(mappedComponent, originalDocument, state, mappedSessionObject, pageContext)\n const { head: headElement, body: bodyElement } = findHeadAndBody(mappedComponent.root)\n\n if (normalizedOptions.externalStyles && normalizedOptions.externalStyles.length > 0) {\n injectExternalStyles(mappedComponent.root, headElement, normalizedOptions.externalStyles)\n }\n if (mappedSessionObject.styles.size > 0) {\n injectStyles(mappedComponent.root, headElement, mappedSessionObject.styles)\n }\n if (mappedSessionObject.componentTags.size > 0) {\n const targetElement = headElement || bodyElement || mappedComponent.root\n const layoutStyleElement = createCoraliteElement({\n type: 'tag',\n name: 'style',\n parent: targetElement,\n attribs: { id: 'coralite-components' },\n children: []\n })\n const selectors = Array.from(mappedSessionObject.componentTags)\n selectors.push('c-token')\n layoutStyleElement.children.push(createCoraliteTextNode({\n type: 'text',\n data: `${selectors.join(', ')} { display: contents; }`,\n parent: layoutStyleElement\n }))\n if (targetElement === headElement || targetElement === bodyElement) {\n targetElement.children.push(layoutStyleElement)\n } else {\n targetElement.children.unshift(layoutStyleElement)\n }\n }\n\n if (mappedSessionObject.scripts.content[mappedComponent.path.pathname]) {\n const scripts = mappedSessionObject.scripts.content[mappedComponent.path.pathname]\n const instances = {}\n const componentIds = new Set()\n for (const key in scripts) {\n const script = scripts[key]\n componentIds.add(script.componentId)\n instances[script.id] = {\n instanceId: script.id,\n componentId: script.componentId,\n page: script.page,\n state: script.state\n }\n }\n const cacheKey = Array.from(componentIds).sort().join(',')\n let scriptResult\n if (scriptResultCache.has(cacheKey)) {\n scriptResult = scriptResultCache.get(cacheKey)\n } else {\n /** @type {Object.<string, InstanceContext>} */\n const normalizedInstances = {}\n\n for (const [id, instance] of Object.entries(instances)) {\n normalizedInstances[id] = {\n ...instance,\n state: normalizeObjectFunctions(instance.state, astTransformer)\n }\n }\n\n scriptResult = await scriptManager.compileAllInstances(normalizedInstances, normalizedOptions.mode)\n scriptResultCache.set(cacheKey, scriptResult)\n Object.assign(outputFiles, scriptResult.outputFiles)\n }\n if (!scriptResult.manifest['chunk-shared']) {\n handleError({\n level: 'ERR',\n message: 'MANIFEST MISSING chunk-shared!',\n error: new Error(JSON.stringify(scriptResult.manifest))\n })\n }\n injectReadinessScript(mappedComponent.root, headElement, true)\n injectImportMap(mappedComponent.root, headElement, scriptResult.importMap)\n const chunkManifest = { ...scriptResult.manifest }\n delete chunkManifest['chunk-shared']\n const base = normalizedOptions.baseURL.endsWith('/') ? normalizedOptions.baseURL : normalizedOptions.baseURL + '/'\n const scriptContent = generateClientRuntime({\n base,\n sharedChunkPath: scriptResult.manifest['chunk-shared'],\n chunkManifest\n })\n const hydrationData = {}\n for (const [id, instance] of Object.entries(instances)) {\n if (instance.state && Object.keys(instance.state).length > 0) {\n hydrationData[id] = normalizeObjectFunctions(instance.state, astTransformer)\n }\n }\n const hydrationScriptElement = createCoraliteElement({\n type: 'tag',\n name: 'script',\n parent: bodyElement,\n attribs: {\n id: '__CORALITE_HYDRATION__',\n type: 'application/json'\n },\n children: []\n })\n hydrationScriptElement.children.push(createCoraliteTextNode({\n type: 'text',\n data: JSON.stringify(hydrationData),\n parent: hydrationScriptElement\n }))\n bodyElement.children.push(hydrationScriptElement)\n const scriptElement = createCoraliteElement({\n type: 'tag',\n name: 'script',\n parent: bodyElement,\n attribs: { type: 'module' },\n children: []\n })\n scriptElement.children.push(createCoraliteTextNode({\n type: 'text',\n data: scriptContent,\n parent: scriptElement\n }))\n bodyElement.children.push(scriptElement)\n }\n\n removeElements(mappedComponent.skipRenderElements, true)\n if (!mappedSessionObject.scripts.content[mappedComponent.path.pathname]) {\n injectReadinessScript(mappedComponent.root, headElement, false)\n }\n const rawHTML = transformNode(mappedComponent.root)\n\n /** @type {CoraliteBuildResult} */\n const result = {\n type: 'page',\n path: mappedComponent.path,\n content: rawHTML,\n duration: performance.now() - startTime,\n session\n }\n yield result\n\n if (isProduction) {\n mappedComponent.root = null; mappedComponent.customElements = null; mappedComponent.tempElements = null; mappedComponent.skipRenderElements = null\n delete pageItem.content\n }\n session.state = null; session.styles = null; session.scripts = null\n if (session.source) {\n session.source.contextInstances = null; session.source = null\n }\n }\n } finally {\n renderQueues.delete(buildId)\n }\n }\n\n /**\n * Adds a page or a collection item to the current render queue.\n *\n * @param {string | CoraliteCollectionItem | { pathname: string, content: string, cacheKey?: string, volatile?: boolean }} value - The ID of the page or the collection item to add.\n * @param {string} buildId - The unique identifier for the current build session.\n * @throws {Error} If the buildId is missing or invalid, or if the page ID is not found.\n * @returns {Promise<void>}\n */\n const addRenderQueue = async (value, buildId) => {\n if (!buildId) {\n throw new CoraliteError('addRenderQueue requires a buildId')\n }\n if (sealedQueues.has(buildId)) {\n console.warn(`[Coralite] Attempted to add to sealed queue for build \"${buildId}\". All virtual pages must be added in onBeforeBuild.`)\n return\n }\n const queue = renderQueues.get(buildId)\n if (!queue) {\n throw new CoraliteError(`addRenderQueue - buildId not found: \"${buildId}\"`)\n }\n\n let item\n if (typeof value === 'string') {\n // @ts-ignore\n item = app.pages.getItem(value)\n if (!item) {\n throw new CoraliteError(`addRenderQueue - unexpected page ID: \"${value}\"`)\n }\n } else if (isCoraliteCollectionItem(value)) {\n // @ts-ignore\n item = await app.pages.setItem(value)\n } else if (value && typeof value === 'object' && 'pathname' in value) {\n const pathname = value.pathname\n /** @type {HTMLData} */\n const itemData = {\n type: 'page',\n content: value.content,\n virtual: true,\n cacheKey: value.cacheKey,\n volatile: value.volatile,\n path: {\n pathname,\n filename: join(pathname),\n dirname: dirname(pathname)\n }\n }\n\n // Set content again to ensure it's not deleted if it matches collection's onSet/onUpdate criteria\n item = await app.pages.setItem({\n ...itemData,\n content: value.content\n })\n\n // Force properties directly on the item that resolvePageQueue might return\n item.content = value.content\n item.virtual = true\n item.cacheKey = value.cacheKey\n item.volatile = value.volatile\n\n // Also ensure the collection item itself has these\n const collectionItem = app.pages.getItem(pathname)\n if (collectionItem) {\n collectionItem.content = value.content\n collectionItem.virtual = true\n collectionItem.cacheKey = value.cacheKey\n collectionItem.volatile = value.volatile\n }\n }\n\n if (item && !queue.includes(item)) {\n queue.push(item)\n }\n }\n\n /**\n * Compiles and renders specified pages.\n *\n * @param {string | string[] | CoraliteBuildCallback} [pathOrOptions] - The path(s) to build, or a callback if no path is provided.\n * @param {CoraliteBuildOptions | CoraliteBuildCallback} [optionsOrCallback] - Build options or a callback.\n * @param {CoraliteBuildCallback} [callback] - Optional callback executed for each rendered page.\n * @returns {Promise<CoraliteBuildResult[]>} A promise resolving to an array of build results.\n */\n const build = async (pathOrOptions, optionsOrCallback, callback) => {\n const startTime = performance.now()\n const buildId = randomUUID()\n let buildPath = pathOrOptions\n let buildOptions\n let buildCallback = callback\n\n if (typeof pathOrOptions === 'function') {\n buildPath = null\n buildCallback = pathOrOptions\n } else if (typeof optionsOrCallback === 'function') {\n buildCallback = optionsOrCallback\n } else {\n buildOptions = optionsOrCallback\n }\n\n if (!buildOptions) {\n buildOptions = {}\n }\n\n // Phase 1: Discovery & Pre-Render Staging\n if (buildPath) {\n const paths = Array.isArray(buildPath) ? buildPath : [buildPath]\n for (const p of paths) {\n // @ts-ignore\n if (!app.pages.getItem(p)) {\n try {\n // @ts-ignore\n await app.pages.setItem(p)\n } catch (_err) {\n }\n }\n }\n }\n\n renderQueues.set(buildId, [])\n\n let mappedBeforeBuild\n try {\n mappedBeforeBuild = await hooks.trigger('onBeforeBuild', {\n app,\n buildId,\n options: buildOptions,\n addRenderQueue: (value) => addRenderQueue(value, buildId)\n })\n } catch (errorHook) {\n const error = new CoraliteError(`Error in onBeforeBuild hook: ${errorHook.message}`, { cause: errorHook })\n handleError({\n level: 'ERR',\n message: error.message,\n error\n })\n throw error\n }\n buildOptions = mappedBeforeBuild.options || buildOptions\n\n // @ts-ignore\n const resolvedQueue = resolvePageQueue(app.pages, buildPath)\n const queue = renderQueues.get(buildId)\n\n for (let i = 0; i < resolvedQueue.length; i++) {\n const item = resolvedQueue[i]\n if (!queue.includes(item)) {\n queue.push(item)\n }\n }\n\n // Seal the queue\n sealedQueues.add(buildId)\n\n // Phase 2: ISR & Manifest Invalidation\n const projectRoot = app.options.projectRoot || process.cwd()\n const cacheDir = join(projectRoot, '.coralite')\n const manifestPath = join(cacheDir, 'manifest.json')\n let manifest = {\n physical: {},\n virtual: {},\n dependencies: {}\n }\n\n try {\n const content = await readFile(manifestPath, 'utf8')\n manifest = JSON.parse(content)\n } catch (e) {\n // Manifest missing (cold start) or corrupt, use default\n if (e.code !== 'ENOENT') {\n handleError({\n level: 'WARN',\n message: `Could not parse manifest at ${manifestPath}: ${e.message}. Starting with fresh manifest.`\n })\n }\n }\n\n const pagesToRender = []\n const skippedPages = []\n const newManifest = {\n physical: {},\n virtual: {},\n dependencies: {}\n }\n\n // Check components first for dependency cascading\n const componentChanges = new Map()\n const allComponents = app.components.list\n for (const component of allComponents) {\n const { changed, metadata } = await checkFileChange(component.path.pathname, manifest.physical[component.path.pathname])\n newManifest.physical[component.path.pathname] = metadata\n if (changed) {\n componentChanges.set(component.result.id, true)\n // Force re-parse\n await app.components.updateItem(component.path.pathname)\n }\n }\n\n const pageCustomElements = {\n ...manifest.dependencies,\n ...app._dependencyGraph.pageCustomElements\n }\n\n for (const pageItem of queue) {\n let shouldRebuild = false\n\n // Check if any dependent component changed\n const componentIds = Object.keys(pageCustomElements).filter(id => {\n const pages = pageCustomElements[id]\n if (pages instanceof Set) {\n return pages.has(pageItem.path.pathname)\n }\n return Array.isArray(pages) && pages.includes(pageItem.path.pathname)\n })\n if (componentIds.some(id => componentChanges.get(id))) {\n shouldRebuild = true\n }\n\n if (pageItem.virtual) {\n if (pageItem.volatile || !manifest.virtual || !manifest.virtual[pageItem.path.pathname] || String(manifest.virtual[pageItem.path.pathname].cacheKey) !== String(pageItem.cacheKey) || normalizedOptions.mode === 'development') {\n shouldRebuild = true\n } else {\n shouldRebuild = false\n }\n if (!shouldRebuild) {\n /** @type {import('../types/index.js').CoraliteBuildResult} */\n const skippedResult = {\n type: 'page',\n // @ts-ignore\n path: {\n ...pageItem.path,\n pages: normalizedOptions.path.pages,\n components: normalizedOptions.path.components\n },\n status: 'skipped'\n }\n skippedPages.push(skippedResult)\n if (!newManifest.virtual) {\n newManifest.virtual = {}\n }\n newManifest.virtual[pageItem.path.pathname] = { cacheKey: pageItem.cacheKey }\n } else {\n pagesToRender.push(pageItem)\n if (!newManifest.virtual) {\n newManifest.virtual = {}\n }\n newManifest.virtual[pageItem.path.pathname] = { cacheKey: pageItem.cacheKey }\n }\n } else {\n const { changed, metadata } = await checkFileChange(pageItem.path.pathname, manifest.physical[pageItem.path.pathname])\n newManifest.physical[pageItem.path.pathname] = metadata\n if (changed || shouldRebuild || normalizedOptions.mode === 'development') {\n pagesToRender.push(pageItem)\n } else {\n /** @type {import('../types/index.js').CoraliteBuildResult} */\n const skippedResult = {\n type: 'page',\n // @ts-ignore\n path: {\n ...pageItem.path,\n pages: normalizedOptions.path.pages,\n components: normalizedOptions.path.components\n },\n status: 'skipped'\n }\n skippedPages.push(skippedResult)\n }\n }\n }\n\n // Update dependency graph in manifest\n const { pageCustomElements: livePageCustomElements } = app._dependencyGraph\n for (const [id, pages] of Object.entries(livePageCustomElements)) {\n newManifest.dependencies[id] = Array.from(pages)\n }\n // Carry over old dependencies if not overwritten\n for (const [id, pages] of Object.entries(manifest.dependencies || {})) {\n if (!newManifest.dependencies[id]) {\n newManifest.dependencies[id] = pages\n }\n }\n\n const signal = buildOptions?.signal\n const maxConcurrent = buildOptions?.maxConcurrent || availableParallelism()\n const variables = buildOptions?.variables\n const limit = pLimit(maxConcurrent)\n const executing = new Set()\n const results = []\n let buildError = null\n\n try {\n // Phase 3: The Render Engine\n for await (const result of _generatePages(pagesToRender, buildId, variables)) {\n if (signal?.aborted) {\n throw signal.reason\n }\n if (executing.size >= limit.concurrency) {\n await Promise.race(executing)\n }\n const task = limit(async () => {\n if (signal?.aborted) {\n throw signal.reason\n }\n // Note: additionalPages from onAfterPageRender are now ignored/warned if added via addRenderQueue\n await hooks.triggerAggregate('onAfterPageRender', {\n result,\n session: result.session,\n app\n })\n\n const items = [result]\n const finalResults = []\n for (const item of items) {\n if (typeof buildCallback === 'function') {\n const transformed = await buildCallback(item)\n if (transformed) {\n finalResults.push(transformed)\n }\n } else {\n finalResults.push(item)\n }\n }\n return finalResults\n })\n executing.add(task)\n task.then((callbackResults) => {\n if (callbackResults?.length) {\n results.push(...callbackResults)\n } executing.delete(task)\n })\n .catch((err) => {\n executing.delete(task); handleError({\n level: 'ERR',\n message: err.message,\n error: err\n })\n })\n }\n await Promise.all(executing)\n\n // Combine with skipped pages\n for (const skipped of skippedPages) {\n if (typeof buildCallback === 'function') {\n const transformed = await buildCallback(skipped)\n if (transformed) {\n results.push(transformed)\n }\n } else {\n results.push(skipped)\n }\n }\n\n // Write updated manifest atomically\n try {\n await mkdir(cacheDir, { recursive: true })\n const tempManifestPath = `${manifestPath}.tmp`\n await writeFile(tempManifestPath, JSON.stringify(newManifest, null, 2))\n await rename(tempManifestPath, manifestPath)\n } catch (e) {\n handleError({\n level: 'WARN',\n message: `Failed to write manifest: ${e.message}`\n })\n }\n\n return results\n } catch (error) {\n await Promise.allSettled(executing)\n if (error.name === 'AbortError') {\n handleError({\n level: 'WARN',\n message: 'Build cancelled by user.'\n })\n }\n buildError = error instanceof Error ? error : new CoraliteError(`Build failed: ${error.message}`, { cause: error })\n throw buildError\n } finally {\n const duration = performance.now() - startTime\n await hooks.trigger('onAfterBuild', {\n results,\n error: buildError,\n duration,\n app\n })\n renderQueues.delete(buildId)\n sealedQueues.delete(buildId)\n app._clearDependencies()\n // Clean up local arrays to help GC\n pagesToRender.length = 0\n skippedPages.length = 0\n }\n }\n\n return {\n outputFiles,\n createSession: _createSession,\n addRenderQueue,\n createComponentElement,\n build\n }\n}\n", "import { createCoraliteElement, createCoraliteTextNode } from './dom.js'\n\n/**\n * @import {\n * CoraliteElement,\n * CoraliteComponentRoot,\n * CoraliteCollectionItem\n * } from '../../../types/index.js'\n */\n\n/**\n * @import CoraliteCollection from '../../collection.js'\n */\n\n/**\n * Finds the <head> and <body> elements within the HTML AST.\n *\n * @param {CoraliteComponentRoot} root - The root of the AST.\n * @returns {{ head: CoraliteElement | null, body: CoraliteElement | CoraliteComponentRoot }}\n */\nexport function findHeadAndBody (root) {\n let head = null\n /** @type {CoraliteElement | CoraliteComponentRoot} */\n let body = root\n\n for (let i = 0; i < root.children.length; i++) {\n const rootNode = root.children[i]\n\n if (rootNode.type === 'tag' && rootNode.name === 'html') {\n for (let j = 0; j < rootNode.children.length; j++) {\n const node = rootNode.children[j]\n\n if (node.type === 'tag' && node.name === 'head') {\n head = node\n }\n if (node.type === 'tag' && node.name === 'body') {\n body = node\n }\n }\n break\n }\n }\n\n return {\n head,\n body\n }\n}\n\n/**\n * Injects external global style link tags into the document head (or root if head is missing).\n *\n * @param {CoraliteComponentRoot} root - The root of the AST.\n * @param {CoraliteElement | null} head - The head element.\n * @param {string[]} styles - Array of style URLs.\n */\nexport function injectExternalStyles (root, head, styles) {\n if (!styles || styles.length === 0) {\n return\n }\n\n const existingLinks = new Set()\n if (head) {\n head.children.forEach(child => {\n if (child.type === 'tag' && child.name === 'link' && child.attribs?.href) {\n existingLinks.add(child.attribs.href)\n }\n })\n }\n\n for (let i = 0; i < styles.length; i++) {\n const styleUrl = styles[i]\n\n if (existingLinks.has(styleUrl)) {\n continue\n }\n\n const linkElement = createCoraliteElement({\n type: 'tag',\n name: 'link',\n parent: head || root,\n attribs: {\n rel: 'stylesheet',\n href: styleUrl\n },\n children: []\n })\n\n if (head) {\n head.children.push(linkElement)\n } else {\n root.children.unshift(linkElement)\n }\n }\n}\n\n/**\n * Injects style tags into the document head (or root if head is missing).\n *\n * @param {CoraliteComponentRoot} root - The root of the AST.\n * @param {CoraliteElement | null} head - The head element.\n * @param {Map<string, string>} styles - Map of style selectors and their CSS content.\n */\nexport function injectStyles (root, head, styles) {\n if (!styles || styles.size === 0) {\n return\n }\n\n let cssContent = ''\n for (const [selector, css] of styles) {\n cssContent += `[data-style-selector=\"${selector}\"] {\\n${css}\\n}\\n`\n }\n\n const styleElement = createCoraliteElement({\n type: 'tag',\n name: 'style',\n parent: head || root,\n attribs: {},\n children: []\n })\n\n styleElement.children.push(createCoraliteTextNode({\n type: 'text',\n data: cssContent,\n parent: styleElement\n }))\n\n if (head) {\n head.children.push(styleElement)\n } else {\n root.children.unshift(styleElement)\n }\n}\n\n/**\n * Injects the readiness script into the document head (or root if head is missing).\n *\n * @param {CoraliteComponentRoot} root - The root of the AST.\n * @param {CoraliteElement | null} head - The head element.\n * @param {boolean} hasScripts - Whether the page has scripts to wait for.\n */\nexport function injectReadinessScript (root, head, hasScripts) {\n const readinessScriptElement = createCoraliteElement({\n type: 'tag',\n name: 'script',\n parent: head || root,\n attribs: {},\n children: []\n })\n\n const data = hasScripts\n ? 'window.__coralite_ready__ = new Promise(resolve => { window.__coralite_resolve_ready__ = resolve; });'\n : 'window.__coralite_ready__ = Promise.resolve(); window.__coralite_resolve_ready__ = () => {};'\n\n readinessScriptElement.children.push(createCoraliteTextNode({\n type: 'text',\n data,\n parent: readinessScriptElement\n }))\n\n if (head) {\n head.children.unshift(readinessScriptElement)\n } else {\n root.children.unshift(readinessScriptElement)\n }\n}\n\n/**\n * Injects an import map into the document head (or root if head is missing).\n *\n * @param {CoraliteComponentRoot} root - The root of the AST.\n * @param {CoraliteElement | null} head - The head element.\n * @param {Object} importMap - The import map object.\n */\nexport function injectImportMap (root, head, importMap) {\n if (!importMap || Object.keys(importMap).length === 0) {\n return\n }\n\n const importMapElement = createCoraliteElement({\n type: 'tag',\n name: 'script',\n parent: head || root,\n attribs: {\n type: 'importmap'\n },\n children: []\n })\n\n importMapElement.children.push(createCoraliteTextNode({\n type: 'text',\n data: JSON.stringify({ imports: importMap }),\n parent: importMapElement\n }))\n\n if (head) {\n head.children.push(importMapElement)\n } else {\n root.children.unshift(importMapElement)\n }\n}\n\n/**\n * Removes temporary and skip-render elements from the AST.\n *\n * @param {CoraliteElement[]} elements - The elements to remove.\n * @param {boolean} [matchInstance=true] - Whether to match by identity (true) or by 'remove' property (false).\n */\nexport function removeElements (elements, matchInstance = true) {\n if (!elements || elements.length === 0) {\n return\n }\n\n if (matchInstance) {\n for (let i = 0; i < elements.length; i++) {\n const element = elements[i]\n if (element.parent && element.parent.children) {\n element.parent.children = element.parent.children.filter(child => child !== element)\n }\n }\n } else {\n // Optimization: collect unique parents and filter children only once per parent\n const parents = new Set()\n for (let i = 0; i < elements.length; i++) {\n if (elements[i].parent) {\n parents.add(elements[i].parent)\n }\n }\n\n for (const parent of parents) {\n if (parent.children) {\n parent.children = parent.children.filter(child => !child._markedForRemoval)\n }\n }\n }\n}\n\n/**\n * Resolves the initial queue of pages to be generated.\n *\n * @param {CoraliteCollection} pagesCollection - The collection of pages.\n * @param {string | string[]} [path] - The path(s) to include.\n * @returns {CoraliteCollectionItem[]}\n */\nexport function resolvePageQueue (pagesCollection, path) {\n let queue = []\n\n if (Array.isArray(path)) {\n const uniquePaths = new Set(path)\n for (const p of uniquePaths) {\n const result = pagesCollection.getListByPath(p) || pagesCollection.getItem(p)\n if (result) {\n if (Array.isArray(result)) {\n queue = queue.concat(result)\n } else {\n queue.push(result)\n }\n }\n }\n } else if (typeof path === 'string') {\n const result = pagesCollection.getListByPath(path) || pagesCollection.getItem(path)\n if (result) {\n if (Array.isArray(result)) {\n queue = queue.concat(result)\n } else {\n queue.push(result)\n }\n }\n } else {\n queue = pagesCollection.list.slice()\n }\n\n return queue\n}\n", "/**\n * @import { InstanceContext } from '../types/index.js'\n */\n\n/**\n * Generates the client-side runtime script for Coralite pages.\n *\n * @param {Object} options - The options used to configure the client-side runtime.\n * @param {string} options.base - The base URL for assets.\n * @param {string} options.sharedChunkPath - The filename of the shared chunk.\n * @param {Object} options.chunkManifest - Manifest mapping component IDs to their chunk filenames.\n * @param {string[]} [options.declarativeTags=[]] - The declarative tags used.\n * @returns {string} The generated JavaScript runtime.\n */\nexport function generateClientRuntime ({\n base,\n sharedChunkPath,\n chunkManifest,\n declarativeTags = []\n}) {\n return `\nimport { getClientContext, getSetups, createCoraliteClass, globalClientHooks } from '${base}assets/js/${sharedChunkPath}';\n\n(async () => {\n if (!window.__coralite_ready__) {\n window.__coralite_ready__ = new Promise(resolve => { window.__coralite_resolve_ready__ = resolve; });\n }\n globalThis.executableScripts = [];\n globalThis.globalAbortController = new AbortController();\n\n const componentManifest = ${JSON.stringify(chunkManifest)};\n const loadCache = {};\n\n const loadComponent = (componentId) => {\n if (!componentManifest[componentId]) return Promise.resolve();\n if (customElements.get(componentId)) return Promise.resolve();\n if (loadCache[componentId]) return loadCache[componentId];\n\n loadCache[componentId] = (async () => {\n const module = await import('${base}assets/js/' + componentManifest[componentId]);\n if (module.default && module.default.componentId) {\n if (!customElements.get(module.default.componentId)) {\n customElements.define(module.default.componentId, createCoraliteClass(module.default, getClientContext, globalClientHooks));\n }\n }\n })();\n return loadCache[componentId];\n };\n\n const declarativeTags = ${JSON.stringify(declarativeTags)};\n const allTags = Object.keys(componentManifest);\n const imperativeTags = allTags.filter(tag => !declarativeTags.includes(tag));\n\n const loadPromises = declarativeTags.map(tagName => loadComponent(tagName));\n await Promise.all(loadPromises);\n\n if (typeof window.__coralite_resolve_ready__ === 'function') {\n window.__coralite_resolve_ready__();\n }\n\n if (imperativeTags.length > 0) {\n const lazyLoad = () => imperativeTags.forEach(tagName => loadComponent(tagName));\n \n if ('requestIdleCallback' in window) {\n requestIdleCallback(lazyLoad, { timeout: 500 });\n } else {\n setTimeout(lazyLoad, 1);\n }\n }\n})();\n`.trim()\n}\n", "import postcss from 'postcss'\nimport selectorParser from 'postcss-selector-parser'\n\n/**\n * @import { CoraliteOnError } from '../../../types/index.js'\n */\n\n/**\n * Transforms CSS to automatically apply `&.` prefix to classes present on the root element.\n * @param {string} css - The CSS content\n * @param {Set<string>} rootClasses - Set of classes found on the root element\n * @param {Set<string>} descendantClasses - Set of classes found on descendant elements\n * @param {CoraliteOnError} [onError] - Error handler\n * @returns {Promise<string>} Transformed CSS\n */\nexport async function transformCss (css, rootClasses, descendantClasses, onError) {\n const processor = postcss([\n {\n postcssPlugin: 'coralite-style-transform',\n Rule (rule) {\n // Only process top-level rules or rules directly inside @media/@supports etc.\n // Ignore rules nested inside other rules (standard CSS nesting behavior)\n if (rule.parent.type === 'rule') {\n return\n }\n\n const transformSelector = selectorParser((root) => {\n // Iterate over a static list to avoid infinite loops with insertions\n const selectors = []\n root.each(selector => {\n selectors.push(selector)\n })\n\n selectors.forEach((selector) => {\n // We only care about Selector nodes\n if (selector.type !== 'selector') {\n return\n }\n\n const firstNode = selector.first\n\n // Skip if empty or already nested\n if (!firstNode) {\n return\n }\n if (firstNode.type === 'nesting') {\n return\n }\n\n // Check if first node is a class\n if (firstNode.type === 'class') {\n const className = firstNode.value\n const isRoot = rootClasses.has(className)\n const isDescendant = descendantClasses.has(className)\n\n if (isRoot) {\n if (isDescendant) {\n // Transform to: &.classname, .classname\n // Clone first (creates the descendant version)\n const descendantSelector = selector.clone()\n\n // Modify the original to be root version (&.classname)\n const nesting = selectorParser.nesting()\n selector.insertBefore(firstNode, nesting)\n\n // Append the descendant selector to the parent Container\n root.insertAfter(selector, descendantSelector)\n } else {\n // Transform to: &.classname\n const nesting = selectorParser.nesting()\n selector.insertBefore(firstNode, nesting)\n }\n }\n }\n })\n })\n\n try {\n // @ts-ignore\n transformSelector.processSync(rule, { updateSelector: true })\n } catch (error) {\n const message = 'Error parsing selector: ' + rule.selector\n if (typeof onError === 'function') {\n onError({\n level: 'ERR',\n message,\n error\n })\n } else {\n console.error(message, error)\n }\n }\n }\n }\n ])\n\n const result = await processor.process(css, { from: undefined })\n return result.css\n}\n", "import { readFile, stat } from 'node:fs/promises'\nimport xxhash from 'xxhash-wasm'\n\n/**\n * @import { XXHashAPI } from 'xxhash-wasm'\n */\n\n/** @type {XXHashAPI['h64Raw'] | undefined} */\nlet hasher\n\n/** @type {Promise<void> | null} */\nlet initPromise = null\n\n/**\n * Initializes the xxHash hasher.\n * This should be called during the application setup phase.\n * @returns {Promise<void>}\n */\nexport async function initHasher () {\n if (hasher) {\n return\n }\n if (initPromise) {\n return initPromise\n }\n\n initPromise = (async () => {\n const { h64Raw } = await xxhash()\n hasher = h64Raw\n initPromise = null\n })()\n\n return initPromise\n}\n\n/**\n * Generates an xxHash64 hash of a string or Buffer.\n * @param {string | Uint8Array} data - The data to hash.\n * @returns {string}\n */\nexport function hash (data) {\n if (!hasher) {\n throw new Error('Hasher not initialized. Call initHasher() first.')\n }\n const uint8Data = typeof data === 'string' ? new TextEncoder().encode(data) : data\n const hashBigInt = hasher(uint8Data)\n return hashBigInt.toString(16).padStart(16, '0')\n}\n\n/**\n * Generates a hash of a file's content.\n * @param {string} filepath - The path to the file.\n * @returns {Promise<string>}\n */\nexport async function hashFile (filepath) {\n const content = await readFile(filepath)\n return hash(content)\n}\n\n/**\n * Performs a two-tier check on a file to see if it has changed.\n * Tier 1: mtime and size.\n * Tier 2: Hash (xxHash64).\n *\n * @param {string} filepath - The path to the file.\n * @param {Object} previousMetadata - The previous metadata.\n * @returns {Promise<{ changed: boolean, metadata: Object }>}\n */\nexport async function checkFileChange (filepath, previousMetadata = {}) {\n const stats = await stat(filepath)\n const mtime = stats.mtimeMs\n const size = stats.size\n\n if (previousMetadata.mtime === mtime && previousMetadata.size === size) {\n return {\n changed: false,\n metadata: previousMetadata\n }\n }\n\n const hash = await hashFile(filepath)\n const metadata = {\n mtime,\n size,\n hash\n }\n\n if (previousMetadata.hash === hash) {\n // mtime changed but hash is same, still return changed: false to optimize\n // but update metadata for next time (to keep mtime/size in sync)\n return {\n changed: false,\n metadata\n }\n }\n\n return {\n changed: true,\n metadata\n }\n}\n", "/**\n * @import {CoraliteConfig} from '../types/index.js'\n */\nimport { CoraliteError } from './utils/errors.js'\n\n/**\n * Validates and defines a Coralite configuration object\n * @param {CoraliteConfig} options - The configuration options to validate and define\n * @returns {CoraliteConfig} The validated configuration object\n * @throws {Error} If the configuration is invalid\n */\nexport function defineConfig (options) {\n // Validate that options is an object\n if (!options || typeof options !== 'object') {\n throw new CoraliteError('Config must be an object')\n }\n\n // Validate required string state\n const requiredProps = ['output', 'components', 'pages']\n\n for (const prop of requiredProps) {\n // Check if property exists\n if (!(prop in options)) {\n throw new CoraliteError(`Missing required config property: \"${prop}\"`)\n }\n\n // Check if property is a string\n if (typeof options[prop] !== 'string') {\n throw new CoraliteError(\n `Config property \"${prop}\" must be a string, received ${typeof options[prop]}`\n )\n }\n\n // Check if property is not empty\n if (options[prop].trim() === '') {\n throw new CoraliteError(`Config property \"${prop}\" cannot be empty`)\n }\n }\n\n // Validate optional plugins property\n if ('plugins' in options && options.plugins !== undefined) {\n if (!Array.isArray(options.plugins)) {\n throw new CoraliteError(\n `Config property \"plugins\" must be an array, received ${typeof options.plugins}`\n )\n }\n\n // Validate each plugin in the array\n options.plugins.forEach((plugin, index) => {\n if (typeof plugin !== 'object' || plugin === null) {\n throw new CoraliteError(\n `Plugin at index ${index} must be an object, received ${typeof plugin}`\n )\n }\n\n if (typeof plugin.name !== 'string' || plugin.name.trim() === '') {\n throw new CoraliteError(\n `Plugin at index ${index} must have a valid \"name\" property (non-empty string)`\n )\n }\n })\n }\n\n return options\n}\n", "import { createCoralite } from './coralite.js'\n\nexport * from '../types/index.js'\nexport * from './utils/index.js'\nexport * from './utils/server/index.js'\nexport * from './plugin.js'\nexport * from './config.js'\n\n/** @typedef {import('../types/core.js').CoraliteInstance} Coralite */\n\nexport { createCoralite }\nexport default createCoralite\n"],
5
- "mappings": ";AAAA,SAAS,SAAS,SA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,UACR,mBAAmB,KAAK,gCAAgC,OAAO,MAAM;AAAA,QACvE;AAAA,MACF;AAEA,UAAI,OAAO,OAAO,SAAS,YAAY,OAAO,KAAK,KAAK,MAAM,IAAI;AAChE,cAAM,IAAI;AAAA,UACR,mBAAmB,KAAK;AAAA,QAC1B;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AACT;;;ACrDA,IAAO,gBAAQ;",
6
- "names": ["dirname", "path", "parseJS", "walkJS", "transform", "path", "target", "dirname", "render", "parseJS", "walkJS", "dirname", "path", "dirname", "dirname", "join", "parse", "existsSync", "require", "mkdir", "writeFile", "dirname", "join", "relative", "parseJS", "parseJS", "render", "render", "pathToFileURL", "resolve", "createRequire", "path", "pathToFileURL", "resolve", "bindPlugins", "defineComponent", "createExecutionError", "createRequire", "evaluate", "dirname", "join", "relative", "pathToFileURL", "handleError", "evaluate", "pathToFileURL", "join", "relative", "dirname", "i", "getHtmlFile", "dirname", "join", "availableParallelism", "readFile", "mkdir", "pLimit", "path", "readFile", "hash", "evaluate", "handleError", "createExecutionError", "join", "dirname", "build", "readFile", "availableParallelism", "pLimit", "mkdir", "path", "relative", "join", "mkdir", "writeFile", "dirname"]
4
+ "sourcesContent": ["import { dirname, extname, join } from 'node:path'\nimport { readdir, readFile } from 'node:fs/promises'\nimport { readFileSync } from 'node:fs'\nimport { availableParallelism } from 'node:os'\nimport pLimit from 'p-limit'\nimport CoraliteCollection from '../../collection.js'\nimport { CoraliteError } from '../errors.js'\n\n/**\n * @import {\n * CoraliteCollectionEventSet,\n * CoraliteCollectionEventUpdate,\n * CoraliteCollectionEventDelete } from '../../../types/index.js'\n * @import { LimitFunction } from 'p-limit'\n */\n\n/**\n * Get HTML\n * @param {Object} options - Options for searching HTML files\n * @param {string} options.path - Path to the directory containing HTML files\n * @param {'page' | 'component'} options.type - Document types\n * @param {boolean} [options.recursive=false] - Whether to search recursively in subdirectories\n * @param {string[]} [options.exclude=[]] - Files or directories to exclude from search\n * @param {CoraliteCollectionEventSet} [options.onFileSet] - The callback triggered when a file is set in the collection.\n * @param {CoraliteCollectionEventUpdate} [options.onFileUpdate] - The callback triggered when a file is updated in the collection.\n * @param {CoraliteCollectionEventDelete} [options.onFileDelete] - The callback triggered when a file is deleted from the collection.\n * @param {CoraliteCollection} [options.collection] - Optional collection instance to populate\n * @param {LimitFunction} [options.limit] - Optional concurrency limiter\n * @param {boolean} [options.discoverOnly=false] - Whether to skip reading file content and only discover paths\n * @returns {Promise<CoraliteCollection>} Array of HTML file data including parent path, name, and content\n *\n * @example\n * // example usage:\n * const htmlFiles = await getHtmlFiles({\n * path: 'src',\n * recursive: true,\n * exclude: ['index.html', 'subdir/file2.html']\n * })\n */\nexport async function getHtmlFiles ({\n path,\n type,\n recursive = false,\n exclude = [],\n discoverOnly = false,\n onFileSet,\n onFileUpdate,\n onFileDelete,\n collection,\n limit\n}) {\n const resultCollection = collection || new CoraliteCollection({\n rootDir: path,\n onSet: onFileSet,\n onUpdate: onFileUpdate,\n onDelete: onFileDelete\n })\n\n if (!limit) {\n limit = pLimit(availableParallelism())\n }\n\n const entries = await readdir(path, { withFileTypes: true })\n const tasks = []\n\n for (let i = 0; i < entries.length; i++) {\n const entry = entries[i]\n\n // Skip hidden files/directories starting with dot\n if (entry.name.startsWith('.')) {\n continue\n }\n\n const pathname = join(entry.parentPath, entry.name)\n\n // Calculate relative path from root for exclusion checking\n const relativePath = pathname.replace(path + '/', '')\n\n // Check if entry should be excluded by: name, relative path, or full path\n const shouldExclude = exclude.includes(entry.name) ||\n exclude.includes(relativePath) ||\n exclude.includes(pathname) ||\n exclude.some(excludePath => {\n // Handle directory-based exclusions\n const excludeDir = excludePath.endsWith('/') ? excludePath.slice(0, -1) : excludePath\n return relativePath.startsWith(excludeDir + '/')\n })\n\n if (shouldExclude) {\n continue\n }\n\n if (entry.isDirectory() && recursive) {\n tasks.push(getHtmlFiles({\n path: pathname,\n type,\n recursive,\n exclude,\n discoverOnly,\n onFileSet,\n onFileUpdate,\n onFileDelete,\n collection: resultCollection,\n limit\n }))\n } else if (entry.isFile() && extname(entry.name).toLowerCase() === '.html') {\n tasks.push(limit(async () => {\n const content = discoverOnly ? undefined : await readFile(pathname, { encoding: 'utf8' })\n\n await resultCollection.setItem({\n type,\n content,\n virtual: false,\n path: {\n pathname: pathname,\n filename: entry.name,\n dirname: dirname(pathname)\n }\n })\n }))\n }\n }\n\n await Promise.all(tasks)\n\n return resultCollection\n}\n\n/**\n * Generator that yields HTML files found in a directory.\n * Useful for lazy discovery and memory-efficient processing of many files.\n *\n * @param {Object} options - Options for searching HTML files\n * @param {string} options.path - Path to the directory containing HTML files\n * @param {'page' | 'component'} options.type - Document types\n * @param {boolean} [options.recursive=false] - Whether to search recursively\n * @param {string[]} [options.exclude=[]] - Files or directories to exclude\n * @param {boolean} [options.discoverOnly=false] - Whether to skip reading file content\n * @yields {Promise<{ type: 'page' | 'component', content: string | undefined, path: { pathname: string, filename: string, dirname: string } }>}\n */\nexport async function* discoverHtmlFiles ({\n path,\n type,\n recursive = false,\n exclude = [],\n discoverOnly = false\n}) {\n const entries = await readdir(path, { withFileTypes: true })\n\n for (let i = 0; i < entries.length; i++) {\n const entry = entries[i]\n\n if (entry.name.startsWith('.')) {\n continue\n }\n\n const pathname = join(entry.parentPath, entry.name)\n const relativePath = pathname.replace(path + '/', '')\n\n const shouldExclude = exclude.includes(entry.name) ||\n exclude.includes(relativePath) ||\n exclude.includes(pathname) ||\n exclude.some(excludePath => {\n const excludeDir = excludePath.endsWith('/') ? excludePath.slice(0, -1) : excludePath\n return relativePath.startsWith(excludeDir + '/')\n })\n\n if (shouldExclude) {\n continue\n }\n\n if (entry.isDirectory() && recursive) {\n yield* discoverHtmlFiles({\n path: pathname,\n type,\n recursive,\n exclude,\n discoverOnly\n })\n } else if (entry.isFile() && extname(entry.name).toLowerCase() === '.html') {\n const content = discoverOnly ? undefined : await readFile(pathname, { encoding: 'utf8' })\n\n yield {\n type,\n content,\n virtual: false,\n path: {\n pathname: pathname,\n filename: entry.name,\n dirname: dirname(pathname)\n }\n }\n }\n }\n}\n\n/**\n * Reads an HTML file and returns its content as a string.\n * @param {string} pathname - The path to the HTML file.\n * @throws {Error} If the file cannot be read.\n */\nexport function getHtmlFileSync (pathname) {\n try {\n const extension = extname(pathname).toLowerCase()\n\n if (extension === '.html') {\n return readFileSync(pathname, 'utf8')\n }\n\n throw new CoraliteError('Unexpected filename extension \"' + extension +'\"', {\n filePath: pathname\n })\n } catch (err) {\n throw err\n }\n}\n\n/**\n * Reads an HTML file and returns its content as a string.\n * @param {string} pathname - The path to the HTML file.\n * @throws {Error} If the file cannot be read.\n */\nexport async function getHtmlFile (pathname) {\n try {\n const extension = extname(pathname).toLowerCase()\n\n if (extension === '.html') {\n return await readFile(pathname, 'utf8')\n }\n\n throw new CoraliteError('Unexpected filename extension \"' + extension +'\"', {\n filePath: pathname\n })\n } catch (err) {\n throw err\n }\n}\n", "import path from 'node:path'\nimport { getHtmlFile } from './utils/server/html.js'\nimport { CoraliteError } from './utils/errors.js'\nimport { access } from 'node:fs/promises'\nimport { existsSync } from 'node:fs'\n\n/**\n * @import {\n * CoraliteCollectionEventDelete,\n * CoraliteCollectionEventSet,\n * CoraliteCollectionEventUpdate,\n * CoraliteCollectionItem,\n * HTMLData } from '../types/index.js'\n */\n\n/**\n * Represents a collection of documents with methods to organize and retrieve them.\n * Maintains three views: flat list, path-based grouping, and ID lookup.\n * @class\n * @param {Object} [options={}] - Options for configuring the collection\n * @param {string} [options.rootDir=''] - The root directory path for the collection\n * @param {CoraliteCollectionEventSet} [options.onSet] - Event handler for when documents are set\n * @param {CoraliteCollectionEventUpdate} [options.onUpdate] - Event handler for when documents are updated\n * @param {CoraliteCollectionEventDelete} [options.onDelete] - Event handler for when documents are deleted\n */\nfunction CoraliteCollection (options = { rootDir: '' }) {\n /**\n * Root directory where collection items are located\n */\n this.rootDir = path.join(options.rootDir)\n\n if (!existsSync(this.rootDir)) {\n throw new CoraliteError('Root directory was not found: ' + this.rootDir, {\n filePath: this.rootDir\n })\n }\n\n /**\n * An array of HTMLData objects representing the list of documents.\n * @type {CoraliteCollectionItem[]}\n */\n this.list = []\n\n /**\n * An object mapping paths to arrays of HTMLData objects.\n * Used for grouping documents by their file path.\n * @type {Object.<string, CoraliteCollectionItem[]>}\n */\n this.listByPath = Object.create(null)\n\n /**\n * An object mapping unique identifiers to HTMLData objects.\n * Used for quick lookup of documents by their identifier.\n * @type {Object.<string, CoraliteCollectionItem>}\n */\n this.collection = Object.create(null)\n\n /**\n * Callback triggered when setting a new item\n * @type {CoraliteCollectionEventSet | undefined}\n */\n this._onSet = options.onSet\n\n /**\n * Callback triggered when updating an existing item\n * @type {CoraliteCollectionEventUpdate | undefined}\n */\n this._onUpdate = options.onUpdate\n\n /**\n * Callback triggered when deleting an item\n * @type {CoraliteCollectionEventDelete | undefined}\n */\n this._onDelete = options.onDelete\n}\n\n/**\n * Adds or updates an HTMLData object in the collection and associated lists.\n * If the item already exists, it will be updated in all views.\n * @param {HTMLData|string} value - The HTMLData object to be added or updated.\n * @returns {Promise<CoraliteCollectionItem>} The modified document\n */\nCoraliteCollection.prototype.setItem = async function (value) {\n if (typeof value === 'string') {\n value = await this._loadByPath(value)\n }\n\n if (!value || !value.path) {\n throw new CoraliteError('Valid HTMLData object must be provided')\n }\n\n const pathname = value.path.pathname\n const dirname = value.path.dirname\n const originalValue = this.collection[pathname]\n\n /** @type {CoraliteCollectionItem} */\n const documentValue = value\n\n if (!originalValue) {\n // handle pre-set hook if defined\n if (typeof this._onSet === 'function') {\n const result = await this._onSet(value)\n\n // abort adding item\n if (!result) {\n return\n }\n\n documentValue.result = result.value\n\n if (result.state) {\n documentValue.state = result.state\n }\n\n if (result.type === 'page' || result.type === 'component') {\n documentValue.type = result.type\n }\n\n // update collection using ID from hook result if available\n if (typeof result.id === 'string' && result.id) {\n this.collection[result.id] = documentValue\n }\n\n if (documentValue.result && typeof documentValue.result === 'object') {\n documentValue.result.path = documentValue.path\n }\n }\n\n // always update the collection with current pathname\n this.collection[pathname] = documentValue\n\n // initialize directory list if it doesn't exist\n if (!this.listByPath[dirname]) {\n this.listByPath[dirname] = []\n }\n\n // add to both directory-specific and general lists\n // check if already added to avoid duplicates\n if (!this.listByPath[dirname].includes(documentValue)) {\n this.listByPath[dirname].push(documentValue)\n }\n if (!this.list.includes(documentValue)) {\n this.list.push(documentValue)\n }\n } else {\n return await this.updateItem(value)\n }\n\n return documentValue\n}\n\n/**\n * Removes an HTMLData object from the collection and associated lists.\n * Accepts either an HTMLData object or a pathname string.\n * @param {HTMLData | string} value - The HTMLData object or a pathname to be removed.\n * @throws {Error} If invalid input is provided\n */\nCoraliteCollection.prototype.deleteItem = async function (value) {\n if (!value) {\n throw new CoraliteError('Valid pathname must be provided')\n }\n\n let pathname\n let dirname\n let valuesByPath\n let originalValue\n\n if (typeof value !== 'string' && value.path) {\n // if the input is an HTMLData object, extract its pathname and directory name\n pathname = value.path.pathname\n dirname = value.path.dirname\n valuesByPath = this.listByPath[dirname]\n originalValue = value\n } else if (typeof value === 'string') {\n // if the input is a string, use it as the pathname and determine the directory name\n pathname = value\n dirname = path.dirname(pathname)\n valuesByPath = this.listByPath[dirname]\n originalValue = this.collection[pathname]\n } else {\n throw new CoraliteError('Valid pathname must be provided')\n }\n\n if (!originalValue) {\n // item not found, nothing to delete\n return\n }\n\n if (!valuesByPath) {\n // directory list doesn't exist, but we still need to clean up collection\n // This can happen if the item was stored under a different ID\n for (const key in this.collection) {\n if (this.collection[key] === originalValue) {\n delete this.collection[key]\n }\n }\n return\n }\n\n if (typeof this._onDelete === 'function') {\n await this._onDelete(originalValue)\n }\n\n // remove the document from the collection\n // also check if it's stored under a different ID (from hook result)\n for (const key in this.collection) {\n if (this.collection[key] === originalValue) {\n delete this.collection[key]\n }\n }\n\n // find and remove the document from the list and by-path grouping\n const listIndex = this.list.indexOf(originalValue)\n const pathIndex = valuesByPath.indexOf(originalValue)\n\n if (listIndex !== -1) {\n this.list.splice(listIndex, 1)\n }\n if (pathIndex !== -1) {\n valuesByPath.splice(pathIndex, 1)\n }\n\n // clean up empty directory arrays\n if (valuesByPath.length === 0) {\n delete this.listByPath[dirname]\n }\n}\n\n/**\n * Updates an existing HTMLData object in the collection.\n * If the document does not exist, it will be added using the set method.\n * @param {CoraliteCollectionItem|string} value - The HTMLData object to be updated or added.\n * @throws {Error} If invalid input is provided\n */\nCoraliteCollection.prototype.updateItem = async function (value) {\n if (typeof value === 'string') {\n value = await this._loadByPath(value)\n }\n\n if (!value || !value.path) {\n throw new CoraliteError('Valid HTMLData object must be provided')\n }\n\n const pathname = value.path.pathname\n const originalValue = this.collection[pathname]\n\n if (!originalValue) {\n // if the document does not exist, add it using the set method\n return await this.setItem(value)\n }\n\n if (typeof this._onUpdate === 'function') {\n const result = await this._onUpdate(value, originalValue)\n\n // abort update\n if (!result) {\n return originalValue\n }\n\n // handle callback result\n if (result && typeof result === 'object') {\n // if result has a value property, use it\n if (result.value !== undefined) {\n originalValue.result = result.value\n } else {\n originalValue.result = result\n }\n\n // update type if provided\n if (result.type === 'page' || result.type === 'component') {\n originalValue.type = result.type\n }\n } else {\n originalValue.result = result\n }\n }\n\n // update core state\n if (value.content !== undefined) {\n originalValue.content = value.content\n }\n\n // update path information if it changed\n if (value.path && value.path !== originalValue.path) {\n originalValue.path = value.path\n }\n\n // update type if explicitly set\n if (value.type) {\n originalValue.type = value.type\n }\n\n // update any additional state\n if (value.state !== undefined) {\n originalValue.state = value.state\n }\n\n // update ISR related fields\n if (value.cacheKey !== undefined) {\n originalValue.cacheKey = value.cacheKey\n }\n if (value.volatile !== undefined) {\n originalValue.volatile = value.volatile\n }\n if (value.virtual !== undefined) {\n originalValue.virtual = value.virtual\n }\n\n if (originalValue.result && typeof originalValue.result === 'object') {\n originalValue.result.path = originalValue.path\n }\n\n return originalValue\n}\n\n/**\n * Retrieves an item by its unique identifier\n * @param {string} id - Unique identifier of the item\n * @returns {CoraliteCollectionItem | undefined} The found item or undefined\n */\nCoraliteCollection.prototype.getItem = function (id) {\n if (!this.collection[id] && id.endsWith('html')) {\n id = path.join(this.rootDir, id)\n }\n\n return this.collection[id]\n}\n\n/**\n * Retrieves a list of items grouped by directory path\n * @param {string} dirname - Directory name to look up\n * @returns {CoraliteCollectionItem[] | undefined} A copy of the item list or undefined\n */\nCoraliteCollection.prototype.getListByPath = function (dirname) {\n const list = this.listByPath[dirname]\n\n if (list) {\n return list.slice()\n }\n}\n\n/**\n * Loads a collection item by its file path.\n *\n * @param {string} filepath - The path to the collection item file\n * @returns {Promise<HTMLData>} A promise that resolves to the loaded item object\n * @throws {Error} If the file cannot be found at either the provided path or within the root directory\n */\nCoraliteCollection.prototype._loadByPath = async function (filepath) {\n try {\n await access(filepath)\n } catch {\n try {\n filepath = path.join(this.rootDir, filepath)\n\n await access(filepath)\n } catch {\n throw new CoraliteError('Could not find collection item: ' + filepath, {\n filePath: filepath\n })\n }\n }\n\n const content = await getHtmlFile(filepath)\n\n return {\n type: 'page',\n content,\n path: {\n pathname: filepath,\n dirname: path.dirname(filepath),\n filename: path.basename(filepath)\n }\n }\n}\n\nexport default CoraliteCollection\n", "\n/**\n * @import { CoraliteErrorData } from '../../types/index.js'\n */\n\n/**\n * Base error class for all Coralite-related errors.\n */\nexport class CoraliteError extends Error {\n /**\n * @param {string} message - The error message.\n * @param {Object} [options] - Additional options for the error.\n * @param {string} [options.componentId] - The ID of the component where the error occurred.\n * @param {string} [options.filePath] - The path to the file where the error occurred.\n * @param {string} [options.instanceId] - The unique ID of the component instance.\n * @param {string} [options.pagePath] - The path to the page being rendered.\n * @param {number} [options.line] - The line number where the error occurred.\n * @param {number} [options.column] - The column number where the error occurred.\n * @param {string} [options.stackFile] - The file name from the stack trace.\n * @param {Error} [options.cause] - The original error that caused this error.\n */\n constructor (message, options = {}) {\n super(message, options)\n this.name = 'CoraliteError'\n this.isCoraliteError = true\n this.componentId = options.componentId\n this.filePath = options.filePath\n this.instanceId = options.instanceId\n this.pagePath = options.pagePath\n this.line = options.line\n this.column = options.column\n this.stackFile = options.stackFile\n\n // Polyfill cause if necessary (node version differences)\n if (options.cause && !this.cause) {\n this.cause = options.cause\n }\n }\n}\n\n/**\n * Default error handler.\n * @param {CoraliteErrorData} data - The data object containing error details.\n */\nexport function defaultOnError ({ level, message, error }) {\n if (level === 'ERR') {\n if (error) {\n throw error\n }\n throw new CoraliteError(message)\n } else if (level === 'WARN') {\n console.warn(message)\n } else {\n console.log(message)\n }\n}\n\n/**\n * Handles errors using an optional callback or the default handler.\n * @param {Object} options - The options for handling the error.\n * @param {Function} [options.onErrorCallback] - The optional custom error callback function.\n * @param {CoraliteErrorData} options.data - The error data to be handled.\n */\nexport function handleError ({ onErrorCallback, data }) {\n const error = data.error\n if (error && 'isCoraliteError' in error && error.isCoraliteError) {\n const coraliteError = error\n // @ts-ignore\n data.componentId = data.componentId || coraliteError.componentId\n // @ts-ignore\n data.filePath = data.filePath || coraliteError.filePath\n // @ts-ignore\n data.instanceId = data.instanceId || coraliteError.instanceId\n // @ts-ignore\n data.pagePath = data.pagePath || coraliteError.pagePath\n // @ts-ignore\n data.line = data.line || coraliteError.line\n // @ts-ignore\n data.column = data.column || coraliteError.column\n // @ts-ignore\n data.stackFile = data.stackFile || coraliteError.stackFile\n }\n\n if (onErrorCallback) {\n onErrorCallback(data)\n } else {\n defaultOnError(data)\n }\n}\n", "import { Parser } from 'htmlparser2'\nimport {\n createCoraliteElement,\n createCoraliteTextNode,\n createCoraliteComment,\n createCoraliteDirective,\n createCoraliteComponent,\n relinkChildren\n} from './dom.js'\nimport { isValidCustomElementName, VALID_TAGS } from '../tags.js'\nimport { CoraliteError } from '../errors.js'\n\n/**\n * @import {\n * CoraliteToken,\n * CoraliteModule,\n * CoraliteTextNode,\n * CoraliteElement,\n * CoraliteModuleSlotElement,\n * CoraliteComponentValues,\n * CoraliteComponentRoot,\n * CoraliteContentNode,\n * Attribute,\n * ParseHTMLResult,\n * CoraliteOnError} from '../../../types/index.js'\n */\n\n/**\n * @internal\n * @param {CoraliteElement} element - The element being parsed\n * @param {Record<string, string>} attributes - A dictionary of element attributes\n * @param {Array<string | Attribute>} skipRenderByAttribute - Keys to search for skip flag\n */\nfunction applySkipRenderAttribute (element, attributes, skipRenderByAttribute) {\n if (skipRenderByAttribute && skipRenderByAttribute.length > 0) {\n for (let i = 0; i < skipRenderByAttribute.length; i++) {\n const skipItem = skipRenderByAttribute[i]\n if (typeof skipItem === 'string') {\n if (Object.prototype.hasOwnProperty.call(attributes, skipItem)) {\n element.skipRender = true\n break\n }\n } else if (skipItem && typeof skipItem === 'object') {\n if (Object.prototype.hasOwnProperty.call(attributes, skipItem.name) && attributes[skipItem.name].includes(skipItem.value)) {\n element.skipRender = true\n break\n }\n }\n }\n }\n}\n\nfunction handleTemplateOpenTag (attributes) {\n if (!attributes.id) {\n throw new CoraliteError('Template requires an \"id\"')\n }\n if (!isValidCustomElementName(attributes.id)) {\n throw new CoraliteError('Invalid template id: \"' + attributes.id + '\" it must match following the pattern https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name')\n }\n return attributes.id\n}\n\n/**\n * @internal\n * @param {CoraliteElement} element - The slot element node\n * @param {Record<string, string>} attributes - A dictionary of element attributes\n * @param {string} templateId - Current template definition id\n * @param {Object.<string, Object.<string, CoraliteModuleSlotElement>>} slotElements - State containing slot lists\n */\nfunction handleSlotOpenTag (element, attributes, templateId, slotElements) {\n const name = attributes.name || 'default'\n if (slotElements[templateId] && slotElements[templateId][name]) {\n throw new CoraliteError('Slot names must be unique: \"' + name + '\"', {\n componentId: templateId\n })\n }\n const slot = {\n name,\n element\n }\n if (!slotElements[templateId]) {\n slotElements[templateId] = { [name]: slot }\n } else {\n slotElements[templateId][name] = slot\n }\n}\n\n/**\n * Parse HTML content and return a CoraliteComponent object representing the parsed component structure\n *\n * @param {string} string - HTML content to parse as string input type textual data\n * @param {Array<string | Attribute>} [ignoreByAttribute] - Ignore element with attribute name value pair\n * @param {Array<string | Attribute>} [skipRenderByAttribute] - Parse element but remove before final render\n * @param {CoraliteOnError} [onError] - Callback function for error and warning handling\n * @returns {ParseHTMLResult}\n * @example parseHTML('<h1>Hello world!</h1>')\n */\nexport function parseHTML (string, ignoreByAttribute, skipRenderByAttribute, onError) {\n // root element reference\n const root = createCoraliteComponent({\n type: 'root',\n children: []\n })\n\n // stack to keep track of current element hierarchy\n /** @type {CoraliteContentNode[]} */\n const stack = [root]\n const customElements = []\n /** @type {CoraliteElement[]} */\n const tempElements = []\n /** @type {CoraliteElement[]} */\n const skipRenderElements = []\n\n const ignoreAttributeMap = getIgnoreAttributeMap(ignoreByAttribute)\n\n const parser = new Parser({\n onprocessinginstruction (name, data) {\n root.children.push(createCoraliteDirective({\n type: 'directive',\n name,\n data\n }))\n },\n onopentag (originalName, attributes) {\n const name = originalName.toLowerCase()\n const parent = stack[stack.length - 1]\n const element = createElement({\n name,\n attributes,\n parent,\n ignoreByAttribute: ignoreAttributeMap,\n onError\n })\n\n applySkipRenderAttribute(element, attributes, skipRenderByAttribute)\n\n if (element.slots) {\n // store custom element\n customElements.push(element)\n }\n\n // push element to stack as it may have children\n stack.push(element)\n },\n ontext (text) {\n const parent = stack[stack.length - 1]\n\n createTextNode(text, parent)\n },\n onclosetag () {\n const element = stack[stack.length - 1]\n\n if (element.type === 'tag') {\n if (element._markedForRemoval) {\n // store element for removal\n // @ts-ignore\n tempElements.push(element.parent.children[element.parent.children.length - 1])\n } else if (element.skipRender) {\n // @ts-ignore\n skipRenderElements.push(element.parent.children[element.parent.children.length - 1])\n }\n }\n\n // remove current element from stack as we're done with its children\n stack.pop()\n },\n oncomment (data) {\n const parent = stack[stack.length - 1]\n\n parent.children.push(createCoraliteComment({\n type: 'comment',\n data,\n parent\n }))\n }\n }, { decodeEntities: false })\n\n parser.write(string)\n parser.end()\n\n relinkChildren(root)\n sortSlottedChildren(customElements)\n\n return {\n root,\n customElements,\n tempElements,\n skipRenderElements\n }\n}\n\n/**\n * Processes custom elements to organize their children by slot name.\n * @param {CoraliteElement[]} elements - Array of custom element objects with `children` and `attribs`.\n */\nfunction sortSlottedChildren (elements) {\n for (let i = 0; i < elements.length; i++) {\n const element = elements[i]\n\n for (let k = 0; k < element.children.length; k++) {\n const childNode = element.children[k]\n let slotName = 'default'\n\n if (childNode.type === 'tag'\n && childNode.attribs\n && childNode.attribs.slot) {\n slotName = childNode.attribs.slot\n\n // clean up slot attribute\n delete childNode.attribs.slot\n }\n\n element.slots.push({\n name: slotName,\n node: childNode\n })\n }\n }\n}\n\n/**\n * Parses HTML string containing meta tags or generates Coralite module structure from markup.\n *\n * @param {string} string - HTML content containing meta tags or module markup\n * @param {Object} options - The options for parsing the module.\n * @param {Array<string | Attribute>} options.ignoreByAttribute - An array of attribute names and values to ignore during parsing\n * @param {Array<string | Attribute>} [options.skipRenderByAttribute] - An array of attributes that exclude element from rendering\n * @param {CoraliteOnError} [options.onError] - Callback function for error and warning handling\n * @returns {CoraliteModule} - Parsed module information, including template, script, tokens, and slot configurations\n *\n * @example\n * ```\n * // example usage:\n * const html = `<template id=\"home\">\n * <slot name=\"default\">Hello</slot>\n * </template>`;\n * const module = parseModule(html, { ignoreByAttribute: [] });\n *\n * // module object structure will be:\n * //{\n * // id: 'home',\n * // template: { ... },\n * // tokens: [],\n * // customElements: [],\n * // slotElements: {\n * // default: {\n * // name: 'slot',\n * // element: {}\n * // }\n * // }\n * //}\n * ```\n */\nexport function parseModule (string, { ignoreByAttribute, skipRenderByAttribute, onError }) {\n // root element reference\n const root = createCoraliteComponent({\n type: 'root',\n children: []\n })\n // stack to keep track of current element hierarchy\n /** @type {CoraliteContentNode[]} */\n const stack = [root]\n const customElements = []\n /** @type {Object.<string, Object.<string,CoraliteModuleSlotElement>>} */\n const slotElements = {}\n /** @type {CoraliteComponentValues} */\n const documentValues = {\n refs: [],\n attributes: [],\n textNodes: []\n }\n const styles = []\n let isScript = false\n let isTemplate = false\n let templateId = ''\n const rootClasses = new Set()\n const descendantClasses = new Set()\n\n const ignoreAttributeMap = getIgnoreAttributeMap(ignoreByAttribute)\n\n const parser = new Parser({\n onopentag (originalName, attributes) {\n const parent = stack[stack.length - 1]\n const element = createElement({\n name: originalName,\n attributes,\n parent,\n ignoreByAttribute: ignoreAttributeMap,\n onError\n })\n\n applySkipRenderAttribute(element, attributes, skipRenderByAttribute)\n\n if (element.slots) {\n customElements.push(element)\n }\n\n // push element to stack as it may have children\n stack.push(element)\n\n if (element.name === 'script') {\n isScript = true\n } else if (element.name === 'template') {\n isTemplate = true\n templateId = handleTemplateOpenTag(attributes)\n } else if (element.name === 'slot') {\n handleSlotOpenTag(element, attributes, templateId, slotElements)\n } else if (isTemplate) {\n const attributeNames = Object.keys(attributes)\n\n // Collect classes\n if (attributes.class && parent.type !== 'root') {\n const classes = attributes.class.trim().split(/\\s+/)\n const isRoot = parent.name === 'template'\n\n for (const className of classes) {\n if (className) {\n if (isRoot) {\n rootClasses.add(className)\n } else {\n descendantClasses.add(className)\n }\n }\n }\n }\n\n // collect tokens inside template tag\n if (attributeNames.length) {\n for (let i = 0; i < attributeNames.length; i++) {\n const name = attributeNames[i]\n const value = attributes[name]\n const tokens = getTokensFromString(value)\n\n // store attribute tokens\n if (tokens.length) {\n documentValues.attributes.push({\n name,\n tokens,\n element\n })\n }\n\n if (name === 'ref') {\n documentValues.refs.push({\n name: value,\n element\n })\n }\n }\n }\n }\n },\n ontext (text) {\n const parent = stack[stack.length - 1]\n\n if (isTemplate && !isScript && text.trim()) {\n const topLevelTokens = getTokensFromString(text, true)\n\n if (topLevelTokens.length) {\n let lastIndex = 0\n for (const token of topLevelTokens) {\n const index = text.indexOf(token.content, lastIndex)\n\n if (index > lastIndex) {\n createTextNode(text.substring(lastIndex, index), parent)\n }\n\n const cToken = createCoraliteElement({\n type: 'tag',\n name: 'c-token',\n parent,\n attribs: {},\n children: []\n })\n parent.children.push(cToken)\n\n const tokenNode = createTextNode(token.content, cToken)\n documentValues.textNodes.push({\n tokens: getTokensFromString(token.content),\n textNode: tokenNode,\n type: 'html'\n })\n\n lastIndex = index + token.content.length\n }\n\n if (lastIndex < text.length) {\n createTextNode(text.substring(lastIndex), parent)\n }\n return\n }\n }\n\n createTextNode(text, parent)\n },\n onclosetag (name) {\n const element = stack[stack.length - 1]\n\n if (element.type === 'tag' && element._markedForRemoval) {\n // remove element from tree\n element.parent.children.pop()\n }\n\n if (name === 'template') {\n // exit template tag\n isTemplate = false\n } else if (name === 'script') {\n isScript = false\n }\n\n // remove current element from stack as we're done with its children\n stack.pop()\n },\n oncdatastart () {\n },\n\n oncomment (data) {\n stack[stack.length - 1].children.push(createCoraliteComment({\n type: 'comment',\n data,\n parent: stack[stack.length - 1]\n }))\n }\n }, { decodeEntities: false })\n\n parser.write(string)\n parser.end()\n\n relinkChildren(root)\n\n /** @type {CoraliteElement} */\n let template\n let script\n\n for (let i = 0; i < root.children.length; i++) {\n const node = root.children[i]\n\n if (node.type === 'tag') {\n if (node.name === 'template') {\n if (template) {\n throw new CoraliteError('One template element is permitted', {\n componentId: templateId\n })\n }\n\n // @ts-ignore\n template = node\n\n } else if (node.name === 'script') {\n if (node.attribs.type !== 'module') {\n throw new CoraliteError('Template \"' + templateId + '\" script tag must contain the `type=\"module\"` attribute', {\n componentId: templateId\n })\n }\n const scriptString = node.children[0]\n\n if (scriptString.type !== 'text') {\n throw new CoraliteError('Script tag must contain text', {\n componentId: templateId\n })\n }\n\n script = scriptString.data\n } else if (node.name === 'style') {\n const styleContent = node.children[0]\n\n if (styleContent && styleContent.type === 'text') {\n styles.push(styleContent.data)\n }\n }\n }\n }\n\n if (!template) {\n return {\n isTemplate: false\n }\n }\n\n const scriptIndex = string.indexOf('<script')\n const scriptTagEnd = string.indexOf('>', scriptIndex) + 1\n const stringHead = string.substring(0, scriptTagEnd)\n const lineOffset = stringHead.split(/\\r\\n|\\r|\\n/).length - 1\n\n return {\n id: template.attribs.id,\n template,\n script,\n styles,\n values: documentValues,\n lineOffset,\n customElements,\n slotElements,\n isTemplate: true,\n rootClasses,\n descendantClasses\n }\n}\n\n/**\n * Creates an element within the component structure based on provided parameters.\n * @param {Object} data - An object containing details needed to create the element.\n * @param {string} data.name - The tag name of the new element.\n * @param {Object.<string, string>} data.attributes - Attributes for the new element.\n * @param {CoraliteElement | CoraliteComponentRoot} data.parent - Parent element or component root where this element will be attached.\n * @param {Array<string | Attribute> | Map<string, string[]>} [data.ignoreByAttribute] - Optional parameter used for ignoring elements based on attributes.\n * @param {CoraliteOnError} [data.onError] - Callback function for error and warning handling\n * @returns {CoraliteElement} The newly created element with its parent reference and position in the parent's children list.\n */\nexport function createElement ({\n name,\n attributes,\n parent,\n ignoreByAttribute,\n onError\n}) {\n const sanitisedName = name.toLowerCase()\n const element = createCoraliteElement({\n type: 'tag',\n name: sanitisedName,\n attribs: attributes,\n children: [],\n parent,\n parentChildIndex: parent.children.length\n })\n\n if (ignoreByAttribute) {\n const ignore = findAttributesToIgnore(ignoreByAttribute, attributes)\n\n if (ignore) {\n element._markedForRemoval = true\n }\n }\n\n if (!VALID_TAGS[sanitisedName]) {\n const specUrl = 'https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name'\n\n try {\n element.name = name\n\n // check if the tag name matches the regex for valid custom elements\n if (isValidCustomElementName(name)) {\n // store custom elements\n element.slots = []\n } else {\n const message = 'Invalid custom element tag name: \"' + name + '\" (' + specUrl + ')'\n if (typeof onError === 'function') {\n onError({\n level: 'WARN',\n message\n })\n } else {\n console.warn(message)\n }\n }\n } catch (error) {\n const message = error.message + ' (' + specUrl + ')'\n if (typeof onError === 'function') {\n onError({\n level: 'WARN',\n message,\n error\n })\n } else {\n console.warn(message)\n }\n }\n }\n\n // add element to its parent's children\n parent.children.push(element)\n\n return element\n}\n\n/**\n * @param {string} data - The text content to create a text node\n * @param {CoraliteElement | CoraliteComponentRoot} parent - parent node\n * @returns {CoraliteTextNode}\n *\n * @example\n * const textNode = createTextNode('Hello World', parentNode);\n */\nexport function createTextNode (data, parent) {\n /** @type {CoraliteTextNode} */\n const textNode = createCoraliteTextNode({\n type: 'text',\n data,\n parent\n })\n\n // @ts-ignore\n parent.children.push(textNode)\n\n return textNode\n}\n\n/**\n * Find attributes to be ignored by the parser.\n *\n * @param {Array<string | Attribute> | Map<string, Array<string | null>>} ignoreByAttribute - An array of attribute pairs/strings or a map to be ignored by the parser\n * @param {Object<string, string>} attributes - The HTML attribute object to be parsed by the parser\n * @returns {boolean}\n */\nfunction findAttributesToIgnore (ignoreByAttribute, attributes) {\n if (Array.isArray(ignoreByAttribute)) {\n for (let i = 0; i < ignoreByAttribute.length; i++) {\n const item = ignoreByAttribute[i]\n if (typeof item === 'string') {\n if (Object.prototype.hasOwnProperty.call(attributes, item)) {\n return true\n }\n } else {\n const { name, value } = item\n if (attributes[name] && attributes[name].includes(value)) {\n return true\n }\n }\n }\n return false\n }\n\n // Handle Map optimization\n for (const name in attributes) {\n if (Object.prototype.hasOwnProperty.call(attributes, name)) {\n if (ignoreByAttribute.has(name)) {\n const values = ignoreByAttribute.get(name)\n const attributeValue = attributes[name]\n\n for (let i = 0; i < values.length; i++) {\n if (values[i] === null) {\n return true\n } else if (attributeValue.includes(values[i])) {\n return true\n }\n }\n }\n }\n }\n\n return false\n}\n\n/**\n * Create a map from ignoreByAttribute array.\n * @param {Array<string | Attribute> | Map<string, Array<string | null>>} ignoreByAttribute - The ignore configurations\n * @returns {Map<string, Array<string | null>>} The generated map\n */\nfunction getIgnoreAttributeMap (ignoreByAttribute) {\n if (!ignoreByAttribute) {\n return\n }\n\n if (!Array.isArray(ignoreByAttribute)) {\n return ignoreByAttribute\n }\n\n const map = new Map()\n\n for (let i = 0; i < ignoreByAttribute.length; i++) {\n const item = ignoreByAttribute[i]\n let name, value\n if (typeof item === 'string') {\n name = item\n value = null\n } else {\n name = item.name\n value = item.value\n }\n\n if (!map.has(name)) {\n map.set(name, [])\n }\n map.get(name).push(value)\n }\n\n return map\n}\n\n/**\n * Extract tokens from string\n * @param {string} string - The string to extract tokens from\n * @returns {CoraliteToken[]} The array of tokens extracted from the string\n *\n * @example\n * getTokensFromString('Hello {{ name }} and {{ age }}')\n * // Returns: [{ name: 'name', content: '{{ name }}' }, { name: 'age', content: '{{ age }}' }]\n *\n * Handles:\n * - Multiple tokens in one string\n * - Nested braces: {{ {{nested}} }} extracts both\n * - Complex token names: {{ user.name }}, {{ items[0] }}\n * - Empty tokens: {{}} (returns empty name)\n * - Malformed tokens: {{unclosed, {{extra}} braces}}\n */\nfunction getTokensFromString (string, topLevelOnly = false) {\n const result = []\n let i = 0\n\n while (i < string.length) {\n if (string[i] === '{' && string[i + 1] === '{') {\n const tokenStart = i\n i += 2\n\n // Track brace depth for nested tokens\n let depth = 1\n let tokenEnd = -1\n\n // Scan until we find matching closing braces\n while (i < string.length && depth > 0) {\n if (string[i] === '{' && string[i + 1] === '{') {\n depth++\n i += 2\n } else if (string[i] === '}' && string[i + 1] === '}') {\n depth--\n if (depth === 0) {\n tokenEnd = i + 2\n break\n }\n i += 2\n } else {\n i++\n }\n }\n\n // If we found a complete token\n if (tokenEnd > 0) {\n const fullToken = string.slice(tokenStart, tokenEnd)\n const tokenContent = fullToken.slice(2, -2).trim()\n\n // Add the full token\n result.push({\n name: tokenContent,\n content: fullToken\n })\n\n if (!topLevelOnly) {\n // Also extract any nested tokens from the content\n // This handles cases like {{ {{nested}} }} which should extract both\n const nestedTokens = getTokensFromString(tokenContent)\n\n // Add nested tokens that are different from the full token\n for (const nested of nestedTokens) {\n // Only add if it's not the same as what we just added\n if (nested.content !== fullToken) {\n result.push(nested)\n }\n }\n }\n\n // Continue scanning after this token\n continue\n }\n\n // If token is unclosed, treat it as literal text and continue\n i = tokenStart + 2\n } else {\n i++\n }\n }\n\n return result\n}\n", "/**\n * @import {\n * CoraliteElement,\n * CoraliteTextNode,\n * CoraliteAnyNode,\n * CoraliteComponentRoot,\n * CoraliteComment,\n * CoraliteDirective,\n * RawCoraliteElement,\n * RawCoraliteTextNode,\n * RawCoraliteComment,\n * RawCoraliteDirective,\n * RawCoraliteComponentRoot\n * } from '../../../types/index.js'\n */\n\nconst ELEMENT_NODE = 1\nconst TEXT_NODE = 3\nconst COMMENT_NODE = 8\nconst DOCUMENT_NODE = 9\nconst DOCUMENT_TYPE_NODE = 10\n\nconst nodeTypes = {\n tag: ELEMENT_NODE,\n script: ELEMENT_NODE,\n style: ELEMENT_NODE,\n text: TEXT_NODE,\n comment: COMMENT_NODE,\n root: DOCUMENT_NODE,\n directive: DOCUMENT_TYPE_NODE\n}\n\nconst PARENT_SYM = Symbol('parent')\nconst PREV_SYM = Symbol('prev')\nconst NEXT_SYM = Symbol('next')\nconst SLOTS_SYM = Symbol('slots')\n\n/**\n * Ensures circular properties are non-enumerable to prevent serialization issues.\n * @param {any} node - The node to enhance\n */\nfunction makeCircularPropertiesNonEnumerable (node) {\n for (const key of ['parent', 'prev', 'next', 'slots']) {\n if (Object.hasOwn(node, key)) {\n const val = node[key]\n delete node[key]\n if (val !== undefined) {\n node[key] = val\n }\n }\n }\n}\n\n/**\n * Base prototype for all Coralite nodes.\n */\nconst CoraliteNodePrototype = {\n /**\n * Removes the node from its parent's children list and updates siblings.\n */\n remove () {\n if (this.parent && this.parent.children) {\n const index = this.parent.children.indexOf(this)\n if (index > -1) {\n this.parent.children.splice(index, 1)\n }\n }\n\n // Re-stitch the linked list\n if (this.prev) {\n this.prev.next = this.next\n }\n if (this.next) {\n this.next.prev = this.prev\n }\n\n this.parent = null\n this.next = null\n this.prev = null\n }\n}\n\nObject.defineProperties(CoraliteNodePrototype, {\n nodeType: {\n get () {\n return nodeTypes[this.type] || ELEMENT_NODE\n }\n },\n parent: {\n get () {\n return this[PARENT_SYM] || null\n },\n set (v) {\n this[PARENT_SYM] = v\n },\n enumerable: false\n },\n prev: {\n get () {\n return this[PREV_SYM] || null\n },\n set (v) {\n this[PREV_SYM] = v\n },\n enumerable: false\n },\n next: {\n get () {\n return this[NEXT_SYM] || null\n },\n set (v) {\n this[NEXT_SYM] = v\n },\n enumerable: false\n },\n slots: {\n get () {\n return this[SLOTS_SYM] || null\n },\n set (v) {\n this[SLOTS_SYM] = v\n },\n enumerable: false\n },\n parentNode: {\n get () {\n return this.parent || null\n },\n set (value) {\n this.parent = value\n }\n },\n parentElement: {\n get () {\n return this.parent || null\n },\n set (value) {\n this.parent = value\n }\n },\n previousSibling: {\n get () {\n return this.prev || null\n }\n },\n nextSibling: {\n get () {\n return this.next || null\n }\n }\n})\n\n/**\n * Prototype for Coralite Elements.\n */\nconst CoraliteElementPrototype = Object.create(CoraliteNodePrototype)\n\n/**\n * Returns the value of a specified attribute on the element.\n * @param {string} name - The name of the attribute\n * @returns {string | null}\n */\nCoraliteElementPrototype.getAttribute = function (name) {\n return this.attribs && Object.hasOwn(this.attribs, name) ? this.attribs[name] : null\n}\n\n/**\n * Sets the value of an attribute on the element.\n * @param {string} name - The name of the attribute\n * @param {any} value - The value to set\n */\nCoraliteElementPrototype.setAttribute = function (name, value) {\n if (!this.attribs) {\n this.attribs = {}\n }\n this.attribs[name] = String(value)\n}\n\n/**\n * Returns a boolean value indicating whether the specified element has the specified attribute or not.\n * @param {string} name - The name of the attribute\n * @returns {boolean}\n */\nCoraliteElementPrototype.hasAttribute = function (name) {\n return !!(this.attribs && Object.hasOwn(this.attribs, name))\n}\n\n/**\n * Removes an attribute from the element.\n * @param {string} name - The name of the attribute\n */\nCoraliteElementPrototype.removeAttribute = function (name) {\n if (this.attribs) {\n delete this.attribs[name]\n }\n}\n\n/**\n * Adds a node to the end of the list of children of a specified parent node.\n * @param {any} node - The node to append\n * @returns {any}\n */\nCoraliteElementPrototype.appendChild = function (node) {\n if (node.parent) {\n node.remove()\n }\n\n if (!this.children) {\n this.children = []\n }\n\n const lastChild = this.children[this.children.length - 1]\n if (lastChild) {\n lastChild.next = node\n node.prev = lastChild\n } else {\n node.prev = null\n }\n\n node.next = null\n node.parent = this\n this.children.push(node)\n\n return node\n}\n\n/**\n * Inserts a set of Node objects or string objects after the last child of the Element.\n * @param {...(any)} nodes - The nodes or strings to append\n */\nCoraliteElementPrototype.append = function (...nodes) {\n for (let node of nodes) {\n if (typeof node === 'string') {\n node = createCoraliteTextNode({\n type: 'text',\n data: node\n })\n }\n this.appendChild(node)\n }\n}\n\nObject.defineProperties(CoraliteElementPrototype, {\n nodeName: {\n get () {\n return (this.name || '').toUpperCase()\n }\n },\n tagName: {\n get () {\n return (this.name || '').toUpperCase()\n },\n set (value) {\n this.name = (value || '').toLowerCase()\n }\n },\n nodeValue: {\n get () {\n return null\n },\n set () {\n // Elements do not have nodeValue\n }\n },\n attributes: {\n get () {\n return this.attribs\n },\n set (value) {\n this.attribs = value\n }\n },\n childNodes: {\n get () {\n return this.children || []\n },\n set (value) {\n this.children = value\n }\n },\n firstChild: {\n get () {\n return (this.children && this.children[0]) || null\n }\n },\n lastChild: {\n get () {\n return (this.children && this.children[this.children.length - 1]) || null\n }\n },\n textContent: {\n get () {\n if (this.children) {\n return this.children.map(child => child.textContent).join('')\n }\n return ''\n },\n set (value) {\n if (this.children) {\n for (const child of this.children) {\n child.parent = null\n child.prev = null\n child.next = null\n }\n }\n\n const textNode = createCoraliteTextNode({\n type: 'text',\n data: value,\n parent: this,\n prev: null,\n next: null\n })\n this.children = [textNode]\n }\n },\n id: {\n get () {\n return this.attribs ? this.attribs.id : ''\n },\n set (value) {\n if (!this.attribs) {\n this.attribs = {}\n }\n this.attribs.id = value\n }\n },\n className: {\n get () {\n return this.attribs ? this.attribs.class : ''\n },\n set (value) {\n if (!this.attribs) {\n this.attribs = {}\n }\n this.attribs.class = value\n }\n },\n classList: {\n get () {\n if (!this._classList) {\n const self = this\n const classList = {\n add (...classes) {\n const current = self.className ? self.className.split(/\\s+/).filter(Boolean) : []\n const set = new Set(current)\n classes.forEach(c => set.add(c))\n self.className = Array.from(set).join(' ')\n },\n remove (...classes) {\n const current = self.className ? self.className.split(/\\s+/).filter(Boolean) : []\n const set = new Set(current)\n classes.forEach(c => set.delete(c))\n self.className = Array.from(set).join(' ')\n },\n contains (cls) {\n const current = self.className ? self.className.split(/\\s+/).filter(Boolean) : []\n return current.includes(cls)\n },\n toggle (cls, force) {\n const current = self.className ? self.className.split(/\\s+/).filter(Boolean) : []\n const set = new Set(current)\n if (force !== undefined) {\n if (force) {\n set.add(cls)\n } else {\n set.delete(cls)\n }\n } else {\n if (set.has(cls)) {\n set.delete(cls)\n } else {\n set.add(cls)\n }\n }\n self.className = Array.from(set).join(' ')\n return set.has(cls)\n },\n get value () {\n return self.className\n }\n }\n Object.defineProperty(this, '_classList', {\n value: classList,\n enumerable: false,\n writable: true,\n configurable: true\n })\n }\n return this._classList\n }\n }\n})\n\n/**\n * Prototype for Coralite Text Nodes.\n */\nconst CoraliteTextNodePrototype = Object.create(CoraliteNodePrototype)\n\nObject.defineProperties(CoraliteTextNodePrototype, {\n nodeName: {\n get () {\n return '#text'\n }\n },\n nodeValue: {\n get () {\n return this.data\n },\n set (value) {\n this.data = value\n }\n },\n textContent: {\n get () {\n return this.data\n },\n set (value) {\n this.data = value\n }\n }\n})\n\n/**\n * Prototype for Coralite Comment Nodes.\n */\nconst CoraliteCommentPrototype = Object.create(CoraliteNodePrototype)\n\nObject.defineProperties(CoraliteCommentPrototype, {\n nodeName: {\n get () {\n return '#comment'\n }\n },\n nodeValue: {\n get () {\n return this.data\n },\n set (value) {\n this.data = value\n }\n },\n textContent: {\n get () {\n return this.data\n },\n set (value) {\n this.data = value\n }\n }\n})\n\n/**\n * Prototype for Coralite Directive Nodes.\n */\nconst CoraliteDirectivePrototype = Object.create(CoraliteNodePrototype)\n\nObject.defineProperties(CoraliteDirectivePrototype, {\n nodeName: {\n get () {\n return this.name\n }\n },\n nodeValue: {\n get () {\n return this.data\n },\n set (value) {\n this.data = value\n }\n }\n})\n\n/**\n * Prototype for Coralite Component Roots (Document).\n */\nconst CoraliteComponentPrototype = Object.create(CoraliteNodePrototype)\n\nObject.defineProperties(CoraliteComponentPrototype, {\n nodeName: {\n get () {\n return '#document'\n }\n },\n nodeValue: {\n get () {\n return null\n }\n },\n childNodes: {\n get () {\n return this.children || []\n },\n set (value) {\n this.children = value\n }\n },\n firstChild: {\n get () {\n return (this.children && this.children[0]) || null\n }\n },\n lastChild: {\n get () {\n return (this.children && this.children[this.children.length - 1]) || null\n }\n },\n textContent: {\n get () {\n return null\n }\n }\n})\n\n/**\n * Internal helper to get prototype based on node type.\n */\nfunction getPrototypeForType (type) {\n switch (type) {\n case 'tag':\n case 'script':\n case 'style':\n return CoraliteElementPrototype\n case 'text':\n return CoraliteTextNodePrototype\n case 'comment':\n return CoraliteCommentPrototype\n case 'directive':\n return CoraliteDirectivePrototype\n case 'root':\n return CoraliteComponentPrototype\n default:\n return CoraliteNodePrototype\n }\n}\n\n/**\n * Enhances a raw node by applying the correct prototype based on its type.\n * @param {any} node - The node to enhance\n * @returns {any} The enhanced node\n */\nexport function enhanceNode (node) {\n if (!node || node.__coralite_enhanced__) {\n return node\n }\n\n const prototype = getPrototypeForType(node.type)\n Object.setPrototypeOf(node, prototype)\n makeCircularPropertiesNonEnumerable(node)\n\n Object.defineProperty(node, '__coralite_enhanced__', {\n value: true,\n enumerable: false,\n configurable: true\n })\n\n return node\n}\n\n/**\n * Re-links all children of a parent node, ensuring parent, prev, and next pointers are correct.\n * @param {any} parent - The parent node whose children should be re-linked\n */\nexport function relinkChildren (parent) {\n if (!parent || !parent.children || !Array.isArray(parent.children)) {\n return\n }\n\n for (let i = 0; i < parent.children.length; i++) {\n const child = parent.children[i]\n if (!child) {\n continue\n }\n\n enhanceNode(child)\n child.parent = parent\n child.prev = parent.children[i - 1] || null\n child.next = parent.children[i + 1] || null\n\n if (child.children) {\n relinkChildren(child)\n }\n }\n}\n\n/**\n * Creates an enhanced Coralite Element\n * @param {RawCoraliteElement} node - The raw element node\n * @returns {CoraliteElement} The enhanced Coralite Element\n */\nexport function createCoraliteElement (node) {\n node.type = node.type || 'tag'\n return enhanceNode(node)\n}\n\n/**\n * Creates an enhanced Coralite Text Node\n * @param {RawCoraliteTextNode} node - The raw text node\n * @returns {CoraliteTextNode} The enhanced Coralite Text Node\n */\nexport function createCoraliteTextNode (node) {\n node.type = 'text'\n return enhanceNode(node)\n}\n\n/**\n * Creates an enhanced Coralite Comment Node\n * @param {RawCoraliteComment} node - The raw comment node\n * @returns {CoraliteComment} The enhanced Coralite Comment Node\n */\nexport function createCoraliteComment (node) {\n node.type = 'comment'\n return enhanceNode(node)\n}\n\n/**\n * Creates an enhanced Coralite Directive Node (e.g. DOCTYPE)\n * @param {RawCoraliteDirective} node - The raw directive node\n * @returns {CoraliteDirective} The enhanced Coralite Directive Node\n */\nexport function createCoraliteDirective (node) {\n node.type = 'directive'\n return enhanceNode(node)\n}\n\n/**\n * Creates an enhanced Coralite Document Root\n * @param {RawCoraliteComponentRoot} node - The raw document node\n * @returns {CoraliteComponentRoot} The enhanced Coralite Document Root\n */\nexport function createCoraliteComponent (node) {\n node.type = 'root'\n return enhanceNode(node)\n}\n", "import { CoraliteError } from './errors.js'\n\nexport const BOOLEAN_ATTRIBUTES = new Set([\n 'allowfullscreen',\n 'async',\n 'autofocus',\n 'autoplay',\n 'checked',\n 'controls',\n 'default',\n 'defer',\n 'disabled',\n 'formnovalidate',\n 'hidden',\n 'inert',\n 'ismap',\n 'itemscope',\n 'loop',\n 'multiple',\n 'muted',\n 'nomodule',\n 'novalidate',\n 'open',\n 'playsinline',\n 'readonly',\n 'required',\n 'reversed',\n 'selected',\n 'truespeed'\n])\n\nexport const VALID_TAGS = {\n a: true,\n abbr: true,\n acronym: true,\n address: true,\n area: true,\n article: true,\n aside: true,\n audio: true,\n b: true,\n base: true,\n bdi: true,\n bdo: true,\n big: true,\n blockquote: true,\n body: true,\n br: true,\n button: true,\n canvas: true,\n caption: true,\n center: true,\n cite: true,\n code: true,\n col: true,\n colgroup: true,\n data: true,\n datalist: true,\n dd: true,\n del: true,\n details: true,\n dfn: true,\n dialog: true,\n dir: true,\n div: true,\n dl: true,\n dt: true,\n em: true,\n embed: true,\n fencedframe: true,\n fieldset: true,\n figcaption: true,\n figure: true,\n font: true,\n footer: true,\n form: true,\n frame: true,\n frameset: true,\n h1: true,\n h2: true,\n h3: true,\n h4: true,\n h5: true,\n h6: true,\n head: true,\n header: true,\n hgroup: true,\n hr: true,\n html: true,\n i: true,\n iframe: true,\n img: true,\n input: true,\n ins: true,\n kbd: true,\n label: true,\n legend: true,\n li: true,\n link: true,\n main: true,\n map: true,\n mark: true,\n marquee: true,\n menu: true,\n meta: true,\n meter: true,\n nav: true,\n nobr: true,\n noembed: true,\n noframes: true,\n noscript: true,\n object: true,\n ol: true,\n optgroup: true,\n option: true,\n output: true,\n p: true,\n param: true,\n picture: true,\n plaintext: true,\n portal: true,\n pre: true,\n progress: true,\n q: true,\n rb: true,\n rp: true,\n rt: true,\n rtc: true,\n ruby: true,\n s: true,\n samp: true,\n script: true,\n search: true,\n section: true,\n select: true,\n slot: true,\n small: true,\n source: true,\n span: true,\n strike: true,\n strong: true,\n style: true,\n sub: true,\n summary: true,\n sup: true,\n table: true,\n tbody: true,\n td: true,\n template: true,\n textarea: true,\n tfoot: true,\n th: true,\n thead: true,\n time: true,\n title: true,\n tr: true,\n track: true,\n tt: true,\n u: true,\n ul: true,\n var: true,\n video: true,\n wbr: true,\n xmp: true,\n // svg\n svg: true,\n animate: true,\n animatemotion: true,\n animatetransform: true,\n circle: true,\n clippath: true,\n defs: true,\n desc: true,\n ellipse: true,\n feblend: true,\n fecolormatrix: true,\n fecomponenttransfer: true,\n fecomposite: true,\n feconvolvematrix: true,\n fediffuselighting: true,\n fedisplacementmap: true,\n fedistantlight: true,\n fedropshadow: true,\n feflood: true,\n fefunca: true,\n fefuncb: true,\n fefuncg: true,\n fefuncr: true,\n fegaussianblur: true,\n feimage: true,\n femerge: true,\n femergenode: true,\n femorphology: true,\n feoffset: true,\n fepointlight: true,\n fespecularlighting: true,\n fespotlight: true,\n fetile: true,\n feturbulence: true,\n filter: true,\n foreignobject: true,\n g: true,\n image: true,\n line: true,\n lineargradient: true,\n marker: true,\n mask: true,\n metadata: true,\n mpath: true,\n path: true,\n pattern: true,\n polygon: true,\n polyline: true,\n radialgradient: true,\n rect: true,\n set: true,\n stop: true,\n switch: true,\n symbol: true,\n text: true,\n textpath: true,\n tspan: true,\n use: true,\n view: true\n}\n\nexport const RESERVED_ELEMENT_NAMES = {\n 'annotation-xml': true,\n 'color-profile': true,\n 'font-face': true,\n 'font-face-src': true,\n 'font-face-uri': true,\n 'font-face-format': true,\n 'font-face-name': true,\n 'missing-glyph': true\n}\n\nconst CUSTOM_ELEMENT_TAG = /^[a-z](?:[-.\\w\\u00B7\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u203F-\\u2040\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD])*?-(?:[-.\\w\\u00B7\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u203F-\\u2040\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD])*$/\n\n/**\n * Validates a custom element name\n * @param {string} name - The custom element name to validate\n * @param {number} [maxLength=100] - Max length of the tag name\n * @returns {boolean} - True if valid, false otherwise\n * @throws {Error} - If the element name is reserved\n */\nexport function isValidCustomElementName (name, maxLength = 100) {\n // Check if string is empty or not a string\n if (!name || typeof name !== 'string') {\n return false\n }\n\n // Check against reserved names first (case-insensitive)\n if (RESERVED_ELEMENT_NAMES[name.toLowerCase()]) {\n throw new CoraliteError('Element name is reserved: \"'+ name +'\"')\n }\n\n // Length check to prevent ReDoS\n if (name.length > maxLength) {\n return false\n }\n\n // check for obviously invalid patterns that could cause backtracking\n if (name.includes('--') || name.startsWith('-') || name.endsWith('-')) {\n return false\n }\n\n // Test against the regex\n return CUSTOM_ELEMENT_TAG.test(name)\n}\n", "import { build } from 'esbuild'\nimport serialize from 'serialize-javascript'\nimport { parse as parseJS } from 'acorn'\nimport { simple as walkJS } from 'acorn-walk'\nimport { normalizeFunction, normalizeObjectFunctions, hasObjectKeys, mergeUniqueObjects, addComponentAndDependencies, cleanAST, cleanValues, generateHydrationMap } from './utils/core.js'\nimport { findAndExtractImperativeComponents, astTransformer } from './utils/server/server.js'\nimport { CoraliteError } from './utils/errors.js'\nimport { pathToFileURL, fileURLToPath } from 'node:url'\nimport { resolve, parse, dirname, relative } from 'node:path'\nimport { nodeModulesPolyfillPlugin } from 'esbuild-plugins-node-modules-polyfill'\nimport render from 'dom-serializer'\n\n/**\n * Script Manager for Coralite\n * Manages shared functions across component instances and provides plugin extensibility\n * @import { ScriptPlugin, InstanceContext } from '../types/index.js'\n * @import { ScriptContent } from '../types/script.js'\n */\n\n/**\n * ScriptManager constructor function\n * @class\n * @param {Object} options - The configuration options for the script manager.\n */\nexport function ScriptManager (options = {}) {\n this.sharedFunctions = Object.create(null)\n this.contextProps = Object.create(null)\n this.plugins = []\n this.scriptModules = []\n this.options = options\n}\n\n/**\n * Register a plugin\n * @param {ScriptPlugin} plugin - Plugin object or setup function\n * @returns {Promise<ScriptManager>} - Returns this for method chaining\n */\nScriptManager.prototype.use = async function (plugin) {\n // Register script modules (client plugins)\n if (\n plugin\n && typeof plugin !== 'function'\n ) {\n if (plugin.context\n || typeof plugin.setup === 'function'\n || typeof plugin.onBeforeComponentRender === 'function'\n || typeof plugin.onAfterComponentRender === 'function'\n || typeof plugin.onDisconnected === 'function') {\n this.scriptModules.push(plugin)\n\n if (plugin.context) {\n let extractedComponents = []\n for (const key in plugin.context) {\n if (Object.hasOwn(plugin.context, key)) {\n const contextFn = plugin.context[key]\n const contextStr = typeof contextFn === 'function' ? `(${contextFn.toString()})` : serialize(contextFn)\n const foundComponents = findAndExtractImperativeComponents(contextStr)\n extractedComponents = extractedComponents.concat(foundComponents)\n }\n }\n if (extractedComponents.length > 0) {\n plugin._extractedComponents = Array.from(new Set(extractedComponents))\n }\n }\n }\n }\n\n this.plugins.push(plugin)\n return this\n}\n\n/**\n * Get context object content string\n * @returns {string} String containing all context as object state\n */\nScriptManager.prototype.getClientContextContent = function () {\n let contextPropsStr = ''\n\n for (const [key, value] of Object.entries(this.contextProps)) {\n contextPropsStr += `\"${key}\": async (globalContext) => {\n const phase1 = ${value};\n const phase2 = await phase1(globalContext);\n return (localContext) => phase2(localContext);\n },`\n }\n\n return contextPropsStr\n}\n\n/**\n * Add a context property function\n * @param {string} name - Property name\n * @param {function} method - The property function\n * @returns {Promise<ScriptManager>} - Returns this for method chaining\n */\nScriptManager.prototype.addContextProp = async function (name, method) {\n this.contextProps[name] = normalizeFunction(method)\n\n return this\n}\n\n/**\n * Register shared functions for a component\n * @param {Object} options - The options used to register the component.\n * @param {string} options.id - The component identifier.\n * @param {ScriptContent} [options.script={}] - The script content or function associated with the component.\n * @param {string} [options.filePath] - The source file path used to map back to the original source.\n * @param {Array<Object>|null} [options.templateAST=null] - The parsed HTML template AST for client-side rendering.\n * @param {Object|null} [options.templateValues=null] - The token positions for AST updates.\n * @param {Object} [options.defaultValues={}] - The initial default state from setup().\n * @param {Object} [options.getters={}] - The component getters.\n * @param {string} [options.styles=''] - The raw CSS string for the component.\n * @param {Object.<string, Function>} [options.slots={}] - The transformation functions for computed slots.\n * @param {boolean} [options.override=false] - Whether to override existing component definition.\n */\nScriptManager.prototype.registerComponent = function ({\n id,\n script = {},\n filePath,\n templateAST = null,\n templateValues = null,\n defaultValues = {},\n getters = {},\n styles = '',\n slots = {},\n override = false\n}) {\n // Initialize base object if it's the first time we are seeing this ID\n const isNew = !this.sharedFunctions[id]\n if (isNew) {\n this.sharedFunctions[id] = {\n id,\n components: [],\n filePath: `/component-${id}.js`\n }\n }\n\n const target = this.sharedFunctions[id]\n\n if (hasObjectKeys(script)) {\n if (isNew || override) {\n target.script = script\n }\n }\n\n if (hasObjectKeys(getters)) {\n if (isNew || override) {\n target.getters = getters\n }\n }\n\n if (templateAST) {\n if (isNew || override) {\n target.templateAST = templateAST\n }\n }\n\n if (templateValues) {\n if (isNew || override) {\n target.templateValues = templateValues\n }\n }\n\n if (styles) {\n if (isNew || override) {\n target.styles = styles\n }\n }\n\n if (filePath) {\n if (isNew || override) {\n target.filePath = resolve(filePath)\n }\n }\n\n\n if (hasObjectKeys(defaultValues)) {\n if (isNew || override) {\n target.defaultValues = defaultValues\n }\n }\n\n if (hasObjectKeys(slots)) {\n if (isNew || override) {\n target.slots = slots\n }\n }\n\n if (script) {\n if (script.components?.length) {\n if (isNew || override) {\n target.components = script.components\n } else {\n target.components = mergeUniqueObjects(target.components, script.components)\n }\n }\n }\n}\n\n/**\n * Generate instance-specific script wrapper\n * @param {string} id - component identifier\n * @param {InstanceContext} instanceContext - Instance context\n * @returns {string} Generated script\n */\nScriptManager.prototype.generateInstanceWrapper = function (id, instanceContext) {\n const state = instanceContext.state ? serialize(instanceContext.state) : '{}'\n const page = instanceContext.page ? serialize(instanceContext.page) : '{}'\n\n // Generate wrapper that calls shared functions with instance context\n return `await coraliteComponentFunctions[\"${id}\"]({\n state: ${state},\n page: ${page},\n ...pluginContexts,\n instanceId: '${instanceContext.instanceId}'\n });`\n}\n\n/**\n * Compile all instances for a component\n * @param {Object.<string, InstanceContext>} instances - Map of instanceId -> instance data\n * @param {string} mode - Build mode\n * @returns {Promise<any>} Compiled script\n */\nScriptManager.prototype.compileAllInstances = async function (instances, mode) {\n const entryCodeParts = []\n const moduleNamespace = 'coralite-script-module:'\n // Generate ESM imports for each script module\n for (let i = 0; i < this.scriptModules.length; i++) {\n entryCodeParts.push(`import { clientContextProps as clientContextProps_${i}, runSetup as runSetup_${i}, onBeforeComponentRender as onBeforeComponentRender_${i}, onAfterComponentRender as onAfterComponentRender_${i}, onDisconnected as onDisconnected_${i} } from \"${moduleNamespace}${i}\";\\n`)\n }\n\n // Setup client context state\n const contextParts = [\n ...this.scriptModules.map((_, i) => `...clientContextProps_${i}`),\n this.getClientContextContent()\n ].filter(Boolean).join(',\\n')\n\n entryCodeParts.push(`const coraliteComponentClientContextProps = {\n ${contextParts}\n };\\n`)\n\n entryCodeParts.push(`const getSetups = async (context) => {\n const state = {};\n for (const runSetup of [${this.scriptModules.map((_, i) => `runSetup_${i}`).join(', ')}]) {\n const result = await runSetup(context);\n if (result && typeof result === 'object') {\n Object.assign(state, result);\n }\n }\n return state;\n }\\n`)\n\n // Global setups initialization\n entryCodeParts.push('const globalContext = { values: {} };\\n')\n\n entryCodeParts.push(`const resolvedContextPropsPromise = (async () => {\n const setupValues = await getSetups(globalContext);\n Object.assign(globalContext.values, setupValues);\n\n const resolvedProps = {};\n const keys = Object.keys(coraliteComponentClientContextProps);\n for (const key of keys) {\n resolvedProps[key] = await coraliteComponentClientContextProps[key](globalContext);\n globalContext[key] = resolvedProps[key];\n }\n return resolvedProps;\n })();\\n`)\n\n entryCodeParts.push(`const getClientContext = async (context) => {\n const clientContextProps = {}\n const resolvedProps = await resolvedContextPropsPromise;\n for (const [key, resolvedProp] of Object.entries(resolvedProps)) {\n const bound = resolvedProp(context);\n clientContextProps[key] = bound;\n }\n return clientContextProps\n }\\n`)\n\n const instanceValues = Object.entries(instances)\n // Collect unique components\n /** @type {Record<string, boolean>} */\n const processedComponent = {}\n\n for (const instanceData of instanceValues) {\n addComponentAndDependencies(instanceData[1].componentId, processedComponent, this.sharedFunctions)\n }\n\n // Add plugin dependencies explicitly if they are standalone\n for (const plugin of this.plugins) {\n if (plugin && plugin._extractedComponents && Array.isArray(plugin._extractedComponents)) {\n for (const compPath of plugin._extractedComponents) {\n for (const id of Object.keys(this.sharedFunctions)) {\n if (compPath.endsWith(`/${id}.html`) || compPath.endsWith(`\\\\${id}.html`) || compPath === id || compPath.endsWith(`/${id}`)) {\n addComponentAndDependencies(id, processedComponent, this.sharedFunctions)\n }\n }\n }\n }\n }\n\n // Force inclusion of all components that evaluate something inside\n // This is required because if a parent is ONLY instantiated via script dynamically,\n // it might not be in instances or plugin explicit references.\n for (const [componentId, fnData] of Object.entries(this.sharedFunctions)) {\n // \"forcing all imperative components into the final chunks bundle, is fine, but it must not include the children of the imperative components since the imperative should load its own dependent components.\"\n if (fnData.script && fnData.script.content) {\n const scriptContent = fnData.script.content.replace(/\\s+/g, '')\n if (scriptContent !== 'function(){}') {\n processedComponent[componentId] = true\n }\n } else if (fnData.script && fnData.script.components && fnData.script.components.length > 0) {\n processedComponent[componentId] = true\n } else if (hasObjectKeys(fnData.defaultValues)) {\n processedComponent[componentId] = true\n }\n }\n\n const processedComponentKeys = Object.keys(processedComponent).sort()\n const regex = /[-.:]/g\n const namespace = 'coralite-component:'\n\n // Generate ESM imports for each component script\n for (const componentId of processedComponentKeys) {\n if (this.sharedFunctions[componentId]) {\n const safeId = componentId.replace(regex, '_')\n entryCodeParts.push(`import component_${safeId} from \"${namespace}${componentId}\";\\n`)\n }\n }\n\n // Map imports to the functions object\n entryCodeParts.push('const coraliteComponentFunctions = {\\n')\n for (const componentId of processedComponentKeys) {\n if (this.sharedFunctions[componentId]) {\n entryCodeParts.push(` \"${componentId}\": component_${componentId.replace(regex, '_')},\\n`)\n }\n }\n entryCodeParts.push('};\\n')\n\n entryCodeParts.push('const coraliteComponentDefaults = {\\n')\n for (const key of processedComponentKeys) {\n if (this.sharedFunctions[key] && this.sharedFunctions[key].defaultValues) {\n const normalizedDefaults = normalizeObjectFunctions(this.sharedFunctions[key].defaultValues, astTransformer)\n\n entryCodeParts.push(` \"${key}\": (() => {\\n`)\n entryCodeParts.push(` const defaults = ${serialize(normalizedDefaults)};\\n`)\n entryCodeParts.push(` return defaults;\\n`)\n entryCodeParts.push(` })(),\\n`)\n } else {\n entryCodeParts.push(` \"${key}\": {},\\n`)\n }\n }\n entryCodeParts.push('};\\n')\n\n entryCodeParts.push('const coraliteComponentStyles = {\\n')\n for (const key of processedComponentKeys) {\n if (this.sharedFunctions[key] && this.sharedFunctions[key].styles) {\n entryCodeParts.push(` \"${key}\": ${JSON.stringify(this.sharedFunctions[key].styles)},\\n`)\n }\n }\n entryCodeParts.push('};\\n')\n\n const coraliteElementPath = fileURLToPath(import.meta.resolve('./coralite-element.js'))\n\n entryCodeParts.push(`const globalClientHooks = {\n onBeforeComponentRender: [${this.scriptModules.map((_, i) => `onBeforeComponentRender_${i}`).join(', ')}].filter(Boolean),\n onAfterComponentRender: [${this.scriptModules.map((_, i) => `onAfterComponentRender_${i}`).join(', ')}].filter(Boolean),\n onDisconnected: [${this.scriptModules.map((_, i) => `onDisconnected_${i}`).join(', ')}].filter(Boolean)\n };\\n`)\n\n entryCodeParts.push(`import { createCoraliteClass } from ${JSON.stringify(coraliteElementPath)};\\n`)\n entryCodeParts.push('\\nexport { getClientContext, getSetups, createCoraliteClass, globalClientHooks };\\n')\n\n const entryPoints = {\n 'chunk-shared': entryCodeParts.join('').trimEnd()\n }\n\n // Create virtual entry points for each component\n for (const componentId of processedComponentKeys) {\n if (this.sharedFunctions[componentId]) {\n const safeId = componentId.replace(regex, '_')\n let componentEntryCode = ''\n\n const hasScript = this.sharedFunctions[componentId].script && this.sharedFunctions[componentId].script.content && this.sharedFunctions[componentId].script.content.trim() !== 'function(){}' && this.sharedFunctions[componentId].script.content.trim() !== 'function() {}' && this.sharedFunctions[componentId].script.content.trim() !== 'function() { }'\n const hasState = this.sharedFunctions[componentId].script && this.sharedFunctions[componentId].script.stateContent\n\n if (hasScript || hasState) {\n componentEntryCode += `import * as componentModule_${safeId} from \"${namespace}${componentId}\";\\n`\n }\n\n // Use a WeakMap to map original nodes to a unique index\n const nodeMap = new WeakMap()\n const state = { counter: 0 }\n\n cleanAST(this.sharedFunctions[componentId].templateAST, nodeMap, state)\n const templateHTML = serialize(this.sharedFunctions[componentId].templateAST ? render(this.sharedFunctions[componentId].templateAST, { decodeEntities: false }) : '')\n const templateValues = serialize(cleanValues(this.sharedFunctions[componentId].templateValues, nodeMap) || {\n attributes: [],\n textNodes: [],\n refs: []\n })\n const styles = JSON.stringify(this.sharedFunctions[componentId].styles || '')\n\n let normalizedDefaults = this.sharedFunctions[componentId].defaultValues || {}\n if (this.sharedFunctions[componentId].defaultValues) {\n normalizedDefaults = normalizeObjectFunctions(this.sharedFunctions[componentId].defaultValues, astTransformer)\n }\n const defaults = serialize(normalizedDefaults)\n const attributes = serialize(this.sharedFunctions[componentId].script?.attributes || {})\n const hydrationMap = serialize(generateHydrationMap(this.sharedFunctions[componentId].templateAST, this.sharedFunctions[componentId].templateValues))\n const getters = serialize(this.sharedFunctions[componentId].getters || this.sharedFunctions[componentId].script?.getters || {})\n const dependencies = JSON.stringify(this.sharedFunctions[componentId].components || [])\n\n let normalizedSlots = this.sharedFunctions[componentId].slots || {}\n if (this.sharedFunctions[componentId].slots) {\n normalizedSlots = normalizeObjectFunctions(this.sharedFunctions[componentId].slots, astTransformer)\n }\n const slots = serialize(normalizedSlots)\n\n componentEntryCode += `\nexport default {\n componentId: \"${componentId}\",\n templateHTML: ${templateHTML},\n templateValues: ${templateValues},\n styles: ${styles},\n attributes: ${attributes},\n hydrationMap: ${hydrationMap},\n getters: ${getters},\n defaultValues: (() => { const defaults = ${defaults}; return defaults; })(),\n slots: (() => { const slots = ${slots}; return slots; })(),\n dependencies: ${dependencies},\n imports: {},\n script: ${hasScript ? `componentModule_${safeId}.script` : 'null'},\n state: ${hasState ? `componentModule_${safeId}.state` : 'null'}\n};\n`\n entryPoints[componentId] = componentEntryCode\n }\n }\n\n const resolvedImportMap = {}\n\n // Use config's import map if available\n const userImportMap = this.options?.importMap || {}\n\n // Since we cannot pass raw code directly as values in the entryPoints object to esbuild,\n // we need to pass virtual paths.\n /** @type {Record<string, string>} */\n const virtualEntryPoints = {}\n for (const key of Object.keys(entryPoints)) {\n virtualEntryPoints[key] = `virtual-entry-point:${key}`\n }\n\n // Build and bundle\n const result = await build({\n entryPoints: virtualEntryPoints,\n bundle: true,\n write: false,\n treeShaking: true,\n splitting: true,\n metafile: true,\n minify: mode === 'production',\n sourcemap: mode === 'production' ? 'external' : 'inline',\n outdir: 'assets/js',\n entryNames: '[name]-[hash]',\n chunkNames: '[name]-[hash]',\n format: 'esm',\n sourceRoot: pathToFileURL(process.cwd()).href,\n define: {\n global: 'window',\n __dirname: '\"\"',\n __filename: '\"\"'\n },\n plugins: [\n nodeModulesPolyfillPlugin(),\n {\n name: 'coralite-import-map-resolver',\n setup: (pluginBuild) => {\n // Regex to catch bare specifiers (doesn't start with ., .., /, or http)\n const bareSpecifierRegex = /^[^.\\/]|^\\.[^.\\/]|^\\.\\.[^\\/]/\n\n pluginBuild.onResolve({ filter: bareSpecifierRegex }, (args) => {\n // Only intercept specifiers inside generated component scripts/files.\n // Do not externalize entry points themselves.\n if (args.kind === 'entry-point') {\n return null\n }\n\n // Do not externalize if the path resolves to a virtual module\n if (args.namespace === 'coralite-entry') {\n return null\n }\n\n // Check for Coralite internal modules first\n if (args.path.startsWith('coralite-component:') ||\n args.path.startsWith('coralite-script-module:') ||\n args.path === 'chunk-shared') {\n return null\n }\n\n if (args.path === 'coralite') {\n const utilsPath = fileURLToPath(import.meta.resolve('./utils/core.js'))\n const pluginPath = fileURLToPath(import.meta.resolve('./plugin.js'))\n\n return {\n path: 'coralite',\n namespace: 'coralite-entry',\n pluginData: {\n contents: `\n export { defineComponent } from '${utilsPath.replace(/\\\\/g, '/')}';\n export { definePlugin } from '${pluginPath.replace(/\\\\/g, '/')}';\n `\n }\n }\n }\n\n if (args.path === 'coralite/utils') {\n return {\n path: fileURLToPath(import.meta.resolve('./utils/index.js'))\n }\n }\n\n // Do not externalize if the entry point name actually matches a bare specifier\n if (Object.hasOwn(entryPoints, args.path)) {\n return null\n }\n\n // Ignore absolute URLs that are already explicitly defined\n if (args.path.startsWith('http')) {\n return {\n path: args.path,\n external: true\n }\n }\n\n // Check if the user provided an explicit override in coralite.config.js\n if (userImportMap[args.path]) {\n resolvedImportMap[args.path] = userImportMap[args.path]\n return {\n path: userImportMap[args.path],\n external: true\n }\n }\n })\n }\n },\n {\n name: 'coralite-virtual-modules',\n setup: (pluginBuild) => {\n pluginBuild.onResolve({ filter: /^virtual-entry-point:/ }, args => {\n const key = args.path.replace('virtual-entry-point:', '')\n if (entryPoints[key]) {\n return {\n path: key,\n namespace: 'coralite-entry'\n }\n }\n })\n\n pluginBuild.onLoad({\n filter: /.*/,\n namespace: 'coralite-entry'\n }, args => {\n if (args.pluginData && args.pluginData.contents) {\n return {\n contents: args.pluginData.contents,\n loader: 'js',\n resolveDir: process.cwd()\n }\n }\n\n if (entryPoints[args.path]) {\n return {\n contents: entryPoints[args.path],\n loader: 'js',\n resolveDir: process.cwd()\n }\n }\n })\n }\n },\n {\n name: 'coralite-component-resolver',\n setup: (pluginBuild) => {\n // Catch the script module, associate with real file paths\n const componentRegex = new RegExp(`^${namespace}`)\n\n pluginBuild.onResolve({ filter: componentRegex }, args => {\n const componentId = args.path.replace(namespace, '')\n const sharedFn = this.sharedFunctions[componentId]\n\n return {\n path: sharedFn.filePath,\n pluginData: { componentId }\n }\n })\n\n // Handle script modules\n const moduleRegex = new RegExp(`^${moduleNamespace}`)\n pluginBuild.onResolve({ filter: moduleRegex }, args => {\n const index = parseInt(args.path.replace(moduleNamespace, ''), 10)\n return {\n path: args.path,\n namespace: 'coralite-script-module',\n pluginData: { index }\n }\n })\n\n pluginBuild.onLoad({\n filter: /.*/,\n namespace: 'coralite-script-module'\n }, args => {\n const index = args.pluginData.index\n const module = this.scriptModules[index]\n let contents = ''\n\n // Generate config object\n const configContent = module.config\n ? `const pluginConfig = ${JSON.stringify(module.config)};`\n : 'const pluginConfig = {};'\n\n contents += configContent + '\\n'\n\n // Generate setup function\n const setupFn = module.setup ? normalizeFunction(module.setup) : 'null'\n contents += `export const runSetup = async (context) => {\n const setup = ${setupFn};\n if (!setup) return {};\n const contextObject = Object.create(context);\n contextObject.config = pluginConfig;\n return await setup(contextObject);\n };\\n`\n\n const beforeFn = module.onBeforeComponentRender ? normalizeFunction(module.onBeforeComponentRender) : 'null'\n contents += `export const onBeforeComponentRender = ${beforeFn};\\n`\n\n const afterFn = module.onAfterComponentRender ? normalizeFunction(module.onAfterComponentRender) : 'null'\n contents += `export const onAfterComponentRender = ${afterFn};\\n`\n\n const disconnectedFn = module.onDisconnected ? normalizeFunction(module.onDisconnected) : 'null'\n contents += `export const onDisconnected = ${disconnectedFn};\\n`\n\n // Generate client context state\n contents += 'export const clientContextProps = {\\n'\n if (module.context) {\n contents += ` \"${module.name}\": async (globalContext) => {\\n`\n contents += ' const props = {};\\n'\n for (const key in module.context) {\n if (Object.hasOwn(module.context, key)) {\n if (['id', 'state', 'page', 'root', 'signal'].includes(key)) {\n throw new CoraliteError(`Reserved context key '${key}' cannot be used in plugin context.`)\n }\n const fn = normalizeFunction(module.context[key])\n contents += ` props[\"${key}\"] = await (async (globalContext) => {\n const fn = ${fn};\n const pluginContext = new Proxy(globalContext, {\n get (target, prop) {\n if (prop === 'config') return pluginConfig;\n return target[prop];\n },\n set (target, prop, value) {\n return Reflect.set(target, prop, value);\n }\n });\n const phase2 = await fn(pluginContext);\n return (localContext) => phase2(localContext);\n })(globalContext);\\n`\n }\n }\n contents += ' const resolver = (localContext) => {\\n'\n contents += ' const bound = {};\\n'\n contents += ' for (const [key, fn] of Object.entries(props)) {\\n'\n contents += ' bound[key] = fn(localContext);\\n'\n contents += ' }\\n'\n contents += ' return bound;\\n'\n contents += ' };\\n'\n contents += ' Object.assign(resolver, props);\\n'\n contents += ' return resolver;\\n'\n contents += ' },\\n'\n }\n contents += '};\\n'\n\n return {\n contents,\n loader: 'js',\n resolveDir: module.rootDir || (module.filePath ? dirname(module.filePath) : process.cwd())\n }\n })\n\n // Provide the script content to esbuild when it loads those file paths\n pluginBuild.onLoad({\n filter: /.*/\n }, args => {\n if (!args.pluginData || !args.pluginData.componentId) {\n return\n }\n\n const sharedFn = this.sharedFunctions[args.pluginData.componentId]\n let contents = ''\n\n\n if (sharedFn.script && sharedFn.script.content) {\n const padding = '\\n'.repeat(Math.max(0, sharedFn.script.lineOffset || 0))\n\n // More robust way to strip 'data' from defineComponent call\n let strippedContent = sharedFn.script.content\n\n try {\n const ast = parseJS(strippedContent, {\n ecmaVersion: 'latest',\n sourceType: 'module'\n })\n let dataStart = -1\n let dataEnd = -1\n\n walkJS(ast, {\n CallExpression (node) {\n if (node.callee.type === 'Identifier' && node.callee.name === 'defineComponent') {\n const firstArg = node.arguments[0]\n if (firstArg && firstArg.type === 'ObjectExpression') {\n const dataProp = firstArg.properties.find(p => p.type === 'Property' && p.key?.type === 'Identifier' && p.key?.name === 'data')\n // @ts-ignore\n if (dataProp && dataProp.type === 'Property') {\n // @ts-ignore\n dataStart = dataProp.start\n // @ts-ignore\n dataEnd = dataProp.end\n }\n }\n }\n }\n })\n\n if (dataStart !== -1) {\n let start = dataStart\n let end = dataEnd\n\n // Handle comma to avoid syntax errors\n const afterContent = strippedContent.slice(end)\n const trailingComma = afterContent.match(/^\\s*,/)\n if (trailingComma) {\n end += trailingComma[0].length\n } else {\n const beforeContent = strippedContent.slice(0, start)\n const leadingComma = beforeContent.match(/,\\s*$/)\n if (leadingComma) {\n start -= leadingComma[0].length\n }\n }\n strippedContent = strippedContent.slice(0, start) + strippedContent.slice(end)\n }\n } catch {\n // Fallback to regex if AST parsing fails\n strippedContent = strippedContent.replace(/data\\s*:\\s*async\\s*function\\s*\\([^\\)]*\\)\\s*\\{[\\s\\S]*?\\}(?=\\s*,|\\s*\\})/, '/* data stripped */')\n strippedContent = strippedContent.replace(/async\\s*data\\s*\\([^\\)]*\\)\\s*\\{[\\s\\S]*?\\}(?=\\s*,|\\s*\\})/, '/* data stripped */')\n }\n\n contents += `${padding}export const script = ${strippedContent};\\n`\n contents += `export default script;\\n`\n } else {\n contents += `export const script = null;\\n`\n contents += `export default null;\\n`\n }\n\n if (sharedFn.script && sharedFn.script.stateContent) {\n const padding = '\\n'.repeat(Math.max(0, sharedFn.script.stateLineOffset || 0))\n contents += `${padding}export const state = ${sharedFn.script.stateContent};\\n`\n } else {\n contents += `export const state = null;\\n`\n }\n\n return {\n contents,\n loader: 'js',\n resolveDir: sharedFn.filePath ? dirname(sharedFn.filePath) : process.cwd()\n }\n })\n }\n }\n ]\n })\n\n const manifest = {}\n if (result.metafile && result.metafile.outputs) {\n for (const [outputPath, meta] of Object.entries(result.metafile.outputs)) {\n if (meta.entryPoint) {\n const entryPoint = meta.entryPoint\n const cleanEntry = entryPoint.includes(':') ? entryPoint.split(':').pop() : entryPoint\n\n // STRIP THE EXTENSION (Fixes E2E Bootstrapper Timeout)\n const tagName = parse(cleanEntry).name\n\n // USE RELATIVE PATHS (Fixes the chunks/ 404 issue)\n const relativePath = relative('assets/js', outputPath).replace(/\\\\/g, '/')\n\n manifest[tagName] = relativePath\n }\n }\n }\n\n const outdirAbs = resolve('assets/js')\n const outputFiles = {}\n\n if (result.outputFiles) {\n for (const file of result.outputFiles) {\n // Keep the relative path for the output file creation on disk\n const relativePath = relative(outdirAbs, file.path).replace(/\\\\/g, '/')\n\n outputFiles[relativePath] = {\n ...file,\n hashedPath: relativePath,\n text: file.text\n }\n }\n }\n\n return {\n manifest,\n outputFiles,\n importMap: resolvedImportMap\n }\n}\n", "import { CoraliteError } from './errors.js'\n\n/**\n * @import {\n * CoraliteModule,\n * CoraliteComponent,\n * CoraliteComponentResult,\n * } from '../../types/index.js'\n */\n\nconst KEBAB_REGEX = /[-|:]([a-z])/g\n\n/**\n * Converts a kebab-case string to camelCase\n * @param {string} str - The kebab-case string to convert\n * @returns {string} - The camelCase version of the string\n */\nexport function kebabToCamel (str) {\n // replace each dash followed by a letter with the uppercase version of the letter\n return str.replace(KEBAB_REGEX, function (match, letter) {\n return letter.toUpperCase()\n })\n}\n\n/**\n * Converts all keys in an object from kebab-case to camelCase\n * @template T\n * @param {Record<string, T>} object - The object with kebab-case keys\n * @returns {Record<string, T>} - A new object with camelCase keys\n */\nexport function cleanKeys (object) {\n /** @type {Record<string, T>} */\n const result = {}\n\n for (const [key, value] of Object.entries(object)) {\n result[key] = value\n\n const camelKey = kebabToCamel(key)\n if (camelKey !== key) {\n result[camelKey] = value\n }\n }\n\n return result\n}\n\n/**\n * Recursively clones an object or array and normalizes any function state\n * it finds into a string representation that preserves standard function syntax,\n * bypassing ES6 shorthand method serialization issues.\n * @param {any} target - The object or array to normalize.\n * @param {Function} [transform] - Optional transform function for each node.\n * @param {WeakMap} [seen=new WeakMap()] - Map of seen objects to handle circular references.\n * @returns {any} A deeply cloned object with normalized functions.\n */\nexport function normalizeObjectFunctions (target, transform = null, seen = new WeakMap()) {\n if (typeof transform === 'function') {\n const transformed = transform(target)\n if (transformed !== target) {\n return transformed\n }\n }\n\n if (typeof target !== 'object' || target === null) {\n return target\n }\n\n if (seen.has(target)) {\n return seen.get(target)\n }\n\n if (Array.isArray(target)) {\n const arr = []\n seen.set(target, arr)\n for (let i = 0; i < target.length; i++) {\n arr.push(normalizeObjectFunctions(target[i], transform, seen))\n }\n return arr\n }\n\n const obj = {}\n seen.set(target, obj)\n for (const key in target) {\n if (Object.hasOwn(target, key)) {\n if (typeof target[key] === 'function') {\n const normalizedString = normalizeFunction(target[key])\n const originalFunction = target[key]\n\n const wrapper = function () {\n return originalFunction.apply(this, arguments)\n }\n wrapper.toString = () => normalizedString\n obj[key] = wrapper\n } else {\n obj[key] = normalizeObjectFunctions(target[key], transform, seen)\n }\n }\n }\n\n return obj\n}\n\n/**\n * Checks whether the given object is an object and has at least one own key.\n * @param {any} obj - The object to check.\n * @returns {boolean} True if the object is truthy and has keys, otherwise false.\n */\nexport function hasObjectKeys (obj) {\n return obj && typeof obj === 'object' && Object.keys(obj).length > 0\n}\n\n/**\n * Merges two arrays, returning a new array with unique items.\n * Uses JSON.stringify for deep comparison of object elements, preserving object uniqueness correctly.\n * @param {Array<any>} [arr1] - The first array.\n * @param {Array<any>} [arr2] - The second array.\n * @returns {Array<any>} A new array with unique values from both input arrays.\n */\nexport function mergeUniqueObjects (arr1, arr2) {\n const all = [...(arr1 || []), ...(arr2 || [])]\n const seen = new Set()\n return all.filter(item => {\n const key = typeof item === 'object' ? JSON.stringify(item) : item\n if (seen.has(key)) {\n return false\n }\n seen.add(key)\n return true\n })\n}\n\n/**\n * Normalizes function declarations to ensure consistent formatting.\n * Converts shorthand method syntax to full function declarations where needed,\n * while preserving arrow functions and existing full declarations.\n *\n * @param {Function} func - The function to normalize\n * @returns {string} The normalized function string representation\n */\nexport function normalizeFunction (func) {\n const original = func.toString().trim()\n\n const firstBrace = original.indexOf('{')\n const firstArrow = original.indexOf('=>')\n\n const isArrow = firstArrow !== -1 && (firstBrace === -1 || firstArrow < firstBrace)\n\n if (isArrow) {\n return original\n }\n\n // For non-arrows, extract header to check for shorthand\n const header = firstBrace !== -1 ? original.slice(0, firstBrace).trim() : original\n\n const isStandard = header.startsWith('function') || header.startsWith('async function')\n\n if (isStandard) {\n return original\n }\n\n // Handle Method Shorthand\n if (header.startsWith('async ')) {\n if (header.startsWith('async get ') || header.startsWith('async set ')) {\n return original\n }\n\n return original.replace(/^async\\s+([$\\w]+)\\s*\\(/, 'async function(')\n } else {\n if (header.startsWith('get ') || header.startsWith('set ')) {\n return original\n }\n\n return original.replace(/^([$\\w]+)\\s*\\(/, 'function(')\n }\n}\n\n\n/**\n * Recursively clones an AST node and its children, ensuring that\n * inner references (like parents and slots) point to the newly cloned nodes.\n *\n * @param {Map<Object, Object>} nodeMap - A map tracking original nodes to their newly cloned counterparts.\n * @param {Object} node - The current AST node being cloned.\n * @param {Object} [parent] - The parent node reference to assign to the clone.\n * @returns {Object} The newly cloned node.\n */\nexport function cloneNode (nodeMap, node, parent) {\n const newNode = Object.create(Object.getPrototypeOf(node))\n\n // Copy all own enumerable properties\n Object.assign(newNode, node)\n\n if (parent) {\n newNode.parent = parent\n }\n\n if (newNode.attribs) {\n newNode.attribs = { ...newNode.attribs }\n }\n\n // Register in map\n nodeMap.set(node, newNode)\n\n // Recursively clone children\n if (node.children) {\n const children = node.children\n const length = children.length\n const clonedChildren = new Array(length)\n newNode.children = clonedChildren\n\n for (let i = 0; i < length; i++) {\n const clonedChild = cloneNode(nodeMap, children[i], newNode)\n clonedChildren[i] = clonedChild\n if (i > 0) {\n clonedChild.prev = clonedChildren[i - 1]\n clonedChildren[i - 1].next = clonedChild\n }\n }\n }\n\n // Update slot references to point to new cloned nodes\n if (node.slots) {\n const slots = node.slots\n const length = slots.length\n const clonedSlots = new Array(length)\n for (let i = 0; i < length; i++) {\n const slot = slots[i]\n const clonedSlot = { ...slot }\n if (slot.node) {\n const clonedNode = nodeMap.get(slot.node)\n if (clonedNode) {\n clonedSlot.node = clonedNode\n }\n }\n clonedSlots[i] = clonedSlot\n }\n newNode.slots = clonedSlots\n }\n\n // Preserve the enhanced flag without re-running enhanceNode\n Object.defineProperty(newNode, '__coralite_enhanced__', {\n value: true,\n enumerable: false,\n configurable: true\n })\n\n return newNode\n}\n\n/**\n * Creates a shallow copy of a CoraliteModule with a deep clone of its DOM tree (template) and re-linked internal references to enable safe independent mutation.\n *\n * Top-level non-DOM state (id, path, script, isTemplate, lineOffset) are shallow copied. Nested objects within these state (e.g., path) remain shared references. Only DOM-related structures undergo deep cloning and reference re-linking to isolate mutations from the original module.\n *\n * @param {CoraliteModule} originalModule - Module to clone.\n * @returns {CoraliteModule}\n */\nexport function cloneModuleInstance (originalModule) {\n const nodeMap = new Map()\n\n // Clone the main template tree\n const newTemplate = cloneNode(nodeMap, originalModule.template, null)\n\n // Reconstruct the 'values' object\n const newValues = {\n attributes: originalModule.values.attributes.map(item => ({\n ...item,\n element: nodeMap.get(item.element)\n })),\n textNodes: originalModule.values.textNodes.map(item => ({\n ...item,\n textNode: nodeMap.get(item.textNode)\n })),\n refs: originalModule.values.refs.map(item => ({\n ...item,\n element: nodeMap.get(item.element)\n }))\n }\n\n // Reconstruct customElements list\n const newCustomElements = originalModule.customElements.map(el => nodeMap.get(el))\n\n // Reconstruct slotElements\n const newSlotElements = {}\n if (originalModule.slotElements) {\n for (const modId in originalModule.slotElements) {\n newSlotElements[modId] = {}\n const slotGroup = originalModule.slotElements[modId]\n\n for (const slotName in slotGroup) {\n const slotItem = slotGroup[slotName]\n newSlotElements[modId][slotName] = {\n ...slotItem,\n element: nodeMap.get(slotItem.element)\n }\n }\n }\n }\n\n // Return the new module structure\n return {\n ...originalModule,\n template: newTemplate,\n values: newValues,\n customElements: newCustomElements,\n // @ts-ignore\n slotElements: newSlotElements\n }\n}\n\n/**\n * Creates a deep copy of a CoraliteComponent with re-linked internal references to enable safe independent mutation.\n *\n * @param {CoraliteComponent & CoraliteComponentResult} originalDocument - Document to clone.\n * @returns {CoraliteComponent & CoraliteComponentResult}\n */\nexport function cloneComponentInstance (originalDocument) {\n const nodeMap = new Map()\n const newRoot = cloneNode(nodeMap, originalDocument.root, null)\n\n const newCustomElements = originalDocument.customElements.map(el => nodeMap.get(el))\n const newTempElements = originalDocument.tempElements ? originalDocument.tempElements.map(el => nodeMap.get(el)) : []\n const newSkipRenderElements = originalDocument.skipRenderElements ? originalDocument.skipRenderElements.map(el => nodeMap.get(el)) : []\n\n return {\n ...originalDocument,\n state: { ...originalDocument.state },\n root: newRoot,\n customElements: newCustomElements,\n tempElements: newTempElements,\n skipRenderElements: newSkipRenderElements\n }\n}\n\n/**\n * Calculates the DOM path from a node to the root.\n * @param {Object} node - The node to calculate the path for.\n * @param {Object} root - The root node.\n * @returns {Array<number>} An array of indices representing the path.\n */\nexport function getNodePath (node, root) {\n const path = []\n let current = node\n while (current && current !== root) {\n const parent = current.parent\n if (!parent) {\n break\n }\n const index = parent.children.indexOf(current)\n if (index === -1) {\n break\n }\n path.unshift(index)\n current = parent\n }\n return path\n}\n\n/**\n * Generates a hydration map for the client.\n * @param {Array<Object>} templateNodes - The component's template nodes.\n * @param {Object} templateValues - The component's template values.\n * @returns {Object} The hydration map.\n */\nexport function generateHydrationMap (templateNodes, templateValues) {\n const map = {\n texts: [],\n attributes: [],\n refs: []\n }\n\n if (!templateNodes || !templateValues) {\n return map\n }\n\n const root = templateNodes.length > 0 ? templateNodes[0].parent : { children: templateNodes }\n\n if (templateValues.textNodes) {\n for (const item of templateValues.textNodes) {\n if (item.textNode) {\n const isHtml = item.type === 'html'\n const targetNode = isHtml ? item.textNode.parent : item.textNode\n\n map.texts.push({\n path: getNodePath(targetNode, root),\n template: item.textNode.data,\n type: isHtml ? 'html' : 'text'\n })\n }\n }\n }\n\n if (templateValues.attributes) {\n for (const item of templateValues.attributes) {\n if (item.element && item.element.attribs) {\n const originalValue = item.element.attribs[item.name]\n map.attributes.push({\n path: getNodePath(item.element, root),\n name: item.name,\n template: originalValue\n })\n }\n }\n }\n\n if (templateValues.refs) {\n for (const item of templateValues.refs) {\n if (item.element) {\n map.refs.push({\n path: getNodePath(item.element, root),\n name: item.name\n })\n }\n }\n }\n\n return map\n}\n\n/**\n * Recursively adds a component and its dependencies to a tracking object.\n *\n * @param {string} componentId - The ID of the component to add.\n * @param {Object.<string, boolean>} processed - The object tracking processed components.\n * @param {Object.<string, any>} sharedFunctions - The map of shared component functions.\n */\nexport function addComponentAndDependencies (componentId, processed, sharedFunctions) {\n if (!processed[componentId] && sharedFunctions[componentId]) {\n processed[componentId] = true\n\n // Add all dependencies of this component\n const dependencies = sharedFunctions[componentId].components || []\n for (const depId of dependencies) {\n addComponentAndDependencies(depId, processed, sharedFunctions)\n }\n }\n}\n\n/**\n * Recursively clones an AST node and its children, stripping circular references\n * and assigning unique IDs for client-side hydration.\n *\n * @param {Array<Object>} nodes - The nodes to clean.\n * @param {WeakMap} nodeMap - Map to track original nodes to their unique IDs.\n * @param {Object} state - Object containing the current node counter.\n * @returns {Array<Object>|null} The cleaned AST nodes.\n */\nexport function cleanAST (nodes, nodeMap, state) {\n if (!nodes) {\n return null\n }\n\n return nodes.map((node) => {\n const cloned = { ...node }\n // Assign unique ID for token mapping\n const id = state.counter++\n nodeMap.set(node, id)\n cloned._id = id\n\n // Remove circular references\n delete cloned.parent\n delete cloned.prev\n delete cloned.next\n delete cloned.slots\n\n if (cloned.children) {\n cloned.children = cleanAST(cloned.children, nodeMap, state)\n }\n return cloned\n })\n}\n\n/**\n * Cleans the template values object, mapping original node references to unique IDs.\n *\n * @param {Object} values - The values object to clean.\n * @param {WeakMap} nodeMap - Map of original nodes to their unique IDs.\n * @returns {Object|null} The cleaned values object.\n */\nexport function cleanValues (values, nodeMap) {\n if (!values) {\n return null\n }\n\n const result = { ...values }\n\n if (result.attributes) {\n result.attributes = result.attributes.map(item => {\n const cloned = { ...item }\n cloned.elementId = nodeMap.get(item.element)\n delete cloned.element\n return cloned\n })\n }\n\n if (result.textNodes) {\n result.textNodes = result.textNodes.map(item => {\n const cloned = { ...item }\n cloned.textNodeId = nodeMap.get(item.textNode)\n delete cloned.textNode\n return cloned\n })\n }\n\n if (result.refs) {\n result.refs = result.refs.map(item => {\n const cloned = { ...item }\n cloned.elementId = nodeMap.get(item.element)\n delete cloned.element\n return cloned\n })\n }\n return result\n}\n\n/**\n * Safely merges partial plugin updates into the main context object.\n * Deeply merges plain objects and overwrites other types (arrays, primitives, etc.).\n *\n * @param {any} current - The current state object.\n * @param {any} patch - The patch object containing updates.\n * @returns {any} The newly merged state object.\n */\nexport function mergePluginState (current, patch) {\n if (!patch || typeof patch !== 'object') {\n return current\n }\n\n const result = { ...current }\n\n for (const key of Object.keys(patch)) {\n const patchValue = patch[key]\n const currentValue = result[key]\n\n // If both are plain objects, merge them deeply\n if (\n patchValue && typeof patchValue === 'object' && !Array.isArray(patchValue) &&\n currentValue && typeof currentValue === 'object' && !Array.isArray(currentValue)\n ) {\n result[key] = mergePluginState(currentValue, patchValue)\n } else {\n // Otherwise, overwrite (Arrays, strings, numbers, etc.)\n result[key] = patchValue\n }\n }\n\n return result\n}\n\n/**\n * Creates a reactive proxy that triggers a callback on changes.\n * Supports deep reactivity via lazy proxying of nested objects.\n *\n * @param {Object} target - The object to proxy.\n * @param {Function} onChange - Callback triggered when a property is set or deleted.\n * @param {WeakMap} [proxies=new WeakMap()] - Cache for existing proxies to handle circular references and identity.\n * @returns {Proxy} The reactive proxy.\n */\nexport function createReactiveProxy (target, onChange, proxies = new WeakMap()) {\n if (proxies.has(target)) {\n return proxies.get(target)\n }\n\n const handler = {\n get (target, property, receiver) {\n const value = Reflect.get(target, property, receiver)\n if (value !== null && typeof value === 'object' && !(typeof Node !== 'undefined' && value instanceof Node)) {\n return createReactiveProxy(value, onChange, proxies)\n }\n return value\n },\n set (target, property, value, receiver) {\n const oldValue = target[property]\n if (oldValue === value && property in target) {\n return true\n }\n\n const result = Reflect.set(target, property, value, receiver)\n if (result) {\n onChange({\n property,\n value,\n oldValue,\n target\n })\n }\n return result\n },\n deleteProperty (target, property) {\n const hadProperty = Object.prototype.hasOwnProperty.call(target, property)\n const oldValue = target[property]\n const result = Reflect.deleteProperty(target, property)\n if (result && hadProperty) {\n onChange({\n property,\n value: undefined,\n oldValue,\n target,\n deleted: true\n })\n }\n return result\n }\n }\n\n const proxy = new Proxy(target, handler)\n proxies.set(target, proxy)\n return proxy\n}\n\n/**\n * Creates a read-only proxy that throws on mutation attempts.\n * @param {Object} target - The object to proxy.\n * @param {WeakMap} [proxies=new WeakMap()] - Cache for existing proxies.\n * @returns {Proxy} The read-only proxy.\n */\nexport function createReadOnlyProxy (target, proxies = new WeakMap()) {\n if (proxies.has(target)) {\n return proxies.get(target)\n }\n\n const handler = {\n get (target, property, receiver) {\n const value = Reflect.get(target, property, receiver)\n if (value !== null && typeof value === 'object' && !(typeof Node !== 'undefined' && value instanceof Node)) {\n return createReadOnlyProxy(value, proxies)\n }\n return value\n },\n set () {\n throw new CoraliteError('Cannot mutate state inside a getter. State is read-only here.')\n },\n deleteProperty () {\n throw new CoraliteError('Cannot delete state inside a getter. State is read-only here.')\n }\n }\n\n const proxy = new Proxy(target, handler)\n\n proxies.set(target, proxy)\n\n return proxy\n}\n\n/**\n * Defines a Coralite component.\n * On the client, this acts as an identity function for type safety and HRM.\n * @param {Object} options - Component options\n * @returns {Object} The component options\n */\nexport function defineComponent (options) {\n return options\n}\n", "import { parse as parseJS } from 'acorn'\nimport { simple as walkJS } from 'acorn-walk'\nimport render from 'dom-serializer'\nimport { sanitize } from 'isomorphic-dompurify'\nimport { parseHTML } from './parse.js'\nimport { isCoraliteNode } from '../types.js'\nimport { createCoraliteTextNode, relinkChildren } from './dom.js'\nimport { BOOLEAN_ATTRIBUTES } from '../tags.js'\n\n/**\n * @import {\n * CoraliteElement,\n * CoraliteModuleDefinition,\n * CoraliteTextNode,\n * ScriptContent\n * } from '../../../types/index.js'\n */\n\nconst astCache = new Map()\n\nfunction getAST (code, locations = false) {\n const cacheKey = `${code}_${locations}`\n if (astCache.has(cacheKey)) {\n return astCache.get(cacheKey)\n }\n const ast = parseJS(code, {\n ecmaVersion: 'latest',\n sourceType: 'module',\n locations\n })\n astCache.set(cacheKey, ast)\n return ast\n}\n\n/**\n * Extracts and normalizes the script content from a component definition.\n *\n * @param {string} code - The raw script content\n * @returns {ScriptContent | null}\n */\nexport function findAndExtractScript (code) {\n const ast = getAST(code, true)\n\n /** @type {ScriptContent | null} */\n let result = null\n const components = new Set()\n\n walkJS(ast, {\n CallExpression (node) {\n if (\n node.callee &&\n node.callee.type === 'Identifier' &&\n node.callee.name === 'defineComponent'\n ) {\n const firstArg = node.arguments[0]\n\n if (firstArg && firstArg.type === 'ObjectExpression') {\n const scriptProp = firstArg.properties.find(\n prop => prop.type === 'Property' &&\n prop.key && prop.key.type === 'Identifier' &&\n prop.key.name === 'script'\n )\n\n if (scriptProp && scriptProp.type === 'Property') {\n const { value, method } = scriptProp\n let startLine = value.loc.start.line - 1\n let prefix = ''\n let content = ''\n\n // Get source slice\n const source = code.slice(value.start, value.end)\n\n if (value.type === 'ArrowFunctionExpression') {\n content = prefix + source\n startLine = value.loc.start.line - 1\n } else if (value.type === 'FunctionExpression') {\n if (method) {\n const isAsync = value.async\n prefix += (isAsync ? 'async ' : '') + 'function script'\n content = prefix + source\n startLine = scriptProp.key.loc.start.line - 1\n } else {\n content = prefix + source\n startLine = value.loc.start.line - 1\n }\n }\n\n result = {\n content,\n lineOffset: startLine\n }\n }\n }\n } else if (\n node.callee &&\n node.callee.type === 'MemberExpression' &&\n node.callee.object &&\n node.callee.object.type === 'Identifier' &&\n node.callee.object.name === 'document' &&\n node.callee.property &&\n node.callee.property.type === 'Identifier' &&\n node.callee.property.name === 'createElement'\n ) {\n const arg = node.arguments[0]\n if (arg && arg.type === 'Literal' && typeof arg.value === 'string') {\n components.add(arg.value)\n }\n }\n }\n })\n\n if (result && components.size > 0) {\n result.components = Array.from(components)\n }\n\n return result\n}\n\n/**\n * Extracts and normalizes the state content from a component definition.\n *\n * @param {string} code - The raw script content\n * @returns {ScriptContent | null}\n */\nexport function findAndExtractProperties (code) {\n const ast = getAST(code, true)\n\n /** @type {ScriptContent | null} */\n let result = null\n\n walkJS(ast, {\n CallExpression (node) {\n if (\n node.callee &&\n node.callee.type === 'Identifier' &&\n node.callee.name === 'defineComponent'\n ) {\n const firstArg = node.arguments[0]\n\n if (firstArg && firstArg.type === 'ObjectExpression') {\n const stateProp = firstArg.properties.find(\n prop => prop.type === 'Property' &&\n prop.key && prop.key.type === 'Identifier' &&\n prop.key.name === 'state'\n )\n\n if (stateProp && stateProp.type === 'Property') {\n const { value, method } = stateProp\n let startLine = value.loc.start.line - 1\n let prefix = ''\n let content = ''\n\n // Get source slice\n const source = code.slice(value.start, value.end)\n\n if (value.type === 'ArrowFunctionExpression') {\n content = prefix + source\n startLine = value.loc.start.line - 1\n } else if (value.type === 'FunctionExpression') {\n if (method) {\n const isAsync = value.async\n prefix += (isAsync ? 'async ' : '') + 'function state'\n content = prefix + source\n startLine = stateProp.key.loc.start.line - 1\n } else {\n content = prefix + source\n startLine = value.loc.start.line - 1\n }\n } else if (value.type === 'ObjectExpression') {\n // Wrap object in a function returning that object\n content = `() => (${source})`\n startLine = value.loc.start.line - 1\n }\n\n result = {\n content,\n lineOffset: startLine\n }\n }\n }\n }\n }\n })\n\n return result\n}\n\n/**\n * Extracts all component tag names dynamically created via document.createElement.\n *\n * @param {string} code - The raw script content\n * @returns {Array<string>} - Array of identified imperative component tags\n */\nexport function findAndExtractImperativeComponents (code) {\n try {\n const ast = getAST(code)\n\n const components = new Set()\n\n walkJS(ast, {\n CallExpression (node) {\n if (\n node.callee &&\n node.callee.type === 'MemberExpression' &&\n node.callee.object &&\n node.callee.object.type === 'Identifier' &&\n node.callee.object.name === 'document' &&\n node.callee.property &&\n node.callee.property.type === 'Identifier' &&\n node.callee.property.name === 'createElement'\n ) {\n const arg = node.arguments[0]\n if (arg && arg.type === 'Literal' && typeof arg.value === 'string' && arg.value.includes('-')) {\n components.add(arg.value)\n }\n }\n }\n })\n\n return [...components]\n } catch {\n return []\n }\n}\n\n/**\n * Extracts global variable names from a module script code using Acorn parsing and AST walking.\n * @param {string} code - The raw script code\n * @returns {Array<string>} - Array of identified global variables\n */\nexport function extractGlobals (code) {\n try {\n const ast = getAST(code)\n\n const globals = new Set()\n walkJS(ast, {\n Identifier (node) {\n globals.add(node.name)\n }\n })\n\n return [...globals]\n } catch {\n return []\n }\n}\n\n/**\n * Transforms Coralite AST nodes into HTML strings for serialization.\n *\n * @param {any} target - The target to transform.\n * @returns {any} The transformed target.\n */\nexport function astTransformer (target) {\n if (isCoraliteNode(target)) {\n // @ts-ignore\n return render(target, { decodeEntities: false })\n }\n\n if (Array.isArray(target) && target.length > 0 && isCoraliteNode(target[0])) {\n // @ts-ignore\n return render(target, { decodeEntities: false })\n }\n\n return target\n}\n\n/**\n * Replaces a token in a Coralite node based on its type, attribute, and content.\n *\n * @param {Object} token - The token to replace.\n * @param {string} token.type - The type of the token ('attribute' or 'text').\n * @param {CoraliteElement|CoraliteTextNode} token.node - The node containing the token.\n * @param {string} [token.attribute] - The attribute name to replace within the node.\n * @param {string} token.content - The content of the token.\n * @param {CoraliteModuleDefinition} token.value - The definition associated with the token.\n */\nexport function replaceToken ({\n type,\n node,\n attribute,\n content,\n value\n}) {\n if (\n type === 'attribute'\n && node.type === 'tag'\n ) {\n if (BOOLEAN_ATTRIBUTES.has(attribute) && (node.attribs[attribute] || '').trim() === content) {\n // @ts-ignore\n const isFalsy = value === 'false' || value === 'null' || value === 'undefined' || value === '0' || value === 0 || value === '' || value === false || value === null || value === undefined\n\n if (isFalsy) {\n delete node.attribs[attribute]\n } else {\n node.attribs[attribute] = ''\n }\n } else if (typeof value === 'string') {\n node.attribs[attribute] = node.attribs[attribute].replace(content, value)\n }\n } else if (node.type === 'text') {\n if (typeof value === 'object' && value !== null) {\n if (Array.isArray(value) || value.type) {\n let nodesArray = Array.isArray(value) ? value : [value]\n\n // inject nodes\n const textSplit = node.data.split(content)\n const childIndex = node.parent.children.indexOf(node)\n const children = []\n\n // append computed tokens in between token split\n for (let i = 0; i < nodesArray.length; i++) {\n const child = nodesArray[i]\n\n if (typeof child !== 'string' && child.type !== 'directive' && typeof child === 'object' && child.type) {\n // update child parent\n // @ts-ignore\n child.parent = node.parent\n // @ts-ignore\n children.push(child)\n }\n }\n\n // replace computed token\n node.parent.children.splice(childIndex, 1,\n createCoraliteTextNode({\n type: 'text',\n data: textSplit[0],\n parent: node.parent\n }),\n // @ts-ignore\n ...children,\n createCoraliteTextNode({\n type: 'text',\n data: textSplit[1],\n parent: node.parent\n })\n )\n relinkChildren(node.parent)\n } else {\n // Handle object values like refs stringification\n node.data = node.data.replace(content, JSON.stringify(value))\n }\n } else {\n // replace token string\n // @ts-ignore\n const newVal = node.data.replace(content, value)\n const isHTML = /<[a-z][\\s\\S]*>/i.test(newVal)\n\n if (isHTML && node.parent\n && node.parent.type === 'tag'\n && node.parent.name === 'c-token'\n ) {\n const sanitized = sanitize(newVal)\n const parsed = parseHTML(sanitized)\n const children = parsed.root.children\n\n // Use the existing object-handling logic by recursing with the children array\n return replaceToken({\n type,\n node,\n attribute,\n content,\n value: children\n })\n }\n node.data = newVal\n }\n }\n}\n", "/**\n * @import {\n * CoraliteCollectionItem,\n * CoraliteComment,\n * CoraliteDirective,\n * CoraliteComponentRoot,\n * CoraliteElement,\n * CoraliteTextNode,\n * CoraliteAnyNode,\n * CoraliteSlotElement } from '../../types/index.js'\n */\n\n/**\n * Check if value is a non-null object\n * @param {any} obj - The value to check\n * @returns {boolean} True if the value is a non-null object\n */\nfunction isObject (obj) {\n return typeof obj === 'object' && obj !== null\n}\n\n/**\n * Checks if an object is a CoraliteElement.\n * @param {any} obj - The object to check.\n * @returns {obj is CoraliteElement} True if the object is a CoraliteElement, false otherwise.\n */\nfunction isCoraliteElement (obj) {\n return isObject(obj) && (obj.type === 'tag' || obj.type === 'script' || obj.type === 'style')\n}\n\n/**\n * Checks if an object is a CoraliteTextNode.\n * @param {any} obj - The object to check.\n * @returns {obj is CoraliteTextNode} True if the object is a CoraliteTextNode, false otherwise.\n */\nfunction isCoraliteTextNode (obj) {\n return isObject(obj) && obj.type === 'text'\n}\n\n/**\n * Checks if an object is a CoraliteComment.\n * @param {any} obj - The object to check.\n * @returns {obj is CoraliteComment} True if the object is a CoraliteComment, false otherwise.\n */\nfunction isCoraliteComment (obj) {\n return isObject(obj) && obj.type === 'comment'\n}\n\n/**\n * Checks if an object is a CoraliteDirective.\n * @param {any} obj - The object to check.\n * @returns {obj is CoraliteDirective} True if the object is a CoraliteDirective, false otherwise.\n */\nfunction isCoraliteDirective (obj) {\n return isObject(obj) && obj.type === 'directive'\n}\n\n/**\n * Checks if an object is a CoraliteComponentRoot.\n * @param {any} obj - The object to check.\n * @returns {obj is CoraliteComponentRoot} True if the object is a CoraliteComponentRoot, false otherwise.\n */\nfunction isCoraliteComponentRoot (obj) {\n return isObject(obj) && obj.type === 'root'\n}\n\n/**\n * Checks if an object is a CoraliteSlotElement.\n * @param {any} obj - The object to check.\n * @returns {obj is CoraliteSlotElement} True if the object is a CoraliteSlotElement, false otherwise.\n */\nfunction isCoraliteSlotElement (obj) {\n return isObject(obj) &&\n typeof obj.name === 'string' &&\n isCoraliteElement(obj.element) &&\n (obj.customElement === undefined || isCoraliteElement(obj.customElement))\n}\n\n/**\n * Determines whether the given object is a CoraliteCollectionItem.\n * @param {any} obj - The object to check.\n * @returns {obj is CoraliteCollectionItem} True if the object is a CoraliteCollectionItem, false otherwise.\n */\nfunction isCoraliteCollectionItem (obj) {\n return isObject(obj) &&\n 'path' in obj &&\n isObject(obj.path) &&\n typeof obj.path.pathname === 'string'\n}\n\n/**\n * Checks if an object is any Coralite node type (Element, TextNode, Comment, Directive, or DocumentRoot).\n * @param {any} obj - The object to check.\n * @returns {obj is CoraliteAnyNode | CoraliteDirective | CoraliteComponentRoot} True if the object is any Coralite node type.\n */\nfunction isCoraliteNode (obj) {\n return isCoraliteElement(obj) ||\n isCoraliteTextNode(obj) ||\n isCoraliteComment(obj) ||\n isCoraliteDirective(obj) ||\n isCoraliteComponentRoot(obj)\n}\n\n/**\n * Checks if an object has a valid CoraliteElement structure with required state.\n * @param {any} obj - The object to check.\n * @returns {boolean} True if the object has valid CoraliteElement structure.\n */\nfunction hasValidElementStructure (obj) {\n return isCoraliteElement(obj) &&\n typeof obj.name === 'string' &&\n isObject(obj.attribs) &&\n Array.isArray(obj.children)\n}\n\n/**\n * Checks if an object has a valid CoraliteTextNode structure with required state.\n * @param {any} obj - The object to check.\n * @returns {boolean} True if the object has valid CoraliteTextNode structure.\n */\nfunction hasValidTextNodeStructure (obj) {\n return isCoraliteTextNode(obj) &&\n typeof obj.data === 'string'\n}\n\n/**\n * Checks if an object has a valid CoraliteComment structure with required state.\n * @param {any} obj - The object to check.\n * @returns {boolean} True if the object has valid CoraliteComment structure.\n */\nfunction hasValidCommentStructure (obj) {\n return isCoraliteComment(obj) &&\n typeof obj.data === 'string'\n}\n\n/**\n * Safely checks if a value is a valid child node for a CoraliteElement.\n * @param {any} obj - The object to check.\n * @returns {boolean} True if the object is a valid child node.\n */\nfunction isValidChildNode (obj) {\n return isCoraliteElement(obj) ||\n isCoraliteTextNode(obj) ||\n isCoraliteComment(obj) ||\n isCoraliteDirective(obj)\n}\n\n/**\n * Checks if an object is a parent node (has children property).\n * @param {any} obj - The object to check.\n * @returns {boolean} True if the object has a children property.\n */\nfunction isParentNode (obj) {\n return isObject(obj) && Array.isArray(obj.children)\n}\n\n/**\n * Checks if an object is a removable node (has _markedForRemoval property set to true).\n * @param {any} obj - The object to check.\n * @returns {boolean} True if the object has _markedForRemoval property set to true.\n */\nfunction isRemovableNode (obj) {\n return isObject(obj) && obj._markedForRemoval === true\n}\n\nexport {\n // Core type guards\n isCoraliteElement,\n isCoraliteTextNode,\n isCoraliteComment,\n isCoraliteDirective,\n isCoraliteComponentRoot,\n isCoraliteSlotElement,\n isCoraliteCollectionItem,\n\n // Utility type guards\n isCoraliteNode,\n\n // Structure validation\n hasValidElementStructure,\n hasValidTextNodeStructure,\n hasValidCommentStructure,\n\n // Node property checks\n isValidChildNode,\n isParentNode,\n isRemovableNode\n}\n", "/**\n * @import { CoralitePlugin, HTMLData } from '../types/index.js'\n */\n\nimport { basename, dirname } from 'path'\nimport { CoraliteError } from './utils/errors.js'\n\n/**\n * Validates that a value is a non-empty string\n * @param {*} value - Value to validate\n * @param {string} paramName - Parameter name for error messages\n * @throws {Error} If value is not a valid non-empty string\n */\nfunction validateNonEmptyString (value, paramName) {\n if (typeof value !== 'string' || value.trim().length === 0) {\n throw new CoraliteError(\n `Coralite plugin validation failed: \"${paramName}\" must be a non-empty string, received ${typeof value}`\n )\n }\n}\n\n/**\n * Validates that a value is an array of strings (or empty array)\n * @param {*} value - Value to validate\n * @param {string} paramName - Parameter name for error messages\n * @throws {Error} If value is defined but not an array of strings\n */\nfunction validateStringArray (value, paramName) {\n if (!Array.isArray(value)) {\n throw new CoraliteError(\n `Coralite plugin validation failed: \"${paramName}\" must be an array, received ${typeof value}`\n )\n }\n\n for (let i = 0; i < value.length; i++) {\n if (typeof value[i] !== 'string') {\n throw new CoraliteError(\n `Coralite plugin validation failed: \"${paramName}[${i}]\" must be a string, received ${typeof value[i]}`\n )\n }\n }\n}\n\n/**\n * Processes a single components file with optional caching\n * @param {string} path - Template file path\n * @returns {HTMLData} Template data\n * @throws {Error} If components file cannot be read or is invalid\n */\nfunction processComponents (path) {\n try {\n const componentData = {\n path: {\n pathname: path,\n dirname: dirname(path),\n filename: basename(path)\n }\n }\n\n return componentData\n } catch (error) {\n throw new CoraliteError(\n `Coralite plugin component processing failed for \"${path}\": ${error.message}`,\n {\n cause: error,\n filePath: path\n }\n )\n }\n}\n\n/**\n * Creates a new Coralite plugin instance based on provided configuration options.\n * @param {CoralitePlugin & { server?: { components?: string[] } }} options - Plugin configuration object\n * @returns {CoralitePlugin} A configured plugin instance ready to be registered with Coralite\n * @example\n * // Basic plugin\n * const myPlugin = definePlugin({\n * name: 'my-plugin',\n * server: {\n * exports: {\n * getData: (context) => (options) => {\n * // Plugin logic implementation\n * return { ...context.state, custom: 'data', ...options }\n * }\n * }\n * }\n * })\n *\n * @example\n * // Plugin with components and metadata\n * const advancedPlugin = definePlugin({\n * name: 'advanced-plugin',\n * server: {\n * exports: {\n * process: (context) => async (options) => {\n * // Async plugin logic\n * return { ...context.state, processed: true, ...options }\n * }\n * },\n * components: ['src/components/header.html', 'src/components/footer.html'],\n * onPageSet: async (data) => {\n * console.log('Page created:', data.path.pathname)\n * }\n * }\n * })\n */\nexport function definePlugin ({\n name,\n server,\n client\n}) {\n validateNonEmptyString(name, 'name')\n\n let callerDir\n if (client != null && client.rootDir == null) {\n const stack = new Error().stack\n if (stack) {\n const callerLine = stack.split('\\n')[2]\n if (callerLine) {\n const match = callerLine.match(/file:\\/\\/(.+?):/)\n if (match) {\n callerDir = dirname(match[1])\n }\n }\n }\n }\n\n // Validate server plugin if provided\n if (server != null) {\n if (typeof server !== 'object') {\n throw new CoraliteError(\n `Coralite plugin validation failed: \"server\" must be an object, received ${typeof server}`\n )\n }\n\n server = { ...server }\n\n // Process component files with error handling\n if (server.components) {\n validateStringArray(server.components, 'server.components')\n\n const componentHTMLData = []\n try {\n // Process all components\n for (const path of server.components) {\n componentHTMLData.push(processComponents(path))\n }\n // @ts-ignore\n server.components = componentHTMLData\n } catch (error) {\n // Enhance error message with plugin context\n throw new CoraliteError(\n `Coralite plugin \"${name}\" failed to load components: ${error.message}`,\n { cause: error }\n )\n }\n }\n }\n\n // Validate client plugin if provided\n if (client != null) {\n if (typeof client !== 'object') {\n throw new CoraliteError(\n `Coralite plugin validation failed: \"client\" must be an object, received ${typeof client}`\n )\n }\n\n // Validate optional client state\n if (client.setup != null && typeof client.setup !== 'function') {\n throw new CoraliteError(\n `Coralite plugin validation failed: \"client.setup\" must be a function, received ${typeof client.setup}`\n )\n }\n\n if (client.config != null && typeof client.config !== 'object') {\n throw new CoraliteError(\n `Coralite plugin validation failed: \"client.config\" must be an object, received ${typeof client.config}`\n )\n }\n\n // append rootDir\n client.rootDir = client.rootDir || callerDir\n client.name = client.name || name\n }\n\n // Create the plugin object with all configured state\n return {\n name,\n server,\n client\n }\n}\n", "import { definePlugin } from '../lib/plugin.js'\n\n/**\n * @import { ParseHTMLResult } from '../types/index.js'\n * @import { CoraliteCollectionItem } from '../types/collection.js'\n * @import { CoraliteInstance, CoralitePage } from '../types/core.js'\n */\n\n/**\n * Processes a single element to extract metadata.\n */\nasync function processMetadataElement (element, context, index) {\n const { page, state, data, app, elements } = context\n\n if (element.type !== 'tag') {\n return\n }\n\n if (element.name === 'meta' && element.attribs?.name && element.attribs?.content) {\n page.meta[element.attribs.name] = element.attribs.content\n } else if (element.slots) {\n const componentElement = await app.createComponentElement({\n id: element.name,\n state,\n element,\n page,\n root: elements.root,\n contextId: data.path.pathname + index + element.name,\n index\n })\n\n if (componentElement) {\n for (let j = 0; j < componentElement.children.length; j++) {\n const child = componentElement.children[j]\n if (child.type === 'tag' && child.name === 'meta' && child.attribs?.name && child.attribs?.content) {\n page.meta[child.attribs.name] = child.attribs.content\n } else if (child.type === 'tag' && child.name === 'title' && child.children?.length && child.children[0].type === 'text') {\n page.meta.title = child.children[0].data\n }\n }\n }\n } else if (element.name === 'title' && element.children?.length && element.children[0].type === 'text') {\n page.meta.title = element.children[0].data\n }\n}\n\n/**\n * Extracts metadata tags from the parsed HTML root elements.\n * Supports static <title> and <meta> tags, as well as resolving dynamic custom\n * element slots inside the <head> segment to compute metadata.\n *\n * @param {Object} context - The context used to extract metadata from the document.\n * @param {ParseHTMLResult} context.elements - The parsed HTML elements including root\n * @param {CoralitePage} context.page - The global page object to store the extracted metadata\n * @param {Object.<string, any>} context.state - The global state object to store the extracted metadata\n * @param {CoraliteCollectionItem} context.data - The file data currently being evaluated\n * @param {CoraliteInstance} [context.app] - The global CoraliteInstance\n * @returns {Promise<void>}\n */\nasync function extractMetadata (context) {\n const { elements, page } = context\n page.meta.lang = ''\n\n for (let i = 0; i < elements.root.children.length; i++) {\n const rootNode = elements.root.children[i]\n\n if (rootNode.type === 'tag' && rootNode.name === 'html') {\n page.meta.lang = rootNode.attribs?.lang || ''\n\n for (let j = 0; j < rootNode.children.length; j++) {\n const node = rootNode.children[j]\n\n if (node.type === 'tag' && node.name === 'head') {\n for (let k = 0; k < node.children.length; k++) {\n await processMetadataElement(node.children[k], context, k)\n }\n return\n }\n }\n }\n }\n}\n\nexport const metadataPlugin = definePlugin({\n name: 'metadata',\n server: {\n async onPageSet ({ elements, state, page, data, app }) {\n await extractMetadata({\n elements,\n state,\n page,\n data,\n app\n })\n },\n async onPageUpdate ({ elements, page, newValue, app }) {\n await extractMetadata({\n elements,\n state: newValue.result.state,\n page,\n data: newValue,\n app\n })\n\n return {\n newValue: {\n result: {\n page\n }\n }\n }\n }\n }\n})\n", "import { definePlugin } from '../lib/plugin.js'\nimport { createRequire } from 'node:module'\nimport { dirname, join, parse } from 'node:path'\nimport { existsSync } from 'node:fs'\nimport { cp, mkdir, stat } from 'node:fs/promises'\n\n/**\n * Finds the nearest package.json starting from a given directory.\n * @param {string} startDir - The directory to start searching from.\n * @returns {string} The path to the directory containing package.json.\n * @throws {Error} If package.json is not found up to the root.\n */\nfunction findPackageRoot (startDir) {\n let currentDir = startDir\n const rootDir = parse(currentDir).root\n\n while (currentDir !== rootDir) {\n if (existsSync(join(currentDir, 'package.json'))) {\n return currentDir\n }\n currentDir = dirname(currentDir)\n }\n\n throw new Error('package.json not found')\n}\n\n/**\n * @import { CoraliteStaticAsset } from '../types/index.js'\n */\n\n/**\n * Coralite plugin to copy static assets during build\n * @param {CoraliteStaticAsset[]} assets - Static assets to copy during build.\n */\nexport const staticAssetPlugin = (assets = []) => {\n const inFlight = new Map()\n\n return definePlugin({\n name: 'static-asset-plugin',\n server: {\n onBeforeBuild: async function (context) {\n const outputDir = context.app.options.output || join(process.cwd(), 'dist')\n const copyTasks = []\n\n for (const asset of assets) {\n if (!asset.dest) {\n throw new Error('staticAssetPlugin requires assets to have a dest property.')\n }\n\n const dest = join(outputDir, asset.dest)\n let src = asset.src\n\n if (!src) {\n if (!asset.pkg || !asset.path) {\n throw new Error('staticAssetPlugin requires assets to have pkg and path state when src is not provided.')\n }\n\n const require = createRequire(join(process.cwd(), 'package.json'))\n let pkgPath\n\n try {\n pkgPath = dirname(require.resolve(`${asset.pkg}/package.json`))\n } catch {\n try {\n const resolvedPath = require.resolve(asset.pkg)\n pkgPath = findPackageRoot(dirname(resolvedPath))\n } catch {\n throw new Error(`staticAssetPlugin could not resolve package.json for package: ${asset.pkg}`)\n }\n }\n\n src = join(pkgPath, asset.path)\n }\n\n if (inFlight.has(dest)) {\n const active = inFlight.get(dest)\n if (active.src !== src) {\n console.warn(`[staticAssetPlugin] Destination collision: Both \"${src}\" and \"${active.src}\" are targeting \"${asset.dest}\". Only the first one will be processed.`)\n }\n copyTasks.push(active.promise)\n continue\n }\n\n const performCopy = (async () => {\n try {\n const [srcStat, destStat] = await Promise.all([\n stat(src).catch(() => null),\n stat(dest).catch(() => null)\n ])\n\n if (!srcStat) {\n console.warn(`[staticAssetPlugin] Source file not found: ${src}`)\n return\n }\n\n // Only optimize for individual files; directories must always be copied to capture deep changes\n if (srcStat.isFile() && destStat) {\n if (Math.floor(srcStat.mtimeMs) === Math.floor(destStat.mtimeMs) && srcStat.size === destStat.size) {\n return\n }\n }\n\n await mkdir(dirname(dest), { recursive: true })\n await cp(src, dest, {\n recursive: true,\n preserveTimestamps: true\n })\n } finally {\n inFlight.delete(dest)\n }\n })()\n\n inFlight.set(dest, {\n promise: performCopy,\n src\n })\n copyTasks.push(performCopy)\n }\n\n await Promise.all(copyTasks)\n }\n }\n })\n}\n", "import { definePlugin } from '../lib/plugin.js'\n\n/**\n * Traverses an AST recursively and duplicates 'ref' attributes to 'data-testid'.\n * Note: Modifying AST nodes in-place is required to preserve reference identity\n * for internal framework arrays (e.g. customElements, skipRenderElements).\n * @param {Array} children - The AST nodes to traverse.\n */\nfunction traverseAndAddTestId (children) {\n if (!Array.isArray(children)) {\n return\n }\n\n for (let i = 0; i < children.length; i++) {\n const node = children[i]\n\n if (node.type === 'tag' && node.attribs?.ref) {\n node.attribs['data-testid'] = node.attribs.ref\n }\n\n if (node.children?.length > 0) {\n traverseAndAddTestId(node.children)\n }\n }\n}\n\nexport const testingPlugin = definePlugin({\n name: 'testing',\n server: {\n onBeforeComponentRender: ({ instanceId, refs }) => {\n for (let i = 0; i < refs.length; i++) {\n const ref = refs[i]\n const uniqueRefValue = `${instanceId}__${ref.name}`\n\n if (ref.element.attribs) {\n ref.element.attribs['data-testid'] = uniqueRefValue\n }\n }\n },\n onComponentSet: ({ component }) => {\n const children = component?.template?.children\n if (children) {\n traverseAndAddTestId(children)\n }\n },\n onPageSet: ({ elements }) => {\n const children = elements?.root?.children\n if (children) {\n traverseAndAddTestId(children)\n }\n }\n },\n client: {\n onBeforeComponentRender: ({ instanceId, refs }) => {\n for (let i = 0; i < refs.length; i++) {\n const ref = refs[i]\n const uniqueRefValue = `${instanceId}__${ref.name}`\n\n if (ref.element && ref.element.setAttribute) {\n ref.element.setAttribute('data-testid', uniqueRefValue)\n }\n }\n }\n }\n})\n", "import { getHtmlFile, getHtmlFiles, discoverHtmlFiles } from './utils/server/html.js'\nimport { parseHTML, parseModule } from './utils/server/parse.js'\nimport { ScriptManager } from './script-manager.js'\nimport { metadataPlugin, staticAssetPlugin, testingPlugin } from '#plugins'\nimport { mkdir, writeFile } from 'node:fs/promises'\nimport { dirname, join, normalize, relative } from 'node:path'\nimport { handleError } from './utils/errors.js'\nimport { createExecutionError } from './utils/server/errors.js'\nimport { transformNode } from './parser.js'\nimport { evaluate } from './compiler.js'\nimport {\n triggerPluginAggregateHook,\n triggerPluginHook,\n bindPlugins\n} from './hooks.js'\nimport CoraliteCollection from './collection.js'\n\n// Refactored helper imports\nimport { createComponentDefinition, registerBaseComponent } from './component-setup.js'\nimport { setupPlugins } from './plugin-setup.js'\nimport { createPageHandlers } from './collection-handlers.js'\nimport { createRenderer } from './renderer.js'\nimport { initHasher } from './utils/server/manifest.js'\n\n/**\n * @import {\n * CoraliteConfig,\n * CoraliteInstance,\n * CoraliteBuildOptions,\n * CoraliteSaveResult\n * } from '../types/index.js'\n */\n\n/**\n * Factory function to create and initialize a Coralite instance.\n *\n * @param {CoraliteConfig} options - The configuration options for the Coralite instance.\n * @returns {Promise<CoraliteInstance>} A fully initialized Coralite instance.\n */\nexport async function createCoralite ({\n components,\n pages,\n plugins: userPlugins,\n assets,\n externalStyles,\n baseURL = '/',\n projectRoot = process.cwd(),\n ignoreByAttribute,\n skipRenderByAttribute,\n onError,\n mode = 'production',\n output\n}) {\n // Validate required parameters\n if (!components || typeof components !== 'string') {\n handleError({\n onErrorCallback: onError,\n data: {\n level: 'ERR',\n message: 'createCoralite requires \"components\" option to be defined as a string'\n }\n })\n }\n\n if (!pages || typeof pages !== 'string') {\n handleError({\n onErrorCallback: onError,\n data: {\n level: 'ERR',\n message: 'createCoralite requires \"pages\" option to be defined as a string'\n }\n })\n }\n\n const path = {\n components: normalize(components),\n pages: normalize(pages)\n }\n\n const normalizedOptions = {\n components,\n pages,\n plugins: [...(userPlugins || [])],\n assets,\n externalStyles,\n baseURL,\n projectRoot: normalize(projectRoot),\n ignoreByAttribute,\n skipRenderByAttribute,\n mode,\n path,\n output: output ? normalize(output) : undefined\n }\n\n /** @type {CoraliteInstance} */\n // @ts-ignore\n const app = {\n options: normalizedOptions,\n pages: null,\n components: null,\n build: null,\n save: null,\n transform: transformNode,\n addRenderQueue: null,\n getPagePathsUsingCustomElement: null,\n createComponentElement: null,\n _dependencyGraph: {\n pageCustomElements: {},\n childCustomElements: {}\n },\n _clearDependencies: () => {\n app._dependencyGraph.pageCustomElements = {}\n app._dependencyGraph.childCustomElements = {}\n }\n }\n\n // State\n const plugins = {\n components: [],\n hooks: {\n onPageSet: [],\n onPageUpdate: [],\n onPageDelete: [],\n onComponentSet: [],\n onComponentUpdate: [],\n onComponentDelete: [],\n onBeforePageRender: [],\n onAfterPageRender: [],\n onBeforeComponentRender: [],\n onAfterComponentRender: [],\n onBeforeBuild: [],\n onAfterBuild: []\n }\n }\n const scriptManager = new ScriptManager(normalizedOptions)\n // @ts-ignore\n const serverGlobalContext = { app }\n\n const _handleErrorLocal = (data) => handleError({\n onErrorCallback: onError,\n data\n })\n\n const source = {\n utils: {\n parseHTML: (string, ignore = normalizedOptions.ignoreByAttribute, skip = normalizedOptions.skipRenderByAttribute) => parseHTML(string, ignore, skip, _handleErrorLocal),\n parseModule: (string, opts) => parseModule(string, {\n ignoreByAttribute: normalizedOptions.ignoreByAttribute,\n skipRenderByAttribute: normalizedOptions.skipRenderByAttribute,\n onError: _handleErrorLocal,\n ...opts\n }),\n getHtmlFiles,\n getHtmlFile\n },\n plugins: {}\n }\n\n // @ts-ignore\n app.source = source\n\n // Helper to register a component via its ID\n const getComponent = (id) => app.components.getItem(id)\n\n const _triggerPluginHookLocal = (name, initialData) => triggerPluginHook({\n app,\n hooks: plugins.hooks,\n serverGlobalContext,\n name,\n initialData\n })\n\n const _triggerPluginAggregateHookLocal = (name, contextData) => triggerPluginAggregateHook({\n app,\n hooks: plugins.hooks,\n serverGlobalContext,\n name,\n contextData\n })\n\n const _bindPluginsLocal = (phase2Functions, instanceContext) => bindPlugins({\n serverGlobalContext,\n phase2Functions,\n instanceContext\n })\n\n const _defineComponent = createComponentDefinition({ app })\n\n const _evaluateLocal = (options) => evaluate({\n ...options,\n app,\n source,\n bindPlugins: _bindPluginsLocal,\n defineComponent: _defineComponent,\n createExecutionError,\n getComponent\n })\n\n // Instantiate the isolated rendering engine\n const renderer = createRenderer({\n app,\n scriptManager,\n source,\n evaluate: _evaluateLocal,\n handleError: _handleErrorLocal,\n hooks: {\n trigger: _triggerPluginHookLocal,\n triggerAggregate: _triggerPluginAggregateHookLocal,\n bind: _bindPluginsLocal\n },\n options: normalizedOptions,\n createExecutionError\n })\n\n Object.assign(app, {\n get outputFiles () {\n return renderer.outputFiles\n },\n createComponentElement: renderer.createComponentElement,\n build: renderer.build,\n /**\n * Executes a full build and saves the generated pages to the configured output directory.\n *\n * @param {string | string[]} [savePath] - The target path or directory to build.\n * @param {CoraliteBuildOptions} [saveOptions={}] - Additional configuration for the save process.\n * @returns {Promise<CoraliteSaveResult[]>} A promise resolving to an array of all saved file results.\n */\n save: async (savePath, saveOptions = {}) => {\n const signal = saveOptions?.signal\n const createdDir = {}\n if (!app.options.output) {\n handleError({\n onErrorCallback: onError,\n data: {\n level: 'ERR',\n message: 'Coralite instance must be configured with an \"output\" option to use save()'\n }\n })\n }\n const outputDir = app.options.output\n const results = []\n await app.build(savePath, saveOptions, async (result) => {\n // @ts-ignore\n const relativeDir = relative(app.options.path.pages, result.path.dirname)\n const outDir = join(outputDir, relativeDir)\n const outFile = join(outDir, result.path.filename)\n\n if (result.status === 'skipped') {\n return undefined\n }\n\n if (!createdDir[outDir]) {\n await mkdir(outDir, { recursive: true }); createdDir[outDir] = true\n }\n\n await writeFile(outFile, result.content, { signal })\n\n results.push({\n path: outFile,\n duration: result.duration\n })\n\n return undefined\n })\n\n if (renderer.outputFiles) {\n const assetsDir = join(outputDir, 'assets', 'js')\n\n if (!createdDir[assetsDir]) {\n await mkdir(assetsDir, { recursive: true }); createdDir[assetsDir] = true\n }\n\n const assetWrites = Object.values(renderer.outputFiles).map(async (file) => {\n const outFile = join(assetsDir, file.hashedPath)\n const outDir = dirname(outFile)\n\n if (!createdDir[outDir]) {\n await mkdir(outDir, { recursive: true }); createdDir[outDir] = true\n }\n\n await writeFile(outFile, file.text, { signal })\n\n results.push({\n path: outFile,\n duration: 0\n })\n })\n await Promise.all(assetWrites)\n }\n return results\n },\n\n addRenderQueue: renderer.addRenderQueue,\n clearCache: renderer.clearCache,\n\n _triggerPluginAggregateHook: _triggerPluginAggregateHookLocal,\n _triggerPluginHook: _triggerPluginHookLocal,\n /**\n * Retrieves all page paths that utilize a specific custom element.\n *\n * @param {string} targetPath - The path or ID of the custom element (component) to search for.\n * @returns {string[]} An array of page pathnames that include the specified component.\n */\n getPagePathsUsingCustomElement: (targetPath) => {\n // @ts-ignore\n if (targetPath.startsWith(app.options.path.components)) {\n // @ts-ignore\n targetPath = targetPath.substring(app.options.path.components.length + 1)\n }\n const item = app.components.getItem(targetPath)\n const results = []\n if (item) {\n const id = app._dependencyGraph.childCustomElements[item.result.id] || item.result.id\n const pce = app._dependencyGraph.pageCustomElements[id]\n if (pce) {\n pce.forEach(p => results.push(p))\n }\n }\n return results\n }\n })\n\n // --- Initialization ---\n\n // Pre-initialization: load core plugins\n if (app.options.mode === 'development') {\n app.options.plugins.unshift(testingPlugin)\n }\n app.options.plugins.unshift(metadataPlugin)\n if (assets) {\n app.options.plugins.unshift(staticAssetPlugin(assets))\n }\n\n await Promise.all([\n initHasher(),\n setupPlugins({\n app,\n // @ts-ignore\n serverGlobalContext,\n plugins,\n scriptManager,\n source\n })\n ])\n\n const handlers = createPageHandlers({\n app,\n triggerHook: _triggerPluginHookLocal,\n handleError: _handleErrorLocal,\n evaluate: _evaluateLocal,\n scriptManager,\n createSession: renderer.createSession\n })\n\n app.components = await getHtmlFiles({\n path: app.options.components,\n recursive: true,\n type: 'component',\n onFileSet: handlers.onComponentSet,\n onFileUpdate: handlers.onComponentUpdate,\n onFileDelete: handlers.onComponentDelete\n })\n\n await Promise.all(plugins.components.map(c => app.components.setItem(c)))\n\n // Perform base evaluation for all discovered components\n for (const component of app.components.list) {\n await registerBaseComponent({\n component: component.result,\n evaluate: _evaluateLocal,\n scriptManager,\n createSession: renderer.createSession,\n mode: app.options.mode\n })\n }\n\n app.pages = new CoraliteCollection({\n rootDir: app.options.pages,\n onSet: handlers.onPageSet,\n onUpdate: handlers.onPageUpdate,\n onDelete: handlers.onPageDelete\n })\n\n if (app.options.mode === 'production') {\n for await (const file of discoverHtmlFiles({\n path: app.options.pages,\n recursive: true,\n type: 'page',\n discoverOnly: false\n })) {\n // @ts-ignore\n await app.pages.setItem(file)\n }\n } else {\n await getHtmlFiles({\n path: app.options.pages,\n recursive: true,\n type: 'page',\n discoverOnly: false,\n // @ts-ignore\n collection: app.pages\n })\n }\n\n return app\n}\n\nexport default createCoralite\n", "\nimport { parse as parseJS } from 'acorn'\nimport { CoraliteError } from '../errors.js'\n\n/**\n * @import { CoraliteModule, CoraliteCollectionItem, CoralitePage } from '../../../types/index.js'\n */\n\nconst CURRENT_FILE_URL = import.meta.url\n\n/**\n * Helper to create CoraliteError during component execution\n * @param {Error} error - The caught error\n * @param {CoraliteModule} module - The component module\n * @param {CoraliteCollectionItem} moduleComponent - The parent module component\n * @param {CoralitePage} page - The current page\n * @param {string} instanceId - The unique instance id\n * @returns {CoraliteError} The generated error object\n */\nexport function createExecutionError (error, module, moduleComponent, page, instanceId) {\n let line, column, stackFile\n const isSyntaxError = error instanceof SyntaxError\n const isImportError = error.message.includes('provide an export named')\n\n if (error.stack) {\n const stackLines = error.stack.split('\\n')\n\n for (let i = 1; i < stackLines.length; i++) {\n const stackLine = stackLines[i]\n if (stackLine.includes(CURRENT_FILE_URL) || stackLine.includes('packages/coralite/lib/errors.js')) {\n continue\n }\n\n const match = stackLine.match(/\\(([^)]*):(\\d+):(\\d+)\\)$/) || stackLine.match(/at\\s+(.*?):(\\d+):(\\d+)$/)\n\n if (match) {\n stackFile = match[1]\n line = parseInt(match[2], 10)\n column = parseInt(match[3], 10)\n\n\n if (stackFile === 'node:internal/vm/module') {\n stackFile = moduleComponent.path.pathname\n line = undefined\n column = undefined\n }\n break\n }\n }\n }\n\n // Attempt to recover location for SyntaxErrors or Linking errors that lost it\n if (isSyntaxError || isImportError) {\n stackFile = moduleComponent.path.pathname\n try {\n // Re-parse to find syntax error location if missing\n parseJS(module.script, {\n ecmaVersion: 'latest',\n sourceType: 'module',\n locations: true\n })\n } catch (e) {\n const errorToParse = e\n\n if (errorToParse.loc) {\n line = (module.lineOffset || 0) + errorToParse.loc.line\n column = errorToParse.loc.column + 1\n } else if (errorToParse.pos !== undefined) {\n const prefix = module.script.substring(0, errorToParse.pos)\n const lines = prefix.split('\\n')\n\n line = (module.lineOffset || 0) + lines.length\n column = lines[lines.length - 1].length + 1\n }\n }\n\n // Some SyntaxErrors from VM have line/column properties (though often 1-based and relative to script)\n // @ts-ignore\n if (!line && error.lineNumber !== undefined) {\n // @ts-ignore\n line = (module.lineOffset || 0) + error.lineNumber\n // @ts-ignore\n column = error.columnNumber || 1\n }\n\n // For import errors, try to find the problematic import line\n if (isImportError && !line && module.script) {\n const match = error.message.match(/module '([^']*)' does not provide an export named '([^']*)'/)\n\n if (match) {\n const [, moduleName, exportName] = match\n const lines = module.script.split('\\n')\n\n for (let i = 0; i < lines.length; i++) {\n if (lines[i].includes(moduleName) && lines[i].includes(exportName)) {\n line = (module.lineOffset || 0) + i + 1\n column = lines[i].indexOf(exportName) + 1\n break\n }\n }\n }\n }\n }\n\n return new CoraliteError(error.message, {\n cause: error,\n componentId: module.id,\n filePath: moduleComponent.path.pathname,\n pagePath: page?.file?.pathname,\n instanceId,\n line,\n column,\n stackFile\n })\n}\n", "import render from 'dom-serializer'\nimport { parseHTML } from './utils/server/parse.js'\nimport { relinkChildren } from './utils/server/dom.js'\n\n/**\n * @import { CoraliteElement, CoraliteAnyNode, CoraliteComponentRoot, Attribute, CoraliteModule, CoraliteSession } from '../types/index.js'\n * @import { DomSerializerOptions } from 'dom-serializer'\n */\n\n/**\n * Renders the provided node or array of nodes using the render function.\n *\n * @param {CoraliteComponentRoot | CoraliteAnyNode | CoraliteAnyNode[]} root - The node(s) to be rendered.\n * @param {DomSerializerOptions} [options] - Changes serialization behavior\n * @returns {string}\n */\nexport function transformNode (root, options) {\n // @ts-ignore\n return render(root, {\n decodeEntities: false,\n ...options\n })\n}\n\n/**\n * Replaces a custom element with its template content.\n * @param {CoraliteElement} coraliteElement - The custom element to be replaced.\n * @param {CoraliteElement} element - The target element to replace the tokens with.\n */\nexport function replaceCustomElementWithTemplate (coraliteElement, element) {\n coraliteElement.children = element.children\n relinkChildren(coraliteElement)\n}\n\n/**\n * Process a token value - parse HTML strings and handle custom elements\n * @param {any} value - The value to process\n * @param {Object} context - Processing context\n * @param {Attribute[]} [context.excludeByAttribute] - List of attribute name-value pairs to ignore\n * @param {Object} [context.state] - Replacement tokens for the component\n * @param {CoraliteModule} [context.module] - The component module\n * @param {Function} [context.createComponentElement] - The createComponentElement function\n * @param {CoraliteSession} [context.session] - The current build session\n * @param {boolean} [context.noHydration] - No hydration flag\n * @returns {Promise<any>} - Processed value\n */\nexport async function processTokenValue (value, context) {\n const { excludeByAttribute, state, module, createComponentElement, session, noHydration } = context\n // If not a string, return as-is\n if (typeof value !== 'string') {\n return value\n }\n\n // Parse HTML string\n const result = parseHTML(value, excludeByAttribute)\n\n // If no children, return undefined (for empty HTML)\n if (!result.root.children.length) {\n return undefined\n }\n\n // Process custom elements\n for (let i = 0; i < result.customElements.length; i++) {\n const customElement = result.customElements[i]\n const cid = `${module.path.pathname}${customElement.name}-${i}`\n const childNoHydration = noHydration || (customElement.attribs && 'no-hydration' in customElement.attribs)\n\n const componentElement = await createComponentElement({\n contextId: cid,\n id: customElement.name,\n state,\n element: customElement,\n module,\n index: i,\n session,\n noHydration: childNoHydration\n })\n\n if (componentElement) {\n if (childNoHydration) {\n const parent = customElement.parent\n if (parent && parent.children) {\n const elementIndex = parent.children.indexOf(customElement)\n if (elementIndex !== -1) {\n parent.children.splice(elementIndex, 1, ...componentElement.children)\n relinkChildren(parent)\n }\n }\n } else {\n customElement.children = componentElement.children\n relinkChildren(customElement)\n\n if (!customElement.attribs) {\n customElement.attribs = {}\n }\n customElement.attribs['data-cid'] = cid\n\n session.componentTags.add(customElement.name)\n }\n }\n }\n\n // For static strings, optimize single text nodes\n if (result.root.children.length === 1 && result.root.children[0].type === 'text') {\n return result.root.children[0].data\n }\n\n return result.root.children\n}\n", "import { pathToFileURL } from 'node:url'\nimport { resolve } from 'node:path'\nimport { createContext } from 'node:vm'\nimport { transform } from 'esbuild'\nimport { createRequire } from 'node:module'\nimport { extractGlobals } from './utils/server/server.js'\nimport { CoraliteError } from './utils/errors.js'\n\n/**\n * @import { CoraliteModule, CoraliteModuleDefinitions, CoralitePage, CoraliteSession, CoraliteFilePath, CoralitePluginContext } from '../types/index.js'\n * @import { Module } from 'node:vm'\n */\n\nlet SourceTextModuleCache = null\n\n/**\n * Generates a custom module linker callback for the Node.js VM context.\n *\n * @param {Object} options - The options used to create the module linker.\n * @param {CoraliteFilePath} options.path - The file path metadata of the component\n * @param {CoralitePluginContext} options.context - Contextual rendering data\n * @param {Object} options.source - Framework source context\n * @param {Object} options.plugins - Bound plugins\n * @param {Function} options.importModuleDynamically - The dynamic import callback\n * @returns {(specifier: string, referencingModule: Module, extra: { attributes: any }) => Promise<Module>}\n */\nexport function createModuleLinker ({ path, context, source, plugins, importModuleDynamically }) {\n const componentDirURL = pathToFileURL(resolve(path.dirname)).href\n\n return async (specifier, referencingModule, extra) => {\n if (!SourceTextModuleCache) {\n SourceTextModuleCache = (await import('node:vm')).SourceTextModule\n }\n\n const SourceTextModule = SourceTextModuleCache\n const originalSpecifier = specifier\n\n if (plugins[specifier]) {\n const plugin = plugins[specifier]\n let pluginExports = ''\n\n for (const key in plugin) {\n if (Object.prototype.hasOwnProperty.call(plugin, key)) {\n pluginExports += `export const ${key} = globalThis.__coralite_plugins__[\"${specifier}\"][\"${key}\"];\\n`\n }\n }\n\n return new SourceTextModule(pluginExports, {\n context: referencingModule.context,\n importModuleDynamically\n })\n } else if (specifier == 'coralite/utils') {\n const utils = source.utils\n let utilsExports = ''\n\n utilsExports = 'const utils = globalThis.__coralite_utils__; export default utils;'\n\n for (const key in utils) {\n if (Object.prototype.hasOwnProperty.call(utils, key)) {\n utilsExports += `export const ${key} = utils[\"${key}\"];\\n`\n }\n }\n\n return new SourceTextModule(utilsExports, {\n context: referencingModule.context,\n importModuleDynamically\n })\n } else if (specifier === 'coralite') {\n let coraliteExports = 'const context = globalThis.__coralite_context__; export default context;'\n\n for (const key in context) {\n if (Object.prototype.hasOwnProperty.call(context, key)) {\n coraliteExports += `export const ${key} = context[\"${key}\"];\\n`\n }\n }\n\n coraliteExports += 'export const defineComponent = globalThis.__coralite_define_component__;\\n'\n\n return new SourceTextModule(coraliteExports, {\n context: referencingModule.context,\n importModuleDynamically\n })\n } else if (specifier.startsWith('.')) {\n // handle relative path\n specifier = pathToFileURL(resolve(path.dirname, specifier)).href\n } else {\n // handle modules\n specifier = import.meta.resolve(specifier, componentDirURL)\n }\n\n try {\n let module\n if (extra.attributes && Object.keys(extra.attributes).length > 0) {\n module = await import(specifier, { with: extra.attributes })\n } else {\n module = await import(specifier)\n }\n let exportModule = ''\n\n for (const key in module) {\n if (Object.prototype.hasOwnProperty.call(module, key)) {\n const name = 'globalThis[\"' + originalSpecifier + '\"].'\n\n if (key === 'default') {\n exportModule += 'export default ' + name + key + ';\\n'\n } else {\n exportModule += 'export const ' + key + ' = ' + name + key + ';\\n'\n }\n }\n\n referencingModule.context[originalSpecifier] = module\n }\n\n return new SourceTextModule(exportModule, {\n context: referencingModule.context,\n importModuleDynamically\n })\n } catch (error) {\n throw new CoraliteError(error.message, {\n cause: error,\n filePath: specifier\n })\n }\n }\n}\n\n/**\n * Parses a Coralite module script and evaluates it using SourceTextModule.\n *\n * @param {Object} options - The options used for module evaluation in development mode.\n * @param {CoraliteModule} options.module - The Coralite module to parse\n * @param {CoraliteModuleDefinitions} options.state - Replacement tokens for the component\n * @param {CoralitePage} options.page - The global page object\n * @param {any} options.root - The Coralite module to parse\n * @param {string} options.contextId - Context Id\n * @param {CoraliteSession} options.session - Render Context\n * @param {boolean} options.noHydration - No hydration flag\n * @param {Object} options.app - The Coralite instance\n * @param {Object} options.source - Framework source context\n * @param {Function} options.bindPlugins - Function to bind plugins\n * @param {Function} options.defineComponent - Function to define component\n * @param {Function} options.createExecutionError - Function to create execution error\n * @param {Function} options.getComponent - Function to get component\n *\n * @returns {Promise<CoraliteModuleDefinitions>}\n */\nexport async function evaluateDevelopment ({\n module,\n state,\n page,\n root,\n contextId,\n session,\n noHydration,\n app,\n source,\n bindPlugins,\n defineComponent,\n createExecutionError,\n getComponent\n}) {\n if (!SourceTextModuleCache) {\n SourceTextModuleCache = (await import('node:vm')).SourceTextModule\n }\n const SourceTextModule = SourceTextModuleCache\n\n if (!SourceTextModule) {\n throw new CoraliteError('SourceTextModule is not available. Please run Node.js with --experimental-vm-modules to use Development mode.')\n }\n\n const context = {\n state: state || {},\n page,\n root,\n module,\n id: contextId,\n session,\n app,\n noHydration\n }\n\n const cachedBoundPlugins = await bindPlugins(source.plugins, context)\n\n session.source.currentSourceContextId = contextId\n session.source.contextInstances[contextId] = context\n\n const boundDefineComponent = (options) => defineComponent(options, context)\n\n const standardBuiltIns = new Set(['Object', 'Function', 'Array', 'String', 'Boolean', 'Number', 'Math', 'Date', 'RegExp', 'Error', 'EvalError', 'RangeError', 'ReferenceError', 'SyntaxError', 'TypeError', 'URIError', 'JSON', 'Promise', 'Proxy', 'Reflect', 'Map', 'Set', 'WeakMap', 'WeakSet', 'ArrayBuffer', 'SharedArrayBuffer', 'DataView', 'Atomics', 'Int8Array', 'Uint8Array', 'Uint8ClampedArray', 'Int16Array', 'Uint16Array', 'Int32Array', 'Uint32Array', 'Float32Array', 'Float64Array', 'BigInt', 'BigInt64Array', 'BigUint64Array', 'Symbol', 'Infinity', 'NaN', 'undefined', 'globalThis', 'decodeURI', 'decodeURIComponent', 'encodeURI', 'encodeURIComponent', 'escape', 'eval', 'isFinite', 'isNaN', 'parseFloat', 'parseInt', 'unescape'])\n if (!module._globalsCache) {\n module._globalsCache = extractGlobals(module.script)\n }\n const usedGlobals = module._globalsCache\n\n const contextGlobals = {\n __coralite_context__: context,\n __coralite_plugins__: cachedBoundPlugins,\n __coralite_utils__: source.utils,\n __coralite_define_component__: boundDefineComponent\n }\n\n for (const glob of usedGlobals) {\n if (!standardBuiltIns.has(glob) && glob in globalThis && globalThis[glob] !== undefined && !(glob in contextGlobals)) {\n contextGlobals[glob] = globalThis[glob]\n }\n }\n\n const contextifiedObject = createContext(contextGlobals)\n const moduleComponent = getComponent(module.id)\n\n let linker\n\n const importModuleDynamically = async (specifier, referencingModule, extra) => {\n const mod = await linker(specifier, referencingModule, extra)\n if (mod.status === 'unlinked') {\n await mod.link(linker)\n }\n if (mod.status === 'linked') {\n await mod.evaluate()\n }\n return mod\n }\n\n linker = createModuleLinker({\n path: moduleComponent.path,\n context,\n source,\n plugins: cachedBoundPlugins,\n importModuleDynamically\n })\n\n const script = new SourceTextModule(module.script, {\n initializeImportMeta (meta) {\n meta.url = pathToFileURL(resolve(moduleComponent.path.pathname)).href\n },\n importModuleDynamically,\n lineOffset: module.lineOffset || 0,\n identifier: pathToFileURL(resolve(moduleComponent.path.pathname)).href,\n context: contextifiedObject\n })\n\n await script.link(linker)\n\n try {\n await script.evaluate()\n } catch (error) {\n throw createExecutionError(error, module, moduleComponent, page, contextId)\n }\n\n // @ts-ignore\n if (script.namespace.default != null) {\n // @ts-ignore\n return await script.namespace.default\n }\n\n throw new CoraliteError(`Module \"${module.id}\" has no default export`, {\n componentId: module.id,\n filePath: moduleComponent.path.pathname\n })\n}\n\n/**\n * Parses a Coralite module script and compiles it into JavaScript using esbuild.\n *\n * @param {Object} options - The options used for module evaluation.\n * @param {CoraliteModule} options.module - The Coralite module to parse\n * @param {CoraliteModuleDefinitions} options.state - Replacement tokens for the component\n * @param {CoralitePage} options.page - The global page object\n * @param {any} options.root - The Coralite module to parse\n * @param {string} options.contextId - Context Id\n * @param {CoraliteSession} options.session - Render Context\n * @param {boolean} options.noHydration - No hydration flag\n * @param {Object} options.app - The Coralite instance\n * @param {Object} options.source - Framework source context\n * @param {Function} options.bindPlugins - Function to bind plugins\n * @param {Function} options.defineComponent - Function to define component\n * @param {Function} options.createExecutionError - Function to create execution error\n * @param {Function} options.getComponent - Function to get component\n *\n * @returns {Promise<CoraliteModuleDefinitions>}\n */\nexport async function evaluateProduction ({\n module,\n state,\n page,\n root,\n contextId,\n session,\n noHydration,\n app,\n source,\n bindPlugins,\n defineComponent,\n createExecutionError,\n getComponent\n}) {\n const context = {\n state: state || {},\n page,\n root,\n module,\n id: contextId,\n session,\n app,\n noHydration\n }\n\n session.source.currentSourceContextId = contextId\n session.source.contextInstances[contextId] = context\n\n const moduleComponent = getComponent(module.id)\n\n if (!moduleComponent.result._compiledCode) {\n const paddingCount = Math.max(0, (module.lineOffset - 1 || 0))\n const padding = '\\n'.repeat(paddingCount)\n\n const { code } = await transform(padding + module.script, {\n loader: 'js',\n format: 'cjs',\n target: 'node18',\n platform: 'node'\n })\n\n moduleComponent.result._compiledCode = `(async() => {${code}})();`\n }\n\n const fileRequire = createRequire(resolve(moduleComponent.path.pathname))\n const cachedBoundPlugins = await bindPlugins(source.plugins, context)\n\n const customRequire = (id) => {\n const isCoralite = id === 'coralite'\n const isUtils = id === 'coralite/utils'\n const isPlugin = source.plugins[id] !== undefined\n\n if (isCoralite || isUtils || isPlugin) {\n if (isCoralite) {\n return {\n ...context,\n defineComponent: (options) => defineComponent(options, context),\n default: {\n ...context,\n defineComponent: (options) => defineComponent(options, context)\n }\n }\n }\n\n if (isPlugin) {\n return {\n ...(cachedBoundPlugins[id] || {}),\n default: cachedBoundPlugins[id]\n }\n }\n\n if (isUtils) {\n return {\n ...source.utils,\n default: source.utils\n }\n }\n }\n\n return fileRequire(id)\n }\n\n const moduleMock = { exports: {} }\n\n if (!moduleComponent.result._compiledFunction) {\n moduleComponent.result._compiledFunction = new Function(\n 'module',\n 'exports',\n 'require',\n 'coralite',\n moduleComponent.result._compiledCode.trim()\n )\n }\n\n const fn = moduleComponent.result._compiledFunction\n\n try {\n await fn(moduleMock, moduleMock.exports, customRequire, context)\n } catch (error) {\n throw createExecutionError(error, module, moduleComponent, page, contextId)\n }\n\n if (moduleMock.exports.default != null) {\n return moduleMock.exports.default\n }\n\n throw new CoraliteError(`Module \"${module.id}\" has no default export`, {\n componentId: module.id,\n filePath: moduleComponent.path.pathname\n })\n}\n\n/**\n * Evaluates a Coralite module script using the appropriate engine for the current mode.\n * @param {any} options - The evaluation options for the module.\n */\nexport async function evaluate (options) {\n if (options.mode === 'development') {\n return evaluateDevelopment(options)\n }\n return evaluateProduction(options)\n}\n", "import { mergePluginState } from './utils/core.js'\nimport { CoraliteError } from './utils/errors.js'\n\n/**\n * Registers a callback function under the specified hook name.\n *\n * @param {Object} hooks - The hooks storage object\n * @param {'onPageSet'|'onPageUpdate'|'onPageDelete'|'onComponentSet'|'onComponentUpdate'|'onComponentDelete'|'onBeforePageRender'|'onAfterPageRender'|'onBeforeComponentRender'|'onAfterComponentRender'|'onBeforeBuild'|'onAfterBuild'} name - Hook name\n * @param {Function} callback - Callback function\n */\nexport function addPluginHook (hooks, name, callback) {\n if (typeof callback !== 'function') {\n throw new CoraliteError(`Plugin hook \"${name}\" must be a function`)\n }\n\n if (hooks[name]) {\n hooks[name].push(callback)\n }\n}\n\n/**\n * Executes a collecting plugin hook where the results are aggregated.\n *\n * @param {Object} options - The options used to trigger the aggregated plugin hook.\n * @param {Object} options.app - The global Coralite app instance.\n * @param {Object} options.hooks - The collection of registered plugin hooks.\n * @param {Object} options.serverGlobalContext - The global server-side context.\n * @param {string} options.name - The name of the hook to trigger.\n * @param {any} options.contextData - The data associated with the hook context.\n * @returns {Promise<any[]>} Aggregated results\n */\nexport async function triggerPluginAggregateHook ({ app, hooks, serverGlobalContext, name, contextData }) {\n const pluginHooks = hooks[name]\n const aggregatedResults = []\n\n if (!pluginHooks || pluginHooks.length === 0) {\n return aggregatedResults\n }\n\n for (let i = 0; i < pluginHooks.length; i++) {\n let result = pluginHooks[i](Object.assign({ app }, serverGlobalContext, contextData))\n\n if (result !== null && typeof result === 'object' && typeof result.then === 'function') {\n result = await result\n }\n\n if (result !== undefined && result !== null) {\n if (Array.isArray(result)) {\n aggregatedResults.push(...result)\n } else {\n aggregatedResults.push(result)\n }\n }\n }\n\n return aggregatedResults\n}\n\n/**\n * Executes all plugin callbacks registered under the specified hook name sequentially.\n *\n * @param {Object} options - The options used to trigger the plugin hook.\n * @param {Object} options.app - The global Coralite app instance.\n * @param {Object} options.hooks - The collection of registered plugin hooks.\n * @param {Object} options.serverGlobalContext - The global server-side context.\n * @param {string} options.name - The name of the hook to trigger.\n * @param {any} options.initialData - The initial data to be modified by the hooks.\n * @returns {Promise<any>} Merged data\n */\nexport async function triggerPluginHook ({ app, hooks, serverGlobalContext, name, initialData }) {\n const pluginHooks = hooks[name]\n\n if (!pluginHooks || pluginHooks.length === 0) {\n return initialData\n }\n\n let currentData = typeof initialData === 'object' && initialData !== null\n ? Object.assign({ app }, serverGlobalContext, initialData)\n : initialData\n\n for (let i = 0; i < pluginHooks.length; i++) {\n let result = pluginHooks[i](currentData)\n\n if (result !== null && typeof result === 'object' && typeof result.then === 'function') {\n result = await result\n }\n\n if (result !== undefined && result !== null) {\n currentData = mergePluginState(currentData, result)\n }\n }\n\n return currentData\n}\n\n/**\n * Executes Phase 2 of plugin exports with the given instance context.\n *\n * @param {Object} options - The options used to bind plugins.\n * @param {Object} options.serverGlobalContext - The global server-side context.\n * @param {Object} options.phase2Functions - The map of Phase 2 plugin functions to be bound.\n * @param {Object} options.instanceContext - The specific instance context to bind the functions to.\n * @returns {Promise<Object>} Bound plugins\n */\nexport async function bindPlugins ({ serverGlobalContext, phase2Functions, instanceContext }) {\n const boundPlugins = {}\n const globalContext = Object.assign({ app: serverGlobalContext.app }, instanceContext)\n\n for (const name in phase2Functions) {\n const pluginExports = phase2Functions[name]\n if (pluginExports !== null && typeof pluginExports === 'object') {\n const boundObj = {}\n for (const prop in pluginExports) {\n if (typeof pluginExports[prop] === 'function') {\n boundObj[prop] = await pluginExports[prop](globalContext)\n } else {\n boundObj[prop] = pluginExports[prop]\n }\n }\n boundPlugins[name] = boundObj\n } else {\n boundPlugins[name] = pluginExports\n }\n }\n\n return boundPlugins\n}\n", "import { createReadOnlyProxy } from './utils/core.js'\nimport { processTokenValue } from './parser.js'\nimport { CoraliteError } from './utils/errors.js'\nimport {\n isCoraliteElement,\n isCoraliteTextNode,\n isCoraliteComment\n} from './utils/types.js'\nimport { findAndExtractScript, findAndExtractProperties } from './utils/server/server.js'\n\n/**\n * @import {\n * CoralitePluginContext,\n * CoraliteInstance\n * } from '../types/index.js'\n */\n\n/**\n * Factory to create the component definition function.\n *\n * @param {Object} dependencies - The dependencies required to create the component definition.\n * @param {CoraliteInstance} dependencies.app - The global Coralite app instance.\n * @returns {Function}\n */\nexport function createComponentDefinition ({ app }) {\n /**\n * This function defines a component for the Coralite framework.\n * @param {Object} options - Configuration options for the component\n * @param {CoralitePluginContext} context - The evaluation context\n * @returns {Promise<Object>}\n */\n return async (options, context) => {\n const { attributes, data, getters, slots, script } = options\n const { state: initialState, module, root } = context\n\n if (attributes) {\n for (const [key, value] of Object.entries(attributes)) {\n if (value.type === Object || value.type === Array) {\n throw new CoraliteError(`Component \"${module.id}\" defines attribute \"${key}\" as ${value.type.name}. Object and Array types are blocked in attributes. Use data() for complex data.`, {\n componentId: module.id,\n filePath: module.path?.pathname\n })\n }\n }\n }\n\n const state = Object.assign({}, initialState)\n const serializableAttributes = {}\n if (attributes) {\n for (const [key, schema] of Object.entries(attributes)) {\n serializableAttributes[key] = {\n type: schema.type.name || schema.type,\n default: schema.default\n }\n }\n }\n\n const scriptDefaultValues = {}\n if (attributes) {\n for (const [key, schema] of Object.entries(attributes)) {\n if (schema.default !== undefined) {\n scriptDefaultValues[key] = schema.default\n }\n }\n }\n\n state.__script__ = {\n attributes: serializableAttributes,\n getters: getters || {},\n state: {},\n defaultValues: scriptDefaultValues,\n slots: slots || {}\n }\n\n if (attributes) {\n for (const [key, schema] of Object.entries(attributes)) {\n const typeName = schema.type.name || schema.type\n if (state[key] !== undefined) {\n const value = state[key]\n if (typeName === 'Number') {\n state[key] = Number(value)\n } else if (typeName === 'Boolean') {\n state[key] = value !== 'false' && value !== null && value !== ''\n } else if (typeName === 'String') {\n state[key] = String(value)\n }\n } else if (schema.default !== undefined) {\n state[key] = schema.default\n }\n }\n }\n\n if (typeof data === 'function') {\n const dataResult = await data({\n ...context,\n ...initialState\n })\n if (dataResult) {\n state.__script__.data = dataResult\n Object.assign(state, dataResult)\n Object.assign(state.__script__.state, dataResult)\n }\n }\n\n if (getters) {\n const roState = createReadOnlyProxy(state)\n for (const [key, getter] of Object.entries(getters)) {\n const result = getter(roState, { signal: new AbortController().signal })\n state[key] = (result && typeof result.then === 'function') ? await result : result\n if (state.__script__ && state.__script__.state) {\n state.__script__.state[key] = state[key]\n }\n }\n }\n\n if (slots) {\n for (const name in slots) {\n if (Object.prototype.hasOwnProperty.call(slots, name)) {\n const computedSlot = slots[name]\n const methodKey = `slots_method_${name}`\n state.__script__.defaultValues[methodKey] = computedSlot\n const slotContent = []\n const elementSlots = []\n\n if (root && 'slots' in root && Array.isArray(root.slots)) {\n for (let j = 0; j < root.slots.length; j++) {\n const slot = root.slots[j]\n\n if (slot.name === name) {\n slotContent.push(slot.node)\n } else {\n elementSlots.push(slot)\n }\n }\n }\n\n let result = computedSlot(slotContent, state)\n if (result === undefined) {\n result = slotContent\n }\n\n if (result === null || result === '' || (Array.isArray(result) && result.length === 0)) {\n if (root && 'slots' in root && Array.isArray(root.slots)) {\n root.slots = root.slots.filter(s => s.name !== name)\n }\n\n continue\n }\n\n if (typeof result === 'string') {\n const processedResult = await processTokenValue(result, {\n ...context,\n state,\n createComponentElement: app.createComponentElement,\n noHydration: context.noHydration\n })\n if (Array.isArray(processedResult)) {\n for (let j = 0; j < processedResult.length; j++) {\n elementSlots.push({\n name,\n node: processedResult[j]\n })\n }\n } else {\n elementSlots.push({\n name,\n node: {\n type: 'text',\n data: processedResult\n }\n })\n }\n } else if (Array.isArray(result)) {\n for (let index = 0; index < result.length; index++) {\n const node = result[index]\n if (isCoraliteElement(node) || isCoraliteTextNode(node) || isCoraliteComment(node)) {\n elementSlots.push({\n name,\n node\n })\n } else {\n throw new CoraliteError(`Unexpected slot value in \"${module.path.pathname}\"`, {\n componentId: module.id,\n filePath: module.path.pathname\n })\n }\n }\n }\n\n if (root && 'slots' in root && Array.isArray(root.slots)) {\n root.slots = elementSlots\n }\n }\n }\n }\n\n const hasScript = typeof script === 'function'\n const hasSlots = slots && Object.keys(slots).length > 0\n const hasGetters = getters && Object.keys(getters).length > 0\n const hasAttributes = attributes && Object.keys(attributes).length > 0\n const hasData = typeof data === 'function'\n\n if (hasScript || hasSlots || hasGetters || hasAttributes || hasData) {\n if (hasScript) {\n const scriptTextContent = script.toString().trim()\n const args = {}\n for (const key in state) {\n if (!Object.hasOwn(state, key)) {\n continue\n }\n\n if (scriptTextContent.includes(key) || key.startsWith('ref_')) {\n args[key] = state.__script__.defaultValues[key] !== undefined\n ? state.__script__.defaultValues[key]\n : state[key]\n }\n }\n Object.assign(state.__script__.state, args)\n }\n } else {\n delete state.__script__\n }\n\n return state\n }\n}\n\n/**\n * Performs base evaluation and registers a component in the script manager.\n * Used during discovery and updates to lock in the pristine component definition.\n *\n * @param {Object} options - The registration options.\n * @param {any} options.component - The component document.\n * @param {Function} options.evaluate - The evaluation function.\n * @param {any} options.scriptManager - The script manager instance.\n * @param {Function} options.createSession - The session creation function.\n * @param {string} options.mode - The current build mode.\n * @returns {Promise<void>}\n */\nexport async function registerBaseComponent ({\n component,\n evaluate,\n scriptManager,\n createSession,\n mode\n}) {\n if (!component || !component.script) {\n return\n }\n\n try {\n const baseSession = createSession('base-evaluation')\n const scriptResult = await evaluate({\n module: component,\n state: {},\n page: {\n url: { pathname: '' },\n file: { pathname: '' },\n meta: {}\n },\n root: null,\n contextId: `base-${component.id}`,\n session: baseSession,\n mode\n })\n\n if (scriptResult && scriptResult.__script__) {\n const scriptMeta = scriptResult.__script__\n const templateAST = component.template?.children || []\n const templateValues = component.values || {}\n const stylesHTML = component._processedCss || ''\n\n const scriptObj = {\n ...scriptMeta,\n content: 'function(){}',\n state: scriptMeta.state || {},\n slots: scriptMeta.slots || {}\n }\n let defaultValues = scriptMeta.defaultValues || {}\n let extractedComponents = []\n\n if (!component._extractedScript) {\n component._extractedScript = findAndExtractScript(component.script)\n }\n const extractedScript = component._extractedScript\n\n if (extractedScript) {\n scriptObj.content = extractedScript.content\n scriptObj.lineOffset = (component.lineOffset || 0) + extractedScript.lineOffset\n extractedComponents = extractedScript.components || []\n }\n\n if (!component._extractedProperties) {\n component._extractedProperties = findAndExtractProperties(component.script)\n }\n const extractedProperties = component._extractedProperties\n\n if (extractedProperties) {\n scriptObj.stateContent = extractedProperties.content\n scriptObj.stateLineOffset = (component.lineOffset || 0) + extractedProperties.lineOffset\n }\n\n const declarativeComponents = (component.customElements || []).map(el => el.name)\n const nestedComponents = [...new Set([...declarativeComponents, ...extractedComponents])]\n scriptObj.components = nestedComponents\n\n templateValues?.refs?.forEach(ref => {\n const refKey = `ref_${ref.name}`\n defaultValues[refKey] = ''\n scriptObj.state[refKey] = ''\n })\n scriptObj.defaultValues = defaultValues\n\n scriptManager.registerComponent({\n id: component.id,\n getters: scriptMeta.getters,\n script: scriptObj,\n filePath: component.filePath || (component.path && component.path.pathname),\n templateAST,\n templateValues,\n defaultValues,\n styles: stylesHTML,\n slots: scriptMeta.slots,\n override: true\n })\n }\n } catch {\n // Base evaluation is allowed to fail silently\n }\n}\n", "import { addPluginHook } from './hooks.js'\n\n/**\n * @import { CoraliteInstance, CoralitePluginContext } from '../types/index.js'\n * @import { ScriptManager } from './script-manager.js'\n */\n\n/**\n * Logic for initializing plugins.\n *\n * @param {Object} dependencies - The dependencies required to initialize the plugins.\n * @param {CoraliteInstance} dependencies.app - The global Coralite app instance.\n * @param {CoralitePluginContext} dependencies.serverGlobalContext - The global server context for plugins.\n * @param {Object} dependencies.plugins - The collection of registered plugins and hooks.\n * @param {ScriptManager} dependencies.scriptManager - The script manager for handling client-side scripts.\n * @param {Object} dependencies.source - The framework source utilities and context.\n * @returns {Promise<void>}\n */\nexport async function setupPlugins ({\n app,\n serverGlobalContext,\n plugins,\n scriptManager,\n source\n}) {\n const pluginsToInit = app.options.plugins\n const allExportNames = new Set()\n\n for (const plugin of pluginsToInit) {\n if (plugin.server) {\n if (plugin.server.exports) {\n // @ts-ignore\n const { app: _, ...restGlobalContext } = serverGlobalContext\n // @ts-ignore\n const pluginContext = new Proxy(Object.assign({ app: serverGlobalContext.app }, restGlobalContext), {\n get (target, prop) {\n if (prop === 'config') {\n return plugin.server.config || {}\n }\n return target[prop]\n },\n set (target, prop, value) {\n serverGlobalContext[prop] = value\n return Reflect.set(target, prop, value)\n }\n })\n\n const phase2Obj = {}\n for (const prop in plugin.server.exports) {\n if (allExportNames.has(prop)) {\n throw new Error(`Coralite Error: Plugin export name conflict. The export name \"${prop}\" from plugin \"${plugin.name}\" is already defined by another plugin.`)\n }\n\n allExportNames.add(prop)\n\n if (typeof plugin.server.exports[prop] === 'function') {\n // @ts-ignore\n phase2Obj[prop] = await plugin.server.exports[prop](pluginContext)\n } else {\n phase2Obj[prop] = plugin.server.exports[prop]\n }\n }\n source.plugins[plugin.name] = phase2Obj\n serverGlobalContext[plugin.name] = phase2Obj\n }\n if (plugin.server.components) {\n plugin.server.components.forEach(c => plugins.components.push(c))\n }\n const wrapHook = (hook) => (ctx) => {\n const hookContext = Object.create(ctx)\n hookContext.config = plugin.server.config || {}\n return hook(hookContext)\n }\n\n if (plugin.server.onPageSet) {\n addPluginHook(plugins.hooks, 'onPageSet', wrapHook(plugin.server.onPageSet))\n }\n if (plugin.server.onPageDelete) {\n addPluginHook(plugins.hooks, 'onPageDelete', wrapHook(plugin.server.onPageDelete))\n }\n if (plugin.server.onPageUpdate) {\n addPluginHook(plugins.hooks, 'onPageUpdate', wrapHook(plugin.server.onPageUpdate))\n }\n if (plugin.server.onComponentSet) {\n addPluginHook(plugins.hooks, 'onComponentSet', wrapHook(plugin.server.onComponentSet))\n }\n if (plugin.server.onComponentDelete) {\n addPluginHook(plugins.hooks, 'onComponentDelete', wrapHook(plugin.server.onComponentDelete))\n }\n if (plugin.server.onComponentUpdate) {\n addPluginHook(plugins.hooks, 'onComponentUpdate', wrapHook(plugin.server.onComponentUpdate))\n }\n if (plugin.server.onBeforePageRender) {\n addPluginHook(plugins.hooks, 'onBeforePageRender', wrapHook(plugin.server.onBeforePageRender))\n }\n if (plugin.server.onAfterPageRender) {\n addPluginHook(plugins.hooks, 'onAfterPageRender', wrapHook(plugin.server.onAfterPageRender))\n }\n if (plugin.server.onBeforeComponentRender) {\n addPluginHook(plugins.hooks, 'onBeforeComponentRender', wrapHook(plugin.server.onBeforeComponentRender))\n }\n if (plugin.server.onAfterComponentRender) {\n addPluginHook(plugins.hooks, 'onAfterComponentRender', wrapHook(plugin.server.onAfterComponentRender))\n }\n if (plugin.server.onBeforeBuild) {\n addPluginHook(plugins.hooks, 'onBeforeBuild', async (ctx) => {\n const hookContext = Object.create(ctx)\n hookContext.config = plugin.server.config || {}\n const res = await plugin.server.onBeforeBuild(hookContext)\n if (res && typeof res === 'object') {\n Object.assign(serverGlobalContext, res)\n }\n return res\n })\n }\n if (plugin.server.onAfterBuild) {\n addPluginHook(plugins.hooks, 'onAfterBuild', wrapHook(plugin.server.onAfterBuild))\n }\n }\n if (plugin.client) {\n plugin.client.name = plugin.client.name || plugin.name\n scriptManager.use(plugin.client)\n }\n }\n}\n", "import { dirname, join, relative } from 'node:path'\nimport { pathToFileURL } from 'node:url'\nimport { parseHTML, parseModule } from './utils/server/parse.js'\nimport { registerBaseComponent } from './component-setup.js'\n\n/**\n * @import {\n * CoraliteInstance,\n * CoraliteOnError\n * } from '../types/index.js'\n */\n\n/**\n * Factory for collection handlers.\n *\n * @param {Object} context - The context containing shared dependencies for the handlers.\n * @param {CoraliteInstance} context.app - The global Coralite app instance.\n * @param {Function} context.triggerHook - The function used to trigger plugin hooks.\n * @param {CoraliteOnError} context.handleError - The callback for handling errors during collection events.\n * @param {Function} [context.evaluate] - The evaluation function for components.\n * @param {any} [context.scriptManager] - The script manager for components.\n * @param {Function} [context.createSession] - The session creation function.\n * @returns {Object}\n */\nexport function createPageHandlers ({\n app,\n triggerHook,\n handleError,\n evaluate,\n scriptManager,\n createSession\n}) {\n const { pageCustomElements, childCustomElements } = app._dependencyGraph\n const onFileSetLocal = async (data) => {\n // @ts-ignore\n const rootPath = data.type === 'component' ? app.options.path.components : app.options.path.pages\n const urlPathname = pathToFileURL(join('/', relative(rootPath, data.path.pathname))).pathname\n const page = {\n url: {\n pathname: urlPathname,\n dirname: pathToFileURL(dirname(urlPathname)).pathname\n },\n file: {\n pathname: data.path.pathname,\n dirname: data.path.dirname,\n filename: data.path.filename\n },\n meta: data.state?.page?.meta || {}\n }\n\n const state = {\n ...data.state,\n page\n }\n\n if (data.content === undefined) {\n return ({\n type: 'page',\n value: {\n state,\n page,\n path: data.path\n }\n })\n }\n\n const elements = parseHTML(data.content, app.options.ignoreByAttribute, app.options.skipRenderByAttribute, handleError)\n\n if (true) {\n const customElementsList = elements && elements.customElements ? elements.customElements : []\n for (let i = 0; i < customElementsList.length; i++) {\n const name = customElementsList[i].name\n if (!pageCustomElements[name]) {\n pageCustomElements[name] = new Set()\n // Always track dependencies for ISR\n // @ts-ignore\n app._dependencyGraph.pageCustomElements[name] = pageCustomElements[name]\n const component = app.components.getItem(name)\n\n if (component && component.result && component.result.customElements && component.result.customElements.length) {\n const stack = [component.result.customElements]\n\n while (stack.length > 0) {\n const current = stack.pop()\n\n for (let i = 0; i < current.length; i++) {\n const element = current[i]\n\n if (!childCustomElements[element.name]) {\n childCustomElements[element.name] = name\n const comp = app.components.getItem(element.name)\n\n if (comp && comp.result && comp.result.customElements && comp.result.customElements.length) {\n stack.push(comp.result.customElements)\n }\n }\n }\n }\n }\n }\n\n /** @type {Set<string>} */\n const customElements = pageCustomElements[name]\n customElements.add(data.path.pathname)\n }\n }\n\n const mappedContext = await triggerHook('onPageSet', {\n elements,\n state,\n page,\n data,\n app\n })\n\n const isProduction = app.options.mode === 'production'\n if (isProduction && !data.virtual) {\n delete data.content\n }\n\n return {\n type: 'page',\n value: {\n state: mappedContext.state,\n page: mappedContext.page,\n path: mappedContext.data.path,\n root: isProduction ? null : mappedContext.elements.root,\n customElements: isProduction ? null : mappedContext.elements.customElements,\n tempElements: isProduction ? null : mappedContext.elements.tempElements,\n skipRenderElements: isProduction ? null : mappedContext.elements.skipRenderElements\n },\n state: mappedContext.state\n }\n }\n\n const onPageUpdateLocal = async (newValue, oldValue) => {\n if (app.options.mode === 'production') {\n return newValue.result\n }\n\n let newCustomElements\n\n if (!newValue.result) {\n const res = await onFileSetLocal(newValue); newValue.result = res.value; newCustomElements = res.value.customElements\n } else {\n newCustomElements = newValue.result.customElements\n }\n\n const oldElements = (oldValue.result.customElements || []).slice()\n const mappedContext = await triggerHook('onPageUpdate', {\n elements: newValue.result,\n page: newValue.result.page,\n newValue,\n oldValue,\n app\n })\n\n newValue.result = mappedContext.elements; newValue = mappedContext.newValue\n\n for (let i = 0; i < newCustomElements.length; i++) {\n const name = newCustomElements[i].name\n let hasElement = false\n for (let j = 0; j < oldElements.length; j++) {\n if (name === oldElements[j].name) {\n hasElement = true; oldElements.splice(j, 1); break\n }\n }\n\n if (!hasElement) {\n if (!pageCustomElements[name]) {\n pageCustomElements[name] = new Set()\n // Always track dependencies for ISR\n // @ts-ignore\n app._dependencyGraph.pageCustomElements[name] = pageCustomElements[name]\n }\n /** @type {Set<string>} */\n const customElements = pageCustomElements[name]\n customElements.add(newValue.path.pathname)\n }\n }\n oldElements.forEach(oe => {\n if (pageCustomElements[oe.name]) {\n // Track deletions for ISR\n /** @type {Set<string>} */\n const customElements = pageCustomElements[oe.name]\n customElements.delete(newValue.path.pathname)\n }\n })\n return newValue.result\n }\n\n const onPageDeleteLocal = async (value) => {\n if (app.options.mode === 'production') {\n return\n }\n\n const res = await triggerHook('onPageDelete', {\n data: value,\n app\n })\n\n value = res.data\n if (value?.result?.customElements) {\n value.result.customElements.forEach(ce => {\n const ceName = typeof ce === 'string' ? ce : ce.name\n if (pageCustomElements[ceName]) {\n // Track deletions for ISR\n /** @type {Set<string>} */\n const customElements = pageCustomElements[ceName]\n customElements.delete(value.path.pathname)\n }\n })\n }\n }\n\n const onComponentSetLocal = async (v) => {\n if (v.content === undefined) {\n v.content = await getHtmlFile(v.path.pathname)\n }\n\n const component = parseModule(v.content, {\n ignoreByAttribute: app.options.ignoreByAttribute,\n skipRenderByAttribute: app.options.skipRenderByAttribute,\n onError: handleError\n })\n\n if (!component.isTemplate) {\n return\n }\n\n const res = await triggerHook('onComponentSet', {\n component,\n app\n })\n\n return {\n type: 'component',\n id: res.component.id,\n value: res.component\n }\n }\n\n const onComponentUpdateLocal = async (v) => {\n if (v.content === undefined) {\n v.content = await getHtmlFile(v.path.pathname)\n }\n\n const component = parseModule(v.content, {\n ignoreByAttribute: app.options.ignoreByAttribute,\n skipRenderByAttribute: app.options.skipRenderByAttribute,\n onError: handleError\n })\n\n if (!component.isTemplate) {\n return\n }\n\n const res = await triggerHook('onComponentUpdate', {\n component,\n app\n })\n\n await registerBaseComponent({\n component: res.component,\n evaluate,\n scriptManager,\n createSession,\n mode: app.options.mode\n })\n\n return res.component\n }\n\n const onComponentDeleteLocal = async (v) => {\n await triggerHook('onComponentDelete', {\n component: v,\n app\n })\n }\n\n // Internal helper for reading HTML files\n async function getHtmlFile (pathname) {\n // @ts-ignore\n return app.source.utils.getHtmlFile(pathname)\n }\n\n return {\n onPageSet: onFileSetLocal,\n onPageUpdate: onPageUpdateLocal,\n onPageDelete: onPageDeleteLocal,\n onComponentSet: onComponentSetLocal,\n onComponentUpdate: onComponentUpdateLocal,\n onComponentDelete: onComponentDeleteLocal\n }\n}\n", "import { randomUUID } from 'node:crypto'\nimport { dirname, join } from 'node:path'\nimport { availableParallelism } from 'node:os'\nimport { readFile, writeFile, mkdir, rename } from 'node:fs/promises'\nimport pLimit from 'p-limit'\nimport {\n cleanKeys,\n cloneModuleInstance,\n cloneComponentInstance,\n normalizeObjectFunctions\n} from './utils/core.js'\nimport {\n replaceToken,\n findAndExtractScript,\n findAndExtractProperties,\n astTransformer\n} from './utils/server/server.js'\nimport { getHtmlFile } from './utils/server/html.js'\nimport { parseHTML } from './utils/server/parse.js'\nimport {\n findHeadAndBody,\n injectExternalStyles,\n injectStyles,\n injectReadinessScript,\n injectImportMap,\n removeElements,\n resolvePageQueue\n} from './utils/server/render.js'\nimport { generateClientRuntime } from './utils/client/runtime.js'\nimport { transformCss } from './utils/server/style.js'\nimport { transformNode } from './parser.js'\nimport { CoraliteError } from './utils/errors.js'\nimport { checkFileChange } from './utils/server/manifest.js'\nimport {\n isCoraliteElement,\n isCoraliteCollectionItem\n} from './utils/types.js'\nimport { createCoraliteElement, createCoraliteTextNode, relinkChildren } from './utils/server/dom.js'\n\n/**\n * @import {\n * CoraliteInstance,\n * CoraliteSession,\n * CoraliteBuildResult,\n * CoraliteBuildCallback,\n * CoraliteBuildOptions,\n * CoraliteOnError,\n * CoraliteAnyNode,\n * CoraliteCollectionItem,\n * ComponentElementOptions,\n * HTMLData\n * } from '../types/index.js'\n */\n\n/**\n * @import { InstanceContext } from '../types/script.js'\n * @import { ScriptManager } from './script-manager.js'\n */\n\n/**\n * Factory for the rendering pipeline.\n *\n * @param {Object} dependencies - The dependencies required to create the renderer.\n * @param {CoraliteInstance} dependencies.app - The global Coralite app instance.\n * @param {ScriptManager} dependencies.scriptManager - The script manager for handling client-side scripts.\n * @param {Object} dependencies.source - The framework source utilities and context.\n * @param {Function} dependencies.evaluate - The function used to evaluate component scripts.\n * @param {CoraliteOnError} dependencies.handleError - The callback for handling errors during rendering.\n * @param {Object} dependencies.hooks - The collection of bound plugin hooks.\n * @param {any} dependencies.options - The normalized configuration options for the framework.\n * @param {Function} dependencies.createExecutionError - The factory function for creating detailed execution errors.\n * @returns {Object}\n */\nexport function createRenderer ({\n app,\n scriptManager,\n source,\n evaluate,\n handleError,\n hooks,\n options: normalizedOptions,\n createExecutionError\n}) {\n const renderQueues = new Map()\n const sealedQueues = new Set()\n const outputFiles = {}\n const scriptResultCache = new Map()\n\n /**\n * Creates a new rendering session.\n * @param {string} [buildId] - Unique identifier for the build\n * @returns {CoraliteSession}\n */\n const _createSession = (buildId) => ({\n buildId,\n state: {},\n styles: new Map(),\n componentTags: new Set(),\n instanceCounters: {},\n generateId (prefix) {\n if (this.instanceCounters[prefix] === undefined) {\n this.instanceCounters[prefix] = 0\n }\n return `${prefix}-${this.instanceCounters[prefix]++}`\n },\n scripts: {\n content: {},\n add (id, item) {\n if (!this.content[id]) {\n this.content[id] = {}\n }\n this.content[id][item.id] = item\n }\n },\n source: {\n currentSourceContextId: '',\n contextInstances: {}\n }\n })\n\n const _replaceSlots = async (id, element, module, state, page, root, index, session, noHydration) => {\n const slots = module.slotElements ? module.slotElements[id] : null\n if (!slots) {\n return\n }\n\n const slotChildren = {}\n const slotNames = Object.keys(slots)\n for (let i = 0; i < slotNames.length; i++) {\n slotChildren[slotNames[i]] = []\n }\n\n if (element && element.slots) {\n for (let i = 0; i < element.slots.length; i++) {\n const elementSlotContent = element.slots[i]\n const slotName = elementSlotContent.name\n const slot = slots[slotName]\n if (slot) {\n if (elementSlotContent.node.attribs) {\n delete elementSlotContent.node.attribs.slot\n }\n slotChildren[slotName].push(elementSlotContent.node)\n }\n }\n }\n\n const slotTasks = []\n\n for (let i = 0; i < slotNames.length; i++) {\n const slotName = slotNames[i]\n let slotNodes = slotChildren[slotName]\n const slot = slots[slotName]\n\n if (!slot.element || !slot.element.parent || !slot.element.parent.children) {\n continue\n }\n const emptySlot = slotNodes.filter(node => node.type !== 'text' || (node.data && node.data.trim().length > 0))\n if (!emptySlot.length) {\n slotNodes = slot.element.children || []\n slot.element.children = slotNodes\n relinkChildren(slot.element)\n } else {\n const componentTasks = []\n for (let j = slotNodes.length - 1; j > -1; j--) {\n const node = slotNodes[j]\n if (node.name) {\n const slotComponentItem = app.components.getItem(node.name)\n\n if (slotComponentItem) {\n const slotContextId = session.generateId(node.name)\n const currentProperties = session.state[slotContextId] || {}\n const attribValues = cleanKeys(node.attribs)\n session.state[slotContextId] = typeof node.attribs === 'object'\n ? {\n ...currentProperties,\n ...state,\n ...attribValues\n }\n : Object.assign(currentProperties, state)\n\n const childNoHydration = noHydration || (node.attribs && 'no-hydration' in node.attribs)\n componentTasks.push(createComponentElement({\n id: node.name,\n state: session.state[slotContextId],\n element: node,\n page,\n root,\n contextId: slotContextId,\n index,\n session,\n noHydration: childNoHydration\n }, false).then(componentElement => ({\n componentElement,\n node,\n slotContextId,\n childNoHydration\n })))\n }\n }\n }\n\n slotTasks.push(Promise.all(componentTasks).then(results => {\n for (const { componentElement, node, slotContextId, childNoHydration } of results) {\n if (componentElement) {\n if (childNoHydration) {\n const parent = node.parent\n\n if (parent && Array.isArray(parent.children)) {\n const idx = parent.children.indexOf(node)\n if (idx !== -1) {\n let children = []\n\n if (Array.isArray(componentElement)) {\n children = componentElement\n } else if ('children' in componentElement && Array.isArray(componentElement.children)) {\n children = componentElement.children\n }\n\n parent.children.splice(idx, 1, ...children)\n relinkChildren(parent)\n }\n }\n } else {\n let children = []\n\n if (Array.isArray(componentElement)) {\n children = componentElement\n } else if ('children' in componentElement && Array.isArray(componentElement.children)) {\n children = componentElement.children\n }\n\n node.children = children\n relinkChildren(node)\n\n if (!node.attribs) {\n node.attribs = {}\n }\n\n node.attribs['data-cid'] = slotContextId\n session.componentTags.add(node.name)\n }\n }\n }\n slot.element.children = slotNodes\n relinkChildren(slot.element)\n }))\n }\n }\n await Promise.all(slotTasks)\n }\n\n const _processDependentComponents = async (componentIds, session, page, root, state = {}) => {\n if (!componentIds?.length) {\n return\n }\n for (const id of componentIds) {\n if (scriptManager.sharedFunctions[id]) {\n continue\n }\n const moduleComponent = app.components.getItem(id)\n if (!moduleComponent) {\n continue\n }\n const module = cloneModuleInstance(moduleComponent.result)\n\n let scriptResult = {}\n if (module.script) {\n try {\n scriptResult = await evaluate({\n module,\n state,\n page,\n root,\n contextId: `dependent-${id}`,\n session\n })\n } catch (error) {\n throw createExecutionError(error, module, moduleComponent, page, `dependent-${id}`)\n }\n }\n\n const scriptMeta = scriptResult.__script__ || {}\n const templateAST = moduleComponent.result.template?.children || []\n const templateValues = moduleComponent.result.values || {}\n\n if (module.styles?.length && !moduleComponent.result._processedCss) {\n const rawCss = module.styles.join('\\n')\n const { rootClasses, descendantClasses } = moduleComponent.result\n moduleComponent.result._processedCss = await transformCss(rawCss, rootClasses, descendantClasses, handleError)\n }\n const stylesHTML = moduleComponent.result._processedCss || ''\n\n const scriptObj = {\n content: 'function(){}',\n state: scriptMeta.state || {},\n slots: scriptMeta.slots || {}\n }\n let defaultValues = scriptMeta.defaultValues || {}\n let extractedComponents = []\n\n if (scriptResult.__script__) {\n if (!moduleComponent.result._extractedScript) {\n moduleComponent.result._extractedScript = findAndExtractScript(module.script)\n }\n const extractedScript = moduleComponent.result._extractedScript\n\n if (extractedScript) {\n scriptObj.content = extractedScript.content\n scriptObj.lineOffset = (module.lineOffset || 0) + extractedScript.lineOffset\n extractedComponents = extractedScript.components || []\n }\n\n if (!moduleComponent.result._extractedProperties) {\n moduleComponent.result._extractedProperties = findAndExtractProperties(module.script)\n }\n\n const extractedProperties = moduleComponent.result._extractedProperties\n\n if (extractedProperties) {\n scriptObj.stateContent = extractedProperties.content\n scriptObj.stateLineOffset = (module.lineOffset || 0) + extractedProperties.lineOffset\n }\n }\n\n const declarativeComponents = (module.customElements || []).map(el => el.name)\n const nestedComponents = [...new Set([...declarativeComponents, ...extractedComponents])]\n scriptObj.components = nestedComponents\n\n templateValues?.refs?.forEach(ref => {\n const refKey = `ref_${ref.name}`\n defaultValues[refKey] = ''\n scriptObj.state[refKey] = ''\n })\n\n scriptObj.defaultValues = defaultValues\n\n scriptManager.registerComponent({\n id: module.id,\n getters: scriptMeta.getters,\n script: scriptObj,\n filePath: moduleComponent.path.pathname,\n templateAST,\n templateValues,\n defaultValues,\n styles: stylesHTML,\n slots: scriptObj.slots\n })\n\n if (nestedComponents.length > 0) {\n const inheritedState = { ...state }\n // @ts-ignore\n delete inheritedState.__script__\n await _processDependentComponents(nestedComponents, session, page, root, inheritedState)\n }\n }\n }\n\n /**\n * Creates and initializes a component element from its definition and state.\n *\n * @param {ComponentElementOptions} options - Configuration and context for the component instance.\n * @param {boolean} [head=true] - Whether this component is being processed as a top-level head element.\n * @returns {Promise<CoraliteAnyNode | CoraliteAnyNode[] | void>} The rendered AST node(s) for the component.\n */\n const createComponentElement = async ({ id, state = {}, element, page, root, contextId, index, session, noHydration }, head = true) => {\n if (!session) {\n session = _createSession()\n }\n const moduleComponent = app.components.getItem(id)\n if (!moduleComponent || !moduleComponent.result) {\n return\n }\n\n const componentId = moduleComponent.result.id\n if (!contextId) {\n contextId = session.generateId(componentId)\n }\n\n const instanceId = contextId\n let componentState = { ...state }\n if (head) {\n // @ts-ignore\n if (element && element.attribs) {\n // @ts-ignore\n componentState = Object.assign(componentState, element.attribs)\n }\n componentState = cleanKeys(componentState)\n }\n\n const module = cloneModuleInstance(moduleComponent.result)\n\n if (module.values && module.values.refs) {\n for (let i = 0; i < module.values.refs.length; i++) {\n const ref = module.values.refs[i]\n const uniqueRefValue = `${instanceId}__${ref.name}`\n\n if (ref.element && ref.element.attribs) {\n ref.element.attribs.ref = uniqueRefValue\n }\n\n componentState[`ref_${ref.name}`] = uniqueRefValue\n }\n }\n\n const mappedComponentContext = await hooks.trigger('onBeforeComponentRender', {\n state: componentState,\n componentId: module.id,\n instanceId,\n refs: module.values.refs,\n textNodes: module.values.textNodes,\n attributes: module.values.attributes,\n page,\n element,\n session,\n app\n })\n componentState = mappedComponentContext.state\n const result = module.template\n\n if (module.styles.length) {\n const selector = module.id\n if (!moduleComponent.result._processedCss) {\n const rawCss = module.styles.join('\\n')\n const { rootClasses, descendantClasses } = moduleComponent.result\n moduleComponent.result._processedCss = await transformCss(rawCss, rootClasses, descendantClasses, handleError)\n }\n if (!session.styles.has(selector)) {\n session.styles.set(selector, moduleComponent.result._processedCss)\n }\n for (let i = 0; i < result.children.length; i++) {\n const child = result.children[i]\n if (child.type === 'tag') {\n if (!child.attribs) {\n child.attribs = {}\n }\n child.attribs['data-style-selector'] = selector\n }\n }\n }\n\n if (module.script) {\n let scriptResult = {}\n try {\n const evaluationState = { ...componentState }\n const pluginContext = {\n state: evaluationState,\n page,\n root: element || root,\n module,\n id: contextId,\n session,\n noHydration\n }\n\n await hooks.bind(source.plugins, pluginContext)\n\n scriptResult = await evaluate({\n module,\n element,\n state: evaluationState,\n page,\n root: element || root,\n contextId,\n session,\n noHydration,\n mode: app.options.mode\n })\n } catch (error) {\n throw createExecutionError(error, module, moduleComponent, page, contextId)\n }\n\n if (scriptResult && scriptResult.__script__ != null) {\n if (!moduleComponent.result._extractedScript) {\n moduleComponent.result._extractedScript = findAndExtractScript(module.script)\n }\n const extractedScript = moduleComponent.result._extractedScript\n\n let extractedComponents = []\n if (extractedScript) {\n scriptResult.__script__.lineOffset = (module.lineOffset || 0) + extractedScript.lineOffset\n scriptResult.__script__.content = extractedScript.content\n if (extractedScript.components) {\n extractedComponents = extractedScript.components\n }\n } else {\n scriptResult.__script__.lineOffset = module.lineOffset || 0\n scriptResult.__script__.content = 'function(){}'\n }\n\n const stylesHTML = moduleComponent.result._processedCss || ''\n const templateAST = moduleComponent.result.template.children\n const templateValues = moduleComponent.result.values\n const componentTokens = {}\n\n module.values.attributes.forEach(item => item.tokens.forEach(t => {\n componentTokens[t.name] = true\n }))\n\n module.values.textNodes.forEach(item => item.tokens.forEach(t => {\n componentTokens[t.name] = true\n }))\n\n const componentDefaultValues = scriptResult.__script__.defaultValues || {}\n\n const declarativeComponents = (module.customElements || []).map(el => el.name)\n const mergedComponents = Array.from(new Set([...declarativeComponents, ...extractedComponents]))\n if (scriptResult.__script__) {\n scriptResult.__script__.components = mergedComponents\n }\n\n scriptManager.registerComponent({\n id: module.id,\n getters: scriptResult.__script__.getters,\n script: scriptResult.__script__,\n filePath: moduleComponent.path.pathname,\n templateAST,\n templateValues,\n defaultValues: componentDefaultValues,\n styles: stylesHTML,\n slots: scriptResult.__script__.slots || {}\n })\n\n if (mergedComponents.length > 0) {\n const inheritedState = { ...state }\n // @ts-ignore\n delete inheritedState.__script__\n await _processDependentComponents(mergedComponents, session, page, root, inheritedState)\n }\n\n if (!scriptResult.__script__.state) {\n scriptResult.__script__.state = {}\n }\n if (!noHydration) {\n session.scripts.add(page.file.pathname, {\n id: contextId,\n componentId: module.id,\n page,\n state: scriptResult.__script__.state\n })\n }\n delete scriptResult.__script__\n }\n componentState = Object.assign(componentState, scriptResult)\n }\n\n session.state[contextId] = componentState\n\n module.values.attributes.forEach(item => item.tokens.forEach(token => {\n let value = componentState[token.name]\n if (value == null) {\n value = ''\n }\n replaceToken({\n type: 'attribute',\n node: item.element,\n attribute: item.name,\n content: token.content,\n value\n })\n }))\n\n module.values.textNodes.forEach(item => item.tokens.forEach(token => {\n let value = componentState[token.name]\n if (value == null) {\n value = ''\n }\n replaceToken({\n type: 'textNode',\n node: item.textNode,\n content: token.content,\n value\n })\n }))\n\n const customElements = module.customElements\n customElements.forEach(customElement => {\n if (customElement.children && customElement.children.length && !customElement.slots.length) {\n customElement.children.forEach(node => {\n const slotElement = {\n name: 'default',\n node\n }\n if (isCoraliteElement(node) && node.attribs.slot) {\n slotElement.name = node.attribs.slot\n }\n customElement.slots.push(slotElement)\n })\n }\n })\n\n const createComponentTasks = []\n customElements.forEach(customElement => {\n const parent = customElement.parent\n\n if (parent && 'slots' in parent && Array.isArray(parent.slots)) {\n return\n }\n\n const childContextId = session.generateId(customElement.name)\n const currentProperties = session.state[childContextId] || {}\n\n let childState = { ...state }\n if (typeof customElement.attribs === 'object') {\n const attribValues = cleanKeys(customElement.attribs)\n childState = {\n ...childState,\n ...currentProperties,\n ...attribValues\n }\n } else {\n childState = {\n ...childState,\n ...currentProperties\n }\n }\n\n session.state[childContextId] = childState\n const childNoHydration = noHydration || (customElement.attribs && 'no-hydration' in customElement.attribs)\n\n createComponentTasks.push(createComponentElement({\n id: customElement.name,\n state: childState,\n element: customElement,\n page,\n root,\n contextId: childContextId,\n index,\n session,\n noHydration: childNoHydration\n }, false).then(childComponentElement => ({\n childComponentElement,\n customElement,\n childContextId,\n noHydration: childNoHydration\n })))\n })\n\n const results = await Promise.all(createComponentTasks)\n\n results.forEach(({ childComponentElement, customElement, childContextId, noHydration: childNoHydration }) => {\n if (childComponentElement && typeof childComponentElement === 'object') {\n if (childNoHydration) {\n const parent = customElement.parent\n if (parent && parent.children) {\n const idx = parent.children.indexOf(customElement)\n if (idx !== -1) {\n const children = Array.isArray(childComponentElement) ? childComponentElement : childComponentElement.children\n parent.children.splice(idx, 1, ...children)\n\n relinkChildren(parent)\n }\n }\n } else {\n const children = Array.isArray(childComponentElement) ? childComponentElement : childComponentElement.children\n customElement.children = children\n\n relinkChildren(customElement)\n\n if (!customElement.attribs) {\n customElement.attribs = {}\n }\n\n customElement.attribs['data-cid'] = childContextId\n session.componentTags.add(customElement.name)\n }\n }\n })\n\n await _replaceSlots(id, element, module, componentState, page, root, index, session, noHydration)\n\n if (noHydration) {\n const stack = [...result.children]\n\n while (stack.length > 0) {\n const node = stack.pop()\n if (node.type === 'tag') {\n if (node.name === 'c-token') {\n const parent = node.parent\n if (parent && parent.children) {\n const idx = parent.children.indexOf(node)\n if (idx !== -1) {\n parent.children.splice(idx, 1, ...node.children)\n relinkChildren(parent)\n }\n }\n } else {\n stack.push(...(node.children || []))\n }\n }\n }\n }\n\n const mappedAfterContext = await hooks.trigger('onAfterComponentRender', {\n result,\n state: componentState,\n componentId: module.id,\n instanceId,\n refs: module.values.refs,\n textNodes: module.values.textNodes,\n attributes: module.values.attributes,\n page,\n element,\n session,\n app\n })\n return mappedAfterContext.result\n }\n\n const _processCustomElementsInPage = async (mappedComponent, originalDocument, state, mappedSessionObject, pageContext) => {\n const customElementsList = mappedComponent.customElements || []\n const tasks = []\n\n for (let i = 0; i < customElementsList.length; i++) {\n const customElement = customElementsList[i]\n const contextId = mappedSessionObject.generateId(customElement.name)\n const currentProperties = mappedSessionObject.state[contextId] || {}\n mappedSessionObject.state[contextId] = typeof customElement.attribs === 'object'\n ? {\n ...currentProperties,\n ...state,\n ...mappedComponent.state,\n ...customElement.attribs\n }\n : {\n ...currentProperties,\n ...state,\n ...mappedComponent.state\n }\n\n const noHydration = customElement.attribs && 'no-hydration' in customElement.attribs\n\n tasks.push(createComponentElement({\n id: customElement.name,\n state: mappedSessionObject.state[contextId],\n element: customElement,\n page: pageContext || originalDocument.page,\n root: mappedComponent.root,\n contextId,\n index: i,\n session: mappedSessionObject,\n noHydration\n }).then(componentElement => ({\n componentElement,\n customElement,\n contextId,\n noHydration\n })))\n }\n\n const results = await Promise.all(tasks)\n\n for (const { componentElement, customElement, contextId, noHydration } of results) {\n if (componentElement) {\n if (noHydration) {\n const parent = customElement.parent\n if (parent && parent.children) {\n const elementIndex = parent.children.indexOf(customElement)\n\n if (elementIndex !== -1) {\n let children = componentElement\n\n if ('children' in componentElement && Array.isArray(componentElement.children)) {\n children = componentElement.children\n }\n\n if (Array.isArray(children)) {\n parent.children.splice(elementIndex, 1, ...children)\n\n relinkChildren(parent)\n }\n }\n }\n } else {\n if (Array.isArray(componentElement)) {\n customElement.children = componentElement\n } else if ('children' in componentElement && Array.isArray(componentElement.children)) {\n customElement.children = componentElement.children\n }\n\n relinkChildren(customElement)\n\n if (!customElement.attribs) {\n customElement.attribs = {}\n }\n\n customElement.attribs['data-cid'] = contextId\n mappedSessionObject.componentTags.add(customElement.name)\n }\n }\n }\n }\n\n const _generatePages = async function* (activeQueue, buildId, state = {}) {\n const isProduction = normalizedOptions.mode === 'production'\n\n try {\n for (let q = 0; q < activeQueue.length; q++) {\n const pageItem = activeQueue[q]\n const startTime = performance.now()\n const originalDocument = pageItem.result\n let component\n let pageContext = originalDocument.page\n\n if (!originalDocument.root || pageItem.virtual) {\n let content = pageItem.content\n\n if (content === undefined) {\n try {\n content = await getHtmlFile(pageItem.path.pathname)\n } catch (e) {\n if (pageItem.virtual) {\n // If a virtual page is missing content, it's a critical error\n throw new CoraliteError(`Virtual page missing content: ${pageItem.path.pathname}`, {\n pagePath: pageItem.path.pathname\n })\n }\n content = pageItem.content !== undefined ? pageItem.content : (()=>{\n throw e\n })()\n }\n }\n\n pageItem.content = content\n\n const elements = parseHTML(content, normalizedOptions.ignoreByAttribute, normalizedOptions.skipRenderByAttribute, handleError)\n\n pageContext = {\n ...originalDocument.page,\n meta: { ...(originalDocument.page?.meta || {}) }\n }\n\n const pageState = {\n ...originalDocument.state,\n page: pageContext\n }\n\n const mappedContext = await hooks.trigger('onPageSet', {\n elements,\n state: pageState,\n page: pageContext,\n data: pageItem,\n app\n })\n\n const fullPath = Object.assign({}, mappedContext.data.path, {\n pages: normalizedOptions.path.pages,\n components: normalizedOptions.path.components\n })\n\n component = {\n state: { ...mappedContext.state },\n page: mappedContext.page,\n path: fullPath,\n root: mappedContext.elements.root,\n customElements: mappedContext.elements.customElements,\n tempElements: mappedContext.elements.tempElements,\n skipRenderElements: mappedContext.elements.skipRenderElements,\n ignoreByAttribute: normalizedOptions.ignoreByAttribute || []\n }\n } else {\n component = cloneComponentInstance(originalDocument)\n component.ignoreByAttribute = component.ignoreByAttribute || normalizedOptions.ignoreByAttribute || []\n pageContext = component.page\n }\n\n Object.assign(component.state, state)\n const session = _createSession(buildId)\n session.mode = normalizedOptions.mode\n\n const mappedSession = await hooks.trigger('onBeforePageRender', {\n component,\n state,\n page: pageContext,\n session,\n app\n })\n\n const mappedComponent = mappedSession.component\n const mappedSessionObject = mappedSession.session\n\n state = mappedSession.state\n mappedSessionObject.mode = normalizedOptions.mode\n\n removeElements(mappedComponent.tempElements, false)\n\n await _processCustomElementsInPage(mappedComponent, originalDocument, state, mappedSessionObject, pageContext)\n\n const { head: headElement, body: bodyElement } = findHeadAndBody(mappedComponent.root)\n\n if (normalizedOptions.externalStyles && normalizedOptions.externalStyles.length > 0) {\n injectExternalStyles(mappedComponent.root, headElement, normalizedOptions.externalStyles)\n }\n\n if (mappedSessionObject.styles.size > 0) {\n injectStyles(mappedComponent.root, headElement, mappedSessionObject.styles)\n }\n\n if (mappedSessionObject.componentTags.size > 0) {\n const targetElement = headElement || bodyElement || mappedComponent.root\n const layoutStyleElement = createCoraliteElement({\n type: 'tag',\n name: 'style',\n parent: targetElement,\n attribs: { id: 'coralite-components' },\n children: []\n })\n\n const selectors = Array.from(mappedSessionObject.componentTags)\n\n selectors.push('c-token')\n\n layoutStyleElement.children.push(createCoraliteTextNode({\n type: 'text',\n data: `${selectors.join(', ')} { display: contents; }`,\n parent: layoutStyleElement\n }))\n\n if (targetElement === headElement || targetElement === bodyElement) {\n targetElement.children.push(layoutStyleElement)\n } else {\n targetElement.children.unshift(layoutStyleElement)\n }\n }\n\n if (mappedSessionObject.scripts.content[mappedComponent.path.pathname]) {\n const scripts = mappedSessionObject.scripts.content[mappedComponent.path.pathname]\n const instances = {}\n const componentIds = new Set()\n for (const key in scripts) {\n const script = scripts[key]\n componentIds.add(script.componentId)\n instances[script.id] = {\n instanceId: script.id,\n componentId: script.componentId,\n page: script.page,\n state: script.state\n }\n }\n\n const cacheKey = Array.from(componentIds).sort().join(',')\n let scriptResult\n\n if (scriptResultCache.has(cacheKey)) {\n scriptResult = scriptResultCache.get(cacheKey)\n } else {\n /** @type {Object.<string, InstanceContext>} */\n const normalizedInstances = {}\n\n for (const [id, instance] of Object.entries(instances)) {\n normalizedInstances[id] = {\n ...instance,\n state: normalizeObjectFunctions(instance.state, astTransformer)\n }\n }\n\n scriptResult = await scriptManager.compileAllInstances(normalizedInstances, normalizedOptions.mode)\n scriptResultCache.set(cacheKey, scriptResult)\n Object.assign(outputFiles, scriptResult.outputFiles)\n }\n\n if (!scriptResult.manifest['chunk-shared']) {\n handleError({\n level: 'ERR',\n message: 'MANIFEST MISSING chunk-shared!',\n error: new Error(JSON.stringify(scriptResult.manifest))\n })\n }\n\n injectReadinessScript(mappedComponent.root, headElement, true)\n injectImportMap(mappedComponent.root, headElement, scriptResult.importMap)\n const chunkManifest = { ...scriptResult.manifest }\n delete chunkManifest['chunk-shared']\n const base = normalizedOptions.baseURL.endsWith('/') ? normalizedOptions.baseURL : normalizedOptions.baseURL + '/'\n const scriptContent = generateClientRuntime({\n base,\n sharedChunkPath: scriptResult.manifest['chunk-shared'],\n chunkManifest\n })\n const hydrationData = {}\n\n for (const [id, instance] of Object.entries(instances)) {\n if (instance.state && Object.keys(instance.state).length > 0) {\n hydrationData[id] = normalizeObjectFunctions(instance.state, astTransformer)\n }\n }\n\n const hydrationScriptElement = createCoraliteElement({\n type: 'tag',\n name: 'script',\n parent: bodyElement,\n attribs: {\n id: '__CORALITE_HYDRATION__',\n type: 'application/json'\n },\n children: []\n })\n\n hydrationScriptElement.children.push(createCoraliteTextNode({\n type: 'text',\n data: JSON.stringify(hydrationData),\n parent: hydrationScriptElement\n }))\n\n bodyElement.children.push(hydrationScriptElement)\n const scriptElement = createCoraliteElement({\n type: 'tag',\n name: 'script',\n parent: bodyElement,\n attribs: { type: 'module' },\n children: []\n })\n\n scriptElement.children.push(createCoraliteTextNode({\n type: 'text',\n data: scriptContent,\n parent: scriptElement\n }))\n bodyElement.children.push(scriptElement)\n }\n\n removeElements(mappedComponent.skipRenderElements, true)\n\n if (!mappedSessionObject.scripts.content[mappedComponent.path.pathname]) {\n injectReadinessScript(mappedComponent.root, headElement, false)\n }\n\n const rawHTML = transformNode(mappedComponent.root)\n\n /** @type {CoraliteBuildResult} */\n const result = {\n type: 'page',\n path: mappedComponent.path,\n content: rawHTML,\n duration: performance.now() - startTime,\n session\n }\n\n yield result\n\n if (isProduction) {\n mappedComponent.root = null; mappedComponent.customElements = null; mappedComponent.tempElements = null; mappedComponent.skipRenderElements = null\n delete pageItem.content\n }\n\n session.state = null; session.styles = null; session.scripts = null\n\n if (session.source) {\n session.source.contextInstances = null; session.source = null\n }\n }\n } finally {\n renderQueues.delete(buildId)\n }\n }\n\n /**\n * Adds a page or a collection item to the current render queue.\n *\n * @param {string | CoraliteCollectionItem | { pathname: string, content: string, cacheKey?: string, volatile?: boolean }} value - The ID of the page or the collection item to add.\n * @param {string} buildId - The unique identifier for the current build session.\n * @throws {Error} If the buildId is missing or invalid, or if the page ID is not found.\n * @returns {Promise<void>}\n */\n const addRenderQueue = async (value, buildId) => {\n if (!buildId) {\n throw new CoraliteError('addRenderQueue requires a buildId')\n }\n if (sealedQueues.has(buildId)) {\n console.warn(`[Coralite] Attempted to add to sealed queue for build \"${buildId}\". All virtual pages must be added in onBeforeBuild.`)\n return\n }\n const queue = renderQueues.get(buildId)\n if (!queue) {\n throw new CoraliteError(`addRenderQueue - buildId not found: \"${buildId}\"`)\n }\n\n let item\n if (typeof value === 'string') {\n item = app.pages.getItem(value)\n if (!item) {\n throw new CoraliteError(`addRenderQueue - unexpected page ID: \"${value}\"`)\n }\n } else if (isCoraliteCollectionItem(value)) {\n item = await app.pages.setItem(value)\n } else if (value && typeof value === 'object' && 'pathname' in value) {\n const pathname = value.pathname\n /** @type {HTMLData} */\n const itemData = {\n type: 'page',\n content: value.content,\n virtual: true,\n cacheKey: value.cacheKey,\n volatile: value.volatile,\n path: {\n pathname,\n filename: join(pathname),\n dirname: dirname(pathname)\n }\n }\n\n // Set content again to ensure it's not deleted if it matches collection's onSet/onUpdate criteria\n item = await app.pages.setItem({\n ...itemData,\n content: value.content\n })\n\n // Force properties directly on the item that resolvePageQueue might return\n item.content = value.content\n item.virtual = true\n item.cacheKey = value.cacheKey\n item.volatile = value.volatile\n\n // Also ensure the collection item itself has these\n const collectionItem = app.pages.getItem(pathname)\n if (collectionItem) {\n collectionItem.content = value.content\n collectionItem.virtual = true\n collectionItem.cacheKey = value.cacheKey\n collectionItem.volatile = value.volatile\n }\n }\n\n if (item && !queue.includes(item)) {\n queue.push(item)\n }\n }\n\n /**\n * Compiles and renders specified pages.\n *\n * @param {string | string[] | CoraliteBuildCallback} [pathOrOptions] - The path(s) to build, or a callback if no path is provided.\n * @param {CoraliteBuildOptions | CoraliteBuildCallback} [optionsOrCallback] - Build options or a callback.\n * @param {CoraliteBuildCallback} [callback] - Optional callback executed for each rendered page.\n * @returns {Promise<CoraliteBuildResult[]>} A promise resolving to an array of build results.\n */\n const build = async (pathOrOptions, optionsOrCallback, callback) => {\n const startTime = performance.now()\n const buildId = randomUUID()\n let buildPath = pathOrOptions\n let buildOptions\n let buildCallback = callback\n\n if (typeof pathOrOptions === 'function') {\n buildPath = null\n buildCallback = pathOrOptions\n } else if (typeof optionsOrCallback === 'function') {\n buildCallback = optionsOrCallback\n } else {\n buildOptions = optionsOrCallback\n }\n\n if (!buildOptions) {\n buildOptions = {}\n }\n\n // Phase 1: Discovery & Pre-Render Staging\n if (buildPath) {\n const paths = Array.isArray(buildPath) ? buildPath : [buildPath]\n for (const p of paths) {\n if (typeof p === 'string' && !app.pages.getItem(p)) {\n try {\n await app.pages.setItem(p)\n } catch (_err) {\n }\n }\n }\n }\n\n renderQueues.set(buildId, [])\n\n let mappedBeforeBuild\n try {\n mappedBeforeBuild = await hooks.trigger('onBeforeBuild', {\n app,\n buildId,\n options: buildOptions,\n addRenderQueue: (value) => addRenderQueue(value, buildId)\n })\n } catch (errorHook) {\n const error = new CoraliteError(`Error in onBeforeBuild hook: ${errorHook.message}`, { cause: errorHook })\n handleError({\n level: 'ERR',\n message: error.message,\n error\n })\n throw error\n }\n\n buildOptions = mappedBeforeBuild.options || buildOptions\n\n // @ts-ignore\n const resolvedQueue = resolvePageQueue(app.pages, buildPath)\n const queue = renderQueues.get(buildId)\n\n for (let i = 0; i < resolvedQueue.length; i++) {\n const item = resolvedQueue[i]\n if (!queue.includes(item)) {\n queue.push(item)\n }\n }\n\n // Seal the queue\n sealedQueues.add(buildId)\n\n // Phase 2: ISR & Manifest Invalidation\n const projectRoot = app.options.projectRoot || process.cwd()\n const cacheDir = join(projectRoot, '.coralite')\n const manifestPath = join(cacheDir, 'manifest.json')\n let manifest = {\n physical: {},\n virtual: {},\n dependencies: {}\n }\n\n try {\n const content = await readFile(manifestPath, 'utf8')\n manifest = JSON.parse(content)\n } catch (e) {\n // Manifest missing (cold start) or corrupt, use default\n if (e.code !== 'ENOENT') {\n handleError({\n level: 'WARN',\n message: `Could not parse manifest at ${manifestPath}: ${e.message}. Starting with fresh manifest.`\n })\n }\n }\n\n const pagesToRender = []\n const skippedPages = []\n const newManifest = {\n physical: {},\n virtual: {},\n dependencies: {}\n }\n\n // Check components first for dependency cascading\n const componentChanges = new Map()\n const allComponents = app.components.list\n for (const component of allComponents) {\n const { changed, metadata } = await checkFileChange(component.path.pathname, manifest.physical[component.path.pathname])\n newManifest.physical[component.path.pathname] = metadata\n if (changed) {\n componentChanges.set(component.result.id, true)\n // Force re-parse\n await app.components.updateItem(component.path.pathname)\n }\n }\n\n const pageCustomElements = {\n ...manifest.dependencies,\n ...app._dependencyGraph.pageCustomElements\n }\n\n for (const pageItem of queue) {\n let shouldRebuild = false\n\n // Check if any dependent component changed\n const componentIds = Object.keys(pageCustomElements).filter(id => {\n const pages = pageCustomElements[id]\n if (pages instanceof Set) {\n return pages.has(pageItem.path.pathname)\n }\n return Array.isArray(pages) && pages.includes(pageItem.path.pathname)\n })\n if (componentIds.some(id => componentChanges.get(id))) {\n shouldRebuild = true\n }\n\n if (pageItem.virtual) {\n if (pageItem.volatile || !manifest.virtual || !manifest.virtual[pageItem.path.pathname] || String(manifest.virtual[pageItem.path.pathname].cacheKey) !== String(pageItem.cacheKey) || normalizedOptions.mode === 'development') {\n shouldRebuild = true\n } else {\n shouldRebuild = false\n }\n if (!shouldRebuild) {\n /** @type {CoraliteBuildResult} */\n const skippedResult = {\n type: 'page',\n // @ts-ignore\n path: {\n ...pageItem.path,\n pages: normalizedOptions.path.pages,\n components: normalizedOptions.path.components\n },\n status: 'skipped'\n }\n\n skippedPages.push(skippedResult)\n if (!newManifest.virtual) {\n newManifest.virtual = {}\n }\n\n newManifest.virtual[pageItem.path.pathname] = { cacheKey: pageItem.cacheKey }\n } else {\n pagesToRender.push(pageItem)\n if (!newManifest.virtual) {\n newManifest.virtual = {}\n }\n newManifest.virtual[pageItem.path.pathname] = { cacheKey: pageItem.cacheKey }\n }\n } else {\n const { changed, metadata } = await checkFileChange(pageItem.path.pathname, manifest.physical[pageItem.path.pathname])\n newManifest.physical[pageItem.path.pathname] = metadata\n if (changed || shouldRebuild || normalizedOptions.mode === 'development') {\n pagesToRender.push(pageItem)\n } else {\n /** @type {CoraliteBuildResult} */\n const skippedResult = {\n type: 'page',\n // @ts-ignore\n path: {\n ...pageItem.path,\n pages: normalizedOptions.path.pages,\n components: normalizedOptions.path.components\n },\n status: 'skipped'\n }\n\n skippedPages.push(skippedResult)\n }\n }\n }\n\n // Update dependency graph in manifest\n const { pageCustomElements: livePageCustomElements } = app._dependencyGraph\n\n for (const [id, pages] of Object.entries(livePageCustomElements)) {\n newManifest.dependencies[id] = Array.from(pages)\n }\n\n // Carry over old dependencies if not overwritten\n for (const [id, pages] of Object.entries(manifest.dependencies || {})) {\n if (!newManifest.dependencies[id]) {\n newManifest.dependencies[id] = pages\n }\n }\n\n const signal = buildOptions?.signal\n const maxConcurrent = buildOptions?.maxConcurrent || availableParallelism()\n const variables = buildOptions?.variables\n const limit = pLimit(maxConcurrent)\n const executing = new Set()\n const results = []\n let buildError = null\n\n try {\n // Phase 3: The Render Engine\n for await (const result of _generatePages(pagesToRender, buildId, variables)) {\n if (signal?.aborted) {\n throw signal.reason\n }\n if (executing.size >= limit.concurrency) {\n await Promise.race(executing)\n }\n const task = limit(async () => {\n if (signal?.aborted) {\n throw signal.reason\n }\n // Note: additionalPages from onAfterPageRender are now ignored/warned if added via addRenderQueue\n await hooks.triggerAggregate('onAfterPageRender', {\n result,\n session: result.session,\n app\n })\n\n const items = [result]\n const finalResults = []\n for (const item of items) {\n if (typeof buildCallback === 'function') {\n const transformed = await buildCallback(item)\n if (transformed) {\n finalResults.push(transformed)\n }\n } else {\n finalResults.push(item)\n }\n }\n return finalResults\n })\n executing.add(task)\n task.then((callbackResults) => {\n if (callbackResults?.length) {\n results.push(...callbackResults)\n } executing.delete(task)\n })\n .catch((err) => {\n executing.delete(task); handleError({\n level: 'ERR',\n message: err.message,\n error: err\n })\n })\n }\n await Promise.all(executing)\n\n // Combine with skipped pages\n for (const skipped of skippedPages) {\n if (typeof buildCallback === 'function') {\n const transformed = await buildCallback(skipped)\n if (transformed) {\n results.push(transformed)\n }\n } else {\n results.push(skipped)\n }\n }\n\n // Write updated manifest atomically\n try {\n await mkdir(cacheDir, { recursive: true })\n const tempManifestPath = `${manifestPath}.tmp`\n await writeFile(tempManifestPath, JSON.stringify(newManifest, null, 2))\n await rename(tempManifestPath, manifestPath)\n } catch (e) {\n handleError({\n level: 'WARN',\n message: `Failed to write manifest: ${e.message}`\n })\n }\n\n return results\n } catch (error) {\n await Promise.allSettled(executing)\n if (error.name === 'AbortError') {\n handleError({\n level: 'WARN',\n message: 'Build cancelled by user.'\n })\n }\n buildError = error instanceof Error ? error : new CoraliteError(`Build failed: ${error.message}`, { cause: error })\n throw buildError\n } finally {\n const duration = performance.now() - startTime\n await hooks.trigger('onAfterBuild', {\n results,\n error: buildError,\n duration,\n app\n })\n renderQueues.delete(buildId)\n sealedQueues.delete(buildId)\n app._clearDependencies()\n // Clean up local arrays to help GC\n pagesToRender.length = 0\n skippedPages.length = 0\n }\n }\n\n /**\n * Clears the internal script result cache and output files.\n * This is useful during development to ensure that changes to components\n * are reflected in the generated client-side script bundles.\n */\n const clearCache = () => {\n scriptResultCache.clear()\n for (const key in outputFiles) {\n delete outputFiles[key]\n }\n }\n\n return {\n outputFiles,\n clearCache,\n createSession: _createSession,\n addRenderQueue,\n createComponentElement,\n build\n }\n}\n", "import { createCoraliteElement, createCoraliteTextNode } from './dom.js'\n\n/**\n * @import {\n * CoraliteElement,\n * CoraliteComponentRoot,\n * CoraliteCollectionItem\n * } from '../../../types/index.js'\n */\n\n/**\n * @import CoraliteCollection from '../../collection.js'\n */\n\n/**\n * Finds the <head> and <body> elements within the HTML AST.\n *\n * @param {CoraliteComponentRoot} root - The root of the AST.\n * @returns {{ head: CoraliteElement | null, body: CoraliteElement | CoraliteComponentRoot }}\n */\nexport function findHeadAndBody (root) {\n let head = null\n /** @type {CoraliteElement | CoraliteComponentRoot} */\n let body = root\n\n for (let i = 0; i < root.children.length; i++) {\n const rootNode = root.children[i]\n\n if (rootNode.type === 'tag' && rootNode.name === 'html') {\n for (let j = 0; j < rootNode.children.length; j++) {\n const node = rootNode.children[j]\n\n if (node.type === 'tag' && node.name === 'head') {\n head = node\n }\n if (node.type === 'tag' && node.name === 'body') {\n body = node\n }\n }\n break\n }\n }\n\n return {\n head,\n body\n }\n}\n\n/**\n * Injects external global style link tags into the document head (or root if head is missing).\n *\n * @param {CoraliteComponentRoot} root - The root of the AST.\n * @param {CoraliteElement | null} head - The head element.\n * @param {string[]} styles - Array of style URLs.\n */\nexport function injectExternalStyles (root, head, styles) {\n if (!styles || styles.length === 0) {\n return\n }\n\n const existingLinks = new Set()\n if (head) {\n head.children.forEach(child => {\n if (child.type === 'tag' && child.name === 'link' && child.attribs?.href) {\n existingLinks.add(child.attribs.href)\n }\n })\n }\n\n for (let i = 0; i < styles.length; i++) {\n const styleUrl = styles[i]\n\n if (existingLinks.has(styleUrl)) {\n continue\n }\n\n const linkElement = createCoraliteElement({\n type: 'tag',\n name: 'link',\n parent: head || root,\n attribs: {\n rel: 'stylesheet',\n href: styleUrl\n },\n children: []\n })\n\n if (head) {\n head.children.push(linkElement)\n } else {\n root.children.unshift(linkElement)\n }\n }\n}\n\n/**\n * Injects style tags into the document head (or root if head is missing).\n *\n * @param {CoraliteComponentRoot} root - The root of the AST.\n * @param {CoraliteElement | null} head - The head element.\n * @param {Map<string, string>} styles - Map of style selectors and their CSS content.\n */\nexport function injectStyles (root, head, styles) {\n if (!styles || styles.size === 0) {\n return\n }\n\n let cssContent = ''\n for (const [selector, css] of styles) {\n cssContent += `[data-style-selector=\"${selector}\"] {\\n${css}\\n}\\n`\n }\n\n const styleElement = createCoraliteElement({\n type: 'tag',\n name: 'style',\n parent: head || root,\n attribs: {},\n children: []\n })\n\n styleElement.children.push(createCoraliteTextNode({\n type: 'text',\n data: cssContent,\n parent: styleElement\n }))\n\n if (head) {\n head.children.push(styleElement)\n } else {\n root.children.unshift(styleElement)\n }\n}\n\n/**\n * Injects the readiness script into the document head (or root if head is missing).\n *\n * @param {CoraliteComponentRoot} root - The root of the AST.\n * @param {CoraliteElement | null} head - The head element.\n * @param {boolean} hasScripts - Whether the page has scripts to wait for.\n */\nexport function injectReadinessScript (root, head, hasScripts) {\n const readinessScriptElement = createCoraliteElement({\n type: 'tag',\n name: 'script',\n parent: head || root,\n attribs: {},\n children: []\n })\n\n const data = hasScripts\n ? 'window.__coralite_ready__ = new Promise(resolve => { window.__coralite_resolve_ready__ = resolve; });'\n : 'window.__coralite_ready__ = Promise.resolve(); window.__coralite_resolve_ready__ = () => {};'\n\n readinessScriptElement.children.push(createCoraliteTextNode({\n type: 'text',\n data,\n parent: readinessScriptElement\n }))\n\n if (head) {\n head.children.unshift(readinessScriptElement)\n } else {\n root.children.unshift(readinessScriptElement)\n }\n}\n\n/**\n * Injects an import map into the document head (or root if head is missing).\n *\n * @param {CoraliteComponentRoot} root - The root of the AST.\n * @param {CoraliteElement | null} head - The head element.\n * @param {Object} importMap - The import map object.\n */\nexport function injectImportMap (root, head, importMap) {\n if (!importMap || Object.keys(importMap).length === 0) {\n return\n }\n\n const importMapElement = createCoraliteElement({\n type: 'tag',\n name: 'script',\n parent: head || root,\n attribs: {\n type: 'importmap'\n },\n children: []\n })\n\n importMapElement.children.push(createCoraliteTextNode({\n type: 'text',\n data: JSON.stringify({ imports: importMap }),\n parent: importMapElement\n }))\n\n if (head) {\n head.children.push(importMapElement)\n } else {\n root.children.unshift(importMapElement)\n }\n}\n\n/**\n * Removes temporary and skip-render elements from the AST.\n *\n * @param {CoraliteElement[]} elements - The elements to remove.\n * @param {boolean} [matchInstance=true] - Whether to match by identity (true) or by 'remove' property (false).\n */\nexport function removeElements (elements, matchInstance = true) {\n if (!elements || elements.length === 0) {\n return\n }\n\n if (matchInstance) {\n for (let i = 0; i < elements.length; i++) {\n const element = elements[i]\n if (element.parent && element.parent.children) {\n element.parent.children = element.parent.children.filter(child => child !== element)\n }\n }\n } else {\n // Optimization: collect unique parents and filter children only once per parent\n const parents = new Set()\n for (let i = 0; i < elements.length; i++) {\n if (elements[i].parent) {\n parents.add(elements[i].parent)\n }\n }\n\n for (const parent of parents) {\n if (parent.children) {\n parent.children = parent.children.filter(child => !child._markedForRemoval)\n }\n }\n }\n}\n\n/**\n * Resolves the initial queue of pages to be generated.\n *\n * @param {CoraliteCollection} pagesCollection - The collection of pages.\n * @param {string | string[]} [path] - The path(s) to include.\n * @returns {CoraliteCollectionItem[]}\n */\nexport function resolvePageQueue (pagesCollection, path) {\n let queue = []\n\n if (Array.isArray(path)) {\n const uniquePaths = new Set(path)\n for (const p of uniquePaths) {\n const result = pagesCollection.getListByPath(p) || pagesCollection.getItem(p)\n if (result) {\n if (Array.isArray(result)) {\n queue = queue.concat(result)\n } else {\n queue.push(result)\n }\n }\n }\n } else if (typeof path === 'string') {\n const result = pagesCollection.getListByPath(path) || pagesCollection.getItem(path)\n if (result) {\n if (Array.isArray(result)) {\n queue = queue.concat(result)\n } else {\n queue.push(result)\n }\n }\n } else {\n queue = pagesCollection.list.slice()\n }\n\n return queue\n}\n", "/**\n * @import { InstanceContext } from '../types/index.js'\n */\n\n/**\n * Generates the client-side runtime script for Coralite pages.\n *\n * @param {Object} options - The options used to configure the client-side runtime.\n * @param {string} options.base - The base URL for assets.\n * @param {string} options.sharedChunkPath - The filename of the shared chunk.\n * @param {Object} options.chunkManifest - Manifest mapping component IDs to their chunk filenames.\n * @param {string[]} [options.declarativeTags=[]] - The declarative tags used.\n * @returns {string} The generated JavaScript runtime.\n */\nexport function generateClientRuntime ({\n base,\n sharedChunkPath,\n chunkManifest,\n declarativeTags = []\n}) {\n return `\nimport { getClientContext, getSetups, createCoraliteClass, globalClientHooks } from '${base}assets/js/${sharedChunkPath}';\n\n(async () => {\n if (!window.__coralite_ready__) {\n window.__coralite_ready__ = new Promise(resolve => { window.__coralite_resolve_ready__ = resolve; });\n }\n globalThis.executableScripts = [];\n globalThis.globalAbortController = new AbortController();\n\n const componentManifest = ${JSON.stringify(chunkManifest)};\n const loadCache = {};\n\n const loadComponent = (componentId) => {\n if (!componentManifest[componentId]) return Promise.resolve();\n if (customElements.get(componentId)) return Promise.resolve();\n if (loadCache[componentId]) return loadCache[componentId];\n\n loadCache[componentId] = (async () => {\n const module = await import('${base}assets/js/' + componentManifest[componentId]);\n if (module.default && module.default.componentId) {\n if (!customElements.get(module.default.componentId)) {\n customElements.define(module.default.componentId, createCoraliteClass(module.default, getClientContext, globalClientHooks));\n }\n }\n })();\n return loadCache[componentId];\n };\n\n const declarativeTags = ${JSON.stringify(declarativeTags)};\n const allTags = Object.keys(componentManifest);\n const imperativeTags = allTags.filter(tag => !declarativeTags.includes(tag));\n\n const loadPromises = declarativeTags.map(tagName => loadComponent(tagName));\n await Promise.all(loadPromises);\n\n if (typeof window.__coralite_resolve_ready__ === 'function') {\n window.__coralite_resolve_ready__();\n }\n\n if (imperativeTags.length > 0) {\n const lazyLoad = () => imperativeTags.forEach(tagName => loadComponent(tagName));\n \n if ('requestIdleCallback' in window) {\n requestIdleCallback(lazyLoad, { timeout: 500 });\n } else {\n setTimeout(lazyLoad, 1);\n }\n }\n})();\n`.trim()\n}\n", "import postcss from 'postcss'\nimport selectorParser from 'postcss-selector-parser'\n\n/**\n * @import { CoraliteOnError } from '../../../types/index.js'\n */\n\n/**\n * Transforms CSS to automatically apply `&.` prefix to classes present on the root element.\n * @param {string} css - The CSS content\n * @param {Set<string>} rootClasses - Set of classes found on the root element\n * @param {Set<string>} descendantClasses - Set of classes found on descendant elements\n * @param {CoraliteOnError} [onError] - Error handler\n * @returns {Promise<string>} Transformed CSS\n */\nexport async function transformCss (css, rootClasses, descendantClasses, onError) {\n const processor = postcss([\n {\n postcssPlugin: 'coralite-style-transform',\n Rule (rule) {\n // Only process top-level rules or rules directly inside @media/@supports etc.\n // Ignore rules nested inside other rules (standard CSS nesting behavior)\n if (rule.parent.type === 'rule') {\n return\n }\n\n const transformSelector = selectorParser((root) => {\n // Iterate over a static list to avoid infinite loops with insertions\n const selectors = []\n root.each(selector => {\n selectors.push(selector)\n })\n\n selectors.forEach((selector) => {\n // We only care about Selector nodes\n if (selector.type !== 'selector') {\n return\n }\n\n const firstNode = selector.first\n\n // Skip if empty or already nested\n if (!firstNode) {\n return\n }\n if (firstNode.type === 'nesting') {\n return\n }\n\n // Check if first node is a class\n if (firstNode.type === 'class') {\n const className = firstNode.value\n const isRoot = rootClasses.has(className)\n const isDescendant = descendantClasses.has(className)\n\n if (isRoot) {\n if (isDescendant) {\n // Transform to: &.classname, .classname\n // Clone first (creates the descendant version)\n const descendantSelector = selector.clone()\n\n // Modify the original to be root version (&.classname)\n const nesting = selectorParser.nesting()\n selector.insertBefore(firstNode, nesting)\n\n // Append the descendant selector to the parent Container\n root.insertAfter(selector, descendantSelector)\n } else {\n // Transform to: &.classname\n const nesting = selectorParser.nesting()\n selector.insertBefore(firstNode, nesting)\n }\n }\n }\n })\n })\n\n try {\n // @ts-ignore\n transformSelector.processSync(rule, { updateSelector: true })\n } catch (error) {\n const message = 'Error parsing selector: ' + rule.selector\n if (typeof onError === 'function') {\n onError({\n level: 'ERR',\n message,\n error\n })\n } else {\n console.error(message, error)\n }\n }\n }\n }\n ])\n\n const result = await processor.process(css, { from: undefined })\n return result.css\n}\n", "import { readFile, stat } from 'node:fs/promises'\nimport xxhash from 'xxhash-wasm'\n\n/**\n * @import { XXHashAPI } from 'xxhash-wasm'\n */\n\n/** @type {XXHashAPI['h64Raw'] | undefined} */\nlet hasher\n\n/** @type {Promise<void> | null} */\nlet initPromise = null\n\n/**\n * Initializes the xxHash hasher.\n * This should be called during the application setup phase.\n * @returns {Promise<void>}\n */\nexport async function initHasher () {\n if (hasher) {\n return\n }\n if (initPromise) {\n return initPromise\n }\n\n initPromise = (async () => {\n const { h64Raw } = await xxhash()\n hasher = h64Raw\n initPromise = null\n })()\n\n return initPromise\n}\n\n/**\n * Generates an xxHash64 hash of a string or Buffer.\n * @param {string | Uint8Array} data - The data to hash.\n * @returns {string}\n */\nexport function hash (data) {\n if (!hasher) {\n throw new Error('Hasher not initialized. Call initHasher() first.')\n }\n const uint8Data = typeof data === 'string' ? new TextEncoder().encode(data) : data\n const hashBigInt = hasher(uint8Data)\n return hashBigInt.toString(16).padStart(16, '0')\n}\n\n/**\n * Generates a hash of a file's content.\n * @param {string} filepath - The path to the file.\n * @returns {Promise<string>}\n */\nexport async function hashFile (filepath) {\n const content = await readFile(filepath)\n return hash(content)\n}\n\n/**\n * Performs a two-tier check on a file to see if it has changed.\n * Tier 1: mtime and size.\n * Tier 2: Hash (xxHash64).\n *\n * @param {string} filepath - The path to the file.\n * @param {Object} previousMetadata - The previous metadata.\n * @returns {Promise<{ changed: boolean, metadata: Object }>}\n */\nexport async function checkFileChange (filepath, previousMetadata = {}) {\n const stats = await stat(filepath)\n const mtime = stats.mtimeMs\n const size = stats.size\n\n if (previousMetadata.mtime === mtime && previousMetadata.size === size) {\n return {\n changed: false,\n metadata: previousMetadata\n }\n }\n\n const hash = await hashFile(filepath)\n const metadata = {\n mtime,\n size,\n hash\n }\n\n if (previousMetadata.hash === hash) {\n // mtime changed but hash is same, still return changed: false to optimize\n // but update metadata for next time (to keep mtime/size in sync)\n return {\n changed: false,\n metadata\n }\n }\n\n return {\n changed: true,\n metadata\n }\n}\n", "/**\n * @import {CoraliteConfig} from '../types/index.js'\n */\nimport { CoraliteError } from './utils/errors.js'\n\n/**\n * Validates and defines a Coralite configuration object\n * @param {CoraliteConfig} options - The configuration options to validate and define\n * @returns {CoraliteConfig} The validated configuration object\n * @throws {Error} If the configuration is invalid\n */\nexport function defineConfig (options) {\n // Validate that options is an object\n if (!options || typeof options !== 'object') {\n throw new CoraliteError('Config must be an object')\n }\n\n // Validate required string state\n const requiredProps = ['output', 'components', 'pages']\n\n for (const prop of requiredProps) {\n // Check if property exists\n if (!(prop in options)) {\n throw new CoraliteError(`Missing required config property: \"${prop}\"`)\n }\n\n // Check if property is a string\n if (typeof options[prop] !== 'string') {\n throw new CoraliteError(\n `Config property \"${prop}\" must be a string, received ${typeof options[prop]}`\n )\n }\n\n // Check if property is not empty\n if (options[prop].trim() === '') {\n throw new CoraliteError(`Config property \"${prop}\" cannot be empty`)\n }\n }\n\n // Validate optional plugins property\n if ('plugins' in options && options.plugins !== undefined) {\n if (!Array.isArray(options.plugins)) {\n throw new CoraliteError(\n `Config property \"plugins\" must be an array, received ${typeof options.plugins}`\n )\n }\n\n // Validate each plugin in the array\n options.plugins.forEach((plugin, index) => {\n if (typeof plugin !== 'object' || plugin === null) {\n throw new CoraliteError(\n `Plugin at index ${index} must be an object, received ${typeof plugin}`\n )\n }\n\n if (typeof plugin.name !== 'string' || plugin.name.trim() === '') {\n throw new CoraliteError(\n `Plugin at index ${index} must have a valid \"name\" property (non-empty string)`\n )\n }\n })\n }\n\n return options\n}\n", "import { createCoralite } from './coralite.js'\n\nexport * from '../types/index.js'\nexport * from './utils/index.js'\nexport * from './utils/server/index.js'\nexport * from './plugin.js'\nexport * from './config.js'\n\n/** @typedef {import('../types/core.js').CoraliteInstance} Coralite */\n\nexport { createCoralite }\nexport default createCoralite\n"],
5
+ "mappings": ";AAAA,SAAS,SAAS,SAAS,YAAY;AACvC,SAAS,SAAS,gBAAgB;AAClC,SAAS,oBAAoB;AAC7B,SAAS,4BAA4B;AACrC,OAAO,YAAY;;;ACJnB,OAAO,UAAU;;;ACQV,IAAM,gBAAN,cAA4B,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAavC,YAAa,SAAS,UAAU,CAAC,GAAG;AAClC,UAAM,SAAS,OAAO;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,MACF;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AACT;;;ACrDA,IAAO,gBAAQ;",
6
+ "names": ["dirname", "path", "parseJS", "walkJS", "transform", "path", "target", "dirname", "render", "parseJS", "walkJS", "dirname", "path", "dirname", "dirname", "join", "parse", "existsSync", "require", "mkdir", "writeFile", "dirname", "join", "relative", "parseJS", "parseJS", "render", "render", "pathToFileURL", "resolve", "createRequire", "path", "pathToFileURL", "resolve", "bindPlugins", "defineComponent", "createExecutionError", "createRequire", "evaluate", "dirname", "join", "relative", "pathToFileURL", "handleError", "evaluate", "pathToFileURL", "join", "relative", "dirname", "i", "getHtmlFile", "dirname", "join", "availableParallelism", "readFile", "mkdir", "pLimit", "path", "readFile", "stat", "hash", "evaluate", "handleError", "createExecutionError", "join", "dirname", "build", "readFile", "availableParallelism", "pLimit", "mkdir", "path", "relative", "join", "mkdir", "writeFile", "dirname"]
7
7
  }