nuclo 0.3.21 → 0.3.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=[];var t=class{nodeType=1;nodeName=``;nodeValue=null;parentNode=null;textContent=``;get childNodes(){return e}},n=class{get cssText(){let e=Object.entries(this);return e.length===0?``:e.map(([e,t])=>`${e}: ${t}`).join(`; `)}setProperty(e,t){this[e]=t}getPropertyValue(e){return this[e]||``}},r=class{_el;constructor(e){this._el=e}tokens(){return this._el.className.split(` `).filter(Boolean)}add(...e){let t=this.tokens();for(let n of e)n&&!t.includes(n)&&t.push(n);this._el.className=t.join(` `)}remove(...e){this._el.className=this.tokens().filter(t=>!e.includes(t)).join(` `)}contains(e){return this.tokens().includes(e)}toggle(e,t){let n=t??!this.contains(e);return n?this.add(e):this.remove(e),n}replace(e,t){return this.contains(e)?(this.remove(e),this.add(t),!0):!1}item(e){return this.tokens()[e]??null}get length(){return this.tokens().length}get value(){return this._el.className}set value(e){this._el.className=e}toString(){return this._el.className}supports(e){return!1}forEach(e){this.tokens().forEach((t,n)=>e(t,n,this))}[Symbol.iterator](){return this.tokens().values()}entries(){return this.tokens().entries()}keys(){return this.tokens().keys()}values(){return this.tokens().values()}},i=class extends t{tagName;children;className=``;textContent=``;parentNode=null;id=``;namespaceURI;_style;_classList;_attributes;get attributes(){return this._attributes??=/* @__PURE__ */ new Map}set attributes(e){this._attributes=e}get innerText(){return this.textContent}set innerText(e){this.textContent=e}get style(){return this._style??=new n}set style(e){this._style=e}get classList(){return this._classList??=new r(this)}set classList(e){this._classList=e}constructor(e){super(),this.tagName=e.toLowerCase(),this.nodeType=1,this.nodeName=e.toUpperCase(),this.children=[]}get childNodes(){return this.children}appendChild(e){if(e?.nodeType===11){let t=e.childNodes;e.childNodes=[],e.children&&=[];for(let e=0;e<t.length;e++)this.appendChild(t[e]);return e}return this.children.push(e),typeof e==`object`&&e&&`parentNode`in e&&(e.parentNode=this),e}setAttribute(e,t){(this._attributes??=/* @__PURE__ */ new Map).set(e,t),e===`class`?this.className=t:e===`id`&&(this.id=t)}getAttribute(e){return this._attributes?.get(e)??null}removeAttribute(e){this._attributes?.delete(e),e===`class`&&(this.className=``)}hasAttribute(e){return this._attributes?.has(e)??!1}insertBefore(e,t){if(t===null)return this.appendChild(e);if(e?.nodeType===11){let n=e.childNodes;e.childNodes=[],e.children&&=[];for(let e=0;e<n.length;e++)this.insertBefore(n[e],t);return e}let n=this.children.indexOf(t);return n!==-1&&(this.children.splice(n,0,e),typeof e==`object`&&e&&`parentNode`in e&&(e.parentNode=this)),e}removeChild(e){let t=this.children.indexOf(e);return t!==-1&&(this.children.splice(t,1),typeof e==`object`&&e&&`parentNode`in e&&(e.parentNode=null)),e}replaceChild(e,t){let n=this.children.indexOf(t);return n!==-1&&(this.children[n]=e,typeof e==`object`&&e&&`parentNode`in e&&(e.parentNode=this),typeof t==`object`&&t&&`parentNode`in t&&(t.parentNode=null)),t}addEventListener(e,t){}removeEventListener(e,t){}dispatchEvent(e){return!0}querySelector(e){return null}querySelectorAll(e){return[]}},a=class{nodeType=3;nodeName=`#text`;data;textContent;parentNode=null;constructor(e){this.data=e,this.textContent=e}get nodeValue(){return this.data}set nodeValue(e){this.data=e,this.textContent=e}},o=class{nodeType=11;nodeName=`#document-fragment`;childNodes=[];children=[];textContent=``;get firstChild(){return this.childNodes.length>0?this.childNodes[0]:null}get lastChild(){return this.childNodes.length>0?this.childNodes[this.childNodes.length-1]:null}appendChild(e){return this.childNodes.push(e),e.nodeType===1&&this.children.push(e),e.parentNode=this,e}insertBefore(e,t){if(!t)return this.appendChild(e);let n=this.childNodes.indexOf(t);if(n!==-1&&(this.childNodes.splice(n,0,e),e.nodeType===1)){let n=this.children.indexOf(t);n!==-1&&this.children.splice(n,0,e)}return e.parentNode=this,e}removeChild(e){let t=this.childNodes.indexOf(e);if(t!==-1&&this.childNodes.splice(t,1),e.nodeType===1){let t=this.children.indexOf(e);t!==-1&&this.children.splice(t,1)}return e.parentNode=null,e}replaceChild(e,t){let n=this.childNodes.indexOf(t);if(n!==-1&&(this.childNodes[n]=e,t.nodeType===1&&e.nodeType===1)){let n=this.children.indexOf(t);n!==-1&&(this.children[n]=e)}return e.parentNode=this,t.parentNode=null,e}querySelector(){return null}querySelectorAll(){return[]}},s=class{head;body;constructor(){this.head=new i(`head`),this.body=new i(`body`)}createElement(e,t){return new i(e)}createElementNS(e,t,n){let r=new i(t);return r.namespaceURI=e,r}createTextNode(e){return new a(e)}createComment(e,t){return{nodeType:8,nodeName:`#comment`,data:e,textContent:e,nodeValue:e,parentNode:null,nextSibling:null,previousSibling:null,marker:t===!0}}createDocumentFragment(){return new o}querySelector(e){return null}querySelectorAll(e){return[]}addEventListener(e,t,n){}removeEventListener(e,t,n){}dispatchEvent(e){return!0}contains(e){return!1}};const c=globalThis.document||new s,l=globalThis.Event,u=globalThis.CustomEvent,d=t,f=i,p=i;if(typeof window>`u`){let e=globalThis;e.document??=c,e.Node??=t,e.Element??=i,e.HTMLElement??=i}exports.CustomEvent=u,exports.Element=f,exports.Event=l,exports.HTMLElement=p,exports.Node=d,exports.NucloDocument=s,exports.NucloElement=i,exports.NucloNode=t,exports.NucloText=a,exports.document=c;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=[];function t(e,t){let n=e.parentNode?.childNodes;if(!n)return null;let r=Array.prototype.indexOf.call(n,e);return r===-1?null:n[r+t]??null}var n=class{nodeType=1;nodeName=``;nodeValue=null;parentNode=null;textContent=``;get childNodes(){return e}get nextSibling(){return t(this,1)}get previousSibling(){return t(this,-1)}},r=class extends n{data;marker;constructor(e,t){super(),this.nodeType=8,this.nodeName=`#comment`,this.data=e,this.textContent=e,this.nodeValue=e,this.marker=t}},i=class{get cssText(){let e=Object.entries(this);return e.length===0?``:e.map(([e,t])=>`${e}: ${t}`).join(`; `)}setProperty(e,t){this[e]=t}getPropertyValue(e){return this[e]||``}},a=class{_el;constructor(e){this._el=e}tokens(){return this._el.className.split(` `).filter(Boolean)}add(...e){let t=this.tokens();for(let n of e)n&&!t.includes(n)&&t.push(n);this._el.className=t.join(` `)}remove(...e){this._el.className=this.tokens().filter(t=>!e.includes(t)).join(` `)}contains(e){return this.tokens().includes(e)}toggle(e,t){let n=t??!this.contains(e);return n?this.add(e):this.remove(e),n}replace(e,t){return this.contains(e)?(this.remove(e),this.add(t),!0):!1}item(e){return this.tokens()[e]??null}get length(){return this.tokens().length}get value(){return this._el.className}set value(e){this._el.className=e}toString(){return this._el.className}supports(e){return!1}forEach(e){this.tokens().forEach((t,n)=>e(t,n,this))}[Symbol.iterator](){return this.tokens().values()}entries(){return this.tokens().entries()}keys(){return this.tokens().keys()}values(){return this.tokens().values()}},o=class extends n{tagName;children;className=``;textContent=``;parentNode=null;id=``;namespaceURI;_style;_classList;_attributes;get attributes(){return this._attributes??=/* @__PURE__ */ new Map}set attributes(e){this._attributes=e}get innerText(){return this.textContent}set innerText(e){this.textContent=e}get style(){return this._style??=new i}set style(e){this._style=e}get classList(){return this._classList??=new a(this)}set classList(e){this._classList=e}constructor(e){super(),this.tagName=e.toLowerCase(),this.nodeType=1,this.nodeName=e.toUpperCase(),this.children=[]}get childNodes(){return this.children}appendChild(e){if(e?.nodeType===11){let t=e.childNodes;e.childNodes=[],e.children&&=[];for(let e=0;e<t.length;e++)this.appendChild(t[e]);return e}return this.children.push(e),typeof e==`object`&&e&&`parentNode`in e&&(e.parentNode=this),e}setAttribute(e,t){(this._attributes??=/* @__PURE__ */ new Map).set(e,t),e===`class`?this.className=t:e===`id`&&(this.id=t)}getAttribute(e){return this._attributes?.get(e)??null}removeAttribute(e){this._attributes?.delete(e),e===`class`&&(this.className=``)}hasAttribute(e){return this._attributes?.has(e)??!1}insertBefore(e,t){if(t===null)return this.appendChild(e);if(e?.nodeType===11){let n=e.childNodes;e.childNodes=[],e.children&&=[];for(let e=0;e<n.length;e++)this.insertBefore(n[e],t);return e}let n=this.children.indexOf(t);return n!==-1&&(this.children.splice(n,0,e),typeof e==`object`&&e&&`parentNode`in e&&(e.parentNode=this)),e}removeChild(e){let t=this.children.indexOf(e);return t!==-1&&(this.children.splice(t,1),typeof e==`object`&&e&&`parentNode`in e&&(e.parentNode=null)),e}replaceChild(e,t){let n=this.children.indexOf(t);return n!==-1&&(this.children[n]=e,typeof e==`object`&&e&&`parentNode`in e&&(e.parentNode=this),typeof t==`object`&&t&&`parentNode`in t&&(t.parentNode=null)),t}addEventListener(e,t){}removeEventListener(e,t){}dispatchEvent(e){return!0}querySelector(e){return null}querySelectorAll(e){return[]}},s=class{nodeType=3;nodeName=`#text`;data;textContent;parentNode=null;constructor(e){this.data=e,this.textContent=e}get nodeValue(){return this.data}set nodeValue(e){this.data=e,this.textContent=e}get childNodes(){return e}get nextSibling(){return t(this,1)}get previousSibling(){return t(this,-1)}},c=class{nodeType=11;nodeName=`#document-fragment`;childNodes=[];children=[];textContent=``;get firstChild(){return this.childNodes.length>0?this.childNodes[0]:null}get lastChild(){return this.childNodes.length>0?this.childNodes[this.childNodes.length-1]:null}appendChild(e){return this.childNodes.push(e),e.nodeType===1&&this.children.push(e),e.parentNode=this,e}insertBefore(e,t){if(!t)return this.appendChild(e);let n=this.childNodes.indexOf(t);if(n!==-1&&(this.childNodes.splice(n,0,e),e.nodeType===1)){let n=this.children.indexOf(t);n!==-1&&this.children.splice(n,0,e)}return e.parentNode=this,e}removeChild(e){let t=this.childNodes.indexOf(e);if(t!==-1&&this.childNodes.splice(t,1),e.nodeType===1){let t=this.children.indexOf(e);t!==-1&&this.children.splice(t,1)}return e.parentNode=null,e}replaceChild(e,t){let n=this.childNodes.indexOf(t);if(n!==-1&&(this.childNodes[n]=e,t.nodeType===1&&e.nodeType===1)){let n=this.children.indexOf(t);n!==-1&&(this.children[n]=e)}return e.parentNode=this,t.parentNode=null,e}querySelector(){return null}querySelectorAll(){return[]}},l=class{head;body;constructor(){this.head=new o(`head`),this.body=new o(`body`)}createElement(e,t){return new o(e)}createElementNS(e,t,n){let r=new o(t);return r.namespaceURI=e,r}createTextNode(e){return new s(e)}createComment(e,t){return new r(e,t===!0)}createDocumentFragment(){return new c}querySelector(e){return null}querySelectorAll(e){return[]}addEventListener(e,t,n){}removeEventListener(e,t,n){}dispatchEvent(e){return!0}contains(e){return!1}};const u=globalThis.document||new l,d=globalThis.Event,f=globalThis.CustomEvent,p=n,m=o,h=o;if(typeof window>`u`){let e=globalThis;e.document??=u,e.Node??=n,e.Element??=o,e.HTMLElement??=o}exports.CustomEvent=f,exports.Element=m,exports.Event=d,exports.HTMLElement=h,exports.Node=p,exports.NucloDocument=l,exports.NucloElement=o,exports.NucloNode=n,exports.NucloText=s,exports.document=u;
2
2
  //# sourceMappingURL=nuclo.polyfill.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"nuclo.polyfill.cjs","names":["NO_CHILDREN","NucloNode","SSRStyle","entries","k","v","name","value","SSRClassList","el","tokens","classes","t","c","token","on","force","oldToken","newToken","index","cb","i","NucloElement","tagName","child","kids","referenceNode","newNode","oldChild","newChild","NucloText","data","SSRDocumentFragment","refNode","elementIndex","NucloDocument","element","namespace","marker","document","Event","CustomEvent","Node","Element","HTMLElement","g"],"sources":["../../src/polyfill/Node.ts","../../src/polyfill/Element.ts","../../src/polyfill/Text.ts","../../src/polyfill/Document.ts","../../src/polyfill/index.ts"],"sourcesContent":["const NO_CHILDREN: never[] = [];\n\n/**\n * Base Node class for instanceof checks in Node.js polyfill\n */\nexport class NucloNode {\n nodeType: number = 1; // ELEMENT_NODE\n nodeName: string = '';\n nodeValue: string | null = null;\n parentNode: unknown = null;\n textContent: string = '';\n\n get childNodes(): NodeListOf<ChildNode> {\n return NO_CHILDREN as unknown as NodeListOf<ChildNode>;\n }\n}\n","import { NucloNode } from './Node';\n\n/**\n * Lightweight style object for SSR — prototype methods instead of Object.defineProperty per element.\n * Stores CSS properties as own properties and provides cssText/setProperty/getPropertyValue via prototype.\n */\nclass SSRStyle {\n [key: string]: unknown;\n\n get cssText(): string {\n const entries = Object.entries(this);\n if (entries.length === 0) return '';\n return entries.map(([k, v]) => `${k}: ${v}`).join('; ');\n }\n\n setProperty(name: string, value: string): void {\n (this as Record<string, unknown>)[name] = value;\n }\n\n getPropertyValue(name: string): string {\n return ((this as Record<string, unknown>)[name] as string) || '';\n }\n}\n\n// Lightweight classList for SSR — prototype methods instead of per-element closures\nclass SSRClassList {\n private _el: NucloElement;\n constructor(el: NucloElement) { this._el = el; }\n\n private tokens(): string[] { return this._el.className.split(' ').filter(Boolean); }\n\n add(...tokens: string[]): void {\n const classes = this.tokens();\n for (const t of tokens) if (t && !classes.includes(t)) classes.push(t);\n this._el.className = classes.join(' ');\n }\n remove(...tokens: string[]): void {\n this._el.className = this.tokens().filter(c => !tokens.includes(c)).join(' ');\n }\n contains(token: string): boolean { return this.tokens().includes(token); }\n toggle(token: string, force?: boolean): boolean {\n const on = force ?? !this.contains(token);\n if (on) this.add(token); else this.remove(token);\n return on;\n }\n replace(oldToken: string, newToken: string): boolean {\n if (!this.contains(oldToken)) return false;\n this.remove(oldToken); this.add(newToken); return true;\n }\n item(index: number): string | null { return this.tokens()[index] ?? null; }\n get length(): number { return this.tokens().length; }\n get value(): string { return this._el.className; }\n set value(v: string) { this._el.className = v; }\n toString(): string { return this._el.className; }\n supports(_token: string): boolean { return false; }\n forEach(cb: (value: string, key: number, parent: DOMTokenList) => void): void {\n this.tokens().forEach((token, i) => cb(token, i, this as unknown as DOMTokenList));\n }\n [Symbol.iterator](): IterableIterator<string> { return this.tokens().values(); }\n entries(): IterableIterator<[number, string]> { return this.tokens().entries(); }\n keys(): IterableIterator<number> { return this.tokens().keys(); }\n values(): IterableIterator<string> { return this.tokens().values(); }\n}\n\nexport class NucloElement extends NucloNode {\n tagName: string;\n children: unknown[];\n className: string = '';\n textContent: string = '';\n parentNode: unknown = null;\n id: string = '';\n namespaceURI?: string;\n\n // style/classList are allocated lazily: the vast majority of SSR elements\n // never touch either (className is stored on the .className string, and the\n // serializer reads the backing field directly), so eagerly constructing an\n // SSRStyle + SSRClassList per element would be pure allocation churn.\n private _style?: CSSStyleDeclaration;\n private _classList?: DOMTokenList;\n\n // attributes is allocated lazily too — most elements carry their identity on\n // .className/.id (separate string fields) and never call setAttribute. Reads\n // short-circuit on the undefined backing map without allocating; the\n // serializer reads _attributes directly. The public getter still lazily\n // materializes a Map for any external `el.attributes` consumer.\n private _attributes?: Map<string, string>;\n\n get attributes(): Map<string, string> {\n return (this._attributes ??= new Map<string, string>());\n }\n set attributes(value: Map<string, string>) {\n this._attributes = value;\n }\n\n // `{ innerText }` behaves like `{ textContent }` on the server: plain text\n // the serializer escapes. (Prototype accessor — no per-element field.)\n get innerText(): string {\n return this.textContent;\n }\n set innerText(value: string) {\n this.textContent = value;\n }\n\n get style(): CSSStyleDeclaration {\n return (this._style ??= new SSRStyle() as unknown as CSSStyleDeclaration);\n }\n set style(value: CSSStyleDeclaration) {\n this._style = value;\n }\n\n get classList(): DOMTokenList {\n return (this._classList ??= new SSRClassList(this) as unknown as DOMTokenList);\n }\n set classList(value: DOMTokenList) {\n this._classList = value;\n }\n\n constructor(tagName: string) {\n super();\n this.tagName = tagName.toLowerCase();\n this.nodeType = 1; // ELEMENT_NODE\n this.nodeName = tagName.toUpperCase();\n this.children = [];\n }\n\n /** Every node, elements, text and comments alike (children holds them all). */\n get childNodes(): NodeListOf<ChildNode> {\n return this.children as unknown as NodeListOf<ChildNode>;\n }\n\n appendChild<T extends Node>(child: T): T {\n // Spec behaviour: appending a DocumentFragment moves its children into this\n // node and leaves the fragment empty. The list runtime relies on this to\n // batch row insertions.\n if ((child as any)?.nodeType === 11) {\n // Detach the fragment's backing array before iterating (instead of\n // slicing it) — the fragment is emptied either way, and reassigning\n // first means the loop never has to allocate a copy just to guard\n // against the array it's about to discard.\n const kids = (child as any).childNodes as Node[];\n (child as any).childNodes = [];\n if ((child as any).children) (child as any).children = [];\n for (let i = 0; i < kids.length; i++) this.appendChild(kids[i]);\n return child;\n }\n this.children.push(child);\n if (typeof child === 'object' && child !== null && 'parentNode' in child) {\n (child as { parentNode: unknown }).parentNode = this;\n }\n return child;\n }\n \n setAttribute(name: string, value: string): void {\n (this._attributes ??= new Map<string, string>()).set(name, value);\n if (name === 'class') {\n this.className = value;\n } else if (name === 'id') {\n this.id = value;\n }\n }\n\n getAttribute(name: string): string | null {\n return this._attributes?.get(name) ?? null;\n }\n\n removeAttribute(name: string): void {\n this._attributes?.delete(name);\n if (name === 'class') {\n this.className = '';\n }\n }\n\n hasAttribute(name: string): boolean {\n return this._attributes?.has(name) ?? false;\n }\n \n insertBefore<T extends Node>(newNode: T, referenceNode: Node | null): T {\n if (referenceNode === null) {\n return this.appendChild(newNode);\n }\n // Spec behaviour: inserting a DocumentFragment moves its children (in order)\n // before the reference node and empties the fragment.\n if ((newNode as any)?.nodeType === 11) {\n const kids = (newNode as any).childNodes as Node[];\n (newNode as any).childNodes = [];\n if ((newNode as any).children) (newNode as any).children = [];\n for (let i = 0; i < kids.length; i++) this.insertBefore(kids[i], referenceNode);\n return newNode;\n }\n const index = this.children.indexOf(referenceNode);\n if (index !== -1) {\n this.children.splice(index, 0, newNode);\n if (typeof newNode === 'object' && newNode !== null && 'parentNode' in newNode) {\n (newNode as { parentNode: unknown }).parentNode = this;\n }\n }\n return newNode;\n }\n \n removeChild<T extends Node>(child: T): T {\n const index = this.children.indexOf(child);\n if (index !== -1) {\n this.children.splice(index, 1);\n if (typeof child === 'object' && child !== null && 'parentNode' in child) {\n (child as { parentNode: unknown }).parentNode = null;\n }\n }\n return child;\n }\n\n replaceChild<T extends Node>(newChild: Node, oldChild: T): T {\n const index = this.children.indexOf(oldChild);\n if (index !== -1) {\n this.children[index] = newChild;\n if (typeof newChild === 'object' && newChild !== null && 'parentNode' in newChild) {\n (newChild as { parentNode: unknown }).parentNode = this;\n }\n if (typeof oldChild === 'object' && oldChild !== null && 'parentNode' in oldChild) {\n (oldChild as { parentNode: unknown }).parentNode = null;\n }\n }\n return oldChild;\n }\n \n // SSR never dispatches events: listeners are accepted and dropped, and\n // queries find nothing (serialize with renderToString instead).\n addEventListener(_type: string, _listener: EventListener): void {}\n removeEventListener(_type: string, _listener: EventListener): void {}\n dispatchEvent(_event: Event): boolean {\n return true;\n }\n querySelector(_selector: string): Element | null {\n return null;\n }\n querySelectorAll(_selector: string): NodeListOf<Element> {\n return [] as unknown as NodeListOf<Element>;\n }\n}\n","export class NucloText {\n nodeType = 3; // Node.TEXT_NODE\n nodeName = '#text';\n data: string;\n textContent: string;\n parentNode: unknown = null;\n \n constructor(data: string) {\n this.data = data;\n this.textContent = data;\n }\n \n get nodeValue(): string {\n return this.data;\n }\n \n set nodeValue(value: string) {\n this.data = value;\n this.textContent = value;\n }\n}\n","import { NucloElement } from './Element';\nimport { NucloText } from './Text';\n\n/**\n * Lightweight DocumentFragment for SSR — prototype methods instead of per-instance closures.\n */\nclass SSRDocumentFragment {\n nodeType: number = 11;\n nodeName: string = '#document-fragment';\n childNodes: Node[] = [];\n children: Element[] = [];\n textContent: string = '';\n\n get firstChild(): Node | null {\n return this.childNodes.length > 0 ? this.childNodes[0] : null;\n }\n\n get lastChild(): Node | null {\n return this.childNodes.length > 0 ? this.childNodes[this.childNodes.length - 1] : null;\n }\n\n appendChild<T extends Node>(child: T): T {\n this.childNodes.push(child);\n if ((child as any).nodeType === 1) {\n this.children.push(child as unknown as Element);\n }\n (child as any).parentNode = this;\n return child;\n }\n\n insertBefore<T extends Node>(newNode: T, refNode: Node | null): T {\n if (!refNode) return this.appendChild(newNode);\n const index = this.childNodes.indexOf(refNode);\n if (index !== -1) {\n this.childNodes.splice(index, 0, newNode);\n if ((newNode as any).nodeType === 1) {\n const elementIndex = this.children.indexOf(refNode as Element);\n if (elementIndex !== -1) {\n this.children.splice(elementIndex, 0, newNode as unknown as Element);\n }\n }\n }\n (newNode as any).parentNode = this;\n return newNode;\n }\n\n removeChild<T extends Node>(child: T): T {\n const index = this.childNodes.indexOf(child);\n if (index !== -1) this.childNodes.splice(index, 1);\n if ((child as any).nodeType === 1) {\n const elementIndex = this.children.indexOf(child as unknown as Element);\n if (elementIndex !== -1) this.children.splice(elementIndex, 1);\n }\n (child as any).parentNode = null;\n return child;\n }\n\n replaceChild<T extends Node>(newChild: T, oldChild: Node): T {\n const index = this.childNodes.indexOf(oldChild);\n if (index !== -1) {\n this.childNodes[index] = newChild;\n if ((oldChild as any).nodeType === 1 && (newChild as any).nodeType === 1) {\n const elementIndex = this.children.indexOf(oldChild as Element);\n if (elementIndex !== -1) {\n this.children[elementIndex] = newChild as unknown as Element;\n }\n }\n }\n (newChild as any).parentNode = this;\n (oldChild as any).parentNode = null;\n return newChild;\n }\n\n querySelector(): null { return null; }\n querySelectorAll(): NodeListOf<Element> { return [] as unknown as NodeListOf<Element>; }\n}\n\nexport class NucloDocument {\n head: ExpandedElement;\n body: ExpandedElement;\n\n constructor() {\n this.head = new NucloElement('head') as unknown as ExpandedElement;\n this.body = new NucloElement('body') as unknown as ExpandedElement;\n }\n \n createElement(tagName: string, _options?: unknown): ExpandedElement {\n return new NucloElement(tagName) as unknown as ExpandedElement;\n }\n \n createElementNS(namespace: string, tagName: string, _options?: unknown): ExpandedElement {\n const element = new NucloElement(tagName) as unknown as ExpandedElement;\n (element as any).namespaceURI = namespace;\n return element;\n }\n \n createTextNode(data: string): Text {\n return new NucloText(data) as unknown as Text;\n }\n \n /**\n * `marker` is passed by nuclo's own text/list/when markers (see\n * createMarker() in shared/dom.ts): renderToString() emits those verbatim\n * and only inspects comments the app created itself.\n */\n createComment(data: string, marker?: boolean): Comment {\n const comment = {\n nodeType: 8,\n nodeName: '#comment',\n data,\n textContent: data,\n nodeValue: data,\n parentNode: null,\n nextSibling: null,\n previousSibling: null,\n marker: marker === true\n };\n return comment as unknown as Comment;\n }\n \n createDocumentFragment(): DocumentFragment {\n return new SSRDocumentFragment() as unknown as DocumentFragment;\n }\n \n // SSR never dispatches events: listeners are accepted and dropped, and\n // queries find nothing.\n querySelector(_selector: string): Element | null {\n return null;\n }\n\n querySelectorAll(_selector: string): NodeListOf<Element> {\n return [] as unknown as NodeListOf<Element>;\n }\n\n addEventListener(_type: string, _listener: EventListener, _options?: boolean | AddEventListenerOptions): void {}\n\n removeEventListener(_type: string, _listener: EventListener, _options?: boolean | AddEventListenerOptions): void {}\n\n dispatchEvent(_event: Event): boolean {\n return true;\n }\n\n contains(_node: Node): boolean {\n return false;\n }\n}\n\nexport const document = globalThis.document || new NucloDocument();","/**\n * Polyfills for Node.js environments\n *\n * This module provides minimal browser API polyfills to allow Nuclo to run in Node.js\n * for server-side rendering (SSR).\n *\n * To use in Node.js:\n * ```typescript\n * import 'nuclo/polyfill';\n * // or\n * import { document, Event, CustomEvent } from 'nuclo/polyfill';\n * ```\n */\n\nexport { NucloDocument, document } from './Document';\nexport { NucloElement } from './Element';\nexport { NucloText } from './Text';\nexport { NucloNode } from './Node';\n\nimport { NucloElement } from './Element';\nimport { NucloNode } from './Node';\nimport { document } from './Document';\n\n// Event and CustomEvent are built into every supported runtime (Node >= 19,\n// Bun, Deno); re-exported for the documented named imports.\nexport const Event = globalThis.Event;\nexport const CustomEvent = globalThis.CustomEvent;\nexport const Node = NucloNode;\nexport const Element = NucloElement;\nexport const HTMLElement = NucloElement;\n\n// Auto-apply polyfills to globalThis if in Node environment (synchronous — no top-level await)\nif (typeof window === 'undefined') {\n const g = globalThis as unknown as {\n document?: typeof document;\n Node?: typeof NucloNode;\n Element?: typeof NucloElement;\n HTMLElement?: typeof NucloElement;\n };\n g.document ??= document;\n g.Node ??= NucloNode;\n g.Element ??= NucloElement;\n g.HTMLElement ??= NucloElement;\n}\n"],"mappings":"mEAAA,MAAMA,EAAuB,CAAC,EAK9B,IAAaC,EAAb,KAAuB,CACrB,SAAmB,EACnB,SAAmB,GACnB,UAA2B,KAC3B,WAAsB,KACtB,YAAsB,GAEtB,IAAI,YAAoC,CACtC,OAAOD,CACT,CACF,ECTME,EAAN,KAAe,CAGb,IAA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CACzF,EAEaM,EAAb,KAA2B,CACzB,KACA,KAEA,aAAc,CACZ,KAAK,KAAO,IAAIb,EAAa,MAAM,EACnC,KAAK,KAAO,IAAIA,EAAa,MAAM,CACrC,CAEA,cAAc,EAAiB,EAAqC,CAClE,OAAO,IAAIA,EAAaC,CAAO,CACjC,CAEA,gBAAgB,EAAmB,EAAiB,EAAqC,CACvF,IAAMa,EAAU,IAAId,EAAaC,CAAO,EAExC,MADA,GAAiB,aAAec,EACzBD,CACT,CAEA,eAAe,EAAoB,CACjC,OAAO,IAAIN,EAAUC,CAAI,CAC3B,CAOA,cAAc,EAAc,EAA2B,CAYrD,MAAO,CAVL,SAAU,EACV,SAAU,WACV,OACA,YAAaA,EACb,UAAWA,EACX,WAAY,KACZ,YAAa,KACb,gBAAiB,KACjB,OAAQO,IAAW,EAER,CACf,CAEA,wBAA2C,CACzC,OAAO,IAAIN,CACb,CAIA,cAAc,EAAmC,CAC/C,OAAO,IACT,CAEA,iBAAiB,EAAwC,CACvD,MAAO,CAAC,CACV,CAEA,iBAAiB,EAAe,EAA0B,EAAoD,CAAC,CAE/G,oBAAoB,EAAe,EAA0B,EAAoD,CAAC,CAElH,cAAc,EAAwB,CACpC,MAAO,EACT,CAEA,SAAS,EAAsB,CAC7B,MAAO,EACT,CACF,EAEA,MAAaO,EAAW,WAAW,UAAY,IAAIJ,EC1HtCK,EAAQ,WAAW,MACnBC,EAAc,WAAW,YACzBC,EAAOzC,EACP0C,EAAUrB,EACVsB,EAActB,EAG3B,GAAI,OAAO,OAAW,IAAa,CACjC,IAAMuB,EAAI,WAMV,EAAE,WAAaN,EACf,EAAE,OAAStC,EACX,EAAE,UAAYqB,EACd,EAAE,cAAgBA,CACpB"}
1
+ {"version":3,"file":"nuclo.polyfill.cjs","names":["NO_CHILDREN","siblingOf","kids","node","i","offset","NucloNode","NucloComment","data","marker","SSRStyle","entries","k","v","name","value","SSRClassList","el","tokens","classes","t","c","token","on","force","oldToken","newToken","index","cb","NucloElement","tagName","child","referenceNode","newNode","oldChild","newChild","NucloText","SSRDocumentFragment","refNode","elementIndex","NucloDocument","element","namespace","document","Event","CustomEvent","Node","Element","HTMLElement","g"],"sources":["../../src/polyfill/Node.ts","../../src/polyfill/Element.ts","../../src/polyfill/Text.ts","../../src/polyfill/Document.ts","../../src/polyfill/index.ts"],"sourcesContent":["/** The child list of a node that can have none (text, comments). */\nexport const NO_CHILDREN: never[] = [];\n\n/**\n * A node's neighbour in its parent's child array.\n *\n * Computed on each read rather than kept as pointers: appendChild is the\n * hottest path in renderToString() and would pay for pointer upkeep on every\n * node, while a sibling walk on a server is rare and short — a region\n * replacing its `empty` content, or a latest region taking a second view.\n */\nexport function siblingOf(node: object, offset: 1 | -1): Node | null {\n const parent = (node as { parentNode: { childNodes?: ArrayLike<Node> } | null }).parentNode;\n const kids = parent?.childNodes;\n if (!kids) return null;\n const i = Array.prototype.indexOf.call(kids, node);\n return i === -1 ? null : (kids[i + offset] ?? null);\n}\n\n/**\n * Base Node class for instanceof checks in Node.js polyfill\n */\nexport class NucloNode {\n nodeType = 1; // ELEMENT_NODE\n nodeName = '';\n nodeValue: string | null = null;\n parentNode: unknown = null;\n textContent = '';\n\n get childNodes(): NodeListOf<ChildNode> {\n return NO_CHILDREN as unknown as NodeListOf<ChildNode>;\n }\n\n get nextSibling(): Node | null {\n return siblingOf(this, 1);\n }\n\n get previousSibling(): Node | null {\n return siblingOf(this, -1);\n }\n}\n\n/** A comment: nuclo's own markers (`marker` set) and the app's. */\nexport class NucloComment extends NucloNode {\n data: string;\n marker: boolean;\n\n constructor(data: string, marker: boolean) {\n super();\n this.nodeType = 8; // COMMENT_NODE\n this.nodeName = '#comment';\n this.data = data;\n this.textContent = data;\n this.nodeValue = data;\n this.marker = marker;\n }\n}\n","import { NucloNode } from './Node';\n\n/**\n * Lightweight style object for SSR — prototype methods instead of Object.defineProperty per element.\n * Stores CSS properties as own properties and provides cssText/setProperty/getPropertyValue via prototype.\n */\nclass SSRStyle {\n [key: string]: unknown;\n\n get cssText() {\n const entries = Object.entries(this);\n if (entries.length === 0) return '';\n return entries.map(([k, v]) => `${k}: ${v}`).join('; ');\n }\n\n setProperty(name: string, value: string) {\n (this as Record<string, unknown>)[name] = value;\n }\n\n getPropertyValue(name: string) {\n return ((this as Record<string, unknown>)[name] as string) || '';\n }\n}\n\n// Lightweight classList for SSR — prototype methods instead of per-element closures\nclass SSRClassList {\n private _el: NucloElement;\n constructor(el: NucloElement) { this._el = el; }\n\n private tokens(): string[] { return this._el.className.split(' ').filter(Boolean); }\n\n add(...tokens: string[]) {\n const classes = this.tokens();\n for (const t of tokens) if (t && !classes.includes(t)) classes.push(t);\n this._el.className = classes.join(' ');\n }\n remove(...tokens: string[]) {\n this._el.className = this.tokens().filter(c => !tokens.includes(c)).join(' ');\n }\n contains(token: string) { return this.tokens().includes(token); }\n toggle(token: string, force?: boolean) {\n const on = force ?? !this.contains(token);\n if (on) this.add(token); else this.remove(token);\n return on;\n }\n replace(oldToken: string, newToken: string) {\n if (!this.contains(oldToken)) return false;\n this.remove(oldToken); this.add(newToken); return true;\n }\n item(index: number): string | null { return this.tokens()[index] ?? null; }\n get length() { return this.tokens().length; }\n get value() { return this._el.className; }\n set value(v: string) { this._el.className = v; }\n toString() { return this._el.className; }\n supports(_token: string) { return false; }\n forEach(cb: (value: string, key: number, parent: DOMTokenList) => void) {\n this.tokens().forEach((token, i) => cb(token, i, this as unknown as DOMTokenList));\n }\n [Symbol.iterator](): IterableIterator<string> { return this.tokens().values(); }\n entries(): IterableIterator<[number, string]> { return this.tokens().entries(); }\n keys(): IterableIterator<number> { return this.tokens().keys(); }\n values(): IterableIterator<string> { return this.tokens().values(); }\n}\n\nexport class NucloElement extends NucloNode {\n tagName: string;\n children: unknown[];\n className = '';\n textContent = '';\n parentNode: unknown = null;\n id = '';\n namespaceURI?: string;\n\n // style/classList are allocated lazily: the vast majority of SSR elements\n // never touch either (className is stored on the .className string, and the\n // serializer reads the backing field directly), so eagerly constructing an\n // SSRStyle + SSRClassList per element would be pure allocation churn.\n private _style?: CSSStyleDeclaration;\n private _classList?: DOMTokenList;\n\n // attributes is allocated lazily too — most elements carry their identity on\n // .className/.id (separate string fields) and never call setAttribute. Reads\n // short-circuit on the undefined backing map without allocating; the\n // serializer reads _attributes directly. The public getter still lazily\n // materializes a Map for any external `el.attributes` consumer.\n private _attributes?: Map<string, string>;\n\n get attributes(): Map<string, string> {\n return (this._attributes ??= new Map<string, string>());\n }\n set attributes(value: Map<string, string>) {\n this._attributes = value;\n }\n\n // `{ innerText }` behaves like `{ textContent }` on the server: plain text\n // the serializer escapes. (Prototype accessor — no per-element field.)\n get innerText() {\n return this.textContent;\n }\n set innerText(value: string) {\n this.textContent = value;\n }\n\n get style(): CSSStyleDeclaration {\n return (this._style ??= new SSRStyle() as unknown as CSSStyleDeclaration);\n }\n set style(value: CSSStyleDeclaration) {\n this._style = value;\n }\n\n get classList(): DOMTokenList {\n return (this._classList ??= new SSRClassList(this) as unknown as DOMTokenList);\n }\n set classList(value: DOMTokenList) {\n this._classList = value;\n }\n\n constructor(tagName: string) {\n super();\n this.tagName = tagName.toLowerCase();\n this.nodeType = 1; // ELEMENT_NODE\n this.nodeName = tagName.toUpperCase();\n this.children = [];\n }\n\n /** Every node, elements, text and comments alike (children holds them all). */\n get childNodes(): NodeListOf<ChildNode> {\n return this.children as unknown as NodeListOf<ChildNode>;\n }\n\n appendChild<T extends Node>(child: T): T {\n // Spec behaviour: appending a DocumentFragment moves its children into this\n // node and leaves the fragment empty. The list runtime relies on this to\n // batch row insertions.\n if ((child as any)?.nodeType === 11) {\n // Detach the fragment's backing array before iterating (instead of\n // slicing it) — the fragment is emptied either way, and reassigning\n // first means the loop never has to allocate a copy just to guard\n // against the array it's about to discard.\n const kids = (child as any).childNodes as Node[];\n (child as any).childNodes = [];\n if ((child as any).children) (child as any).children = [];\n for (let i = 0; i < kids.length; i++) this.appendChild(kids[i]);\n return child;\n }\n this.children.push(child);\n if (typeof child === 'object' && child !== null && 'parentNode' in child) {\n (child as { parentNode: unknown }).parentNode = this;\n }\n return child;\n }\n \n setAttribute(name: string, value: string) {\n (this._attributes ??= new Map<string, string>()).set(name, value);\n if (name === 'class') {\n this.className = value;\n } else if (name === 'id') {\n this.id = value;\n }\n }\n\n getAttribute(name: string): string | null {\n return this._attributes?.get(name) ?? null;\n }\n\n removeAttribute(name: string) {\n this._attributes?.delete(name);\n if (name === 'class') {\n this.className = '';\n }\n }\n\n hasAttribute(name: string) {\n return this._attributes?.has(name) ?? false;\n }\n \n insertBefore<T extends Node>(newNode: T, referenceNode: Node | null): T {\n if (referenceNode === null) {\n return this.appendChild(newNode);\n }\n // Spec behaviour: inserting a DocumentFragment moves its children (in order)\n // before the reference node and empties the fragment.\n if ((newNode as any)?.nodeType === 11) {\n const kids = (newNode as any).childNodes as Node[];\n (newNode as any).childNodes = [];\n if ((newNode as any).children) (newNode as any).children = [];\n for (let i = 0; i < kids.length; i++) this.insertBefore(kids[i], referenceNode);\n return newNode;\n }\n const index = this.children.indexOf(referenceNode);\n if (index !== -1) {\n this.children.splice(index, 0, newNode);\n if (typeof newNode === 'object' && newNode !== null && 'parentNode' in newNode) {\n (newNode as { parentNode: unknown }).parentNode = this;\n }\n }\n return newNode;\n }\n \n removeChild<T extends Node>(child: T): T {\n const index = this.children.indexOf(child);\n if (index !== -1) {\n this.children.splice(index, 1);\n if (typeof child === 'object' && child !== null && 'parentNode' in child) {\n (child as { parentNode: unknown }).parentNode = null;\n }\n }\n return child;\n }\n\n replaceChild<T extends Node>(newChild: Node, oldChild: T): T {\n const index = this.children.indexOf(oldChild);\n if (index !== -1) {\n this.children[index] = newChild;\n if (typeof newChild === 'object' && newChild !== null && 'parentNode' in newChild) {\n (newChild as { parentNode: unknown }).parentNode = this;\n }\n if (typeof oldChild === 'object' && oldChild !== null && 'parentNode' in oldChild) {\n (oldChild as { parentNode: unknown }).parentNode = null;\n }\n }\n return oldChild;\n }\n \n // SSR never dispatches events: listeners are accepted and dropped, and\n // queries find nothing (serialize with renderToString instead).\n addEventListener(_type: string, _listener: EventListener) {}\n removeEventListener(_type: string, _listener: EventListener) {}\n dispatchEvent(_event: Event) {\n return true;\n }\n querySelector(_selector: string): Element | null {\n return null;\n }\n querySelectorAll(_selector: string): NodeListOf<Element> {\n return [] as unknown as NodeListOf<Element>;\n }\n}\n","import { NO_CHILDREN, siblingOf } from './Node';\n\nexport class NucloText {\n nodeType = 3; // Node.TEXT_NODE\n nodeName = '#text';\n data: string;\n textContent: string;\n parentNode: unknown = null;\n \n constructor(data: string) {\n this.data = data;\n this.textContent = data;\n }\n \n get nodeValue() {\n return this.data;\n }\n \n set nodeValue(value: string) {\n this.data = value;\n this.textContent = value;\n }\n\n get childNodes(): NodeListOf<ChildNode> {\n return NO_CHILDREN as unknown as NodeListOf<ChildNode>;\n }\n\n get nextSibling(): Node | null {\n return siblingOf(this, 1);\n }\n\n get previousSibling(): Node | null {\n return siblingOf(this, -1);\n }\n}\n","import { NucloElement } from './Element';\nimport { NucloText } from './Text';\nimport { NucloComment } from './Node';\n\n/**\n * Lightweight DocumentFragment for SSR — prototype methods instead of per-instance closures.\n */\nclass SSRDocumentFragment {\n nodeType = 11;\n nodeName = '#document-fragment';\n childNodes: Node[] = [];\n children: Element[] = [];\n textContent = '';\n\n get firstChild(): Node | null {\n return this.childNodes.length > 0 ? this.childNodes[0] : null;\n }\n\n get lastChild(): Node | null {\n return this.childNodes.length > 0 ? this.childNodes[this.childNodes.length - 1] : null;\n }\n\n appendChild<T extends Node>(child: T): T {\n this.childNodes.push(child);\n if ((child as any).nodeType === 1) {\n this.children.push(child as unknown as Element);\n }\n (child as any).parentNode = this;\n return child;\n }\n\n insertBefore<T extends Node>(newNode: T, refNode: Node | null): T {\n if (!refNode) return this.appendChild(newNode);\n const index = this.childNodes.indexOf(refNode);\n if (index !== -1) {\n this.childNodes.splice(index, 0, newNode);\n if ((newNode as any).nodeType === 1) {\n const elementIndex = this.children.indexOf(refNode as Element);\n if (elementIndex !== -1) {\n this.children.splice(elementIndex, 0, newNode as unknown as Element);\n }\n }\n }\n (newNode as any).parentNode = this;\n return newNode;\n }\n\n removeChild<T extends Node>(child: T): T {\n const index = this.childNodes.indexOf(child);\n if (index !== -1) this.childNodes.splice(index, 1);\n if ((child as any).nodeType === 1) {\n const elementIndex = this.children.indexOf(child as unknown as Element);\n if (elementIndex !== -1) this.children.splice(elementIndex, 1);\n }\n (child as any).parentNode = null;\n return child;\n }\n\n replaceChild<T extends Node>(newChild: T, oldChild: Node): T {\n const index = this.childNodes.indexOf(oldChild);\n if (index !== -1) {\n this.childNodes[index] = newChild;\n if ((oldChild as any).nodeType === 1 && (newChild as any).nodeType === 1) {\n const elementIndex = this.children.indexOf(oldChild as Element);\n if (elementIndex !== -1) {\n this.children[elementIndex] = newChild as unknown as Element;\n }\n }\n }\n (newChild as any).parentNode = this;\n (oldChild as any).parentNode = null;\n return newChild;\n }\n\n querySelector(): null { return null; }\n querySelectorAll(): NodeListOf<Element> { return [] as unknown as NodeListOf<Element>; }\n}\n\nexport class NucloDocument {\n head: ExpandedElement;\n body: ExpandedElement;\n\n constructor() {\n this.head = new NucloElement('head') as unknown as ExpandedElement;\n this.body = new NucloElement('body') as unknown as ExpandedElement;\n }\n \n createElement(tagName: string, _options?: unknown): ExpandedElement {\n return new NucloElement(tagName) as unknown as ExpandedElement;\n }\n \n createElementNS(namespace: string, tagName: string, _options?: unknown): ExpandedElement {\n const element = new NucloElement(tagName) as unknown as ExpandedElement;\n (element as any).namespaceURI = namespace;\n return element;\n }\n \n createTextNode(data: string): Text {\n return new NucloText(data) as unknown as Text;\n }\n \n /**\n * `marker` is passed by nuclo's own text/list/when markers (see\n * createMarker() in shared/dom.ts): renderToString() emits those verbatim\n * and only inspects comments the app created itself.\n */\n createComment(data: string, marker?: boolean): Comment {\n return new NucloComment(data, marker === true) as unknown as Comment;\n }\n \n createDocumentFragment(): DocumentFragment {\n return new SSRDocumentFragment() as unknown as DocumentFragment;\n }\n \n // SSR never dispatches events: listeners are accepted and dropped, and\n // queries find nothing.\n querySelector(_selector: string): Element | null {\n return null;\n }\n\n querySelectorAll(_selector: string): NodeListOf<Element> {\n return [] as unknown as NodeListOf<Element>;\n }\n\n addEventListener(_type: string, _listener: EventListener, _options?: boolean | AddEventListenerOptions) {}\n\n removeEventListener(_type: string, _listener: EventListener, _options?: boolean | AddEventListenerOptions) {}\n\n dispatchEvent(_event: Event) {\n return true;\n }\n\n contains(_node: Node) {\n return false;\n }\n}\n\nexport const document = globalThis.document || new NucloDocument();","/**\n * Polyfills for Node.js environments\n *\n * This module provides minimal browser API polyfills to allow Nuclo to run in Node.js\n * for server-side rendering (SSR).\n *\n * To use in Node.js:\n * ```typescript\n * import 'nuclo/polyfill';\n * // or\n * import { document, Event, CustomEvent } from 'nuclo/polyfill';\n * ```\n */\n\nexport { NucloDocument, document } from './Document';\nexport { NucloElement } from './Element';\nexport { NucloText } from './Text';\nexport { NucloNode } from './Node';\n\nimport { NucloElement } from './Element';\nimport { NucloNode } from './Node';\nimport { document } from './Document';\n\n// Event and CustomEvent are built into every supported runtime (Node >= 19,\n// Bun, Deno); re-exported for the documented named imports.\nexport const Event = globalThis.Event;\nexport const CustomEvent = globalThis.CustomEvent;\nexport const Node = NucloNode;\nexport const Element = NucloElement;\nexport const HTMLElement = NucloElement;\n\n// Auto-apply polyfills to globalThis if in Node environment (synchronous — no top-level await)\nif (typeof window === 'undefined') {\n const g = globalThis as unknown as {\n document?: typeof document;\n Node?: typeof NucloNode;\n Element?: typeof NucloElement;\n HTMLElement?: typeof NucloElement;\n };\n g.document ??= document;\n g.Node ??= NucloNode;\n g.Element ??= NucloElement;\n g.HTMLElement ??= NucloElement;\n}\n"],"mappings":"mEACA,MAAaA,EAAuB,CAAC,EAUrC,SAAgBC,EAAU,EAAc,EAA6B,CAEnE,IAAMC,EADUC,EAAiE,YAC5D,WACrB,GAAI,CAACD,EAAM,OAAO,KAClB,IAAME,EAAI,MAAM,UAAU,QAAQ,KAAKF,EAAMC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B,EAAwC,CACvD,MAAO,CAAC,CACV,CAEA,iBAAiB,EAAe,EAA0B,EAA8C,CAAC,CAEzG,oBAAoB,EAAe,EAA0B,EAA8C,CAAC,CAE5G,cAAc,EAAe,CAC3B,MAAO,EACT,CAEA,SAAS,EAAa,CACpB,MAAO,EACT,CACF,EAEA,MAAaM,EAAW,WAAW,UAAY,IAAIH,EChHtCI,EAAQ,WAAW,MACnBC,EAAc,WAAW,YACzBC,EAAOxC,EACPyC,EAAUlB,EACVmB,EAAcnB,EAG3B,GAAI,OAAO,OAAW,IAAa,CACjC,IAAMoB,EAAI,WAMV,EAAE,WAAaN,EACf,EAAE,OAASrC,EACX,EAAE,UAAYuB,EACd,EAAE,cAAgBA,CACpB"}
@@ -1,2 +1,2 @@
1
- const e=[];var t=class{nodeType=1;nodeName=``;nodeValue=null;parentNode=null;textContent=``;get childNodes(){return e}},n=class{get cssText(){let e=Object.entries(this);return e.length===0?``:e.map(([e,t])=>`${e}: ${t}`).join(`; `)}setProperty(e,t){this[e]=t}getPropertyValue(e){return this[e]||``}},r=class{_el;constructor(e){this._el=e}tokens(){return this._el.className.split(` `).filter(Boolean)}add(...e){let t=this.tokens();for(let n of e)n&&!t.includes(n)&&t.push(n);this._el.className=t.join(` `)}remove(...e){this._el.className=this.tokens().filter(t=>!e.includes(t)).join(` `)}contains(e){return this.tokens().includes(e)}toggle(e,t){let n=t??!this.contains(e);return n?this.add(e):this.remove(e),n}replace(e,t){return this.contains(e)?(this.remove(e),this.add(t),!0):!1}item(e){return this.tokens()[e]??null}get length(){return this.tokens().length}get value(){return this._el.className}set value(e){this._el.className=e}toString(){return this._el.className}supports(e){return!1}forEach(e){this.tokens().forEach((t,n)=>e(t,n,this))}[Symbol.iterator](){return this.tokens().values()}entries(){return this.tokens().entries()}keys(){return this.tokens().keys()}values(){return this.tokens().values()}},i=class extends t{tagName;children;className=``;textContent=``;parentNode=null;id=``;namespaceURI;_style;_classList;_attributes;get attributes(){return this._attributes??=/* @__PURE__ */ new Map}set attributes(e){this._attributes=e}get innerText(){return this.textContent}set innerText(e){this.textContent=e}get style(){return this._style??=new n}set style(e){this._style=e}get classList(){return this._classList??=new r(this)}set classList(e){this._classList=e}constructor(e){super(),this.tagName=e.toLowerCase(),this.nodeType=1,this.nodeName=e.toUpperCase(),this.children=[]}get childNodes(){return this.children}appendChild(e){if(e?.nodeType===11){let t=e.childNodes;e.childNodes=[],e.children&&=[];for(let e=0;e<t.length;e++)this.appendChild(t[e]);return e}return this.children.push(e),typeof e==`object`&&e&&`parentNode`in e&&(e.parentNode=this),e}setAttribute(e,t){(this._attributes??=/* @__PURE__ */ new Map).set(e,t),e===`class`?this.className=t:e===`id`&&(this.id=t)}getAttribute(e){return this._attributes?.get(e)??null}removeAttribute(e){this._attributes?.delete(e),e===`class`&&(this.className=``)}hasAttribute(e){return this._attributes?.has(e)??!1}insertBefore(e,t){if(t===null)return this.appendChild(e);if(e?.nodeType===11){let n=e.childNodes;e.childNodes=[],e.children&&=[];for(let e=0;e<n.length;e++)this.insertBefore(n[e],t);return e}let n=this.children.indexOf(t);return n!==-1&&(this.children.splice(n,0,e),typeof e==`object`&&e&&`parentNode`in e&&(e.parentNode=this)),e}removeChild(e){let t=this.children.indexOf(e);return t!==-1&&(this.children.splice(t,1),typeof e==`object`&&e&&`parentNode`in e&&(e.parentNode=null)),e}replaceChild(e,t){let n=this.children.indexOf(t);return n!==-1&&(this.children[n]=e,typeof e==`object`&&e&&`parentNode`in e&&(e.parentNode=this),typeof t==`object`&&t&&`parentNode`in t&&(t.parentNode=null)),t}addEventListener(e,t){}removeEventListener(e,t){}dispatchEvent(e){return!0}querySelector(e){return null}querySelectorAll(e){return[]}},a=class{nodeType=3;nodeName=`#text`;data;textContent;parentNode=null;constructor(e){this.data=e,this.textContent=e}get nodeValue(){return this.data}set nodeValue(e){this.data=e,this.textContent=e}},o=class{nodeType=11;nodeName=`#document-fragment`;childNodes=[];children=[];textContent=``;get firstChild(){return this.childNodes.length>0?this.childNodes[0]:null}get lastChild(){return this.childNodes.length>0?this.childNodes[this.childNodes.length-1]:null}appendChild(e){return this.childNodes.push(e),e.nodeType===1&&this.children.push(e),e.parentNode=this,e}insertBefore(e,t){if(!t)return this.appendChild(e);let n=this.childNodes.indexOf(t);if(n!==-1&&(this.childNodes.splice(n,0,e),e.nodeType===1)){let n=this.children.indexOf(t);n!==-1&&this.children.splice(n,0,e)}return e.parentNode=this,e}removeChild(e){let t=this.childNodes.indexOf(e);if(t!==-1&&this.childNodes.splice(t,1),e.nodeType===1){let t=this.children.indexOf(e);t!==-1&&this.children.splice(t,1)}return e.parentNode=null,e}replaceChild(e,t){let n=this.childNodes.indexOf(t);if(n!==-1&&(this.childNodes[n]=e,t.nodeType===1&&e.nodeType===1)){let n=this.children.indexOf(t);n!==-1&&(this.children[n]=e)}return e.parentNode=this,t.parentNode=null,e}querySelector(){return null}querySelectorAll(){return[]}},s=class{head;body;constructor(){this.head=new i(`head`),this.body=new i(`body`)}createElement(e,t){return new i(e)}createElementNS(e,t,n){let r=new i(t);return r.namespaceURI=e,r}createTextNode(e){return new a(e)}createComment(e,t){return{nodeType:8,nodeName:`#comment`,data:e,textContent:e,nodeValue:e,parentNode:null,nextSibling:null,previousSibling:null,marker:t===!0}}createDocumentFragment(){return new o}querySelector(e){return null}querySelectorAll(e){return[]}addEventListener(e,t,n){}removeEventListener(e,t,n){}dispatchEvent(e){return!0}contains(e){return!1}};const c=globalThis.document||new s,l=globalThis.Event,u=globalThis.CustomEvent,d=t,f=i,p=i;if(typeof window>`u`){let e=globalThis;e.document??=c,e.Node??=t,e.Element??=i,e.HTMLElement??=i}export{u as CustomEvent,f as Element,l as Event,p as HTMLElement,d as Node,s as NucloDocument,i as NucloElement,t as NucloNode,a as NucloText,c as document};
1
+ const e=[];function t(e,t){let n=e.parentNode?.childNodes;if(!n)return null;let r=Array.prototype.indexOf.call(n,e);return r===-1?null:n[r+t]??null}var n=class{nodeType=1;nodeName=``;nodeValue=null;parentNode=null;textContent=``;get childNodes(){return e}get nextSibling(){return t(this,1)}get previousSibling(){return t(this,-1)}},r=class extends n{data;marker;constructor(e,t){super(),this.nodeType=8,this.nodeName=`#comment`,this.data=e,this.textContent=e,this.nodeValue=e,this.marker=t}},i=class{get cssText(){let e=Object.entries(this);return e.length===0?``:e.map(([e,t])=>`${e}: ${t}`).join(`; `)}setProperty(e,t){this[e]=t}getPropertyValue(e){return this[e]||``}},a=class{_el;constructor(e){this._el=e}tokens(){return this._el.className.split(` `).filter(Boolean)}add(...e){let t=this.tokens();for(let n of e)n&&!t.includes(n)&&t.push(n);this._el.className=t.join(` `)}remove(...e){this._el.className=this.tokens().filter(t=>!e.includes(t)).join(` `)}contains(e){return this.tokens().includes(e)}toggle(e,t){let n=t??!this.contains(e);return n?this.add(e):this.remove(e),n}replace(e,t){return this.contains(e)?(this.remove(e),this.add(t),!0):!1}item(e){return this.tokens()[e]??null}get length(){return this.tokens().length}get value(){return this._el.className}set value(e){this._el.className=e}toString(){return this._el.className}supports(e){return!1}forEach(e){this.tokens().forEach((t,n)=>e(t,n,this))}[Symbol.iterator](){return this.tokens().values()}entries(){return this.tokens().entries()}keys(){return this.tokens().keys()}values(){return this.tokens().values()}},o=class extends n{tagName;children;className=``;textContent=``;parentNode=null;id=``;namespaceURI;_style;_classList;_attributes;get attributes(){return this._attributes??=/* @__PURE__ */ new Map}set attributes(e){this._attributes=e}get innerText(){return this.textContent}set innerText(e){this.textContent=e}get style(){return this._style??=new i}set style(e){this._style=e}get classList(){return this._classList??=new a(this)}set classList(e){this._classList=e}constructor(e){super(),this.tagName=e.toLowerCase(),this.nodeType=1,this.nodeName=e.toUpperCase(),this.children=[]}get childNodes(){return this.children}appendChild(e){if(e?.nodeType===11){let t=e.childNodes;e.childNodes=[],e.children&&=[];for(let e=0;e<t.length;e++)this.appendChild(t[e]);return e}return this.children.push(e),typeof e==`object`&&e&&`parentNode`in e&&(e.parentNode=this),e}setAttribute(e,t){(this._attributes??=/* @__PURE__ */ new Map).set(e,t),e===`class`?this.className=t:e===`id`&&(this.id=t)}getAttribute(e){return this._attributes?.get(e)??null}removeAttribute(e){this._attributes?.delete(e),e===`class`&&(this.className=``)}hasAttribute(e){return this._attributes?.has(e)??!1}insertBefore(e,t){if(t===null)return this.appendChild(e);if(e?.nodeType===11){let n=e.childNodes;e.childNodes=[],e.children&&=[];for(let e=0;e<n.length;e++)this.insertBefore(n[e],t);return e}let n=this.children.indexOf(t);return n!==-1&&(this.children.splice(n,0,e),typeof e==`object`&&e&&`parentNode`in e&&(e.parentNode=this)),e}removeChild(e){let t=this.children.indexOf(e);return t!==-1&&(this.children.splice(t,1),typeof e==`object`&&e&&`parentNode`in e&&(e.parentNode=null)),e}replaceChild(e,t){let n=this.children.indexOf(t);return n!==-1&&(this.children[n]=e,typeof e==`object`&&e&&`parentNode`in e&&(e.parentNode=this),typeof t==`object`&&t&&`parentNode`in t&&(t.parentNode=null)),t}addEventListener(e,t){}removeEventListener(e,t){}dispatchEvent(e){return!0}querySelector(e){return null}querySelectorAll(e){return[]}},s=class{nodeType=3;nodeName=`#text`;data;textContent;parentNode=null;constructor(e){this.data=e,this.textContent=e}get nodeValue(){return this.data}set nodeValue(e){this.data=e,this.textContent=e}get childNodes(){return e}get nextSibling(){return t(this,1)}get previousSibling(){return t(this,-1)}},c=class{nodeType=11;nodeName=`#document-fragment`;childNodes=[];children=[];textContent=``;get firstChild(){return this.childNodes.length>0?this.childNodes[0]:null}get lastChild(){return this.childNodes.length>0?this.childNodes[this.childNodes.length-1]:null}appendChild(e){return this.childNodes.push(e),e.nodeType===1&&this.children.push(e),e.parentNode=this,e}insertBefore(e,t){if(!t)return this.appendChild(e);let n=this.childNodes.indexOf(t);if(n!==-1&&(this.childNodes.splice(n,0,e),e.nodeType===1)){let n=this.children.indexOf(t);n!==-1&&this.children.splice(n,0,e)}return e.parentNode=this,e}removeChild(e){let t=this.childNodes.indexOf(e);if(t!==-1&&this.childNodes.splice(t,1),e.nodeType===1){let t=this.children.indexOf(e);t!==-1&&this.children.splice(t,1)}return e.parentNode=null,e}replaceChild(e,t){let n=this.childNodes.indexOf(t);if(n!==-1&&(this.childNodes[n]=e,t.nodeType===1&&e.nodeType===1)){let n=this.children.indexOf(t);n!==-1&&(this.children[n]=e)}return e.parentNode=this,t.parentNode=null,e}querySelector(){return null}querySelectorAll(){return[]}},l=class{head;body;constructor(){this.head=new o(`head`),this.body=new o(`body`)}createElement(e,t){return new o(e)}createElementNS(e,t,n){let r=new o(t);return r.namespaceURI=e,r}createTextNode(e){return new s(e)}createComment(e,t){return new r(e,t===!0)}createDocumentFragment(){return new c}querySelector(e){return null}querySelectorAll(e){return[]}addEventListener(e,t,n){}removeEventListener(e,t,n){}dispatchEvent(e){return!0}contains(e){return!1}};const u=globalThis.document||new l,d=globalThis.Event,f=globalThis.CustomEvent,p=n,m=o,h=o;if(typeof window>`u`){let e=globalThis;e.document??=u,e.Node??=n,e.Element??=o,e.HTMLElement??=o}export{f as CustomEvent,m as Element,d as Event,h as HTMLElement,p as Node,l as NucloDocument,o as NucloElement,n as NucloNode,s as NucloText,u as document};
2
2
  //# sourceMappingURL=nuclo.polyfill.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"nuclo.polyfill.mjs","names":["NO_CHILDREN","NucloNode","SSRStyle","entries","k","v","name","value","SSRClassList","el","tokens","classes","t","c","token","on","force","oldToken","newToken","index","cb","i","NucloElement","tagName","child","kids","referenceNode","newNode","oldChild","newChild","NucloText","data","SSRDocumentFragment","refNode","elementIndex","NucloDocument","element","namespace","marker","document","Event","CustomEvent","Node","Element","HTMLElement","g"],"sources":["../../src/polyfill/Node.ts","../../src/polyfill/Element.ts","../../src/polyfill/Text.ts","../../src/polyfill/Document.ts","../../src/polyfill/index.ts"],"sourcesContent":["const NO_CHILDREN: never[] = [];\n\n/**\n * Base Node class for instanceof checks in Node.js polyfill\n */\nexport class NucloNode {\n nodeType: number = 1; // ELEMENT_NODE\n nodeName: string = '';\n nodeValue: string | null = null;\n parentNode: unknown = null;\n textContent: string = '';\n\n get childNodes(): NodeListOf<ChildNode> {\n return NO_CHILDREN as unknown as NodeListOf<ChildNode>;\n }\n}\n","import { NucloNode } from './Node';\n\n/**\n * Lightweight style object for SSR — prototype methods instead of Object.defineProperty per element.\n * Stores CSS properties as own properties and provides cssText/setProperty/getPropertyValue via prototype.\n */\nclass SSRStyle {\n [key: string]: unknown;\n\n get cssText(): string {\n const entries = Object.entries(this);\n if (entries.length === 0) return '';\n return entries.map(([k, v]) => `${k}: ${v}`).join('; ');\n }\n\n setProperty(name: string, value: string): void {\n (this as Record<string, unknown>)[name] = value;\n }\n\n getPropertyValue(name: string): string {\n return ((this as Record<string, unknown>)[name] as string) || '';\n }\n}\n\n// Lightweight classList for SSR — prototype methods instead of per-element closures\nclass SSRClassList {\n private _el: NucloElement;\n constructor(el: NucloElement) { this._el = el; }\n\n private tokens(): string[] { return this._el.className.split(' ').filter(Boolean); }\n\n add(...tokens: string[]): void {\n const classes = this.tokens();\n for (const t of tokens) if (t && !classes.includes(t)) classes.push(t);\n this._el.className = classes.join(' ');\n }\n remove(...tokens: string[]): void {\n this._el.className = this.tokens().filter(c => !tokens.includes(c)).join(' ');\n }\n contains(token: string): boolean { return this.tokens().includes(token); }\n toggle(token: string, force?: boolean): boolean {\n const on = force ?? !this.contains(token);\n if (on) this.add(token); else this.remove(token);\n return on;\n }\n replace(oldToken: string, newToken: string): boolean {\n if (!this.contains(oldToken)) return false;\n this.remove(oldToken); this.add(newToken); return true;\n }\n item(index: number): string | null { return this.tokens()[index] ?? null; }\n get length(): number { return this.tokens().length; }\n get value(): string { return this._el.className; }\n set value(v: string) { this._el.className = v; }\n toString(): string { return this._el.className; }\n supports(_token: string): boolean { return false; }\n forEach(cb: (value: string, key: number, parent: DOMTokenList) => void): void {\n this.tokens().forEach((token, i) => cb(token, i, this as unknown as DOMTokenList));\n }\n [Symbol.iterator](): IterableIterator<string> { return this.tokens().values(); }\n entries(): IterableIterator<[number, string]> { return this.tokens().entries(); }\n keys(): IterableIterator<number> { return this.tokens().keys(); }\n values(): IterableIterator<string> { return this.tokens().values(); }\n}\n\nexport class NucloElement extends NucloNode {\n tagName: string;\n children: unknown[];\n className: string = '';\n textContent: string = '';\n parentNode: unknown = null;\n id: string = '';\n namespaceURI?: string;\n\n // style/classList are allocated lazily: the vast majority of SSR elements\n // never touch either (className is stored on the .className string, and the\n // serializer reads the backing field directly), so eagerly constructing an\n // SSRStyle + SSRClassList per element would be pure allocation churn.\n private _style?: CSSStyleDeclaration;\n private _classList?: DOMTokenList;\n\n // attributes is allocated lazily too — most elements carry their identity on\n // .className/.id (separate string fields) and never call setAttribute. Reads\n // short-circuit on the undefined backing map without allocating; the\n // serializer reads _attributes directly. The public getter still lazily\n // materializes a Map for any external `el.attributes` consumer.\n private _attributes?: Map<string, string>;\n\n get attributes(): Map<string, string> {\n return (this._attributes ??= new Map<string, string>());\n }\n set attributes(value: Map<string, string>) {\n this._attributes = value;\n }\n\n // `{ innerText }` behaves like `{ textContent }` on the server: plain text\n // the serializer escapes. (Prototype accessor — no per-element field.)\n get innerText(): string {\n return this.textContent;\n }\n set innerText(value: string) {\n this.textContent = value;\n }\n\n get style(): CSSStyleDeclaration {\n return (this._style ??= new SSRStyle() as unknown as CSSStyleDeclaration);\n }\n set style(value: CSSStyleDeclaration) {\n this._style = value;\n }\n\n get classList(): DOMTokenList {\n return (this._classList ??= new SSRClassList(this) as unknown as DOMTokenList);\n }\n set classList(value: DOMTokenList) {\n this._classList = value;\n }\n\n constructor(tagName: string) {\n super();\n this.tagName = tagName.toLowerCase();\n this.nodeType = 1; // ELEMENT_NODE\n this.nodeName = tagName.toUpperCase();\n this.children = [];\n }\n\n /** Every node, elements, text and comments alike (children holds them all). */\n get childNodes(): NodeListOf<ChildNode> {\n return this.children as unknown as NodeListOf<ChildNode>;\n }\n\n appendChild<T extends Node>(child: T): T {\n // Spec behaviour: appending a DocumentFragment moves its children into this\n // node and leaves the fragment empty. The list runtime relies on this to\n // batch row insertions.\n if ((child as any)?.nodeType === 11) {\n // Detach the fragment's backing array before iterating (instead of\n // slicing it) — the fragment is emptied either way, and reassigning\n // first means the loop never has to allocate a copy just to guard\n // against the array it's about to discard.\n const kids = (child as any).childNodes as Node[];\n (child as any).childNodes = [];\n if ((child as any).children) (child as any).children = [];\n for (let i = 0; i < kids.length; i++) this.appendChild(kids[i]);\n return child;\n }\n this.children.push(child);\n if (typeof child === 'object' && child !== null && 'parentNode' in child) {\n (child as { parentNode: unknown }).parentNode = this;\n }\n return child;\n }\n \n setAttribute(name: string, value: string): void {\n (this._attributes ??= new Map<string, string>()).set(name, value);\n if (name === 'class') {\n this.className = value;\n } else if (name === 'id') {\n this.id = value;\n }\n }\n\n getAttribute(name: string): string | null {\n return this._attributes?.get(name) ?? null;\n }\n\n removeAttribute(name: string): void {\n this._attributes?.delete(name);\n if (name === 'class') {\n this.className = '';\n }\n }\n\n hasAttribute(name: string): boolean {\n return this._attributes?.has(name) ?? false;\n }\n \n insertBefore<T extends Node>(newNode: T, referenceNode: Node | null): T {\n if (referenceNode === null) {\n return this.appendChild(newNode);\n }\n // Spec behaviour: inserting a DocumentFragment moves its children (in order)\n // before the reference node and empties the fragment.\n if ((newNode as any)?.nodeType === 11) {\n const kids = (newNode as any).childNodes as Node[];\n (newNode as any).childNodes = [];\n if ((newNode as any).children) (newNode as any).children = [];\n for (let i = 0; i < kids.length; i++) this.insertBefore(kids[i], referenceNode);\n return newNode;\n }\n const index = this.children.indexOf(referenceNode);\n if (index !== -1) {\n this.children.splice(index, 0, newNode);\n if (typeof newNode === 'object' && newNode !== null && 'parentNode' in newNode) {\n (newNode as { parentNode: unknown }).parentNode = this;\n }\n }\n return newNode;\n }\n \n removeChild<T extends Node>(child: T): T {\n const index = this.children.indexOf(child);\n if (index !== -1) {\n this.children.splice(index, 1);\n if (typeof child === 'object' && child !== null && 'parentNode' in child) {\n (child as { parentNode: unknown }).parentNode = null;\n }\n }\n return child;\n }\n\n replaceChild<T extends Node>(newChild: Node, oldChild: T): T {\n const index = this.children.indexOf(oldChild);\n if (index !== -1) {\n this.children[index] = newChild;\n if (typeof newChild === 'object' && newChild !== null && 'parentNode' in newChild) {\n (newChild as { parentNode: unknown }).parentNode = this;\n }\n if (typeof oldChild === 'object' && oldChild !== null && 'parentNode' in oldChild) {\n (oldChild as { parentNode: unknown }).parentNode = null;\n }\n }\n return oldChild;\n }\n \n // SSR never dispatches events: listeners are accepted and dropped, and\n // queries find nothing (serialize with renderToString instead).\n addEventListener(_type: string, _listener: EventListener): void {}\n removeEventListener(_type: string, _listener: EventListener): void {}\n dispatchEvent(_event: Event): boolean {\n return true;\n }\n querySelector(_selector: string): Element | null {\n return null;\n }\n querySelectorAll(_selector: string): NodeListOf<Element> {\n return [] as unknown as NodeListOf<Element>;\n }\n}\n","export class NucloText {\n nodeType = 3; // Node.TEXT_NODE\n nodeName = '#text';\n data: string;\n textContent: string;\n parentNode: unknown = null;\n \n constructor(data: string) {\n this.data = data;\n this.textContent = data;\n }\n \n get nodeValue(): string {\n return this.data;\n }\n \n set nodeValue(value: string) {\n this.data = value;\n this.textContent = value;\n }\n}\n","import { NucloElement } from './Element';\nimport { NucloText } from './Text';\n\n/**\n * Lightweight DocumentFragment for SSR — prototype methods instead of per-instance closures.\n */\nclass SSRDocumentFragment {\n nodeType: number = 11;\n nodeName: string = '#document-fragment';\n childNodes: Node[] = [];\n children: Element[] = [];\n textContent: string = '';\n\n get firstChild(): Node | null {\n return this.childNodes.length > 0 ? this.childNodes[0] : null;\n }\n\n get lastChild(): Node | null {\n return this.childNodes.length > 0 ? this.childNodes[this.childNodes.length - 1] : null;\n }\n\n appendChild<T extends Node>(child: T): T {\n this.childNodes.push(child);\n if ((child as any).nodeType === 1) {\n this.children.push(child as unknown as Element);\n }\n (child as any).parentNode = this;\n return child;\n }\n\n insertBefore<T extends Node>(newNode: T, refNode: Node | null): T {\n if (!refNode) return this.appendChild(newNode);\n const index = this.childNodes.indexOf(refNode);\n if (index !== -1) {\n this.childNodes.splice(index, 0, newNode);\n if ((newNode as any).nodeType === 1) {\n const elementIndex = this.children.indexOf(refNode as Element);\n if (elementIndex !== -1) {\n this.children.splice(elementIndex, 0, newNode as unknown as Element);\n }\n }\n }\n (newNode as any).parentNode = this;\n return newNode;\n }\n\n removeChild<T extends Node>(child: T): T {\n const index = this.childNodes.indexOf(child);\n if (index !== -1) this.childNodes.splice(index, 1);\n if ((child as any).nodeType === 1) {\n const elementIndex = this.children.indexOf(child as unknown as Element);\n if (elementIndex !== -1) this.children.splice(elementIndex, 1);\n }\n (child as any).parentNode = null;\n return child;\n }\n\n replaceChild<T extends Node>(newChild: T, oldChild: Node): T {\n const index = this.childNodes.indexOf(oldChild);\n if (index !== -1) {\n this.childNodes[index] = newChild;\n if ((oldChild as any).nodeType === 1 && (newChild as any).nodeType === 1) {\n const elementIndex = this.children.indexOf(oldChild as Element);\n if (elementIndex !== -1) {\n this.children[elementIndex] = newChild as unknown as Element;\n }\n }\n }\n (newChild as any).parentNode = this;\n (oldChild as any).parentNode = null;\n return newChild;\n }\n\n querySelector(): null { return null; }\n querySelectorAll(): NodeListOf<Element> { return [] as unknown as NodeListOf<Element>; }\n}\n\nexport class NucloDocument {\n head: ExpandedElement;\n body: ExpandedElement;\n\n constructor() {\n this.head = new NucloElement('head') as unknown as ExpandedElement;\n this.body = new NucloElement('body') as unknown as ExpandedElement;\n }\n \n createElement(tagName: string, _options?: unknown): ExpandedElement {\n return new NucloElement(tagName) as unknown as ExpandedElement;\n }\n \n createElementNS(namespace: string, tagName: string, _options?: unknown): ExpandedElement {\n const element = new NucloElement(tagName) as unknown as ExpandedElement;\n (element as any).namespaceURI = namespace;\n return element;\n }\n \n createTextNode(data: string): Text {\n return new NucloText(data) as unknown as Text;\n }\n \n /**\n * `marker` is passed by nuclo's own text/list/when markers (see\n * createMarker() in shared/dom.ts): renderToString() emits those verbatim\n * and only inspects comments the app created itself.\n */\n createComment(data: string, marker?: boolean): Comment {\n const comment = {\n nodeType: 8,\n nodeName: '#comment',\n data,\n textContent: data,\n nodeValue: data,\n parentNode: null,\n nextSibling: null,\n previousSibling: null,\n marker: marker === true\n };\n return comment as unknown as Comment;\n }\n \n createDocumentFragment(): DocumentFragment {\n return new SSRDocumentFragment() as unknown as DocumentFragment;\n }\n \n // SSR never dispatches events: listeners are accepted and dropped, and\n // queries find nothing.\n querySelector(_selector: string): Element | null {\n return null;\n }\n\n querySelectorAll(_selector: string): NodeListOf<Element> {\n return [] as unknown as NodeListOf<Element>;\n }\n\n addEventListener(_type: string, _listener: EventListener, _options?: boolean | AddEventListenerOptions): void {}\n\n removeEventListener(_type: string, _listener: EventListener, _options?: boolean | AddEventListenerOptions): void {}\n\n dispatchEvent(_event: Event): boolean {\n return true;\n }\n\n contains(_node: Node): boolean {\n return false;\n }\n}\n\nexport const document = globalThis.document || new NucloDocument();","/**\n * Polyfills for Node.js environments\n *\n * This module provides minimal browser API polyfills to allow Nuclo to run in Node.js\n * for server-side rendering (SSR).\n *\n * To use in Node.js:\n * ```typescript\n * import 'nuclo/polyfill';\n * // or\n * import { document, Event, CustomEvent } from 'nuclo/polyfill';\n * ```\n */\n\nexport { NucloDocument, document } from './Document';\nexport { NucloElement } from './Element';\nexport { NucloText } from './Text';\nexport { NucloNode } from './Node';\n\nimport { NucloElement } from './Element';\nimport { NucloNode } from './Node';\nimport { document } from './Document';\n\n// Event and CustomEvent are built into every supported runtime (Node >= 19,\n// Bun, Deno); re-exported for the documented named imports.\nexport const Event = globalThis.Event;\nexport const CustomEvent = globalThis.CustomEvent;\nexport const Node = NucloNode;\nexport const Element = NucloElement;\nexport const HTMLElement = NucloElement;\n\n// Auto-apply polyfills to globalThis if in Node environment (synchronous — no top-level await)\nif (typeof window === 'undefined') {\n const g = globalThis as unknown as {\n document?: typeof document;\n Node?: typeof NucloNode;\n Element?: typeof NucloElement;\n HTMLElement?: typeof NucloElement;\n };\n g.document ??= document;\n g.Node ??= NucloNode;\n g.Element ??= NucloElement;\n g.HTMLElement ??= NucloElement;\n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,UAAYqB,EACd,EAAE,cAAgBA,CACpB"}
1
+ {"version":3,"file":"nuclo.polyfill.mjs","names":["NO_CHILDREN","siblingOf","kids","node","i","offset","NucloNode","NucloComment","data","marker","SSRStyle","entries","k","v","name","value","SSRClassList","el","tokens","classes","t","c","token","on","force","oldToken","newToken","index","cb","NucloElement","tagName","child","referenceNode","newNode","oldChild","newChild","NucloText","SSRDocumentFragment","refNode","elementIndex","NucloDocument","element","namespace","document","Event","CustomEvent","Node","Element","HTMLElement","g"],"sources":["../../src/polyfill/Node.ts","../../src/polyfill/Element.ts","../../src/polyfill/Text.ts","../../src/polyfill/Document.ts","../../src/polyfill/index.ts"],"sourcesContent":["/** The child list of a node that can have none (text, comments). */\nexport const NO_CHILDREN: never[] = [];\n\n/**\n * A node's neighbour in its parent's child array.\n *\n * Computed on each read rather than kept as pointers: appendChild is the\n * hottest path in renderToString() and would pay for pointer upkeep on every\n * node, while a sibling walk on a server is rare and short — a region\n * replacing its `empty` content, or a latest region taking a second view.\n */\nexport function siblingOf(node: object, offset: 1 | -1): Node | null {\n const parent = (node as { parentNode: { childNodes?: ArrayLike<Node> } | null }).parentNode;\n const kids = parent?.childNodes;\n if (!kids) return null;\n const i = Array.prototype.indexOf.call(kids, node);\n return i === -1 ? null : (kids[i + offset] ?? null);\n}\n\n/**\n * Base Node class for instanceof checks in Node.js polyfill\n */\nexport class NucloNode {\n nodeType = 1; // ELEMENT_NODE\n nodeName = '';\n nodeValue: string | null = null;\n parentNode: unknown = null;\n textContent = '';\n\n get childNodes(): NodeListOf<ChildNode> {\n return NO_CHILDREN as unknown as NodeListOf<ChildNode>;\n }\n\n get nextSibling(): Node | null {\n return siblingOf(this, 1);\n }\n\n get previousSibling(): Node | null {\n return siblingOf(this, -1);\n }\n}\n\n/** A comment: nuclo's own markers (`marker` set) and the app's. */\nexport class NucloComment extends NucloNode {\n data: string;\n marker: boolean;\n\n constructor(data: string, marker: boolean) {\n super();\n this.nodeType = 8; // COMMENT_NODE\n this.nodeName = '#comment';\n this.data = data;\n this.textContent = data;\n this.nodeValue = data;\n this.marker = marker;\n }\n}\n","import { NucloNode } from './Node';\n\n/**\n * Lightweight style object for SSR — prototype methods instead of Object.defineProperty per element.\n * Stores CSS properties as own properties and provides cssText/setProperty/getPropertyValue via prototype.\n */\nclass SSRStyle {\n [key: string]: unknown;\n\n get cssText() {\n const entries = Object.entries(this);\n if (entries.length === 0) return '';\n return entries.map(([k, v]) => `${k}: ${v}`).join('; ');\n }\n\n setProperty(name: string, value: string) {\n (this as Record<string, unknown>)[name] = value;\n }\n\n getPropertyValue(name: string) {\n return ((this as Record<string, unknown>)[name] as string) || '';\n }\n}\n\n// Lightweight classList for SSR — prototype methods instead of per-element closures\nclass SSRClassList {\n private _el: NucloElement;\n constructor(el: NucloElement) { this._el = el; }\n\n private tokens(): string[] { return this._el.className.split(' ').filter(Boolean); }\n\n add(...tokens: string[]) {\n const classes = this.tokens();\n for (const t of tokens) if (t && !classes.includes(t)) classes.push(t);\n this._el.className = classes.join(' ');\n }\n remove(...tokens: string[]) {\n this._el.className = this.tokens().filter(c => !tokens.includes(c)).join(' ');\n }\n contains(token: string) { return this.tokens().includes(token); }\n toggle(token: string, force?: boolean) {\n const on = force ?? !this.contains(token);\n if (on) this.add(token); else this.remove(token);\n return on;\n }\n replace(oldToken: string, newToken: string) {\n if (!this.contains(oldToken)) return false;\n this.remove(oldToken); this.add(newToken); return true;\n }\n item(index: number): string | null { return this.tokens()[index] ?? null; }\n get length() { return this.tokens().length; }\n get value() { return this._el.className; }\n set value(v: string) { this._el.className = v; }\n toString() { return this._el.className; }\n supports(_token: string) { return false; }\n forEach(cb: (value: string, key: number, parent: DOMTokenList) => void) {\n this.tokens().forEach((token, i) => cb(token, i, this as unknown as DOMTokenList));\n }\n [Symbol.iterator](): IterableIterator<string> { return this.tokens().values(); }\n entries(): IterableIterator<[number, string]> { return this.tokens().entries(); }\n keys(): IterableIterator<number> { return this.tokens().keys(); }\n values(): IterableIterator<string> { return this.tokens().values(); }\n}\n\nexport class NucloElement extends NucloNode {\n tagName: string;\n children: unknown[];\n className = '';\n textContent = '';\n parentNode: unknown = null;\n id = '';\n namespaceURI?: string;\n\n // style/classList are allocated lazily: the vast majority of SSR elements\n // never touch either (className is stored on the .className string, and the\n // serializer reads the backing field directly), so eagerly constructing an\n // SSRStyle + SSRClassList per element would be pure allocation churn.\n private _style?: CSSStyleDeclaration;\n private _classList?: DOMTokenList;\n\n // attributes is allocated lazily too — most elements carry their identity on\n // .className/.id (separate string fields) and never call setAttribute. Reads\n // short-circuit on the undefined backing map without allocating; the\n // serializer reads _attributes directly. The public getter still lazily\n // materializes a Map for any external `el.attributes` consumer.\n private _attributes?: Map<string, string>;\n\n get attributes(): Map<string, string> {\n return (this._attributes ??= new Map<string, string>());\n }\n set attributes(value: Map<string, string>) {\n this._attributes = value;\n }\n\n // `{ innerText }` behaves like `{ textContent }` on the server: plain text\n // the serializer escapes. (Prototype accessor — no per-element field.)\n get innerText() {\n return this.textContent;\n }\n set innerText(value: string) {\n this.textContent = value;\n }\n\n get style(): CSSStyleDeclaration {\n return (this._style ??= new SSRStyle() as unknown as CSSStyleDeclaration);\n }\n set style(value: CSSStyleDeclaration) {\n this._style = value;\n }\n\n get classList(): DOMTokenList {\n return (this._classList ??= new SSRClassList(this) as unknown as DOMTokenList);\n }\n set classList(value: DOMTokenList) {\n this._classList = value;\n }\n\n constructor(tagName: string) {\n super();\n this.tagName = tagName.toLowerCase();\n this.nodeType = 1; // ELEMENT_NODE\n this.nodeName = tagName.toUpperCase();\n this.children = [];\n }\n\n /** Every node, elements, text and comments alike (children holds them all). */\n get childNodes(): NodeListOf<ChildNode> {\n return this.children as unknown as NodeListOf<ChildNode>;\n }\n\n appendChild<T extends Node>(child: T): T {\n // Spec behaviour: appending a DocumentFragment moves its children into this\n // node and leaves the fragment empty. The list runtime relies on this to\n // batch row insertions.\n if ((child as any)?.nodeType === 11) {\n // Detach the fragment's backing array before iterating (instead of\n // slicing it) — the fragment is emptied either way, and reassigning\n // first means the loop never has to allocate a copy just to guard\n // against the array it's about to discard.\n const kids = (child as any).childNodes as Node[];\n (child as any).childNodes = [];\n if ((child as any).children) (child as any).children = [];\n for (let i = 0; i < kids.length; i++) this.appendChild(kids[i]);\n return child;\n }\n this.children.push(child);\n if (typeof child === 'object' && child !== null && 'parentNode' in child) {\n (child as { parentNode: unknown }).parentNode = this;\n }\n return child;\n }\n \n setAttribute(name: string, value: string) {\n (this._attributes ??= new Map<string, string>()).set(name, value);\n if (name === 'class') {\n this.className = value;\n } else if (name === 'id') {\n this.id = value;\n }\n }\n\n getAttribute(name: string): string | null {\n return this._attributes?.get(name) ?? null;\n }\n\n removeAttribute(name: string) {\n this._attributes?.delete(name);\n if (name === 'class') {\n this.className = '';\n }\n }\n\n hasAttribute(name: string) {\n return this._attributes?.has(name) ?? false;\n }\n \n insertBefore<T extends Node>(newNode: T, referenceNode: Node | null): T {\n if (referenceNode === null) {\n return this.appendChild(newNode);\n }\n // Spec behaviour: inserting a DocumentFragment moves its children (in order)\n // before the reference node and empties the fragment.\n if ((newNode as any)?.nodeType === 11) {\n const kids = (newNode as any).childNodes as Node[];\n (newNode as any).childNodes = [];\n if ((newNode as any).children) (newNode as any).children = [];\n for (let i = 0; i < kids.length; i++) this.insertBefore(kids[i], referenceNode);\n return newNode;\n }\n const index = this.children.indexOf(referenceNode);\n if (index !== -1) {\n this.children.splice(index, 0, newNode);\n if (typeof newNode === 'object' && newNode !== null && 'parentNode' in newNode) {\n (newNode as { parentNode: unknown }).parentNode = this;\n }\n }\n return newNode;\n }\n \n removeChild<T extends Node>(child: T): T {\n const index = this.children.indexOf(child);\n if (index !== -1) {\n this.children.splice(index, 1);\n if (typeof child === 'object' && child !== null && 'parentNode' in child) {\n (child as { parentNode: unknown }).parentNode = null;\n }\n }\n return child;\n }\n\n replaceChild<T extends Node>(newChild: Node, oldChild: T): T {\n const index = this.children.indexOf(oldChild);\n if (index !== -1) {\n this.children[index] = newChild;\n if (typeof newChild === 'object' && newChild !== null && 'parentNode' in newChild) {\n (newChild as { parentNode: unknown }).parentNode = this;\n }\n if (typeof oldChild === 'object' && oldChild !== null && 'parentNode' in oldChild) {\n (oldChild as { parentNode: unknown }).parentNode = null;\n }\n }\n return oldChild;\n }\n \n // SSR never dispatches events: listeners are accepted and dropped, and\n // queries find nothing (serialize with renderToString instead).\n addEventListener(_type: string, _listener: EventListener) {}\n removeEventListener(_type: string, _listener: EventListener) {}\n dispatchEvent(_event: Event) {\n return true;\n }\n querySelector(_selector: string): Element | null {\n return null;\n }\n querySelectorAll(_selector: string): NodeListOf<Element> {\n return [] as unknown as NodeListOf<Element>;\n }\n}\n","import { NO_CHILDREN, siblingOf } from './Node';\n\nexport class NucloText {\n nodeType = 3; // Node.TEXT_NODE\n nodeName = '#text';\n data: string;\n textContent: string;\n parentNode: unknown = null;\n \n constructor(data: string) {\n this.data = data;\n this.textContent = data;\n }\n \n get nodeValue() {\n return this.data;\n }\n \n set nodeValue(value: string) {\n this.data = value;\n this.textContent = value;\n }\n\n get childNodes(): NodeListOf<ChildNode> {\n return NO_CHILDREN as unknown as NodeListOf<ChildNode>;\n }\n\n get nextSibling(): Node | null {\n return siblingOf(this, 1);\n }\n\n get previousSibling(): Node | null {\n return siblingOf(this, -1);\n }\n}\n","import { NucloElement } from './Element';\nimport { NucloText } from './Text';\nimport { NucloComment } from './Node';\n\n/**\n * Lightweight DocumentFragment for SSR — prototype methods instead of per-instance closures.\n */\nclass SSRDocumentFragment {\n nodeType = 11;\n nodeName = '#document-fragment';\n childNodes: Node[] = [];\n children: Element[] = [];\n textContent = '';\n\n get firstChild(): Node | null {\n return this.childNodes.length > 0 ? this.childNodes[0] : null;\n }\n\n get lastChild(): Node | null {\n return this.childNodes.length > 0 ? this.childNodes[this.childNodes.length - 1] : null;\n }\n\n appendChild<T extends Node>(child: T): T {\n this.childNodes.push(child);\n if ((child as any).nodeType === 1) {\n this.children.push(child as unknown as Element);\n }\n (child as any).parentNode = this;\n return child;\n }\n\n insertBefore<T extends Node>(newNode: T, refNode: Node | null): T {\n if (!refNode) return this.appendChild(newNode);\n const index = this.childNodes.indexOf(refNode);\n if (index !== -1) {\n this.childNodes.splice(index, 0, newNode);\n if ((newNode as any).nodeType === 1) {\n const elementIndex = this.children.indexOf(refNode as Element);\n if (elementIndex !== -1) {\n this.children.splice(elementIndex, 0, newNode as unknown as Element);\n }\n }\n }\n (newNode as any).parentNode = this;\n return newNode;\n }\n\n removeChild<T extends Node>(child: T): T {\n const index = this.childNodes.indexOf(child);\n if (index !== -1) this.childNodes.splice(index, 1);\n if ((child as any).nodeType === 1) {\n const elementIndex = this.children.indexOf(child as unknown as Element);\n if (elementIndex !== -1) this.children.splice(elementIndex, 1);\n }\n (child as any).parentNode = null;\n return child;\n }\n\n replaceChild<T extends Node>(newChild: T, oldChild: Node): T {\n const index = this.childNodes.indexOf(oldChild);\n if (index !== -1) {\n this.childNodes[index] = newChild;\n if ((oldChild as any).nodeType === 1 && (newChild as any).nodeType === 1) {\n const elementIndex = this.children.indexOf(oldChild as Element);\n if (elementIndex !== -1) {\n this.children[elementIndex] = newChild as unknown as Element;\n }\n }\n }\n (newChild as any).parentNode = this;\n (oldChild as any).parentNode = null;\n return newChild;\n }\n\n querySelector(): null { return null; }\n querySelectorAll(): NodeListOf<Element> { return [] as unknown as NodeListOf<Element>; }\n}\n\nexport class NucloDocument {\n head: ExpandedElement;\n body: ExpandedElement;\n\n constructor() {\n this.head = new NucloElement('head') as unknown as ExpandedElement;\n this.body = new NucloElement('body') as unknown as ExpandedElement;\n }\n \n createElement(tagName: string, _options?: unknown): ExpandedElement {\n return new NucloElement(tagName) as unknown as ExpandedElement;\n }\n \n createElementNS(namespace: string, tagName: string, _options?: unknown): ExpandedElement {\n const element = new NucloElement(tagName) as unknown as ExpandedElement;\n (element as any).namespaceURI = namespace;\n return element;\n }\n \n createTextNode(data: string): Text {\n return new NucloText(data) as unknown as Text;\n }\n \n /**\n * `marker` is passed by nuclo's own text/list/when markers (see\n * createMarker() in shared/dom.ts): renderToString() emits those verbatim\n * and only inspects comments the app created itself.\n */\n createComment(data: string, marker?: boolean): Comment {\n return new NucloComment(data, marker === true) as unknown as Comment;\n }\n \n createDocumentFragment(): DocumentFragment {\n return new SSRDocumentFragment() as unknown as DocumentFragment;\n }\n \n // SSR never dispatches events: listeners are accepted and dropped, and\n // queries find nothing.\n querySelector(_selector: string): Element | null {\n return null;\n }\n\n querySelectorAll(_selector: string): NodeListOf<Element> {\n return [] as unknown as NodeListOf<Element>;\n }\n\n addEventListener(_type: string, _listener: EventListener, _options?: boolean | AddEventListenerOptions) {}\n\n removeEventListener(_type: string, _listener: EventListener, _options?: boolean | AddEventListenerOptions) {}\n\n dispatchEvent(_event: Event) {\n return true;\n }\n\n contains(_node: Node) {\n return false;\n }\n}\n\nexport const document = globalThis.document || new NucloDocument();","/**\n * Polyfills for Node.js environments\n *\n * This module provides minimal browser API polyfills to allow Nuclo to run in Node.js\n * for server-side rendering (SSR).\n *\n * To use in Node.js:\n * ```typescript\n * import 'nuclo/polyfill';\n * // or\n * import { document, Event, CustomEvent } from 'nuclo/polyfill';\n * ```\n */\n\nexport { NucloDocument, document } from './Document';\nexport { NucloElement } from './Element';\nexport { NucloText } from './Text';\nexport { NucloNode } from './Node';\n\nimport { NucloElement } from './Element';\nimport { NucloNode } from './Node';\nimport { document } from './Document';\n\n// Event and CustomEvent are built into every supported runtime (Node >= 19,\n// Bun, Deno); re-exported for the documented named imports.\nexport const Event = globalThis.Event;\nexport const CustomEvent = globalThis.CustomEvent;\nexport const Node = NucloNode;\nexport const Element = NucloElement;\nexport const HTMLElement = NucloElement;\n\n// Auto-apply polyfills to globalThis if in Node environment (synchronous — no top-level await)\nif (typeof window === 'undefined') {\n const g = globalThis as unknown as {\n document?: typeof document;\n Node?: typeof NucloNode;\n Element?: typeof NucloElement;\n HTMLElement?: typeof NucloElement;\n };\n g.document ??= document;\n g.Node ??= NucloNode;\n g.Element ??= NucloElement;\n g.HTML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jC,OAAO,IAAIL,EAAU5B,CAAI,CAC3B,CAOA,cAAc,EAAc,EAA2B,CACrD,OAAO,IAAID,EAAaC,EAAMC,IAAW,EAAI,CAC/C,CAEA,wBAA2C,CACzC,OAAO,IAAI4B,CACb,CAIA,cAAc,EAAmC,CAC/C,OAAO,IACT,CAEA,iBAAiB,EAAwC,CACvD,MAAO,CAAC,CACV,CAEA,iBAAiB,EAAe,EAA0B,EAA8C,CAAC,CAEzG,oBAAoB,EAAe,EAA0B,EAA8C,CAAC,CAE5G,cAAc,EAAe,CAC3B,MAAO,EACT,CAEA,SAAS,EAAa,CACpB,MAAO,EACT,CACF,EAEA,MAAaM,EAAW,WAAW,UAAY,IAAIH,EChHtCI,EAAQ,WAAW,MACnBC,EAAc,WAAW,YACzBC,EAAOxC,EACPyC,EAAUlB,EACVmB,EAAcnB,EAG3B,GAAI,OAAO,OAAW,IAAa,CACjC,IAAMoB,EAAI,WAMV,EAAE,WAAaN,EACf,EAAE,OAASrC,EACX,EAAE,UAAYuB,EACd,EAAE,cAAgBA,CACpB"}
@@ -1,3 +1,3 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e){let t=0;for(;t<e.length;t++){let n=e.charCodeAt(t);if(n>=65&&n<=90)break}if(t===e.length)return e;let n=e.slice(0,t);for(let r=t;r<e.length;r++){let t=e.charCodeAt(r);n+=t>=65&&t<=90?`-`+String.fromCharCode(t+32):e[r]}return n}const t=/[&<>"']/,n=/[&<>]/;function r(e){let n=t.exec(e);if(!n)return e;let r=``,i=0;for(let t=n.index;t<e.length;t++){let n;switch(e.charCodeAt(t)){case 38:n=`&amp;`;break;case 60:n=`&lt;`;break;case 62:n=`&gt;`;break;case 34:n=`&quot;`;break;case 39:n=`&#039;`;break;default:continue}r+=e.slice(i,t)+n,i=t+1}return r+e.slice(i)}function i(e){let t=n.exec(e);if(!t)return e;let r=``,i=0;for(let n=t.index;n<e.length;n++){let t;switch(e.charCodeAt(n)){case 38:t=`&amp;`;break;case 60:t=`&lt;`;break;case 62:t=`&gt;`;break;default:continue}r+=e.slice(i,n)+t,i=n+1}return r+e.slice(i)}function a(e){switch(e){case`htmlFor`:return`for`;case`httpEquiv`:return`http-equiv`;case`acceptCharset`:return`accept-charset`;case`defaultValue`:return`value`;case`defaultChecked`:return`checked`;case`defaultSelected`:return`selected`}let t=e.charCodeAt(4);return t>=65&&t<=90&&e.startsWith(`aria`)?`aria-`+e.slice(4).toLowerCase():e.toLowerCase()}const o=Symbol.for(`nuclo.serializing.v1`),s=globalThis,c=s[o]??(s[o]={on:!1});function l(e){let t=c.on;c.on=!0;try{return e()}finally{c.on=t}}const u=/* @__PURE__ */ new Set(/* @__PURE__ */ `allowfullscreen.async.autofocus.autoplay.checked.controls.default.defer.disabled.disablepictureinpicture.disableremoteplayback.formnovalidate.hidden.inert.ismap.itemscope.loop.multiple.muted.nomodule.novalidate.open.playsinline.readonly.required.reversed.selected`.split(`.`)),d=/[\s"'<>\/=\u0000-\u001f\u007f]/,f=/* @__PURE__ */ new Map;function p(e){let t=f.get(e);return t===void 0&&(t=d.test(e)?``:a(e),f.size<1024&&f.set(e,t)),t}function m(t,n){if(n==null||n===!1)return``;if(n===!0)return` ${t}`;if(u.has(t)){if(n===`false`)return``;if(n===`true`||n===``||n===t)return` ${t}`}if(t===`style`&&typeof n==`object`){let t=``;for(let r in n){let i=n[r];i!=null&&i!==``&&(t+=(t?` `:``)+e(r)+`: `+String(i)+`;`)}return t?` style="${r(t)}"`:``}return` ${t}="${r(String(n))}"`}function h(t,n,i){let a=``;if(n){let n=t,o=n._attributes;n.id&&!o?.has(`id`)&&(a+=m(`id`,n.id)),n.className&&!o?.has(`class`)&&(a+=m(`class`,n.className));let s=n._style;if(s&&!o?.has(`style`)){let t=``;for(let n in s){let r=s[n];r!=null&&r!==``&&(t+=(t?` `:``)+e(n)+`: `+String(r)+`;`)}t&&(a+=` style="${r(t)}"`)}if(o){let e=n.namespaceURI===`http://www.w3.org/2000/svg`;for(let[t,n]of o){if(t===`innerHTML`||i&&t===`value`)continue;let r=p(t);r!==``&&(a+=m(e?t:r,n))}}return a}if(t.attributes&&t.attributes.length)for(let e=0;e<t.attributes.length;e++){let n=t.attributes[e];n&&n.name&&(a+=m(n.name,n.value))}return a}const g=Object.assign(Object.create(null),{area:1,base:1,br:1,col:1,embed:1,hr:1,img:1,input:1,link:1,meta:1,param:1,source:1,track:1,wbr:1,script:2,style:2,title:3,textarea:3,select:4,option:5,optgroup:6}),_={script:/<\/(script)/gi,style:/<\/(style)/gi};function v(e,t){return t.replace(_[e],`<\\/$1`)}function y(e){if(e.selected!==void 0&&e.localName===`option`){let t=e;if(!t.selected||t.hasAttribute(`selected`))return``;let n=t.parentNode;n&&n.nodeName===`OPTGROUP`&&(n=n.parentNode);let r=n&&n.nodeName===`SELECT`?n:null;return r&&!r.multiple&&r.options[0]===t?``:` selected`}let t=e,n=``;t.checked===!0&&!t.hasAttribute(`checked`)&&(n+=` checked`);let r=t.value;return typeof r==`string`&&r!==``&&!t.hasAttribute(`value`)&&(t.type!==`checkbox`&&t.type!==`radio`||r!==`on`)&&t.type!==`file`&&(n+=m(`value`,r)),n}function b(e){let t=e.children,n=``;if(t)for(let e=0;e<t.length;e++)t[e].nodeType===3&&(n+=t[e].textContent||``);return n}function x(e,t){if(e.nodeType===3)return i(e.textContent||``);if(e.nodeType===8){let t=e.textContent||``;return e.marker===!0||!t.includes(`>`)?`<!--${t}-->`:`<!--${t.replace(/>/g,`&gt;`)}-->`}if(e.nodeType===1){let n=e,r=Array.isArray(n.children),a=n.tagName.toLowerCase(),o=g[a];o===3&&n.namespaceURI===`http://www.w3.org/2000/svg`&&(o=void 0);let s=o===3&&a===`textarea`,c=r?n._attributes:void 0,l=h(n,r,s||o===4);if(o===4){let e=c?.get(`value`);t=e==null?void 0:String(e)}else if(t!==void 0){if(o===5){let e=c?.get(`value`)??b(n);String(e)===t&&!c?.has(`selected`)&&(l+=` selected`)}o!==6&&(t=void 0)}if(!r&&(o===5||a===`input`)&&(l+=y(n)),o===1)return`<${a}${l} />`;let u=r?n.children:n.childNodes;if(o===2||o===3){let t=``,c=u;if(c&&c.length>0)for(let e=0;e<c.length;e++){let n=c[e];n&&n.nodeType===3&&(t+=n.textContent||``)}else{let n=e.textContent;typeof n==`string`&&(t=n)}if(o===2)return`<${a}${l}>${v(a,t)}</${a}>`;if(s){let e=r?n._attributes?.get(`value`):n.value;typeof e==`string`&&e&&(t=e),t.charCodeAt(0)===10&&(t=`
2
- `+t)}return`<${a}${l}>${i(t)}</${a}>`}let d=c?.get(`innerHTML`),f=d===void 0?``:String(d);if(u&&u.length>0)for(let e=0;e<u.length;e++){let n=u[e];n&&(f+=x(n,t))}else if(d===void 0){let t=e.textContent;typeof t==`string`&&t&&(f=i(t))}return`<${a}${l}>${f}</${a}>`}if(e.nodeType===11){let t=``,n=e.childNodes??[];if(n.length>0)for(let e=0;e<n.length;e++){let r=n[e];r&&(t+=x(r))}return t}return``}function S(e){if(!e)return``;if(typeof e==`function`)try{let t=l(()=>{if(typeof document>`u`)throw Error(`Document is not available. Make sure polyfills are loaded.`);let t=document.createElement(`div`),n=e(t,0);return typeof n==`function`&&(n=n(t,0)),n});return t&&typeof t==`object`&&`nodeType`in t?x(t):``}catch(e){return console.error(`Error rendering component to string:`,e),``}return`nodeType`in e?x(e):``}function C(e){return e.map(e=>S(e))}function w(e,t=`div`,n={}){let r=S(e);return`<${t}${Object.entries(n).map(([e,t])=>e===``||d.test(e)?``:m(e,t)).join(``)}>${r}</${t}>`}function T(){return{atomCache:/* @__PURE__ */ new Map,atomMeta:/* @__PURE__ */ new Map,rawKeys:/* @__PURE__ */ new Set,baseRules:[],queryRules:/* @__PURE__ */ new Map,styleEpoch:0,cssTextCache:null,sheet:null,sheetDocument:null,baseRuleCount:0,groupRules:/* @__PURE__ */ new Map,externalRules:null,hasExternalGroups:!1}}const E=Symbol.for(`nuclo.style.engine.v1`),D=globalThis;let O;function k(){return O??=D[E]??(D[E]=T())}function A(){let e=k();if(e.cssTextCache!==null)return e.cssTextCache;let t=e.baseRules.join(``);for(let[n,r]of e.queryRules)r.length>0&&(t+=n+`{`+r.join(``)+`}`);return e.cssTextCache=t,t}exports.getCssText=A,exports.renderManyToString=C,exports.renderToString=S,exports.renderToStringWithContainer=w;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e){let t=0;for(;t<e.length;t++){let n=e.charCodeAt(t);if(n>=65&&n<=90)break}if(t===e.length)return e;let n=e.slice(0,t);for(let r=t;r<e.length;r++){let t=e.charCodeAt(r);n+=t>=65&&t<=90?`-`+String.fromCharCode(t+32):e[r]}return n}const t=/[&<>"']/,n=/[&<>]/;function r(e){let n=t.exec(e);if(!n)return e;let r=``,i=0;for(let t=n.index;t<e.length;t++){let n;switch(e.charCodeAt(t)){case 38:n=`&amp;`;break;case 60:n=`&lt;`;break;case 62:n=`&gt;`;break;case 34:n=`&quot;`;break;case 39:n=`&#039;`;break;default:continue}r+=e.slice(i,t)+n,i=t+1}return r+e.slice(i)}function i(e){let t=n.exec(e);if(!t)return e;let r=``,i=0;for(let n=t.index;n<e.length;n++){let t;switch(e.charCodeAt(n)){case 38:t=`&amp;`;break;case 60:t=`&lt;`;break;case 62:t=`&gt;`;break;default:continue}r+=e.slice(i,n)+t,i=n+1}return r+e.slice(i)}function a(e){switch(e){case`htmlFor`:return`for`;case`httpEquiv`:return`http-equiv`;case`acceptCharset`:return`accept-charset`;case`defaultValue`:return`value`;case`defaultChecked`:return`checked`;case`defaultSelected`:return`selected`}let t=e.charCodeAt(4);return t>=65&&t<=90&&e.startsWith(`aria`)?`aria-`+e.slice(4).toLowerCase():e.toLowerCase()}const o=Symbol.for(`nuclo.serializing.v1`),s=globalThis,c=s[o]??(s[o]={on:!1,scratch:/* @__PURE__ */ new Map});function l(e){let t=c.on;c.on=!0;try{return e()}finally{c.on=t,c.on||c.scratch.clear()}}function u(e){return typeof e==`function`}function d(e){return u(e)&&e.length===0}const f=/* @__PURE__ */ new Set(/* @__PURE__ */ `allowfullscreen.async.autofocus.autoplay.checked.controls.default.defer.disabled.disablepictureinpicture.disableremoteplayback.formnovalidate.hidden.inert.ismap.itemscope.loop.multiple.muted.nomodule.novalidate.open.playsinline.readonly.required.reversed.selected`.split(`.`)),p=/[\s"'<>\/=\u0000-\u001f\u007f]/,m=/* @__PURE__ */ new Map;function h(e){let t=m.get(e);return t===void 0&&(t=p.test(e)?``:a(e),m.size<1024&&m.set(e,t)),t}function g(t,n){if(n==null||n===!1)return``;if(n===!0)return` ${t}`;if(f.has(t)){if(n===`false`)return``;if(n===`true`||n===``||n===t)return` ${t}`}if(t===`style`&&typeof n==`object`){let t=``;for(let r in n){let i=n[r];i!=null&&i!==``&&(t+=(t?` `:``)+e(r)+`: `+String(i)+`;`)}return t?` style="${r(t)}"`:``}return` ${t}="${r(String(n))}"`}function _(t,n,i){let a=``;if(n){let n=t,o=n._attributes;n.id&&!o?.has(`id`)&&(a+=g(`id`,n.id)),n.className&&!o?.has(`class`)&&(a+=g(`class`,n.className));let s=n._style;if(s&&!o?.has(`style`)){let t=``;for(let n in s){let r=s[n];r!=null&&r!==``&&(t+=(t?` `:``)+e(n)+`: `+String(r)+`;`)}t&&(a+=` style="${r(t)}"`)}if(o){let e=n.namespaceURI===`http://www.w3.org/2000/svg`;for(let[t,n]of o){if(t===`innerHTML`||i&&t===`value`)continue;let r=h(t);r!==``&&(a+=g(e?t:r,n))}}return a}if(t.attributes&&t.attributes.length)for(let e=0;e<t.attributes.length;e++){let n=t.attributes[e];n&&n.name&&(a+=g(n.name,n.value))}return a}const v=Object.assign(Object.create(null),{area:1,base:1,br:1,col:1,embed:1,hr:1,img:1,input:1,link:1,meta:1,param:1,source:1,track:1,wbr:1,script:2,style:2,title:3,textarea:3,select:4,option:5,optgroup:6}),y={script:/<\/(script)/gi,style:/<\/(style)/gi};function b(e,t){return t.replace(y[e],`<\\/$1`)}function x(e){if(e.selected!==void 0&&e.localName===`option`){let t=e;if(!t.selected||t.hasAttribute(`selected`))return``;let n=t.parentNode;n&&n.nodeName===`OPTGROUP`&&(n=n.parentNode);let r=n&&n.nodeName===`SELECT`?n:null;return r&&!r.multiple&&r.options[0]===t?``:` selected`}let t=e,n=``;t.checked===!0&&!t.hasAttribute(`checked`)&&(n+=` checked`);let r=t.value;return typeof r==`string`&&r!==``&&!t.hasAttribute(`value`)&&(t.type!==`checkbox`&&t.type!==`radio`||r!==`on`)&&t.type!==`file`&&(n+=g(`value`,r)),n}function S(e){let t=e.children,n=``;if(t)for(let e=0;e<t.length;e++)t[e].nodeType===3&&(n+=t[e].textContent||``);return n}function C(e,t){if(e.nodeType===3)return i(e.textContent||``);if(e.nodeType===8){let t=e.textContent||``;return e.marker===!0||!t.includes(`>`)?`<!--${t}-->`:`<!--${t.replace(/>/g,`&gt;`)}-->`}if(e.nodeType===1){let n=e,r=Array.isArray(n.children),a=n.tagName.toLowerCase(),o=v[a];o===3&&n.namespaceURI===`http://www.w3.org/2000/svg`&&(o=void 0);let s=o===3&&a===`textarea`,c=r?n._attributes:void 0,l=_(n,r,s||o===4);if(o===4){let e=c?.get(`value`);t=e==null?void 0:String(e)}else if(t!==void 0){if(o===5){let e=c?.get(`value`)??S(n);String(e)===t&&!c?.has(`selected`)&&(l+=` selected`)}o!==6&&(t=void 0)}if(!r&&(o===5||a===`input`)&&(l+=x(n)),o===1)return`<${a}${l} />`;let u=r?n.children:n.childNodes;if(o===2||o===3){let t=``,c=u;if(c&&c.length>0)for(let e=0;e<c.length;e++){let n=c[e];n&&n.nodeType===3&&(t+=n.textContent||``)}else{let n=e.textContent;typeof n==`string`&&(t=n)}if(o===2)return`<${a}${l}>${b(a,t)}</${a}>`;if(s){let e=r?n._attributes?.get(`value`):n.value;typeof e==`string`&&e&&(t=e),t.charCodeAt(0)===10&&(t=`
2
+ `+t)}return`<${a}${l}>${i(t)}</${a}>`}let d=c?.get(`innerHTML`),f=d===void 0?``:String(d);if(u&&u.length>0)for(let e=0;e<u.length;e++){let n=u[e];n&&(f+=C(n,t))}else if(d===void 0){let t=e.textContent;typeof t==`string`&&t&&(f=i(t))}return`<${a}${l}>${f}</${a}>`}if(e.nodeType===11){let t=``,n=e.childNodes??[];if(n.length>0)for(let e=0;e<n.length;e++){let r=n[e];r&&(t+=C(r))}return t}return``}function w(e){if(!e)return``;if(typeof e==`function`)try{let t=l(()=>{if(typeof document>`u`)throw Error(`Document is not available. Make sure polyfills are loaded.`);let t=document.createElement(`div`),n=d(e)?e():e;return typeof n==`function`&&(n=n(t,0)),n});return t&&typeof t==`object`&&`nodeType`in t?C(t):``}catch(e){return console.error(`Error rendering component to string:`,e),``}return`nodeType`in e?C(e):``}function T(e){return e.map(e=>w(e))}function E(e,t=`div`,n={}){let r=w(e);return`<${t}${Object.entries(n).map(([e,t])=>e===``||p.test(e)?``:g(e,t)).join(``)}>${r}</${t}>`}function D(){return{atomCache:/* @__PURE__ */ new Map,atomMeta:/* @__PURE__ */ new Map,rawKeys:/* @__PURE__ */ new Set,baseRules:[],queryRules:/* @__PURE__ */ new Map,styleEpoch:0,cssTextCache:null,sheet:null,sheetDocument:null,baseRuleCount:0,groupRules:/* @__PURE__ */ new Map,externalRules:null,hasExternalGroups:!1}}const O=Symbol.for(`nuclo.style.engine.v1`),k=globalThis;let A;function j(){return A??=k[O]??(k[O]=D())}function M(){let e=j();if(e.cssTextCache!==null)return e.cssTextCache;let t=e.baseRules.join(``);for(let[n,r]of e.queryRules)r.length>0&&(t+=n+`{`+r.join(``)+`}`);return e.cssTextCache=t,t}exports.getCssText=M,exports.renderManyToString=T,exports.renderToString=w,exports.renderToStringWithContainer=E;
3
3
  //# sourceMappingURL=nuclo.ssr.cjs.map