coralite 0.36.0 → 0.36.1
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.
- package/dist/lib/coralite-element.d.ts.map +1 -1
- package/dist/lib/coralite-element.js +3 -11
- package/dist/lib/coralite-element.js.map +2 -2
- package/dist/lib/coralite.d.ts +3 -4
- package/dist/lib/coralite.d.ts.map +1 -1
- package/dist/lib/coralite.js +2 -2
- package/dist/lib/coralite.js.map +2 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coralite-element.d.ts","sourceRoot":"","sources":["../../lib/coralite-element.js"],"names":[],"mappings":"AAsCA;;;;;;GAMG;AACH,8BAJW,GAAG,QACH,WAAS,MAAM,GACb,GAAG,CAmBf;AAED;;;;;GAKG;AACH,gGAwBC;
|
|
1
|
+
{"version":3,"file":"coralite-element.d.ts","sourceRoot":"","sources":["../../lib/coralite-element.js"],"names":[],"mappings":"AAsCA;;;;;;GAMG;AACH,8BAJW,GAAG,QACH,WAAS,MAAM,GACb,GAAG,CAmBf;AAED;;;;;GAKG;AACH,gGAwBC;AA2kBD;;;;;;;;;;GAUG;AACH,6CARW,wBAAwB,kBACxB,WAAS,IAAI,UAErB;IAAyE,uBAAuB,GAAxF,KAAK,CAAC,iDAAiD,CAAC;IACQ,sBAAsB,GAAtF,KAAK,CAAC,gDAAgD,CAAC;IACC,cAAc,GAAtE,KAAK,CAAC,wCAAwC,CAAC;CACvD,GAAU,OAAO,eAAe,CA8BlC;AA/mBD;;;;;;;;;;GAUG;AAEH;;;;;;GAMG;AACH;IAOI;;;;OAIG;IACH,4BAHU,eAAe,GAAC,IAAI,CAGF;IAE5B;;;;OAIG;IACH,uBAHU,MAAM,GAAC,IAAI,CAGE;IAEvB;;;;OAIG;IACH,kBAHU,MAAO,IAAI,CAGH;IAElB;;;;OAIG;IACH,qBAHU,KAAK,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EA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
const node = this.getNodeByPath(item.path);
|
|
292
292
|
if (node) {
|
|
293
293
|
this._bindings.push({
|
|
294
|
-
type: "text",
|
|
294
|
+
type: item.type || "text",
|
|
295
295
|
node,
|
|
296
296
|
template: item.template
|
|
297
297
|
});
|
|
@@ -371,11 +371,7 @@ class CoraliteElement extends HTMLElement {
|
|
|
371
371
|
} else if (binding.type === "html") {
|
|
372
372
|
const element = binding.node;
|
|
373
373
|
if (element.innerHTML !== hydratedValue) {
|
|
374
|
-
|
|
375
|
-
element.setHTML(hydratedValue);
|
|
376
|
-
} else {
|
|
377
|
-
element.innerHTML = hydratedValue;
|
|
378
|
-
}
|
|
374
|
+
element.innerHTML = hydratedValue;
|
|
379
375
|
}
|
|
380
376
|
} else if (binding.type === "attribute") {
|
|
381
377
|
const element = binding.node;
|
|
@@ -442,11 +438,7 @@ class CoraliteElement extends HTMLElement {
|
|
|
442
438
|
}
|
|
443
439
|
const result = slotFn(slotEl._originalNodes, this._state);
|
|
444
440
|
if (typeof result === "string") {
|
|
445
|
-
|
|
446
|
-
slotEl.setHTMLUnsafe(result);
|
|
447
|
-
} else {
|
|
448
|
-
slotEl.innerHTML = result;
|
|
449
|
-
}
|
|
441
|
+
slotEl.innerHTML = result;
|
|
450
442
|
} else if (Array.isArray(result)) {
|
|
451
443
|
slotEl.replaceChildren(...result);
|
|
452
444
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../lib/coralite-element.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * @import { CoraliteComponent } from '../types/index.js'\n * @import {\n * CoraliteClientPluginDisconnectedCallback,\n * CoraliteClientPluginAfterComponentRenderCallback,\n * CoraliteClientPluginBeforeComponentRenderCallback\n * } from '../types/plugin.js'\n */\n\nconst 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\n/**\n * Coerces a value to a specified type.\n * Supports Number, Boolean, and String.\n * @param {any} value - The value to coerce.\n * @param {Function|string} type - The target type (Constructor or string name).\n * @returns {any} The coerced value.\n */\nexport function coerce (value, type) {\n if (value === null || value === undefined) {\n return value\n }\n if (type === Number || type === 'Number') {\n return Number(value)\n }\n if (type === Boolean || type === 'Boolean') {\n if (value === '') {\n return true\n }\n return value !== 'false' && value !== null\n }\n if (type === String || type === 'String') {\n return String(value)\n }\n return value\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 Error('Coralite Error: Cannot mutate state inside a getter. State is read-only here.')\n },\n deleteProperty () {\n throw new Error('Coralite Error: Cannot delete state inside a getter. State is read-only here.')\n }\n }\n\n const proxy = new Proxy(target, handler)\n proxies.set(target, proxy)\n return proxy\n}\n\n\n/**\n * @typedef {Object} CoraliteComponentOptions\n * @property {string} componentId - The unique identifier for the component.\n * @property {string} [templateHTML] - The raw HTML string for imperative mounting.\n * @property {Object} [defaultValues] - The initial state values extracted from the server data block.\n * @property {Object} [attributes] - Schema for coercing HTML attributes into typed primitives.\n * @property {Object.<string, Function>} [getters] - Pure functions for derived state, supporting Promises.\n * @property {Object.<string, Function>} [slots] - Transformation functions for projected Light DOM.\n * @property {Function} [script] - The client-side controller logic.\n * @property {Object} [hydrationMap] - AST mapping for reactive text nodes, attributes, and refs.\n */\n\n/**\n * Base class for all Coralite custom elements.\n * * This class acts as the client-side runtime engine. It manages DOM hydration,\n * native Web Component lifecycles, batched reactive state management (via Proxies),\n * asynchronous getter race-condition locks, and isomorphic plugin hooks.\n * * @augments HTMLElement\n */\nexport class CoraliteElement extends HTMLElement {\n /**\n * Initializes a new instance of the CoraliteElement.\n * Sets up internal state trackers, binding collections, and hook registries.\n */\n constructor () {\n super()\n /**\n * Controls native teardown of event listeners and async fetches upon disconnection.\n * @type {AbortController|null}\n * @protected\n */\n this._abortController = null\n\n /**\n * A globally unique, deterministic identifier (e.g., `my-comp-0`).\n * @type {string|null}\n * @protected\n */\n this._instanceId = null\n\n /**\n * The unified, deeply reactive proxy holding attributes, data, and getters.\n * @type {Object|null}\n * @protected\n */\n this._state = null\n\n /**\n * The collection of DOM nodes mapped to template tokens and attributes.\n * @type {Array<{type: string, node: Node, template?: string, name?: string}>}\n * @protected\n */\n this._bindings = []\n\n /**\n * Flag to prevent multiple synchronous state mutations from triggering multiple DOM paints.\n * @type {boolean}\n * @protected\n */\n this._isUpdatePending = false\n\n /**\n * A unique Symbol generated per render cycle to prevent async getter race conditions.\n * @type {symbol|null}\n * @protected\n */\n this._currentRenderVersion = null\n\n /**\n * @type {MutationObserver|null}\n * @protected\n */\n this._observer = null\n\n /**\n * Hook to fetch globally registered Phase-2 plugin contexts.\n * @type {Function|null}\n * @protected\n */\n this._clientContextGetter = null\n\n /**\n * Tracks AbortControllers specifically for cancelling stale async getters.\n * @type {Object.<string, AbortController>|null}\n * @protected\n */\n this._getterAbortControllers = null\n\n /**\n * Internal lifecycle hooks injected by registered Coralite plugins.\n * @type {{\n * onBeforeComponentRender: Array<CoraliteClientPluginBeforeComponentRenderCallback>,\n * onAfterComponentRender: Array<CoraliteClientPluginAfterComponentRenderCallback>,\n * onDisconnected: Array<CoraliteClientPluginDisconnectedCallback>\n * }}\n * @protected\n */\n this._hooks = {\n onBeforeComponentRender: [],\n onAfterComponentRender: [],\n onDisconnected: []\n }\n\n /**\n * The definition and schema of the component generated by the compiler.\n * @type {CoraliteComponentOptions|null}\n */\n this.componentOptions = null\n }\n\n /**\n * Invoked natively when the element is added to the document.\n * Handles the architectural split between Declarative (SSR) and Imperative (JS) components.\n * Orchestrates template injection, instance ID generation, and state/binding setup.\n */\n connectedCallback () {\n this._abortController = new AbortController()\n\n if (!this.componentOptions) {\n return\n }\n\n // Declarative components receive a data-cid from the server.\n // Imperative components (created via document.createElement) do not.\n const isImperative = !this.hasAttribute('data-cid')\n\n // Imperative Flow: Manually stamp the template and project the Light DOM.\n if (isImperative && this.componentOptions.templateHTML) {\n const originalLightDOM = Array.from(this.childNodes)\n this.innerHTML = this.componentOptions.templateHTML\n\n if (originalLightDOM.length > 0) {\n const slots = this.querySelectorAll('slot')\n slots.forEach(slot => {\n const slotName = slot.getAttribute('name') || 'default'\n const matchingNodes = originalLightDOM.filter(node => {\n // @ts-ignore\n const nodeSlot = (node.getAttribute && node.getAttribute('slot')) || 'default'\n return nodeSlot === slotName\n })\n matchingNodes.forEach(n => slot.appendChild(n))\n })\n }\n }\n\n // Establish the Deterministic Instance ID\n if (this.hasAttribute('data-cid')) {\n this._instanceId = this.getAttribute('data-cid')\n } else {\n // Fallback counter for imperatively created components\n // @ts-ignore\n window.__coralite_instanceCounters = window.__coralite_instanceCounters || {}\n const prefix = this.componentOptions.componentId\n // @ts-ignore\n if (window.__coralite_instanceCounters[prefix] === undefined) {\n // @ts-ignore\n window.__coralite_instanceCounters[prefix] = 0\n }\n // @ts-ignore\n this._instanceId = `${prefix}-${window.__coralite_instanceCounters[prefix]++}`\n }\n\n if (isImperative) {\n this.setAttribute('data-cid', this._instanceId)\n }\n\n this._setupState()\n this._setupBindings()\n this._init(isImperative)\n }\n\n /**\n * Invoked natively when the element is removed from the document.\n * Aborts pending requests and triggers `onDisconnected` plugin hooks\n * to ensure external libraries (e.g., Observers) do not cause memory leaks.\n */\n disconnectedCallback () {\n if (this._abortController) {\n this._abortController.abort()\n }\n\n if (!this.componentOptions) {\n return\n }\n\n for (const hook of this._hooks.onDisconnected) {\n hook({\n state: this._state,\n instanceId: this._instanceId,\n componentId: this.componentOptions.componentId,\n element: this,\n options: this.componentOptions\n })\n }\n }\n\n /**\n * Invoked natively when an observed HTML attribute changes.\n * Coerces the raw string value based on the component's attribute schema\n * and synchronizes it into the reactive state proxy.\n * @param {string} name - The kebab-case name of the attribute.\n * @param {string|null} oldVal - The previous value.\n * @param {string|null} newVal - The new value.\n */\n attributeChangedCallback (name, oldVal, newVal) {\n if (!this._state || oldVal === newVal || name === 'data-cid') {\n return\n }\n const camelName = name.replace(/-([a-z])/g, (g) => g[1].toUpperCase())\n const schema = this.componentOptions.attributes?.[camelName] || this.componentOptions.attributes?.[name]\n const value = schema ? coerce(newVal, schema.type) : newVal\n\n this._state[camelName] = value\n }\n\n /**\n * Constructs the unified state object.\n * Merges `defaultValues`, JSON hydration payloads, and DOM attributes.\n * Defines getters (wrapping state in a Read-Only proxy) and applies the final Read/Write Proxy.\n * @private\n */\n _setupState () {\n const options = this.componentOptions\n const target = { ...options.defaultValues }\n\n /** @type {Array<{name: string, element: HTMLElement}>} */\n const refs = []\n if (options.hydrationMap && options.hydrationMap.refs) {\n for (const item of options.hydrationMap.refs) {\n /** @type {HTMLElement} */\n // @ts-ignore\n const node = this.getNodeByPath(item.path)\n if (node) {\n refs.push({\n name: item.name,\n element: node\n })\n }\n }\n }\n\n // Trigger Before-Render hooks BEFORE state is proxied, allowing plugins to inject reactive data\n for (const hook of this._hooks.onBeforeComponentRender) {\n hook({\n state: target,\n instanceId: this._instanceId,\n componentId: this.componentOptions.componentId,\n refs,\n element: this,\n options: this.componentOptions\n })\n }\n\n // Hydrate data() block results from the SSR JSON payload\n const hydrationTag = document.getElementById('__CORALITE_HYDRATION__')\n if (hydrationTag) {\n try {\n const allData = JSON.parse(hydrationTag.textContent)\n if (allData[this._instanceId]) {\n Object.assign(target, allData[this._instanceId])\n }\n } catch (e) {\n console.error('Coralite Element hydration failed:', this._instanceId)\n }\n }\n\n // Process initial attributes mapping\n for (const attr of this.attributes) {\n if (attr.name === 'data-cid') {\n continue\n }\n const camelName = attr.name.replace(/-([a-z])/g, (g) => g[1].toUpperCase())\n const schema = options.attributes?.[camelName] || options.attributes?.[attr.name]\n target[camelName] = schema ? coerce(attr.value, schema.type) : attr.value\n }\n\n // Define derived state getters with isolation controllers\n this._getterAbortControllers = {}\n for (const [key, getter] of Object.entries(options.getters || {})) {\n Object.defineProperty(target, key, {\n get: () => {\n if (this._getterAbortControllers[key]) {\n this._getterAbortControllers[key].abort()\n }\n this._getterAbortControllers[key] = new AbortController()\n\n // Enforce \"Dual-Proxy\" safety: Getters cannot mutate state\n const roState = createReadOnlyProxy(this._state)\n return getter(roState, { signal: this._getterAbortControllers[key].signal })\n },\n enumerable: true,\n configurable: true\n })\n }\n\n this._state = this._createReactiveProxy(target)\n }\n\n /**\n * Wraps the state target in a reactive Proxy.\n * Intercepts property setters to automatically batch and schedule DOM updates.\n * @param {Object} target - The state dictionary.\n * @returns {Proxy} The reactive state proxy.\n * @private\n */\n _createReactiveProxy (target) {\n const self = this\n return new Proxy(target, {\n set (t, p, v) {\n if (t[p] === v) {\n return true\n }\n t[p] = v\n self._scheduleUpdate()\n return true\n }\n })\n }\n\n /**\n * Traverses the DOM tree using an AST-generated path index array.\n * Allows O(1) element lookups without relying on querySelectors or classes.\n * @param {number[]} path - Array of childNode indices (e.g., `[0, 1, 2]`).\n * @returns {Node|null} The physical DOM node, or null if traversal fails.\n */\n getNodeByPath (path) {\n let node = this\n for (const index of path) {\n if (!node) {\n return null\n }\n // @ts-ignore\n node = node.childNodes[index]\n }\n return node\n }\n\n /**\n * Initializes DOM bindings based on the compiler's hydration map.\n * Caches physical DOM references to text nodes and attributes that contain template tokens.\n * @private\n */\n _setupBindings () {\n this._bindings = []\n const map = this.componentOptions.hydrationMap\n if (!map) {\n return\n }\n\n if (map.texts) {\n for (const item of map.texts) {\n const node = this.getNodeByPath(item.path)\n if (node) {\n this._bindings.push({\n type: 'text',\n node,\n template: item.template\n })\n }\n }\n }\n\n if (map.attributes) {\n for (const item of map.attributes) {\n const node = this.getNodeByPath(item.path)\n if (node) {\n this._bindings.push({\n type: 'attribute',\n node,\n name: item.name,\n template: item.template\n })\n }\n }\n }\n }\n\n /**\n * Schedules a DOM update in the next microtask queue.\n * This guarantees that multiple synchronous state mutations result in only one render pass.\n * @private\n */\n _scheduleUpdate () {\n if (this._isUpdatePending) {\n return\n }\n this._isUpdatePending = true\n queueMicrotask(() => {\n this._updateDOM()\n this._isUpdatePending = false\n })\n }\n\n /**\n * Performs the physical DOM update and resolves template tokens.\n * **Async Safety:** Implements a Symbol-based locking mechanism (`renderVersion`)\n * to guarantee that if state mutates while an async getter is pending, the stale\n * Promise will be discarded, preventing DOM race conditions.\n * @private\n */\n _updateDOM () {\n // Create a unique lock for this specific render cycle\n const renderVersion = Symbol()\n this._currentRenderVersion = renderVersion\n\n // Extract unique tokens to prevent double-reading and accidental aborts\n /** @type {Set<string>} */\n const requiredTokens = new Set()\n for (const binding of this._bindings) {\n binding.template.replace(/\\{\\{\\s*(.+?)\\s*\\}\\}/g, (_, key) => {\n requiredTokens.add(key)\n return ''\n })\n }\n\n const evaluatedTokens = {}\n let hasPromise = false\n\n // Evaluate getters exactly once per render cycle\n for (const key of requiredTokens) {\n let val = this._state[key]\n if (typeof val === 'function') {\n val = val(this._state)\n }\n evaluatedTokens[key] = val\n if (val instanceof Promise) {\n hasPromise = true\n }\n }\n\n // The DOM Mutator Function\n const applyBindings = (tokenValues) => {\n // Race Condition Lock: Abort if a newer render cycle has already begun\n if (this._currentRenderVersion !== renderVersion) {\n return\n }\n\n for (const binding of this._bindings) {\n const hydratedValue = binding.template.replace(/\\{\\{\\s*(.+?)\\s*\\}\\}/g, (_, key) => {\n return tokenValues[key] ?? ''\n })\n\n if (binding.type === 'text') {\n if (binding.node.textContent !== hydratedValue) {\n binding.node.textContent = hydratedValue\n }\n } else if (binding.type === 'html') {\n /** @type {HTMLElement} */\n // @ts-ignore\n const element = binding.node\n\n if (element.innerHTML !== hydratedValue) {\n // @ts-ignore\n if (element.setHTML) {\n // @ts-ignore\n element.setHTML(hydratedValue)\n } else {\n element.innerHTML = hydratedValue\n }\n }\n } else if (binding.type === 'attribute') {\n /** @type {HTMLElement} */\n // @ts-ignore\n const element = binding.node\n\n if (BOOLEAN_ATTRIBUTES.has(binding.name)) {\n const isFalsy = hydratedValue === '' || hydratedValue === 'false' || hydratedValue === 'null' || hydratedValue === '0' || hydratedValue === 'undefined'\n if (isFalsy) {\n element.removeAttribute(binding.name)\n } else {\n element.setAttribute(binding.name, '')\n }\n } else {\n if (element.getAttribute(binding.name) !== hydratedValue) {\n element.setAttribute(binding.name, hydratedValue)\n }\n }\n }\n }\n\n this._processSlots()\n\n // Trigger After-Render hooks ONLY after the physical DOM is stable\n for (const hook of this._hooks.onAfterComponentRender) {\n hook({\n state: this._state,\n instanceId: this._instanceId,\n componentId: this.componentOptions.componentId,\n element: this,\n options: this.componentOptions\n })\n }\n }\n\n // 5. Await Promises or Apply Synchronously\n if (hasPromise) {\n const keys = Object.keys(evaluatedTokens)\n const promises = keys.map(k => Promise.resolve(evaluatedTokens[k]))\n\n Promise.all(promises).then(resolvedValues => {\n const resolvedMap = {}\n keys.forEach((k, i) => {\n resolvedMap[k] = resolvedValues[i]\n })\n applyBindings(resolvedMap)\n }).catch(e => {\n if (e.name !== 'AbortError') {\n console.error('Coralite Async Getter Error:', e)\n }\n })\n } else {\n applyBindings(evaluatedTokens)\n }\n }\n\n /**\n * Evaluates and projects Light DOM elements into their respective `<slot>` nodes.\n * Invokes component-specific slot transformation functions.\n * @private\n */\n _processSlots () {\n const slots = this.componentOptions.slots\n if (!slots || Object.keys(slots).length === 0) {\n return\n }\n\n const slotElements = this.querySelectorAll('slot')\n slotElements.forEach(slotEl => {\n const slotName = slotEl.getAttribute('name') || 'default'\n const slotFn = slots[slotName]\n\n if (slotFn) {\n // @ts-ignore\n if (!slotEl._originalNodes) {\n // @ts-ignore\n slotEl._originalNodes = Array.from(slotEl.childNodes).map(n => n.cloneNode(true))\n }\n\n // @ts-ignore\n const result = slotFn(slotEl._originalNodes, this._state)\n\n if (typeof result === 'string') {\n if (slotEl.setHTMLUnsafe) {\n slotEl.setHTMLUnsafe(result)\n } else {\n slotEl.innerHTML = result\n }\n } else if (Array.isArray(result)) {\n slotEl.replaceChildren(...result)\n }\n }\n })\n }\n\n /**\n * The final initialization pipeline.\n * Injects globally registered client plugins into the local context payload,\n * triggers the initial DOM render, and invokes the user's `script()` logic.\n * @param {boolean} [isImperative=false] - If true, initial render runs synchronously.\n * @private\n */\n async _init (isImperative = false) {\n /**\n * The context payload injected into the user's script block.\n * @type {Object}\n */\n const localContext = {\n instanceId: this._instanceId,\n state: this._state,\n root: this,\n signal: this._abortController.signal\n }\n\n if (typeof this._clientContextGetter === 'function') {\n const pluginContext = await this._clientContextGetter(localContext)\n Object.assign(localContext, pluginContext)\n }\n\n if (isImperative) {\n this._updateDOM()\n } else {\n this._scheduleUpdate()\n }\n\n if (this.componentOptions.script) {\n try {\n this.componentOptions.script(localContext)\n } catch (error) {\n console.error(`Coralite Error: Component \"${this.componentOptions.componentId}\" script failed:`, error)\n }\n }\n }\n}\n\n/**\n * Factory function to create a Coralite element class.\n * It dynamically defines the class, including observed attributes and hook initialization.\n * @param {CoraliteComponentOptions} options - Component options and metadata.\n * @param {Function|null} [contextGetter=null] - Optional function to retrieve client-side plugin context.\n * @param {Object} [hooks={}] - Lifecycle hooks to register.\n * @param {Array<CoraliteClientPluginBeforeComponentRenderCallback>} [hooks.onBeforeComponentRender] - Hooks to run before render.\n * @param {Array<CoraliteClientPluginAfterComponentRenderCallback>} [hooks.onAfterComponentRender] - Hooks to run after render.\n * @param {Array<CoraliteClientPluginDisconnectedCallback>} [hooks.onDisconnected] - Hooks to run after render.\n * @returns {typeof CoraliteElement} A new CoraliteElement subclass.\n */\nexport function createCoraliteClass (options, contextGetter = null, hooks = {}) {\n return class extends CoraliteElement {\n /**\n * The attributes to observe for changes.\n * @returns {string[]} Array of attribute names.\n */\n static get observedAttributes () {\n if (!options.attributes) {\n return []\n }\n return Object.keys(options.attributes).map(key => key.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()\n )\n }\n\n /**\n * Initializes the dynamic Coralite element.\n */\n constructor () {\n super()\n this.componentOptions = options\n this._clientContextGetter = contextGetter\n this._hooks = {\n onBeforeComponentRender: hooks.onBeforeComponentRender || [],\n onAfterComponentRender: hooks.onAfterComponentRender || [],\n onDisconnected: hooks.onDisconnected || []\n }\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "AASA,MAAM,qBAAqB,oBAAI,IAAI;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AASM,SAAS,OAAQ,OAAO,MAAM;AACnC,MAAI,UAAU,QAAQ,UAAU,QAAW;AACzC,WAAO;AAAA,EACT;AACA,MAAI,SAAS,UAAU,SAAS,UAAU;AACxC,WAAO,OAAO,KAAK;AAAA,EACrB;AACA,MAAI,SAAS,WAAW,SAAS,WAAW;AAC1C,QAAI,UAAU,IAAI;AAChB,aAAO;AAAA,IACT;AACA,WAAO,UAAU,WAAW,UAAU;AAAA,EACxC;AACA,MAAI,SAAS,UAAU,SAAS,UAAU;AACxC,WAAO,OAAO,KAAK;AAAA,EACrB;AACA,SAAO;AACT;AAQO,SAAS,oBAAqB,QAAQ,UAAU,oBAAI,QAAQ,GAA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I;AACP,aAAK,gBAAgB;AACrB,eAAO;AAAA,MACT;AAAA,IACF,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,cAAe,MAAM;AACnB,QAAI,OAAO;AACX,eAAW,SAAS,MAAM;AACxB,UAAI,CAAC,MAAM;AACT,eAAO;AAAA,MACT;AAEA,aAAO,KAAK,WAAW,KAAK;AAAA,IAC9B;AACA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,iBAAkB;AAChB,SAAK,YAAY,CAAC;AAClB,UAAM,MAAM,KAAK,iBAAiB;AAClC,QAAI,CAAC,KAAK;AACR;AAAA,IACF;AAEA,QAAI,IAAI,OAAO;AACb,iBAAW,QAAQ,IAAI,OAAO;AAC5B,cAAM,OAAO,KAAK,cAAc,KAAK,IAAI;AACzC,YAAI,MAAM;AACR,eAAK,UAAU,KAAK;AAAA,YAClB,MAAM;AAAA,
|
|
4
|
+
"sourcesContent": ["/**\n * @import { CoraliteComponent } from '../types/index.js'\n * @import {\n * CoraliteClientPluginDisconnectedCallback,\n * CoraliteClientPluginAfterComponentRenderCallback,\n * CoraliteClientPluginBeforeComponentRenderCallback\n * } from '../types/plugin.js'\n */\n\nconst 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\n/**\n * Coerces a value to a specified type.\n * Supports Number, Boolean, and String.\n * @param {any} value - The value to coerce.\n * @param {Function|string} type - The target type (Constructor or string name).\n * @returns {any} The coerced value.\n */\nexport function coerce (value, type) {\n if (value === null || value === undefined) {\n return value\n }\n if (type === Number || type === 'Number') {\n return Number(value)\n }\n if (type === Boolean || type === 'Boolean') {\n if (value === '') {\n return true\n }\n return value !== 'false' && value !== null\n }\n if (type === String || type === 'String') {\n return String(value)\n }\n return value\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 Error('Coralite Error: Cannot mutate state inside a getter. State is read-only here.')\n },\n deleteProperty () {\n throw new Error('Coralite Error: Cannot delete state inside a getter. State is read-only here.')\n }\n }\n\n const proxy = new Proxy(target, handler)\n proxies.set(target, proxy)\n return proxy\n}\n\n\n/**\n * @typedef {Object} CoraliteComponentOptions\n * @property {string} componentId - The unique identifier for the component.\n * @property {string} [templateHTML] - The raw HTML string for imperative mounting.\n * @property {Object} [defaultValues] - The initial state values extracted from the server data block.\n * @property {Object} [attributes] - Schema for coercing HTML attributes into typed primitives.\n * @property {Object.<string, Function>} [getters] - Pure functions for derived state, supporting Promises.\n * @property {Object.<string, Function>} [slots] - Transformation functions for projected Light DOM.\n * @property {Function} [script] - The client-side controller logic.\n * @property {Object} [hydrationMap] - AST mapping for reactive text nodes, attributes, and refs.\n */\n\n/**\n * Base class for all Coralite custom elements.\n * * This class acts as the client-side runtime engine. It manages DOM hydration,\n * native Web Component lifecycles, batched reactive state management (via Proxies),\n * asynchronous getter race-condition locks, and isomorphic plugin hooks.\n * * @augments HTMLElement\n */\nexport class CoraliteElement extends HTMLElement {\n /**\n * Initializes a new instance of the CoraliteElement.\n * Sets up internal state trackers, binding collections, and hook registries.\n */\n constructor () {\n super()\n /**\n * Controls native teardown of event listeners and async fetches upon disconnection.\n * @type {AbortController|null}\n * @protected\n */\n this._abortController = null\n\n /**\n * A globally unique, deterministic identifier (e.g., `my-comp-0`).\n * @type {string|null}\n * @protected\n */\n this._instanceId = null\n\n /**\n * The unified, deeply reactive proxy holding attributes, data, and getters.\n * @type {Object|null}\n * @protected\n */\n this._state = null\n\n /**\n * The collection of DOM nodes mapped to template tokens and attributes.\n * @type {Array<{type: string, node: Node, template?: string, name?: string}>}\n * @protected\n */\n this._bindings = []\n\n /**\n * Flag to prevent multiple synchronous state mutations from triggering multiple DOM paints.\n * @type {boolean}\n * @protected\n */\n this._isUpdatePending = false\n\n /**\n * A unique Symbol generated per render cycle to prevent async getter race conditions.\n * @type {symbol|null}\n * @protected\n */\n this._currentRenderVersion = null\n\n /**\n * @type {MutationObserver|null}\n * @protected\n */\n this._observer = null\n\n /**\n * Hook to fetch globally registered Phase-2 plugin contexts.\n * @type {Function|null}\n * @protected\n */\n this._clientContextGetter = null\n\n /**\n * Tracks AbortControllers specifically for cancelling stale async getters.\n * @type {Object.<string, AbortController>|null}\n * @protected\n */\n this._getterAbortControllers = null\n\n /**\n * Internal lifecycle hooks injected by registered Coralite plugins.\n * @type {{\n * onBeforeComponentRender: Array<CoraliteClientPluginBeforeComponentRenderCallback>,\n * onAfterComponentRender: Array<CoraliteClientPluginAfterComponentRenderCallback>,\n * onDisconnected: Array<CoraliteClientPluginDisconnectedCallback>\n * }}\n * @protected\n */\n this._hooks = {\n onBeforeComponentRender: [],\n onAfterComponentRender: [],\n onDisconnected: []\n }\n\n /**\n * The definition and schema of the component generated by the compiler.\n * @type {CoraliteComponentOptions|null}\n */\n this.componentOptions = null\n }\n\n /**\n * Invoked natively when the element is added to the document.\n * Handles the architectural split between Declarative (SSR) and Imperative (JS) components.\n * Orchestrates template injection, instance ID generation, and state/binding setup.\n */\n connectedCallback () {\n this._abortController = new AbortController()\n\n if (!this.componentOptions) {\n return\n }\n\n // Declarative components receive a data-cid from the server.\n // Imperative components (created via document.createElement) do not.\n const isImperative = !this.hasAttribute('data-cid')\n\n // Imperative Flow: Manually stamp the template and project the Light DOM.\n if (isImperative && this.componentOptions.templateHTML) {\n const originalLightDOM = Array.from(this.childNodes)\n this.innerHTML = this.componentOptions.templateHTML\n\n if (originalLightDOM.length > 0) {\n const slots = this.querySelectorAll('slot')\n slots.forEach(slot => {\n const slotName = slot.getAttribute('name') || 'default'\n const matchingNodes = originalLightDOM.filter(node => {\n // @ts-ignore\n const nodeSlot = (node.getAttribute && node.getAttribute('slot')) || 'default'\n return nodeSlot === slotName\n })\n matchingNodes.forEach(n => slot.appendChild(n))\n })\n }\n }\n\n // Establish the Deterministic Instance ID\n if (this.hasAttribute('data-cid')) {\n this._instanceId = this.getAttribute('data-cid')\n } else {\n // Fallback counter for imperatively created components\n // @ts-ignore\n window.__coralite_instanceCounters = window.__coralite_instanceCounters || {}\n const prefix = this.componentOptions.componentId\n // @ts-ignore\n if (window.__coralite_instanceCounters[prefix] === undefined) {\n // @ts-ignore\n window.__coralite_instanceCounters[prefix] = 0\n }\n // @ts-ignore\n this._instanceId = `${prefix}-${window.__coralite_instanceCounters[prefix]++}`\n }\n\n if (isImperative) {\n this.setAttribute('data-cid', this._instanceId)\n }\n\n this._setupState()\n this._setupBindings()\n this._init(isImperative)\n }\n\n /**\n * Invoked natively when the element is removed from the document.\n * Aborts pending requests and triggers `onDisconnected` plugin hooks\n * to ensure external libraries (e.g., Observers) do not cause memory leaks.\n */\n disconnectedCallback () {\n if (this._abortController) {\n this._abortController.abort()\n }\n\n if (!this.componentOptions) {\n return\n }\n\n for (const hook of this._hooks.onDisconnected) {\n hook({\n state: this._state,\n instanceId: this._instanceId,\n componentId: this.componentOptions.componentId,\n element: this,\n options: this.componentOptions\n })\n }\n }\n\n /**\n * Invoked natively when an observed HTML attribute changes.\n * Coerces the raw string value based on the component's attribute schema\n * and synchronizes it into the reactive state proxy.\n * @param {string} name - The kebab-case name of the attribute.\n * @param {string|null} oldVal - The previous value.\n * @param {string|null} newVal - The new value.\n */\n attributeChangedCallback (name, oldVal, newVal) {\n if (!this._state || oldVal === newVal || name === 'data-cid') {\n return\n }\n const camelName = name.replace(/-([a-z])/g, (g) => g[1].toUpperCase())\n const schema = this.componentOptions.attributes?.[camelName] || this.componentOptions.attributes?.[name]\n const value = schema ? coerce(newVal, schema.type) : newVal\n\n this._state[camelName] = value\n }\n\n /**\n * Constructs the unified state object.\n * Merges `defaultValues`, JSON hydration payloads, and DOM attributes.\n * Defines getters (wrapping state in a Read-Only proxy) and applies the final Read/Write Proxy.\n * @private\n */\n _setupState () {\n const options = this.componentOptions\n const target = { ...options.defaultValues }\n\n /** @type {Array<{name: string, element: HTMLElement}>} */\n const refs = []\n if (options.hydrationMap && options.hydrationMap.refs) {\n for (const item of options.hydrationMap.refs) {\n /** @type {HTMLElement} */\n // @ts-ignore\n const node = this.getNodeByPath(item.path)\n if (node) {\n refs.push({\n name: item.name,\n element: node\n })\n }\n }\n }\n\n // Trigger Before-Render hooks BEFORE state is proxied, allowing plugins to inject reactive data\n for (const hook of this._hooks.onBeforeComponentRender) {\n hook({\n state: target,\n instanceId: this._instanceId,\n componentId: this.componentOptions.componentId,\n refs,\n element: this,\n options: this.componentOptions\n })\n }\n\n // Hydrate data() block results from the SSR JSON payload\n const hydrationTag = document.getElementById('__CORALITE_HYDRATION__')\n if (hydrationTag) {\n try {\n const allData = JSON.parse(hydrationTag.textContent)\n if (allData[this._instanceId]) {\n Object.assign(target, allData[this._instanceId])\n }\n } catch (e) {\n console.error('Coralite Element hydration failed:', this._instanceId)\n }\n }\n\n // Process initial attributes mapping\n for (const attr of this.attributes) {\n if (attr.name === 'data-cid') {\n continue\n }\n const camelName = attr.name.replace(/-([a-z])/g, (g) => g[1].toUpperCase())\n const schema = options.attributes?.[camelName] || options.attributes?.[attr.name]\n target[camelName] = schema ? coerce(attr.value, schema.type) : attr.value\n }\n\n // Define derived state getters with isolation controllers\n this._getterAbortControllers = {}\n for (const [key, getter] of Object.entries(options.getters || {})) {\n Object.defineProperty(target, key, {\n get: () => {\n if (this._getterAbortControllers[key]) {\n this._getterAbortControllers[key].abort()\n }\n this._getterAbortControllers[key] = new AbortController()\n\n // Enforce \"Dual-Proxy\" safety: Getters cannot mutate state\n const roState = createReadOnlyProxy(this._state)\n return getter(roState, { signal: this._getterAbortControllers[key].signal })\n },\n enumerable: true,\n configurable: true\n })\n }\n\n this._state = this._createReactiveProxy(target)\n }\n\n /**\n * Wraps the state target in a reactive Proxy.\n * Intercepts property setters to automatically batch and schedule DOM updates.\n * @param {Object} target - The state dictionary.\n * @returns {Proxy} The reactive state proxy.\n * @private\n */\n _createReactiveProxy (target) {\n const self = this\n return new Proxy(target, {\n set (t, p, v) {\n if (t[p] === v) {\n return true\n }\n t[p] = v\n self._scheduleUpdate()\n return true\n }\n })\n }\n\n /**\n * Traverses the DOM tree using an AST-generated path index array.\n * Allows O(1) element lookups without relying on querySelectors or classes.\n * @param {number[]} path - Array of childNode indices (e.g., `[0, 1, 2]`).\n * @returns {Node|null} The physical DOM node, or null if traversal fails.\n */\n getNodeByPath (path) {\n let node = this\n for (const index of path) {\n if (!node) {\n return null\n }\n // @ts-ignore\n node = node.childNodes[index]\n }\n return node\n }\n\n /**\n * Initializes DOM bindings based on the compiler's hydration map.\n * Caches physical DOM references to text nodes and attributes that contain template tokens.\n * @private\n */\n _setupBindings () {\n this._bindings = []\n const map = this.componentOptions.hydrationMap\n if (!map) {\n return\n }\n\n if (map.texts) {\n for (const item of map.texts) {\n const node = this.getNodeByPath(item.path)\n if (node) {\n this._bindings.push({\n type: item.type || 'text',\n node,\n template: item.template\n })\n }\n }\n }\n\n if (map.attributes) {\n for (const item of map.attributes) {\n const node = this.getNodeByPath(item.path)\n if (node) {\n this._bindings.push({\n type: 'attribute',\n node,\n name: item.name,\n template: item.template\n })\n }\n }\n }\n }\n\n /**\n * Schedules a DOM update in the next microtask queue.\n * This guarantees that multiple synchronous state mutations result in only one render pass.\n * @private\n */\n _scheduleUpdate () {\n if (this._isUpdatePending) {\n return\n }\n this._isUpdatePending = true\n queueMicrotask(() => {\n this._updateDOM()\n this._isUpdatePending = false\n })\n }\n\n /**\n * Performs the physical DOM update and resolves template tokens.\n * **Async Safety:** Implements a Symbol-based locking mechanism (`renderVersion`)\n * to guarantee that if state mutates while an async getter is pending, the stale\n * Promise will be discarded, preventing DOM race conditions.\n * @private\n */\n _updateDOM () {\n // Create a unique lock for this specific render cycle\n const renderVersion = Symbol()\n this._currentRenderVersion = renderVersion\n\n // Extract unique tokens to prevent double-reading and accidental aborts\n /** @type {Set<string>} */\n const requiredTokens = new Set()\n for (const binding of this._bindings) {\n binding.template.replace(/\\{\\{\\s*(.+?)\\s*\\}\\}/g, (_, key) => {\n requiredTokens.add(key)\n return ''\n })\n }\n\n const evaluatedTokens = {}\n let hasPromise = false\n\n // Evaluate getters exactly once per render cycle\n for (const key of requiredTokens) {\n let val = this._state[key]\n if (typeof val === 'function') {\n val = val(this._state)\n }\n evaluatedTokens[key] = val\n if (val instanceof Promise) {\n hasPromise = true\n }\n }\n\n // The DOM Mutator Function\n const applyBindings = (tokenValues) => {\n // Race Condition Lock: Abort if a newer render cycle has already begun\n if (this._currentRenderVersion !== renderVersion) {\n return\n }\n\n for (const binding of this._bindings) {\n const hydratedValue = binding.template.replace(/\\{\\{\\s*(.+?)\\s*\\}\\}/g, (_, key) => {\n return tokenValues[key] ?? ''\n })\n\n if (binding.type === 'text') {\n if (binding.node.textContent !== hydratedValue) {\n binding.node.textContent = hydratedValue\n }\n } else if (binding.type === 'html') {\n /** @type {HTMLElement} */\n // @ts-ignore\n const element = binding.node\n\n if (element.innerHTML !== hydratedValue) {\n element.innerHTML = hydratedValue\n }\n } else if (binding.type === 'attribute') {\n /** @type {HTMLElement} */\n // @ts-ignore\n const element = binding.node\n\n if (BOOLEAN_ATTRIBUTES.has(binding.name)) {\n const isFalsy = hydratedValue === '' || hydratedValue === 'false' || hydratedValue === 'null' || hydratedValue === '0' || hydratedValue === 'undefined'\n if (isFalsy) {\n element.removeAttribute(binding.name)\n } else {\n element.setAttribute(binding.name, '')\n }\n } else {\n if (element.getAttribute(binding.name) !== hydratedValue) {\n element.setAttribute(binding.name, hydratedValue)\n }\n }\n }\n }\n\n this._processSlots()\n\n // Trigger After-Render hooks ONLY after the physical DOM is stable\n for (const hook of this._hooks.onAfterComponentRender) {\n hook({\n state: this._state,\n instanceId: this._instanceId,\n componentId: this.componentOptions.componentId,\n element: this,\n options: this.componentOptions\n })\n }\n }\n\n // 5. Await Promises or Apply Synchronously\n if (hasPromise) {\n const keys = Object.keys(evaluatedTokens)\n const promises = keys.map(k => Promise.resolve(evaluatedTokens[k]))\n\n Promise.all(promises).then(resolvedValues => {\n const resolvedMap = {}\n keys.forEach((k, i) => {\n resolvedMap[k] = resolvedValues[i]\n })\n applyBindings(resolvedMap)\n }).catch(e => {\n if (e.name !== 'AbortError') {\n console.error('Coralite Async Getter Error:', e)\n }\n })\n } else {\n applyBindings(evaluatedTokens)\n }\n }\n\n /**\n * Evaluates and projects Light DOM elements into their respective `<slot>` nodes.\n * Invokes component-specific slot transformation functions.\n * @private\n */\n _processSlots () {\n const slots = this.componentOptions.slots\n if (!slots || Object.keys(slots).length === 0) {\n return\n }\n\n const slotElements = this.querySelectorAll('slot')\n slotElements.forEach(slotEl => {\n const slotName = slotEl.getAttribute('name') || 'default'\n const slotFn = slots[slotName]\n\n if (slotFn) {\n // @ts-ignore\n if (!slotEl._originalNodes) {\n // @ts-ignore\n slotEl._originalNodes = Array.from(slotEl.childNodes).map(n => n.cloneNode(true))\n }\n\n // @ts-ignore\n const result = slotFn(slotEl._originalNodes, this._state)\n\n if (typeof result === 'string') {\n slotEl.innerHTML = result\n } else if (Array.isArray(result)) {\n slotEl.replaceChildren(...result)\n }\n }\n })\n }\n\n /**\n * The final initialization pipeline.\n * Injects globally registered client plugins into the local context payload,\n * triggers the initial DOM render, and invokes the user's `script()` logic.\n * @param {boolean} [isImperative=false] - If true, initial render runs synchronously.\n * @private\n */\n async _init (isImperative = false) {\n /**\n * The context payload injected into the user's script block.\n * @type {Object}\n */\n const localContext = {\n instanceId: this._instanceId,\n state: this._state,\n root: this,\n signal: this._abortController.signal\n }\n\n if (typeof this._clientContextGetter === 'function') {\n const pluginContext = await this._clientContextGetter(localContext)\n Object.assign(localContext, pluginContext)\n }\n\n if (isImperative) {\n this._updateDOM()\n } else {\n this._scheduleUpdate()\n }\n\n if (this.componentOptions.script) {\n try {\n this.componentOptions.script(localContext)\n } catch (error) {\n console.error(`Coralite Error: Component \"${this.componentOptions.componentId}\" script failed:`, error)\n }\n }\n }\n}\n\n/**\n * Factory function to create a Coralite element class.\n * It dynamically defines the class, including observed attributes and hook initialization.\n * @param {CoraliteComponentOptions} options - Component options and metadata.\n * @param {Function|null} [contextGetter=null] - Optional function to retrieve client-side plugin context.\n * @param {Object} [hooks={}] - Lifecycle hooks to register.\n * @param {Array<CoraliteClientPluginBeforeComponentRenderCallback>} [hooks.onBeforeComponentRender] - Hooks to run before render.\n * @param {Array<CoraliteClientPluginAfterComponentRenderCallback>} [hooks.onAfterComponentRender] - Hooks to run after render.\n * @param {Array<CoraliteClientPluginDisconnectedCallback>} [hooks.onDisconnected] - Hooks to run after render.\n * @returns {typeof CoraliteElement} A new CoraliteElement subclass.\n */\nexport function createCoraliteClass (options, contextGetter = null, hooks = {}) {\n return class extends CoraliteElement {\n /**\n * The attributes to observe for changes.\n * @returns {string[]} Array of attribute names.\n */\n static get observedAttributes () {\n if (!options.attributes) {\n return []\n }\n return Object.keys(options.attributes).map(key => key.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()\n )\n }\n\n /**\n * Initializes the dynamic Coralite element.\n */\n constructor () {\n super()\n this.componentOptions = options\n this._clientContextGetter = contextGetter\n this._hooks = {\n onBeforeComponentRender: hooks.onBeforeComponentRender || [],\n onAfterComponentRender: hooks.onAfterComponentRender || [],\n onDisconnected: hooks.onDisconnected || []\n }\n }\n }\n}\n"],
|
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503,7 @@ export class Coralite {
|
|
|
503
503
|
* @param {CoraliteModuleDefinitions} [options.state={}] - Token state available for replacement
|
|
504
504
|
* @param {CoraliteElement} [options.element] - The original Custom Element node
|
|
505
505
|
* @param {CoralitePage} options.page - The global page object
|
|
506
|
-
* @param {
|
|
506
|
+
* @param {CoraliteComponentRoot} [options.root] - The root element of the component
|
|
507
507
|
* @param {string} [options.contextId] - Context Id
|
|
508
508
|
* @param {number} [options.index] - Context index
|
|
509
509
|
* @param {CoraliteSession} [options.session] - Render Context
|
|
@@ -516,7 +516,7 @@ export class Coralite {
|
|
|
516
516
|
state?: CoraliteModuleDefinitions;
|
|
517
517
|
element?: CoraliteElement;
|
|
518
518
|
page: CoralitePage;
|
|
519
|
-
root
|
|
519
|
+
root?: CoraliteComponentRoot;
|
|
520
520
|
contextId?: string;
|
|
521
521
|
index?: number;
|
|
522
522
|
session?: CoraliteSession;
|
|
@@ -528,7 +528,6 @@ export class Coralite {
|
|
|
528
528
|
* @param {string} id - Component ID
|
|
529
529
|
* @param {CoraliteElement} element - The original Custom Element node
|
|
530
530
|
* @param {CoraliteModule} module - The component module configuration
|
|
531
|
-
* @param {string} contextId - Instance context ID
|
|
532
531
|
* @param {Object} state - The component state
|
|
533
532
|
* @param {CoralitePage} page - Active page object
|
|
534
533
|
* @param {any} root - The component root element
|
|
@@ -537,7 +536,7 @@ export class Coralite {
|
|
|
537
536
|
* @param {boolean} noHydration - No hydration flag
|
|
538
537
|
* @returns {Promise<void>} Resolves when slots are successfully replaced
|
|
539
538
|
*/
|
|
540
|
-
readonly _replaceSlots: (id: string, element: CoraliteElement, module: CoraliteModule,
|
|
539
|
+
readonly _replaceSlots: (id: string, element: CoraliteElement, module: CoraliteModule, state: any, page: CoralitePage, root: any, index: number, session: CoraliteSession, noHydration: boolean) => Promise<void>;
|
|
541
540
|
/**
|
|
542
541
|
* Generates a custom module linker callback for the Node.js VM context.
|
|
543
542
|
* This linker is responsible for resolving `import` statements inside evaluated
|
|
@@ -1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AC,mBAAmB,GAAC,mBAAmB,GAAC,oBAAoB,GAAC,mBAAmB,GAAC,yBAAyB,GAAC,wBAAwB,GAAC,eAAe,GAAC,cAAc,8BAGvM;IAUjC;;;;;OAKG;IACH,8DAHW,eAAe,WACf,eAAe,UAE0B;IAOpD;;;;;;;;;;;;OAYG;IACH,qCAVW,GAAG,WAEX;QAA8B,kBAAkB,GAAxC,SAAS,EAAE;QACM,KAAK;QACG,MAAM,GAA/B,cAAc;QACK,sBAAsB;QACf,OAAO,GAAjC,eAAe;QACG,WAAW,GAA7B,OAAO;KACf,KAAU,OAAO,CAAC,GAAG,CAAC,CAEY;IAoErC;;;;;;;OAOG;IACH,mDAHW,qBAAqB,KACnB,OAAO,KAAQ,CAEO;;;wCAvpDxB,cAAc,KACZ,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG;oCAriCrB,mBAAmB;4CAAnB,mBAAmB;8BA1CC,qBAAqB;6BALU,WAAW;4BAAX,WAAW;+BAGF,YAAY;2CA4CxE,mBAAmB;qCAAnB,mBAAmB;0CAIU,gBAAgB;+BA5BxB,iBAAiB;oCAwBtC,mBAAmB;kCAAnB,mBAAmB;8BA9BC,aAAa;qCA8BjC,mBAAmB;uCAAnB,mBAAmB;6CAAnB,mBAAmB;oCAAnB,mBAAmB;+CAAnB,mBAAmB;qCAAnB,mBAAmB;sCAAnB,mBAAmB;2CAAnB,mBAAmB;+BAAnB,mBAAmB"}
|
package/dist/lib/coralite.js
CHANGED
|
@@ -1369,7 +1369,7 @@ Coralite.prototype.createComponentElement = async function({
|
|
|
1369
1369
|
}
|
|
1370
1370
|
}
|
|
1371
1371
|
}
|
|
1372
|
-
await this._replaceSlots(id, element, module,
|
|
1372
|
+
await this._replaceSlots(id, element, module, componentState, page, root, index, session, noHydration);
|
|
1373
1373
|
if (noHydration) {
|
|
1374
1374
|
const stack = [...result.children];
|
|
1375
1375
|
while (stack.length > 0) {
|
|
@@ -1406,7 +1406,7 @@ Coralite.prototype.createComponentElement = async function({
|
|
|
1406
1406
|
});
|
|
1407
1407
|
return mappedAfterContext.result;
|
|
1408
1408
|
};
|
|
1409
|
-
Coralite.prototype._replaceSlots = async function(id, element, module,
|
|
1409
|
+
Coralite.prototype._replaceSlots = async function(id, element, module, state, page, root, index, session, noHydration) {
|
|
1410
1410
|
const slots = module.slotElements ? module.slotElements[id] : null;
|
|
1411
1411
|
if (!slots) {
|
|
1412
1412
|
return;
|
package/dist/lib/coralite.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../lib/coralite.js"],
|
|
4
|
-
"sourcesContent": ["import { cleanKeys, cloneModuleInstance, replaceToken, cloneComponentInstance, findAndExtractScript, findAndExtractProperties, extractGlobals, mergePluginState, normalizeObjectFunctions, astTransformer } from './utils.js'\nimport { getHtmlFile, getHtmlFiles, discoverHtmlFiles } from './html.js'\nimport { findHeadAndBody, injectExternalStyles, injectStyles, injectReadinessScript, injectImportMap, removeElements, resolvePageQueue } from './render-helpers.js'\nimport { generateClientRuntime } from './client-runtime.js'\nimport { parseHTML, parseModule, createElement, createTextNode } from './parse.js'\nimport { transformCss } from './style-transform.js'\nimport { ScriptManager } from './script-manager.js'\nimport { metadataPlugin, refsPlugin, staticAssetPlugin, testingPlugin } from '#plugins'\nimport { mkdir, writeFile } from 'node:fs/promises'\nimport { dirname, join, normalize, relative, resolve } from 'node:path'\nimport { createRequire } from 'node:module'\nimport { transform } from 'esbuild'\nimport {\n isCoraliteElement,\n isCoraliteCollectionItem,\n isCoraliteComment,\n isCoraliteTextNode\n} from './type-helper.js'\nimport { CoraliteError } from './errors.js'\nimport { pathToFileURL } from 'node:url'\nimport { availableParallelism } from 'node:os'\nimport render from 'dom-serializer'\nimport pLimit from 'p-limit'\nimport { createCoraliteElement, createCoraliteTextNode } from './dom.js'\nimport CoraliteCollection from './collection.js'\nimport { randomUUID } from 'node:crypto'\nimport { createContext } from 'node:vm'\nimport { createReadOnlyProxy } from './utils.js'\n\n/**\n * @import {\n * CoraliteElement,\n * CoraliteAnyNode,\n * CoraliteModule,\n * CoraliteResult,\n * CoraliteModuleDefinitions,\n * CoraliteComponent,\n * CoraliteCollectionItem,\n * CoraliteComponentRoot,\n * CoraliteCollectionEventSet,\n * CoraliteComponentResult,\n * InstanceContext,\n * CoraliteConfig,\n * CoraliteFilePath,\n * CoralitePage,\n * CoraliteSession,\n * CoralitePluginContext,\n * Attribute\n * } from '../types/index.js'\n */\n\n/**\n * @import {DomSerializerOptions} from 'dom-serializer'\n */\n\n/**\n * @class\n * @param {CoraliteConfig} options\n * @example\n * const coralite = new Coralite({\n * components: './path/to/components',\n * pages: './path/to/pages',\n * mode: 'development',\n * plugins: [myPlugin],\n * ignoreByAttribute: [{ name: 'data-ignore', value: 'true' }],\n * skipRenderByAttribute: ['data-skip-render']\n * });\n */\nexport function Coralite ({\n components,\n pages,\n plugins,\n assets,\n externalStyles,\n baseURL = '/',\n ignoreByAttribute,\n skipRenderByAttribute,\n onError,\n mode = 'production',\n output\n}) {\n // Validate required parameters\n if (!components && typeof components !== 'string') {\n throw new Error('Coralite constructor requires \"components\" option to be defined')\n }\n\n if (!pages && typeof pages !== 'string') {\n throw new Error('Coralite constructor requires \"pages\" option to be defined')\n }\n\n if (!plugins) {\n plugins = []\n }\n\n const path = {\n components: normalize(components),\n pages: normalize(pages)\n }\n\n this._onErrorCallback = onError\n\n // instance options\n this.options = {\n components,\n pages,\n plugins,\n assets,\n externalStyles,\n baseURL,\n ignoreByAttribute,\n skipRenderByAttribute,\n mode,\n path,\n output: output ? normalize(output) : undefined\n }\n\n /** @type {Map<string, CoraliteCollectionItem[]>} */\n this._renderQueues = new Map()\n\n // plugins\n this._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\n // Initialize script manager\n this._scriptManager = new ScriptManager(this.options)\n\n // source context\n this._source = {\n utils: {\n parseHTML: (string, ignoreByAttribute = this.options.ignoreByAttribute, skipRenderByAttribute = this.options.skipRenderByAttribute) => parseHTML(string, ignoreByAttribute, skipRenderByAttribute, (errorData) => this._handleError(errorData)),\n parseModule: (string, options) => parseModule(string, {\n ignoreByAttribute: this.options.ignoreByAttribute,\n skipRenderByAttribute: this.options.skipRenderByAttribute,\n onError: (errorData) => this._handleError(errorData),\n ...options\n }),\n getHtmlFiles,\n getHtmlFile,\n createElement: (options) => createElement({\n onError: (errorData) => this._handleError(errorData),\n ...options\n }),\n createTextNode,\n transform: this.transform\n },\n plugins: {\n }\n }\n\n // place core plugin first\n if (this.options.mode === 'development') {\n plugins.unshift(testingPlugin)\n }\n plugins.unshift(refsPlugin, metadataPlugin)\n\n if (assets) {\n plugins.unshift(staticAssetPlugin(assets))\n }\n\n const source = this._source\n // iterate over each plugin and register its hooks and modules in the Coralite source context.\n for (let i = 0; i < plugins.length; i++) {\n const plugin = plugins[i]\n\n if (plugin.server) {\n // set plugin method\n if (plugin.server.exports !== undefined) {\n source.plugins[plugin.name] = plugin.server.exports\n }\n\n // queue any components provided by the plugin to be registered.\n if (plugin.server.components && Array.isArray(plugin.server.components)) {\n for (let j = 0; j < plugin.server.components.length; j++) {\n this._plugins.components.push(plugin.server.components[j])\n }\n }\n\n // add the plugin's hooks to the appropriate Coralite hook lists.\n if (plugin.server.onPageSet) {\n this._addPluginHook('onPageSet', plugin.server.onPageSet)\n }\n if (plugin.server.onPageDelete) {\n this._addPluginHook('onPageDelete', plugin.server.onPageDelete)\n }\n if (plugin.server.onPageUpdate) {\n this._addPluginHook('onPageUpdate', plugin.server.onPageUpdate)\n }\n if (plugin.server.onComponentSet) {\n this._addPluginHook('onComponentSet', plugin.server.onComponentSet)\n }\n if (plugin.server.onComponentDelete) {\n this._addPluginHook('onComponentDelete', plugin.server.onComponentDelete)\n }\n if (plugin.server.onComponentUpdate) {\n this._addPluginHook('onComponentUpdate', plugin.server.onComponentUpdate)\n }\n if (plugin.server.onBeforePageRender) {\n this._addPluginHook('onBeforePageRender', plugin.server.onBeforePageRender)\n }\n if (plugin.server.onAfterPageRender) {\n this._addPluginHook('onAfterPageRender', plugin.server.onAfterPageRender)\n }\n if (plugin.server.onBeforeComponentRender) {\n this._addPluginHook('onBeforeComponentRender', plugin.server.onBeforeComponentRender)\n }\n if (plugin.server.onAfterComponentRender) {\n this._addPluginHook('onAfterComponentRender', plugin.server.onAfterComponentRender)\n }\n if (plugin.server.onBeforeBuild) {\n this._addPluginHook('onBeforeBuild', plugin.server.onBeforeBuild)\n }\n if (plugin.server.onAfterBuild) {\n this._addPluginHook('onAfterBuild', plugin.server.onAfterBuild)\n }\n }\n\n // register client-side plugin if provided\n if (plugin.client) {\n this._scriptManager.use(plugin.client)\n }\n }\n\n const propertyDescriptors = {\n enumerable: false,\n configurable: false,\n writable: false\n }\n\n const enumerablePropertyDescriptors = {\n enumerable: true,\n configurable: false,\n writable: true\n }\n\n Object.defineProperties(this, {\n options: { ...enumerablePropertyDescriptors },\n _plugins: { ...propertyDescriptors },\n _scriptManager: { ...propertyDescriptors },\n _source: { ...propertyDescriptors },\n _onErrorCallback: { ...propertyDescriptors },\n _renderQueues: { ...propertyDescriptors }\n })\n}\n\n/**\n * Initialises the Coralite instance.\n * @returns {Promise<void>}\n */\nCoralite.prototype.initialise = async function () {\n this.components = await getHtmlFiles({\n path: this.options.components,\n recursive: true,\n type: 'component',\n onFileSet: async (value) => {\n if (value.content === undefined) {\n value.content = await getHtmlFile(value.path.pathname)\n }\n\n const component = parseModule(value.content, {\n ignoreByAttribute: this.options.ignoreByAttribute,\n skipRenderByAttribute: this.options.skipRenderByAttribute,\n onError: (errorData) => this._handleError(errorData)\n })\n\n // abort component add\n if (!component.isTemplate) {\n return\n }\n\n const mappedComponent = await this._triggerPluginHook('onComponentSet', component)\n\n return {\n type: 'component',\n id: mappedComponent.id,\n value: mappedComponent\n }\n },\n onFileUpdate: async (value) => {\n if (value.content === undefined) {\n value.content = await getHtmlFile(value.path.pathname)\n }\n\n const component = parseModule(value.content, {\n ignoreByAttribute: this.options.ignoreByAttribute,\n skipRenderByAttribute: this.options.skipRenderByAttribute,\n onError: (errorData) => this._handleError(errorData)\n })\n\n // abort component update\n if (!component.isTemplate) {\n return\n }\n\n return await this._triggerPluginHook('onComponentUpdate', component)\n },\n onFileDelete: async (value) => {\n await this._triggerPluginHook('onComponentDelete', value)\n }\n })\n\n // register plugin components\n await Promise.all(this._plugins.components.map(c => this.components.setItem(c)))\n\n // collection of custom elements used by pages\n /** @type {Object.<string, Set<string>>} */\n const pageCustomElements = {}\n /** @type {Object.<string, string>} */\n const childCustomElements = {}\n\n /**\n * @type {Object.<string, Set<string>>}\n */\n this._pageCustomElements = pageCustomElements\n /**\n * @type {Object.<string, string>}\n */\n this._childCustomElements = childCustomElements\n\n Object.defineProperties(this, {\n _pageCustomElements: {\n enumerable: false,\n configurable: false,\n writable: false\n },\n _childCustomElements: {\n enumerable: false,\n configurable: false,\n writable: false\n }\n })\n\n /** @type {CoraliteCollectionEventSet} */\n const onFileSet = async (data) => {\n // Determine the root path based on the data type\n let rootPath = this.options.path.pages\n\n if (data.type === 'component') {\n rootPath = this.options.path.components\n }\n\n // Convert relative file path to a URL pathname format\n const urlPathname = pathToFileURL(join('/', relative(rootPath, data.path.pathname))).pathname\n\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: {}\n }\n\n // define a set of context state for component rendering\n /** @type {any} */\n const state = {\n ...data.state,\n page\n }\n\n // If discovered only, skip parsing and plugin hooks to save memory\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, this.options.ignoreByAttribute, this.options.skipRenderByAttribute, (errorData) => this._handleError(errorData))\n\n // track parent-child relationship between custom elements (only in development)\n if (this.options.mode !== 'production') {\n const customElementsList = elements ? (elements.customElements || []) : []\n for (let i = 0; i < customElementsList.length; i++) {\n const customElement = customElementsList[i]\n const name = customElement.name\n let item = pageCustomElements[name]\n\n if (!item) {\n pageCustomElements[name] = new Set()\n item = pageCustomElements[name]\n\n const component = this.components.getItem(name)\n\n if (\n component &&\n component.result &&\n component.result.customElements &&\n component.result.customElements.length\n ) {\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\n // process nested elements recursively\n const component = this.components.getItem(element.name)\n\n if (\n component &&\n component.result &&\n component.result.customElements &&\n component.result.customElements.length\n ) {\n // push nested custom elements to stack for processing\n stack.push(component.result.customElements)\n }\n }\n }\n }\n }\n }\n\n // add page to custom element collection\n item.add(data.path.pathname)\n }\n }\n\n const mappedContext = await this._triggerPluginHook('onPageSet', {\n elements,\n state: state,\n page,\n data\n })\n\n const isProduction = this.options.mode === 'production'\n\n if (isProduction && data.physical) {\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 // In production, we discard the heavy AST nodes after initialization hooks to save memory.\n // They will be re-parsed on-demand during the build/render phase.\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 onPageUpdate = async (newValue, oldValue) => {\n if (this.options.mode === 'production') {\n return newValue.result\n }\n\n let newCustomElements\n\n if (!newValue.result) {\n const result = await onFileSet(newValue)\n\n newValue.result = result.value\n newCustomElements = result.value.customElements\n } else {\n newCustomElements = newValue.result.customElements\n }\n\n let oldElements = (oldValue.result.customElements || []).slice()\n\n const mappedContext = await this._triggerPluginHook('onPageUpdate', {\n elements: newValue.result,\n page: newValue.result.page,\n newValue,\n oldValue\n })\n\n // Assign back the mapped elements to result so that rendering uses the updated AST and state\n newValue.result = mappedContext.elements\n newValue = mappedContext.newValue\n\n for (let i = 0; i < newCustomElements.length; i++) {\n const newElement = newCustomElements[i]\n\n let hasElement = false\n\n for (let j = 0; j < oldElements.length; j++) {\n const oldElement = oldElements[j]\n\n if (newElement.name === oldElement.name) {\n hasElement = true\n oldElements.splice(j, 1)\n break\n }\n }\n\n if (!hasElement) {\n let item = pageCustomElements[newElement.name]\n\n if (!item) {\n pageCustomElements[newElement.name] = new Set()\n item = pageCustomElements[newElement.name]\n }\n\n // add page to custom element collection\n item.add(newValue.path.pathname)\n }\n }\n\n for (let i = 0; i < oldElements.length; i++) {\n const pageCustomElement = pageCustomElements[oldElements[i].name]\n\n // remove page from custom element reference\n pageCustomElement.delete(newValue.path.pathname)\n }\n\n return newValue.result\n }\n\n const onPageDelete = async (value) => {\n if (this.options.mode === 'production') {\n return\n }\n\n value = await this._triggerPluginHook('onPageDelete', value)\n\n // remove page from custom element reference\n if (value && value.result && value.result.customElements) {\n const customElements = value.result.customElements\n\n for (let i = 0; i < customElements.length; i++) {\n const pageCustomElement = pageCustomElements[customElements[i]]\n\n if (pageCustomElement) {\n pageCustomElement.delete(value.path.pathname)\n }\n }\n }\n }\n\n this.pages = new CoraliteCollection({\n rootDir: this.options.pages,\n onSet: onFileSet,\n onUpdate: onPageUpdate,\n onDelete: onPageDelete\n })\n\n const isProduction = this.options.mode === 'production'\n\n if (isProduction) {\n for await (const file of discoverHtmlFiles({\n path: this.options.pages,\n recursive: true,\n type: 'page',\n discoverOnly: false\n })) {\n // Process file for metadata, then it will be discarded because isProduction is true in onFileSet\n await this.pages.setItem(file)\n }\n } else {\n /** @type {CoraliteCollection} */\n await getHtmlFiles({\n path: this.options.pages,\n recursive: true,\n type: 'page',\n discoverOnly: false,\n collection: this.pages\n })\n }\n}\n\n/**\n * Default error handler for the Coralite instance.\n * @internal\n * @param {Object} data\n * @param {'WARN' | 'ERR' | 'LOG'} data.level\n * @param {string} data.message\n * @param {Error} [data.error]\n */\nCoralite.prototype._defaultOnError = function ({ level, message, error }) {\n if (level === 'ERR') {\n if (error) {\n throw error\n }\n throw new Error(message)\n } else if (level === 'WARN') {\n console.warn(message)\n } else {\n console.log(message)\n }\n}\n\n/**\n * Internal error handler for the Coralite instance.\n * @internal\n * @param {Object} data - The error or log data object containing the details of the event.\n * @param {'WARN' | 'ERR' | 'LOG'} data.level - The severity level of the message.\n * @param {string} data.message - The descriptive message to be logged or thrown.\n * @param {Error} [data.error] - An optional Error instance providing a stack trace.\n */\nCoralite.prototype._handleError = function (data) {\n if (this._onErrorCallback) {\n this._onErrorCallback(data)\n } else {\n this._defaultOnError(data)\n }\n}\n\n/**\n * Helper to create CoraliteError during component execution\n * @internal\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 */\nCoralite.prototype._createExecutionError = function (error, module, moduleComponent, page, instanceId) {\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 })\n}\n\n/**\n * Creates a render context for the build process.\n * @internal\n * @param {string} [buildId] - The unique identifier for the build process.\n * @returns {CoraliteSession}\n */\nCoralite.prototype._createSession = function (buildId) {\n return {\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/**\n * Compiles specified page(s) by rendering their document content and measuring render time.\n * Processes pages based on provided path(s), replacing custom elements with components,\n * and returns rendered results with performance metrics.\n *\n * @internal\n *\n * @param {string | string[]} [path] - Path to a single page or array of page paths relative to the pages directory. If omitted, compiles all pages.\n * @param {Object} [state] - Properties to be passed to the page\n * @returns {AsyncGenerator<CoraliteResult>}\n */\n\n/**\n * Processes custom elements found within a generated page context\n * @internal\n * @param {CoraliteComponent & CoraliteComponentResult} mappedComponent - The compiled component instance\n * @param {CoraliteComponentResult} originalDocument - The original document mapping\n * @param {Object} state - Local component state\n * @param {CoraliteSession} mappedSessionObject - Global rendering state\n * @returns {Promise<void>} Resolves when the elements are processed\n */\nCoralite.prototype._processCustomElementsInPage = async function (mappedComponent, originalDocument, state, mappedSessionObject, pageContext) {\n const customElementsList = mappedComponent.customElements || []\n for (let i = 0; i < customElementsList.length; i++) {\n const customElement = customElementsList[i]\n\n const contextId = mappedSessionObject.generateId(customElement.name)\n const currentProperties = mappedSessionObject.state[contextId] || {}\n\n if (typeof customElement.attribs === 'object') {\n mappedSessionObject.state[contextId] = {\n ...currentProperties,\n ...state,\n ...mappedComponent.state,\n ...customElement.attribs\n }\n } else {\n mappedSessionObject.state[contextId] = {\n ...currentProperties,\n ...state,\n ...mappedComponent.state\n }\n }\n\n const noHydration = customElement.attribs && 'no-hydration' in customElement.attribs\n const componentElement = await this.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 })\n\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 for (let j = 0; j < componentElement.children.length; j++) {\n componentElement.children[j].parent = parent\n }\n parent.children.splice(elementIndex, 1, ...componentElement.children)\n }\n }\n } else {\n customElement.children = componentElement.children\n for (let j = 0; j < customElement.children.length; j++) {\n customElement.children[j].parent = customElement\n }\n\n if (!customElement.attribs) {\n customElement.attribs = {}\n }\n customElement.attribs['data-cid'] = contextId\n\n mappedSessionObject.componentTags.add(customElement.name)\n }\n }\n }\n}\n\nCoralite.prototype._generatePages = async function* (path, state = {}) {\n const isProduction = this.options.mode === 'production'\n\n if (path) {\n const paths = Array.isArray(path) ? path : [path]\n for (const p of paths) {\n if (!this.pages.getItem(p)) {\n try {\n await this.pages.setItem(p)\n } catch (e) {\n // Path might not be a direct file, could be a glob or dir handled by resolvePageQueue\n }\n }\n }\n }\n\n const queue = resolvePageQueue(this.pages, path)\n\n const buildId = randomUUID()\n this._renderQueues.set(buildId, queue)\n const scriptResultCache = new Map()\n\n try {\n const activeQueue = this._renderQueues.get(buildId)\n\n for (let q = 0; q < activeQueue.length; q++) {\n const pageItem = activeQueue[q]\n const startTime = performance.now()\n\n /** @type {CoraliteComponent & CoraliteComponentResult} */\n const originalDocument = pageItem.result\n\n /** @type {CoraliteComponent & CoraliteComponentResult} */\n // @ts-ignore\n let component\n let pageContext = originalDocument.page\n\n // If the page was discovery-only initialized (no root AST), parse it on-demand\n if (!originalDocument.root) {\n let content = pageItem.content\n if (content === undefined) {\n try {\n content = await getHtmlFile(pageItem.path.pathname)\n } catch (e) {\n // Re-check content in case it was set concurrently or by a plugin (virtual pages)\n if (pageItem.content !== undefined) {\n content = pageItem.content\n } else {\n throw e\n }\n }\n }\n\n // Temporarily store content so plugins can find it via app.pages.getItem()\n pageItem.content = content\n\n const elements = parseHTML(content, this.options.ignoreByAttribute, this.options.skipRenderByAttribute, (errorData) => this._handleError(errorData))\n\n // Shallow clone page object to avoid polluting state across builds\n pageContext = {\n ...originalDocument.page,\n meta: { ...originalDocument.page.meta }\n }\n const pageState = {\n ...originalDocument.state,\n page: pageContext\n }\n\n const mappedContext = await this._triggerPluginHook('onPageSet', {\n elements,\n state: pageState,\n page: pageContext,\n data: pageItem\n })\n\n const fullPath = Object.assign({}, mappedContext.data.path, {\n pages: this.options.path.pages,\n components: this.options.path.components\n })\n /** @type {CoraliteComponent & CoraliteComponentResult} */\n // @ts-ignore\n component = {\n // @ts-ignore\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: this.options.ignoreByAttribute || []\n }\n\n } else {\n // Deep clone the document to ensure thread safety\n component = cloneComponentInstance(originalDocument)\n component.ignoreByAttribute = component.ignoreByAttribute || this.options.ignoreByAttribute || []\n\n // Ensure pageContext is correctly initialized from cloned component\n pageContext = component.page\n }\n\n // Merge state into component\n Object.assign(component.state, state)\n\n // Initialize Render Context\n const session = this._createSession(buildId)\n // @ts-ignore\n session.mode = this.options.mode\n\n const mappedSession = await this._triggerPluginHook('onBeforePageRender', {\n component,\n state,\n page: pageContext,\n session\n })\n\n const mappedComponent = mappedSession.component\n const mappedSessionObject = mappedSession.session\n\n // reassign the top-level state object in case it was modified\n state = mappedSession.state\n\n // @ts-ignore\n mappedSessionObject.mode = this.options.mode\n\n // remove temporary elements\n removeElements(mappedComponent.tempElements, false)\n\n await this._processCustomElementsInPage(mappedComponent, originalDocument, state, mappedSessionObject, pageContext)\n\n const { head: headElement, body: bodyElement } = findHeadAndBody(mappedComponent.root)\n\n if (this.options.externalStyles && this.options.externalStyles.length > 0) {\n injectExternalStyles(mappedComponent.root, headElement, this.options.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: {\n id: 'coralite-components'\n },\n children: []\n })\n\n const selectors = Array.from(mappedSessionObject.componentTags)\n selectors.push('c-token')\n const selector = selectors.join(', ')\n layoutStyleElement.children.push(createCoraliteTextNode({\n type: 'text',\n data: `${selector} { 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\n // Build instances object for script manager\n /** @type {Object.<string, InstanceContext>} */\n const instances = {}\n const componentIds = new Set()\n for (const key in scripts) {\n if (Object.prototype.hasOwnProperty.call(scripts, key)) {\n const script = scripts[key]\n componentIds.add(script.componentId)\n // extending script content with templateId and values\n instances[script.id] = {\n instanceId: script.id,\n componentId: script.componentId,\n page: script.page,\n state: script.state\n }\n }\n }\n\n // Generate a deterministic cache key based on the sorted list of components required by this page\n const cacheKey = Array.from(componentIds).sort().join(',')\n\n let scriptResult\n if (scriptResultCache.has(cacheKey)) {\n scriptResult = scriptResultCache.get(cacheKey)\n } else {\n // Wrap hydration state in AST-safe normalization to prevent circularity\n /** @type {Object.<string, InstanceContext>} **/\n const normalizedInstances = {}\n for (const [id, instance] of Object.entries(instances)) {\n normalizedInstances[id] = {\n ...instance,\n state: normalizeObjectFunctions(instance.state, astTransformer)\n }\n }\n\n // Use script manager to compile all instances\n scriptResult = await this._scriptManager.compileAllInstances(normalizedInstances, this.options.mode)\n scriptResultCache.set(cacheKey, scriptResult)\n\n // Store the asset results in the coralite instance to be saved later\n if (!this.outputFiles) {\n this.outputFiles = {}\n }\n Object.assign(this.outputFiles, scriptResult.outputFiles)\n }\n\n if (!scriptResult.manifest['chunk-shared']) {\n this._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\n const chunkManifest = { ...scriptResult.manifest }\n delete chunkManifest['chunk-shared']\n\n const base = this.options.baseURL.endsWith('/') ? this.options.baseURL : this.options.baseURL + '/'\n const scriptContent = generateClientRuntime({\n base,\n sharedChunkPath: scriptResult.manifest['chunk-shared'],\n chunkManifest\n })\n\n const hydrationData = {}\n for (const [id, instance] of Object.entries(instances)) {\n const contextId = instance.instanceId\n if (instance.state && Object.keys(instance.state).length > 0) {\n // Ensure state is normalized to remove circular AST nodes before JSON serialization\n hydrationData[contextId] = 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\n const scriptElement = createCoraliteElement({\n type: 'tag',\n name: 'script',\n parent: bodyElement,\n attribs: {\n type: 'module'\n },\n children: []\n })\n\n scriptElement.children.push(createCoraliteTextNode({\n type: 'text',\n data: scriptContent,\n parent: scriptElement\n }))\n\n bodyElement.children.push(scriptElement)\n }\n\n // remove skip render elements\n removeElements(mappedComponent.skipRenderElements, true)\n\n if (!mappedSessionObject.scripts.content[mappedComponent.path.pathname]) {\n injectReadinessScript(mappedComponent.root, headElement, false)\n }\n\n let rawHTML = ''\n // render document\n rawHTML = this.transform(mappedComponent.root)\n\n\n yield {\n type: 'page',\n path: mappedComponent.path,\n content: rawHTML,\n duration: performance.now() - startTime,\n session\n }\n\n // Explicitly nullify large objects to help GC\n if (isProduction) {\n mappedComponent.root = null\n mappedComponent.customElements = null\n mappedComponent.tempElements = null\n mappedComponent.skipRenderElements = null\n }\n\n if (isProduction) {\n // In production, we can discard the yielded content from the item\n // but we must keep the result object (minus the AST) for metadata and rebuilds.\n delete pageItem.content\n }\n\n // Explicitly nullify render context contents to help GC\n session.state = null\n session.styles = null\n session.scripts = null\n if (session.source) {\n session.source.contextInstances = null\n session.source = null\n }\n }\n } finally {\n this._renderQueues.delete(buildId)\n }\n}\n\n/**\n * @callback BuildPageHandler\n * @param {CoraliteResult} result - The rendered output document for a specific page.\n * @returns {Promise<any> | any} The transformed result to be collected (falsy values are filtered).\n */\n\n/**\n * Compiles pages and collects the results with controlled concurrency.\n * Can optionally transform each result via a callback before collecting.\n *\n * @overload\n * @param {string | string[]} [path] - The target directory or an array of specific page paths to build.\n * @returns {Promise<CoraliteResult[]>} A Promise that resolves to an array of build results.\n *\n * @overload\n * @param {BuildPageHandler} callback - A function invoked for each page to transform the result.\n * @returns {Promise<CoraliteResult[]>} A Promise that resolves to an array of build results.\n *\n * @overload\n * @param {string | string[]} [path] - The target directory or an array of specific page paths to build.\n * @param {Object} [options] - Configuration options for the build process.\n * @param {number} [options.maxConcurrent=availableParallelism] - The maximum number of concurrent file write operations.\n * @param {AbortSignal} [options.signal] - An AbortSignal to cancel the build operation.\n * @param {Object} [options.variables] - Local variables for the page\n * @returns {Promise<CoraliteResult[]>} A Promise that resolves to an array of build results.\n *\n * @overload\n * @param {string | string[]} [path] - The target directory or an array of specific page paths to build.\n * @param {BuildPageHandler} callback - A function invoked for each page to transform the result.\n * @returns {Promise<any[]>} A Promise that resolves to an array of the transformed results.\n *\n * @overload\n * @param {string | string[]} [path] - The target directory or an array of specific page paths to build.\n * @param {Object} [options] - Configuration options for the build process.\n * @param {number} [options.maxConcurrent=availableParallelism] - The maximum number of concurrent file write operations.\n * @param {AbortSignal} [options.signal] - An AbortSignal to cancel the build operation.\n * @param {BuildPageHandler} callback - A function invoked for each page to transform the result.\n * @returns {Promise<any[]>} A Promise that resolves to an array of the transformed results.\n *\n * @example\n * // Build and get all results\n * const results = await coralite.build('./dist')\n * // results is CoraliteResult[]\n *\n * // Build and transform results\n * const titles = await coralite.build('./dist', (result) => {\n * return result.path\n * })\n */\nCoralite.prototype.build = async function (...args) {\n const startTime = performance.now()\n let path = args[0]\n let options\n let callback\n\n // add callback since there are no options\n if (typeof args[0] === 'function') {\n path = null\n callback = args[0]\n } else if (typeof args[1] === 'function') {\n callback = args[1]\n } else {\n options = args[1]\n callback = args[2]\n }\n\n if (!options) {\n options = {}\n }\n\n const mappedBeforeBuild = await this._triggerPluginHook('onBeforeBuild', {\n path,\n options\n })\n\n path = mappedBeforeBuild.path\n options = mappedBeforeBuild.options\n\n // Add options with defaults\n const signal = options?.signal\n const maxConcurrent = options?.maxConcurrent || availableParallelism()\n const variables = options?.variables\n\n // Initialize the limiter\n const limit = pLimit(maxConcurrent)\n const executing = new Set()\n const results = []\n let buildError = null\n const isStreaming = !!callback\n\n try {\n for await (const result of this._generatePages(path, variables)) {\n // Check for immediate cancellation\n if (signal?.aborted) {\n throw signal.reason\n }\n\n // Backpressure - don't pull more data than we can process\n if (executing.size >= limit.concurrency) {\n await Promise.race(executing)\n }\n\n const task = limit(async () => {\n // Exit early if build was cancelled while in queue\n if (signal?.aborted) {\n throw signal.reason\n }\n\n // Trigger onAfterPageRender hooks using the aggregate method\n const additionalPages = await this._triggerPluginAggregateHook('onAfterPageRender', {\n result,\n session: result.session\n })\n\n const items = [result]\n\n // Process any dynamically generated pages returned by the plugins\n for (const newPage of additionalPages) {\n if (newPage && newPage.path && newPage.content) {\n // Mock path data for dynamically generated pages if needed\n if (typeof newPage.path === 'string') {\n newPage.path = {\n pathname: newPage.path,\n filename: join(newPage.path),\n dirname: dirname(newPage.path)\n }\n }\n items.push(newPage)\n }\n }\n\n const finalResults = []\n\n for (const item of items) {\n if (typeof callback === 'function') {\n const transformed = await callback(item)\n if (transformed) {\n finalResults.push(transformed)\n }\n } else {\n finalResults.push(item)\n }\n }\n\n return finalResults\n })\n\n executing.add(task)\n\n // Clean up task\n task.then((callbackResults) => {\n if (callbackResults && callbackResults.length) {\n results.push(...callbackResults)\n }\n\n executing.delete(task)\n }).catch((err) => {\n executing.delete(task)\n\n this._handleError({\n level: 'ERR',\n message: err.message,\n error: err\n })\n })\n }\n\n await Promise.all(executing)\n\n return results\n\n } catch (error) {\n // Clean up - If one fails or we abort, wait for pending to settle\n await Promise.allSettled(executing)\n\n let finalError = error\n\n if (error.name === 'AbortError') {\n this._handleError({\n level: 'WARN',\n message: 'Build cancelled by user.'\n })\n }\n\n if (error instanceof Error) {\n error.message = `Build failed: ${error.message}`\n finalError = error\n } else {\n finalError = new Error(`Build failed: ${error.message}`, { cause: error })\n }\n\n buildError = finalError\n throw finalError\n } finally {\n const duration = performance.now() - startTime\n await this._triggerPluginHook('onAfterBuild', {\n results,\n error: buildError,\n duration\n })\n\n // Clean up to save memory\n }\n}\n\n/**\n * Compiles and saves pages to disk\n *\n * @param {string | string[]} [path] - Optional page path(s) to build\n * @param {Object} [options] - Build configuration\n * @param {number} [options.maxConcurrent=10] - Max concurrent file writes (min 1, max 100)\n * @param {AbortSignal} [options.signal] - AbortSignal\n * @returns {Promise<{ path: string, duration: number }[]>} Array of saved file paths\n * @example\n * // Build entire site with default concurrency (10 files)\n * await coralite.save()\n *\n * // Build specific pages with custom concurrency\n * await coralite.save(['blog/*'], { maxConcurrent: 5 })\n */\nCoralite.prototype.save = async function (path, options = {}) {\n const signal = options?.signal\n const createdDir = {}\n\n if (!this.options.output) {\n throw new Error('Coralite instance must be configured with an \"output\" option to use save()')\n }\n\n const output = this.options.output\n\n const results = []\n await this.build(path, options, async (result) => {\n let relativeDir, outDir, outFile, contentToWrite\n\n // It's a standard HTML page\n relativeDir = relative(this.options.path.pages, result.path.dirname)\n outDir = join(output, relativeDir)\n outFile = join(outDir, result.path.filename)\n contentToWrite = result.content\n\n if (!createdDir[outDir]) {\n await mkdir(outDir, { recursive: true })\n\n createdDir[outDir] = true\n }\n\n // Pass signal to writeFile so Node can stop the I/O immediately\n await writeFile(outFile, contentToWrite, { signal })\n\n results.push({\n path: outFile,\n duration: result.duration\n })\n\n // Return undefined to prevent build() from accumulating redundant results\n return undefined\n })\n\n // Write ESM script assets generated during the build phase\n if (this.outputFiles) {\n const assetsDir = join(output, 'assets', 'js')\n if (!createdDir[assetsDir]) {\n await mkdir(assetsDir, { recursive: true })\n createdDir[assetsDir] = true\n }\n\n const assetWrites = Object.values(this.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 })\n createdDir[outDir] = true\n }\n\n await writeFile(outFile, file.text, { signal })\n results.push({\n path: outFile,\n duration: 0\n })\n })\n\n await Promise.all(assetWrites)\n }\n\n return results\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} returns raw HTML\n */\nCoralite.prototype.transform = function (root, options) {\n // @ts-ignore\n return render(root, {\n decodeEntities: false,\n ...options\n })\n}\n\n/**\n * Adds a page to the current render queue.\n * @param {string|CoraliteCollectionItem} value - The path to a page or a CoraliteCollectionItem to add to the render queue.\n * @param {string} buildId - The unique identifier for the current build process.\n */\nCoralite.prototype.addRenderQueue = async function (value, buildId) {\n if (!buildId) {\n throw new Error('addRenderQueue requires a buildId')\n }\n\n const queue = this._renderQueues.get(buildId)\n\n if (!queue) {\n throw new Error('addRenderQueue - buildId not found: \"' + buildId + '\"')\n }\n\n if (typeof value === 'string') {\n const component = this.pages.getItem(value)\n\n if (!component) {\n throw new Error('addRenderQueue - unexpected page ID: \"' + value + '\"')\n }\n\n queue.push(component)\n } else if (isCoraliteCollectionItem(value)) {\n const component = await this.pages.setItem(value)\n\n // add render queue\n queue.push(component)\n }\n}\n\n/**\n * Retrieves page paths associated with a custom element components.\n *\n * @param {string} path - The original path potentially prefixed with the components directory.\n * @returns {string[]} An array of page paths linked to the custom element component.\n */\nCoralite.prototype.getPagePathsUsingCustomElement = function (path) {\n if (this.options.mode === 'production') {\n return []\n }\n\n // normalize path by removing the components directory prefix\n if (path.startsWith(this.options.path.components)) {\n path = path.substring(this.options.path.components.length + 1)\n }\n\n // retrieve the component item from the components collection\n const item = this.components.getItem(path)\n const pages = []\n\n // if component exists, collect associated page paths\n if (item) {\n const id = this._childCustomElements[item.result.id] || item.result.id\n const pageCustomElements = this._pageCustomElements[id]\n\n if (pageCustomElements) {\n // iterate over custom element paths linked to this component\n pageCustomElements.forEach(path => {\n pages.push(path)\n })\n }\n }\n\n return pages\n}\n\n/**\n * Recursively resolves imperative component dependencies, bundling their HTML and state for the client.\n *\n * @param {string[]} componentIds - Array of component IDs to process.\n * @param {CoraliteSession} session - The current build render context.\n * @param {CoralitePage} page - The global page object\n * @param {CoraliteComponentRoot} root - The root element of the component\n * @param {Object} state - The current token state and state available\n * @returns {Promise<void>}\n */\nCoralite.prototype._processDependentComponents = async function (componentIds, session, page, root, state = {}) {\n if (!componentIds?.length) {\n return\n }\n\n for (const id of componentIds) {\n if (this._scriptManager.sharedFunctions[id]) {\n continue\n }\n\n const moduleComponent = this.components.getItem(id)\n if (!moduleComponent) {\n continue\n }\n\n const module = cloneModuleInstance(moduleComponent.result)\n\n // Evaluate the script\n let scriptResult = {}\n if (module.script) {\n try {\n scriptResult = await this._evaluate({\n module,\n state,\n page,\n root,\n contextId: `dependent-${id}`,\n session\n })\n } catch (error) {\n throw this._createExecutionError(error, module, moduleComponent, page, `dependent-${id}`)\n }\n }\n\n // Safely extract __script__ metadata once\n const scriptMeta = scriptResult.__script__ || {}\n const templateAST = moduleComponent.result.template?.children || []\n const templateValues = moduleComponent.result.values || {}\n\n // Process CSS\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(\n rawCss, rootClasses, descendantClasses,\n (errorData) => this._handleError(errorData)\n )\n }\n const stylesHTML = moduleComponent.result._processedCss || ''\n\n // Construct script object\n const scriptObj = {\n content: 'function(){}',\n state: scriptMeta.state || {},\n slots: scriptMeta.slots || {}\n }\n\n let defaultValues = scriptMeta.defaultValues || {}\n let extractedComponents = []\n\n // Extract AST\n if (scriptResult.__script__) {\n const extractedScript = findAndExtractScript(module.script)\n if (extractedScript) {\n scriptObj.content = extractedScript.content\n scriptObj.lineOffset = (module.lineOffset || 0) + extractedScript.lineOffset\n extractedComponents = extractedScript.components || []\n }\n\n const extractedProperties = findAndExtractProperties(module.script)\n if (extractedProperties) {\n scriptObj.stateContent = extractedProperties.content\n scriptObj.stateLineOffset = (module.lineOffset || 0) + extractedProperties.lineOffset\n }\n }\n\n // Deduplicate nested components\n const declarativeComponents = (module.customElements || []).map(el => el.name)\n const nestedComponents = [...new Set([...declarativeComponents, ...extractedComponents])]\n\n scriptObj.components = nestedComponents\n\n // Extract tokens\n const extractTokens = (nodes) => nodes?.flatMap(n => n.tokens?.map(t => t.name) || []) || []\n const allTokens = new Set([\n ...extractTokens(module.values?.attributes),\n ...extractTokens(module.values?.textNodes)\n ])\n\n // Apply token values to defaultValues\n for (const token of allTokens) {\n if (defaultValues[token] === undefined && scriptResult[token] !== undefined) {\n defaultValues[token] = scriptResult[token]\n }\n }\n\n // Process Template Refs\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 this._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 // Recursively process deeper dependencies\n if (nestedComponents.length > 0) {\n const inheritedState = {\n ...state\n }\n delete inheritedState.__script__\n\n await this._processDependentComponents(nestedComponents, session, page, root, inheritedState)\n }\n\n }\n}\n\n/**\n * @param {Object} options\n * @param {string} options.id - id - Unique identifier for the component\n * @param {CoraliteModuleDefinitions} [options.state={}] - Token state available for replacement\n * @param {CoraliteElement} [options.element] - The original Custom Element node\n * @param {CoralitePage} options.page - The global page object\n * @param {any} options.root - The root element of the component\n * @param {string} [options.contextId] - Context Id\n * @param {number} [options.index] - Context index\n * @param {CoraliteSession} [options.session] - Render Context\n * @param {boolean} [options.noHydration] - Indicates if the component should be stripped and not hydrated\n * @param {boolean} [head=true] - Indicates if the current function call is for the head of the recursion\n * @returns {Promise<CoraliteElement | void>}\n */\nCoralite.prototype.createComponentElement = async function ({\n id,\n state = {},\n element,\n page,\n root,\n contextId,\n index,\n session,\n noHydration\n}, head = true) {\n if (!session) {\n session = this._createSession()\n }\n\n const moduleComponent = this.components.getItem(id)\n\n if (!moduleComponent || !moduleComponent.result) {\n return\n }\n\n const componentId = moduleComponent.result.id\n\n if (!contextId) {\n contextId = session.generateId(componentId)\n }\n\n const instanceId = contextId\n\n let componentState = { ...state }\n\n if (head) {\n if (element && element.attribs) {\n componentState = Object.assign(componentState, element.attribs)\n }\n\n // convert object keys to camel case format for consistent naming conventions\n // @ts-ignore\n componentState = cleanKeys(componentState)\n }\n\n /**\n * clone the component to avoid mutations during replacement process.\n * @type {CoraliteModule}\n */\n const module = cloneModuleInstance(moduleComponent.result)\n\n const mappedComponentContext = await this._triggerPluginHook('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 })\n componentState = mappedComponentContext.state\n\n const result = module.template\n\n if (module.styles.length) {\n const attributeName = 'data-style-selector'\n const selector = module.id\n\n // Check if styles have been processed for this component\n if (!moduleComponent.result._processedCss) {\n const rawCss = module.styles.join('\\n')\n\n const { rootClasses, descendantClasses } = moduleComponent.result\n\n // Transform CSS\n moduleComponent.result._processedCss = await transformCss(rawCss, rootClasses, descendantClasses, (errorData) => this._handleError(errorData))\n }\n\n // Add styles to session (idempotent for the build)\n if (!session.styles.has(selector)) {\n session.styles.set(selector, moduleComponent.result._processedCss)\n }\n\n // Inject attribute into component root elements\n const value = selector\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\n // Handle existing attribute value\n child.attribs[attributeName] = value\n }\n }\n }\n\n // merge state from component script\n if (module.script) {\n let scriptResult = {}\n\n try {\n const evaluationState = Object.assign({}, componentState)\n\n scriptResult = await this._evaluate({\n module,\n element,\n state: evaluationState,\n page,\n root: element || root,\n contextId,\n session,\n noHydration\n })\n } catch (error) {\n throw this._createExecutionError(error, module, moduleComponent, page, contextId)\n }\n\n if (scriptResult && scriptResult.__script__ != null) {\n const extractedScript = findAndExtractScript(module.script)\n let extractedComponents = []\n\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 // Fallback for when script extraction fails (shouldn't happen with valid defineComponent)\n // Ensure we don't crash\n scriptResult.__script__.lineOffset = module.lineOffset || 0\n scriptResult.__script__.content = 'function(){}'\n }\n\n // Extract processed styles from the module\n const stylesHTML = moduleComponent.result._processedCss || ''\n\n const templateAST = moduleComponent.result.template.children\n const templateValues = moduleComponent.result.values\n const componentTokens = {}\n\n for (let i = 0; i < module.values.attributes.length; i++) {\n const item = module.values.attributes[i]\n for (let j = 0; j < item.tokens.length; j++) {\n componentTokens[item.tokens[j].name] = true\n }\n }\n for (let i = 0; i < module.values.textNodes.length; i++) {\n const item = module.values.textNodes[i]\n for (let j = 0; j < item.tokens.length; j++) {\n componentTokens[item.tokens[j].name] = true\n }\n }\n\n // Include all computed state into default values so client script can use them\n const componentDefaultValues = scriptResult.__script__.defaultValues || {}\n if (componentState) {\n for (const token of Object.keys(componentTokens)) {\n if (componentDefaultValues[token] === undefined && componentState[token] !== undefined) {\n componentDefaultValues[token] = componentState[token]\n }\n }\n }\n\n // Dynamically load any components dynamically inserted if they are explicitly mentioned\n const declarativeComponents = (module.customElements || []).map(el => el.name)\n const mergedComponents = Array.from(new Set([...declarativeComponents, ...extractedComponents]))\n\n if (scriptResult.__script__) {\n scriptResult.__script__.components = mergedComponents\n }\n\n // Register component script with script manager\n this._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 // Merge the evaluated script results into the state context for dependencies\n const inheritedState = Object.assign({}, state)\n delete inheritedState.__script__\n\n await this._processDependentComponents(mergedComponents, session, page, root, inheritedState)\n }\n\n // Ensure state object exists in scriptResult\n if (!scriptResult.__script__.state) {\n scriptResult.__script__.state = {}\n }\n\n\n // Store instance data for script manager\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\n delete scriptResult.__script__\n }\n\n componentState = Object.assign(componentState, scriptResult)\n }\n\n session.state[contextId] = componentState\n\n // replace tokens in the component with their state from `componentState` object and store them into computed value array for later use if needed (e.g., to be injected back).\n for (let i = 0; i < module.values.attributes.length; i++) {\n const item = module.values.attributes[i]\n\n for (let j = 0; j < item.tokens.length; j++) {\n const token = item.tokens[j]\n let value = componentState[token.name]\n\n if (value == null) {\n // console.error('Token \"' + token.name +'\" was empty used on \"' + moduleComponent.id + '\"')\n value = ''\n }\n\n replaceToken({\n type: 'attribute',\n node: item.element,\n attribute: item.name,\n content: token.content,\n value\n })\n }\n }\n\n for (let i = 0; i < module.values.textNodes.length; i++) {\n const item = module.values.textNodes[i]\n\n for (let j = 0; j < item.tokens.length; j++) {\n const token = item.tokens[j]\n let value = componentState[token.name]\n\n if (value == null) {\n // console.error('Token \"' + token.name +'\" was empty used on \"' + moduleComponent.id + '\"')\n value = ''\n }\n\n replaceToken({\n type: 'textNode',\n node: item.textNode,\n content: token.content,\n value\n })\n }\n }\n\n // replace nested customElements\n const customElements = module.customElements\n let childIndex\n\n // Update slot elements for all custom elements\n for (let i = 0; i < customElements.length; i++) {\n const customElement = customElements[i]\n\n // update slot elements\n if (customElement.children\n && customElement.children.length\n && !customElement.slots.length\n ) {\n for (let j = 0; j < customElement.children.length; j++) {\n const node = customElement.children[j]\n const slotElement = {\n name: 'default',\n node\n }\n\n // @ts-ignore\n if (isCoraliteElement(node) && node.attribs.slot) {\n // add named slot\n // @ts-ignore\n slotElement.name = node.attribs.slot\n }\n\n customElement.slots.push(slotElement)\n }\n }\n }\n\n const createComponentTasks = []\n\n for (let i = 0; i < customElements.length; i++) {\n const customElement = customElements[i]\n\n // Skip if this element is a direct child of another custom element.\n // The parent will handle processing this element via slots.\n // @ts-ignore\n if (customElement.parent && customElement.parent.slots) {\n continue\n }\n\n const childContextId = session.generateId(customElement.name)\n const currentProperties = session.state[childContextId] || {}\n\n let childState = { ...state }\n\n // append custom attributes to state\n if (typeof customElement.attribs === 'object') {\n const attribValues = cleanKeys(customElement.attribs)\n\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\n const childNoHydration = noHydration || (customElement.attribs && 'no-hydration' in customElement.attribs)\n\n createComponentTasks.push(\n this.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\n const results = await Promise.all(createComponentTasks)\n\n for (let i = 0; i < results.length; i++) {\n const { childComponentElement, customElement, childContextId, noHydration: childNoHydration } = results[i]\n\n // replace custom element with component\n if (childComponentElement && typeof childComponentElement === 'object') {\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 for (let j = 0; j < childComponentElement.children.length; j++) {\n childComponentElement.children[j].parent = parent\n }\n parent.children.splice(elementIndex, 1, ...childComponentElement.children)\n }\n }\n } else {\n customElement.children = childComponentElement.children\n for (let j = 0; j < customElement.children.length; j++) {\n customElement.children[j].parent = customElement\n }\n\n if (!customElement.attribs) {\n customElement.attribs = {}\n }\n customElement.attribs['data-cid'] = childContextId\n\n session.componentTags.add(customElement.name)\n }\n }\n }\n\n await this._replaceSlots(id, element, module, contextId, 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 index = parent.children.indexOf(node)\n if (index !== -1) {\n for (let j = 0; j < node.children.length; j++) {\n node.children[j].parent = parent\n }\n parent.children.splice(index, 1, ...node.children)\n }\n }\n } else {\n stack.push(...(node.children || []))\n }\n }\n }\n }\n\n const mappedAfterContext = await this._triggerPluginHook('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 })\n return mappedAfterContext.result\n}\n\n\n/**\n * Replaces slot elements in a component with provided content\n * @internal\n * @param {string} id - Component ID\n * @param {CoraliteElement} element - The original Custom Element node\n * @param {CoraliteModule} module - The component module configuration\n * @param {string} contextId - Instance context ID\n * @param {Object} state - The component state\n * @param {CoralitePage} page - Active page object\n * @param {any} root - The component root element\n * @param {number} index - Index of element\n * @param {CoraliteSession} session - Rendering state\n * @param {boolean} noHydration - No hydration flag\n * @returns {Promise<void>} Resolves when slots are successfully replaced\n */\nCoralite.prototype._replaceSlots = async function (id, element, module, contextId, state, page, root, index, session, noHydration) {\n const slots = module.slotElements ? module.slotElements[id] : null\n\n if (!slots) {\n return\n }\n\n const slotChildren = {}\n const slotNames = Object.keys(slots)\n\n for (let i = 0; i < slotNames.length; i++) {\n const slotName = slotNames[i]\n slotChildren[slotName] = []\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\n if (slot) {\n if (elementSlotContent.node.attribs) {\n delete elementSlotContent.node.attribs.slot\n }\n\n slotChildren[slotName].push(elementSlotContent.node)\n }\n }\n }\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\n const slotIndex = slot.element.parent.children.indexOf(slot.element)\n\n const emptySlot = slotNodes.filter(node => {\n return node.type !== 'text' || (node.data && node.data.trim().length > 0)\n })\n\n if (!emptySlot.length) {\n slotNodes = slot.element.children || []\n } else {\n const startIndex = slotNodes.length - 1\n\n for (let i = startIndex; i > -1; i--) {\n const node = slotNodes[i]\n\n if (node.name) {\n const slotComponentItem = this.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\n if (typeof node.attribs === 'object') {\n session.state[slotContextId] = {\n ...currentProperties,\n ...state,\n ...attribValues\n }\n } else {\n session.state[slotContextId] = Object.assign(currentProperties, state)\n }\n\n const childNoHydration = noHydration || (node.attribs && 'no-hydration' in node.attribs)\n\n const componentElement = await this.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)\n\n if (componentElement) {\n if (childNoHydration) {\n const parent = node.parent\n if (parent && parent.children) {\n const elementIndex = parent.children.indexOf(node)\n if (elementIndex !== -1) {\n for (let j = 0; j < componentElement.children.length; j++) {\n componentElement.children[j].parent = parent\n }\n parent.children.splice(elementIndex, 1, ...componentElement.children)\n }\n }\n } else {\n node.children = componentElement.children\n for (let j = 0; j < node.children.length; j++) {\n node.children[j].parent = node\n }\n\n if (!node.attribs) {\n node.attribs = {}\n }\n node.attribs['data-cid'] = slotContextId\n\n session.componentTags.add(node.name)\n }\n }\n }\n }\n }\n }\n\n slot.element.children = slotNodes\n\n for (let j = 0; j < slotNodes.length; j++) {\n if (slotNodes[j]) {\n slotNodes[j].parent = slot.element\n }\n }\n }\n}\n\n\n/**\n * Generates a custom module linker callback for the Node.js VM context.\n * This linker is responsible for resolving `import` statements inside evaluated\n * component scripts. It intercepts specific specifiers to provide synthetic modules\n * for `coralite` and plugins, correctly resolves relative paths against\n * the component's directory, and safely bridges external Node.js modules into the VM sandbox.\n *\n * @internal\n * @param {CoraliteFilePath} path - The file path metadata of the component currently being evaluated. Used as the base for relative imports.\n * @param {CoralitePluginContext} context - Contextual rendering data and state to be exposed when a script imports `'coralite'`.\n * @returns {(specifier: string, referencingModule: import('node:vm').Module, extra: { attributes: any }) => Promise<import('node:vm').Module>} The async linker function used by the VM module.\n */\nCoralite.prototype._moduleLinker = function (path, context) {\n const source = this._source\n const componentDirURL = pathToFileURL(resolve(path.dirname)).href\n\n /**\n * The linker callback invoked by the Node.js VM when an `import` is encountered.\n *\n * @param {string} specifier - The string path of the requested module (e.g., `'./utils.js'`, `'coralite'`).\n * @param {import('node:vm').Module} referencingModule - The VM Module instance that initiated the import request.\n * @param {{ attributes: Record<string, string> }} extra - Additional import constraints, such as import attributes (e.g., `with { type: 'json' }`).\n * @returns {Promise<import('node:vm').Module>} A promise that resolves to a newly instantiated VM SourceTextModule containing the requested exports.\n */\n return async (specifier, referencingModule, extra) => {\n const { SourceTextModule } = await import('node:vm')\n const originalSpecifier = specifier\n\n if (source.plugins[specifier]) {\n const plugin = source.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 })\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 })\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 })\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 const { SourceTextModule } = await import('node:vm')\n\n return new SourceTextModule(exportModule, {\n context: referencingModule.context\n })\n } catch (error) {\n throw new Error(error)\n }\n }\n}\n\n/**\n * Parses a Coralite module script and evaluates it using SourceTextModule.\n *\n * @param {Object} data\n * @param {CoraliteModule} data.module - The Coralite module to parse\n * @param {CoraliteModuleDefinitions} data.state - Replacement tokens for the component\n * @param {CoralitePage} data.page - The global page object\n * @param {any} data.root - The Coralite module to parse\n * @param {string} data.contextId - Context Id\n * @param {CoraliteSession} data.session - Render Context\n * @param {boolean} data.noHydration - No hydration flag\n *\n * @returns {Promise<CoraliteModuleDefinitions>}\n */\nCoralite.prototype._evaluateDevelopment = async function ({\n module,\n state,\n page,\n root,\n contextId,\n session,\n noHydration\n}) {\n const { SourceTextModule } = await import('node:vm')\n\n if (!SourceTextModule) {\n throw new Error('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: this,\n noHydration\n }\n\n const cachedBoundPlugins = this._bindPlugins(this._source.plugins, context)\n\n session.source.currentSourceContextId = contextId\n session.source.contextInstances[contextId] = context\n\n const boundDefineComponent = (options) => this._defineComponent(options, context)\n\n // Protect fundamental constructors from being extracted and polluting the context realm\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 const usedGlobals = extractGlobals(module.script)\n const contextGlobals = {\n __coralite_context__: context,\n __coralite_plugins__: cachedBoundPlugins,\n __coralite_utils__: this._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 // Create a fresh context for the module\n const contextifiedObject = createContext(contextGlobals)\n\n const moduleComponent = this.components.getItem(module.id)\n\n // create a new source text module with the provided script content, configuration options, and context\n const script = new SourceTextModule(module.script, {\n initializeImportMeta (meta) {\n meta.url = pathToFileURL(resolve(moduleComponent.path.pathname)).href\n },\n lineOffset: module.lineOffset,\n identifier: resolve(moduleComponent.path.pathname),\n context: contextifiedObject\n })\n\n const linker = this._moduleLinker(moduleComponent.path, context)\n\n await script.link(linker)\n\n // evaluate the module to execute its content\n try {\n await script.evaluate()\n } catch (error) {\n throw this._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 an error if no default export was found\n throw new Error(`Module \"${module.id}\" has no default export`)\n}\n\n/**\n * Parses a Coralite module script and compiles it into JavaScript using esbuild.\n * Replaces node:vm SourceTextModule for better performance and memory management.\n *\n * @param {Object} data\n * @param {CoraliteModule} data.module - The Coralite module to parse\n * @param {CoraliteModuleDefinitions} data.state - Replacement tokens for the component\n * @param {CoralitePage} data.page - The global page object\n * @param {any} data.root - The Coralite module to parse\n * @param {string} data.contextId - Context Id\n * @param {CoraliteSession} data.session - Render Context\n * @param {boolean} data.noHydration - No hydration flag\n *\n * @returns {Promise<CoraliteModuleDefinitions>}\n */\nCoralite.prototype._evaluateProduction = async function ({\n module,\n state,\n page,\n root,\n contextId,\n session,\n noHydration\n}) {\n const context = {\n state: state || {},\n page,\n root,\n module,\n id: contextId,\n session,\n app: this,\n noHydration\n }\n\n session.source.currentSourceContextId = contextId\n session.source.contextInstances[contextId] = context\n\n // Retrieve Template and check cache\n const moduleComponent = this.components.getItem(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 // Transform using esbuild\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 // Create a require function anchored to the moduleComponent's file path to resolve relative imports\n const fileRequire = createRequire(resolve(moduleComponent.path.pathname))\n\n let cachedBoundPlugins = null\n\n const customRequire = (id) => {\n const isCoralite = id === 'coralite'\n const isUtils = id === 'coralite/utils'\n const isPlugin = this._source.plugins[id] !== undefined\n\n // Handle internal coralite imports\n if (isCoralite || isUtils || isPlugin) {\n // Lazily bind plugins once per evaluation\n if (!cachedBoundPlugins) {\n cachedBoundPlugins = this._bindPlugins(this._source.plugins, context)\n }\n\n if (isCoralite) {\n return {\n ...context,\n defineComponent: (options) => this._defineComponent(options, context),\n default: {\n ...context,\n defineComponent: (options) => this._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 ...this._source.utils,\n default: this._source.utils\n }\n }\n }\n\n return fileRequire(id)\n }\n\n // Mock the CommonJS 'module' object to capture exports\n const moduleMock = { exports: {} }\n\n // Create the function. We pass 'coralite' explicitly to support the\n // \"export const document = coralite.document\" pattern found in existing modules.\n // Arguments: module, exports, require, coralite\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 // Execute the function with our mocks and context\n try {\n await fn(moduleMock, moduleMock.exports, customRequire, context)\n } catch (error) {\n throw this._createExecutionError(error, module, moduleComponent, page, contextId)\n }\n\n if (moduleMock.exports.default != null) {\n return moduleMock.exports.default\n }\n\n throw new Error(`Module \"${module.id}\" has no default export`)\n}\n\n/**\n * Parses a Coralite module script and compiles it into JavaScript using esbuild.\n * Replaces node:vm SourceTextModule for better performance and memory management.\n *\n * @param {Object} data -\n * @param {CoraliteModule} data.module - The Coralite module to parse\n * @param {CoraliteModuleDefinitions} data.state - Replacement tokens for the component\n * @param {CoralitePage} data.page - The global page object\n * @param {any} data.element - The Coralite module to parse\n * @param {string} data.contextId - Context Id\n * @param {CoraliteSession} data.session - Render Context\n *\n * @returns {Promise<CoraliteModuleDefinitions>}\n */\nCoralite.prototype._evaluate = async function (options) {\n if (this.options.mode === 'development') {\n return this._evaluateDevelopment(options)\n }\n return this._evaluateProduction(options)\n}\n\n/**\n * Executes a collecting plugin hook where the results are aggregated.\n * Useful for hooks like `onAfterPageRender` that return new pages to be added to the build.\n *\n * @internal\n * @param {string} name - The name of the hook to trigger.\n * @param {any} contextData - Context to pass to the callbacks (not mutated by this function).\n * @returns {Promise<any[]>} A flattened array of all results returned by the plugins.\n */\nCoralite.prototype._triggerPluginAggregateHook = async function (name, contextData) {\n const pluginHooks = this._plugins.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](contextData)\n\n if (result !== null && typeof result === 'object' && typeof result.then === 'function') {\n result = await result\n }\n\n // Collect the results into a flat array instead of merging them into the context\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 * @internal Executes Phase 1 of plugin exports with the given context.\n *\n * @param {Object} plugins - The plugins object\n * @param {Object} context - The context object to pass to Phase 1\n * @returns {Object} The Phase 2 functions\n */\nCoralite.prototype._bindPlugins = function (plugins, context) {\n const cachedBoundPlugins = {}\n\n for (const key in plugins) {\n const pluginExports = plugins[key]\n if (pluginExports !== null && typeof pluginExports === 'object') {\n const pluginObj = {}\n for (const prop in pluginExports) {\n if (typeof pluginExports[prop] === 'function') {\n pluginObj[prop] = pluginExports[prop](context)\n } else {\n pluginObj[prop] = pluginExports[prop]\n }\n }\n cachedBoundPlugins[key] = pluginObj\n } else {\n cachedBoundPlugins[key] = pluginExports\n }\n }\n\n return cachedBoundPlugins\n}\n\n/**\n * @template T\n *\n * Executes all plugin callbacks registered under the specified hook name sequentially.\n *\n * @internal\n *\n * @param {'onPageSet'|'onPageUpdate'|'onPageDelete'|'onComponentSet'|'onComponentUpdate'|'onComponentDelete'|'onBeforePageRender'|'onAfterPageRender'|'onBeforeComponentRender'|'onAfterComponentRender'|'onBeforeBuild'|'onAfterBuild'} name - The name of the hook to trigger.\n * @param {T} initialData - Data to pass to each callback function.\n * @returns {Promise<T>} A promise that resolves to the merged data.\n */\nCoralite.prototype._triggerPluginHook = async function (name, initialData) {\n const pluginHooks = this._plugins.hooks[name]\n\n if (!pluginHooks || pluginHooks.length === 0) {\n return initialData\n }\n\n // Clone initial data once to prevent accidental root-level mutations\n // leaking backwards if a plugin still mutates it directly.\n let currentData = typeof initialData === 'object' && initialData !== null\n ? {\n ...initialData,\n app: this\n }\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 the plugin returned a patch, the framework handles the mapping\n if (result !== undefined && result !== null) {\n currentData = mergePluginState(currentData, result)\n }\n }\n\n return currentData\n}\n\n/**\n * Registers a callback function under the specified hook name.\n *\n * @internal\n *\n * @param {'onPageSet'|'onPageUpdate'|'onPageDelete'|'onComponentSet'|'onComponentUpdate'|'onComponentDelete'|'onBeforePageRender'|'onAfterPageRender'|'onBeforeComponentRender'|'onAfterComponentRender'|'onBeforeBuild'|'onAfterBuild'} name - The name of the hook to register the callback with.\n * @param {Function} callback - The callback function to be executed when the hook is triggered.\n */\nCoralite.prototype._addPluginHook = function (name, callback) {\n if (typeof callback !== 'function') {\n throw new Error(`Plugin hook \"${name}\" must be a function`)\n }\n\n if (this._plugins.hooks[name]) {\n this._plugins.hooks[name].push(callback)\n }\n}\n\n/**\n * Replaces a custom element with its template content.\n * @internal\n * @param {CoraliteElement} coraliteElement - The custom element to be replaced.\n * @param {CoraliteElement} element - The target element to replace the tokens with.\n */\nCoralite.prototype._replaceCustomElementWithTemplate = function (coraliteElement, element) {\n coraliteElement.children = element.children\n for (let j = 0; j < coraliteElement.children.length; j++) {\n coraliteElement.children[j].parent = coraliteElement\n }\n}\n\n/**\n * Process a token value - parse HTML strings and handle custom elements\n * @internal\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 */\nCoralite.prototype._processTokenValue = async function (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 for (let j = 0; j < componentElement.children.length; j++) {\n componentElement.children[j].parent = parent\n }\n parent.children.splice(elementIndex, 1, ...componentElement.children)\n }\n }\n } else {\n customElement.children = componentElement.children\n for (let j = 0; j < customElement.children.length; j++) {\n customElement.children[j].parent = customElement\n }\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\n/**\n * This function defines a component for the Coralite framework.\n * It is used to register components with their associated state and scripts.\n * @internal\n * @param {Object} options - Configuration options for the component\n * @param {CoralitePluginContext} context - The evaluation context\n * @returns {Promise<Object>} A promise resolving to the module state associated with this component.\n */\nCoralite.prototype._defineComponent = async function (options, context) {\n const {\n attributes,\n data,\n getters,\n slots,\n script\n } = options\n\n const {\n state: initialState,\n module,\n root\n } = context\n\n // Validate attributes\n if (attributes) {\n for (const [key, value] of Object.entries(attributes)) {\n if (value.type === Object || value.type === Array) {\n throw new Error(`Coralite Error: Component \"${module.id}\" defines attribute \"${key}\" as ${value.type.name}. Object and Array types are blocked in attributes for V1.1 to prevent \"JSON-in-HTML\" anti-patterns. Use the data() block for complex data.`)\n }\n }\n }\n\n let state = Object.assign({}, initialState)\n\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 state.__script__ = {\n attributes: serializableAttributes,\n getters: getters || {},\n state: {},\n defaultValues: {},\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 // Coerce existing attribute values\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(context)\n if (dataResult) {\n state.__script__.data = dataResult\n Object.assign(state, dataResult)\n // Ensure data results are added to state.__script__.state for serialization to client\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 // Ensure getters use read-only proxy to preemptively throw error if developer attempts to mutate the state.\n const result = getter(roState, { signal: new AbortController().signal })\n\n if (result && typeof result.then === 'function') {\n state[key] = await result\n } else {\n state[key] = result\n }\n\n // Add getter result to state.__script__.state so it's serialized to the client\n if (state.__script__ && state.__script__.state) {\n state.__script__.state[key] = state[key]\n }\n }\n }\n\n // process computed slots\n if (slots) {\n for (const name in slots) {\n if (Object.prototype.hasOwnProperty.call(slots, name)) {\n const computedSlot = slots[name]\n\n const methodKey = `slots_method_${name}`\n state.__script__.defaultValues[methodKey] = computedSlot\n\n // slot content to compute\n const slotContent = []\n // new slot elements\n const elementSlots = []\n\n // @ts-ignore\n if (root && root.slots) {\n // @ts-ignore\n for (let j = 0; j < root.slots.length; j++) {\n // @ts-ignore\n const slot = root.slots[j]\n\n if (slot.name === name) {\n // slot content to compute\n slotContent.push(slot.node)\n } else {\n elementSlots.push(slot)\n }\n }\n }\n\n // compute slot nodes\n const result = computedSlot(slotContent, state) || slotContent\n\n // append new slot nodes\n if (typeof result === 'string') {\n // process string result through unified processor\n const processedResult = await this._processTokenValue(result, {\n ...context,\n state,\n createComponentElement: context.app.createComponentElement,\n noHydration: context.noHydration\n })\n\n if (Array.isArray(processedResult)) {\n // multiple nodes from parsed HTML\n for (let j = 0; j < processedResult.length; j++) {\n elementSlots.push({\n name,\n node: processedResult[j]\n })\n }\n } else {\n // single text node\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\n if (\n isCoraliteElement(node)\n || isCoraliteTextNode(node)\n || isCoraliteComment(node)\n ) {\n elementSlots.push({\n name,\n node\n })\n } else {\n throw new Error('Unexpected slot value, expected a node but found: '\n + '\\n result: ' + JSON.stringify(node)\n + '\\n path: \"' + module.path.pathname + '\"')\n }\n }\n }\n\n // update element slots\n if (root) {\n // @ts-ignore\n root.slots = elementSlots\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\n // include state used in script\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\n Object.assign(state.__script__.state, args)\n }\n } else {\n // remove custom element parent script\n delete state.__script__\n }\n\n return state\n}\n\nconst coraliteInternalProperty = {\n enumerable: false,\n configurable: false,\n writable: false\n}\n\nObject.defineProperty(Coralite.prototype, '_defaultOnError', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_handleError', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_createExecutionError', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_createSession', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_processCustomElementsInPage', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_generatePages', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_processDependentComponents', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_replaceSlots', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_moduleLinker', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_evaluateDevelopment', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_evaluateProduction', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_evaluate', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_triggerPluginAggregateHook', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_triggerPluginHook', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_bindPlugins', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_addPluginHook', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_replaceCustomElementWithTemplate', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_processTokenValue', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_defineComponent', coraliteInternalProperty)\n\nexport default Coralite\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,WAAW,qBAAqB,cAAc,wBAAwB,sBAAsB,0BAA0B,gBAAgB,kBAAkB,0BAA0B,sBAAsB;AACjN,SAAS,aAAa,cAAc,yBAAyB;AAC7D,SAAS,iBAAiB,sBAAsB,cAAc,uBAAuB,iBAAiB,gBAAgB,wBAAwB;AAC9I,SAAS,6BAA6B;AACtC,SAAS,WAAW,aAAa,eAAe,sBAAsB;AACtE,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB,YAAY,mBAAmB,qBAAqB;AAC7E,SAAS,OAAO,iBAAiB;AACjC,SAAS,SAAS,MAAM,WAAW,UAAU,eAAe;AAC5D,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAC1B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,4BAA4B;AACrC,OAAO,YAAY;AACnB,OAAO,YAAY;AACnB,SAAS,uBAAuB,8BAA8B;AAC9D,OAAO,wBAAwB;AAC/B,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AAyC7B,SAAS,SAAU;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP;AACF,GAAG;AAED,MAAI,CAAC,cAAc,OAAO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SAAS,WAAW,+BAA+B,wBAAwB;AACjG,OAAO,eAAe,SAAS,WAAW,iBAAiB,wBAAwB;AACnF,OAAO,eAAe,SAAS,WAAW,iBAAiB,wBAAwB;AACnF,OAAO,eAAe,SAAS,WAAW,wBAAwB,wBAAwB;AAC1F,OAAO,eAAe,SAAS,WAAW,uBAAuB,wBAAwB;AACzF,OAAO,eAAe,SAAS,WAAW,aAAa,wBAAwB;AAC/E,OAAO,eAAe,SAAS,WAAW,+BAA+B,wBAAwB;AACjG,OAAO,eAAe,SAAS,WAAW,sBAAsB,wBAAwB;AACxF,OAAO,eAAe,SAAS,WAAW,gBAAgB,wBAAwB;AAClF,OAAO,eAAe,SAAS,WAAW,kBAAkB,wBAAwB;AACpF,OAAO,eAAe,SAAS,WAAW,qCAAqC,wBAAwB;AACvG,OAAO,eAAe,SAAS,WAAW,sBAAsB,wBAAwB;AACxF,OAAO,eAAe,SAAS,WAAW,oBAAoB,wBAAwB;AAEtF,IAAO,mBAAQ;",
|
|
4
|
+
"sourcesContent": ["import { cleanKeys, cloneModuleInstance, replaceToken, cloneComponentInstance, findAndExtractScript, findAndExtractProperties, extractGlobals, mergePluginState, normalizeObjectFunctions, astTransformer } from './utils.js'\nimport { getHtmlFile, getHtmlFiles, discoverHtmlFiles } from './html.js'\nimport { findHeadAndBody, injectExternalStyles, injectStyles, injectReadinessScript, injectImportMap, removeElements, resolvePageQueue } from './render-helpers.js'\nimport { generateClientRuntime } from './client-runtime.js'\nimport { parseHTML, parseModule, createElement, createTextNode } from './parse.js'\nimport { transformCss } from './style-transform.js'\nimport { ScriptManager } from './script-manager.js'\nimport { metadataPlugin, refsPlugin, staticAssetPlugin, testingPlugin } from '#plugins'\nimport { mkdir, writeFile } from 'node:fs/promises'\nimport { dirname, join, normalize, relative, resolve } from 'node:path'\nimport { createRequire } from 'node:module'\nimport { transform } from 'esbuild'\nimport {\n isCoraliteElement,\n isCoraliteCollectionItem,\n isCoraliteComment,\n isCoraliteTextNode\n} from './type-helper.js'\nimport { CoraliteError } from './errors.js'\nimport { pathToFileURL } from 'node:url'\nimport { availableParallelism } from 'node:os'\nimport render from 'dom-serializer'\nimport pLimit from 'p-limit'\nimport { createCoraliteElement, createCoraliteTextNode } from './dom.js'\nimport CoraliteCollection from './collection.js'\nimport { randomUUID } from 'node:crypto'\nimport { createContext } from 'node:vm'\nimport { createReadOnlyProxy } from './utils.js'\n\n/**\n * @import {\n * CoraliteElement,\n * CoraliteAnyNode,\n * CoraliteModule,\n * CoraliteResult,\n * CoraliteModuleDefinitions,\n * CoraliteComponent,\n * CoraliteCollectionItem,\n * CoraliteComponentRoot,\n * CoraliteCollectionEventSet,\n * CoraliteComponentResult,\n * InstanceContext,\n * CoraliteConfig,\n * CoraliteFilePath,\n * CoralitePage,\n * CoraliteSession,\n * CoralitePluginContext,\n * Attribute\n * } from '../types/index.js'\n */\n\n/**\n * @import {DomSerializerOptions} from 'dom-serializer'\n */\n\n/**\n * @class\n * @param {CoraliteConfig} options\n * @example\n * const coralite = new Coralite({\n * components: './path/to/components',\n * pages: './path/to/pages',\n * mode: 'development',\n * plugins: [myPlugin],\n * ignoreByAttribute: [{ name: 'data-ignore', value: 'true' }],\n * skipRenderByAttribute: ['data-skip-render']\n * });\n */\nexport function Coralite ({\n components,\n pages,\n plugins,\n assets,\n externalStyles,\n baseURL = '/',\n ignoreByAttribute,\n skipRenderByAttribute,\n onError,\n mode = 'production',\n output\n}) {\n // Validate required parameters\n if (!components && typeof components !== 'string') {\n throw new Error('Coralite constructor requires \"components\" option to be defined')\n }\n\n if (!pages && typeof pages !== 'string') {\n throw new Error('Coralite constructor requires \"pages\" option to be defined')\n }\n\n if (!plugins) {\n plugins = []\n }\n\n const path = {\n components: normalize(components),\n pages: normalize(pages)\n }\n\n this._onErrorCallback = onError\n\n // instance options\n this.options = {\n components,\n pages,\n plugins,\n assets,\n externalStyles,\n baseURL,\n ignoreByAttribute,\n skipRenderByAttribute,\n mode,\n path,\n output: output ? normalize(output) : undefined\n }\n\n /** @type {Map<string, CoraliteCollectionItem[]>} */\n this._renderQueues = new Map()\n\n // plugins\n this._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\n // Initialize script manager\n this._scriptManager = new ScriptManager(this.options)\n\n // source context\n this._source = {\n utils: {\n parseHTML: (string, ignoreByAttribute = this.options.ignoreByAttribute, skipRenderByAttribute = this.options.skipRenderByAttribute) => parseHTML(string, ignoreByAttribute, skipRenderByAttribute, (errorData) => this._handleError(errorData)),\n parseModule: (string, options) => parseModule(string, {\n ignoreByAttribute: this.options.ignoreByAttribute,\n skipRenderByAttribute: this.options.skipRenderByAttribute,\n onError: (errorData) => this._handleError(errorData),\n ...options\n }),\n getHtmlFiles,\n getHtmlFile,\n createElement: (options) => createElement({\n onError: (errorData) => this._handleError(errorData),\n ...options\n }),\n createTextNode,\n transform: this.transform\n },\n plugins: {\n }\n }\n\n // place core plugin first\n if (this.options.mode === 'development') {\n plugins.unshift(testingPlugin)\n }\n plugins.unshift(refsPlugin, metadataPlugin)\n\n if (assets) {\n plugins.unshift(staticAssetPlugin(assets))\n }\n\n const source = this._source\n // iterate over each plugin and register its hooks and modules in the Coralite source context.\n for (let i = 0; i < plugins.length; i++) {\n const plugin = plugins[i]\n\n if (plugin.server) {\n // set plugin method\n if (plugin.server.exports !== undefined) {\n source.plugins[plugin.name] = plugin.server.exports\n }\n\n // queue any components provided by the plugin to be registered.\n if (plugin.server.components && Array.isArray(plugin.server.components)) {\n for (let j = 0; j < plugin.server.components.length; j++) {\n this._plugins.components.push(plugin.server.components[j])\n }\n }\n\n // add the plugin's hooks to the appropriate Coralite hook lists.\n if (plugin.server.onPageSet) {\n this._addPluginHook('onPageSet', plugin.server.onPageSet)\n }\n if (plugin.server.onPageDelete) {\n this._addPluginHook('onPageDelete', plugin.server.onPageDelete)\n }\n if (plugin.server.onPageUpdate) {\n this._addPluginHook('onPageUpdate', plugin.server.onPageUpdate)\n }\n if (plugin.server.onComponentSet) {\n this._addPluginHook('onComponentSet', plugin.server.onComponentSet)\n }\n if (plugin.server.onComponentDelete) {\n this._addPluginHook('onComponentDelete', plugin.server.onComponentDelete)\n }\n if (plugin.server.onComponentUpdate) {\n this._addPluginHook('onComponentUpdate', plugin.server.onComponentUpdate)\n }\n if (plugin.server.onBeforePageRender) {\n this._addPluginHook('onBeforePageRender', plugin.server.onBeforePageRender)\n }\n if (plugin.server.onAfterPageRender) {\n this._addPluginHook('onAfterPageRender', plugin.server.onAfterPageRender)\n }\n if (plugin.server.onBeforeComponentRender) {\n this._addPluginHook('onBeforeComponentRender', plugin.server.onBeforeComponentRender)\n }\n if (plugin.server.onAfterComponentRender) {\n this._addPluginHook('onAfterComponentRender', plugin.server.onAfterComponentRender)\n }\n if (plugin.server.onBeforeBuild) {\n this._addPluginHook('onBeforeBuild', plugin.server.onBeforeBuild)\n }\n if (plugin.server.onAfterBuild) {\n this._addPluginHook('onAfterBuild', plugin.server.onAfterBuild)\n }\n }\n\n // register client-side plugin if provided\n if (plugin.client) {\n this._scriptManager.use(plugin.client)\n }\n }\n\n const propertyDescriptors = {\n enumerable: false,\n configurable: false,\n writable: false\n }\n\n const enumerablePropertyDescriptors = {\n enumerable: true,\n configurable: false,\n writable: true\n }\n\n Object.defineProperties(this, {\n options: { ...enumerablePropertyDescriptors },\n _plugins: { ...propertyDescriptors },\n _scriptManager: { ...propertyDescriptors },\n _source: { ...propertyDescriptors },\n _onErrorCallback: { ...propertyDescriptors },\n _renderQueues: { ...propertyDescriptors }\n })\n}\n\n/**\n * Initialises the Coralite instance.\n * @returns {Promise<void>}\n */\nCoralite.prototype.initialise = async function () {\n this.components = await getHtmlFiles({\n path: this.options.components,\n recursive: true,\n type: 'component',\n onFileSet: async (value) => {\n if (value.content === undefined) {\n value.content = await getHtmlFile(value.path.pathname)\n }\n\n const component = parseModule(value.content, {\n ignoreByAttribute: this.options.ignoreByAttribute,\n skipRenderByAttribute: this.options.skipRenderByAttribute,\n onError: (errorData) => this._handleError(errorData)\n })\n\n // abort component add\n if (!component.isTemplate) {\n return\n }\n\n const mappedComponent = await this._triggerPluginHook('onComponentSet', component)\n\n return {\n type: 'component',\n id: mappedComponent.id,\n value: mappedComponent\n }\n },\n onFileUpdate: async (value) => {\n if (value.content === undefined) {\n value.content = await getHtmlFile(value.path.pathname)\n }\n\n const component = parseModule(value.content, {\n ignoreByAttribute: this.options.ignoreByAttribute,\n skipRenderByAttribute: this.options.skipRenderByAttribute,\n onError: (errorData) => this._handleError(errorData)\n })\n\n // abort component update\n if (!component.isTemplate) {\n return\n }\n\n return await this._triggerPluginHook('onComponentUpdate', component)\n },\n onFileDelete: async (value) => {\n await this._triggerPluginHook('onComponentDelete', value)\n }\n })\n\n // register plugin components\n await Promise.all(this._plugins.components.map(c => this.components.setItem(c)))\n\n // collection of custom elements used by pages\n /** @type {Object.<string, Set<string>>} */\n const pageCustomElements = {}\n /** @type {Object.<string, string>} */\n const childCustomElements = {}\n\n /**\n * @type {Object.<string, Set<string>>}\n */\n this._pageCustomElements = pageCustomElements\n /**\n * @type {Object.<string, string>}\n */\n this._childCustomElements = childCustomElements\n\n Object.defineProperties(this, {\n _pageCustomElements: {\n enumerable: false,\n configurable: false,\n writable: false\n },\n _childCustomElements: {\n enumerable: false,\n configurable: false,\n writable: false\n }\n })\n\n /** @type {CoraliteCollectionEventSet} */\n const onFileSet = async (data) => {\n // Determine the root path based on the data type\n let rootPath = this.options.path.pages\n\n if (data.type === 'component') {\n rootPath = this.options.path.components\n }\n\n // Convert relative file path to a URL pathname format\n const urlPathname = pathToFileURL(join('/', relative(rootPath, data.path.pathname))).pathname\n\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: {}\n }\n\n // define a set of context state for component rendering\n /** @type {any} */\n const state = {\n ...data.state,\n page\n }\n\n // If discovered only, skip parsing and plugin hooks to save memory\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, this.options.ignoreByAttribute, this.options.skipRenderByAttribute, (errorData) => this._handleError(errorData))\n\n // track parent-child relationship between custom elements (only in development)\n if (this.options.mode !== 'production') {\n const customElementsList = elements ? (elements.customElements || []) : []\n for (let i = 0; i < customElementsList.length; i++) {\n const customElement = customElementsList[i]\n const name = customElement.name\n let item = pageCustomElements[name]\n\n if (!item) {\n pageCustomElements[name] = new Set()\n item = pageCustomElements[name]\n\n const component = this.components.getItem(name)\n\n if (\n component &&\n component.result &&\n component.result.customElements &&\n component.result.customElements.length\n ) {\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\n // process nested elements recursively\n const component = this.components.getItem(element.name)\n\n if (\n component &&\n component.result &&\n component.result.customElements &&\n component.result.customElements.length\n ) {\n // push nested custom elements to stack for processing\n stack.push(component.result.customElements)\n }\n }\n }\n }\n }\n }\n\n // add page to custom element collection\n item.add(data.path.pathname)\n }\n }\n\n const mappedContext = await this._triggerPluginHook('onPageSet', {\n elements,\n state: state,\n page,\n data\n })\n\n const isProduction = this.options.mode === 'production'\n\n if (isProduction && data.physical) {\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 // In production, we discard the heavy AST nodes after initialization hooks to save memory.\n // They will be re-parsed on-demand during the build/render phase.\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 onPageUpdate = async (newValue, oldValue) => {\n if (this.options.mode === 'production') {\n return newValue.result\n }\n\n let newCustomElements\n\n if (!newValue.result) {\n const result = await onFileSet(newValue)\n\n newValue.result = result.value\n newCustomElements = result.value.customElements\n } else {\n newCustomElements = newValue.result.customElements\n }\n\n let oldElements = (oldValue.result.customElements || []).slice()\n\n const mappedContext = await this._triggerPluginHook('onPageUpdate', {\n elements: newValue.result,\n page: newValue.result.page,\n newValue,\n oldValue\n })\n\n // Assign back the mapped elements to result so that rendering uses the updated AST and state\n newValue.result = mappedContext.elements\n newValue = mappedContext.newValue\n\n for (let i = 0; i < newCustomElements.length; i++) {\n const newElement = newCustomElements[i]\n\n let hasElement = false\n\n for (let j = 0; j < oldElements.length; j++) {\n const oldElement = oldElements[j]\n\n if (newElement.name === oldElement.name) {\n hasElement = true\n oldElements.splice(j, 1)\n break\n }\n }\n\n if (!hasElement) {\n let item = pageCustomElements[newElement.name]\n\n if (!item) {\n pageCustomElements[newElement.name] = new Set()\n item = pageCustomElements[newElement.name]\n }\n\n // add page to custom element collection\n item.add(newValue.path.pathname)\n }\n }\n\n for (let i = 0; i < oldElements.length; i++) {\n const pageCustomElement = pageCustomElements[oldElements[i].name]\n\n // remove page from custom element reference\n pageCustomElement.delete(newValue.path.pathname)\n }\n\n return newValue.result\n }\n\n const onPageDelete = async (value) => {\n if (this.options.mode === 'production') {\n return\n }\n\n value = await this._triggerPluginHook('onPageDelete', value)\n\n // remove page from custom element reference\n if (value && value.result && value.result.customElements) {\n const customElements = value.result.customElements\n\n for (let i = 0; i < customElements.length; i++) {\n const pageCustomElement = pageCustomElements[customElements[i]]\n\n if (pageCustomElement) {\n pageCustomElement.delete(value.path.pathname)\n }\n }\n }\n }\n\n this.pages = new CoraliteCollection({\n rootDir: this.options.pages,\n onSet: onFileSet,\n onUpdate: onPageUpdate,\n onDelete: onPageDelete\n })\n\n const isProduction = this.options.mode === 'production'\n\n if (isProduction) {\n for await (const file of discoverHtmlFiles({\n path: this.options.pages,\n recursive: true,\n type: 'page',\n discoverOnly: false\n })) {\n // Process file for metadata, then it will be discarded because isProduction is true in onFileSet\n await this.pages.setItem(file)\n }\n } else {\n /** @type {CoraliteCollection} */\n await getHtmlFiles({\n path: this.options.pages,\n recursive: true,\n type: 'page',\n discoverOnly: false,\n collection: this.pages\n })\n }\n}\n\n/**\n * Default error handler for the Coralite instance.\n * @internal\n * @param {Object} data\n * @param {'WARN' | 'ERR' | 'LOG'} data.level\n * @param {string} data.message\n * @param {Error} [data.error]\n */\nCoralite.prototype._defaultOnError = function ({ level, message, error }) {\n if (level === 'ERR') {\n if (error) {\n throw error\n }\n throw new Error(message)\n } else if (level === 'WARN') {\n console.warn(message)\n } else {\n console.log(message)\n }\n}\n\n/**\n * Internal error handler for the Coralite instance.\n * @internal\n * @param {Object} data - The error or log data object containing the details of the event.\n * @param {'WARN' | 'ERR' | 'LOG'} data.level - The severity level of the message.\n * @param {string} data.message - The descriptive message to be logged or thrown.\n * @param {Error} [data.error] - An optional Error instance providing a stack trace.\n */\nCoralite.prototype._handleError = function (data) {\n if (this._onErrorCallback) {\n this._onErrorCallback(data)\n } else {\n this._defaultOnError(data)\n }\n}\n\n/**\n * Helper to create CoraliteError during component execution\n * @internal\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 */\nCoralite.prototype._createExecutionError = function (error, module, moduleComponent, page, instanceId) {\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 })\n}\n\n/**\n * Creates a render context for the build process.\n * @internal\n * @param {string} [buildId] - The unique identifier for the build process.\n * @returns {CoraliteSession}\n */\nCoralite.prototype._createSession = function (buildId) {\n return {\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/**\n * Compiles specified page(s) by rendering their document content and measuring render time.\n * Processes pages based on provided path(s), replacing custom elements with components,\n * and returns rendered results with performance metrics.\n *\n * @internal\n *\n * @param {string | string[]} [path] - Path to a single page or array of page paths relative to the pages directory. If omitted, compiles all pages.\n * @param {Object} [state] - Properties to be passed to the page\n * @returns {AsyncGenerator<CoraliteResult>}\n */\n\n/**\n * Processes custom elements found within a generated page context\n * @internal\n * @param {CoraliteComponent & CoraliteComponentResult} mappedComponent - The compiled component instance\n * @param {CoraliteComponentResult} originalDocument - The original document mapping\n * @param {Object} state - Local component state\n * @param {CoraliteSession} mappedSessionObject - Global rendering state\n * @returns {Promise<void>} Resolves when the elements are processed\n */\nCoralite.prototype._processCustomElementsInPage = async function (mappedComponent, originalDocument, state, mappedSessionObject, pageContext) {\n const customElementsList = mappedComponent.customElements || []\n for (let i = 0; i < customElementsList.length; i++) {\n const customElement = customElementsList[i]\n\n const contextId = mappedSessionObject.generateId(customElement.name)\n const currentProperties = mappedSessionObject.state[contextId] || {}\n\n if (typeof customElement.attribs === 'object') {\n mappedSessionObject.state[contextId] = {\n ...currentProperties,\n ...state,\n ...mappedComponent.state,\n ...customElement.attribs\n }\n } else {\n mappedSessionObject.state[contextId] = {\n ...currentProperties,\n ...state,\n ...mappedComponent.state\n }\n }\n\n const noHydration = customElement.attribs && 'no-hydration' in customElement.attribs\n const componentElement = await this.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 })\n\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 for (let j = 0; j < componentElement.children.length; j++) {\n componentElement.children[j].parent = parent\n }\n parent.children.splice(elementIndex, 1, ...componentElement.children)\n }\n }\n } else {\n customElement.children = componentElement.children\n for (let j = 0; j < customElement.children.length; j++) {\n customElement.children[j].parent = customElement\n }\n\n if (!customElement.attribs) {\n customElement.attribs = {}\n }\n customElement.attribs['data-cid'] = contextId\n\n mappedSessionObject.componentTags.add(customElement.name)\n }\n }\n }\n}\n\nCoralite.prototype._generatePages = async function* (path, state = {}) {\n const isProduction = this.options.mode === 'production'\n\n if (path) {\n const paths = Array.isArray(path) ? path : [path]\n for (const p of paths) {\n if (!this.pages.getItem(p)) {\n try {\n await this.pages.setItem(p)\n } catch (e) {\n // Path might not be a direct file, could be a glob or dir handled by resolvePageQueue\n }\n }\n }\n }\n\n const queue = resolvePageQueue(this.pages, path)\n\n const buildId = randomUUID()\n this._renderQueues.set(buildId, queue)\n const scriptResultCache = new Map()\n\n try {\n const activeQueue = this._renderQueues.get(buildId)\n\n for (let q = 0; q < activeQueue.length; q++) {\n const pageItem = activeQueue[q]\n const startTime = performance.now()\n\n /** @type {CoraliteComponent & CoraliteComponentResult} */\n const originalDocument = pageItem.result\n\n /** @type {CoraliteComponent & CoraliteComponentResult} */\n // @ts-ignore\n let component\n let pageContext = originalDocument.page\n\n // If the page was discovery-only initialized (no root AST), parse it on-demand\n if (!originalDocument.root) {\n let content = pageItem.content\n if (content === undefined) {\n try {\n content = await getHtmlFile(pageItem.path.pathname)\n } catch (e) {\n // Re-check content in case it was set concurrently or by a plugin (virtual pages)\n if (pageItem.content !== undefined) {\n content = pageItem.content\n } else {\n throw e\n }\n }\n }\n\n // Temporarily store content so plugins can find it via app.pages.getItem()\n pageItem.content = content\n\n const elements = parseHTML(content, this.options.ignoreByAttribute, this.options.skipRenderByAttribute, (errorData) => this._handleError(errorData))\n\n // Shallow clone page object to avoid polluting state across builds\n pageContext = {\n ...originalDocument.page,\n meta: { ...originalDocument.page.meta }\n }\n const pageState = {\n ...originalDocument.state,\n page: pageContext\n }\n\n const mappedContext = await this._triggerPluginHook('onPageSet', {\n elements,\n state: pageState,\n page: pageContext,\n data: pageItem\n })\n\n const fullPath = Object.assign({}, mappedContext.data.path, {\n pages: this.options.path.pages,\n components: this.options.path.components\n })\n /** @type {CoraliteComponent & CoraliteComponentResult} */\n // @ts-ignore\n component = {\n // @ts-ignore\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: this.options.ignoreByAttribute || []\n }\n\n } else {\n // Deep clone the document to ensure thread safety\n component = cloneComponentInstance(originalDocument)\n component.ignoreByAttribute = component.ignoreByAttribute || this.options.ignoreByAttribute || []\n\n // Ensure pageContext is correctly initialized from cloned component\n pageContext = component.page\n }\n\n // Merge state into component\n Object.assign(component.state, state)\n\n // Initialize Render Context\n const session = this._createSession(buildId)\n // @ts-ignore\n session.mode = this.options.mode\n\n const mappedSession = await this._triggerPluginHook('onBeforePageRender', {\n component,\n state,\n page: pageContext,\n session\n })\n\n const mappedComponent = mappedSession.component\n const mappedSessionObject = mappedSession.session\n\n // reassign the top-level state object in case it was modified\n state = mappedSession.state\n\n // @ts-ignore\n mappedSessionObject.mode = this.options.mode\n\n // remove temporary elements\n removeElements(mappedComponent.tempElements, false)\n\n await this._processCustomElementsInPage(mappedComponent, originalDocument, state, mappedSessionObject, pageContext)\n\n const { head: headElement, body: bodyElement } = findHeadAndBody(mappedComponent.root)\n\n if (this.options.externalStyles && this.options.externalStyles.length > 0) {\n injectExternalStyles(mappedComponent.root, headElement, this.options.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: {\n id: 'coralite-components'\n },\n children: []\n })\n\n const selectors = Array.from(mappedSessionObject.componentTags)\n selectors.push('c-token')\n const selector = selectors.join(', ')\n layoutStyleElement.children.push(createCoraliteTextNode({\n type: 'text',\n data: `${selector} { 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\n // Build instances object for script manager\n /** @type {Object.<string, InstanceContext>} */\n const instances = {}\n const componentIds = new Set()\n for (const key in scripts) {\n if (Object.prototype.hasOwnProperty.call(scripts, key)) {\n const script = scripts[key]\n componentIds.add(script.componentId)\n // extending script content with templateId and values\n instances[script.id] = {\n instanceId: script.id,\n componentId: script.componentId,\n page: script.page,\n state: script.state\n }\n }\n }\n\n // Generate a deterministic cache key based on the sorted list of components required by this page\n const cacheKey = Array.from(componentIds).sort().join(',')\n\n let scriptResult\n if (scriptResultCache.has(cacheKey)) {\n scriptResult = scriptResultCache.get(cacheKey)\n } else {\n // Wrap hydration state in AST-safe normalization to prevent circularity\n /** @type {Object.<string, InstanceContext>} **/\n const normalizedInstances = {}\n for (const [id, instance] of Object.entries(instances)) {\n normalizedInstances[id] = {\n ...instance,\n state: normalizeObjectFunctions(instance.state, astTransformer)\n }\n }\n\n // Use script manager to compile all instances\n scriptResult = await this._scriptManager.compileAllInstances(normalizedInstances, this.options.mode)\n scriptResultCache.set(cacheKey, scriptResult)\n\n // Store the asset results in the coralite instance to be saved later\n if (!this.outputFiles) {\n this.outputFiles = {}\n }\n Object.assign(this.outputFiles, scriptResult.outputFiles)\n }\n\n if (!scriptResult.manifest['chunk-shared']) {\n this._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\n const chunkManifest = { ...scriptResult.manifest }\n delete chunkManifest['chunk-shared']\n\n const base = this.options.baseURL.endsWith('/') ? this.options.baseURL : this.options.baseURL + '/'\n const scriptContent = generateClientRuntime({\n base,\n sharedChunkPath: scriptResult.manifest['chunk-shared'],\n chunkManifest\n })\n\n const hydrationData = {}\n for (const [id, instance] of Object.entries(instances)) {\n const contextId = instance.instanceId\n if (instance.state && Object.keys(instance.state).length > 0) {\n // Ensure state is normalized to remove circular AST nodes before JSON serialization\n hydrationData[contextId] = 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\n const scriptElement = createCoraliteElement({\n type: 'tag',\n name: 'script',\n parent: bodyElement,\n attribs: {\n type: 'module'\n },\n children: []\n })\n\n scriptElement.children.push(createCoraliteTextNode({\n type: 'text',\n data: scriptContent,\n parent: scriptElement\n }))\n\n bodyElement.children.push(scriptElement)\n }\n\n // remove skip render elements\n removeElements(mappedComponent.skipRenderElements, true)\n\n if (!mappedSessionObject.scripts.content[mappedComponent.path.pathname]) {\n injectReadinessScript(mappedComponent.root, headElement, false)\n }\n\n let rawHTML = ''\n // render document\n rawHTML = this.transform(mappedComponent.root)\n\n\n yield {\n type: 'page',\n path: mappedComponent.path,\n content: rawHTML,\n duration: performance.now() - startTime,\n session\n }\n\n // Explicitly nullify large objects to help GC\n if (isProduction) {\n mappedComponent.root = null\n mappedComponent.customElements = null\n mappedComponent.tempElements = null\n mappedComponent.skipRenderElements = null\n }\n\n if (isProduction) {\n // In production, we can discard the yielded content from the item\n // but we must keep the result object (minus the AST) for metadata and rebuilds.\n delete pageItem.content\n }\n\n // Explicitly nullify render context contents to help GC\n session.state = null\n session.styles = null\n session.scripts = null\n if (session.source) {\n session.source.contextInstances = null\n session.source = null\n }\n }\n } finally {\n this._renderQueues.delete(buildId)\n }\n}\n\n/**\n * @callback BuildPageHandler\n * @param {CoraliteResult} result - The rendered output document for a specific page.\n * @returns {Promise<any> | any} The transformed result to be collected (falsy values are filtered).\n */\n\n/**\n * Compiles pages and collects the results with controlled concurrency.\n * Can optionally transform each result via a callback before collecting.\n *\n * @overload\n * @param {string | string[]} [path] - The target directory or an array of specific page paths to build.\n * @returns {Promise<CoraliteResult[]>} A Promise that resolves to an array of build results.\n *\n * @overload\n * @param {BuildPageHandler} callback - A function invoked for each page to transform the result.\n * @returns {Promise<CoraliteResult[]>} A Promise that resolves to an array of build results.\n *\n * @overload\n * @param {string | string[]} [path] - The target directory or an array of specific page paths to build.\n * @param {Object} [options] - Configuration options for the build process.\n * @param {number} [options.maxConcurrent=availableParallelism] - The maximum number of concurrent file write operations.\n * @param {AbortSignal} [options.signal] - An AbortSignal to cancel the build operation.\n * @param {Object} [options.variables] - Local variables for the page\n * @returns {Promise<CoraliteResult[]>} A Promise that resolves to an array of build results.\n *\n * @overload\n * @param {string | string[]} [path] - The target directory or an array of specific page paths to build.\n * @param {BuildPageHandler} callback - A function invoked for each page to transform the result.\n * @returns {Promise<any[]>} A Promise that resolves to an array of the transformed results.\n *\n * @overload\n * @param {string | string[]} [path] - The target directory or an array of specific page paths to build.\n * @param {Object} [options] - Configuration options for the build process.\n * @param {number} [options.maxConcurrent=availableParallelism] - The maximum number of concurrent file write operations.\n * @param {AbortSignal} [options.signal] - An AbortSignal to cancel the build operation.\n * @param {BuildPageHandler} callback - A function invoked for each page to transform the result.\n * @returns {Promise<any[]>} A Promise that resolves to an array of the transformed results.\n *\n * @example\n * // Build and get all results\n * const results = await coralite.build('./dist')\n * // results is CoraliteResult[]\n *\n * // Build and transform results\n * const titles = await coralite.build('./dist', (result) => {\n * return result.path\n * })\n */\nCoralite.prototype.build = async function (...args) {\n const startTime = performance.now()\n let path = args[0]\n let options\n let callback\n\n // add callback since there are no options\n if (typeof args[0] === 'function') {\n path = null\n callback = args[0]\n } else if (typeof args[1] === 'function') {\n callback = args[1]\n } else {\n options = args[1]\n callback = args[2]\n }\n\n if (!options) {\n options = {}\n }\n\n const mappedBeforeBuild = await this._triggerPluginHook('onBeforeBuild', {\n path,\n options\n })\n\n path = mappedBeforeBuild.path\n options = mappedBeforeBuild.options\n\n // Add options with defaults\n const signal = options?.signal\n const maxConcurrent = options?.maxConcurrent || availableParallelism()\n const variables = options?.variables\n\n // Initialize the limiter\n const limit = pLimit(maxConcurrent)\n const executing = new Set()\n const results = []\n let buildError = null\n const isStreaming = !!callback\n\n try {\n for await (const result of this._generatePages(path, variables)) {\n // Check for immediate cancellation\n if (signal?.aborted) {\n throw signal.reason\n }\n\n // Backpressure - don't pull more data than we can process\n if (executing.size >= limit.concurrency) {\n await Promise.race(executing)\n }\n\n const task = limit(async () => {\n // Exit early if build was cancelled while in queue\n if (signal?.aborted) {\n throw signal.reason\n }\n\n // Trigger onAfterPageRender hooks using the aggregate method\n const additionalPages = await this._triggerPluginAggregateHook('onAfterPageRender', {\n result,\n session: result.session\n })\n\n const items = [result]\n\n // Process any dynamically generated pages returned by the plugins\n for (const newPage of additionalPages) {\n if (newPage && newPage.path && newPage.content) {\n // Mock path data for dynamically generated pages if needed\n if (typeof newPage.path === 'string') {\n newPage.path = {\n pathname: newPage.path,\n filename: join(newPage.path),\n dirname: dirname(newPage.path)\n }\n }\n items.push(newPage)\n }\n }\n\n const finalResults = []\n\n for (const item of items) {\n if (typeof callback === 'function') {\n const transformed = await callback(item)\n if (transformed) {\n finalResults.push(transformed)\n }\n } else {\n finalResults.push(item)\n }\n }\n\n return finalResults\n })\n\n executing.add(task)\n\n // Clean up task\n task.then((callbackResults) => {\n if (callbackResults && callbackResults.length) {\n results.push(...callbackResults)\n }\n\n executing.delete(task)\n }).catch((err) => {\n executing.delete(task)\n\n this._handleError({\n level: 'ERR',\n message: err.message,\n error: err\n })\n })\n }\n\n await Promise.all(executing)\n\n return results\n\n } catch (error) {\n // Clean up - If one fails or we abort, wait for pending to settle\n await Promise.allSettled(executing)\n\n let finalError = error\n\n if (error.name === 'AbortError') {\n this._handleError({\n level: 'WARN',\n message: 'Build cancelled by user.'\n })\n }\n\n if (error instanceof Error) {\n error.message = `Build failed: ${error.message}`\n finalError = error\n } else {\n finalError = new Error(`Build failed: ${error.message}`, { cause: error })\n }\n\n buildError = finalError\n throw finalError\n } finally {\n const duration = performance.now() - startTime\n await this._triggerPluginHook('onAfterBuild', {\n results,\n error: buildError,\n duration\n })\n\n // Clean up to save memory\n }\n}\n\n/**\n * Compiles and saves pages to disk\n *\n * @param {string | string[]} [path] - Optional page path(s) to build\n * @param {Object} [options] - Build configuration\n * @param {number} [options.maxConcurrent=10] - Max concurrent file writes (min 1, max 100)\n * @param {AbortSignal} [options.signal] - AbortSignal\n * @returns {Promise<{ path: string, duration: number }[]>} Array of saved file paths\n * @example\n * // Build entire site with default concurrency (10 files)\n * await coralite.save()\n *\n * // Build specific pages with custom concurrency\n * await coralite.save(['blog/*'], { maxConcurrent: 5 })\n */\nCoralite.prototype.save = async function (path, options = {}) {\n const signal = options?.signal\n const createdDir = {}\n\n if (!this.options.output) {\n throw new Error('Coralite instance must be configured with an \"output\" option to use save()')\n }\n\n const output = this.options.output\n\n const results = []\n await this.build(path, options, async (result) => {\n let relativeDir, outDir, outFile, contentToWrite\n\n // It's a standard HTML page\n relativeDir = relative(this.options.path.pages, result.path.dirname)\n outDir = join(output, relativeDir)\n outFile = join(outDir, result.path.filename)\n contentToWrite = result.content\n\n if (!createdDir[outDir]) {\n await mkdir(outDir, { recursive: true })\n\n createdDir[outDir] = true\n }\n\n // Pass signal to writeFile so Node can stop the I/O immediately\n await writeFile(outFile, contentToWrite, { signal })\n\n results.push({\n path: outFile,\n duration: result.duration\n })\n\n // Return undefined to prevent build() from accumulating redundant results\n return undefined\n })\n\n // Write ESM script assets generated during the build phase\n if (this.outputFiles) {\n const assetsDir = join(output, 'assets', 'js')\n if (!createdDir[assetsDir]) {\n await mkdir(assetsDir, { recursive: true })\n createdDir[assetsDir] = true\n }\n\n const assetWrites = Object.values(this.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 })\n createdDir[outDir] = true\n }\n\n await writeFile(outFile, file.text, { signal })\n results.push({\n path: outFile,\n duration: 0\n })\n })\n\n await Promise.all(assetWrites)\n }\n\n return results\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} returns raw HTML\n */\nCoralite.prototype.transform = function (root, options) {\n // @ts-ignore\n return render(root, {\n decodeEntities: false,\n ...options\n })\n}\n\n/**\n * Adds a page to the current render queue.\n * @param {string|CoraliteCollectionItem} value - The path to a page or a CoraliteCollectionItem to add to the render queue.\n * @param {string} buildId - The unique identifier for the current build process.\n */\nCoralite.prototype.addRenderQueue = async function (value, buildId) {\n if (!buildId) {\n throw new Error('addRenderQueue requires a buildId')\n }\n\n const queue = this._renderQueues.get(buildId)\n\n if (!queue) {\n throw new Error('addRenderQueue - buildId not found: \"' + buildId + '\"')\n }\n\n if (typeof value === 'string') {\n const component = this.pages.getItem(value)\n\n if (!component) {\n throw new Error('addRenderQueue - unexpected page ID: \"' + value + '\"')\n }\n\n queue.push(component)\n } else if (isCoraliteCollectionItem(value)) {\n const component = await this.pages.setItem(value)\n\n // add render queue\n queue.push(component)\n }\n}\n\n/**\n * Retrieves page paths associated with a custom element components.\n *\n * @param {string} path - The original path potentially prefixed with the components directory.\n * @returns {string[]} An array of page paths linked to the custom element component.\n */\nCoralite.prototype.getPagePathsUsingCustomElement = function (path) {\n if (this.options.mode === 'production') {\n return []\n }\n\n // normalize path by removing the components directory prefix\n if (path.startsWith(this.options.path.components)) {\n path = path.substring(this.options.path.components.length + 1)\n }\n\n // retrieve the component item from the components collection\n const item = this.components.getItem(path)\n const pages = []\n\n // if component exists, collect associated page paths\n if (item) {\n const id = this._childCustomElements[item.result.id] || item.result.id\n const pageCustomElements = this._pageCustomElements[id]\n\n if (pageCustomElements) {\n // iterate over custom element paths linked to this component\n pageCustomElements.forEach(path => {\n pages.push(path)\n })\n }\n }\n\n return pages\n}\n\n/**\n * Recursively resolves imperative component dependencies, bundling their HTML and state for the client.\n *\n * @param {string[]} componentIds - Array of component IDs to process.\n * @param {CoraliteSession} session - The current build render context.\n * @param {CoralitePage} page - The global page object\n * @param {CoraliteComponentRoot} root - The root element of the component\n * @param {Object} state - The current token state and state available\n * @returns {Promise<void>}\n */\nCoralite.prototype._processDependentComponents = async function (componentIds, session, page, root, state = {}) {\n if (!componentIds?.length) {\n return\n }\n\n for (const id of componentIds) {\n if (this._scriptManager.sharedFunctions[id]) {\n continue\n }\n\n const moduleComponent = this.components.getItem(id)\n if (!moduleComponent) {\n continue\n }\n\n const module = cloneModuleInstance(moduleComponent.result)\n\n // Evaluate the script\n let scriptResult = {}\n if (module.script) {\n try {\n scriptResult = await this._evaluate({\n module,\n state,\n page,\n root,\n contextId: `dependent-${id}`,\n session\n })\n } catch (error) {\n throw this._createExecutionError(error, module, moduleComponent, page, `dependent-${id}`)\n }\n }\n\n // Safely extract __script__ metadata once\n const scriptMeta = scriptResult.__script__ || {}\n const templateAST = moduleComponent.result.template?.children || []\n const templateValues = moduleComponent.result.values || {}\n\n // Process CSS\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(\n rawCss, rootClasses, descendantClasses,\n (errorData) => this._handleError(errorData)\n )\n }\n const stylesHTML = moduleComponent.result._processedCss || ''\n\n // Construct script object\n const scriptObj = {\n content: 'function(){}',\n state: scriptMeta.state || {},\n slots: scriptMeta.slots || {}\n }\n\n let defaultValues = scriptMeta.defaultValues || {}\n let extractedComponents = []\n\n // Extract AST\n if (scriptResult.__script__) {\n const extractedScript = findAndExtractScript(module.script)\n if (extractedScript) {\n scriptObj.content = extractedScript.content\n scriptObj.lineOffset = (module.lineOffset || 0) + extractedScript.lineOffset\n extractedComponents = extractedScript.components || []\n }\n\n const extractedProperties = findAndExtractProperties(module.script)\n if (extractedProperties) {\n scriptObj.stateContent = extractedProperties.content\n scriptObj.stateLineOffset = (module.lineOffset || 0) + extractedProperties.lineOffset\n }\n }\n\n // Deduplicate nested components\n const declarativeComponents = (module.customElements || []).map(el => el.name)\n const nestedComponents = [...new Set([...declarativeComponents, ...extractedComponents])]\n\n scriptObj.components = nestedComponents\n\n // Extract tokens\n const extractTokens = (nodes) => nodes?.flatMap(n => n.tokens?.map(t => t.name) || []) || []\n const allTokens = new Set([\n ...extractTokens(module.values?.attributes),\n ...extractTokens(module.values?.textNodes)\n ])\n\n // Apply token values to defaultValues\n for (const token of allTokens) {\n if (defaultValues[token] === undefined && scriptResult[token] !== undefined) {\n defaultValues[token] = scriptResult[token]\n }\n }\n\n // Process Template Refs\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 this._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 // Recursively process deeper dependencies\n if (nestedComponents.length > 0) {\n const inheritedState = {\n ...state\n }\n delete inheritedState.__script__\n\n await this._processDependentComponents(nestedComponents, session, page, root, inheritedState)\n }\n\n }\n}\n\n/**\n * @param {Object} options\n * @param {string} options.id - id - Unique identifier for the component\n * @param {CoraliteModuleDefinitions} [options.state={}] - Token state available for replacement\n * @param {CoraliteElement} [options.element] - The original Custom Element node\n * @param {CoralitePage} options.page - The global page object\n * @param {CoraliteComponentRoot} [options.root] - The root element of the component\n * @param {string} [options.contextId] - Context Id\n * @param {number} [options.index] - Context index\n * @param {CoraliteSession} [options.session] - Render Context\n * @param {boolean} [options.noHydration] - Indicates if the component should be stripped and not hydrated\n * @param {boolean} [head=true] - Indicates if the current function call is for the head of the recursion\n * @returns {Promise<CoraliteElement | void>}\n */\nCoralite.prototype.createComponentElement = async function ({\n id,\n state = {},\n element,\n page,\n root,\n contextId,\n index,\n session,\n noHydration\n}, head = true) {\n if (!session) {\n session = this._createSession()\n }\n\n const moduleComponent = this.components.getItem(id)\n\n if (!moduleComponent || !moduleComponent.result) {\n return\n }\n\n const componentId = moduleComponent.result.id\n\n if (!contextId) {\n contextId = session.generateId(componentId)\n }\n\n const instanceId = contextId\n\n let componentState = { ...state }\n\n if (head) {\n if (element && element.attribs) {\n componentState = Object.assign(componentState, element.attribs)\n }\n\n // convert object keys to camel case format for consistent naming conventions\n // @ts-ignore\n componentState = cleanKeys(componentState)\n }\n\n /**\n * clone the component to avoid mutations during replacement process.\n * @type {CoraliteModule}\n */\n const module = cloneModuleInstance(moduleComponent.result)\n\n const mappedComponentContext = await this._triggerPluginHook('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 })\n componentState = mappedComponentContext.state\n\n const result = module.template\n\n if (module.styles.length) {\n const attributeName = 'data-style-selector'\n const selector = module.id\n\n // Check if styles have been processed for this component\n if (!moduleComponent.result._processedCss) {\n const rawCss = module.styles.join('\\n')\n\n const { rootClasses, descendantClasses } = moduleComponent.result\n\n // Transform CSS\n moduleComponent.result._processedCss = await transformCss(rawCss, rootClasses, descendantClasses, (errorData) => this._handleError(errorData))\n }\n\n // Add styles to session (idempotent for the build)\n if (!session.styles.has(selector)) {\n session.styles.set(selector, moduleComponent.result._processedCss)\n }\n\n // Inject attribute into component root elements\n const value = selector\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\n // Handle existing attribute value\n child.attribs[attributeName] = value\n }\n }\n }\n\n // merge state from component script\n if (module.script) {\n let scriptResult = {}\n\n try {\n const evaluationState = Object.assign({}, componentState)\n\n scriptResult = await this._evaluate({\n module,\n element,\n state: evaluationState,\n page,\n root: element || root,\n contextId,\n session,\n noHydration\n })\n } catch (error) {\n throw this._createExecutionError(error, module, moduleComponent, page, contextId)\n }\n\n if (scriptResult && scriptResult.__script__ != null) {\n const extractedScript = findAndExtractScript(module.script)\n let extractedComponents = []\n\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 // Fallback for when script extraction fails (shouldn't happen with valid defineComponent)\n // Ensure we don't crash\n scriptResult.__script__.lineOffset = module.lineOffset || 0\n scriptResult.__script__.content = 'function(){}'\n }\n\n // Extract processed styles from the module\n const stylesHTML = moduleComponent.result._processedCss || ''\n\n const templateAST = moduleComponent.result.template.children\n const templateValues = moduleComponent.result.values\n const componentTokens = {}\n\n for (let i = 0; i < module.values.attributes.length; i++) {\n const item = module.values.attributes[i]\n for (let j = 0; j < item.tokens.length; j++) {\n componentTokens[item.tokens[j].name] = true\n }\n }\n for (let i = 0; i < module.values.textNodes.length; i++) {\n const item = module.values.textNodes[i]\n for (let j = 0; j < item.tokens.length; j++) {\n componentTokens[item.tokens[j].name] = true\n }\n }\n\n // Include all computed state into default values so client script can use them\n const componentDefaultValues = scriptResult.__script__.defaultValues || {}\n if (componentState) {\n for (const token of Object.keys(componentTokens)) {\n if (componentDefaultValues[token] === undefined && componentState[token] !== undefined) {\n componentDefaultValues[token] = componentState[token]\n }\n }\n }\n\n // Dynamically load any components dynamically inserted if they are explicitly mentioned\n const declarativeComponents = (module.customElements || []).map(el => el.name)\n const mergedComponents = Array.from(new Set([...declarativeComponents, ...extractedComponents]))\n\n if (scriptResult.__script__) {\n scriptResult.__script__.components = mergedComponents\n }\n\n // Register component script with script manager\n this._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 // Merge the evaluated script results into the state context for dependencies\n const inheritedState = Object.assign({}, state)\n delete inheritedState.__script__\n\n await this._processDependentComponents(mergedComponents, session, page, root, inheritedState)\n }\n\n // Ensure state object exists in scriptResult\n if (!scriptResult.__script__.state) {\n scriptResult.__script__.state = {}\n }\n\n\n // Store instance data for script manager\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\n delete scriptResult.__script__\n }\n\n componentState = Object.assign(componentState, scriptResult)\n }\n\n session.state[contextId] = componentState\n\n // replace tokens in the component with their state from `componentState` object and store them into computed value array for later use if needed (e.g., to be injected back).\n for (let i = 0; i < module.values.attributes.length; i++) {\n const item = module.values.attributes[i]\n\n for (let j = 0; j < item.tokens.length; j++) {\n const token = item.tokens[j]\n let value = componentState[token.name]\n\n if (value == null) {\n // console.error('Token \"' + token.name +'\" was empty used on \"' + moduleComponent.id + '\"')\n value = ''\n }\n\n replaceToken({\n type: 'attribute',\n node: item.element,\n attribute: item.name,\n content: token.content,\n value\n })\n }\n }\n\n for (let i = 0; i < module.values.textNodes.length; i++) {\n const item = module.values.textNodes[i]\n\n for (let j = 0; j < item.tokens.length; j++) {\n const token = item.tokens[j]\n let value = componentState[token.name]\n\n if (value == null) {\n // console.error('Token \"' + token.name +'\" was empty used on \"' + moduleComponent.id + '\"')\n value = ''\n }\n\n replaceToken({\n type: 'textNode',\n node: item.textNode,\n content: token.content,\n value\n })\n }\n }\n\n // replace nested customElements\n const customElements = module.customElements\n let childIndex\n\n // Update slot elements for all custom elements\n for (let i = 0; i < customElements.length; i++) {\n const customElement = customElements[i]\n\n // update slot elements\n if (customElement.children\n && customElement.children.length\n && !customElement.slots.length\n ) {\n for (let j = 0; j < customElement.children.length; j++) {\n const node = customElement.children[j]\n const slotElement = {\n name: 'default',\n node\n }\n\n // @ts-ignore\n if (isCoraliteElement(node) && node.attribs.slot) {\n // add named slot\n // @ts-ignore\n slotElement.name = node.attribs.slot\n }\n\n customElement.slots.push(slotElement)\n }\n }\n }\n\n const createComponentTasks = []\n\n for (let i = 0; i < customElements.length; i++) {\n const customElement = customElements[i]\n\n // Skip if this element is a direct child of another custom element.\n // The parent will handle processing this element via slots.\n // @ts-ignore\n if (customElement.parent && customElement.parent.slots) {\n continue\n }\n\n const childContextId = session.generateId(customElement.name)\n const currentProperties = session.state[childContextId] || {}\n\n let childState = { ...state }\n\n // append custom attributes to state\n if (typeof customElement.attribs === 'object') {\n const attribValues = cleanKeys(customElement.attribs)\n\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\n const childNoHydration = noHydration || (customElement.attribs && 'no-hydration' in customElement.attribs)\n\n createComponentTasks.push(\n this.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\n const results = await Promise.all(createComponentTasks)\n\n for (let i = 0; i < results.length; i++) {\n const { childComponentElement, customElement, childContextId, noHydration: childNoHydration } = results[i]\n\n // replace custom element with component\n if (childComponentElement && typeof childComponentElement === 'object') {\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 for (let j = 0; j < childComponentElement.children.length; j++) {\n childComponentElement.children[j].parent = parent\n }\n parent.children.splice(elementIndex, 1, ...childComponentElement.children)\n }\n }\n } else {\n customElement.children = childComponentElement.children\n for (let j = 0; j < customElement.children.length; j++) {\n customElement.children[j].parent = customElement\n }\n\n if (!customElement.attribs) {\n customElement.attribs = {}\n }\n customElement.attribs['data-cid'] = childContextId\n\n session.componentTags.add(customElement.name)\n }\n }\n }\n\n await this._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 index = parent.children.indexOf(node)\n if (index !== -1) {\n for (let j = 0; j < node.children.length; j++) {\n node.children[j].parent = parent\n }\n parent.children.splice(index, 1, ...node.children)\n }\n }\n } else {\n stack.push(...(node.children || []))\n }\n }\n }\n }\n\n const mappedAfterContext = await this._triggerPluginHook('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 })\n return mappedAfterContext.result\n}\n\n\n/**\n * Replaces slot elements in a component with provided content\n * @internal\n * @param {string} id - Component ID\n * @param {CoraliteElement} element - The original Custom Element node\n * @param {CoraliteModule} module - The component module configuration\n * @param {Object} state - The component state\n * @param {CoralitePage} page - Active page object\n * @param {any} root - The component root element\n * @param {number} index - Index of element\n * @param {CoraliteSession} session - Rendering state\n * @param {boolean} noHydration - No hydration flag\n * @returns {Promise<void>} Resolves when slots are successfully replaced\n */\nCoralite.prototype._replaceSlots = async function (id, element, module, state, page, root, index, session, noHydration) {\n const slots = module.slotElements ? module.slotElements[id] : null\n\n if (!slots) {\n return\n }\n\n const slotChildren = {}\n const slotNames = Object.keys(slots)\n\n for (let i = 0; i < slotNames.length; i++) {\n const slotName = slotNames[i]\n slotChildren[slotName] = []\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\n if (slot) {\n if (elementSlotContent.node.attribs) {\n delete elementSlotContent.node.attribs.slot\n }\n\n slotChildren[slotName].push(elementSlotContent.node)\n }\n }\n }\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\n const slotIndex = slot.element.parent.children.indexOf(slot.element)\n\n const emptySlot = slotNodes.filter(node => {\n return node.type !== 'text' || (node.data && node.data.trim().length > 0)\n })\n\n if (!emptySlot.length) {\n slotNodes = slot.element.children || []\n } else {\n const startIndex = slotNodes.length - 1\n\n for (let i = startIndex; i > -1; i--) {\n const node = slotNodes[i]\n\n if (node.name) {\n const slotComponentItem = this.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\n if (typeof node.attribs === 'object') {\n session.state[slotContextId] = {\n ...currentProperties,\n ...state,\n ...attribValues\n }\n } else {\n session.state[slotContextId] = Object.assign(currentProperties, state)\n }\n\n const childNoHydration = noHydration || (node.attribs && 'no-hydration' in node.attribs)\n\n const componentElement = await this.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)\n\n if (componentElement) {\n if (childNoHydration) {\n const parent = node.parent\n if (parent && parent.children) {\n const elementIndex = parent.children.indexOf(node)\n if (elementIndex !== -1) {\n for (let j = 0; j < componentElement.children.length; j++) {\n componentElement.children[j].parent = parent\n }\n parent.children.splice(elementIndex, 1, ...componentElement.children)\n }\n }\n } else {\n node.children = componentElement.children\n for (let j = 0; j < node.children.length; j++) {\n node.children[j].parent = node\n }\n\n if (!node.attribs) {\n node.attribs = {}\n }\n node.attribs['data-cid'] = slotContextId\n\n session.componentTags.add(node.name)\n }\n }\n }\n }\n }\n }\n\n slot.element.children = slotNodes\n\n for (let j = 0; j < slotNodes.length; j++) {\n if (slotNodes[j]) {\n slotNodes[j].parent = slot.element\n }\n }\n }\n}\n\n\n/**\n * Generates a custom module linker callback for the Node.js VM context.\n * This linker is responsible for resolving `import` statements inside evaluated\n * component scripts. It intercepts specific specifiers to provide synthetic modules\n * for `coralite` and plugins, correctly resolves relative paths against\n * the component's directory, and safely bridges external Node.js modules into the VM sandbox.\n *\n * @internal\n * @param {CoraliteFilePath} path - The file path metadata of the component currently being evaluated. Used as the base for relative imports.\n * @param {CoralitePluginContext} context - Contextual rendering data and state to be exposed when a script imports `'coralite'`.\n * @returns {(specifier: string, referencingModule: import('node:vm').Module, extra: { attributes: any }) => Promise<import('node:vm').Module>} The async linker function used by the VM module.\n */\nCoralite.prototype._moduleLinker = function (path, context) {\n const source = this._source\n const componentDirURL = pathToFileURL(resolve(path.dirname)).href\n\n /**\n * The linker callback invoked by the Node.js VM when an `import` is encountered.\n *\n * @param {string} specifier - The string path of the requested module (e.g., `'./utils.js'`, `'coralite'`).\n * @param {import('node:vm').Module} referencingModule - The VM Module instance that initiated the import request.\n * @param {{ attributes: Record<string, string> }} extra - Additional import constraints, such as import attributes (e.g., `with { type: 'json' }`).\n * @returns {Promise<import('node:vm').Module>} A promise that resolves to a newly instantiated VM SourceTextModule containing the requested exports.\n */\n return async (specifier, referencingModule, extra) => {\n const { SourceTextModule } = await import('node:vm')\n const originalSpecifier = specifier\n\n if (source.plugins[specifier]) {\n const plugin = source.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 })\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 })\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 })\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 const { SourceTextModule } = await import('node:vm')\n\n return new SourceTextModule(exportModule, {\n context: referencingModule.context\n })\n } catch (error) {\n throw new Error(error)\n }\n }\n}\n\n/**\n * Parses a Coralite module script and evaluates it using SourceTextModule.\n *\n * @param {Object} data\n * @param {CoraliteModule} data.module - The Coralite module to parse\n * @param {CoraliteModuleDefinitions} data.state - Replacement tokens for the component\n * @param {CoralitePage} data.page - The global page object\n * @param {any} data.root - The Coralite module to parse\n * @param {string} data.contextId - Context Id\n * @param {CoraliteSession} data.session - Render Context\n * @param {boolean} data.noHydration - No hydration flag\n *\n * @returns {Promise<CoraliteModuleDefinitions>}\n */\nCoralite.prototype._evaluateDevelopment = async function ({\n module,\n state,\n page,\n root,\n contextId,\n session,\n noHydration\n}) {\n const { SourceTextModule } = await import('node:vm')\n\n if (!SourceTextModule) {\n throw new Error('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: this,\n noHydration\n }\n\n const cachedBoundPlugins = this._bindPlugins(this._source.plugins, context)\n\n session.source.currentSourceContextId = contextId\n session.source.contextInstances[contextId] = context\n\n const boundDefineComponent = (options) => this._defineComponent(options, context)\n\n // Protect fundamental constructors from being extracted and polluting the context realm\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 const usedGlobals = extractGlobals(module.script)\n const contextGlobals = {\n __coralite_context__: context,\n __coralite_plugins__: cachedBoundPlugins,\n __coralite_utils__: this._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 // Create a fresh context for the module\n const contextifiedObject = createContext(contextGlobals)\n\n const moduleComponent = this.components.getItem(module.id)\n\n // create a new source text module with the provided script content, configuration options, and context\n const script = new SourceTextModule(module.script, {\n initializeImportMeta (meta) {\n meta.url = pathToFileURL(resolve(moduleComponent.path.pathname)).href\n },\n lineOffset: module.lineOffset,\n identifier: resolve(moduleComponent.path.pathname),\n context: contextifiedObject\n })\n\n const linker = this._moduleLinker(moduleComponent.path, context)\n\n await script.link(linker)\n\n // evaluate the module to execute its content\n try {\n await script.evaluate()\n } catch (error) {\n throw this._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 an error if no default export was found\n throw new Error(`Module \"${module.id}\" has no default export`)\n}\n\n/**\n * Parses a Coralite module script and compiles it into JavaScript using esbuild.\n * Replaces node:vm SourceTextModule for better performance and memory management.\n *\n * @param {Object} data\n * @param {CoraliteModule} data.module - The Coralite module to parse\n * @param {CoraliteModuleDefinitions} data.state - Replacement tokens for the component\n * @param {CoralitePage} data.page - The global page object\n * @param {any} data.root - The Coralite module to parse\n * @param {string} data.contextId - Context Id\n * @param {CoraliteSession} data.session - Render Context\n * @param {boolean} data.noHydration - No hydration flag\n *\n * @returns {Promise<CoraliteModuleDefinitions>}\n */\nCoralite.prototype._evaluateProduction = async function ({\n module,\n state,\n page,\n root,\n contextId,\n session,\n noHydration\n}) {\n const context = {\n state: state || {},\n page,\n root,\n module,\n id: contextId,\n session,\n app: this,\n noHydration\n }\n\n session.source.currentSourceContextId = contextId\n session.source.contextInstances[contextId] = context\n\n // Retrieve Template and check cache\n const moduleComponent = this.components.getItem(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 // Transform using esbuild\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 // Create a require function anchored to the moduleComponent's file path to resolve relative imports\n const fileRequire = createRequire(resolve(moduleComponent.path.pathname))\n\n let cachedBoundPlugins = null\n\n const customRequire = (id) => {\n const isCoralite = id === 'coralite'\n const isUtils = id === 'coralite/utils'\n const isPlugin = this._source.plugins[id] !== undefined\n\n // Handle internal coralite imports\n if (isCoralite || isUtils || isPlugin) {\n // Lazily bind plugins once per evaluation\n if (!cachedBoundPlugins) {\n cachedBoundPlugins = this._bindPlugins(this._source.plugins, context)\n }\n\n if (isCoralite) {\n return {\n ...context,\n defineComponent: (options) => this._defineComponent(options, context),\n default: {\n ...context,\n defineComponent: (options) => this._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 ...this._source.utils,\n default: this._source.utils\n }\n }\n }\n\n return fileRequire(id)\n }\n\n // Mock the CommonJS 'module' object to capture exports\n const moduleMock = { exports: {} }\n\n // Create the function. We pass 'coralite' explicitly to support the\n // \"export const document = coralite.document\" pattern found in existing modules.\n // Arguments: module, exports, require, coralite\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 // Execute the function with our mocks and context\n try {\n await fn(moduleMock, moduleMock.exports, customRequire, context)\n } catch (error) {\n throw this._createExecutionError(error, module, moduleComponent, page, contextId)\n }\n\n if (moduleMock.exports.default != null) {\n return moduleMock.exports.default\n }\n\n throw new Error(`Module \"${module.id}\" has no default export`)\n}\n\n/**\n * Parses a Coralite module script and compiles it into JavaScript using esbuild.\n * Replaces node:vm SourceTextModule for better performance and memory management.\n *\n * @param {Object} data -\n * @param {CoraliteModule} data.module - The Coralite module to parse\n * @param {CoraliteModuleDefinitions} data.state - Replacement tokens for the component\n * @param {CoralitePage} data.page - The global page object\n * @param {any} data.element - The Coralite module to parse\n * @param {string} data.contextId - Context Id\n * @param {CoraliteSession} data.session - Render Context\n *\n * @returns {Promise<CoraliteModuleDefinitions>}\n */\nCoralite.prototype._evaluate = async function (options) {\n if (this.options.mode === 'development') {\n return this._evaluateDevelopment(options)\n }\n return this._evaluateProduction(options)\n}\n\n/**\n * Executes a collecting plugin hook where the results are aggregated.\n * Useful for hooks like `onAfterPageRender` that return new pages to be added to the build.\n *\n * @internal\n * @param {string} name - The name of the hook to trigger.\n * @param {any} contextData - Context to pass to the callbacks (not mutated by this function).\n * @returns {Promise<any[]>} A flattened array of all results returned by the plugins.\n */\nCoralite.prototype._triggerPluginAggregateHook = async function (name, contextData) {\n const pluginHooks = this._plugins.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](contextData)\n\n if (result !== null && typeof result === 'object' && typeof result.then === 'function') {\n result = await result\n }\n\n // Collect the results into a flat array instead of merging them into the context\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 * @internal Executes Phase 1 of plugin exports with the given context.\n *\n * @param {Object} plugins - The plugins object\n * @param {Object} context - The context object to pass to Phase 1\n * @returns {Object} The Phase 2 functions\n */\nCoralite.prototype._bindPlugins = function (plugins, context) {\n const cachedBoundPlugins = {}\n\n for (const key in plugins) {\n const pluginExports = plugins[key]\n if (pluginExports !== null && typeof pluginExports === 'object') {\n const pluginObj = {}\n for (const prop in pluginExports) {\n if (typeof pluginExports[prop] === 'function') {\n pluginObj[prop] = pluginExports[prop](context)\n } else {\n pluginObj[prop] = pluginExports[prop]\n }\n }\n cachedBoundPlugins[key] = pluginObj\n } else {\n cachedBoundPlugins[key] = pluginExports\n }\n }\n\n return cachedBoundPlugins\n}\n\n/**\n * @template T\n *\n * Executes all plugin callbacks registered under the specified hook name sequentially.\n *\n * @internal\n *\n * @param {'onPageSet'|'onPageUpdate'|'onPageDelete'|'onComponentSet'|'onComponentUpdate'|'onComponentDelete'|'onBeforePageRender'|'onAfterPageRender'|'onBeforeComponentRender'|'onAfterComponentRender'|'onBeforeBuild'|'onAfterBuild'} name - The name of the hook to trigger.\n * @param {T} initialData - Data to pass to each callback function.\n * @returns {Promise<T>} A promise that resolves to the merged data.\n */\nCoralite.prototype._triggerPluginHook = async function (name, initialData) {\n const pluginHooks = this._plugins.hooks[name]\n\n if (!pluginHooks || pluginHooks.length === 0) {\n return initialData\n }\n\n // Clone initial data once to prevent accidental root-level mutations\n // leaking backwards if a plugin still mutates it directly.\n let currentData = typeof initialData === 'object' && initialData !== null\n ? {\n ...initialData,\n app: this\n }\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 the plugin returned a patch, the framework handles the mapping\n if (result !== undefined && result !== null) {\n currentData = mergePluginState(currentData, result)\n }\n }\n\n return currentData\n}\n\n/**\n * Registers a callback function under the specified hook name.\n *\n * @internal\n *\n * @param {'onPageSet'|'onPageUpdate'|'onPageDelete'|'onComponentSet'|'onComponentUpdate'|'onComponentDelete'|'onBeforePageRender'|'onAfterPageRender'|'onBeforeComponentRender'|'onAfterComponentRender'|'onBeforeBuild'|'onAfterBuild'} name - The name of the hook to register the callback with.\n * @param {Function} callback - The callback function to be executed when the hook is triggered.\n */\nCoralite.prototype._addPluginHook = function (name, callback) {\n if (typeof callback !== 'function') {\n throw new Error(`Plugin hook \"${name}\" must be a function`)\n }\n\n if (this._plugins.hooks[name]) {\n this._plugins.hooks[name].push(callback)\n }\n}\n\n/**\n * Replaces a custom element with its template content.\n * @internal\n * @param {CoraliteElement} coraliteElement - The custom element to be replaced.\n * @param {CoraliteElement} element - The target element to replace the tokens with.\n */\nCoralite.prototype._replaceCustomElementWithTemplate = function (coraliteElement, element) {\n coraliteElement.children = element.children\n for (let j = 0; j < coraliteElement.children.length; j++) {\n coraliteElement.children[j].parent = coraliteElement\n }\n}\n\n/**\n * Process a token value - parse HTML strings and handle custom elements\n * @internal\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 */\nCoralite.prototype._processTokenValue = async function (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 for (let j = 0; j < componentElement.children.length; j++) {\n componentElement.children[j].parent = parent\n }\n parent.children.splice(elementIndex, 1, ...componentElement.children)\n }\n }\n } else {\n customElement.children = componentElement.children\n for (let j = 0; j < customElement.children.length; j++) {\n customElement.children[j].parent = customElement\n }\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\n/**\n * This function defines a component for the Coralite framework.\n * It is used to register components with their associated state and scripts.\n * @internal\n * @param {Object} options - Configuration options for the component\n * @param {CoralitePluginContext} context - The evaluation context\n * @returns {Promise<Object>} A promise resolving to the module state associated with this component.\n */\nCoralite.prototype._defineComponent = async function (options, context) {\n const {\n attributes,\n data,\n getters,\n slots,\n script\n } = options\n\n const {\n state: initialState,\n module,\n root\n } = context\n\n // Validate attributes\n if (attributes) {\n for (const [key, value] of Object.entries(attributes)) {\n if (value.type === Object || value.type === Array) {\n throw new Error(`Coralite Error: Component \"${module.id}\" defines attribute \"${key}\" as ${value.type.name}. Object and Array types are blocked in attributes for V1.1 to prevent \"JSON-in-HTML\" anti-patterns. Use the data() block for complex data.`)\n }\n }\n }\n\n let state = Object.assign({}, initialState)\n\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 state.__script__ = {\n attributes: serializableAttributes,\n getters: getters || {},\n state: {},\n defaultValues: {},\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 // Coerce existing attribute values\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(context)\n if (dataResult) {\n state.__script__.data = dataResult\n Object.assign(state, dataResult)\n // Ensure data results are added to state.__script__.state for serialization to client\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 // Ensure getters use read-only proxy to preemptively throw error if developer attempts to mutate the state.\n const result = getter(roState, { signal: new AbortController().signal })\n\n if (result && typeof result.then === 'function') {\n state[key] = await result\n } else {\n state[key] = result\n }\n\n // Add getter result to state.__script__.state so it's serialized to the client\n if (state.__script__ && state.__script__.state) {\n state.__script__.state[key] = state[key]\n }\n }\n }\n\n // process computed slots\n if (slots) {\n for (const name in slots) {\n if (Object.prototype.hasOwnProperty.call(slots, name)) {\n const computedSlot = slots[name]\n\n const methodKey = `slots_method_${name}`\n state.__script__.defaultValues[methodKey] = computedSlot\n\n // slot content to compute\n const slotContent = []\n // new slot elements\n const elementSlots = []\n\n // @ts-ignore\n if (root && root.slots) {\n // @ts-ignore\n for (let j = 0; j < root.slots.length; j++) {\n // @ts-ignore\n const slot = root.slots[j]\n\n if (slot.name === name) {\n // slot content to compute\n slotContent.push(slot.node)\n } else {\n elementSlots.push(slot)\n }\n }\n }\n\n // compute slot nodes\n const result = computedSlot(slotContent, state) || slotContent\n\n // append new slot nodes\n if (typeof result === 'string') {\n // process string result through unified processor\n const processedResult = await this._processTokenValue(result, {\n ...context,\n state,\n createComponentElement: context.app.createComponentElement,\n noHydration: context.noHydration\n })\n\n if (Array.isArray(processedResult)) {\n // multiple nodes from parsed HTML\n for (let j = 0; j < processedResult.length; j++) {\n elementSlots.push({\n name,\n node: processedResult[j]\n })\n }\n } else {\n // single text node\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\n if (\n isCoraliteElement(node)\n || isCoraliteTextNode(node)\n || isCoraliteComment(node)\n ) {\n elementSlots.push({\n name,\n node\n })\n } else {\n throw new Error('Unexpected slot value, expected a node but found: '\n + '\\n result: ' + JSON.stringify(node)\n + '\\n path: \"' + module.path.pathname + '\"')\n }\n }\n }\n\n // update element slots\n if (root) {\n // @ts-ignore\n root.slots = elementSlots\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\n // include state used in script\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\n Object.assign(state.__script__.state, args)\n }\n } else {\n // remove custom element parent script\n delete state.__script__\n }\n\n return state\n}\n\nconst coraliteInternalProperty = {\n enumerable: false,\n configurable: false,\n writable: false\n}\n\nObject.defineProperty(Coralite.prototype, '_defaultOnError', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_handleError', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_createExecutionError', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_createSession', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_processCustomElementsInPage', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_generatePages', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_processDependentComponents', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_replaceSlots', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_moduleLinker', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_evaluateDevelopment', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_evaluateProduction', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_evaluate', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_triggerPluginAggregateHook', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_triggerPluginHook', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_bindPlugins', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_addPluginHook', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_replaceCustomElementWithTemplate', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_processTokenValue', coraliteInternalProperty)\nObject.defineProperty(Coralite.prototype, '_defineComponent', coraliteInternalProperty)\n\nexport default Coralite\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,WAAW,qBAAqB,cAAc,wBAAwB,sBAAsB,0BAA0B,gBAAgB,kBAAkB,0BAA0B,sBAAsB;AACjN,SAAS,aAAa,cAAc,yBAAyB;AAC7D,SAAS,iBAAiB,sBAAsB,cAAc,uBAAuB,iBAAiB,gBAAgB,wBAAwB;AAC9I,SAAS,6BAA6B;AACtC,SAAS,WAAW,aAAa,eAAe,sBAAsB;AACtE,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB,YAAY,mBAAmB,qBAAqB;AAC7E,SAAS,OAAO,iBAAiB;AACjC,SAAS,SAAS,MAAM,WAAW,UAAU,eAAe;AAC5D,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAC1B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,4BAA4B;AACrC,OAAO,YAAY;AACnB,OAAO,YAAY;AACnB,SAAS,uBAAuB,8BAA8B;AAC9D,OAAO,wBAAwB;AAC/B,SAAS,kBAAkB;AAC3B,SAAS,qBAAq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