valyrian.js 8.0.13 → 8.1.0

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.
Files changed (60) hide show
  1. package/dist/lib/native-store/index.d.ts +1 -1
  2. package/dist/lib/native-store/index.d.ts.map +1 -1
  3. package/dist/lib/node/index.d.ts +2 -2
  4. package/dist/lib/node/index.d.ts.map +1 -1
  5. package/dist/lib/node/utils/server-storage.d.ts +12 -0
  6. package/dist/lib/node/utils/server-storage.d.ts.map +1 -0
  7. package/dist/lib/node/utils/tree-adapter.d.ts.map +1 -1
  8. package/dist/lib/pulses/index.d.ts +4 -0
  9. package/dist/lib/pulses/index.d.ts.map +1 -1
  10. package/dist/lib/redux-devtools/index.d.ts +15 -0
  11. package/dist/lib/redux-devtools/index.d.ts.map +1 -0
  12. package/dist/lib/request/index.d.ts.map +1 -1
  13. package/dist/lib/translate/index.d.ts +6 -2
  14. package/dist/lib/translate/index.d.ts.map +1 -1
  15. package/dist/native-store/index.js +26 -13
  16. package/dist/native-store/index.js.map +3 -3
  17. package/dist/native-store/index.min.js +1 -1
  18. package/dist/native-store/index.min.js.map +1 -1
  19. package/dist/native-store/index.mjs +26 -13
  20. package/dist/native-store/index.mjs.map +3 -3
  21. package/dist/node/index.js +57 -94
  22. package/dist/node/index.js.map +4 -4
  23. package/dist/node/index.mjs +57 -94
  24. package/dist/node/index.mjs.map +4 -4
  25. package/dist/pulses/index.js +32 -1
  26. package/dist/pulses/index.js.map +2 -2
  27. package/dist/pulses/index.min.js +1 -1
  28. package/dist/pulses/index.min.js.map +1 -1
  29. package/dist/pulses/index.mjs +32 -1
  30. package/dist/pulses/index.mjs.map +2 -2
  31. package/dist/redux-devtools/index.js +81 -0
  32. package/dist/redux-devtools/index.js.map +7 -0
  33. package/dist/redux-devtools/index.min.js +1 -0
  34. package/dist/redux-devtools/index.min.js.map +1 -0
  35. package/dist/redux-devtools/index.mjs +60 -0
  36. package/dist/redux-devtools/index.mjs.map +7 -0
  37. package/dist/request/index.js +20 -7
  38. package/dist/request/index.js.map +2 -2
  39. package/dist/request/index.min.js +1 -1
  40. package/dist/request/index.min.js.map +1 -1
  41. package/dist/request/index.mjs +20 -7
  42. package/dist/request/index.mjs.map +2 -2
  43. package/dist/translate/index.js +36 -26
  44. package/dist/translate/index.js.map +3 -3
  45. package/dist/translate/index.min.js +1 -1
  46. package/dist/translate/index.min.js.map +1 -1
  47. package/dist/translate/index.mjs +36 -26
  48. package/dist/translate/index.mjs.map +3 -3
  49. package/lib/native-store/index.ts +22 -8
  50. package/lib/node/index.ts +4 -4
  51. package/lib/node/utils/server-storage.ts +71 -0
  52. package/lib/node/utils/tree-adapter.ts +25 -1
  53. package/lib/pulses/index.ts +54 -6
  54. package/lib/redux-devtools/index.ts +86 -0
  55. package/lib/request/index.ts +28 -8
  56. package/lib/translate/index.ts +37 -26
  57. package/package.json +14 -14
  58. package/dist/lib/node/utils/session-storage.d.ts +0 -22
  59. package/dist/lib/node/utils/session-storage.d.ts.map +0 -1
  60. package/lib/node/utils/session-storage.ts +0 -120
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../lib/node/index.ts", "../../lib/node/utils/tree-adapter.ts", "../../lib/node/utils/icons.ts", "../../lib/node/utils/inline.ts", "../../lib/node/utils/sw.ts", "../../lib/node/utils/session-storage.ts"],
4
- "sourcesContent": ["import { document, domToHtml, domToHyperscript, htmlToDom, htmlToHyperscript } from \"./utils/tree-adapter\";\nimport { mount, unmount } from \"valyrian.js\";\n\nimport FormData from \"form-data\";\nimport { icons } from \"./utils/icons\";\nimport { inline } from \"./utils/inline\";\nimport { sw } from \"./utils/sw\";\nimport { SessionStorage } from \"./utils/session-storage\";\n\nglobal.FormData = FormData as any;\nglobal.document = document as any;\nglobal.sessionStorage = new SessionStorage();\nglobal.localStorage = new SessionStorage();\n\nfunction render(...args: any[]) {\n const Component = () => args;\n const result = mount(\"div\", Component);\n unmount();\n return result;\n}\n\nexport { domToHtml, domToHyperscript, htmlToDom, htmlToHyperscript, inline, sw, icons, render, SessionStorage };\n", "/* eslint-disable no-use-before-define */\n/* eslint-disable complexity */\ninterface ChildNodes extends Array<Node | Element | Text | DocumentFragment> {}\n\nexport class Node implements Node {\n // eslint-disable-next-line no-use-before-define\n childNodes: ChildNodes = [];\n baseURI: string = \"\";\n\n tag_name!: string;\n get nodeName(): string {\n return this.tag_name.toLowerCase();\n }\n set nodeName(name: string) {\n this.tag_name = name;\n }\n get tagName(): string {\n return this.tag_name;\n }\n set tagName(name: string) {\n this.tag_name = name;\n }\n\n node_type!: number;\n get nodeType(): number {\n return this.node_type;\n }\n set nodeType(type: number) {\n this.node_type = type;\n }\n\n node_value = \"\";\n attributes: Attr[] = [];\n set textContent(text) {\n this.node_value = String(text);\n }\n get textContent() {\n return this.node_value;\n }\n set nodeValue(text) {\n this.node_value = String(text);\n }\n get nodeValue() {\n return this.node_value;\n }\n\n // eslint-disable-next-line no-use-before-define\n parent_node: Node | null = null;\n get parentNode() {\n return this.parent_node;\n }\n set parentNode(node) {\n this.parent_node = node;\n }\n\n get parentElement(): Element | null {\n return this.parentNode instanceof Element ? this.parentNode : null;\n }\n\n set parentElement(node) {\n this.parentNode = node;\n }\n\n #dataset: Record<string | number, any> = {};\n\n get dataset() {\n return this.#dataset;\n }\n\n set dataset(value) {\n this.#dataset = value;\n }\n\n constructor() {}\n\n appendChild<T extends Node>(node: T): T {\n if (node) {\n node.parentNode && node.parentNode.removeChild(node as Node);\n this.childNodes.push(node);\n node.parentNode = this;\n node.parentElement = this instanceof Element ? this : null;\n }\n return node;\n }\n\n insertBefore<T extends Node>(node: T, child: Node | null): T {\n if (node) {\n node.parentNode && node.parentNode.removeChild(node as Node);\n node.parentNode = this;\n node.parentElement = this instanceof Element ? this : null;\n if (child) {\n const idx = this.childNodes.indexOf(child);\n this.childNodes.splice(idx, 0, node);\n } else {\n this.childNodes.push(node);\n }\n }\n return node;\n }\n\n replaceChild<T extends Node>(node: Node, child: T): T {\n if (node && child && child.parentNode === this) {\n this.insertBefore(node, child);\n child.parentNode && child.parentNode.removeChild(child);\n }\n return child;\n }\n removeChild<T extends Node>(child: T): T {\n if (child && child.parentNode === this) {\n const idx = (this.childNodes as unknown as Node[]).indexOf(child);\n (this.childNodes as unknown as Node[]).splice(idx, 1);\n child.parentNode = null;\n child.parentElement = null;\n }\n return child;\n }\n\n remove(): Node {\n return this.parentNode ? this.parentNode.removeChild(this) : this;\n }\n\n cloneNode(deep?: boolean | undefined): Node {\n if (this.nodeType === 3) {\n return new Text(this.nodeValue);\n }\n\n if (this.nodeType === 1) {\n const node = new Element();\n node.nodeType = this.nodeType;\n this.nodeName = this.nodeName;\n if (this.attributes) {\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n node.setAttribute(this.attributes[i].nodeName, this.attributes[i].nodeValue);\n }\n }\n\n for (const key in this.dataset) {\n node.dataset[key] = this.dataset[key];\n }\n\n if (deep) {\n for (let i = 0, l = this.childNodes.length; i < l; i++) {\n node.appendChild(this.childNodes[i].cloneNode(deep));\n }\n }\n return node;\n }\n\n const node = new Node();\n node.nodeType = this.nodeType;\n node.nodeName = this.nodeName;\n return node;\n }\n\n setAttribute(name: string, value: any) {\n const attr = {\n nodeName: name,\n nodeValue: value\n };\n let idx = -1;\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n if (this.attributes[i].nodeName === name) {\n idx = i;\n break;\n }\n }\n idx === -1 ? this.attributes.push(attr as Attr) : this.attributes.splice(idx, 1, attr as Attr);\n }\n\n getAttribute(name: string) {\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n if (this.attributes[i].nodeName === name) {\n return this.attributes[i].nodeValue;\n }\n }\n }\n\n removeAttribute(name: string) {\n let idx = -1;\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n if (this.attributes[i].nodeName === name) {\n idx = i;\n break;\n }\n }\n if (idx > -1) {\n this.attributes.splice(idx, 1);\n }\n }\n\n getElementById(id: string): Node | null {\n let elementFound;\n for (let i = 0, l = this.childNodes.length; i < l; i++) {\n if (this.childNodes[i].nodeType === 1) {\n if (this.childNodes[i].getAttribute(\"id\") === id) {\n elementFound = this.childNodes[i];\n break;\n }\n elementFound = this.childNodes[i].getElementById(id);\n if (elementFound) {\n break;\n }\n }\n }\n return elementFound || null;\n }\n\n // Not implemented\n // firstChild!: ChildNode | null;\n // isConnected!: boolean;\n // lastChild!: ChildNode | null;\n // nextSibling!: ChildNode | null;\n // ownerDocument!: Document | null;\n // parentElement!: HTMLElement | null;\n // previousSibling!: ChildNode | null;\n // compareDocumentPosition(other: Node): number {\n // throw new Error(\"Method not implemented.\");\n // }\n // contains(other: Node | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // getRootNode(options?: GetRootNodeOptions | undefined): Node {\n // throw new Error(\"Method not implemented.\");\n // }\n // hasChildNodes(): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // isDefaultNamespace(namespace: string | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // isEqualNode(otherNode: Node | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // isSameNode(otherNode: Node | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // lookupNamespaceURI(prefix: string | null): string | null {\n // throw new Error(\"Method not implemented.\");\n // }\n // lookupPrefix(namespace: string | null): string | null {\n // throw new Error(\"Method not implemented.\");\n // }\n // normalize(): void {\n // throw new Error(\"Method not implemented.\");\n // }\n // ATTRIBUTE_NODE!: number;\n // CDATA_SECTION_NODE!: number;\n // COMMENT_NODE!: number;\n // DOCUMENT_FRAGMENT_NODE!: number;\n // DOCUMENT_NODE!: number;\n // DOCUMENT_POSITION_CONTAINED_BY!: number;\n // DOCUMENT_POSITION_CONTAINS!: number;\n // DOCUMENT_POSITION_DISCONNECTED!: number;\n // DOCUMENT_POSITION_FOLLOWING!: number;\n // DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC!: number;\n // DOCUMENT_POSITION_PRECEDING!: number;\n // DOCUMENT_TYPE_NODE!: number;\n // ELEMENT_NODE!: number;\n // ENTITY_NODE!: number;\n // ENTITY_REFERENCE_NODE!: number;\n // NOTATION_NODE!: number;\n // PROCESSING_INSTRUCTION_NODE!: number;\n // TEXT_NODE!: number;\n addEventListener(\n // eslint-disable-next-line no-unused-vars\n type: string,\n // eslint-disable-next-line no-unused-vars\n callback: EventListenerOrEventListenerObject | null,\n // eslint-disable-next-line no-unused-vars\n options?: boolean | AddEventListenerOptions | undefined\n ): void {\n // throw new Error(\"Method not implemented.\");\n }\n // dispatchEvent(event: Event): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n removeEventListener(\n // eslint-disable-next-line no-unused-vars\n type: string,\n // eslint-disable-next-line no-unused-vars\n callback: EventListenerOrEventListenerObject | null,\n // eslint-disable-next-line no-unused-vars\n options?: boolean | EventListenerOptions | undefined\n ): void {\n // throw new Error(\"Method not implemented.\");\n }\n}\n\nexport class Text extends Node {\n constructor(text: any) {\n super();\n this.nodeType = 3;\n this.nodeName = \"#text\";\n this.node_value = String(text);\n }\n}\n\nfunction updateElementStyles(element: Element, state: Record<string, any>) {\n let str = \"\";\n for (const key in state) {\n const value = state[key];\n if (typeof value !== \"undefined\" && value !== null && String(value).length > 0) {\n str += `${key}: ${state[key]};`;\n }\n }\n if (str.length === 0) {\n element.removeAttribute(\"style\");\n } else {\n element.setAttribute(\"style\", str);\n }\n}\n\nexport class Element extends Node {\n constructor() {\n super();\n this.nodeType = 1;\n this.attributes = [];\n this.childNodes = [];\n }\n\n _style = new Proxy(\n {},\n {\n get: (state: Record<string, any>, prop: string) => state[prop],\n set: (state: Record<string, any>, prop: string, value: any) => {\n state[prop] = value;\n updateElementStyles(this, state);\n return true;\n },\n deleteProperty: (state: Record<string, any>, prop: string) => {\n Reflect.deleteProperty(state, prop);\n updateElementStyles(this, state);\n return true;\n }\n }\n );\n\n get style() {\n return this._style as any;\n }\n\n set style(value: string) {\n if (typeof value === \"string\") {\n // should match pairs like \"color: red; font-size: 12px; background: url(http://example.com/image.png?s=1024x1024&amp;w=is&amp;k=20&amp;c=ASa_AG8uP5Di7azXgJraSA6ME7fbLB0GX4YT_OzCARI=);\"\n const regex = /([^:\\s]+):\\s*((url\\([^)]+\\))|[^;]+(?=(;|$)))/g;\n let match;\n\n while ((match = regex.exec(value)) !== null) {\n this._style[match[1]] = match[2].trim();\n }\n\n return;\n }\n\n throw new Error(\"Cannot set style\");\n }\n\n get className(): string {\n return this.getAttribute(\"class\") || \"\";\n }\n\n set className(value: string | boolean) {\n if (value == null || value === false) {\n this.removeAttribute(\"class\");\n } else {\n this.setAttribute(\"class\", String(value));\n }\n }\n\n classList = {\n toggle: (item: any, force: any) => {\n if (item) {\n const classes = (this.className || \"\").split(\" \");\n const itemIndex = classes.indexOf(item);\n if (force && itemIndex === -1) {\n classes.push(item);\n }\n\n if (!force && itemIndex !== -1) {\n classes.splice(itemIndex, 1);\n }\n\n const final = classes.join(\" \").trim();\n if (final.length) {\n this.className = classes.join(\" \").trim();\n } else {\n this.className = false;\n }\n }\n }\n };\n\n get id(): string {\n return this.getAttribute(\"id\") || \"\";\n }\n\n set id(value: string | boolean) {\n if (value == null || value === false) {\n this.removeAttribute(\"id\");\n } else {\n this.setAttribute(\"id\", String(value));\n }\n }\n\n set textContent(text) {\n this.nodeValue = String(text);\n this.childNodes = this.nodeValue ? [new Text(this.nodeValue)] : [];\n }\n get textContent() {\n return this.nodeValue;\n }\n\n set innerText(text) {\n this.nodeValue = String(text);\n }\n\n get innerText() {\n return this.nodeValue;\n }\n\n get innerHTML() {\n let str = \"\";\n for (let i = 0, l = this.childNodes.length; i < l; i++) {\n // console.log(\"domToHtml\", this.childNodes[i], domToHtml(this.childNodes[i] as Element));\n str += domToHtml(this.childNodes[i] as Element);\n }\n return str;\n }\n\n set innerHTML(html) {\n this.textContent = \"\";\n const result = htmlToDom(html);\n if (result instanceof DocumentFragment) {\n for (let i = 0, l = result.childNodes.length; i < l; i++) {\n this.appendChild(result.childNodes[i]);\n }\n } else {\n this.appendChild(result);\n }\n }\n\n get outerHTML(): string {\n return domToHtml(this);\n }\n}\n\nexport class DocumentFragment extends Element {\n constructor() {\n super();\n this.nodeType = 11;\n this.nodeName = \"#document-fragment\";\n }\n}\n\nexport class Document extends Element {\n constructor() {\n super();\n this.nodeType = 9;\n this.nodeName = \"#document\";\n this.body = this.createElement(\"body\");\n }\n\n body: Element;\n\n createDocumentFragment(): DocumentFragment {\n return new DocumentFragment();\n }\n\n createElement(type: string) {\n const element = new Element();\n element.nodeName = type.toUpperCase();\n return element;\n }\n\n createElementNS(ns: string, type: string) {\n const element = this.createElement(type);\n element.baseURI = ns;\n return element;\n }\n\n createTextNode(text: any) {\n return new Text(text);\n }\n}\n\nconst selfClosingTags = [\n \"area\",\n \"base\",\n \"br\",\n \"col\",\n \"embed\",\n \"hr\",\n \"img\",\n \"input\",\n \"link\",\n \"meta\",\n \"param\",\n \"source\",\n \"track\",\n \"wbr\",\n \"!doctype\"\n];\n\nexport function domToHtml(dom: Element | Text | DocumentFragment): string {\n if (dom.nodeType === 3) {\n return dom.textContent;\n }\n\n if (dom.nodeType === 1) {\n const name = dom.nodeName.toLowerCase();\n let str = \"<\" + name;\n for (let i = 0, l = dom.attributes.length; i < l; i++) {\n str += \" \" + dom.attributes[i].nodeName + '=\"' + dom.attributes[i].nodeValue + '\"';\n }\n\n if (selfClosingTags.indexOf(name) === -1) {\n str += \">\";\n if (dom.childNodes && dom.childNodes.length > 0) {\n for (let i = 0, l = dom.childNodes.length; i < l; i++) {\n const child = domToHtml(dom.childNodes[i] as Element);\n if (child) {\n str += child;\n }\n }\n }\n str += \"</\" + name + \">\";\n } else {\n str += \"/>\";\n }\n\n return str;\n }\n\n return \"\";\n}\n\nexport function domToHyperscript(childNodes: ChildNodes, depth = 1) {\n let spaces = \"\";\n for (let i = 0; i < depth; i++) {\n spaces += \" \";\n }\n\n return childNodes\n .map((item) => {\n if (item.nodeType === 10) {\n return `\\n${spaces}\"<!DOCTYPE html>\"`;\n } else if (item.nodeType === 3) {\n return `\\n${spaces}\"${item.nodeValue}\"`;\n } else {\n let str = `\\n${spaces}v(\"${item.nodeName}\", `;\n\n if (item.attributes) {\n const attrs: Record<string, any> = {};\n for (let i = 0, l = item.attributes.length; i < l; i++) {\n const attr = item.attributes[i];\n attrs[attr.nodeName] = attr.nodeValue;\n }\n str += JSON.stringify(attrs);\n } else {\n str += \"{}\";\n }\n\n str += \", [\";\n if (item.childNodes && item.childNodes.length > 0) {\n str += `${domToHyperscript(item.childNodes as unknown as Element[], depth + 1)}\\n${spaces}`;\n }\n\n str += `])`;\n return str;\n }\n })\n .join(\",\");\n}\n\ninterface ObjectIndexItem {\n tagName: string;\n startsAt: number;\n endsAt: number | null;\n contentStartsAt: number;\n contentEndsAt: number | null;\n attributes: { [key: string]: any };\n children: ObjectIndexItem[];\n nodeValue: string | null;\n}\n\ninterface ObjectIndexItemWithContent extends ObjectIndexItem {\n endsAt: number;\n contentEndsAt: number;\n children: ObjectIndexItemWithContent[];\n}\n\ninterface ObjectIndexList extends Array<ObjectIndexItem> {}\n\nfunction findTexts(item: ObjectIndexItemWithContent, html: string) {\n const newChildren: ObjectIndexItemWithContent[] = [];\n\n // If the item has children\n if (item.children.length) {\n // Search for texts in the children.\n for (let i = 0; i < item.children.length; i++) {\n const child = item.children[i];\n const nextChild = item.children[i + 1];\n\n // If is the first child and the child startsAt is greater than the item contentStartsAt then\n // the content between the item contentStartsAt and the child startsAt is a text child of the item.\n if (i === 0 && child.startsAt > item.contentStartsAt) {\n const childContent = html.substring(item.contentStartsAt, child.startsAt);\n\n const childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: item.contentStartsAt,\n endsAt: item.contentStartsAt + childContent.length,\n contentStartsAt: item.contentStartsAt,\n contentEndsAt: item.contentStartsAt + childContent.length,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n\n // Add the child to the newChildren array.\n newChildren.push(child);\n\n // If there is a next child and the child endsAt is less than the next child startsAt then\n // the content between the child endsAt and the next child startsAt is a text child of the item.\n if (nextChild && child.endsAt < nextChild.startsAt) {\n const childContent = html.substring(child.endsAt, nextChild.startsAt);\n\n const childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: child.endsAt,\n endsAt: child.endsAt + childContent.length,\n contentStartsAt: child.endsAt,\n contentEndsAt: child.endsAt + childContent.length,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n\n // If there are no next child and the child endsAt is less than the item contentEndsAt then\n // the content between the child endsAt and the item contentEndsAt is a text child of the item.\n if (!nextChild && child.endsAt < item.contentEndsAt) {\n const childContent = html.substring(child.endsAt, item.contentEndsAt);\n\n const childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: child.endsAt,\n endsAt: child.endsAt + childContent.length,\n contentStartsAt: child.endsAt,\n contentEndsAt: item.contentEndsAt,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n\n // Find texts in the child.\n findTexts(child, html);\n }\n }\n\n // If the item has no children then set the contents between the item contentStartsAt and the item contentEndsAt\n // as a text child of the item.\n if (!item.children.length) {\n const childContent = html.substring(item.contentStartsAt, item.contentEndsAt);\n\n if (childContent.length) {\n const childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: item.contentStartsAt,\n endsAt: item.contentEndsAt,\n contentStartsAt: item.contentStartsAt,\n contentEndsAt: item.contentEndsAt,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n }\n\n item.children = newChildren;\n}\n\nfunction convertToDom<T extends Node>(item: ObjectIndexItemWithContent): T {\n let node: T;\n\n if (item.tagName === \"#text\") {\n node = document.createTextNode(item.nodeValue as string) as unknown as T;\n } else {\n node = (item.tagName === \"#document-fragment\"\n ? document.createDocumentFragment()\n : document.createElement(item.tagName)) as unknown as T;\n\n for (const key in item.attributes) {\n node.setAttribute(key, item.attributes[key]);\n }\n\n for (let i = 0; i < item.children.length; i++) {\n const child = convertToDom(item.children[i]);\n node.appendChild(child);\n }\n }\n\n return node;\n}\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nfunction getObjectIndexTree(html: string): DocumentFragment {\n let item;\n const regex = RegExp(\"<([^>|^!]+)>\", \"g\");\n const items: ObjectIndexList = [];\n\n // Make the initial list of items.\n while ((item = regex.exec(html))) {\n // If is a closing tag\n if (item[0].startsWith(\"</\")) {\n const lastOpenedItem = [...items].reverse().find((item) => item.endsAt === null);\n if (lastOpenedItem) {\n lastOpenedItem.endsAt = item.index + item[0].length;\n lastOpenedItem.contentEndsAt = item.index;\n\n // Find the last opened item again, this will be the parent of the current item.\n const parent = [...items].reverse().find((item) => item.endsAt === null);\n if (parent) {\n // Find the index of the current item in the items array.\n const index = items.indexOf(lastOpenedItem);\n // Remove the last opened item from the items array.\n items.splice(index, 1);\n\n // Add the last opened item as a child of the parent.\n parent.children.push(lastOpenedItem);\n }\n }\n\n continue;\n }\n\n // If is an opening tag\n const element: ObjectIndexItem = {\n tagName: item[1].split(\" \")[0],\n startsAt: item.index,\n endsAt: null,\n contentStartsAt: item.index + item[0].length,\n contentEndsAt: null,\n attributes: {},\n children: [],\n nodeValue: null\n };\n\n // Find the attributes of the tag.\n let string = (item[1] || \"\").substring(element.tagName.length + 1).replace(/\\/$/g, \"\");\n const attributesWithValues = string.match(/\\S+=\"[^\"]+\"/g);\n\n if (attributesWithValues) {\n for (const attribute of attributesWithValues) {\n const [name, ...value] = attribute.trim().split(\"=\");\n string = string.replace(attribute, \"\");\n if (value) {\n element.attributes[name] = value.join(\"=\").replace(/(^\"|\"$)/g, \"\");\n }\n }\n }\n\n const attributesWithBooleanValues = string.match(/\\s\\S+=[^\"]+/g);\n if (attributesWithBooleanValues) {\n for (const attribute of attributesWithBooleanValues) {\n const [name, ...value] = attribute.trim().split(\"=\");\n string = string.replace(attribute, \"\");\n if (value) {\n element.attributes[name] = value.join(\"=\").replace(/(^\"|\"$)/g, \"\");\n }\n }\n }\n\n const attributesWithEmptyValues = string.match(/\\s?\\S+/g);\n if (attributesWithEmptyValues) {\n for (const attribute of attributesWithEmptyValues) {\n const name = attribute.trim();\n element.attributes[name] = true;\n }\n }\n\n // If the tag is self closing\n if (item[0].endsWith(\"/>\")) {\n element.endsAt = element.startsAt + item[0].length;\n element.contentStartsAt = element.contentEndsAt = element.endsAt;\n\n // Find the last opened item, this will be the parent of the current item.\n const parent = [...items].reverse().find((item) => item.endsAt === null);\n if (parent) {\n // Add the last opened item as a child of the parent.\n parent.children.push(element);\n continue;\n }\n }\n\n items.push(element);\n }\n\n const fragmentItem: ObjectIndexItemWithContent = {\n tagName: \"#document-fragment\",\n startsAt: 0,\n endsAt: html.length,\n contentStartsAt: 0,\n contentEndsAt: html.length,\n attributes: {},\n children: items as ObjectIndexItemWithContent[],\n nodeValue: null\n };\n\n findTexts(fragmentItem, html);\n\n return convertToDom<DocumentFragment>(fragmentItem);\n}\n\n// First we create a tree of object indexes from the HTML string.\n// The resulting array is then reordered to match the order of the html string.\n// And to move the children to the correct position in its parents.\n// This resulting array is populated with a object node version of the object index.\n// If the final result have more than 1 node, then return a document fragment node.\n// If the final result have 1 node, then return the node.\n// eslint-disable-next-line complexity\nexport function htmlToDom(html: string): Element | Text | DocumentFragment {\n // Search for the opening and closing tags of the root element.\n // The opening tag could be in the middle of the string, so we need to\n // search for the first opening tag.\n const openingTag = html.match(/<[^>]+>/g);\n\n const document = new Document();\n\n // If the opening tag is not found, return a document fragment node with the html string as text content.\n if (!openingTag) {\n const documentFragment = document.createDocumentFragment();\n documentFragment.appendChild(document.createTextNode(html));\n return documentFragment;\n }\n\n const fragment = getObjectIndexTree(html);\n\n if (fragment.childNodes.length > 1) {\n return fragment;\n }\n\n return fragment.childNodes[0];\n}\n\nexport function htmlToHyperscript(html: string) {\n const domTree = htmlToDom(html);\n const hyperscript = domToHyperscript(domTree instanceof DocumentFragment ? domTree.childNodes : [domTree]);\n return `[${hyperscript}\\n]`;\n}\n\nexport const document = new Document();\n\nconst html = document.createElement(\"html\");\nhtml.appendChild(document.createElement(\"head\"));\nhtml.appendChild(document.body);\n", "import fs from \"fs\";\nimport { htmlToHyperscript } from \"./tree-adapter\";\n\nexport interface IconsOptions {\n iconsPath: string | null;\n linksViewPath: string | null;\n logging: boolean;\n\n // favicons options\n path: string;\n appName?: string;\n appDescription?: string;\n developerName?: string;\n developerURL?: string;\n dir?: \"auto\" | \"ltr\" | \"rtl\" | string;\n lang?: string;\n background?: string;\n theme_color?: string;\n display?: \"browser\" | \"standalone\" | string;\n orientation?: \"any\" | \"portrait\" | \"landscape\" | string;\n start_url?: string;\n version?: string;\n icons: {\n android: boolean;\n appleIcon: boolean;\n appleStartup: boolean;\n coast: boolean;\n favicons: boolean;\n firefox: boolean;\n windows: boolean;\n yandex: boolean;\n };\n}\n\nexport async function icons(source: string, configuration?: IconsOptions) {\n const options = {\n ...icons.options,\n ...(configuration || {})\n };\n\n if (options.iconsPath) {\n options.iconsPath = options.iconsPath.replace(/\\/$/gi, \"\") + \"/\";\n }\n\n if (options.linksViewPath) {\n options.linksViewPath = options.linksViewPath.replace(/\\/$/gi, \"\") + \"/\";\n }\n\n const { favicons } = await import(\"favicons\");\n\n try {\n const response = await favicons(source, options);\n\n if (options.iconsPath) {\n for (const i in response.images) {\n fs.writeFileSync(options.iconsPath + response.images[i].name, response.images[i].contents);\n }\n\n for (const i in response.files) {\n fs.writeFileSync(options.iconsPath + response.files[i].name, response.files[i].contents);\n }\n }\n\n if (options.linksViewPath) {\n const html = `\n function Links(){\n return ${htmlToHyperscript(response.html.join(\"\"))};\n }\n \n Links.default = Links;\n module.exports = Links;\n `;\n\n fs.writeFileSync(`${options.linksViewPath}/links.js`, html);\n }\n } catch (err) {\n process.stdout.write((err as any).status + \"\\n\"); // HTTP error code (e.g. `200`) or `null`\n process.stdout.write((err as any).name + \"\\n\"); // Error name e.g. \"API Error\"\n process.stdout.write((err as any).message + \"\\n\"); // Error description e.g. \"An unknown error has occurred\"\n }\n}\n\nicons.options = {\n iconsPath: null,\n linksViewPath: null,\n\n // favicons options\n path: \"\",\n appName: null,\n appDescription: null,\n developerName: null,\n developerURL: null,\n dir: \"auto\",\n lang: \"en-US\",\n background: \"#fff\",\n theme_color: \"#fff\",\n display: \"standalone\",\n orientation: \"any\",\n start_url: \"/\",\n version: \"1.0\",\n logging: false,\n icons: {\n android: true,\n appleIcon: true,\n appleStartup: true,\n coast: false,\n favicons: true,\n firefox: false,\n windows: true,\n yandex: false // Create Yandex browser icon. `boolean`\n }\n} as unknown as IconsOptions;\n", "import * as tsc from \"tsc-prog\";\n\nimport CleanCSS from \"clean-css\";\nimport { PurgeCSS } from \"purgecss\";\nimport esbuild from \"esbuild\";\n/* eslint-disable sonarjs/cognitive-complexity */\nimport fs from \"fs\";\n\n// eslint-disable-next-line complexity\nexport async function inline(\n file: string | { raw: string; map?: string | null; file: string },\n options: Record<string, any> = {}\n) {\n if (typeof file === \"string\") {\n const ext = file.split(\".\").pop();\n if (ext && /(js|cjs|jsx|mjs|ts|tsx)/.test(ext)) {\n if (/(ts|tsx)/.test(ext) && !options.noValidate) {\n const declarationDir = options.declarationDir;\n const emitDeclaration = !!declarationDir;\n\n const tscProgOptions = {\n basePath: process.cwd(), // always required, used for relative paths\n configFilePath: \"tsconfig.json\", // config to inherit from (optional)\n files: [file],\n include: [\"**/*.ts\", \"**/*.js\", \"**/*.tsx\", \"**/*.jsx\", \"**/*.mjs\"],\n exclude: [\"test*/**/*\", \"**/*.test.ts\", \"**/*.spec.ts\", \"dist/**\"],\n pretty: true,\n copyOtherToOutDir: false,\n clean: emitDeclaration ? [declarationDir] : [],\n ...(options.tsc || {}),\n compilerOptions: {\n rootDir: \"./\",\n outDir: \"dist\",\n noEmitOnError: true,\n noEmit: !emitDeclaration,\n declaration: emitDeclaration,\n declarationDir,\n emitDeclarationOnly: emitDeclaration,\n allowJs: true,\n esModuleInterop: true,\n inlineSourceMap: true,\n resolveJsonModule: true,\n removeComments: true,\n ...(options.tsc || {}).compilerOptions\n },\n jsxFactory: \"v\",\n jsxFragment: \"v.fragment\"\n };\n\n // eslint-disable-next-line no-console\n console.log(\"tsc\", tscProgOptions);\n\n tsc.build(tscProgOptions);\n }\n\n const esbuildOptions = {\n entryPoints: [file],\n bundle: \"bundle\" in options ? options.bundle : true,\n sourcemap: \"external\",\n write: false,\n minify: options.compact,\n outdir: \"out\",\n target: \"esnext\",\n jsxFactory: \"v\",\n jsxFragment: \"v.fragment\",\n loader: {\n \".js\": \"jsx\",\n \".cjs\": \"jsx\",\n \".mjs\": \"jsx\",\n \".ts\": \"tsx\"\n },\n ...(options.esbuild || {})\n };\n\n const result = await esbuild.build(esbuildOptions);\n if (result.outputFiles?.length !== 2) {\n throw new Error(result.errors.join(\"\\n\"));\n }\n\n if (options.compact) {\n const terser = await import(\"terser\");\n const result2 = await terser.minify(result.outputFiles[1].text, {\n sourceMap: {\n content: result.outputFiles[0].text.toString()\n },\n compress: {\n booleans_as_integers: false\n },\n output: {\n wrap_func_args: false\n },\n ecma: 2022,\n ...(options.terser || {})\n });\n\n if (!result2.code || !result2.map) {\n throw new Error(\"Unknown error\");\n }\n\n const mapBase64 = Buffer.from(result2.map.toString()).toString(\"base64\");\n const suffix = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${mapBase64}`;\n return { raw: result2.code, map: suffix, file };\n } else {\n const mapBase64 = Buffer.from(result.outputFiles[0].text.toString()).toString(\"base64\");\n const suffix = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${mapBase64}`;\n return { raw: result.outputFiles[1].text, map: suffix, file };\n }\n } else if (ext && /(css|scss|styl)/.test(ext)) {\n const result = await new CleanCSS({\n sourceMap: true,\n level: {\n 1: {\n roundingPrecision: \"all=3\"\n },\n 2: {\n restructureRules: true // controls rule restructuring; defaults to false\n }\n },\n ...(options.cleanCss || {})\n }).minify([file]);\n\n return { raw: result.styles, map: null, file };\n } else {\n return { raw: fs.readFileSync(file, \"utf8\"), map: null, file };\n }\n } else if (typeof file === \"object\" && \"raw\" in file) {\n return { map: null, ...file };\n }\n\n throw new Error(`Unknown file type: ${file}`);\n}\n\ninline.uncss = async function (\n renderedHtml: (string | Promise<string>)[],\n css: string,\n options: Record<string, any> = {}\n) {\n const html = await Promise.all(renderedHtml);\n\n const contents = html.map((item) => {\n return {\n raw: item,\n extension: \"html\"\n };\n });\n\n const purgecss = new PurgeCSS();\n\n const output = await purgecss.purge({\n fontFace: true,\n keyframes: true,\n variables: true,\n defaultExtractor: (content) => content.match(/[A-Za-z0-9-_/:@]*[A-Za-z0-9-_/:@/]+/g) || [],\n ...options,\n content: contents,\n css: [{ raw: css }]\n });\n\n const cleanCss = await new CleanCSS({\n sourceMap: false,\n level: {\n 1: {\n roundingPrecision: \"all=3\"\n },\n 2: {\n restructureRules: true // controls rule restructuring; defaults to false\n }\n },\n ...(options.cleanCss || {})\n }).minify(output[0].css);\n\n return cleanCss.styles;\n};\n", "import fs from \"fs\";\nimport path from \"path\";\n\nexport function sw(file: string, options = {}) {\n const swfiletemplate = path.resolve(__dirname, \"./node.sw.js\");\n const swTpl = fs.readFileSync(swfiletemplate, \"utf8\");\n const opt = {\n version: \"1\",\n name: \"Valyrian.js\",\n urls: [\"/\"],\n debug: false,\n logFetch: false,\n offlinePage: \"/offline.html\",\n ...options\n };\n let contents = swTpl\n .replace(\"v1\", `v${opt.version}`)\n .replace(\"Valyrian.js\", opt.name)\n .replace('[\"/\"]', '[\"' + opt.urls.join('\",\"') + '\"]')\n .replace(\"/offline.html\", opt.offlinePage)\n .replace(\"logFetch: false\", opt.logFetch ? \"logFetch: true\" : \"logFetch: false\");\n\n if (!opt.debug) {\n contents = contents.replace(\"console.log\", \"() => {}\");\n }\n\n fs.writeFileSync(file, contents, \"utf8\");\n}\n\n/*\n // On the server side to generate the service worker\n sw(\"sw.js\", {\n version: \"1\",\n name: \"Valyrian.js\",\n urls: [\"/\"],\n debug: false,\n logFetch: false,\n offlinePage: \"/offline.html\"\n });\n\n\n // On the client side\n if (\"serviceWorker\" in navigator) {\n const registration = await navigator.serviceWorker.register(\"/sw.js\");\n registration.addEventListener(\"updatefound\", () => {\n const newWorker = registration.installing as ServiceWorker;\n newWorker.addEventListener(\"statechange\", () => {\n if (newWorker.state === \"installed\") {\n // Notify the user about the new version and ask if they want to update\n if (confirm(\"There is a new version available. Do you want to update?\")) {\n // Send a message to the service worker to skip the waiting\n navigator.serviceWorker.controller.postMessage({ type: \"SKIP_WAITING\" });\n }\n }\n });\n });\n\n navigator.serviceWorker.addEventListener(\"controllerchange\", () => {\n window.location.reload();\n });\n }\n*/\n", "import fs from \"fs\";\nimport path from \"path\";\n\nexport class SessionStorage {\n private storage: { [key: string]: string };\n private limit: number;\n private persist: boolean;\n private filePath: string;\n private directory: string = \".session-storage\";\n\n constructor({ persist = false, filePath = \"./sessionData.json\" }: { persist?: boolean; filePath?: string } = {}) {\n this.storage = {};\n this.limit = 5 * 1024 * 1024; // 5MB storage limit\n this.persist = persist;\n this.filePath = path.resolve(this.directory, filePath);\n\n if (this.persist) {\n if (!fs.existsSync(this.directory)) {\n fs.mkdirSync(this.directory, { recursive: true });\n }\n\n // Load data from file if persistence is enabled\n this.loadFromFile();\n }\n }\n\n // Calculate total size in bytes of stored data\n private getStorageSize(): number {\n return new TextEncoder().encode(JSON.stringify(this.storage)).length;\n }\n\n // Check if storage limit is exceeded\n private checkSizeLimit(): void {\n const size = this.getStorageSize();\n if (size > this.limit) {\n throw new DOMException(\"Storage limit exceeded\", \"QuotaExceededError\");\n }\n }\n\n // Store value under the specified key\n setItem(key: string | null | undefined, value: string | null | undefined): void {\n if (key === null || key === undefined) {\n throw new TypeError(\"Failed to execute 'setItem' on 'Storage': 1 argument required, but only 0 present.\");\n }\n\n if (value === null) {\n value = \"null\"; // Convert null to \"null\"\n } else if (value === undefined) {\n value = \"undefined\"; // Convert undefined to \"undefined\"\n }\n\n this.loadFromFile();\n this.storage[key] = String(value); // Store as string\n this.checkSizeLimit(); // Check storage limit\n this.saveToFile(); // Save to file if persistence is enabled\n }\n\n // Retrieve value stored under the specified key\n getItem(key: string | null | undefined): string | null {\n if (key === null || key === undefined) {\n throw new TypeError(\"Failed to execute 'getItem' on 'Storage': 1 argument required, but only 0 present.\");\n }\n\n this.loadFromFile();\n return this.storage[key] || null; // Return null if key doesn't exist\n }\n\n // Remove the value under the specified key\n removeItem(key: string | null | undefined): void {\n if (key === null || key === undefined) {\n throw new TypeError(\"Failed to execute 'removeItem' on 'Storage': 1 argument required, but only 0 present.\");\n }\n this.loadFromFile();\n Reflect.deleteProperty(this.storage, key); // Remove key from storage\n this.saveToFile(); // Save to file if persistence is enabled\n }\n\n // Clear all stored values\n clear(): void {\n this.storage = {};\n this.saveToFile(); // Save to file if persistence is enabled\n }\n\n // Return the number of stored items\n get length(): number {\n return Object.keys(this.storage).length;\n }\n\n // Return the key at the specified index\n key(index: number): string | null {\n this.loadFromFile();\n const keys = Object.keys(this.storage);\n return keys[index] || null;\n }\n\n // Save data to a file (only if persistence is enabled)\n private saveToFile(): void {\n if (this.persist) {\n try {\n fs.writeFileSync(this.filePath, JSON.stringify(this.storage), \"utf-8\");\n } catch (error) {\n throw new Error(`Error saving data to file: ${(error as any).message}`);\n }\n }\n }\n\n // Load data from a file (only if persistence is enabled)\n private loadFromFile(): void {\n if (this.persist) {\n try {\n if (fs.existsSync(this.filePath)) {\n const data = fs.readFileSync(this.filePath, \"utf-8\");\n this.storage = JSON.parse(data || \"{}\");\n }\n } catch (error) {\n throw new Error(`Error loading data from file: ${(error as any).message}`);\n }\n }\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,IAAM,OAAN,MAAM,MAAqB;AAAA;AAAA,EAEhC,aAAyB,CAAC;AAAA,EAC1B,UAAkB;AAAA,EAElB;AAAA,EACA,IAAI,WAAmB;AACrB,WAAO,KAAK,SAA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AAM;AACxB,QAAM,aAAS,uBAAM,OAAO,SAAS;AACrC,+BAAQ;AACR,SAAO;AACT;",
6
- "names": ["node", "html", "item", "document", "fs", "html", "import_fs", "esbuild", "CleanCSS", "fs", "html", "import_fs", "path", "fs", "import_fs", "import_path", "path", "fs", "FormData"]
3
+ "sources": ["../../lib/node/index.ts", "../../lib/node/utils/tree-adapter.ts", "../../lib/node/utils/icons.ts", "../../lib/node/utils/inline.ts", "../../lib/node/utils/sw.ts", "../../lib/node/utils/server-storage.ts"],
4
+ "sourcesContent": ["import { document, domToHtml, domToHyperscript, htmlToDom, htmlToHyperscript } from \"./utils/tree-adapter\";\nimport { mount, unmount } from \"valyrian.js\";\n\nimport FormData from \"form-data\";\nimport { icons } from \"./utils/icons\";\nimport { inline } from \"./utils/inline\";\nimport { sw } from \"./utils/sw\";\nimport { ServerStorage } from \"./utils/server-storage\";\n\nglobal.FormData = FormData as any;\nglobal.document = document as any;\nglobal.sessionStorage = new ServerStorage();\nglobal.localStorage = new ServerStorage();\n\nfunction render(...args: any[]) {\n const Component = () => args;\n const result = mount(\"div\", Component);\n unmount();\n return result;\n}\n\nexport { domToHtml, domToHyperscript, htmlToDom, htmlToHyperscript, inline, sw, icons, render, ServerStorage };\n", "/* eslint-disable no-use-before-define */\n/* eslint-disable complexity */\ninterface ChildNodes extends Array<Node | Element | Text | DocumentFragment> {}\n\nexport class Node implements Node {\n // eslint-disable-next-line no-use-before-define\n childNodes: ChildNodes = [];\n baseURI: string = \"\";\n\n tag_name!: string;\n get nodeName(): string {\n return this.tag_name.toLowerCase();\n }\n set nodeName(name: string) {\n this.tag_name = name;\n }\n get tagName(): string {\n return this.tag_name;\n }\n set tagName(name: string) {\n this.tag_name = name;\n }\n\n node_type!: number;\n get nodeType(): number {\n return this.node_type;\n }\n set nodeType(type: number) {\n this.node_type = type;\n }\n\n node_value = \"\";\n attributes: Attr[] = [];\n set textContent(text) {\n this.node_value = String(text);\n }\n get textContent() {\n return this.node_value;\n }\n set nodeValue(text) {\n this.node_value = String(text);\n }\n get nodeValue() {\n return this.node_value;\n }\n\n // eslint-disable-next-line no-use-before-define\n parent_node: Node | null = null;\n get parentNode() {\n return this.parent_node;\n }\n set parentNode(node) {\n this.parent_node = node;\n }\n\n get parentElement(): Element | null {\n return this.parentNode instanceof Element ? this.parentNode : null;\n }\n\n set parentElement(node) {\n this.parentNode = node;\n }\n\n #dataset: Record<string | number, any> = {};\n\n get dataset() {\n return this.#dataset;\n }\n\n set dataset(value) {\n this.#dataset = value;\n }\n\n constructor() {}\n\n appendChild<T extends Node>(node: T): T {\n if (node) {\n node.parentNode && node.parentNode.removeChild(node as Node);\n this.childNodes.push(node);\n node.parentNode = this;\n node.parentElement = this instanceof Element ? this : null;\n }\n return node;\n }\n\n insertBefore<T extends Node>(node: T, child: Node | null): T {\n if (node) {\n node.parentNode && node.parentNode.removeChild(node as Node);\n node.parentNode = this;\n node.parentElement = this instanceof Element ? this : null;\n if (child) {\n const idx = this.childNodes.indexOf(child);\n this.childNodes.splice(idx, 0, node);\n } else {\n this.childNodes.push(node);\n }\n }\n return node;\n }\n\n replaceChild<T extends Node>(node: Node, child: T): T {\n if (node && child && child.parentNode === this) {\n this.insertBefore(node, child);\n child.parentNode && child.parentNode.removeChild(child);\n }\n return child;\n }\n removeChild<T extends Node>(child: T): T {\n if (child && child.parentNode === this) {\n const idx = (this.childNodes as unknown as Node[]).indexOf(child);\n (this.childNodes as unknown as Node[]).splice(idx, 1);\n child.parentNode = null;\n child.parentElement = null;\n }\n return child;\n }\n\n remove(): Node {\n return this.parentNode ? this.parentNode.removeChild(this) : this;\n }\n\n cloneNode(deep?: boolean | undefined): Node {\n if (this.nodeType === 3) {\n return new Text(this.nodeValue);\n }\n\n if (this.nodeType === 1) {\n const node = new Element();\n node.nodeType = this.nodeType;\n this.nodeName = this.nodeName;\n if (this.attributes) {\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n node.setAttribute(this.attributes[i].nodeName, this.attributes[i].nodeValue);\n }\n }\n\n for (const key in this.dataset) {\n node.dataset[key] = this.dataset[key];\n }\n\n if (deep) {\n for (let i = 0, l = this.childNodes.length; i < l; i++) {\n node.appendChild(this.childNodes[i].cloneNode(deep));\n }\n }\n return node;\n }\n\n const node = new Node();\n node.nodeType = this.nodeType;\n node.nodeName = this.nodeName;\n return node;\n }\n\n setAttribute(name: string, value: any) {\n const attr = {\n nodeName: name,\n nodeValue: value\n };\n let idx = -1;\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n if (this.attributes[i].nodeName === name) {\n idx = i;\n break;\n }\n }\n idx === -1 ? this.attributes.push(attr as Attr) : this.attributes.splice(idx, 1, attr as Attr);\n }\n\n getAttribute(name: string) {\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n if (this.attributes[i].nodeName === name) {\n return this.attributes[i].nodeValue;\n }\n }\n }\n\n removeAttribute(name: string) {\n let idx = -1;\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n if (this.attributes[i].nodeName === name) {\n idx = i;\n break;\n }\n }\n if (idx > -1) {\n this.attributes.splice(idx, 1);\n }\n }\n\n getElementById(id: string): Node | null {\n let elementFound;\n for (let i = 0, l = this.childNodes.length; i < l; i++) {\n if (this.childNodes[i].nodeType === 1) {\n if (this.childNodes[i].getAttribute(\"id\") === id) {\n elementFound = this.childNodes[i];\n break;\n }\n elementFound = this.childNodes[i].getElementById(id);\n if (elementFound) {\n break;\n }\n }\n }\n return elementFound || null;\n }\n\n // Not implemented\n // firstChild!: ChildNode | null;\n // isConnected!: boolean;\n // lastChild!: ChildNode | null;\n // nextSibling!: ChildNode | null;\n // ownerDocument!: Document | null;\n // parentElement!: HTMLElement | null;\n // previousSibling!: ChildNode | null;\n // compareDocumentPosition(other: Node): number {\n // throw new Error(\"Method not implemented.\");\n // }\n // contains(other: Node | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // getRootNode(options?: GetRootNodeOptions | undefined): Node {\n // throw new Error(\"Method not implemented.\");\n // }\n // hasChildNodes(): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // isDefaultNamespace(namespace: string | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // isEqualNode(otherNode: Node | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // isSameNode(otherNode: Node | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // lookupNamespaceURI(prefix: string | null): string | null {\n // throw new Error(\"Method not implemented.\");\n // }\n // lookupPrefix(namespace: string | null): string | null {\n // throw new Error(\"Method not implemented.\");\n // }\n // normalize(): void {\n // throw new Error(\"Method not implemented.\");\n // }\n // ATTRIBUTE_NODE!: number;\n // CDATA_SECTION_NODE!: number;\n // COMMENT_NODE!: number;\n // DOCUMENT_FRAGMENT_NODE!: number;\n // DOCUMENT_NODE!: number;\n // DOCUMENT_POSITION_CONTAINED_BY!: number;\n // DOCUMENT_POSITION_CONTAINS!: number;\n // DOCUMENT_POSITION_DISCONNECTED!: number;\n // DOCUMENT_POSITION_FOLLOWING!: number;\n // DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC!: number;\n // DOCUMENT_POSITION_PRECEDING!: number;\n // DOCUMENT_TYPE_NODE!: number;\n // ELEMENT_NODE!: number;\n // ENTITY_NODE!: number;\n // ENTITY_REFERENCE_NODE!: number;\n // NOTATION_NODE!: number;\n // PROCESSING_INSTRUCTION_NODE!: number;\n // TEXT_NODE!: number;\n addEventListener(\n // eslint-disable-next-line no-unused-vars\n type: string,\n // eslint-disable-next-line no-unused-vars\n callback: EventListenerOrEventListenerObject | null,\n // eslint-disable-next-line no-unused-vars\n options?: boolean | AddEventListenerOptions | undefined\n ): void {\n // throw new Error(\"Method not implemented.\");\n }\n // dispatchEvent(event: Event): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n removeEventListener(\n // eslint-disable-next-line no-unused-vars\n type: string,\n // eslint-disable-next-line no-unused-vars\n callback: EventListenerOrEventListenerObject | null,\n // eslint-disable-next-line no-unused-vars\n options?: boolean | EventListenerOptions | undefined\n ): void {\n // throw new Error(\"Method not implemented.\");\n }\n}\n\nexport class Text extends Node {\n constructor(text: any) {\n super();\n this.nodeType = 3;\n this.nodeName = \"#text\";\n this.node_value = String(text);\n }\n}\n\nfunction updateElementStyles(element: Element, state: Record<string, any>) {\n let str = \"\";\n for (const key in state) {\n const value = state[key];\n if (typeof value !== \"undefined\" && value !== null && String(value).length > 0) {\n str += `${key}: ${state[key]};`;\n }\n }\n if (str.length === 0) {\n element.removeAttribute(\"style\");\n } else {\n element.setAttribute(\"style\", str);\n }\n}\n\nexport class Element extends Node {\n constructor() {\n super();\n this.nodeType = 1;\n this.attributes = [];\n this.childNodes = [];\n }\n\n _style = new Proxy(\n {},\n {\n get: (state: Record<string, any>, prop: string) => state[prop],\n set: (state: Record<string, any>, prop: string, value: any) => {\n state[prop] = value;\n updateElementStyles(this, state);\n return true;\n },\n deleteProperty: (state: Record<string, any>, prop: string) => {\n Reflect.deleteProperty(state, prop);\n updateElementStyles(this, state);\n return true;\n }\n }\n );\n\n get style() {\n return this._style as any;\n }\n\n set style(value: string) {\n if (typeof value === \"string\") {\n // should match pairs like \"color: red; font-size: 12px; background: url(http://example.com/image.png?s=1024x1024&amp;w=is&amp;k=20&amp;c=ASa_AG8uP5Di7azXgJraSA6ME7fbLB0GX4YT_OzCARI=);\"\n const regex = /([^:\\s]+):\\s*((url\\([^)]+\\))|[^;]+(?=(;|$)))/g;\n let match;\n\n while ((match = regex.exec(value)) !== null) {\n this._style[match[1]] = match[2].trim();\n }\n\n return;\n }\n\n throw new Error(\"Cannot set style\");\n }\n\n get className(): string {\n return this.getAttribute(\"class\") || \"\";\n }\n\n set className(value: string | boolean) {\n if (value == null || value === false) {\n this.removeAttribute(\"class\");\n } else {\n this.setAttribute(\"class\", String(value));\n }\n }\n\n classList = {\n toggle: (item: any, force: any) => {\n if (item) {\n const classes = (this.className || \"\").split(\" \");\n const itemIndex = classes.indexOf(item);\n if (force && itemIndex === -1) {\n classes.push(item);\n }\n\n if (!force && itemIndex !== -1) {\n classes.splice(itemIndex, 1);\n }\n\n const final = classes.join(\" \").trim();\n if (final.length) {\n this.className = classes.join(\" \").trim();\n } else {\n this.className = false;\n }\n }\n }\n };\n\n get id(): string {\n return this.getAttribute(\"id\") || \"\";\n }\n\n set id(value: string | boolean) {\n if (value == null || value === false) {\n this.removeAttribute(\"id\");\n } else {\n this.setAttribute(\"id\", String(value));\n }\n }\n\n set textContent(text) {\n this.nodeValue = String(text);\n this.childNodes = this.nodeValue ? [new Text(this.nodeValue)] : [];\n }\n get textContent() {\n return this.nodeValue;\n }\n\n set innerText(text) {\n this.nodeValue = String(text);\n }\n\n get innerText() {\n return this.nodeValue;\n }\n\n get innerHTML() {\n let str = \"\";\n for (let i = 0, l = this.childNodes.length; i < l; i++) {\n // console.log(\"domToHtml\", this.childNodes[i], domToHtml(this.childNodes[i] as Element));\n str += domToHtml(this.childNodes[i] as Element);\n }\n return str;\n }\n\n set innerHTML(html) {\n this.textContent = \"\";\n const result = htmlToDom(html);\n if (result instanceof DocumentFragment) {\n for (let i = 0, l = result.childNodes.length; i < l; i++) {\n this.appendChild(result.childNodes[i]);\n }\n } else {\n this.appendChild(result);\n }\n }\n\n get outerHTML(): string {\n return domToHtml(this);\n }\n}\n\nexport class DocumentFragment extends Element {\n constructor() {\n super();\n this.nodeType = 11;\n this.nodeName = \"#document-fragment\";\n }\n}\n\nexport class Document extends Element {\n constructor() {\n super();\n this.nodeType = 9;\n this.nodeName = \"#document\";\n this.body = this.createElement(\"body\");\n }\n\n body: Element;\n\n createDocumentFragment(): DocumentFragment {\n return new DocumentFragment();\n }\n\n createElement(type: string) {\n const element = new Element();\n element.nodeName = type.toUpperCase();\n return element;\n }\n\n createElementNS(ns: string, type: string) {\n const element = this.createElement(type);\n element.baseURI = ns;\n return element;\n }\n\n createTextNode(text: any) {\n return new Text(text);\n }\n}\n\nconst ESCAPE_LOOKUP: { [key: string]: string } = {\n \"&\": \"&amp;\",\n \">\": \"&gt;\",\n \"<\": \"&lt;\",\n '\"': \"&quot;\",\n \"'\": \"&#39;\"\n};\n\nconst ESCAPE_REGEX = /[&><\"']/g;\n\nfunction escapeHtml(str: string | any): string {\n if (typeof str !== \"string\") {\n return String(str);\n }\n\n if (ESCAPE_REGEX.test(str) === false) {\n return str;\n }\n\n return str.replace(ESCAPE_REGEX, (match) => ESCAPE_LOOKUP[match]).replace(/&amp;amp;/g, \"&amp;\");\n}\n\nconst selfClosingTags = [\n \"area\",\n \"base\",\n \"br\",\n \"col\",\n \"embed\",\n \"hr\",\n \"img\",\n \"input\",\n \"link\",\n \"meta\",\n \"param\",\n \"source\",\n \"track\",\n \"wbr\",\n \"!doctype\"\n];\n\nexport function domToHtml(dom: Element | Text | DocumentFragment): string {\n if (dom.nodeType === 3) {\n return dom.textContent;\n }\n\n if (dom.nodeType === 1) {\n const name = dom.nodeName.toLowerCase();\n let str = \"<\" + name;\n\n for (let i = 0, l = dom.attributes.length; i < l; i++) {\n const attr = dom.attributes[i];\n str += \" \" + attr.nodeName + '=\"' + escapeHtml(attr.nodeValue) + '\"';\n }\n\n if (selfClosingTags.indexOf(name) === -1) {\n str += \">\";\n if (dom.childNodes && dom.childNodes.length > 0) {\n for (let i = 0, l = dom.childNodes.length; i < l; i++) {\n const child = domToHtml(dom.childNodes[i] as Element);\n if (child) {\n str += child;\n }\n }\n }\n str += \"</\" + name + \">\";\n } else {\n str += \"/>\";\n }\n\n return str;\n }\n\n return \"\";\n}\n\nexport function domToHyperscript(childNodes: ChildNodes, depth = 1) {\n let spaces = \"\";\n for (let i = 0; i < depth; i++) {\n spaces += \" \";\n }\n\n return childNodes\n .map((item) => {\n if (item.nodeType === 10) {\n return `\\n${spaces}\"<!DOCTYPE html>\"`;\n } else if (item.nodeType === 3) {\n return `\\n${spaces}\"${item.nodeValue}\"`;\n } else {\n let str = `\\n${spaces}v(\"${item.nodeName}\", `;\n\n if (item.attributes) {\n const attrs: Record<string, any> = {};\n for (let i = 0, l = item.attributes.length; i < l; i++) {\n const attr = item.attributes[i];\n attrs[attr.nodeName] = attr.nodeValue;\n }\n str += JSON.stringify(attrs);\n } else {\n str += \"{}\";\n }\n\n str += \", [\";\n if (item.childNodes && item.childNodes.length > 0) {\n str += `${domToHyperscript(item.childNodes as unknown as Element[], depth + 1)}\\n${spaces}`;\n }\n\n str += `])`;\n return str;\n }\n })\n .join(\",\");\n}\n\ninterface ObjectIndexItem {\n tagName: string;\n startsAt: number;\n endsAt: number | null;\n contentStartsAt: number;\n contentEndsAt: number | null;\n attributes: { [key: string]: any };\n children: ObjectIndexItem[];\n nodeValue: string | null;\n}\n\ninterface ObjectIndexItemWithContent extends ObjectIndexItem {\n endsAt: number;\n contentEndsAt: number;\n children: ObjectIndexItemWithContent[];\n}\n\ninterface ObjectIndexList extends Array<ObjectIndexItem> {}\n\nfunction findTexts(item: ObjectIndexItemWithContent, html: string) {\n const newChildren: ObjectIndexItemWithContent[] = [];\n\n // If the item has children\n if (item.children.length) {\n // Search for texts in the children.\n for (let i = 0; i < item.children.length; i++) {\n const child = item.children[i];\n const nextChild = item.children[i + 1];\n\n // If is the first child and the child startsAt is greater than the item contentStartsAt then\n // the content between the item contentStartsAt and the child startsAt is a text child of the item.\n if (i === 0 && child.startsAt > item.contentStartsAt) {\n const childContent = html.substring(item.contentStartsAt, child.startsAt);\n\n const childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: item.contentStartsAt,\n endsAt: item.contentStartsAt + childContent.length,\n contentStartsAt: item.contentStartsAt,\n contentEndsAt: item.contentStartsAt + childContent.length,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n\n // Add the child to the newChildren array.\n newChildren.push(child);\n\n // If there is a next child and the child endsAt is less than the next child startsAt then\n // the content between the child endsAt and the next child startsAt is a text child of the item.\n if (nextChild && child.endsAt < nextChild.startsAt) {\n const childContent = html.substring(child.endsAt, nextChild.startsAt);\n\n const childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: child.endsAt,\n endsAt: child.endsAt + childContent.length,\n contentStartsAt: child.endsAt,\n contentEndsAt: child.endsAt + childContent.length,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n\n // If there are no next child and the child endsAt is less than the item contentEndsAt then\n // the content between the child endsAt and the item contentEndsAt is a text child of the item.\n if (!nextChild && child.endsAt < item.contentEndsAt) {\n const childContent = html.substring(child.endsAt, item.contentEndsAt);\n\n const childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: child.endsAt,\n endsAt: child.endsAt + childContent.length,\n contentStartsAt: child.endsAt,\n contentEndsAt: item.contentEndsAt,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n\n // Find texts in the child.\n findTexts(child, html);\n }\n }\n\n // If the item has no children then set the contents between the item contentStartsAt and the item contentEndsAt\n // as a text child of the item.\n if (!item.children.length) {\n const childContent = html.substring(item.contentStartsAt, item.contentEndsAt);\n\n if (childContent.length) {\n const childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: item.contentStartsAt,\n endsAt: item.contentEndsAt,\n contentStartsAt: item.contentStartsAt,\n contentEndsAt: item.contentEndsAt,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n }\n\n item.children = newChildren;\n}\n\nfunction convertToDom<T extends Node>(item: ObjectIndexItemWithContent): T {\n let node: T;\n\n if (item.tagName === \"#text\") {\n node = document.createTextNode(item.nodeValue as string) as unknown as T;\n } else {\n node = (item.tagName === \"#document-fragment\"\n ? document.createDocumentFragment()\n : document.createElement(item.tagName)) as unknown as T;\n\n for (const key in item.attributes) {\n node.setAttribute(key, item.attributes[key]);\n }\n\n for (let i = 0; i < item.children.length; i++) {\n const child = convertToDom(item.children[i]);\n node.appendChild(child);\n }\n }\n\n return node;\n}\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nfunction getObjectIndexTree(html: string): DocumentFragment {\n let item;\n const regex = RegExp(\"<([^>|^!]+)>\", \"g\");\n const items: ObjectIndexList = [];\n\n // Make the initial list of items.\n while ((item = regex.exec(html))) {\n // If is a closing tag\n if (item[0].startsWith(\"</\")) {\n const lastOpenedItem = [...items].reverse().find((item) => item.endsAt === null);\n if (lastOpenedItem) {\n lastOpenedItem.endsAt = item.index + item[0].length;\n lastOpenedItem.contentEndsAt = item.index;\n\n // Find the last opened item again, this will be the parent of the current item.\n const parent = [...items].reverse().find((item) => item.endsAt === null);\n if (parent) {\n // Find the index of the current item in the items array.\n const index = items.indexOf(lastOpenedItem);\n // Remove the last opened item from the items array.\n items.splice(index, 1);\n\n // Add the last opened item as a child of the parent.\n parent.children.push(lastOpenedItem);\n }\n }\n\n continue;\n }\n\n // If is an opening tag\n const element: ObjectIndexItem = {\n tagName: item[1].split(\" \")[0],\n startsAt: item.index,\n endsAt: null,\n contentStartsAt: item.index + item[0].length,\n contentEndsAt: null,\n attributes: {},\n children: [],\n nodeValue: null\n };\n\n // Find the attributes of the tag.\n let string = (item[1] || \"\").substring(element.tagName.length + 1).replace(/\\/$/g, \"\");\n const attributesWithValues = string.match(/\\S+=\"[^\"]+\"/g);\n\n if (attributesWithValues) {\n for (const attribute of attributesWithValues) {\n const [name, ...value] = attribute.trim().split(\"=\");\n string = string.replace(attribute, \"\");\n if (value) {\n element.attributes[name] = value.join(\"=\").replace(/(^\"|\"$)/g, \"\");\n }\n }\n }\n\n const attributesWithBooleanValues = string.match(/\\s\\S+=[^\"]+/g);\n if (attributesWithBooleanValues) {\n for (const attribute of attributesWithBooleanValues) {\n const [name, ...value] = attribute.trim().split(\"=\");\n string = string.replace(attribute, \"\");\n if (value) {\n element.attributes[name] = value.join(\"=\").replace(/(^\"|\"$)/g, \"\");\n }\n }\n }\n\n const attributesWithEmptyValues = string.match(/\\s?\\S+/g);\n if (attributesWithEmptyValues) {\n for (const attribute of attributesWithEmptyValues) {\n const name = attribute.trim();\n element.attributes[name] = true;\n }\n }\n\n // If the tag is self closing\n if (item[0].endsWith(\"/>\")) {\n element.endsAt = element.startsAt + item[0].length;\n element.contentStartsAt = element.contentEndsAt = element.endsAt;\n\n // Find the last opened item, this will be the parent of the current item.\n const parent = [...items].reverse().find((item) => item.endsAt === null);\n if (parent) {\n // Add the last opened item as a child of the parent.\n parent.children.push(element);\n continue;\n }\n }\n\n items.push(element);\n }\n\n const fragmentItem: ObjectIndexItemWithContent = {\n tagName: \"#document-fragment\",\n startsAt: 0,\n endsAt: html.length,\n contentStartsAt: 0,\n contentEndsAt: html.length,\n attributes: {},\n children: items as ObjectIndexItemWithContent[],\n nodeValue: null\n };\n\n findTexts(fragmentItem, html);\n\n return convertToDom<DocumentFragment>(fragmentItem);\n}\n\n// First we create a tree of object indexes from the HTML string.\n// The resulting array is then reordered to match the order of the html string.\n// And to move the children to the correct position in its parents.\n// This resulting array is populated with a object node version of the object index.\n// If the final result have more than 1 node, then return a document fragment node.\n// If the final result have 1 node, then return the node.\n// eslint-disable-next-line complexity\nexport function htmlToDom(html: string): Element | Text | DocumentFragment {\n // Search for the opening and closing tags of the root element.\n // The opening tag could be in the middle of the string, so we need to\n // search for the first opening tag.\n const openingTag = html.match(/<[^>]+>/g);\n\n const document = new Document();\n\n // If the opening tag is not found, return a document fragment node with the html string as text content.\n if (!openingTag) {\n const documentFragment = document.createDocumentFragment();\n documentFragment.appendChild(document.createTextNode(html));\n return documentFragment;\n }\n\n const fragment = getObjectIndexTree(html);\n\n if (fragment.childNodes.length > 1) {\n return fragment;\n }\n\n return fragment.childNodes[0];\n}\n\nexport function htmlToHyperscript(html: string) {\n const domTree = htmlToDom(html);\n const hyperscript = domToHyperscript(domTree instanceof DocumentFragment ? domTree.childNodes : [domTree]);\n return `[${hyperscript}\\n]`;\n}\n\nexport const document = new Document();\n\nconst html = document.createElement(\"html\");\nhtml.appendChild(document.createElement(\"head\"));\nhtml.appendChild(document.body);\n", "import fs from \"fs\";\nimport { htmlToHyperscript } from \"./tree-adapter\";\n\nexport interface IconsOptions {\n iconsPath: string | null;\n linksViewPath: string | null;\n logging: boolean;\n\n // favicons options\n path: string;\n appName?: string;\n appDescription?: string;\n developerName?: string;\n developerURL?: string;\n dir?: \"auto\" | \"ltr\" | \"rtl\" | string;\n lang?: string;\n background?: string;\n theme_color?: string;\n display?: \"browser\" | \"standalone\" | string;\n orientation?: \"any\" | \"portrait\" | \"landscape\" | string;\n start_url?: string;\n version?: string;\n icons: {\n android: boolean;\n appleIcon: boolean;\n appleStartup: boolean;\n coast: boolean;\n favicons: boolean;\n firefox: boolean;\n windows: boolean;\n yandex: boolean;\n };\n}\n\nexport async function icons(source: string, configuration?: IconsOptions) {\n const options = {\n ...icons.options,\n ...(configuration || {})\n };\n\n if (options.iconsPath) {\n options.iconsPath = options.iconsPath.replace(/\\/$/gi, \"\") + \"/\";\n }\n\n if (options.linksViewPath) {\n options.linksViewPath = options.linksViewPath.replace(/\\/$/gi, \"\") + \"/\";\n }\n\n const { favicons } = await import(\"favicons\");\n\n try {\n const response = await favicons(source, options);\n\n if (options.iconsPath) {\n for (const i in response.images) {\n fs.writeFileSync(options.iconsPath + response.images[i].name, response.images[i].contents);\n }\n\n for (const i in response.files) {\n fs.writeFileSync(options.iconsPath + response.files[i].name, response.files[i].contents);\n }\n }\n\n if (options.linksViewPath) {\n const html = `\n function Links(){\n return ${htmlToHyperscript(response.html.join(\"\"))};\n }\n \n Links.default = Links;\n module.exports = Links;\n `;\n\n fs.writeFileSync(`${options.linksViewPath}/links.js`, html);\n }\n } catch (err) {\n process.stdout.write((err as any).status + \"\\n\"); // HTTP error code (e.g. `200`) or `null`\n process.stdout.write((err as any).name + \"\\n\"); // Error name e.g. \"API Error\"\n process.stdout.write((err as any).message + \"\\n\"); // Error description e.g. \"An unknown error has occurred\"\n }\n}\n\nicons.options = {\n iconsPath: null,\n linksViewPath: null,\n\n // favicons options\n path: \"\",\n appName: null,\n appDescription: null,\n developerName: null,\n developerURL: null,\n dir: \"auto\",\n lang: \"en-US\",\n background: \"#fff\",\n theme_color: \"#fff\",\n display: \"standalone\",\n orientation: \"any\",\n start_url: \"/\",\n version: \"1.0\",\n logging: false,\n icons: {\n android: true,\n appleIcon: true,\n appleStartup: true,\n coast: false,\n favicons: true,\n firefox: false,\n windows: true,\n yandex: false // Create Yandex browser icon. `boolean`\n }\n} as unknown as IconsOptions;\n", "import * as tsc from \"tsc-prog\";\n\nimport CleanCSS from \"clean-css\";\nimport { PurgeCSS } from \"purgecss\";\nimport esbuild from \"esbuild\";\n/* eslint-disable sonarjs/cognitive-complexity */\nimport fs from \"fs\";\n\n// eslint-disable-next-line complexity\nexport async function inline(\n file: string | { raw: string; map?: string | null; file: string },\n options: Record<string, any> = {}\n) {\n if (typeof file === \"string\") {\n const ext = file.split(\".\").pop();\n if (ext && /(js|cjs|jsx|mjs|ts|tsx)/.test(ext)) {\n if (/(ts|tsx)/.test(ext) && !options.noValidate) {\n const declarationDir = options.declarationDir;\n const emitDeclaration = !!declarationDir;\n\n const tscProgOptions = {\n basePath: process.cwd(), // always required, used for relative paths\n configFilePath: \"tsconfig.json\", // config to inherit from (optional)\n files: [file],\n include: [\"**/*.ts\", \"**/*.js\", \"**/*.tsx\", \"**/*.jsx\", \"**/*.mjs\"],\n exclude: [\"test*/**/*\", \"**/*.test.ts\", \"**/*.spec.ts\", \"dist/**\"],\n pretty: true,\n copyOtherToOutDir: false,\n clean: emitDeclaration ? [declarationDir] : [],\n ...(options.tsc || {}),\n compilerOptions: {\n rootDir: \"./\",\n outDir: \"dist\",\n noEmitOnError: true,\n noEmit: !emitDeclaration,\n declaration: emitDeclaration,\n declarationDir,\n emitDeclarationOnly: emitDeclaration,\n allowJs: true,\n esModuleInterop: true,\n inlineSourceMap: true,\n resolveJsonModule: true,\n removeComments: true,\n ...(options.tsc || {}).compilerOptions\n },\n jsxFactory: \"v\",\n jsxFragment: \"v.fragment\"\n };\n\n // eslint-disable-next-line no-console\n console.log(\"tsc\", tscProgOptions);\n\n tsc.build(tscProgOptions);\n }\n\n const esbuildOptions = {\n entryPoints: [file],\n bundle: \"bundle\" in options ? options.bundle : true,\n sourcemap: \"external\",\n write: false,\n minify: options.compact,\n outdir: \"out\",\n target: \"esnext\",\n jsxFactory: \"v\",\n jsxFragment: \"v.fragment\",\n loader: {\n \".js\": \"jsx\",\n \".cjs\": \"jsx\",\n \".mjs\": \"jsx\",\n \".ts\": \"tsx\"\n },\n ...(options.esbuild || {})\n };\n\n const result = await esbuild.build(esbuildOptions);\n if (result.outputFiles?.length !== 2) {\n throw new Error(result.errors.join(\"\\n\"));\n }\n\n if (options.compact) {\n const terser = await import(\"terser\");\n const result2 = await terser.minify(result.outputFiles[1].text, {\n sourceMap: {\n content: result.outputFiles[0].text.toString()\n },\n compress: {\n booleans_as_integers: false\n },\n output: {\n wrap_func_args: false\n },\n ecma: 2022,\n ...(options.terser || {})\n });\n\n if (!result2.code || !result2.map) {\n throw new Error(\"Unknown error\");\n }\n\n const mapBase64 = Buffer.from(result2.map.toString()).toString(\"base64\");\n const suffix = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${mapBase64}`;\n return { raw: result2.code, map: suffix, file };\n } else {\n const mapBase64 = Buffer.from(result.outputFiles[0].text.toString()).toString(\"base64\");\n const suffix = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${mapBase64}`;\n return { raw: result.outputFiles[1].text, map: suffix, file };\n }\n } else if (ext && /(css|scss|styl)/.test(ext)) {\n const result = await new CleanCSS({\n sourceMap: true,\n level: {\n 1: {\n roundingPrecision: \"all=3\"\n },\n 2: {\n restructureRules: true // controls rule restructuring; defaults to false\n }\n },\n ...(options.cleanCss || {})\n }).minify([file]);\n\n return { raw: result.styles, map: null, file };\n } else {\n return { raw: fs.readFileSync(file, \"utf8\"), map: null, file };\n }\n } else if (typeof file === \"object\" && \"raw\" in file) {\n return { map: null, ...file };\n }\n\n throw new Error(`Unknown file type: ${file}`);\n}\n\ninline.uncss = async function (\n renderedHtml: (string | Promise<string>)[],\n css: string,\n options: Record<string, any> = {}\n) {\n const html = await Promise.all(renderedHtml);\n\n const contents = html.map((item) => {\n return {\n raw: item,\n extension: \"html\"\n };\n });\n\n const purgecss = new PurgeCSS();\n\n const output = await purgecss.purge({\n fontFace: true,\n keyframes: true,\n variables: true,\n defaultExtractor: (content) => content.match(/[A-Za-z0-9-_/:@]*[A-Za-z0-9-_/:@/]+/g) || [],\n ...options,\n content: contents,\n css: [{ raw: css }]\n });\n\n const cleanCss = await new CleanCSS({\n sourceMap: false,\n level: {\n 1: {\n roundingPrecision: \"all=3\"\n },\n 2: {\n restructureRules: true // controls rule restructuring; defaults to false\n }\n },\n ...(options.cleanCss || {})\n }).minify(output[0].css);\n\n return cleanCss.styles;\n};\n", "import fs from \"fs\";\nimport path from \"path\";\n\nexport function sw(file: string, options = {}) {\n const swfiletemplate = path.resolve(__dirname, \"./node.sw.js\");\n const swTpl = fs.readFileSync(swfiletemplate, \"utf8\");\n const opt = {\n version: \"1\",\n name: \"Valyrian.js\",\n urls: [\"/\"],\n debug: false,\n logFetch: false,\n offlinePage: \"/offline.html\",\n ...options\n };\n let contents = swTpl\n .replace(\"v1\", `v${opt.version}`)\n .replace(\"Valyrian.js\", opt.name)\n .replace('[\"/\"]', '[\"' + opt.urls.join('\",\"') + '\"]')\n .replace(\"/offline.html\", opt.offlinePage)\n .replace(\"logFetch: false\", opt.logFetch ? \"logFetch: true\" : \"logFetch: false\");\n\n if (!opt.debug) {\n contents = contents.replace(\"console.log\", \"() => {}\");\n }\n\n fs.writeFileSync(file, contents, \"utf8\");\n}\n\n/*\n // On the server side to generate the service worker\n sw(\"sw.js\", {\n version: \"1\",\n name: \"Valyrian.js\",\n urls: [\"/\"],\n debug: false,\n logFetch: false,\n offlinePage: \"/offline.html\"\n });\n\n\n // On the client side\n if (\"serviceWorker\" in navigator) {\n const registration = await navigator.serviceWorker.register(\"/sw.js\");\n registration.addEventListener(\"updatefound\", () => {\n const newWorker = registration.installing as ServiceWorker;\n newWorker.addEventListener(\"statechange\", () => {\n if (newWorker.state === \"installed\") {\n // Notify the user about the new version and ask if they want to update\n if (confirm(\"There is a new version available. Do you want to update?\")) {\n // Send a message to the service worker to skip the waiting\n navigator.serviceWorker.controller.postMessage({ type: \"SKIP_WAITING\" });\n }\n }\n });\n });\n\n navigator.serviceWorker.addEventListener(\"controllerchange\", () => {\n window.location.reload();\n });\n }\n*/\n", "import { AsyncLocalStorage } from \"node:async_hooks\";\n\nconst storageContext = new AsyncLocalStorage<Record<string, string>>();\nlet globalStore: Record<string, string> = {};\n\nexport class ServerStorage implements Storage {\n get store(): Record<string, string> {\n return storageContext.getStore() || globalStore;\n }\n\n get length(): number {\n const store = this.store;\n return store ? Object.keys(store).length : 0;\n }\n\n clear(): void {\n const store = this.store;\n if (store) {\n for (const key in store) {\n Reflect.deleteProperty(store, key);\n }\n }\n }\n\n getItem(key: string): string | null {\n const store = this.store;\n return store ? store[key] || null : null;\n }\n\n key(index: number): string | null {\n const store = this.store;\n return store ? Object.keys(store)[index] || null : null;\n }\n\n removeItem(key: string): void {\n const store = this.store;\n if (store) {\n Reflect.deleteProperty(store, key);\n }\n }\n\n setItem(key: string, value: string): void {\n const store = this.store;\n if (store) {\n store[key] = String(value);\n }\n }\n\n static run(callback: () => void) {\n storageContext.run({}, callback);\n }\n\n toJSON(): Record<string, string> {\n const store = this.store;\n return store ? { ...store } : {};\n }\n}\n\n/*\nOn node.js environment, use ServerStorage for session storage.\nAt each request, a new storage context is created using ServerStorage.run method.\nIn browser environment, use the native sessionStorage.\n\nserver.get(\"*\", (req, res) => {\n ServerStorage.run(() => {\n const html = router.go(req.url);\n res.send(html);\n \n });\n});\n*/\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,IAAM,OAAN,MAAM,MAAqB;AAAA;AAAA,EAEhC,aAAyB,CAAC;AAAA,EAC1B,UAAkB;AAAA,EAElB;AAAA,EACA,IAAI,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AAI,OAAO,KAAK;AAAA,IAC3B;AAAA,EACF;AAAA,EAEA,OAAO,IAAI,UAAsB;AAC/B,mBAAe,IAAI,CAAC,GAAG,QAAQ;AAAA,EACjC;AAAA,EAEA,SAAiC;AAC/B,UAAM,QAAQ,KAAK;AACnB,WAAO,QAAQ,EAAE,GAAG,MAAM,IAAI,CAAC;AAAA,EACjC;AACF;;;AL/CA,OAAO,WAAW,iBAAAC;AAClB,OAAO,WAAW;AAClB,OAAO,iBAAiB,IAAI,cAAc;AAC1C,OAAO,eAAe,IAAI,cAAc;AAExC,SAAS,UAAU,MAAa;AAC9B,QAAM,YAAY,MAAM;AACxB,QAAM,aAAS,uBAAM,OAAO,SAAS;AACrC,+BAAQ;AACR,SAAO;AACT;",
6
+ "names": ["node", "html", "item", "document", "fs", "html", "import_fs", "esbuild", "CleanCSS", "fs", "html", "import_fs", "path", "fs", "FormData"]
7
7
  }
@@ -409,6 +409,23 @@ var Document = class extends Element {
409
409
  return new Text(text);
410
410
  }
411
411
  };
412
+ var ESCAPE_LOOKUP = {
413
+ "&": "&amp;",
414
+ ">": "&gt;",
415
+ "<": "&lt;",
416
+ '"': "&quot;",
417
+ "'": "&#39;"
418
+ };
419
+ var ESCAPE_REGEX = /[&><"']/g;
420
+ function escapeHtml(str) {
421
+ if (typeof str !== "string") {
422
+ return String(str);
423
+ }
424
+ if (ESCAPE_REGEX.test(str) === false) {
425
+ return str;
426
+ }
427
+ return str.replace(ESCAPE_REGEX, (match) => ESCAPE_LOOKUP[match]).replace(/&amp;amp;/g, "&amp;");
428
+ }
412
429
  var selfClosingTags = [
413
430
  "area",
414
431
  "base",
@@ -434,7 +451,8 @@ function domToHtml(dom) {
434
451
  const name = dom.nodeName.toLowerCase();
435
452
  let str = "<" + name;
436
453
  for (let i = 0, l = dom.attributes.length; i < l; i++) {
437
- str += " " + dom.attributes[i].nodeName + '="' + dom.attributes[i].nodeValue + '"';
454
+ const attr = dom.attributes[i];
455
+ str += " " + attr.nodeName + '="' + escapeHtml(attr.nodeValue) + '"';
438
456
  }
439
457
  if (selfClosingTags.indexOf(name) === -1) {
440
458
  str += ">";
@@ -930,115 +948,60 @@ function sw(file, options = {}) {
930
948
  fs3.writeFileSync(file, contents, "utf8");
931
949
  }
932
950
 
933
- // lib/node/utils/session-storage.ts
934
- import fs4 from "fs";
935
- import path2 from "path";
936
- var SessionStorage = class {
937
- storage;
938
- limit;
939
- persist;
940
- filePath;
941
- directory = ".session-storage";
942
- constructor({ persist = false, filePath = "./sessionData.json" } = {}) {
943
- this.storage = {};
944
- this.limit = 5 * 1024 * 1024;
945
- this.persist = persist;
946
- this.filePath = path2.resolve(this.directory, filePath);
947
- if (this.persist) {
948
- if (!fs4.existsSync(this.directory)) {
949
- fs4.mkdirSync(this.directory, { recursive: true });
950
- }
951
- this.loadFromFile();
952
- }
951
+ // lib/node/utils/server-storage.ts
952
+ import { AsyncLocalStorage } from "node:async_hooks";
953
+ var storageContext = new AsyncLocalStorage();
954
+ var globalStore = {};
955
+ var ServerStorage = class {
956
+ get store() {
957
+ return storageContext.getStore() || globalStore;
953
958
  }
954
- // Calculate total size in bytes of stored data
955
- getStorageSize() {
956
- return new TextEncoder().encode(JSON.stringify(this.storage)).length;
957
- }
958
- // Check if storage limit is exceeded
959
- checkSizeLimit() {
960
- const size = this.getStorageSize();
961
- if (size > this.limit) {
962
- throw new DOMException("Storage limit exceeded", "QuotaExceededError");
963
- }
959
+ get length() {
960
+ const store = this.store;
961
+ return store ? Object.keys(store).length : 0;
964
962
  }
965
- // Store value under the specified key
966
- setItem(key, value) {
967
- if (key === null || key === void 0) {
968
- throw new TypeError("Failed to execute 'setItem' on 'Storage': 1 argument required, but only 0 present.");
969
- }
970
- if (value === null) {
971
- value = "null";
972
- } else if (value === void 0) {
973
- value = "undefined";
963
+ clear() {
964
+ const store = this.store;
965
+ if (store) {
966
+ for (const key in store) {
967
+ Reflect.deleteProperty(store, key);
968
+ }
974
969
  }
975
- this.loadFromFile();
976
- this.storage[key] = String(value);
977
- this.checkSizeLimit();
978
- this.saveToFile();
979
970
  }
980
- // Retrieve value stored under the specified key
981
971
  getItem(key) {
982
- if (key === null || key === void 0) {
983
- throw new TypeError("Failed to execute 'getItem' on 'Storage': 1 argument required, but only 0 present.");
984
- }
985
- this.loadFromFile();
986
- return this.storage[key] || null;
972
+ const store = this.store;
973
+ return store ? store[key] || null : null;
974
+ }
975
+ key(index) {
976
+ const store = this.store;
977
+ return store ? Object.keys(store)[index] || null : null;
987
978
  }
988
- // Remove the value under the specified key
989
979
  removeItem(key) {
990
- if (key === null || key === void 0) {
991
- throw new TypeError("Failed to execute 'removeItem' on 'Storage': 1 argument required, but only 0 present.");
980
+ const store = this.store;
981
+ if (store) {
982
+ Reflect.deleteProperty(store, key);
992
983
  }
993
- this.loadFromFile();
994
- Reflect.deleteProperty(this.storage, key);
995
- this.saveToFile();
996
- }
997
- // Clear all stored values
998
- clear() {
999
- this.storage = {};
1000
- this.saveToFile();
1001
- }
1002
- // Return the number of stored items
1003
- get length() {
1004
- return Object.keys(this.storage).length;
1005
984
  }
1006
- // Return the key at the specified index
1007
- key(index) {
1008
- this.loadFromFile();
1009
- const keys = Object.keys(this.storage);
1010
- return keys[index] || null;
1011
- }
1012
- // Save data to a file (only if persistence is enabled)
1013
- saveToFile() {
1014
- if (this.persist) {
1015
- try {
1016
- fs4.writeFileSync(this.filePath, JSON.stringify(this.storage), "utf-8");
1017
- } catch (error) {
1018
- throw new Error(`Error saving data to file: ${error.message}`);
1019
- }
985
+ setItem(key, value) {
986
+ const store = this.store;
987
+ if (store) {
988
+ store[key] = String(value);
1020
989
  }
1021
990
  }
1022
- // Load data from a file (only if persistence is enabled)
1023
- loadFromFile() {
1024
- if (this.persist) {
1025
- try {
1026
- if (fs4.existsSync(this.filePath)) {
1027
- const data = fs4.readFileSync(this.filePath, "utf-8");
1028
- this.storage = JSON.parse(data || "{}");
1029
- }
1030
- } catch (error) {
1031
- throw new Error(`Error loading data from file: ${error.message}`);
1032
- }
1033
- }
991
+ static run(callback) {
992
+ storageContext.run({}, callback);
993
+ }
994
+ toJSON() {
995
+ const store = this.store;
996
+ return store ? { ...store } : {};
1034
997
  }
1035
998
  };
1036
999
 
1037
1000
  // lib/node/index.ts
1038
1001
  global.FormData = FormData;
1039
1002
  global.document = document;
1040
- global.sessionStorage = new SessionStorage();
1041
- global.localStorage = new SessionStorage();
1003
+ global.sessionStorage = new ServerStorage();
1004
+ global.localStorage = new ServerStorage();
1042
1005
  function render(...args) {
1043
1006
  const Component = () => args;
1044
1007
  const result = mount("div", Component);
@@ -1046,7 +1009,7 @@ function render(...args) {
1046
1009
  return result;
1047
1010
  }
1048
1011
  export {
1049
- SessionStorage,
1012
+ ServerStorage,
1050
1013
  domToHtml,
1051
1014
  domToHyperscript,
1052
1015
  htmlToDom,