nuclo 0.1.84 → 0.1.87
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/conditionalUpdater.d.ts.map +1 -1
- package/dist/core/elementFactory.d.ts.map +1 -1
- package/dist/core/reactiveAttributes.d.ts.map +1 -1
- package/dist/core/reactiveText.d.ts.map +1 -1
- package/dist/core/updateController.d.ts.map +1 -1
- package/dist/internal/applyModifiers.d.ts.map +1 -1
- package/dist/nuclo.cjs +1 -1
- package/dist/nuclo.cjs.map +1 -1
- package/dist/nuclo.js +1 -1
- package/dist/nuclo.js.map +1 -1
- package/dist/nuclo.umd.js +1 -1
- package/dist/nuclo.umd.js.map +1 -1
- package/dist/polyfill/Document.d.ts +2 -2
- package/dist/polyfill/Document.d.ts.map +1 -1
- package/dist/ssr/nuclo.ssr.cjs +1 -1
- package/dist/ssr/nuclo.ssr.cjs.map +1 -1
- package/dist/ssr/nuclo.ssr.js +1 -1
- package/dist/ssr/nuclo.ssr.js.map +1 -1
- package/dist/ssr/renderToString.d.ts.map +1 -1
- package/dist/style/cssGenerator.d.ts.map +1 -1
- package/dist/utility/conditionalInfo.d.ts +3 -2
- package/dist/utility/conditionalInfo.d.ts.map +1 -1
- package/dist/utility/dom.d.ts +21 -0
- package/dist/utility/dom.d.ts.map +1 -1
- package/dist/utility/on.d.ts +11 -0
- package/dist/utility/on.d.ts.map +1 -1
- package/dist/utility/scope.d.ts.map +1 -1
- package/package.json +6 -6
|
@@ -10,8 +10,8 @@ export declare class NucloDocument {
|
|
|
10
10
|
createDocumentFragment(): DocumentFragment;
|
|
11
11
|
querySelector(selector: string): Element | null;
|
|
12
12
|
querySelectorAll(_selector: string): NodeListOf<Element>;
|
|
13
|
-
addEventListener(type: string, listener: EventListener): void;
|
|
14
|
-
removeEventListener(type: string, listener: EventListener): void;
|
|
13
|
+
addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void;
|
|
14
|
+
removeEventListener(type: string, listener: EventListener, _options?: boolean | AddEventListenerOptions): void;
|
|
15
15
|
dispatchEvent(event: Event): boolean;
|
|
16
16
|
contains(_node: Node): boolean;
|
|
17
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Document.d.ts","sourceRoot":"","sources":["../../src/polyfill/Document.ts"],"names":[],"mappings":"AAGA,qBAAa,aAAa;IACxB,IAAI,EAAE,eAAe,CAAC;IACtB,IAAI,EAAE,eAAe,CAAC;IACtB,OAAO,CAAC,UAAU,
|
|
1
|
+
{"version":3,"file":"Document.d.ts","sourceRoot":"","sources":["../../src/polyfill/Document.ts"],"names":[],"mappings":"AAGA,qBAAa,aAAa;IACxB,IAAI,EAAE,eAAe,CAAC;IACtB,IAAI,EAAE,eAAe,CAAC;IACtB,OAAO,CAAC,UAAU,CAA4G;;IAQ9H,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,eAAe;IAInE,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,eAAe;IAMxF,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIlC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAcpC,sBAAsB,IAAI,gBAAgB;IAmE1C,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI;IAe/C,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC;IAIxD,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAAG,IAAI;IAQ1G,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAAG,IAAI;IAW9G,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO;IAgBpC,QAAQ,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO;CAG/B;AAED,eAAO,MAAM,QAAQ,UAA6C,CAAC"}
|
package/dist/ssr/nuclo.ssr.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function t(t){const e={"&":"&","<":"<",">":">",'"':""","'":"'"};return t.replace(/[&<>"']/g,t=>e[t])}function e(e,n){if(null==n||!1===n)return"";if(!0===n)return" "+e;if("style"===e&&"object"==typeof n){const e=Object.entries(n).map(([t,e])=>`${function(t){let e="";for(let n=0;t.length>n;n++){const r=t.charCodeAt(n);65>r||r>90?e+=t[n]:(n>0&&(e+="-"),e+=String.fromCharCode(r+32))}return e}(t)}:${e}`).join(";");return e?` style="${t(e)}"`:""}return` ${e}="${t(n+"")}"`}const n=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function r(t){if("childNodes"in t){const e=t.childNodes;if(e&&(Array.isArray(e)||void 0!==e.length))return e}if("children"in t){const e=t.children;if(e&&Array.isArray(e))return e}return[]}function i
|
|
1
|
+
"use strict";function t(t){const e={"&":"&","<":"<",">":">",'"':""","'":"'"};return t.replace(/[&<>"']/g,t=>e[t])}function e(e,n){if(null==n||!1===n)return"";if(!0===n)return" "+e;if("style"===e&&"object"==typeof n){const e=Object.entries(n).map(([t,e])=>`${function(t){let e="";for(let n=0;t.length>n;n++){const r=t.charCodeAt(n);65>r||r>90?e+=t[n]:(n>0&&(e+="-"),e+=String.fromCharCode(r+32))}return e}(t)}:${e}`).join(";");return e?` style="${t(e)}"`:""}return` ${e}="${t(n+"")}"`}const n=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function r(t){if("childNodes"in t){const e=t.childNodes;if(e&&(Array.isArray(e)||void 0!==e.length))return e}if("children"in t){const e=t.children;if(e&&Array.isArray(e))return e}return[]}function o(i){if(3===i.nodeType)return t(i.textContent||"");if(8===i.nodeType)return`\x3c!--${i.textContent||""}--\x3e`;if(1===i.nodeType){const t=i,s=t.tagName.toLowerCase(),a=function(t){let n="";if("attributes"in t&&t.attributes instanceof Map){const r=t;r.id&&!t.attributes.has("id")&&(n+=e("id",r.id)),r.className&&!t.attributes.has("class")&&(n+=e("class",r.className));for(const[r,o]of t.attributes)n+=e(r,o);return n}if(t.attributes&&t.attributes.length)for(let r=0;t.attributes.length>r;r++){const o=t.attributes[r];o&&o.name&&(n+=e(o.name,o.value))}return n}(t);if(n.has(s))return`<${s}${a} />`;let c="";const u=r(t);if(u&&u.length>0)for(let t=0;u.length>t;t++){const e=u[t];e&&(c+=o(e))}return`<${s}${a}>${c}</${s}>`}if(11===i.nodeType){let t="";const e=r(i);if(e&&e.length>0)for(let n=0;e.length>n;n++){const r=e[n];r&&(t+=o(r))}return t}return""}function i(t){if(!t)return"";if("function"==typeof t)try{const e=globalThis.document?document.createElement("div"):null;if(!e)throw Error("Document is not available. Make sure polyfills are loaded.");const n=t(e,0);return n&&"object"==typeof n&&"nodeType"in n?o(n):""}catch(t){return console.error("Error rendering component to string:",t),""}return"nodeType"in t?o(t):""}exports.renderManyToString=function(t){return t.map(t=>i(t))},exports.renderToString=i,exports.renderToStringWithContainer=function(t,n="div",r={}){const o=i(t);return`<${n}${Object.entries(r).map(([t,n])=>e(t,n)).join("")}>${o}</${n}>`};
|
|
2
2
|
//# sourceMappingURL=nuclo.ssr.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nuclo.ssr.cjs","sources":["../../src/utility/stringUtils.ts","../../src/ssr/renderToString.ts"],"sourcesContent":["/**\n * String utility functions\n */\n\n/**\n * Converts camelCase to kebab-case (optimized for performance)\n * Uses direct character code manipulation for maximum speed\n * @example camelToKebab('backgroundColor') => 'background-color'\n */\nexport function camelToKebab(str: string): string {\n let result = '';\n for (let i = 0; i < str.length; i++) {\n const code = str.charCodeAt(i);\n // A-Z is 65-90, a-z is 97-122 (difference of 32)\n if (code >= 65 && code <= 90) {\n if (i > 0) result += '-';\n result += String.fromCharCode(code + 32);\n } else {\n result += str[i];\n }\n }\n return result;\n}\n\n/**\n * Escapes HTML special characters to prevent XSS\n */\nexport function escapeHtml(text: string): string {\n const map: Record<string, string> = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": '''\n };\n return text.replace(/[&<>\"']/g, (char) => map[char]);\n}\n","/**\n * Server-Side Rendering (SSR) utilities for Nuclo\n * Renders Nuclo components to HTML strings in Node.js environment\n */\n\nimport { escapeHtml, camelToKebab } from '../utility/stringUtils';\n\ntype RenderableInput =\n | NodeModFn<ElementTagName>\n | Element\n | Node\n | null\n | undefined;\n\n/**\n * Serializes a DOM attribute value\n */\nfunction serializeAttribute(name: string, value: unknown): string {\n if (value === null || value === undefined || value === false) {\n return '';\n }\n\n if (value === true) {\n return ` ${name}`;\n }\n\n if (name === 'style' && typeof value === 'object') {\n const styleStr = Object.entries(value)\n .map(([key, val]) => {\n const cssKey = camelToKebab(key);\n return `${cssKey}:${val}`;\n })\n .join(';');\n return styleStr ? ` style=\"${escapeHtml(styleStr)}\"` : '';\n }\n\n return ` ${name}=\"${escapeHtml(String(value))}\"`;\n}\n\n/**\n * Serializes DOM element attributes to HTML string\n */\nfunction serializeAttributes(element: Element): string {\n let result = '';\n\n // Handle polyfill elements with Map-based attributes\n if ('attributes' in element && element.attributes instanceof Map) {\n // First, handle special properties that might not be in the attributes Map\n const el = element as any;\n\n // Add id if it exists and is not already in attributes\n if (el.id && !element.attributes.has('id')) {\n result += serializeAttribute('id', el.id);\n }\n\n // Add class if it exists and is not already in attributes\n if (el.className && !element.attributes.has('class')) {\n result += serializeAttribute('class', el.className);\n }\n\n // Then add all attributes from the Map\n for (const [name, value] of element.attributes) {\n result += serializeAttribute(name, value);\n }\n return result;\n }\n\n // Handle browser elements with NamedNodeMap attributes\n if (element.attributes && element.attributes.length) {\n for (let i = 0; i < element.attributes.length; i++) {\n const attr = element.attributes[i];\n if (attr && attr.name) {\n result += serializeAttribute(attr.name, attr.value);\n }\n }\n }\n\n return result;\n}\n\n/**\n * Self-closing HTML tags that don't have closing tags\n */\nconst VOID_ELEMENTS = new Set([\n 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',\n 'link', 'meta', 'param', 'source', 'track', 'wbr'\n]);\n\n/**\n * Get child nodes from an element (handles both browser and polyfill elements)\n */\nfunction getChildNodes(node: Node): ArrayLike<Node> {\n // Check for childNodes first (document fragments and browser elements)\n if ('childNodes' in node) {\n const childNodes = (node as any).childNodes;\n if (childNodes && (Array.isArray(childNodes) || childNodes.length !== undefined)) {\n return childNodes;\n }\n }\n // Polyfill elements have children array\n if ('children' in node) {\n const children = (node as any).children;\n if (children && Array.isArray(children)) {\n return children as ArrayLike<Node>;\n }\n }\n return [] as ArrayLike<Node>;\n}\n\n/**\n * Serializes a DOM node to HTML string\n */\nfunction serializeNode(node: Node): string {\n // Text node\n if (node.nodeType === 3) { // Node.TEXT_NODE\n return escapeHtml(node.textContent || '');\n }\n\n // Comment node\n if (node.nodeType === 8) { // Node.COMMENT_NODE\n return `<!--${node.textContent || ''}-->`;\n }\n\n // Element node\n if (node.nodeType === 1) { // Node.ELEMENT_NODE\n const element = node as Element;\n const tagName = element.tagName.toLowerCase();\n const attributes = serializeAttributes(element);\n\n // Self-closing tags\n if (VOID_ELEMENTS.has(tagName)) {\n return `<${tagName}${attributes} />`;\n }\n\n // Regular elements with children\n let childrenHtml = '';\n const childNodes = getChildNodes(element);\n if (childNodes && childNodes.length > 0) {\n for (let i = 0; i < childNodes.length; i++) {\n const child = childNodes[i];\n if (child) {\n childrenHtml += serializeNode(child);\n }\n }\n }\n\n return `<${tagName}${attributes}>${childrenHtml}</${tagName}>`;\n }\n\n // Document fragment\n if (node.nodeType === 11) { // Node.DOCUMENT_FRAGMENT_NODE\n let result = '';\n const childNodes = getChildNodes(node);\n if (childNodes && childNodes.length > 0) {\n for (let i = 0; i < childNodes.length; i++) {\n const child = childNodes[i];\n if (child) {\n result += serializeNode(child);\n }\n }\n }\n return result;\n }\n\n return '';\n}\n\n/**\n * Renders a Nuclo component to an HTML string for server-side rendering\n *\n * @param input - A Nuclo component function, DOM element, or node\n * @returns HTML string representation of the component\n *\n * @example\n * ```ts\n * import { renderToString } from 'nuclo/ssr';\n * import { div } from 'nuclo';\n *\n * const html = renderToString(\n * div(\"Hello, World!\")\n * );\n * // Returns: '<div>Hello, World!</div>'\n * ```\n */\nexport function renderToString(input: RenderableInput): string {\n if (!input) {\n return '';\n }\n\n // If it's a function (NodeModFn), call it to create the element\n if (typeof input === 'function') {\n try {\n // Create a temporary container to render into\n const container = globalThis.document?.createElement('div');\n if (!container) {\n throw new Error('Document is not available. Make sure polyfills are loaded.');\n }\n\n const element = input(container as ExpandedElement<ElementTagName>, 0);\n return element && typeof element === 'object' && 'nodeType' in element ? serializeNode(element as Node) : '';\n } catch (error) {\n console.error('Error rendering component to string:', error);\n return '';\n }\n }\n\n // If it's already a Node, serialize it directly\n if ('nodeType' in input) {\n return serializeNode(input as Node);\n }\n\n return '';\n}\n\n/**\n * Renders multiple Nuclo components to HTML strings\n *\n * @param inputs - Array of Nuclo components\n * @returns Array of HTML strings\n */\nexport function renderManyToString(inputs: RenderableInput[]): string[] {\n return inputs.map(input => renderToString(input));\n}\n\n/**\n * Renders a Nuclo component and wraps it in a container element\n *\n * @param input - A Nuclo component\n * @param containerTag - The tag name for the container (default: 'div')\n * @param containerAttrs - Attributes for the container element\n * @returns HTML string with container wrapper\n */\nexport function renderToStringWithContainer(\n input: RenderableInput,\n containerTag: string = 'div',\n containerAttrs: Record<string, string> = {}\n): string {\n const content = renderToString(input);\n const attrs = Object.entries(containerAttrs)\n .map(([key, value]) => serializeAttribute(key, value))\n .join('');\n\n return `<${containerTag}${attrs}>${content}</${containerTag}>`;\n}\n"],"names":["escapeHtml","text","map","replace","char","serializeAttribute","name","value","styleStr","Object","entries","key","val","str","result","i","length","code","charCodeAt","String","fromCharCode","camelToKebab","join","VOID_ELEMENTS","Set","getChildNodes","node","childNodes","Array","isArray","undefined","children","serializeNode","nodeType","textContent","element","tagName","toLowerCase","attributes","Map","el","id","has","className","attr","serializeAttributes","childrenHtml","child","renderToString","input","container","globalThis","document","createElement","Error","error","inputs","containerTag","containerAttrs","content"],"mappings":"aA2BM,SAAUA,EAAWC,GACzB,MAAMC,EAA8B,CAClC,IAAK,QACL,IAAK,OACL,IAAK,OACL,IAAK,SACL,IAAK,UAEP,OAAOD,EAAKE,QAAQ,WAAaC,GAASF,EAAIE,GAChD,CCnBA,SAASC,EAAmBC,EAAcC,GACxC,GAAIA,UAAmD,IAAVA,EAC3C,MAAO,GAGT,IAAc,IAAVA,EACF,MAAO,IAAID,EAGb,GAAa,UAATA,GAAqC,iBAAVC,EAAoB,CACjD,MAAMC,EAAWC,OAAOC,QAAQH,GAC7BL,IAAI,EAAES,EAAKC,KAEH,GDrBT,SAAuBC,GAC3B,IAAIC,EAAS,GACb,IAAK,IAAIC,EAAI,EAAOF,EAAIG,OAARD,EAAgBA,IAAK,CACnC,MAAME,EAAOJ,EAAIK,WAAWH,GAEhB,GAARE,GAAcA,EAAQ,GAIxBH,GAAUD,EAAIE,IAHVA,EAAI,IAAGD,GAAU,KACrBA,GAAUK,OAAOC,aAAaH,EAAO,IAIzC,CACA,OAAOH,CACT,CCOuBO,CAAaV,MACRC,KAErBU,KAAK,KACR,OAAOd,EAAW,WAAWR,EAAWQ,MAAe,EACzD,CAEA,MAAO,IAAIF,MAASN,EAAkBO,EAAPY,MACjC,CA8CA,MAAMI,EAAgB,IAAIC,IAAI,CAC5B,OAAQ,OAAQ,KAAM,MAAO,QAAS,KAAM,MAAO,QACnD,OAAQ,OAAQ,QAAS,SAAU,QAAS,QAM9C,SAASC,EAAcC,GAErB,GAAI,eAAgBA,EAAM,CACxB,MAAMC,EAAcD,EAAaC,WACjC,GAAIA,IAAeC,MAAMC,QAAQF,SAAqCG,IAAtBH,EAAWX,QACzD,OAAOW,CAEX,CAEA,GAAI,aA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ACFD,GAAgBd,EAAce,GAElC,CAGF,MAAO,IAAIX,IAAUE,KAAcQ,MAAiBV,IACtD,CAGA,GAAsB,KAAlBV,EAAKO,SAAiB,CACxB,IAAInB,EAAS,GACb,MAAMa,EAAaF,EAAcC,GACjC,GAAIC,GAAcA,EAAWX,OAAS,EACpC,IAAK,IAAID,EAAI,EAAOY,EAAWX,OAAfD,EAAuBA,IAAK,CAC1C,MAAMgC,EAAQpB,EAAWZ,GACrBgC,IACFjC,GAAUkB,EAAce,GAE5B,CAEF,OAAOjC,CACT,CAEA,MAAO,EACT,CAmBM,SAAUkC,EAAeC,GAC7B,IAAKA,EACH,MAAO,GAIT,GAAqB,mBAAVA,EACT,IAEE,MAAMC,EAAYC,WAAWC,UAAUC,cAAc,OACrD,IAAKH,EACH,MAAUI,MAAM,8DAGlB,MAAMnB,EAAUc,EAAMC,EAA8C,GACpE,OAAOf,GAA8B,iBAAZA,GAAwB,aAAcA,EAAUH,EAAcG,GAAmB,EAC5G,CAAE,MAAOoB,GAEP,MAAO,EACT,CAIF,MAAI,aAAcN,EACTjB,EAAciB,GAGhB,EACT,4BAQM,SAA6BO,GACjC,OAAOA,EAAOtD,IAAI+C,GAASD,EAAeC,GAC5C,+DAUM,SACJA,EACAQ,EAAuB,MACvBC,EAAyC,CAAA,GAEzC,MAAMC,EAAUX,EAAeC,GAK/B,MAAO,IAAIQ,IAJGhD,OAAOC,QAAQgD,GAC1BxD,IAAI,EAAES,EAAKJ,KAAWF,EAAmBM,EAAKJ,IAC9Ce,KAAK,OAE2BqC,MAAYF,IACjD"}
|
|
1
|
+
{"version":3,"file":"nuclo.ssr.cjs","sources":["../../src/utility/stringUtils.ts","../../src/ssr/renderToString.ts","../../src/utility/dom.ts"],"sourcesContent":["/**\n * String utility functions\n */\n\n/**\n * Converts camelCase to kebab-case (optimized for performance)\n * Uses direct character code manipulation for maximum speed\n * @example camelToKebab('backgroundColor') => 'background-color'\n */\nexport function camelToKebab(str: string): string {\n let result = '';\n for (let i = 0; i < str.length; i++) {\n const code = str.charCodeAt(i);\n // A-Z is 65-90, a-z is 97-122 (difference of 32)\n if (code >= 65 && code <= 90) {\n if (i > 0) result += '-';\n result += String.fromCharCode(code + 32);\n } else {\n result += str[i];\n }\n }\n return result;\n}\n\n/**\n * Escapes HTML special characters to prevent XSS\n */\nexport function escapeHtml(text: string): string {\n const map: Record<string, string> = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": '''\n };\n return text.replace(/[&<>\"']/g, (char) => map[char]);\n}\n","/**\n * Server-Side Rendering (SSR) utilities for Nuclo\n * Renders Nuclo components to HTML strings in Node.js environment\n */\n\nimport { escapeHtml, camelToKebab } from '../utility/stringUtils';\nimport { createElement } from '../utility/dom';\n\ntype RenderableInput =\n | NodeModFn<ElementTagName>\n | Element\n | Node\n | null\n | undefined;\n\n/**\n * Serializes a DOM attribute value\n */\nfunction serializeAttribute(name: string, value: unknown): string {\n if (value === null || value === undefined || value === false) {\n return '';\n }\n\n if (value === true) {\n return ` ${name}`;\n }\n\n if (name === 'style' && typeof value === 'object') {\n const styleStr = Object.entries(value)\n .map(([key, val]) => {\n const cssKey = camelToKebab(key);\n return `${cssKey}:${val}`;\n })\n .join(';');\n return styleStr ? ` style=\"${escapeHtml(styleStr)}\"` : '';\n }\n\n return ` ${name}=\"${escapeHtml(String(value))}\"`;\n}\n\n/**\n * Serializes DOM element attributes to HTML string\n */\nfunction serializeAttributes(element: Element): string {\n let result = '';\n\n // Handle polyfill elements with Map-based attributes\n if ('attributes' in element && element.attributes instanceof Map) {\n // First, handle special properties that might not be in the attributes Map\n const el = element as any;\n\n // Add id if it exists and is not already in attributes\n if (el.id && !element.attributes.has('id')) {\n result += serializeAttribute('id', el.id);\n }\n\n // Add class if it exists and is not already in attributes\n if (el.className && !element.attributes.has('class')) {\n result += serializeAttribute('class', el.className);\n }\n\n // Then add all attributes from the Map\n for (const [name, value] of element.attributes) {\n result += serializeAttribute(name, value);\n }\n return result;\n }\n\n // Handle browser elements with NamedNodeMap attributes\n if (element.attributes && element.attributes.length) {\n for (let i = 0; i < element.attributes.length; i++) {\n const attr = element.attributes[i];\n if (attr && attr.name) {\n result += serializeAttribute(attr.name, attr.value);\n }\n }\n }\n\n return result;\n}\n\n/**\n * Self-closing HTML tags that don't have closing tags\n */\nconst VOID_ELEMENTS = new Set([\n 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',\n 'link', 'meta', 'param', 'source', 'track', 'wbr'\n]);\n\n/**\n * Get child nodes from an element (handles both browser and polyfill elements)\n */\nfunction getChildNodes(node: Node): ArrayLike<Node> {\n // Check for childNodes first (document fragments and browser elements)\n if ('childNodes' in node) {\n const childNodes = (node as any).childNodes;\n if (childNodes && (Array.isArray(childNodes) || childNodes.length !== undefined)) {\n return childNodes;\n }\n }\n // Polyfill elements have children array\n if ('children' in node) {\n const children = (node as any).children;\n if (children && Array.isArray(children)) {\n return children as ArrayLike<Node>;\n }\n }\n return [] as ArrayLike<Node>;\n}\n\n/**\n * Serializes a DOM node to HTML string\n */\nfunction serializeNode(node: Node): string {\n // Text node\n if (node.nodeType === 3) { // Node.TEXT_NODE\n return escapeHtml(node.textContent || '');\n }\n\n // Comment node\n if (node.nodeType === 8) { // Node.COMMENT_NODE\n return `<!--${node.textContent || ''}-->`;\n }\n\n // Element node\n if (node.nodeType === 1) { // Node.ELEMENT_NODE\n const element = node as Element;\n const tagName = element.tagName.toLowerCase();\n const attributes = serializeAttributes(element);\n\n // Self-closing tags\n if (VOID_ELEMENTS.has(tagName)) {\n return `<${tagName}${attributes} />`;\n }\n\n // Regular elements with children\n let childrenHtml = '';\n const childNodes = getChildNodes(element);\n if (childNodes && childNodes.length > 0) {\n for (let i = 0; i < childNodes.length; i++) {\n const child = childNodes[i];\n if (child) {\n childrenHtml += serializeNode(child);\n }\n }\n }\n\n return `<${tagName}${attributes}>${childrenHtml}</${tagName}>`;\n }\n\n // Document fragment\n if (node.nodeType === 11) { // Node.DOCUMENT_FRAGMENT_NODE\n let result = '';\n const childNodes = getChildNodes(node);\n if (childNodes && childNodes.length > 0) {\n for (let i = 0; i < childNodes.length; i++) {\n const child = childNodes[i];\n if (child) {\n result += serializeNode(child);\n }\n }\n }\n return result;\n }\n\n return '';\n}\n\n/**\n * Renders a Nuclo component to an HTML string for server-side rendering\n *\n * @param input - A Nuclo component function, DOM element, or node\n * @returns HTML string representation of the component\n *\n * @example\n * ```ts\n * import { renderToString } from 'nuclo/ssr';\n * import { div } from 'nuclo';\n *\n * const html = renderToString(\n * div(\"Hello, World!\")\n * );\n * // Returns: '<div>Hello, World!</div>'\n * ```\n */\nexport function renderToString(input: RenderableInput): string {\n if (!input) {\n return '';\n }\n\n // If it's a function (NodeModFn), call it to create the element\n if (typeof input === 'function') {\n try {\n // Create a temporary container to render into\n const container = createElement('div');\n if (!container) {\n throw new Error('Document is not available. Make sure polyfills are loaded.');\n }\n\n const element = input(container as ExpandedElement<ElementTagName>, 0);\n return element && typeof element === 'object' && 'nodeType' in element ? serializeNode(element as Node) : '';\n } catch (error) {\n console.error('Error rendering component to string:', error);\n return '';\n }\n }\n\n // If it's already a Node, serialize it directly\n if ('nodeType' in input) {\n return serializeNode(input as Node);\n }\n\n return '';\n}\n\n/**\n * Renders multiple Nuclo components to HTML strings\n *\n * @param inputs - Array of Nuclo components\n * @returns Array of HTML strings\n */\nexport function renderManyToString(inputs: RenderableInput[]): string[] {\n return inputs.map(input => renderToString(input));\n}\n\n/**\n * Renders a Nuclo component and wraps it in a container element\n *\n * @param input - A Nuclo component\n * @param containerTag - The tag name for the container (default: 'div')\n * @param containerAttrs - Attributes for the container element\n * @returns HTML string with container wrapper\n */\nexport function renderToStringWithContainer(\n input: RenderableInput,\n containerTag: string = 'div',\n containerAttrs: Record<string, string> = {}\n): string {\n const content = renderToString(input);\n const attrs = Object.entries(containerAttrs)\n .map(([key, value]) => serializeAttribute(key, value))\n .join('');\n\n return `<${containerTag}${attrs}>${content}</${containerTag}>`;\n}\n","import { isBrowser } from \"./environment\";\nimport { logError } from \"./errorHandler\";\n\n/**\n * Creates an HTML element.\n * Wrapper for document.createElement with type safety.\n */\nexport function createElement<K extends keyof HTMLElementTagNameMap>(\n tagName: K\n): HTMLElementTagNameMap[K] | null;\nexport function createElement(tagName: string): ExpandedElement | null;\nexport function createElement(tagName: string): ExpandedElement | null {\n return globalThis.document ? document.createElement(tagName) as ExpandedElement : null;\n}\n\n/**\n * Creates an element in the given namespace (typically for SVG elements).\n * Wrapper for document.createElementNS with type safety.\n */\nexport function createElementNS(\n namespace: string,\n tagName: string\n): ExpandedElement | null {\n return globalThis.document ? document.createElementNS(namespace, tagName) as ExpandedElement : null;\n}\n\n/**\n * Creates a text node with the given content.\n * Wrapper for document.createTextNode.\n */\nexport function createTextNode(text: string): Text | null {\n return globalThis.document ? document.createTextNode(text) : null;\n}\n\n/**\n * Creates a document fragment.\n * Wrapper for document.createDocumentFragment.\n */\nexport function createDocumentFragment(): DocumentFragment | null {\n return globalThis.document ? document.createDocumentFragment() : null;\n}\n\nfunction safeAppendChild(parent: Element | Node, child: Node): boolean {\n try {\n parent.appendChild(child);\n return true;\n } catch (error) {\n logError('Failed to append child node', error);\n return false;\n }\n}\n\nexport function safeRemoveChild(child: Node): boolean {\n if (!child?.parentNode) return false;\n try {\n child.parentNode.removeChild(child);\n return true;\n } catch (error) {\n logError('Failed to remove child node', error);\n return false;\n }\n}\n\nfunction safeInsertBefore(parent: Node, newNode: Node, referenceNode: Node | null): boolean {\n try {\n parent.insertBefore(newNode, referenceNode);\n return true;\n } catch (error) {\n logError('Failed to insert node before reference', error);\n return false;\n }\n}\n\nfunction createTextNodeSafely(text: string | number | boolean): Text | null {\n if (!isBrowser) return null;\n try {\n return createTextNode(String(text));\n } catch (error) {\n logError('Failed to create text node', error);\n return null;\n }\n}\n\nfunction createCommentSafely(text: string): Comment | null {\n if (!isBrowser) return null;\n try {\n return document.createComment(text);\n } catch (error) {\n logError('Failed to create comment node', error);\n return null;\n }\n}\n\n/**\n * Creates a comment node safely with error handling.\n * Exported for use across the codebase.\n */\nexport function createComment(text: string): Comment | null {\n return createCommentSafely(text);\n}\n\n/**\n * Creates a conditional comment placeholder node.\n * In SSR environments, this will still work because we bypass the isBrowser check.\n */\nexport function createConditionalComment(tagName: string, suffix: string = \"hidden\"): Comment | null {\n // For SSR, we need to create comments even when isBrowser is false\n // This function intentionally skips the isBrowser check for SSR compatibility\n try {\n return document.createComment(`conditional-${tagName}-${suffix}`);\n } catch (error) {\n logError('Failed to create conditional comment', error);\n return null;\n }\n}\n\nexport function createMarkerComment(prefix: string): Comment {\n if (!isBrowser) {\n throw new Error(\"Cannot create comment in non-browser environment\");\n }\n const comment = createCommentSafely(`${prefix}-${Math.random().toString(36).slice(2)}`);\n if (!comment) {\n throw new Error(\"Failed to create comment\");\n }\n return comment;\n}\n\nexport function createMarkerPair(prefix: string): { start: Comment; end: Comment } {\n const endComment = createCommentSafely(`${prefix}-end`);\n if (!endComment) {\n throw new Error(\"Failed to create end comment\");\n }\n return {\n start: createMarkerComment(`${prefix}-start`),\n end: endComment\n };\n}\n\nexport function clearBetweenMarkers(startMarker: Comment, endMarker: Comment): void {\n let current = startMarker.nextSibling;\n while (current && current !== endMarker) {\n const next = current.nextSibling;\n safeRemoveChild(current);\n current = next;\n }\n}\n\nexport function insertNodesBefore(nodes: Node[], referenceNode: Node): void {\n const parent = referenceNode.parentNode;\n if (parent) {\n nodes.forEach(function(node) { safeInsertBefore(parent, node, referenceNode); });\n }\n}\n\nexport function appendChildren(\n parent: Element | Node,\n ...children: Array<Element | Node | string | null | undefined>\n): Element | Node {\n if (!parent) return parent;\n\n children.forEach(function(child) {\n if (child != null) {\n let nodeToAppend: Node;\n\n if (typeof child === \"string\") {\n const textNode = createTextNodeSafely(child);\n if (textNode) {\n nodeToAppend = textNode;\n } else {\n return;\n }\n } else {\n nodeToAppend = child as Node;\n }\n\n safeAppendChild(parent, nodeToAppend);\n }\n });\n\n return parent;\n}\n\nexport function isNodeConnected(node: Node | null | undefined): boolean {\n if (!node) return false;\n\n // Prefer the built-in isConnected property\n if (typeof node.isConnected === \"boolean\") {\n return node.isConnected;\n }\n\n // Fallback for older browsers (only if in browser environment)\n if (isBrowser && typeof document !== 'undefined') {\n return document.contains(node);\n }\n\n // In SSR or when document is not available, assume disconnected\n return false;\n}\n\n/**\n * Safely replaces an old node with a new node in the DOM.\n * Returns true on success, false on failure (and logs the error).\n */\nexport function replaceNodeSafely(oldNode: Node, newNode: Node): boolean {\n if (!oldNode?.parentNode) return false;\n try {\n oldNode.parentNode.replaceChild(newNode, oldNode);\n return true;\n } catch (error) {\n logError(\"Error replacing conditional node\", error);\n return false;\n }\n}\n"],"names":["escapeHtml","text","map","replace","char","serializeAttribute","name","value","styleStr","Object","entries","key","val","str","result","i","length","code","charCodeAt","String","fromCharCode","camelToKebab","join","VOID_ELEMENTS","Set","getChildNodes","node","childNodes","Array","isArray","undefined","children","serializeNode","nodeType","textContent","element","tagName","toLowerCase","attributes","Map","el","id","has","className","attr","serializeAttributes","childrenHtml","child","renderToString","input","container","globalThis","document","createElement","Error","error","console","inputs","containerTag","containerAttrs","content"],"mappings":"aA2BM,SAAUA,EAAWC,GACzB,MAAMC,EAA8B,CAClC,IAAK,QACL,IAAK,OACL,IAAK,OACL,IAAK,SACL,IAAK,UAEP,OAAOD,EAAKE,QAAQ,WAAaC,GAASF,EAAIE,GAChD,CClBA,SAASC,EAAmBC,EAAcC,GACxC,GAAIA,UAAmD,IAAVA,EAC3C,MAAO,GAGT,IAAc,IAAVA,EACF,MAAO,IAAID,EAGb,GAAa,UAATA,GAAqC,iBAAVC,EAAoB,CACjD,MAAMC,EAAWC,OAAOC,QAAQH,GAC7BL,IAAI,EAAES,EAAKC,KAEH,GDtBT,SAAuBC,GAC3B,IAAIC,EAAS,GACb,IAAK,IAAIC,EAAI,EAAOF,EAAIG,OAARD,EAAgBA,IAAK,CACnC,MAAME,EAAOJ,EAAIK,WAAWH,GAEhB,GAARE,GAAcA,EAAQ,GAIxB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cN,EACTjB,EAAciB,GAGhB,EACT,4BAQM,SAA6BQ,GACjC,OAAOA,EAAOvD,IAAI+C,GAASD,EAAeC,GAC5C,+DAUM,SACJA,EACAS,EAAuB,MACvBC,EAAyC,CAAA,GAEzC,MAAMC,EAAUZ,EAAeC,GAK/B,MAAO,IAAIS,IAJGjD,OAAOC,QAAQiD,GAC1BzD,IAAI,EAAES,EAAKJ,KAAWF,EAAmBM,EAAKJ,IAC9Ce,KAAK,OAE2BsC,MAAYF,IACjD"}
|
package/dist/ssr/nuclo.ssr.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function t(t){const e={"&":"&","<":"<",">":">",'"':""","'":"'"};return t.replace(/[&<>"']/g,t=>e[t])}function e(e,n){if(null==n||!1===n)return"";if(!0===n)return" "+e;if("style"===e&&"object"==typeof n){const e=Object.entries(n).map(([t,e])=>`${function(t){let e="";for(let n=0;t.length>n;n++){const r=t.charCodeAt(n);65>r||r>90?e+=t[n]:(n>0&&(e+="-"),e+=String.fromCharCode(r+32))}return e}(t)}:${e}`).join(";");return e?` style="${t(e)}"`:""}return` ${e}="${t(n+"")}"`}const n=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function r(t){if("childNodes"in t){const e=t.childNodes;if(e&&(Array.isArray(e)||void 0!==e.length))return e}if("children"in t){const e=t.children;if(e&&Array.isArray(e))return e}return[]}function i
|
|
1
|
+
function t(t){const e={"&":"&","<":"<",">":">",'"':""","'":"'"};return t.replace(/[&<>"']/g,t=>e[t])}function e(e,n){if(null==n||!1===n)return"";if(!0===n)return" "+e;if("style"===e&&"object"==typeof n){const e=Object.entries(n).map(([t,e])=>`${function(t){let e="";for(let n=0;t.length>n;n++){const r=t.charCodeAt(n);65>r||r>90?e+=t[n]:(n>0&&(e+="-"),e+=String.fromCharCode(r+32))}return e}(t)}:${e}`).join(";");return e?` style="${t(e)}"`:""}return` ${e}="${t(n+"")}"`}const n=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function r(t){if("childNodes"in t){const e=t.childNodes;if(e&&(Array.isArray(e)||void 0!==e.length))return e}if("children"in t){const e=t.children;if(e&&Array.isArray(e))return e}return[]}function o(i){if(3===i.nodeType)return t(i.textContent||"");if(8===i.nodeType)return`\x3c!--${i.textContent||""}--\x3e`;if(1===i.nodeType){const t=i,s=t.tagName.toLowerCase(),c=function(t){let n="";if("attributes"in t&&t.attributes instanceof Map){const r=t;r.id&&!t.attributes.has("id")&&(n+=e("id",r.id)),r.className&&!t.attributes.has("class")&&(n+=e("class",r.className));for(const[r,o]of t.attributes)n+=e(r,o);return n}if(t.attributes&&t.attributes.length)for(let r=0;t.attributes.length>r;r++){const o=t.attributes[r];o&&o.name&&(n+=e(o.name,o.value))}return n}(t);if(n.has(s))return`<${s}${c} />`;let a="";const u=r(t);if(u&&u.length>0)for(let t=0;u.length>t;t++){const e=u[t];e&&(a+=o(e))}return`<${s}${c}>${a}</${s}>`}if(11===i.nodeType){let t="";const e=r(i);if(e&&e.length>0)for(let n=0;e.length>n;n++){const r=e[n];r&&(t+=o(r))}return t}return""}function i(t){if(!t)return"";if("function"==typeof t)try{const e=globalThis.document?document.createElement("div"):null;if(!e)throw Error("Document is not available. Make sure polyfills are loaded.");const n=t(e,0);return n&&"object"==typeof n&&"nodeType"in n?o(n):""}catch(t){return console.error("Error rendering component to string:",t),""}return"nodeType"in t?o(t):""}function s(t){return t.map(t=>i(t))}function c(t,n="div",r={}){const o=i(t);return`<${n}${Object.entries(r).map(([t,n])=>e(t,n)).join("")}>${o}</${n}>`}export{s as renderManyToString,i as renderToString,c as renderToStringWithContainer};
|
|
2
2
|
//# sourceMappingURL=nuclo.ssr.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nuclo.ssr.js","sources":["../../src/utility/stringUtils.ts","../../src/ssr/renderToString.ts"],"sourcesContent":["/**\n * String utility functions\n */\n\n/**\n * Converts camelCase to kebab-case (optimized for performance)\n * Uses direct character code manipulation for maximum speed\n * @example camelToKebab('backgroundColor') => 'background-color'\n */\nexport function camelToKebab(str: string): string {\n let result = '';\n for (let i = 0; i < str.length; i++) {\n const code = str.charCodeAt(i);\n // A-Z is 65-90, a-z is 97-122 (difference of 32)\n if (code >= 65 && code <= 90) {\n if (i > 0) result += '-';\n result += String.fromCharCode(code + 32);\n } else {\n result += str[i];\n }\n }\n return result;\n}\n\n/**\n * Escapes HTML special characters to prevent XSS\n */\nexport function escapeHtml(text: string): string {\n const map: Record<string, string> = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": '''\n };\n return text.replace(/[&<>\"']/g, (char) => map[char]);\n}\n","/**\n * Server-Side Rendering (SSR) utilities for Nuclo\n * Renders Nuclo components to HTML strings in Node.js environment\n */\n\nimport { escapeHtml, camelToKebab } from '../utility/stringUtils';\n\ntype RenderableInput =\n | NodeModFn<ElementTagName>\n | Element\n | Node\n | null\n | undefined;\n\n/**\n * Serializes a DOM attribute value\n */\nfunction serializeAttribute(name: string, value: unknown): string {\n if (value === null || value === undefined || value === false) {\n return '';\n }\n\n if (value === true) {\n return ` ${name}`;\n }\n\n if (name === 'style' && typeof value === 'object') {\n const styleStr = Object.entries(value)\n .map(([key, val]) => {\n const cssKey = camelToKebab(key);\n return `${cssKey}:${val}`;\n })\n .join(';');\n return styleStr ? ` style=\"${escapeHtml(styleStr)}\"` : '';\n }\n\n return ` ${name}=\"${escapeHtml(String(value))}\"`;\n}\n\n/**\n * Serializes DOM element attributes to HTML string\n */\nfunction serializeAttributes(element: Element): string {\n let result = '';\n\n // Handle polyfill elements with Map-based attributes\n if ('attributes' in element && element.attributes instanceof Map) {\n // First, handle special properties that might not be in the attributes Map\n const el = element as any;\n\n // Add id if it exists and is not already in attributes\n if (el.id && !element.attributes.has('id')) {\n result += serializeAttribute('id', el.id);\n }\n\n // Add class if it exists and is not already in attributes\n if (el.className && !element.attributes.has('class')) {\n result += serializeAttribute('class', el.className);\n }\n\n // Then add all attributes from the Map\n for (const [name, value] of element.attributes) {\n result += serializeAttribute(name, value);\n }\n return result;\n }\n\n // Handle browser elements with NamedNodeMap attributes\n if (element.attributes && element.attributes.length) {\n for (let i = 0; i < element.attributes.length; i++) {\n const attr = element.attributes[i];\n if (attr && attr.name) {\n result += serializeAttribute(attr.name, attr.value);\n }\n }\n }\n\n return result;\n}\n\n/**\n * Self-closing HTML tags that don't have closing tags\n */\nconst VOID_ELEMENTS = new Set([\n 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',\n 'link', 'meta', 'param', 'source', 'track', 'wbr'\n]);\n\n/**\n * Get child nodes from an element (handles both browser and polyfill elements)\n */\nfunction getChildNodes(node: Node): ArrayLike<Node> {\n // Check for childNodes first (document fragments and browser elements)\n if ('childNodes' in node) {\n const childNodes = (node as any).childNodes;\n if (childNodes && (Array.isArray(childNodes) || childNodes.length !== undefined)) {\n return childNodes;\n }\n }\n // Polyfill elements have children array\n if ('children' in node) {\n const children = (node as any).children;\n if (children && Array.isArray(children)) {\n return children as ArrayLike<Node>;\n }\n }\n return [] as ArrayLike<Node>;\n}\n\n/**\n * Serializes a DOM node to HTML string\n */\nfunction serializeNode(node: Node): string {\n // Text node\n if (node.nodeType === 3) { // Node.TEXT_NODE\n return escapeHtml(node.textContent || '');\n }\n\n // Comment node\n if (node.nodeType === 8) { // Node.COMMENT_NODE\n return `<!--${node.textContent || ''}-->`;\n }\n\n // Element node\n if (node.nodeType === 1) { // Node.ELEMENT_NODE\n const element = node as Element;\n const tagName = element.tagName.toLowerCase();\n const attributes = serializeAttributes(element);\n\n // Self-closing tags\n if (VOID_ELEMENTS.has(tagName)) {\n return `<${tagName}${attributes} />`;\n }\n\n // Regular elements with children\n let childrenHtml = '';\n const childNodes = getChildNodes(element);\n if (childNodes && childNodes.length > 0) {\n for (let i = 0; i < childNodes.length; i++) {\n const child = childNodes[i];\n if (child) {\n childrenHtml += serializeNode(child);\n }\n }\n }\n\n return `<${tagName}${attributes}>${childrenHtml}</${tagName}>`;\n }\n\n // Document fragment\n if (node.nodeType === 11) { // Node.DOCUMENT_FRAGMENT_NODE\n let result = '';\n const childNodes = getChildNodes(node);\n if (childNodes && childNodes.length > 0) {\n for (let i = 0; i < childNodes.length; i++) {\n const child = childNodes[i];\n if (child) {\n result += serializeNode(child);\n }\n }\n }\n return result;\n }\n\n return '';\n}\n\n/**\n * Renders a Nuclo component to an HTML string for server-side rendering\n *\n * @param input - A Nuclo component function, DOM element, or node\n * @returns HTML string representation of the component\n *\n * @example\n * ```ts\n * import { renderToString } from 'nuclo/ssr';\n * import { div } from 'nuclo';\n *\n * const html = renderToString(\n * div(\"Hello, World!\")\n * );\n * // Returns: '<div>Hello, World!</div>'\n * ```\n */\nexport function renderToString(input: RenderableInput): string {\n if (!input) {\n return '';\n }\n\n // If it's a function (NodeModFn), call it to create the element\n if (typeof input === 'function') {\n try {\n // Create a temporary container to render into\n const container = globalThis.document?.createElement('div');\n if (!container) {\n throw new Error('Document is not available. Make sure polyfills are loaded.');\n }\n\n const element = input(container as ExpandedElement<ElementTagName>, 0);\n return element && typeof element === 'object' && 'nodeType' in element ? serializeNode(element as Node) : '';\n } catch (error) {\n console.error('Error rendering component to string:', error);\n return '';\n }\n }\n\n // If it's already a Node, serialize it directly\n if ('nodeType' in input) {\n return serializeNode(input as Node);\n }\n\n return '';\n}\n\n/**\n * Renders multiple Nuclo components to HTML strings\n *\n * @param inputs - Array of Nuclo components\n * @returns Array of HTML strings\n */\nexport function renderManyToString(inputs: RenderableInput[]): string[] {\n return inputs.map(input => renderToString(input));\n}\n\n/**\n * Renders a Nuclo component and wraps it in a container element\n *\n * @param input - A Nuclo component\n * @param containerTag - The tag name for the container (default: 'div')\n * @param containerAttrs - Attributes for the container element\n * @returns HTML string with container wrapper\n */\nexport function renderToStringWithContainer(\n input: RenderableInput,\n containerTag: string = 'div',\n containerAttrs: Record<string, string> = {}\n): string {\n const content = renderToString(input);\n const attrs = Object.entries(containerAttrs)\n .map(([key, value]) => serializeAttribute(key, value))\n .join('');\n\n return `<${containerTag}${attrs}>${content}</${containerTag}>`;\n}\n"],"names":["escapeHtml","text","map","replace","char","serializeAttribute","name","value","styleStr","Object","entries","key","val","str","result","i","length","code","charCodeAt","String","fromCharCode","camelToKebab","join","VOID_ELEMENTS","Set","getChildNodes","node","childNodes","Array","isArray","undefined","children","serializeNode","nodeType","textContent","element","tagName","toLowerCase","attributes","Map","el","id","has","className","attr","serializeAttributes","childrenHtml","child","renderToString","input","container","globalThis","document","createElement","Error","error","renderManyToString","inputs","renderToStringWithContainer","containerTag","containerAttrs","content"],"mappings":"AA2BM,SAAUA,EAAWC,GACzB,MAAMC,EAA8B,CAClC,IAAK,QACL,IAAK,OACL,IAAK,OACL,IAAK,SACL,IAAK,UAEP,OAAOD,EAAKE,QAAQ,WAAaC,GAASF,EAAIE,GAChD,CCnBA,SAASC,EAAmBC,EAAcC,GACxC,GAAIA,UAAmD,IAAVA,EAC3C,MAAO,GAGT,IAAc,IAAVA,EACF,MAAO,IAAID,EAGb,GAAa,UAATA,GAAqC,iBAAVC,EAAoB,CACjD,MAAMC,EAAWC,OAAOC,QAAQH,GAC7BL,IAAI,EAAES,EAAKC,KAEH,GDrBT,SAAuBC,GAC3B,IAAIC,EAAS,GACb,IAAK,IAAIC,EAAI,EAAOF,EAAIG,OAARD,EAAgBA,IAAK,CACnC,MAAME,EAAOJ,EAAIK,WAAWH,GAEhB,GAARE,GAAcA,EAAQ,GAIxBH,GAAUD,EAAIE,IAHVA,EAAI,IAAGD,GAAU,KACrBA,GAAUK,OAAOC,aAAaH,EAAO,IAIzC,CACA,OAAOH,CACT,CCOuBO,CAAaV,MACRC,KAErBU,KAAK,KACR,OAAOd,EAAW,WAAWR,EAAWQ,MAAe,EACzD,CAEA,MAAO,IAAIF,MAASN,EAAkBO,EAAPY,MACjC,CA8CA,MAAMI,EAAgB,IAAIC,IAAI,CAC5B,OAAQ,OAAQ,KAAM,MAAO,QAAS,KAAM,MAAO,QACnD,OAAQ,OAAQ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../../src/ssr/renderToString.ts","../../src/utility/dom.ts"],"sourcesContent":["/**\n * String utility functions\n */\n\n/**\n * Converts camelCase to kebab-case (optimized for performance)\n * Uses direct character code manipulation for maximum speed\n * @example camelToKebab('backgroundColor') => 'background-color'\n */\nexport function camelToKebab(str: string): string {\n let result = '';\n for (let i = 0; i < str.length; i++) {\n const code = str.charCodeAt(i);\n // A-Z is 65-90, a-z is 97-122 (difference of 32)\n if (code >= 65 && code <= 90) {\n if (i > 0) result += '-';\n result += String.fromCharCode(code + 32);\n } else {\n result += str[i];\n }\n }\n return result;\n}\n\n/**\n * Escapes HTML special characters to prevent XSS\n */\nexport function escapeHtml(text: string): string {\n const map: Record<string, string> = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": '''\n };\n return text.replace(/[&<>\"']/g, (char) => map[char]);\n}\n","/**\n * Server-Side Rendering (SSR) utilities for Nuclo\n * Renders Nuclo components to HTML strings in Node.js environment\n */\n\nimport { escapeHtml, camelToKebab } from '../utility/stringUtils';\nimport { createElement } from '../utility/dom';\n\ntype RenderableInput =\n | NodeModFn<ElementTagName>\n | Element\n | Node\n | null\n | undefined;\n\n/**\n * Serializes a DOM attribute value\n */\nfunction serializeAttribute(name: string, value: unknown): string {\n if (value === null || value === undefined || value === false) {\n return '';\n }\n\n if (value === true) {\n return ` ${name}`;\n }\n\n if (name === 'style' && typeof value === 'object') {\n const styleStr = Object.entries(value)\n .map(([key, val]) => {\n const cssKey = camelToKebab(key);\n return `${cssKey}:${val}`;\n })\n .join(';');\n return styleStr ? ` style=\"${escapeHtml(styleStr)}\"` : '';\n }\n\n return ` ${name}=\"${escapeHtml(String(value))}\"`;\n}\n\n/**\n * Serializes DOM element attributes to HTML string\n */\nfunction serializeAttributes(element: Element): string {\n let result = '';\n\n // Handle polyfill elements with Map-based attributes\n if ('attributes' in element && element.attributes instanceof Map) {\n // First, handle special properties that might not be in the attributes Map\n const el = element as any;\n\n // Add id if it exists and is not already in attributes\n if (el.id && !element.attributes.has('id')) {\n result += serializeAttribute('id', el.id);\n }\n\n // Add class if it exists and is not already in attributes\n if (el.className && !element.attributes.has('class')) {\n result += serializeAttribute('class', el.className);\n }\n\n // Then add all attributes from the Map\n for (const [name, value] of element.attributes) {\n result += serializeAttribute(name, value);\n }\n return result;\n }\n\n // Handle browser elements with NamedNodeMap attributes\n if (element.attributes && element.attributes.length) {\n for (let i = 0; i < element.attributes.length; i++) {\n const attr = element.attributes[i];\n if (attr && attr.name) {\n result += serializeAttribute(attr.name, attr.value);\n }\n }\n }\n\n return result;\n}\n\n/**\n * Self-closing HTML tags that don't have closing tags\n */\nconst VOID_ELEMENTS = new Set([\n 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',\n 'link', 'meta', 'param', 'source', 'track', 'wbr'\n]);\n\n/**\n * Get child nodes from an element (handles both browser and polyfill elements)\n */\nfunction getChildNodes(node: Node): ArrayLike<Node> {\n // Check for childNodes first (document fragments and browser elements)\n if ('childNodes' in node) {\n const childNodes = (node as any).childNodes;\n if (childNodes && (Array.isArray(childNodes) || childNodes.length !== undefined)) {\n return childNodes;\n }\n }\n // Polyfill elements have children array\n if ('children' in node) {\n const children = (node as any).children;\n if (children && Array.isArray(children)) {\n return children as ArrayLike<Node>;\n }\n }\n return [] as ArrayLike<Node>;\n}\n\n/**\n * Serializes a DOM node to HTML string\n */\nfunction serializeNode(node: Node): string {\n // Text node\n if (node.nodeType === 3) { // Node.TEXT_NODE\n return escapeHtml(node.textContent || '');\n }\n\n // Comment node\n if (node.nodeType === 8) { // Node.COMMENT_NODE\n return `<!--${node.textContent || ''}-->`;\n }\n\n // Element node\n if (node.nodeType === 1) { // Node.ELEMENT_NODE\n const element = node as Element;\n const tagName = element.tagName.toLowerCase();\n const attributes = serializeAttributes(element);\n\n // Self-closing tags\n if (VOID_ELEMENTS.has(tagName)) {\n return `<${tagName}${attributes} />`;\n }\n\n // Regular elements with children\n let childrenHtml = '';\n const childNodes = getChildNodes(element);\n if (childNodes && childNodes.length > 0) {\n for (let i = 0; i < childNodes.length; i++) {\n const child = childNodes[i];\n if (child) {\n childrenHtml += serializeNode(child);\n }\n }\n }\n\n return `<${tagName}${attributes}>${childrenHtml}</${tagName}>`;\n }\n\n // Document fragment\n if (node.nodeType === 11) { // Node.DOCUMENT_FRAGMENT_NODE\n let result = '';\n const childNodes = getChildNodes(node);\n if (childNodes && childNodes.length > 0) {\n for (let i = 0; i < childNodes.length; i++) {\n const child = childNodes[i];\n if (child) {\n result += serializeNode(child);\n }\n }\n }\n return result;\n }\n\n return '';\n}\n\n/**\n * Renders a Nuclo component to an HTML string for server-side rendering\n *\n * @param input - A Nuclo component function, DOM element, or node\n * @returns HTML string representation of the component\n *\n * @example\n * ```ts\n * import { renderToString } from 'nuclo/ssr';\n * import { div } from 'nuclo';\n *\n * const html = renderToString(\n * div(\"Hello, World!\")\n * );\n * // Returns: '<div>Hello, World!</div>'\n * ```\n */\nexport function renderToString(input: RenderableInput): string {\n if (!input) {\n return '';\n }\n\n // If it's a function (NodeModFn), call it to create the element\n if (typeof input === 'function') {\n try {\n // Create a temporary container to render into\n const container = createElement('div');\n if (!container) {\n throw new Error('Document is not available. Make sure polyfills are loaded.');\n }\n\n const element = input(container as ExpandedElement<ElementTagName>, 0);\n return element && typeof element === 'object' && 'nodeType' in element ? serializeNode(element as Node) : '';\n } catch (error) {\n console.error('Error rendering component to string:', error);\n return '';\n }\n }\n\n // If it's already a Node, serialize it directly\n if ('nodeType' in input) {\n return serializeNode(input as Node);\n }\n\n return '';\n}\n\n/**\n * Renders multiple Nuclo components to HTML strings\n *\n * @param inputs - Array of Nuclo components\n * @returns Array of HTML strings\n */\nexport function renderManyToString(inputs: RenderableInput[]): string[] {\n return inputs.map(input => renderToString(input));\n}\n\n/**\n * Renders a Nuclo component and wraps it in a container element\n *\n * @param input - A Nuclo component\n * @param containerTag - The tag name for the container (default: 'div')\n * @param containerAttrs - Attributes for the container element\n * @returns HTML string with container wrapper\n */\nexport function renderToStringWithContainer(\n input: RenderableInput,\n containerTag: string = 'div',\n containerAttrs: Record<string, string> = {}\n): string {\n const content = renderToString(input);\n const attrs = Object.entries(containerAttrs)\n .map(([key, value]) => serializeAttribute(key, value))\n .join('');\n\n return `<${containerTag}${attrs}>${content}</${containerTag}>`;\n}\n","import { isBrowser } from \"./environment\";\nimport { logError } from \"./errorHandler\";\n\n/**\n * Creates an HTML element.\n * Wrapper for document.createElement with type safety.\n */\nexport function createElement<K extends keyof HTMLElementTagNameMap>(\n tagName: K\n): HTMLElementTagNameMap[K] | null;\nexport function createElement(tagName: string): ExpandedElement | null;\nexport function createElement(tagName: string): ExpandedElement | null {\n return globalThis.document ? document.createElement(tagName) as ExpandedElement : null;\n}\n\n/**\n * Creates an element in the given namespace (typically for SVG elements).\n * Wrapper for document.createElementNS with type safety.\n */\nexport function createElementNS(\n namespace: string,\n tagName: string\n): ExpandedElement | null {\n return globalThis.document ? document.createElementNS(namespace, tagName) as ExpandedElement : null;\n}\n\n/**\n * Creates a text node with the given content.\n * Wrapper for document.createTextNode.\n */\nexport function createTextNode(text: string): Text | null {\n return globalThis.document ? document.createTextNode(text) : null;\n}\n\n/**\n * Creates a document fragment.\n * Wrapper for document.createDocumentFragment.\n */\nexport function createDocumentFragment(): DocumentFragment | null {\n return globalThis.document ? document.createDocumentFragment() : null;\n}\n\nfunction safeAppendChild(parent: Element | Node, child: Node): boolean {\n try {\n parent.appendChild(child);\n return true;\n } catch (error) {\n logError('Failed to append child node', error);\n return false;\n }\n}\n\nexport function safeRemoveChild(child: Node): boolean {\n if (!child?.parentNode) return false;\n try {\n child.parentNode.removeChild(child);\n return true;\n } catch (error) {\n logError('Failed to remove child node', error);\n return false;\n }\n}\n\nfunction safeInsertBefore(parent: Node, newNode: Node, referenceNode: Node | null): boolean {\n try {\n parent.insertBefore(newNode, referenceNode);\n return true;\n } catch (error) {\n logError('Failed to insert node before reference', error);\n return false;\n }\n}\n\nfunction createTextNodeSafely(text: string | number | boolean): Text | null {\n if (!isBrowser) return null;\n try {\n return createTextNode(String(text));\n } catch (error) {\n logError('Failed to create text node', error);\n return null;\n }\n}\n\nfunction createCommentSafely(text: string): Comment | null {\n if (!isBrowser) return null;\n try {\n return document.createComment(text);\n } catch (error) {\n logError('Failed to create comment node', error);\n return null;\n }\n}\n\n/**\n * Creates a comment node safely with error handling.\n * Exported for use across the codebase.\n */\nexport function createComment(text: string): Comment | null {\n return createCommentSafely(text);\n}\n\n/**\n * Creates a conditional comment placeholder node.\n * In SSR environments, this will still work because we bypass the isBrowser check.\n */\nexport function createConditionalComment(tagName: string, suffix: string = \"hidden\"): Comment | null {\n // For SSR, we need to create comments even when isBrowser is false\n // This function intentionally skips the isBrowser check for SSR compatibility\n try {\n return document.createComment(`conditional-${tagName}-${suffix}`);\n } catch (error) {\n logError('Failed to create conditional comment', error);\n return null;\n }\n}\n\nexport function createMarkerComment(prefix: string): Comment {\n if (!isBrowser) {\n throw new Error(\"Cannot create comment in non-browser environment\");\n }\n const comment = createCommentSafely(`${prefix}-${Math.random().toString(36).slice(2)}`);\n if (!comment) {\n throw new Error(\"Failed to create comment\");\n }\n return comment;\n}\n\nexport function createMarkerPair(prefix: string): { start: Comment; end: Comment } {\n const endComment = createCommentSafely(`${prefix}-end`);\n if (!endComment) {\n throw new Error(\"Failed to create end comment\");\n }\n return {\n start: createMarkerComment(`${prefix}-start`),\n end: endComment\n };\n}\n\nexport function clearBetweenMarkers(startMarker: Comment, endMarker: Comment): void {\n let current = startMarker.nextSibling;\n while (current && current !== endMarker) {\n const next = current.nextSibling;\n safeRemoveChild(current);\n current = next;\n }\n}\n\nexport function insertNodesBefore(nodes: Node[], referenceNode: Node): void {\n const parent = referenceNode.parentNode;\n if (parent) {\n nodes.forEach(function(node) { safeInsertBefore(parent, node, referenceNode); });\n }\n}\n\nexport function appendChildren(\n parent: Element | Node,\n ...children: Array<Element | Node | string | null | undefined>\n): Element | Node {\n if (!parent) return parent;\n\n children.forEach(function(child) {\n if (child != null) {\n let nodeToAppend: Node;\n\n if (typeof child === \"string\") {\n const textNode = createTextNodeSafely(child);\n if (textNode) {\n nodeToAppend = textNode;\n } else {\n return;\n }\n } else {\n nodeToAppend = child as Node;\n }\n\n safeAppendChild(parent, nodeToAppend);\n }\n });\n\n return parent;\n}\n\nexport function isNodeConnected(node: Node | null | undefined): boolean {\n if (!node) return false;\n\n // Prefer the built-in isConnected property\n if (typeof node.isConnected === \"boolean\") {\n return node.isConnected;\n }\n\n // Fallback for older browsers (only if in browser environment)\n if (isBrowser && typeof document !== 'undefined') {\n return document.contains(node);\n }\n\n // In SSR or when document is not available, assume disconnected\n return false;\n}\n\n/**\n * Safely replaces an old node with a new node in the DOM.\n * Returns true on success, false on failure (and logs the error).\n */\nexport function replaceNodeSafely(oldNode: Node, newNode: Node): boolean {\n if (!oldNode?.parentNode) return false;\n try {\n oldNode.parentNode.replaceChild(newNode, oldNode);\n return true;\n } catch (error) {\n logError(\"Error replacing conditional node\", error);\n return false;\n }\n}\n"],"names":["escapeHtml","text","map","replace","char","serializeAttribute","name","value","styleStr","Object","entries","key","val","str","result","i","length","code","charCodeAt","String","fromCharCode","camelToKebab","join","VOID_ELEMENTS","Set","getChildNodes","node","childNodes","Array","isArray","undefined","children","serializeNode","nodeType","textContent","element","tagName","toLowerCase","attributes","Map","el","id","has","className","attr","serializeAttributes","childrenHtml","child","renderToString","input","container","globalThis","document","createElement","Error","error","console","renderManyToString","inputs","renderToStringWithContainer","containerTag","containerAttrs","content"],"mappings":"AA2BM,SAAUA,EAAWC,GACzB,MAAMC,EAA8B,CAClC,IAAK,QACL,IAAK,OACL,IAAK,OACL,IAAK,SACL,IAAK,UAEP,OAAOD,EAAKE,QAAQ,WAAaC,GAASF,EAAIE,GAChD,CClBA,SAASC,EAAmBC,EAAcC,GACxC,GAAIA,UAAmD,IAAVA,EAC3C,MAAO,GAGT,IAAc,IAAVA,EACF,MAAO,IAAID,EAGb,GAAa,UAATA,GAAqC,iBAAVC,EAAoB,CACjD,MAAMC,EAA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E,IAAKH,EACH,MAAUI,MAAM,8DAGlB,MAAMnB,EAAUc,EAAMC,EAA8C,GACpE,OAAOf,GAA8B,iBAAZA,GAAwB,aAAcA,EAAUH,EAAcG,GAAmB,EAC5G,CAAE,MAAOoB,GAEP,OADAC,QAAQD,MAAM,uCAAwCA,GAC/C,EACT,CAIF,MAAI,aAAcN,EACTjB,EAAciB,GAGhB,EACT,CAQM,SAAUQ,EAAmBC,GACjC,OAAOA,EAAOxD,IAAI+C,GAASD,EAAeC,GAC5C,CAUM,SAAUU,EACdV,EACAW,EAAuB,MACvBC,EAAyC,CAAA,GAEzC,MAAMC,EAAUd,EAAeC,GAK/B,MAAO,IAAIW,IAJGnD,OAAOC,QAAQmD,GAC1B3D,IAAI,EAAES,EAAKJ,KAAWF,EAAmBM,EAAKJ,IAC9Ce,KAAK,OAE2BwC,MAAYF,IACjD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderToString.d.ts","sourceRoot":"","sources":["../../src/ssr/renderToString.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"renderToString.d.ts","sourceRoot":"","sources":["../../src/ssr/renderToString.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,KAAK,eAAe,GAChB,SAAS,CAAC,cAAc,CAAC,GACzB,OAAO,GACP,IAAI,GACJ,IAAI,GACJ,SAAS,CAAC;AA2Jd;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CA4B7D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,EAAE,CAEtE;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,eAAe,EACtB,YAAY,GAAE,MAAc,EAC5B,cAAc,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAC1C,MAAM,CAOR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cssGenerator.d.ts","sourceRoot":"","sources":["../../src/style/cssGenerator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cssGenerator.d.ts","sourceRoot":"","sources":["../../src/style/cssGenerator.ts"],"names":[],"mappings":"AAGA,KAAK,UAAU,GAAG,OAAO,GAAG,WAAW,GAAG,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC;AAG1E,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,UAAU,GAAE,UAAoB,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAoDvI;AAGD,wBAAgB,wBAAwB,CACvC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,SAAS,CAAC,EAAE,MAAM,EAClB,UAAU,GAAE,UAAoB,EAChC,WAAW,CAAC,EAAE,MAAM,GAClB,IAAI,CAyLN;AAGD,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAEtF"}
|
|
@@ -13,9 +13,10 @@ export declare function storeConditionalInfo<TTagName extends ElementTagName>(no
|
|
|
13
13
|
*/
|
|
14
14
|
export declare function unregisterConditionalNode(node: Node): void;
|
|
15
15
|
/**
|
|
16
|
-
* Returns
|
|
16
|
+
* Returns an array of currently tracked conditional nodes that are still alive.
|
|
17
|
+
* Automatically cleans up garbage-collected nodes.
|
|
17
18
|
*/
|
|
18
|
-
export declare function getActiveConditionalNodes():
|
|
19
|
+
export declare function getActiveConditionalNodes(): Node[];
|
|
19
20
|
export declare function hasConditionalInfo(node: Node): boolean;
|
|
20
21
|
export declare function getConditionalInfo(node: Node): ConditionalInfo<keyof HTMLElementTagNameMap> | null;
|
|
21
22
|
//# sourceMappingURL=conditionalInfo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditionalInfo.d.ts","sourceRoot":"","sources":["../../src/utility/conditionalInfo.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe,CAAC,QAAQ,SAAS,cAAc,GAAG,cAAc;IAC/E,SAAS,EAAE,MAAM,OAAO,CAAC;IACzB,OAAO,EAAE,QAAQ,CAAC;IAClB,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC1D,KAAK,EAAE,OAAO,CAAC;CAChB;
|
|
1
|
+
{"version":3,"file":"conditionalInfo.d.ts","sourceRoot":"","sources":["../../src/utility/conditionalInfo.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe,CAAC,QAAQ,SAAS,cAAc,GAAG,cAAc;IAC/E,SAAS,EAAE,MAAM,OAAO,CAAC;IACzB,OAAO,EAAE,QAAQ,CAAC;IAClB,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC1D,KAAK,EAAE,OAAO,CAAC;CAChB;AAaD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,SAAS,cAAc,EAClE,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,eAAe,CAAC,QAAQ,CAAC,GAC9B,IAAI,CAGN;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAQ1D;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,IAAI,IAAI,EAAE,CAoBlD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAEtD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,eAAe,CAAC,MAAM,qBAAqB,CAAC,GAAG,IAAI,CAElG"}
|
package/dist/utility/dom.d.ts
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates an HTML element.
|
|
3
|
+
* Wrapper for document.createElement with type safety.
|
|
4
|
+
*/
|
|
5
|
+
export declare function createElement<K extends keyof HTMLElementTagNameMap>(tagName: K): HTMLElementTagNameMap[K] | null;
|
|
6
|
+
export declare function createElement(tagName: string): ExpandedElement | null;
|
|
7
|
+
/**
|
|
8
|
+
* Creates an element in the given namespace (typically for SVG elements).
|
|
9
|
+
* Wrapper for document.createElementNS with type safety.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createElementNS(namespace: string, tagName: string): ExpandedElement | null;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a text node with the given content.
|
|
14
|
+
* Wrapper for document.createTextNode.
|
|
15
|
+
*/
|
|
16
|
+
export declare function createTextNode(text: string): Text | null;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a document fragment.
|
|
19
|
+
* Wrapper for document.createDocumentFragment.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createDocumentFragment(): DocumentFragment | null;
|
|
1
22
|
export declare function safeRemoveChild(child: Node): boolean;
|
|
2
23
|
/**
|
|
3
24
|
* Creates a comment node safely with error handling.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/utility/dom.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/utility/dom.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,qBAAqB,EACjE,OAAO,EAAE,CAAC,GACT,qBAAqB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;AACnC,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAAC;AAKvE;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,eAAe,GAAG,IAAI,CAExB;AAED;;;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returns a NodeModFn so it can be used like any other modifier.
|
|
14
14
|
* - Produces no child node (returns void in the modifier body).
|
|
15
15
|
* - Provides strong typing of the event object based on the DOM event name.
|
|
16
|
+
* - Stores listener references in a WeakMap to prevent memory leaks.
|
|
17
|
+
* - Listeners are automatically cleaned up when elements are garbage collected.
|
|
16
18
|
*/
|
|
19
|
+
/**
|
|
20
|
+
* Remove a specific listener from an element.
|
|
21
|
+
* This is exported for manual cleanup if needed.
|
|
22
|
+
*/
|
|
23
|
+
export declare function removeListener(element: HTMLElement, type: string, listener: Function): void;
|
|
24
|
+
/**
|
|
25
|
+
* Remove all listeners of a specific type from an element.
|
|
26
|
+
*/
|
|
27
|
+
export declare function removeAllListeners(element: HTMLElement, type?: string): void;
|
|
17
28
|
/**
|
|
18
29
|
* Overload for standard HTMLElement events (strongly typed via lib.dom.d.ts)
|
|
19
30
|
*/
|
package/dist/utility/on.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"on.d.ts","sourceRoot":"","sources":["../../src/utility/on.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"on.d.ts","sourceRoot":"","sources":["../../src/utility/on.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAsCH;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,WAAW,EACpB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,QAAQ,GACjB,IAAI,CAsBN;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,WAAW,EACpB,IAAI,CAAC,EAAE,MAAM,GACZ,IAAI,CAsBN;AAED;;GAEG;AACH,wBAAgB,EAAE,CAChB,CAAC,SAAS,MAAM,mBAAmB,EACnC,QAAQ,SAAS,cAAc,GAAG,cAAc,EAEhD,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,CAAC,EAAE,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAAK,OAAO,EACjD,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAC1C,SAAS,CAAC,QAAQ,CAAC,CAAC;AAEvB;;;;GAIG;AACH,wBAAgB,EAAE,CAChB,CAAC,SAAS,MAAM,EAChB,CAAC,SAAS,KAAK,GAAG,KAAK,EACvB,QAAQ,SAAS,cAAc,GAAG,cAAc,EAEhD,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,OAAO,EAC5B,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAC1C,SAAS,CAAC,QAAQ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../src/utility/scope.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../src/utility/scope.ts"],"names":[],"mappings":"AAmCA,wBAAgB,aAAa,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,EAAE,CAoC/D;AAED,wBAAgB,KAAK,CAAC,QAAQ,SAAS,cAAc,GAAG,cAAc,EACpE,GAAG,GAAG,EAAE,MAAM,EAAE,GACf,SAAS,CAAC,QAAQ,CAAC,CAOrB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuclo",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.87",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/nuclo.cjs",
|
|
7
7
|
"module": "./dist/nuclo.js",
|
|
@@ -33,16 +33,16 @@
|
|
|
33
33
|
"@eslint/markdown": "^7.5.1",
|
|
34
34
|
"@rollup/plugin-terser": "^0.4.4",
|
|
35
35
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
36
|
-
"@types/node": "^25.0.
|
|
37
|
-
"@vitest/coverage-v8": "4.0.
|
|
36
|
+
"@types/node": "^25.0.3",
|
|
37
|
+
"@vitest/coverage-v8": "4.0.16",
|
|
38
38
|
"eslint": "^9.39.2",
|
|
39
39
|
"globals": "^16.5.0",
|
|
40
40
|
"jsdom": "^27.3.0",
|
|
41
|
-
"rollup": "^4.
|
|
41
|
+
"rollup": "^4.54.0",
|
|
42
42
|
"tslib": "^2.8.1",
|
|
43
43
|
"typescript": "^5.9.3",
|
|
44
|
-
"typescript-eslint": "^8.
|
|
45
|
-
"vitest": "^4.0.
|
|
44
|
+
"typescript-eslint": "^8.50.0",
|
|
45
|
+
"vitest": "^4.0.16"
|
|
46
46
|
},
|
|
47
47
|
"repository": {
|
|
48
48
|
"type": "git",
|