From af183183e51d668aa225ba040052c9f698b38c13 Mon Sep 17 00:00:00 2001 From: mychidarko Date: Fri, 14 Apr 2023 12:21:01 +0000 Subject: [PATCH] feat: update dom diffing to include parent nodes --- client/dist/engine/dom.d.ts | 10 ++++ client/dist/ui.cjs.development.js | 56 +++++++++++++++++--- client/dist/ui.cjs.development.js.map | 2 +- client/dist/ui.cjs.production.min.js | 2 +- client/dist/ui.cjs.production.min.js.map | 2 +- client/dist/ui.esm.js | 56 +++++++++++++++++--- client/dist/ui.esm.js.map | 2 +- client/src/engine/dom.ts | 66 +++++++++++++++++++++--- 8 files changed, 170 insertions(+), 26 deletions(-) diff --git a/client/dist/engine/dom.d.ts b/client/dist/engine/dom.d.ts index b2733ab..e2a37a4 100644 --- a/client/dist/engine/dom.d.ts +++ b/client/dist/engine/dom.d.ts @@ -7,6 +7,16 @@ export default class Dom { * @returns The body of the html */ static getBody(html: string, removeScripts?: boolean): HTMLElement; + /** + * Wrap DOM node with a template element + */ + static wrap(node: Node): HTMLElement; + /** + * Parse string to DOM + * + * @param html The html to parse + */ + static parse(html: string): HTMLElement; /** * Get the type for a node * @param {HTMLElement} node The node diff --git a/client/dist/ui.cjs.development.js b/client/dist/ui.cjs.development.js index aec6249..de9114b 100644 --- a/client/dist/ui.cjs.development.js +++ b/client/dist/ui.cjs.development.js @@ -395,15 +395,23 @@ var Connection = /*#__PURE__*/function () { function Connection() {} Connection.connect = function connect(type, uiData, dom) { var _component$getAttribu; + var pageState = {}; var component = uiData.element.closest('[ui-state]'); - var componentData = (_component$getAttribu = component.getAttribute('ui-state')) != null ? _component$getAttribu : '{}'; + var componentData = JSON.parse((_component$getAttribu = component == null ? void 0 : component.getAttribute('ui-state')) != null ? _component$getAttribu : '{}'); + var components = document.querySelectorAll('[ui-state]'); + components.forEach(function (i) { + var _i$getAttribute; + var attr = JSON.parse((_i$getAttribute = i.getAttribute('ui-state')) != null ? _i$getAttribute : '{}'); + pageState[attr.key] = attr; + }); var payload = { type: type, payload: { params: [], method: uiData.method, methodArgs: uiData.methodArgs, - data: componentData + component: componentData == null ? void 0 : componentData.key, + data: pageState } }; return fetch(window.location.href + "?_leaf_ui_config=" + JSON.stringify(payload), { @@ -430,7 +438,7 @@ var Connection = /*#__PURE__*/function () { response.text().then(function (response) { var data = JSON.parse(response); window._leafUIConfig.data = data.state; - dom.diff(data.html, document.body); + dom.diff(data.html, component.nodeName === 'HTML' || !component ? document.body : component); }); _context.next = 9; break; @@ -495,6 +503,24 @@ var Dom = /*#__PURE__*/function () { } return dom.body; } + /** + * Wrap DOM node with a template element + */; + Dom.wrap = function wrap(node) { + var wrapper = document.createElement('x-leafui-wrapper'); + wrapper.appendChild(node); + return wrapper; + } + /** + * Parse string to DOM + * + * @param html The html to parse + */; + Dom.parse = function parse(html) { + var parser = new DOMParser(); + var dom = parser.parseFromString(html, 'text/html'); + return dom.getRootNode().firstChild; + } /** * Get the type for a node * @param {HTMLElement} node The node @@ -522,7 +548,9 @@ var Dom = /*#__PURE__*/function () { * @returns The diffed node */; Dom.diff = function diff(newNode, oldNode) { - Dom.diffElements(Dom.getBody(newNode, false), oldNode); + var structuredNewNode = oldNode.nodeName === 'BODY' ? Dom.getBody(newNode, false) : Dom.getBody(newNode, true).children[0]; + var structuredOldNode = oldNode; + Dom.diffElements(structuredNewNode, structuredOldNode); } /** * Diff the DOM from two elements @@ -541,7 +569,7 @@ var Dom = /*#__PURE__*/function () { } } for (var index = 0; index < newNodes.length; index++) { - var _Object$keys, _oldNodes$index, _oldNodes$index2; + var _node$parentNode$attr, _node$parentNode, _oldNodes$index$paren, _oldNodes$index$paren2, _Object$keys, _oldNodes$index2, _oldNodes$index3; var node = newNodes[index]; if (!oldNodes[index]) { var newNodeClone = node.cloneNode(true); @@ -556,10 +584,22 @@ var Dom = /*#__PURE__*/function () { } continue; } - if (Dom.getNodeType(node) !== Dom.getNodeType(oldNodes[index]) || !arraysMatch((_Object$keys = Object.keys((_oldNodes$index = oldNodes[index]) == null ? void 0 : _oldNodes$index.attributes)) != null ? _Object$keys : [], Object.keys(node.attributes)) || ((_oldNodes$index2 = oldNodes[index]) == null ? void 0 : _oldNodes$index2.innerHTML) !== node.innerHTML) { + if (!arraysMatch(Object.values((_node$parentNode$attr = (_node$parentNode = node.parentNode) == null ? void 0 : _node$parentNode.attributes) != null ? _node$parentNode$attr : {}), Object.values((_oldNodes$index$paren = (_oldNodes$index$paren2 = oldNodes[index].parentNode) == null ? void 0 : _oldNodes$index$paren2.attributes) != null ? _oldNodes$index$paren : {}))) { + for (var nIndex = 0; nIndex < ((_node$parentNode$attr2 = node.parentNode.attributes) == null ? void 0 : _node$parentNode$attr2.length); nIndex++) { + var _node$parentNode$attr2, _oldNodes$index, _oldNodes$index$paren3; + var attribute = node.parentNode.attributes[nIndex]; + (_oldNodes$index = oldNodes[index]) == null ? void 0 : (_oldNodes$index$paren3 = _oldNodes$index.parentNode) == null ? void 0 : _oldNodes$index$paren3.setAttribute(attribute.name, attribute.value); + } + } + if (Dom.getNodeType(node) !== Dom.getNodeType(oldNodes[index]) || !arraysMatch((_Object$keys = Object.keys((_oldNodes$index2 = oldNodes[index]) == null ? void 0 : _oldNodes$index2.attributes)) != null ? _Object$keys : [], Object.keys(node.attributes)) || ((_oldNodes$index3 = oldNodes[index]) == null ? void 0 : _oldNodes$index3.innerHTML) !== node.innerHTML) { var _newNodeClone2 = node.cloneNode(true); - oldNodes[index].parentNode.replaceChild(_newNodeClone2, oldNodes[index]); - initComponent(_newNodeClone2); + if (!oldNodes[index].parentNode) { + oldNodes[index].replaceWith(_newNodeClone2); + initComponent(_newNodeClone2); + } else { + oldNodes[index].parentNode.replaceChild(_newNodeClone2, oldNodes[index]); + initComponent(_newNodeClone2); + } continue; } // If content is different, update it diff --git a/client/dist/ui.cjs.development.js.map b/client/dist/ui.cjs.development.js.map index 08bfbe3..5ec7f41 100644 --- a/client/dist/ui.cjs.development.js.map +++ b/client/dist/ui.cjs.development.js.map @@ -1 +1 @@ -{"version":3,"file":"ui.cjs.development.js","sources":["../src/@types/core.ts","../src/utils/error.ts","../src/server/connection.ts","../src/utils/data.ts","../src/engine/dom.ts","../src/engine/compute.ts","../src/engine/compile.ts","../src/utils/lazy.ts","../src/core/directives/on.ts","../src/core/directives.ts","../src/engine/render.ts","../src/core/component.ts","../src/core/index.ts","../src/utils/reset.ts","../src/index.ts"],"sourcesContent":["export type Directives = Record void>;\n\nexport interface DirectiveProps {\n el: HTMLElement;\n parts: string[];\n data: DirectiveData;\n node?: UINode;\n}\n\nexport type KeyedEvent = KeyboardEvent | MouseEvent | TouchEvent;\n\nexport interface DirectiveData {\n compute: (event?: Event) => any;\n value: string;\n}\n\nexport interface UINode {\n directives: Record;\n el: HTMLElement;\n type: UINodeType;\n}\n\nexport enum UINodeType {\n NULL = -1,\n STATIC = 0,\n DYNAMIC = 1\n}\n\nexport interface LeafUIConfig {\n el: HTMLElement;\n data: Record;\n methods: string[];\n id: string;\n path: string;\n requestMethod: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD';\n component: string;\n}\n","export const error = (\n err: string,\n expression?: string,\n el?: HTMLElement\n): void => {\n let message = `LeafUI Error: \"${err}\"`;\n if (expression) message += `\\n\\nExpression: \"${expression}\"`;\n if (el) message += `\\nElement:`;\n console.warn(message, el);\n};\n","import Dom from './../engine/dom';\nimport { error } from './../utils/error';\n\nexport default class Connection {\n protected static headers: Record;\n\n public static connect(\n type: string,\n uiData: Record,\n dom: typeof Dom\n ) {\n const component: Element = uiData.element.closest('[ui-state]');\n const componentData = component.getAttribute('ui-state') ?? '{}';\n\n const payload = {\n type,\n payload: {\n params: [],\n method: uiData.method,\n methodArgs: uiData.methodArgs,\n data: componentData,\n }\n };\n\n return fetch(\n `${window.location.href}?_leaf_ui_config=${JSON.stringify(\n payload\n )}`,\n {\n method: uiData.config.method,\n // This enables \"cookies\".\n credentials: 'same-origin',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'text/html, application/xhtml+xml',\n 'X-Leaf-UI': 'true',\n\n // set Custom Headers\n ...this.headers,\n\n // We'll set this explicitly to mitigate potential interference from ad-blockers/etc.\n Referer: window.location.href\n }\n }\n ).then(async response => {\n if (response.ok) {\n response.text().then(response => {\n const data = JSON.parse(response);\n window._leafUIConfig.data = data.state;\n dom.diff(data.html, document.body!);\n });\n } else {\n error(await response.text().then(res => res));\n }\n });\n }\n}\n","import Component from './../core/component';\nimport { LeafUIConfig } from './../@types/core';\n\nexport const eventDirectivePrefixRE = (): RegExp => /on|@/gim;\nexport const rawDirectiveSplitRE = (): RegExp => /:|\\./gim;\n\nexport const hasDirectiveRE = (): RegExp => {\n return new RegExp(\n `(ui-|${Object.keys(DIRECTIVE_SHORTHANDS).join('|')})\\\\w+`,\n 'gim'\n );\n};\n\nexport const expressionPropRE = (prop: string): RegExp => {\n // Utilizes \\b (word boundary) for prop differentiation.\n // Fails when next character is a \\w (Word).\n return new RegExp(`\\\\b${prop}\\\\b`, 'gim');\n};\n\nexport enum DIRECTIVE_SHORTHANDS {\n '@' = 'on',\n ':' = 'bind'\n}\n\nexport function arraysMatch(a: any[], b: any[]) {\n return (\n Array.isArray(a) &&\n Array.isArray(b) &&\n a.length === b.length &&\n a.every((val, index) => val === b[index])\n );\n}\n\ndeclare global {\n interface Window {\n leafUI: {\n rootEl?: HTMLElement;\n component: Component;\n };\n _leafUIConfig: LeafUIConfig;\n }\n\n interface HTMLElement {\n component: Component;\n compile: () => void;\n }\n}\n\nwindow.leafUI = window.leafUI || {};\n","import { initComponent } from './../core/component';\nimport { arraysMatch } from './../utils/data';\n\nexport default class Dom {\n /**\n * Get the body of an HTML string\n *\n * @param html The html to parse\n * @param removeScripts Whether to remove scripts from the html\n * @returns The body of the html\n */\n public static getBody(\n html: string,\n removeScripts: boolean = false\n ): HTMLElement {\n const parser = new DOMParser();\n const dom = parser.parseFromString(html, 'text/html');\n\n if (removeScripts === true) {\n const scripts = dom.body.getElementsByTagName('script');\n\n for (let i = 0; i < scripts.length; i++) {\n scripts[i].remove();\n }\n }\n\n return dom.body;\n }\n\n /**\n * Get the type for a node\n * @param {HTMLElement} node The node\n * @return {String} The type\n */\n public static getNodeType(node: HTMLElement): string {\n if (node.nodeType === 3) return 'text';\n if (node.nodeType === 8) return 'comment';\n return node.tagName.toLowerCase();\n }\n\n /**\n * Get the content from a node\n * @param {Node} node The node\n * @return {String} The type\n */\n public static getNodeContent(node: HTMLElement) {\n if (node.children && node.children.length > 0) return null;\n return node.textContent;\n }\n\n /**\n * Diff the DOM from a string and an element\n *\n * @param newNode The new node\n * @param oldNode The old node\n * @returns The diffed node\n */\n public static diff(newNode: string, oldNode: HTMLElement): void {\n Dom.diffElements(Dom.getBody(newNode, false), oldNode);\n }\n\n /**\n * Diff the DOM from two elements\n *\n * @param newNode The new node\n * @param oldNode The old node\n * @returns The diffed node\n */\n public static diffElements(\n newNode: HTMLElement,\n oldNode: HTMLElement\n ): void {\n const newNodes = Array.prototype.slice.call(newNode.children);\n const oldNodes = Array.prototype.slice.call(oldNode.children);\n\n let count = oldNodes.length - newNodes.length;\n if (count > 0) {\n for (; count > 0; count--) {\n oldNodes[oldNodes.length - count].parentNode.removeChild(\n oldNodes[oldNodes.length - count]\n );\n }\n }\n\n for (let index = 0; index < newNodes.length; index++) {\n const node = newNodes[index];\n\n if (!oldNodes[index]) {\n const newNodeClone = node.cloneNode(true);\n oldNode.appendChild(newNodeClone);\n initComponent(newNodeClone);\n continue;\n }\n\n if (\n node instanceof HTMLScriptElement &&\n oldNodes[index] instanceof HTMLScriptElement\n ) {\n if (\n node.src !== oldNodes[index].src ||\n node.innerHTML !== oldNodes[index].innerHTML\n ) {\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n }\n\n continue;\n }\n\n if (\n Dom.getNodeType(node) !== Dom.getNodeType(oldNodes[index]) ||\n !arraysMatch(\n Object.keys(oldNodes[index]?.attributes) ?? [],\n Object.keys(node.attributes)\n ) ||\n oldNodes[index]?.innerHTML !== node.innerHTML\n ) {\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n initComponent(newNodeClone);\n continue;\n }\n\n // If content is different, update it\n const templateContent = Dom.getNodeContent(node);\n if (\n templateContent &&\n templateContent !== Dom.getNodeContent(oldNodes[index])\n ) {\n oldNodes[index].textContent = templateContent;\n }\n\n if (\n oldNodes[index].children.length > 0 &&\n node.children.length < 1\n ) {\n oldNodes[index].innerHTML = '';\n continue;\n }\n\n if (\n oldNodes[index].children.length < 1 &&\n node.children.length > 0\n ) {\n const fragment = document.createDocumentFragment();\n Dom.diffElements(node, fragment as any);\n oldNodes[index].appendChild(fragment);\n continue;\n }\n\n if (node.children.length > 0) {\n Dom.diffElements(node, oldNodes[index]);\n }\n }\n }\n}\n","import { error } from '../utils/error';\nimport Connection from './../server/connection';\nimport Dom from './dom';\n\nexport const compute = (\n expression: string,\n el?: HTMLElement,\n refs: Record = {}\n): ((event?: Event) => any) => {\n const specialPropertiesNames = ['$el', '$emit', '$event', '$refs', '$dom'];\n\n // This \"revives\" a function from a string, only using the new Function syntax once during compilation.\n // This is because raw function is ~50,000x faster than new Function\n const computeFunction = new Function(\n `return (${specialPropertiesNames.join(',')}) => {\n const method = ${JSON.stringify(expression)}.split('(')[0];\n const methodArgs = ${JSON.stringify(expression)}.substring(${JSON.stringify(expression)}.indexOf('(') + 1, ${JSON.stringify(expression)}.lastIndexOf(')'));\n\n if (!window._leafUIConfig.methods.includes(method)) {\n return error(new ReferenceError(method + ' is not defined'), method, $el);\n }\n\n (${\n Connection.connect\n })('callMethod', { element: $el, method, methodArgs, config: window._leafUIConfig }, $dom);\n }`\n )();\n\n const emit = (\n name: string,\n options?: CustomEventInit,\n dispatchGlobal = true\n ) => {\n const event = new CustomEvent(name, options);\n const target = dispatchGlobal ? window : el || window;\n\n target.dispatchEvent(event);\n };\n\n return (event?: Event) => {\n try {\n return computeFunction(el, emit, event, refs, Dom);\n } catch (err) {\n error(err as string, expression, el);\n }\n };\n};\n","import { DirectiveData, UINode, UINodeType } from '../@types/core';\nimport { compute } from './compute';\nimport { DIRECTIVE_SHORTHANDS } from '../utils/data';\n\nexport const flattenElementChildren = (\n rootElement: HTMLElement,\n ignoreRootElement = false\n): HTMLElement[] => {\n const collection: HTMLElement[] = [];\n\n if (!ignoreRootElement) {\n collection.push(rootElement);\n }\n\n for (const childElement of rootElement.children as any) {\n if (childElement instanceof HTMLElement) {\n collection.push(\n ...flattenElementChildren(\n childElement,\n childElement.attributes.length === 0\n )\n );\n }\n }\n\n return collection;\n};\n\nexport const collectRefs = (\n element: HTMLElement | Document = document\n): Record => {\n const refDirective = 'ui-ref';\n const refElements: NodeListOf = element.querySelectorAll(\n `[${refDirective}]`\n );\n const refs: Record = {};\n\n refElements.forEach(refElement => {\n const name = refElement.getAttribute(refDirective);\n\n if (name) {\n refs[name] = refElement;\n }\n });\n\n return refs;\n};\n\nexport const initDirectives = (\n el: HTMLElement\n): Record => {\n const directives: Record = {};\n const refs = collectRefs();\n\n // @ts-ignore\n for (const { name, value } of el.attributes) {\n const hasDirectivePrefix = name.startsWith('ui-');\n const hasDirectiveShorthandPrefix = Object.keys(\n DIRECTIVE_SHORTHANDS\n ).some(shorthand => name.startsWith(shorthand));\n\n if (!(hasDirectivePrefix || hasDirectiveShorthandPrefix)) {\n continue;\n }\n\n const directiveData = {\n compute: compute(value, el, refs),\n value\n };\n\n // Handle normal and shorthand directives=\n const directiveName = hasDirectivePrefix\n ? name.slice('ui-'.length)\n : // @ts-ignore\n `${DIRECTIVE_SHORTHANDS[name[0]]}:${name.slice(1)}`;\n\n directives[directiveName.toLowerCase()] = directiveData;\n }\n\n return directives;\n};\n\nexport const createASTNode = (el: HTMLElement): UINode | undefined => {\n const directives = initDirectives(el);\n const hasDirectives = Object.keys(directives).length > 0;\n const node = { el, directives, type: UINodeType.STATIC };\n\n return hasDirectives ? node : undefined;\n};\n\nexport const compile = (\n el: HTMLElement,\n ignoreRootElement = false\n): UINode[] => {\n const uiNodes: UINode[] = [];\n const elements = flattenElementChildren(el, ignoreRootElement);\n\n elements.forEach(element => {\n const newASTNode = createASTNode(element);\n\n if (newASTNode) {\n uiNodes.push(newASTNode);\n }\n });\n\n return uiNodes;\n};\n","/**\n * @author Aiden Bai \n * @package lucia\n */\n// Lazy allows us to delay render calls if the main thread is blocked\n// This is kind of like time slicing in React but less advanced\n// It's a generator function that yields after a certain amount of time\n// This allows the browser to render other things while the generator is running\n// It's a bit like a setTimeout but it's more accurate\n\nexport const lazy = (\n threshold: number,\n generatorFunction: () => Generator,\n): (() => void) => {\n const generator = generatorFunction();\n return function next() {\n const start = performance.now();\n let task = null;\n do {\n task = generator.next();\n } while (performance.now() - start < threshold && !task.done);\n\n if (task.done) return;\n setTimeout(next);\n };\n};\n\nexport default lazy;\n","import { DirectiveProps, KeyedEvent } from './../../@types/core';\n\nexport const onDirective = ({ el, parts, data }: DirectiveProps): void => {\n const options: Record = {};\n const globalScopeEventProps = ['outside', 'global'];\n const eventProps = parts.slice(2);\n const EVENT_REGISTERED_FLAG = `__on_${parts[1]}_registered`;\n\n // @ts-expect-error: We're adding a custom property to the element\n if (el[EVENT_REGISTERED_FLAG]) return;\n\n const target = globalScopeEventProps.some(prop =>\n String(eventProps).includes(prop)\n )\n ? window\n : el;\n\n const handler = (event: Event) => { \n if (eventProps.length > 0) {\n if (\n event instanceof KeyboardEvent &&\n /\\d/gim.test(String(eventProps))\n ) {\n const whitelistedKeycodes: number[] = [];\n eventProps.forEach(eventProp => {\n // @ts-expect-error: eventProp can be a string, but isNaN only accepts number\n if (!isNaN(eventProp)) {\n whitelistedKeycodes.push(Number(eventProp));\n }\n });\n\n if (!whitelistedKeycodes.includes(event.keyCode)) return;\n }\n\n // Parse event modifiers based on directive prop\n if (eventProps.includes('prevent')) event.preventDefault();\n if (eventProps.includes('stop')) event.stopPropagation();\n if (eventProps.includes('self')) {\n if (event.target !== el) return;\n }\n /* istanbul ignore next */\n if (eventProps.includes('outside')) {\n if (el.contains(event.target as Node)) return;\n if (el.offsetWidth < 1 && el.offsetHeight < 1) return;\n }\n\n if (eventProps.includes('enter') || eventProps.includes('meta')) {\n if ((event as KeyboardEvent).key === 'Enter') {\n data.compute(event);\n }\n }\n\n if (\n (eventProps.includes('ctrl') &&\n (event as KeyedEvent).ctrlKey) ||\n (eventProps.includes('alt') && (event as KeyedEvent).altKey) ||\n (eventProps.includes('shift') &&\n (event as KeyedEvent).shiftKey) ||\n (eventProps.includes('left') &&\n 'button' in event &&\n (event as MouseEvent).button === 0) ||\n (eventProps.includes('middle') &&\n 'button' in event &&\n (event as MouseEvent).button === 1) ||\n (eventProps.includes('right') &&\n 'button' in event &&\n (event as MouseEvent).button === 2)\n ) {\n data.compute(event);\n }\n } else {\n data.compute(event);\n }\n };\n\n options.once = eventProps.includes('once');\n options.passive = eventProps.includes('passive');\n\n target.addEventListener(parts[1], handler, options);\n\n // @ts-expect-error: We're adding a custom property to the element\n el[EVENT_REGISTERED_FLAG] = true;\n};\n","import { DirectiveProps, Directives } from './../@types/core';\n// import { bindDirective } from './directives/bind';\n// import { modelDirective } from './directives/model';\nimport { onDirective } from './directives/on';\n\nexport const directives: Directives = {\n // BIND: bindDirective,\n // MODEL: modelDirective,\n ON: onDirective,\n};\n\nexport const renderDirective = (\n props: DirectiveProps,\n directives: Directives\n): void => {\n directives[props.parts[0].toUpperCase()](props);\n};\n","import lazy from './../utils/lazy';\nimport { renderDirective } from './../core/directives';\nimport { rawDirectiveSplitRE } from './../utils/data';\nimport { Directives, UINode, UINodeType } from './../@types/core';\n\nconst render = (\n uiNodes: UINode[],\n directives: Directives,\n): void => {\n const legalDirectiveNames = Object.keys(directives);\n const LAZY_MODE_TIMEOUT = 25;\n\n lazy(LAZY_MODE_TIMEOUT, function*() {\n for (const node of uiNodes) {\n if (node.type === UINodeType.NULL) continue;\n const isStatic = node.type === UINodeType.STATIC;\n if (isStatic) node.type = UINodeType.NULL;\n yield;\n\n if (!isStatic) continue;\n\n for (const [directiveName, directiveData] of Object.entries(\n node.directives\n )) {\n const rawDirectiveName = directiveName.split(\n rawDirectiveSplitRE()\n )[0];\n\n if (\n !legalDirectiveNames.includes(\n rawDirectiveName.toUpperCase()\n )\n )\n continue;\n yield;\n\n // If affected, then push to render queue\n if (isStatic) {\n const directiveProps = {\n el: node.el,\n parts: directiveName.split(rawDirectiveSplitRE()),\n data: directiveData,\n node,\n };\n\n renderDirective(directiveProps, directives);\n\n // [TODO] Remove this after testing\n delete node.directives[directiveName];\n }\n }\n }\n })();\n};\n\nexport default render;\n","import { UINode } from './../@types/core';\nimport { compile } from '../engine/compile';\nimport render from '../engine/render';\nimport { directives } from './directives';\n\nexport default class Component {\n public uiNodes: UINode[] = [];\n\n constructor() {\n this.uiNodes = [];\n }\n\n public mount(el: HTMLElement | string) {\n const rootEl =\n el instanceof HTMLElement\n ? el\n : document.querySelector(el) || document.body;\n\n this.uiNodes = compile(rootEl);\n this.render();\n rootEl['component'] = this;\n\n window.leafUI = {\n rootEl,\n component: this\n };\n\n return this;\n }\n\n /**\n * Force renders the DOM based on props\n * @param {string[]=} props - Array of root level properties in state\n * @returns {undefined}\n */\n public render() {\n render(this.uiNodes, directives);\n }\n}\n\nexport const initComponent = (element: Element) =>\n new Component().mount(element as HTMLElement);\n","import Component from './component';\n\n/**\n * Initialize Your Leaf UI root component\n * @param {HTMLElement|Document} element - Root element to find uninitialized components\n */\nexport const init = (element: HTMLElement | Document = document): void => {\n const leafUI = new Component();\n const rootElement = element instanceof Document ? element.body : element;\n\n leafUI.mount(rootElement);\n};\n","/**\n * @author Caleb Porzio\n * @package livewire/livewire\n */\nexport function monkeyPatchDomSetAttributeToAllowAtSymbols() {\n // Because morphdom may add attributes to elements containing \"@\" symbols\n // like in the case of an Alpine `@click` directive, we have to patch\n // the standard Element.setAttribute method to allow this to work.\n let original = Element.prototype.setAttribute;\n\n let hostDiv = document.createElement('div');\n\n Element.prototype.setAttribute = function newSetAttribute(name, value) {\n if (!name.includes('@')) {\n return original.call(this, name, value);\n }\n\n hostDiv.innerHTML = ``;\n\n let attr = (hostDiv.firstElementChild)!.getAttributeNode(name)!;\n\n (hostDiv.firstElementChild)!.removeAttributeNode(attr);\n\n this.setAttributeNode(attr);\n };\n}\n","import { init } from './core';\nimport { monkeyPatchDomSetAttributeToAllowAtSymbols } from './utils/reset';\nexport * from './@types';\n\ndocument.addEventListener('DOMContentLoaded', () => {\n monkeyPatchDomSetAttributeToAllowAtSymbols();\n init();\n\n document.querySelectorAll('[ui-lazy]').forEach(el => {\n el.removeAttribute('ui-lazy');\n });\n});\n"],"names":["UINodeType","error","err","expression","el","message","console","warn","Connection","connect","type","uiData","dom","component","element","closest","componentData","getAttribute","payload","params","method","methodArgs","data","fetch","window","location","href","JSON","stringify","config","credentials","headers","Accept","Referer","then","response","ok","text","parse","_leafUIConfig","state","diff","html","document","body","res","rawDirectiveSplitRE","DIRECTIVE_SHORTHANDS","arraysMatch","a","b","Array","isArray","length","every","val","index","leafUI","Dom","getBody","removeScripts","parser","DOMParser","parseFromString","scripts","getElementsByTagName","i","remove","getNodeType","node","nodeType","tagName","toLowerCase","getNodeContent","children","textContent","newNode","oldNode","diffElements","newNodes","prototype","slice","call","oldNodes","count","parentNode","removeChild","newNodeClone","cloneNode","appendChild","initComponent","HTMLScriptElement","src","innerHTML","replaceChild","Object","keys","attributes","templateContent","fragment","createDocumentFragment","compute","refs","specialPropertiesNames","computeFunction","Function","join","emit","name","options","dispatchGlobal","event","CustomEvent","target","dispatchEvent","flattenElementChildren","rootElement","ignoreRootElement","collection","push","childElement","HTMLElement","collectRefs","refDirective","refElements","querySelectorAll","forEach","refElement","initDirectives","directives","value","hasDirectivePrefix","startsWith","hasDirectiveShorthandPrefix","some","shorthand","directiveData","directiveName","createASTNode","hasDirectives","STATIC","undefined","compile","uiNodes","elements","newASTNode","lazy","threshold","generatorFunction","generator","next","start","performance","now","task","done","setTimeout","onDirective","parts","globalScopeEventProps","eventProps","EVENT_REGISTERED_FLAG","prop","String","includes","handler","KeyboardEvent","test","whitelistedKeycodes","eventProp","isNaN","Number","keyCode","preventDefault","stopPropagation","contains","offsetWidth","offsetHeight","key","ctrlKey","altKey","shiftKey","button","once","passive","addEventListener","ON","renderDirective","props","toUpperCase","render","legalDirectiveNames","LAZY_MODE_TIMEOUT","NULL","isStatic","entries","rawDirectiveName","split","directiveProps","Component","mount","rootEl","querySelector","init","Document","monkeyPatchDomSetAttributeToAllowAtSymbols","original","Element","setAttribute","hostDiv","createElement","newSetAttribute","attr","firstElementChild","getAttributeNode","removeAttributeNode","setAttributeNode","removeAttribute"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,IAAYA,UAIX;AAJD,WAAYA,UAAU;EAClBA,4CAAS;EACTA,+CAAU;EACVA,iDAAW;AACf,CAAC,EAJWA,UAAU,KAAVA,UAAU;;ACtBf,IAAMC,KAAK,GAAG,SAARA,KAAK,CACdC,GAAW,EACXC,UAAmB,EACnBC,EAAgB;EAEhB,IAAIC,OAAO,wBAAqBH,GAAG,OAAG;EACtC,IAAIC,UAAU,EAAEE,OAAO,2BAAwBF,UAAU,OAAG;EAC5D,IAAIC,EAAE,EAAEC,OAAO,gBAAgB;EAC/BC,OAAO,CAACC,IAAI,CAACF,OAAO,EAAED,EAAE,CAAC;A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AAgByF,0CAA0C;;;;EAItD,IAAIC,QAAQ,GAAGC,OAAO,CAAC/H,SAAS,CAACgI,YAAY;EAE7C,IAAIC,OAAO,GAAGtK,QAAQ,CAACuK,aAAa,CAAC,KAAK,CAAC;EAE3CH,OAAO,CAAC/H,SAAS,CAACgI,YAAY,GAAG,SAASG,eAAe,CAACvG,IAAI,EAAEsB,KAAK;IACjE,IAAI,CAACtB,IAAI,CAACwD,QAAQ,CAAC,GAAG,CAAC,EAAE;MACrB,OAAO0C,QAAQ,CAAC5H,IAAI,CAAC,IAAI,EAAE0B,IAAI,EAAEsB,KAAK,CAAC;;IAG3C+E,OAAO,CAACpH,SAAS,cAAYe,IAAI,WAAKsB,KAAK,eAAW;IAEtD,IAAIkF,IAAI,GAAIH,OAAO,CAACI,iBAAiB,CAAGC,gBAAgB,CAAC1G,IAAI,CAAE;IAE9DqG,OAAO,CAACI,iBAAiB,CAAGE,mBAAmB,CAACH,IAAI,CAAC;IAEtD,IAAI,CAACI,gBAAgB,CAACJ,IAAI,CAAC;GAC9B;AACL;;ACrBAzK,QAAQ,CAAC8I,gBAAgB,CAAC,kBAAkB,EAAE;EAC1CoB,0CAA0C,EAAE;EAC5CF,IAAI,EAAE;EAENhK,QAAQ,CAACkF,gBAAgB,CAAC,WAAW,CAAC,CAACC,OAAO,CAAC,UAAA1H,EAAE;IAC7CA,EAAE,CAACqN,eAAe,CAAC,SAAS,CAAC;GAChC,CAAC;AACN,CAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"ui.cjs.development.js","sources":["../src/@types/core.ts","../src/utils/error.ts","../src/server/connection.ts","../src/utils/data.ts","../src/engine/dom.ts","../src/engine/compute.ts","../src/engine/compile.ts","../src/utils/lazy.ts","../src/core/directives/on.ts","../src/core/directives.ts","../src/engine/render.ts","../src/core/component.ts","../src/core/index.ts","../src/utils/reset.ts","../src/index.ts"],"sourcesContent":["export type Directives = Record void>;\n\nexport interface DirectiveProps {\n el: HTMLElement;\n parts: string[];\n data: DirectiveData;\n node?: UINode;\n}\n\nexport type KeyedEvent = KeyboardEvent | MouseEvent | TouchEvent;\n\nexport interface DirectiveData {\n compute: (event?: Event) => any;\n value: string;\n}\n\nexport interface UINode {\n directives: Record;\n el: HTMLElement;\n type: UINodeType;\n}\n\nexport enum UINodeType {\n NULL = -1,\n STATIC = 0,\n DYNAMIC = 1\n}\n\nexport interface LeafUIConfig {\n el: HTMLElement;\n data: Record;\n methods: string[];\n id: string;\n path: string;\n requestMethod: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD';\n component: string;\n}\n","export const error = (\n err: string,\n expression?: string,\n el?: HTMLElement\n): void => {\n let message = `LeafUI Error: \"${err}\"`;\n if (expression) message += `\\n\\nExpression: \"${expression}\"`;\n if (el) message += `\\nElement:`;\n console.warn(message, el);\n};\n","import Dom from './../engine/dom';\nimport { error } from './../utils/error';\n\nexport default class Connection {\n protected static headers: Record;\n\n public static connect(\n type: string,\n uiData: Record,\n dom: typeof Dom\n ) {\n const pageState: Record = {};\n const component: HTMLElement = uiData.element.closest('[ui-state]');\n const componentData = JSON.parse(component?.getAttribute('ui-state') ?? '{}');\n const components = document.querySelectorAll('[ui-state]');\n\n components.forEach((i) => {\n const attr = JSON.parse(i.getAttribute('ui-state') ?? '{}');\n pageState[attr.key] = attr;\n });\n\n const payload = {\n type,\n payload: {\n params: [],\n method: uiData.method,\n methodArgs: uiData.methodArgs,\n component: componentData?.key,\n data: pageState,\n }\n };\n\n return fetch(\n `${window.location.href}?_leaf_ui_config=${JSON.stringify(\n payload\n )}`,\n {\n method: uiData.config.method,\n // This enables \"cookies\".\n credentials: 'same-origin',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'text/html, application/xhtml+xml',\n 'X-Leaf-UI': 'true',\n\n // set Custom Headers\n ...this.headers,\n\n // We'll set this explicitly to mitigate potential interference from ad-blockers/etc.\n Referer: window.location.href\n }\n }\n ).then(async response => {\n if (response.ok) {\n response.text().then(response => {\n const data = JSON.parse(response);\n window._leafUIConfig.data = data.state;\n dom.diff(\n data.html,\n component.nodeName === 'HTML' || !component\n ? document.body!\n : component\n );\n });\n } else {\n error(await response.text().then(res => res));\n }\n });\n }\n}\n","import Component from './../core/component';\nimport { LeafUIConfig } from './../@types/core';\n\nexport const eventDirectivePrefixRE = (): RegExp => /on|@/gim;\nexport const rawDirectiveSplitRE = (): RegExp => /:|\\./gim;\n\nexport const hasDirectiveRE = (): RegExp => {\n return new RegExp(\n `(ui-|${Object.keys(DIRECTIVE_SHORTHANDS).join('|')})\\\\w+`,\n 'gim'\n );\n};\n\nexport const expressionPropRE = (prop: string): RegExp => {\n // Utilizes \\b (word boundary) for prop differentiation.\n // Fails when next character is a \\w (Word).\n return new RegExp(`\\\\b${prop}\\\\b`, 'gim');\n};\n\nexport enum DIRECTIVE_SHORTHANDS {\n '@' = 'on',\n ':' = 'bind'\n}\n\nexport function arraysMatch(a: any[], b: any[]) {\n return (\n Array.isArray(a) &&\n Array.isArray(b) &&\n a.length === b.length &&\n a.every((val, index) => val === b[index])\n );\n}\n\ndeclare global {\n interface Window {\n leafUI: {\n rootEl?: HTMLElement;\n component: Component;\n };\n _leafUIConfig: LeafUIConfig;\n }\n\n interface HTMLElement {\n component: Component;\n compile: () => void;\n }\n}\n\nwindow.leafUI = window.leafUI || {};\n","import { initComponent } from './../core/component';\nimport { arraysMatch } from './../utils/data';\n\nexport default class Dom {\n /**\n * Get the body of an HTML string\n *\n * @param html The html to parse\n * @param removeScripts Whether to remove scripts from the html\n * @returns The body of the html\n */\n public static getBody(\n html: string,\n removeScripts: boolean = false\n ): HTMLElement {\n const parser = new DOMParser();\n const dom = parser.parseFromString(html, 'text/html');\n\n if (removeScripts === true) {\n const scripts = dom.body.getElementsByTagName('script');\n\n for (let i = 0; i < scripts.length; i++) {\n scripts[i].remove();\n }\n }\n\n return dom.body;\n }\n\n /**\n * Wrap DOM node with a template element\n */\n public static wrap(node: Node): HTMLElement {\n const wrapper = document.createElement('x-leafui-wrapper');\n wrapper.appendChild(node);\n return wrapper;\n }\n\n /**\n * Parse string to DOM\n *\n * @param html The html to parse\n */\n public static parse(html: string): HTMLElement {\n const parser = new DOMParser();\n const dom = parser.parseFromString(html, 'text/html');\n\n return dom.getRootNode().firstChild as HTMLElement;\n }\n\n /**\n * Get the type for a node\n * @param {HTMLElement} node The node\n * @return {String} The type\n */\n public static getNodeType(node: HTMLElement): string {\n if (node.nodeType === 3) return 'text';\n if (node.nodeType === 8) return 'comment';\n return node.tagName.toLowerCase();\n }\n\n /**\n * Get the content from a node\n * @param {Node} node The node\n * @return {String} The type\n */\n public static getNodeContent(node: HTMLElement) {\n if (node.children && node.children.length > 0) return null;\n return node.textContent;\n }\n\n /**\n * Diff the DOM from a string and an element\n *\n * @param newNode The new node\n * @param oldNode The old node\n * @returns The diffed node\n */\n public static diff(newNode: string, oldNode: HTMLElement): void {\n const structuredNewNode =\n oldNode.nodeName === 'BODY'\n ? Dom.getBody(newNode, false)\n : Dom.getBody(newNode, true).children[0];\n const structuredOldNode = oldNode;\n\n Dom.diffElements(structuredNewNode as HTMLElement, structuredOldNode);\n }\n\n /**\n * Diff the DOM from two elements\n *\n * @param newNode The new node\n * @param oldNode The old node\n * @returns The diffed node\n */\n public static diffElements(\n newNode: HTMLElement,\n oldNode: HTMLElement\n ): void {\n const newNodes = Array.prototype.slice.call(newNode.children);\n const oldNodes = Array.prototype.slice.call(oldNode.children);\n\n let count = oldNodes.length - newNodes.length;\n\n if (count > 0) {\n for (; count > 0; count--) {\n oldNodes[oldNodes.length - count].parentNode.removeChild(\n oldNodes[oldNodes.length - count]\n );\n }\n }\n\n for (let index = 0; index < newNodes.length; index++) {\n const node = newNodes[index];\n\n if (!oldNodes[index]) {\n const newNodeClone = node.cloneNode(true);\n oldNode.appendChild(newNodeClone);\n initComponent(newNodeClone);\n continue;\n }\n\n if (\n node instanceof HTMLScriptElement &&\n oldNodes[index] instanceof HTMLScriptElement\n ) {\n if (\n node.src !== oldNodes[index].src ||\n node.innerHTML !== oldNodes[index].innerHTML\n ) {\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n }\n\n continue;\n }\n\n if (\n !arraysMatch(\n Object.values(node.parentNode?.attributes ?? {}),\n Object.values(oldNodes[index].parentNode?.attributes ?? {})\n )\n ) {\n for (\n let nIndex = 0;\n nIndex < node.parentNode.attributes?.length;\n nIndex++\n ) {\n const attribute = node.parentNode.attributes[nIndex];\n oldNodes[index]?.parentNode?.setAttribute(\n attribute.name,\n attribute.value\n );\n }\n }\n\n if (\n Dom.getNodeType(node) !== Dom.getNodeType(oldNodes[index]) ||\n !arraysMatch(\n Object.keys(oldNodes[index]?.attributes) ?? [],\n Object.keys(node.attributes)\n ) ||\n oldNodes[index]?.innerHTML !== node.innerHTML\n ) {\n const newNodeClone = node.cloneNode(true);\n\n if (!oldNodes[index].parentNode) {\n oldNodes[index].replaceWith(newNodeClone);\n initComponent(newNodeClone);\n } else {\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n initComponent(newNodeClone);\n }\n\n continue;\n }\n\n // If content is different, update it\n const templateContent = Dom.getNodeContent(node);\n if (\n templateContent &&\n templateContent !== Dom.getNodeContent(oldNodes[index])\n ) {\n oldNodes[index].textContent = templateContent;\n }\n\n if (\n oldNodes[index].children.length > 0 &&\n node.children.length < 1\n ) {\n oldNodes[index].innerHTML = '';\n continue;\n }\n\n if (\n oldNodes[index].children.length < 1 &&\n node.children.length > 0\n ) {\n const fragment = document.createDocumentFragment();\n Dom.diffElements(node, fragment as any);\n oldNodes[index].appendChild(fragment);\n continue;\n }\n\n if (node.children.length > 0) {\n Dom.diffElements(node, oldNodes[index]);\n }\n }\n }\n}\n","import { error } from '../utils/error';\nimport Connection from './../server/connection';\nimport Dom from './dom';\n\nexport const compute = (\n expression: string,\n el?: HTMLElement,\n refs: Record = {}\n): ((event?: Event) => any) => {\n const specialPropertiesNames = ['$el', '$emit', '$event', '$refs', '$dom'];\n\n // This \"revives\" a function from a string, only using the new Function syntax once during compilation.\n // This is because raw function is ~50,000x faster than new Function\n const computeFunction = new Function(\n `return (${specialPropertiesNames.join(',')}) => {\n const method = ${JSON.stringify(expression)}.split('(')[0];\n const methodArgs = ${JSON.stringify(expression)}.substring(${JSON.stringify(expression)}.indexOf('(') + 1, ${JSON.stringify(expression)}.lastIndexOf(')'));\n\n if (!window._leafUIConfig.methods.includes(method)) {\n return error(new ReferenceError(method + ' is not defined'), method, $el);\n }\n\n (${\n Connection.connect\n })('callMethod', { element: $el, method, methodArgs, config: window._leafUIConfig }, $dom);\n }`\n )();\n\n const emit = (\n name: string,\n options?: CustomEventInit,\n dispatchGlobal = true\n ) => {\n const event = new CustomEvent(name, options);\n const target = dispatchGlobal ? window : el || window;\n\n target.dispatchEvent(event);\n };\n\n return (event?: Event) => {\n try {\n return computeFunction(el, emit, event, refs, Dom);\n } catch (err) {\n error(err as string, expression, el);\n }\n };\n};\n","import { DirectiveData, UINode, UINodeType } from '../@types/core';\nimport { compute } from './compute';\nimport { DIRECTIVE_SHORTHANDS } from '../utils/data';\n\nexport const flattenElementChildren = (\n rootElement: HTMLElement,\n ignoreRootElement = false\n): HTMLElement[] => {\n const collection: HTMLElement[] = [];\n\n if (!ignoreRootElement) {\n collection.push(rootElement);\n }\n\n for (const childElement of rootElement.children as any) {\n if (childElement instanceof HTMLElement) {\n collection.push(\n ...flattenElementChildren(\n childElement,\n childElement.attributes.length === 0\n )\n );\n }\n }\n\n return collection;\n};\n\nexport const collectRefs = (\n element: HTMLElement | Document = document\n): Record => {\n const refDirective = 'ui-ref';\n const refElements: NodeListOf = element.querySelectorAll(\n `[${refDirective}]`\n );\n const refs: Record = {};\n\n refElements.forEach(refElement => {\n const name = refElement.getAttribute(refDirective);\n\n if (name) {\n refs[name] = refElement;\n }\n });\n\n return refs;\n};\n\nexport const initDirectives = (\n el: HTMLElement\n): Record => {\n const directives: Record = {};\n const refs = collectRefs();\n\n // @ts-ignore\n for (const { name, value } of el.attributes) {\n const hasDirectivePrefix = name.startsWith('ui-');\n const hasDirectiveShorthandPrefix = Object.keys(\n DIRECTIVE_SHORTHANDS\n ).some(shorthand => name.startsWith(shorthand));\n\n if (!(hasDirectivePrefix || hasDirectiveShorthandPrefix)) {\n continue;\n }\n\n const directiveData = {\n compute: compute(value, el, refs),\n value\n };\n\n // Handle normal and shorthand directives=\n const directiveName = hasDirectivePrefix\n ? name.slice('ui-'.length)\n : // @ts-ignore\n `${DIRECTIVE_SHORTHANDS[name[0]]}:${name.slice(1)}`;\n\n directives[directiveName.toLowerCase()] = directiveData;\n }\n\n return directives;\n};\n\nexport const createASTNode = (el: HTMLElement): UINode | undefined => {\n const directives = initDirectives(el);\n const hasDirectives = Object.keys(directives).length > 0;\n const node = { el, directives, type: UINodeType.STATIC };\n\n return hasDirectives ? node : undefined;\n};\n\nexport const compile = (\n el: HTMLElement,\n ignoreRootElement = false\n): UINode[] => {\n const uiNodes: UINode[] = [];\n const elements = flattenElementChildren(el, ignoreRootElement);\n\n elements.forEach(element => {\n const newASTNode = createASTNode(element);\n\n if (newASTNode) {\n uiNodes.push(newASTNode);\n }\n });\n\n return uiNodes;\n};\n","/**\n * @author Aiden Bai \n * @package lucia\n */\n// Lazy allows us to delay render calls if the main thread is blocked\n// This is kind of like time slicing in React but less advanced\n// It's a generator function that yields after a certain amount of time\n// This allows the browser to render other things while the generator is running\n// It's a bit like a setTimeout but it's more accurate\n\nexport const lazy = (\n threshold: number,\n generatorFunction: () => Generator,\n): (() => void) => {\n const generator = generatorFunction();\n return function next() {\n const start = performance.now();\n let task = null;\n do {\n task = generator.next();\n } while (performance.now() - start < threshold && !task.done);\n\n if (task.done) return;\n setTimeout(next);\n };\n};\n\nexport default lazy;\n","import { DirectiveProps, KeyedEvent } from './../../@types/core';\n\nexport const onDirective = ({ el, parts, data }: DirectiveProps): void => {\n const options: Record = {};\n const globalScopeEventProps = ['outside', 'global'];\n const eventProps = parts.slice(2);\n const EVENT_REGISTERED_FLAG = `__on_${parts[1]}_registered`;\n\n // @ts-expect-error: We're adding a custom property to the element\n if (el[EVENT_REGISTERED_FLAG]) return;\n\n const target = globalScopeEventProps.some(prop =>\n String(eventProps).includes(prop)\n )\n ? window\n : el;\n\n const handler = (event: Event) => { \n if (eventProps.length > 0) {\n if (\n event instanceof KeyboardEvent &&\n /\\d/gim.test(String(eventProps))\n ) {\n const whitelistedKeycodes: number[] = [];\n eventProps.forEach(eventProp => {\n // @ts-expect-error: eventProp can be a string, but isNaN only accepts number\n if (!isNaN(eventProp)) {\n whitelistedKeycodes.push(Number(eventProp));\n }\n });\n\n if (!whitelistedKeycodes.includes(event.keyCode)) return;\n }\n\n // Parse event modifiers based on directive prop\n if (eventProps.includes('prevent')) event.preventDefault();\n if (eventProps.includes('stop')) event.stopPropagation();\n if (eventProps.includes('self')) {\n if (event.target !== el) return;\n }\n /* istanbul ignore next */\n if (eventProps.includes('outside')) {\n if (el.contains(event.target as Node)) return;\n if (el.offsetWidth < 1 && el.offsetHeight < 1) return;\n }\n\n if (eventProps.includes('enter') || eventProps.includes('meta')) {\n if ((event as KeyboardEvent).key === 'Enter') {\n data.compute(event);\n }\n }\n\n if (\n (eventProps.includes('ctrl') &&\n (event as KeyedEvent).ctrlKey) ||\n (eventProps.includes('alt') && (event as KeyedEvent).altKey) ||\n (eventProps.includes('shift') &&\n (event as KeyedEvent).shiftKey) ||\n (eventProps.includes('left') &&\n 'button' in event &&\n (event as MouseEvent).button === 0) ||\n (eventProps.includes('middle') &&\n 'button' in event &&\n (event as MouseEvent).button === 1) ||\n (eventProps.includes('right') &&\n 'button' in event &&\n (event as MouseEvent).button === 2)\n ) {\n data.compute(event);\n }\n } else {\n data.compute(event);\n }\n };\n\n options.once = eventProps.includes('once');\n options.passive = eventProps.includes('passive');\n\n target.addEventListener(parts[1], handler, options);\n\n // @ts-expect-error: We're adding a custom property to the element\n el[EVENT_REGISTERED_FLAG] = true;\n};\n","import { DirectiveProps, Directives } from './../@types/core';\n// import { bindDirective } from './directives/bind';\n// import { modelDirective } from './directives/model';\nimport { onDirective } from './directives/on';\n\nexport const directives: Directives = {\n // BIND: bindDirective,\n // MODEL: modelDirective,\n ON: onDirective,\n};\n\nexport const renderDirective = (\n props: DirectiveProps,\n directives: Directives\n): void => {\n directives[props.parts[0].toUpperCase()](props);\n};\n","import lazy from './../utils/lazy';\nimport { renderDirective } from './../core/directives';\nimport { rawDirectiveSplitRE } from './../utils/data';\nimport { Directives, UINode, UINodeType } from './../@types/core';\n\nconst render = (\n uiNodes: UINode[],\n directives: Directives,\n): void => {\n const legalDirectiveNames = Object.keys(directives);\n const LAZY_MODE_TIMEOUT = 25;\n\n lazy(LAZY_MODE_TIMEOUT, function*() {\n for (const node of uiNodes) {\n if (node.type === UINodeType.NULL) continue;\n const isStatic = node.type === UINodeType.STATIC;\n if (isStatic) node.type = UINodeType.NULL;\n yield;\n\n if (!isStatic) continue;\n\n for (const [directiveName, directiveData] of Object.entries(\n node.directives\n )) {\n const rawDirectiveName = directiveName.split(\n rawDirectiveSplitRE()\n )[0];\n\n if (\n !legalDirectiveNames.includes(\n rawDirectiveName.toUpperCase()\n )\n )\n continue;\n yield;\n\n // If affected, then push to render queue\n if (isStatic) {\n const directiveProps = {\n el: node.el,\n parts: directiveName.split(rawDirectiveSplitRE()),\n data: directiveData,\n node,\n };\n\n renderDirective(directiveProps, directives);\n\n // [TODO] Remove this after testing\n delete node.directives[directiveName];\n }\n }\n }\n })();\n};\n\nexport default render;\n","import { UINode } from './../@types/core';\nimport { compile } from '../engine/compile';\nimport render from '../engine/render';\nimport { directives } from './directives';\n\nexport default class Component {\n public uiNodes: UINode[] = [];\n\n constructor() {\n this.uiNodes = [];\n }\n\n public mount(el: HTMLElement | string) {\n const rootEl =\n el instanceof HTMLElement\n ? el\n : document.querySelector(el) || document.body;\n\n this.uiNodes = compile(rootEl);\n this.render();\n rootEl['component'] = this;\n\n window.leafUI = {\n rootEl,\n component: this\n };\n\n return this;\n }\n\n /**\n * Force renders the DOM based on props\n * @param {string[]=} props - Array of root level properties in state\n * @returns {undefined}\n */\n public render() {\n render(this.uiNodes, directives);\n }\n}\n\nexport const initComponent = (element: Element) =>\n new Component().mount(element as HTMLElement);\n","import Component from './component';\n\n/**\n * Initialize Your Leaf UI root component\n * @param {HTMLElement|Document} element - Root element to find uninitialized components\n */\nexport const init = (element: HTMLElement | Document = document): void => {\n const leafUI = new Component();\n const rootElement = element instanceof Document ? element.body : element;\n\n leafUI.mount(rootElement);\n};\n","/**\n * @author Caleb Porzio\n * @package livewire/livewire\n */\nexport function monkeyPatchDomSetAttributeToAllowAtSymbols() {\n // Because morphdom may add attributes to elements containing \"@\" symbols\n // like in the case of an Alpine `@click` directive, we have to patch\n // the standard Element.setAttribute method to allow this to work.\n let original = Element.prototype.setAttribute;\n\n let hostDiv = document.createElement('div');\n\n Element.prototype.setAttribute = function newSetAttribute(name, value) {\n if (!name.includes('@')) {\n return original.call(this, name, value);\n }\n\n hostDiv.innerHTML = ``;\n\n let attr = (hostDiv.firstElementChild)!.getAttributeNode(name)!;\n\n (hostDiv.firstElementChild)!.removeAttributeNode(attr);\n\n this.setAttributeNode(attr);\n };\n}\n","import { init } from './core';\nimport { monkeyPatchDomSetAttributeToAllowAtSymbols } from './utils/reset';\nexport * from './@types';\n\ndocument.addEventListener('DOMContentLoaded', () => {\n monkeyPatchDomSetAttributeToAllowAtSymbols();\n init();\n\n document.querySelectorAll('[ui-lazy]').forEach(el => {\n el.removeAttribute('ui-lazy');\n });\n});\n"],"names":["UINodeType","error","err","expression","el","message","console","warn","Connection","connect","type","uiData","dom","pageState","component","element","closest","componentData","JSON","parse","getAttribute","components","document","querySelectorAll","forEach","i","attr","key","payload","params","method","methodArgs","data","fetch","window","location","href","stringify","config","credentials","headers","Accept","Referer","then","response","ok","text","_leafUIConfig","state","diff","html","nodeName","body","res","rawDirectiveSplitRE","DIRECTIVE_SHORTHANDS","arraysMatch","a","b","Array","isArray","length","every","val","index","leafUI","Dom","getBody","removeScripts","parser","DOMParser","parseFromString","scripts","getElementsByTagName","remove","wrap","node","wrapper","createElement","appendChild","getRootNode","firstChild","getNodeType","nodeType","tagName","toLowerCase","getNodeContent","children","textContent","newNode","oldNode","structuredNewNode","structuredOldNode","diffElements","newNodes","prototype","slice","call","oldNodes","count","parentNode","removeChild","newNodeClone","cloneNode","initComponent","HTMLScriptElement","src","innerHTML","replaceChild","Object","values","attributes","nIndex","attribute","setAttribute","name","value","keys","replaceWith","templateContent","fragment","createDocumentFragment","compute","refs","specialPropertiesNames","computeFunction","Function","join","emit","options","dispatchGlobal","event","CustomEvent","target","dispatchEvent","flattenElementChildren","rootElement","ignoreRootElement","collection","push","childElement","HTMLElement","collectRefs","refDirective","refElements","refElement","initDirectives","directives","hasDirectivePrefix","startsWith","hasDirectiveShorthandPrefix","some","shorthand","directiveData","directiveName","createASTNode","hasDirectives","STATIC","undefined","compile","uiNodes","elements","newASTNode","lazy","threshold","generatorFunction","generator","next","start","performance","now","task","done","setTimeout","onDirective","parts","globalScopeEventProps","eventProps","EVENT_REGISTERED_FLAG","prop","String","includes","handler","KeyboardEvent","test","whitelistedKeycodes","eventProp","isNaN","Number","keyCode","preventDefault","stopPropagation","contains","offsetWidth","offsetHeight","ctrlKey","altKey","shiftKey","button","once","passive","addEventListener","ON","renderDirective","props","toUpperCase","render","legalDirectiveNames","LAZY_MODE_TIMEOUT","NULL","isStatic","entries","rawDirectiveName","split","directiveProps","Component","mount","rootEl","querySelector","init","Document","monkeyPatchDomSetAttributeToAllowAtSymbols","original","Element","hostDiv","newSetAttribute","firstElementChild","getAttributeNode","removeAttributeNode","setAttributeNode","removeAttribute"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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M,OAAO,CAACqC,IAAI,GAAGrC,OAAO;EAExEkD,MAAM,CAACuJ,KAAK,CAAChF,WAAW,CAAC;AAC7B,CAAC;;ACXD;;;;AAIA,SAAgBqF,0CAA0C;;;;EAItD,IAAIC,QAAQ,GAAGC,OAAO,CAAChI,SAAS,CAACmB,YAAY;EAE7C,IAAI8G,OAAO,GAAG1M,QAAQ,CAACwD,aAAa,CAAC,KAAK,CAAC;EAE3CiJ,OAAO,CAAChI,SAAS,CAACmB,YAAY,GAAG,SAAS+G,eAAe,CAAC9G,IAAI,EAAEC,KAAK;IACjE,IAAI,CAACD,IAAI,CAACkE,QAAQ,CAAC,GAAG,CAAC,EAAE;MACrB,OAAOyC,QAAQ,CAAC7H,IAAI,CAAC,IAAI,EAAEkB,IAAI,EAAEC,KAAK,CAAC;;IAG3C4G,OAAO,CAACrH,SAAS,cAAYQ,IAAI,WAAKC,KAAK,eAAW;IAEtD,IAAI1F,IAAI,GAAIsM,OAAO,CAACE,iBAAiB,CAAGC,gBAAgB,CAAChH,IAAI,CAAE;IAE9D6G,OAAO,CAACE,iBAAiB,CAAGE,mBAAmB,CAAC1M,IAAI,CAAC;IAEtD,IAAI,CAAC2M,gBAAgB,CAAC3M,IAAI,CAAC;GAC9B;AACL;;ACrBAJ,QAAQ,CAACmL,gBAAgB,CAAC,kBAAkB,EAAE;EAC1CoB,0CAA0C,EAAE;EAC5CF,IAAI,EAAE;EAENrM,QAAQ,CAACC,gBAAgB,CAAC,WAAW,CAAC,CAACC,OAAO,CAAC,UAAApB,EAAE;IAC7CA,EAAE,CAACkO,eAAe,CAAC,SAAS,CAAC;GAChC,CAAC;AACN,CAAC,CAAC"} \ No newline at end of file diff --git a/client/dist/ui.cjs.production.min.js b/client/dist/ui.cjs.production.min.js index 3a6ef4d..9683261 100644 --- a/client/dist/ui.cjs.production.min.js +++ b/client/dist/ui.cjs.production.min.js @@ -1,2 +1,2 @@ -"use strict";function t(){t=function(){return e};var e={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function l(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,n){return t[e]=n}}function s(t,e,n,r){var i=Object.create((e&&e.prototype instanceof h?e:h).prototype),a=new A(r||[]);return o(i,"_invoke",{value:L(t,n,a)}),i}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=s;var d={};function h(){}function p(){}function v(){}var y={};l(y,a,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(T([])));g&&g!==n&&r.call(g,a)&&(y=g);var w=v.prototype=h.prototype=Object.create(y);function b(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){var n;o(this,"_invoke",{value:function(o,i){function a(){return new e((function(n,a){!function n(o,i,a,c){var u=f(t[o],t,i);if("throw"!==u.type){var l=u.arg,s=l.value;return s&&"object"==typeof s&&r.call(s,"__await")?e.resolve(s.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(s).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}})}function L(t,e,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return{value:void 0,done:!0}}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var c=E(a,n);if(c){if(c===d)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=f(t,e,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===d)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function E(t,e){var n=e.method,r=t.iterator[n];if(void 0===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),d;var o=f(r,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,d;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,d):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,d)}function N(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(N,this),this.reset(!0)}function T(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),O(n),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;O(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:T(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),d}},e}function e(t,e,n,r,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(r,o)}function n(){return(n=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var n=0,r=new Array(e);n=t.length?{done:!0}:{done:!1,value:t[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i;!function(t){t[t.NULL=-1]="NULL",t[t.STATIC=0]="STATIC",t[t.DYNAMIC=1]="DYNAMIC"}(i||(i={}));var a,c=function(t,e,n){var r='LeafUI Error: "'+t+'"';e&&(r+='\n\nExpression: "'+e+'"'),n&&(r+="\nElement:"),console.warn(r,n)},u=function(){function r(){}return r.connect=function(r,o,i){var a,u=null!=(a=o.element.closest("[ui-state]").getAttribute("ui-state"))?a:"{}";return fetch(window.location.href+"?_leaf_ui_config="+JSON.stringify({type:r,payload:{params:[],method:o.method,methodArgs:o.methodArgs,data:u}}),{method:o.config.method,credentials:"same-origin",headers:n({"Content-Type":"application/json",Accept:"text/html, application/xhtml+xml","X-Leaf-UI":"true"},this.headers,{Referer:window.location.href})}).then(function(){var n,r=(n=t().mark((function e(n){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!n.ok){t.next=4;break}n.text().then((function(t){var e=JSON.parse(t);window._leafUIConfig.data=e.state,i.diff(e.html,document.body)})),t.next=9;break;case 4:return t.t0=c,t.next=7,n.text().then((function(t){return t}));case 7:t.t1=t.sent,(0,t.t0)(t.t1);case 9:case"end":return t.stop()}}),e)})),function(){var t=this,r=arguments;return new Promise((function(o,i){var a=n.apply(t,r);function c(t){e(a,o,i,c,u,"next",t)}function u(t){e(a,o,i,c,u,"throw",t)}c(void 0)}))});return function(t){return r.apply(this,arguments)}}())},r}();function l(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===e.length&&t.every((function(t,n){return t===e[n]}))}!function(t){t["@"]="on",t[":"]="bind"}(a||(a={})),window.leafUI=window.leafUI||{};var s=function(){function t(){}return t.getBody=function(t,e){void 0===e&&(e=!1);var n=(new DOMParser).parseFromString(t,"text/html");if(!0===e)for(var r=n.body.getElementsByTagName("script"),o=0;o0?null:t.textContent},t.diff=function(e,n){t.diffElements(t.getBody(e,!1),n)},t.diffElements=function(e,n){var r=Array.prototype.slice.call(e.children),o=Array.prototype.slice.call(n.children),i=o.length-r.length;if(i>0)for(;i>0;i--)o[o.length-i].parentNode.removeChild(o[o.length-i]);for(var a=0;a0&&f.children.length<1)o[a].innerHTML="";else if(o[a].children.length<1&&f.children.length>0){var p=document.createDocumentFragment();t.diffElements(f,p),o[a].appendChild(p)}else f.children.length>0&&t.diffElements(f,o[a])}else{var y=f.cloneNode(!0);o[a].parentNode.replaceChild(y,o[a]),v(y)}else{var m=f.cloneNode(!0);n.appendChild(m),v(m)}}},t}(),f=function(t,e,n){void 0===n&&(n={});var r=new Function("return ("+["$el","$emit","$event","$refs","$dom"].join(",")+") => {\n const method = "+JSON.stringify(t)+".split('(')[0];\n const methodArgs = "+JSON.stringify(t)+".substring("+JSON.stringify(t)+".indexOf('(') + 1, "+JSON.stringify(t)+".lastIndexOf(')'));\n\n if (!window._leafUIConfig.methods.includes(method)) {\n return error(new ReferenceError(method + ' is not defined'), method, $el);\n }\n\n ("+u.connect+")('callMethod', { element: $el, method, methodArgs, config: window._leafUIConfig }, $dom);\n }")(),o=function(t,n,r){void 0===r&&(r=!0);var o=new CustomEvent(t,n);(r?window:e||window).dispatchEvent(o)};return function(i){try{return r(e,o,i,n,s)}catch(n){c(n,t,e)}}},d={ON:function(t){var e=t.el,n=t.parts,r=t.data,o={},i=n.slice(2),a="__on_"+n[1]+"_registered";if(!e[a]){var c=["outside","global"].some((function(t){return String(i).includes(t)}))?window:e;o.once=i.includes("once"),o.passive=i.includes("passive"),c.addEventListener(n[1],(function(t){if(i.length>0){if(t instanceof KeyboardEvent&&/\d/gim.test(String(i))){var n=[];if(i.forEach((function(t){isNaN(t)||n.push(Number(t))})),!n.includes(t.keyCode))return}if(i.includes("prevent")&&t.preventDefault(),i.includes("stop")&&t.stopPropagation(),i.includes("self")&&t.target!==e)return;if(i.includes("outside")){if(e.contains(t.target))return;if(e.offsetWidth<1&&e.offsetHeight<1)return}(i.includes("enter")||i.includes("meta"))&&"Enter"===t.key&&r.compute(t),(i.includes("ctrl")&&t.ctrlKey||i.includes("alt")&&t.altKey||i.includes("shift")&&t.shiftKey||i.includes("left")&&"button"in t&&0===t.button||i.includes("middle")&&"button"in t&&1===t.button||i.includes("right")&&"button"in t&&2===t.button)&&r.compute(t)}else r.compute(t)}),o),e[a]=!0}}},h=function(t,e){e[t.parts[0].toUpperCase()](t)},p=function(){function e(){this.uiNodes=[],this.uiNodes=[]}var n=e.prototype;return n.mount=function(t){var e=t instanceof HTMLElement?t:document.querySelector(t)||document.body;return this.uiNodes=function(t,e){void 0===e&&(e=!1);var n=[];return function t(e,n){void 0===n&&(n=!1);var r=[];n||r.push(e);for(var i,a=o(e.children);!(i=a()).done;){var c=i.value;c instanceof HTMLElement&&r.push.apply(r,t(c,0===c.attributes.length))}return r}(t,e).forEach((function(t){var e=function(t){var e=function(t){for(var e,n={},r=function(t){void 0===t&&(t=document);var e=t.querySelectorAll("[ui-ref]"),n={};return e.forEach((function(t){var e=t.getAttribute("ui-ref");e&&(n[e]=t)})),n}(),i=function(){var o=e.value,i=o.name,c=o.value,u=i.startsWith("ui-"),l=Object.keys(a).some((function(t){return i.startsWith(t)}));if(!u&&!l)return"continue";var s={compute:f(c,t,r),value:c},d=u?i.slice("ui-".length):a[i[0]]+":"+i.slice(1);n[d.toLowerCase()]=s},c=o(t.attributes);!(e=c()).done;)i();return n}(t);return Object.keys(e).length>0?{el:t,directives:e,type:i.STATIC}:void 0}(t);e&&n.push(e)})),n}(e),this.render(),e.component=this,window.leafUI={rootEl:e,component:this},this},n.render=function(){!function(e,n){var r,a=Object.keys(n);(r=t().mark((function r(){var c,u,l,s,f,d,p,v,y,m,g;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:c=o(e);case 1:if((u=c()).done){t.next=25;break}if((l=u.value).type!==i.NULL){t.next=5;break}return t.abrupt("continue",23);case 5:return(s=l.type===i.STATIC)&&(l.type=i.NULL),void(t.next=9);case 9:if(s){t.next=11;break}return t.abrupt("continue",23);case 11:f=0,d=Object.entries(l.directives);case 12:if(!(f';var o=e.firstElementChild.getAttributeNode(n);e.firstElementChild.removeAttributeNode(o),this.setAttributeNode(o)},function(t){void 0===t&&(t=document);var e=new p,n=t instanceof Document?t.body:t;e.mount(n)}(),document.querySelectorAll("[ui-lazy]").forEach((function(t){t.removeAttribute("ui-lazy")}))})); +"use strict";function t(){t=function(){return e};var e={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function l(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,n){return t[e]=n}}function s(t,e,n,r){var i=Object.create((e&&e.prototype instanceof h?e:h).prototype),a=new A(r||[]);return o(i,"_invoke",{value:N(t,n,a)}),i}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=s;var d={};function h(){}function p(){}function v(){}var y={};l(y,a,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(S([])));g&&g!==n&&r.call(g,a)&&(y=g);var b=v.prototype=h.prototype=Object.create(y);function w(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){var n;o(this,"_invoke",{value:function(o,i){function a(){return new e((function(n,a){!function n(o,i,a,u){var c=f(t[o],t,i);if("throw"!==c.type){var l=c.arg,s=l.value;return s&&"object"==typeof s&&r.call(s,"__await")?e.resolve(s.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):e.resolve(s).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,u)}))}u(c.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}})}function N(t,e,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return{value:void 0,done:!0}}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var u=E(a,n);if(u){if(u===d)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=f(t,e,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===d)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}function E(t,e){var n=e.method,r=t.iterator[n];if(void 0===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),d;var o=f(r,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,d;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,d):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,d)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function S(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),O(n),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;O(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:S(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),d}},e}function e(t,e,n,r,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,o)}function n(){return(n=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var n=0,r=new Array(e);n=t.length?{done:!0}:{done:!1,value:t[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i;!function(t){t[t.NULL=-1]="NULL",t[t.STATIC=0]="STATIC",t[t.DYNAMIC=1]="DYNAMIC"}(i||(i={}));var a,u=function(t,e,n){var r='LeafUI Error: "'+t+'"';e&&(r+='\n\nExpression: "'+e+'"'),n&&(r+="\nElement:"),console.warn(r,n)},c=function(){function r(){}return r.connect=function(r,o,i){var a,c={},l=o.element.closest("[ui-state]"),s=JSON.parse(null!=(a=null==l?void 0:l.getAttribute("ui-state"))?a:"{}");return document.querySelectorAll("[ui-state]").forEach((function(t){var e,n=JSON.parse(null!=(e=t.getAttribute("ui-state"))?e:"{}");c[n.key]=n})),fetch(window.location.href+"?_leaf_ui_config="+JSON.stringify({type:r,payload:{params:[],method:o.method,methodArgs:o.methodArgs,component:null==s?void 0:s.key,data:c}}),{method:o.config.method,credentials:"same-origin",headers:n({"Content-Type":"application/json",Accept:"text/html, application/xhtml+xml","X-Leaf-UI":"true"},this.headers,{Referer:window.location.href})}).then(function(){var n,r=(n=t().mark((function e(n){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!n.ok){t.next=4;break}n.text().then((function(t){var e=JSON.parse(t);window._leafUIConfig.data=e.state,i.diff(e.html,"HTML"!==l.nodeName&&l?l:document.body)})),t.next=9;break;case 4:return t.t0=u,t.next=7,n.text().then((function(t){return t}));case 7:t.t1=t.sent,(0,t.t0)(t.t1);case 9:case"end":return t.stop()}}),e)})),function(){var t=this,r=arguments;return new Promise((function(o,i){var a=n.apply(t,r);function u(t){e(a,o,i,u,c,"next",t)}function c(t){e(a,o,i,u,c,"throw",t)}u(void 0)}))});return function(t){return r.apply(this,arguments)}}())},r}();function l(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===e.length&&t.every((function(t,n){return t===e[n]}))}!function(t){t["@"]="on",t[":"]="bind"}(a||(a={})),window.leafUI=window.leafUI||{};var s=function(){function t(){}return t.getBody=function(t,e){void 0===e&&(e=!1);var n=(new DOMParser).parseFromString(t,"text/html");if(!0===e)for(var r=n.body.getElementsByTagName("script"),o=0;o0?null:t.textContent},t.diff=function(e,n){var r="BODY"===n.nodeName?t.getBody(e,!1):t.getBody(e,!0).children[0];t.diffElements(r,n)},t.diffElements=function(e,n){var r=Array.prototype.slice.call(e.children),o=Array.prototype.slice.call(n.children),i=o.length-r.length;if(i>0)for(;i>0;i--)o[o.length-i].parentNode.removeChild(o[o.length-i]);for(var a=0;a0&&y.children.length<1)o[a].innerHTML="";else if(o[a].children.length<1&&y.children.length>0){var L=document.createDocumentFragment();t.diffElements(y,L),o[a].appendChild(L)}else y.children.length>0&&t.diffElements(y,o[a])}else{var O=y.cloneNode(!0);o[a].parentNode?(o[a].parentNode.replaceChild(O,o[a]),v(O)):(o[a].replaceWith(O),v(O))}}else{var A=y.cloneNode(!0);n.appendChild(A),v(A)}}},t}(),f=function(t,e,n){void 0===n&&(n={});var r=new Function("return ("+["$el","$emit","$event","$refs","$dom"].join(",")+") => {\n const method = "+JSON.stringify(t)+".split('(')[0];\n const methodArgs = "+JSON.stringify(t)+".substring("+JSON.stringify(t)+".indexOf('(') + 1, "+JSON.stringify(t)+".lastIndexOf(')'));\n\n if (!window._leafUIConfig.methods.includes(method)) {\n return error(new ReferenceError(method + ' is not defined'), method, $el);\n }\n\n ("+c.connect+")('callMethod', { element: $el, method, methodArgs, config: window._leafUIConfig }, $dom);\n }")(),o=function(t,n,r){void 0===r&&(r=!0);var o=new CustomEvent(t,n);(r?window:e||window).dispatchEvent(o)};return function(i){try{return r(e,o,i,n,s)}catch(n){u(n,t,e)}}},d={ON:function(t){var e=t.el,n=t.parts,r=t.data,o={},i=n.slice(2),a="__on_"+n[1]+"_registered";if(!e[a]){var u=["outside","global"].some((function(t){return String(i).includes(t)}))?window:e;o.once=i.includes("once"),o.passive=i.includes("passive"),u.addEventListener(n[1],(function(t){if(i.length>0){if(t instanceof KeyboardEvent&&/\d/gim.test(String(i))){var n=[];if(i.forEach((function(t){isNaN(t)||n.push(Number(t))})),!n.includes(t.keyCode))return}if(i.includes("prevent")&&t.preventDefault(),i.includes("stop")&&t.stopPropagation(),i.includes("self")&&t.target!==e)return;if(i.includes("outside")){if(e.contains(t.target))return;if(e.offsetWidth<1&&e.offsetHeight<1)return}(i.includes("enter")||i.includes("meta"))&&"Enter"===t.key&&r.compute(t),(i.includes("ctrl")&&t.ctrlKey||i.includes("alt")&&t.altKey||i.includes("shift")&&t.shiftKey||i.includes("left")&&"button"in t&&0===t.button||i.includes("middle")&&"button"in t&&1===t.button||i.includes("right")&&"button"in t&&2===t.button)&&r.compute(t)}else r.compute(t)}),o),e[a]=!0}}},h=function(t,e){e[t.parts[0].toUpperCase()](t)},p=function(){function e(){this.uiNodes=[],this.uiNodes=[]}var n=e.prototype;return n.mount=function(t){var e=t instanceof HTMLElement?t:document.querySelector(t)||document.body;return this.uiNodes=function(t,e){void 0===e&&(e=!1);var n=[];return function t(e,n){void 0===n&&(n=!1);var r=[];n||r.push(e);for(var i,a=o(e.children);!(i=a()).done;){var u=i.value;u instanceof HTMLElement&&r.push.apply(r,t(u,0===u.attributes.length))}return r}(t,e).forEach((function(t){var e=function(t){var e=function(t){for(var e,n={},r=function(t){void 0===t&&(t=document);var e=t.querySelectorAll("[ui-ref]"),n={};return e.forEach((function(t){var e=t.getAttribute("ui-ref");e&&(n[e]=t)})),n}(),i=function(){var o=e.value,i=o.name,u=o.value,c=i.startsWith("ui-"),l=Object.keys(a).some((function(t){return i.startsWith(t)}));if(!c&&!l)return"continue";var s={compute:f(u,t,r),value:u},d=c?i.slice("ui-".length):a[i[0]]+":"+i.slice(1);n[d.toLowerCase()]=s},u=o(t.attributes);!(e=u()).done;)i();return n}(t);return Object.keys(e).length>0?{el:t,directives:e,type:i.STATIC}:void 0}(t);e&&n.push(e)})),n}(e),this.render(),e.component=this,window.leafUI={rootEl:e,component:this},this},n.render=function(){!function(e,n){var r,a=Object.keys(n);(r=t().mark((function r(){var u,c,l,s,f,d,p,v,y,m,g;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:u=o(e);case 1:if((c=u()).done){t.next=25;break}if((l=c.value).type!==i.NULL){t.next=5;break}return t.abrupt("continue",23);case 5:return(s=l.type===i.STATIC)&&(l.type=i.NULL),void(t.next=9);case 9:if(s){t.next=11;break}return t.abrupt("continue",23);case 11:f=0,d=Object.entries(l.directives);case 12:if(!(f';var o=e.firstElementChild.getAttributeNode(n);e.firstElementChild.removeAttributeNode(o),this.setAttributeNode(o)},function(t){void 0===t&&(t=document);var e=new p,n=t instanceof Document?t.body:t;e.mount(n)}(),document.querySelectorAll("[ui-lazy]").forEach((function(t){t.removeAttribute("ui-lazy")}))})); //# sourceMappingURL=ui.cjs.production.min.js.map diff --git a/client/dist/ui.cjs.production.min.js.map b/client/dist/ui.cjs.production.min.js.map index 9f9ea03..3c48018 100644 --- a/client/dist/ui.cjs.production.min.js.map +++ b/client/dist/ui.cjs.production.min.js.map @@ -1 +1 @@ -{"version":3,"file":"ui.cjs.production.min.js","sources":["../src/@types/core.ts","../src/utils/error.ts","../src/utils/data.ts","../src/server/connection.ts","../src/engine/dom.ts","../src/engine/compute.ts","../src/core/directives.ts","../src/core/directives/on.ts","../src/core/component.ts","../src/engine/compile.ts","../src/engine/render.ts","../src/utils/lazy.ts","../src/index.ts","../src/utils/reset.ts","../src/core/index.ts"],"sourcesContent":["export type Directives = Record void>;\n\nexport interface DirectiveProps {\n el: HTMLElement;\n parts: string[];\n data: DirectiveData;\n node?: UINode;\n}\n\nexport type KeyedEvent = KeyboardEvent | MouseEvent | TouchEvent;\n\nexport interface DirectiveData {\n compute: (event?: Event) => any;\n value: string;\n}\n\nexport interface UINode {\n directives: Record;\n el: HTMLElement;\n type: UINodeType;\n}\n\nexport enum UINodeType {\n NULL = -1,\n STATIC = 0,\n DYNAMIC = 1\n}\n\nexport interface LeafUIConfig {\n el: HTMLElement;\n data: Record;\n methods: string[];\n id: string;\n path: string;\n requestMethod: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD';\n component: string;\n}\n","export const error = (\n err: string,\n expression?: string,\n el?: HTMLElement\n): void => {\n let message = `LeafUI Error: \"${err}\"`;\n if (expression) message += `\\n\\nExpression: \"${expression}\"`;\n if (el) message += `\\nElement:`;\n console.warn(message, el);\n};\n","import Component from './../core/component';\nimport { LeafUIConfig } from './../@types/core';\n\nexport const eventDirectivePrefixRE = (): RegExp => /on|@/gim;\nexport const rawDirectiveSplitRE = (): RegExp => /:|\\./gim;\n\nexport const hasDirectiveRE = (): RegExp => {\n return new RegExp(\n `(ui-|${Object.keys(DIRECTIVE_SHORTHANDS).join('|')})\\\\w+`,\n 'gim'\n );\n};\n\nexport const expressionPropRE = (prop: string): RegExp => {\n // Utilizes \\b (word boundary) for prop differentiation.\n // Fails when next character is a \\w (Word).\n return new RegExp(`\\\\b${prop}\\\\b`, 'gim');\n};\n\nexport enum DIRECTIVE_SHORTHANDS {\n '@' = 'on',\n ':' = 'bind'\n}\n\nexport function arraysMatch(a: any[], b: any[]) {\n return (\n Array.isArray(a) &&\n Array.isArray(b) &&\n a.length === b.length &&\n a.every((val, index) => val === b[index])\n );\n}\n\ndeclare global {\n interface Window {\n leafUI: {\n rootEl?: HTMLElement;\n component: Component;\n };\n _leafUIConfig: LeafUIConfig;\n }\n\n interface HTMLElement {\n component: Component;\n compile: () => void;\n }\n}\n\nwindow.leafUI = window.leafUI || {};\n","import Dom from './../engine/dom';\nimport { error } from './../utils/error';\n\nexport default class Connection {\n protected static headers: Record;\n\n public static connect(\n type: string,\n uiData: Record,\n dom: typeof Dom\n ) {\n const component: Element = uiData.element.closest('[ui-state]');\n const componentData = component.getAttribute('ui-state') ?? '{}';\n\n const payload = {\n type,\n payload: {\n params: [],\n method: uiData.method,\n methodArgs: uiData.methodArgs,\n data: componentData,\n }\n };\n\n return fetch(\n `${window.location.href}?_leaf_ui_config=${JSON.stringify(\n payload\n )}`,\n {\n method: uiData.config.method,\n // This enables \"cookies\".\n credentials: 'same-origin',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'text/html, application/xhtml+xml',\n 'X-Leaf-UI': 'true',\n\n // set Custom Headers\n ...this.headers,\n\n // We'll set this explicitly to mitigate potential interference from ad-blockers/etc.\n Referer: window.location.href\n }\n }\n ).then(async response => {\n if (response.ok) {\n response.text().then(response => {\n const data = JSON.parse(response);\n window._leafUIConfig.data = data.state;\n dom.diff(data.html, document.body!);\n });\n } else {\n error(await response.text().then(res => res));\n }\n });\n }\n}\n","import { initComponent } from './../core/component';\nimport { arraysMatch } from './../utils/data';\n\nexport default class Dom {\n /**\n * Get the body of an HTML string\n *\n * @param html The html to parse\n * @param removeScripts Whether to remove scripts from the html\n * @returns The body of the html\n */\n public static getBody(\n html: string,\n removeScripts: boolean = false\n ): HTMLElement {\n const parser = new DOMParser();\n const dom = parser.parseFromString(html, 'text/html');\n\n if (removeScripts === true) {\n const scripts = dom.body.getElementsByTagName('script');\n\n for (let i = 0; i < scripts.length; i++) {\n scripts[i].remove();\n }\n }\n\n return dom.body;\n }\n\n /**\n * Get the type for a node\n * @param {HTMLElement} node The node\n * @return {String} The type\n */\n public static getNodeType(node: HTMLElement): string {\n if (node.nodeType === 3) return 'text';\n if (node.nodeType === 8) return 'comment';\n return node.tagName.toLowerCase();\n }\n\n /**\n * Get the content from a node\n * @param {Node} node The node\n * @return {String} The type\n */\n public static getNodeContent(node: HTMLElement) {\n if (node.children && node.children.length > 0) return null;\n return node.textContent;\n }\n\n /**\n * Diff the DOM from a string and an element\n *\n * @param newNode The new node\n * @param oldNode The old node\n * @returns The diffed node\n */\n public static diff(newNode: string, oldNode: HTMLElement): void {\n Dom.diffElements(Dom.getBody(newNode, false), oldNode);\n }\n\n /**\n * Diff the DOM from two elements\n *\n * @param newNode The new node\n * @param oldNode The old node\n * @returns The diffed node\n */\n public static diffElements(\n newNode: HTMLElement,\n oldNode: HTMLElement\n ): void {\n const newNodes = Array.prototype.slice.call(newNode.children);\n const oldNodes = Array.prototype.slice.call(oldNode.children);\n\n let count = oldNodes.length - newNodes.length;\n if (count > 0) {\n for (; count > 0; count--) {\n oldNodes[oldNodes.length - count].parentNode.removeChild(\n oldNodes[oldNodes.length - count]\n );\n }\n }\n\n for (let index = 0; index < newNodes.length; index++) {\n const node = newNodes[index];\n\n if (!oldNodes[index]) {\n const newNodeClone = node.cloneNode(true);\n oldNode.appendChild(newNodeClone);\n initComponent(newNodeClone);\n continue;\n }\n\n if (\n node instanceof HTMLScriptElement &&\n oldNodes[index] instanceof HTMLScriptElement\n ) {\n if (\n node.src !== oldNodes[index].src ||\n node.innerHTML !== oldNodes[index].innerHTML\n ) {\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n }\n\n continue;\n }\n\n if (\n Dom.getNodeType(node) !== Dom.getNodeType(oldNodes[index]) ||\n !arraysMatch(\n Object.keys(oldNodes[index]?.attributes) ?? [],\n Object.keys(node.attributes)\n ) ||\n oldNodes[index]?.innerHTML !== node.innerHTML\n ) {\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n initComponent(newNodeClone);\n continue;\n }\n\n // If content is different, update it\n const templateContent = Dom.getNodeContent(node);\n if (\n templateContent &&\n templateContent !== Dom.getNodeContent(oldNodes[index])\n ) {\n oldNodes[index].textContent = templateContent;\n }\n\n if (\n oldNodes[index].children.length > 0 &&\n node.children.length < 1\n ) {\n oldNodes[index].innerHTML = '';\n continue;\n }\n\n if (\n oldNodes[index].children.length < 1 &&\n node.children.length > 0\n ) {\n const fragment = document.createDocumentFragment();\n Dom.diffElements(node, fragment as any);\n oldNodes[index].appendChild(fragment);\n continue;\n }\n\n if (node.children.length > 0) {\n Dom.diffElements(node, oldNodes[index]);\n }\n }\n }\n}\n","import { error } from '../utils/error';\nimport Connection from './../server/connection';\nimport Dom from './dom';\n\nexport const compute = (\n expression: string,\n el?: HTMLElement,\n refs: Record = {}\n): ((event?: Event) => any) => {\n const specialPropertiesNames = ['$el', '$emit', '$event', '$refs', '$dom'];\n\n // This \"revives\" a function from a string, only using the new Function syntax once during compilation.\n // This is because raw function is ~50,000x faster than new Function\n const computeFunction = new Function(\n `return (${specialPropertiesNames.join(',')}) => {\n const method = ${JSON.stringify(expression)}.split('(')[0];\n const methodArgs = ${JSON.stringify(expression)}.substring(${JSON.stringify(expression)}.indexOf('(') + 1, ${JSON.stringify(expression)}.lastIndexOf(')'));\n\n if (!window._leafUIConfig.methods.includes(method)) {\n return error(new ReferenceError(method + ' is not defined'), method, $el);\n }\n\n (${\n Connection.connect\n })('callMethod', { element: $el, method, methodArgs, config: window._leafUIConfig }, $dom);\n }`\n )();\n\n const emit = (\n name: string,\n options?: CustomEventInit,\n dispatchGlobal = true\n ) => {\n const event = new CustomEvent(name, options);\n const target = dispatchGlobal ? window : el || window;\n\n target.dispatchEvent(event);\n };\n\n return (event?: Event) => {\n try {\n return computeFunction(el, emit, event, refs, Dom);\n } catch (err) {\n error(err as string, expression, el);\n }\n };\n};\n","import { DirectiveProps, Directives } from './../@types/core';\n// import { bindDirective } from './directives/bind';\n// import { modelDirective } from './directives/model';\nimport { onDirective } from './directives/on';\n\nexport const directives: Directives = {\n // BIND: bindDirective,\n // MODEL: modelDirective,\n ON: onDirective,\n};\n\nexport const renderDirective = (\n props: DirectiveProps,\n directives: Directives\n): void => {\n directives[props.parts[0].toUpperCase()](props);\n};\n","import { DirectiveProps, KeyedEvent } from './../../@types/core';\n\nexport const onDirective = ({ el, parts, data }: DirectiveProps): void => {\n const options: Record = {};\n const globalScopeEventProps = ['outside', 'global'];\n const eventProps = parts.slice(2);\n const EVENT_REGISTERED_FLAG = `__on_${parts[1]}_registered`;\n\n // @ts-expect-error: We're adding a custom property to the element\n if (el[EVENT_REGISTERED_FLAG]) return;\n\n const target = globalScopeEventProps.some(prop =>\n String(eventProps).includes(prop)\n )\n ? window\n : el;\n\n const handler = (event: Event) => { \n if (eventProps.length > 0) {\n if (\n event instanceof KeyboardEvent &&\n /\\d/gim.test(String(eventProps))\n ) {\n const whitelistedKeycodes: number[] = [];\n eventProps.forEach(eventProp => {\n // @ts-expect-error: eventProp can be a string, but isNaN only accepts number\n if (!isNaN(eventProp)) {\n whitelistedKeycodes.push(Number(eventProp));\n }\n });\n\n if (!whitelistedKeycodes.includes(event.keyCode)) return;\n }\n\n // Parse event modifiers based on directive prop\n if (eventProps.includes('prevent')) event.preventDefault();\n if (eventProps.includes('stop')) event.stopPropagation();\n if (eventProps.includes('self')) {\n if (event.target !== el) return;\n }\n /* istanbul ignore next */\n if (eventProps.includes('outside')) {\n if (el.contains(event.target as Node)) return;\n if (el.offsetWidth < 1 && el.offsetHeight < 1) return;\n }\n\n if (eventProps.includes('enter') || eventProps.includes('meta')) {\n if ((event as KeyboardEvent).key === 'Enter') {\n data.compute(event);\n }\n }\n\n if (\n (eventProps.includes('ctrl') &&\n (event as KeyedEvent).ctrlKey) ||\n (eventProps.includes('alt') && (event as KeyedEvent).altKey) ||\n (eventProps.includes('shift') &&\n (event as KeyedEvent).shiftKey) ||\n (eventProps.includes('left') &&\n 'button' in event &&\n (event as MouseEvent).button === 0) ||\n (eventProps.includes('middle') &&\n 'button' in event &&\n (event as MouseEvent).button === 1) ||\n (eventProps.includes('right') &&\n 'button' in event &&\n (event as MouseEvent).button === 2)\n ) {\n data.compute(event);\n }\n } else {\n data.compute(event);\n }\n };\n\n options.once = eventProps.includes('once');\n options.passive = eventProps.includes('passive');\n\n target.addEventListener(parts[1], handler, options);\n\n // @ts-expect-error: We're adding a custom property to the element\n el[EVENT_REGISTERED_FLAG] = true;\n};\n","import { UINode } from './../@types/core';\nimport { compile } from '../engine/compile';\nimport render from '../engine/render';\nimport { directives } from './directives';\n\nexport default class Component {\n public uiNodes: UINode[] = [];\n\n constructor() {\n this.uiNodes = [];\n }\n\n public mount(el: HTMLElement | string) {\n const rootEl =\n el instanceof HTMLElement\n ? el\n : document.querySelector(el) || document.body;\n\n this.uiNodes = compile(rootEl);\n this.render();\n rootEl['component'] = this;\n\n window.leafUI = {\n rootEl,\n component: this\n };\n\n return this;\n }\n\n /**\n * Force renders the DOM based on props\n * @param {string[]=} props - Array of root level properties in state\n * @returns {undefined}\n */\n public render() {\n render(this.uiNodes, directives);\n }\n}\n\nexport const initComponent = (element: Element) =>\n new Component().mount(element as HTMLElement);\n","import { DirectiveData, UINode, UINodeType } from '../@types/core';\nimport { compute } from './compute';\nimport { DIRECTIVE_SHORTHANDS } from '../utils/data';\n\nexport const flattenElementChildren = (\n rootElement: HTMLElement,\n ignoreRootElement = false\n): HTMLElement[] => {\n const collection: HTMLElement[] = [];\n\n if (!ignoreRootElement) {\n collection.push(rootElement);\n }\n\n for (const childElement of rootElement.children as any) {\n if (childElement instanceof HTMLElement) {\n collection.push(\n ...flattenElementChildren(\n childElement,\n childElement.attributes.length === 0\n )\n );\n }\n }\n\n return collection;\n};\n\nexport const collectRefs = (\n element: HTMLElement | Document = document\n): Record => {\n const refDirective = 'ui-ref';\n const refElements: NodeListOf = element.querySelectorAll(\n `[${refDirective}]`\n );\n const refs: Record = {};\n\n refElements.forEach(refElement => {\n const name = refElement.getAttribute(refDirective);\n\n if (name) {\n refs[name] = refElement;\n }\n });\n\n return refs;\n};\n\nexport const initDirectives = (\n el: HTMLElement\n): Record => {\n const directives: Record = {};\n const refs = collectRefs();\n\n // @ts-ignore\n for (const { name, value } of el.attributes) {\n const hasDirectivePrefix = name.startsWith('ui-');\n const hasDirectiveShorthandPrefix = Object.keys(\n DIRECTIVE_SHORTHANDS\n ).some(shorthand => name.startsWith(shorthand));\n\n if (!(hasDirectivePrefix || hasDirectiveShorthandPrefix)) {\n continue;\n }\n\n const directiveData = {\n compute: compute(value, el, refs),\n value\n };\n\n // Handle normal and shorthand directives=\n const directiveName = hasDirectivePrefix\n ? name.slice('ui-'.length)\n : // @ts-ignore\n `${DIRECTIVE_SHORTHANDS[name[0]]}:${name.slice(1)}`;\n\n directives[directiveName.toLowerCase()] = directiveData;\n }\n\n return directives;\n};\n\nexport const createASTNode = (el: HTMLElement): UINode | undefined => {\n const directives = initDirectives(el);\n const hasDirectives = Object.keys(directives).length > 0;\n const node = { el, directives, type: UINodeType.STATIC };\n\n return hasDirectives ? node : undefined;\n};\n\nexport const compile = (\n el: HTMLElement,\n ignoreRootElement = false\n): UINode[] => {\n const uiNodes: UINode[] = [];\n const elements = flattenElementChildren(el, ignoreRootElement);\n\n elements.forEach(element => {\n const newASTNode = createASTNode(element);\n\n if (newASTNode) {\n uiNodes.push(newASTNode);\n }\n });\n\n return uiNodes;\n};\n","import lazy from './../utils/lazy';\nimport { renderDirective } from './../core/directives';\nimport { rawDirectiveSplitRE } from './../utils/data';\nimport { Directives, UINode, UINodeType } from './../@types/core';\n\nconst render = (\n uiNodes: UINode[],\n directives: Directives,\n): void => {\n const legalDirectiveNames = Object.keys(directives);\n const LAZY_MODE_TIMEOUT = 25;\n\n lazy(LAZY_MODE_TIMEOUT, function*() {\n for (const node of uiNodes) {\n if (node.type === UINodeType.NULL) continue;\n const isStatic = node.type === UINodeType.STATIC;\n if (isStatic) node.type = UINodeType.NULL;\n yield;\n\n if (!isStatic) continue;\n\n for (const [directiveName, directiveData] of Object.entries(\n node.directives\n )) {\n const rawDirectiveName = directiveName.split(\n rawDirectiveSplitRE()\n )[0];\n\n if (\n !legalDirectiveNames.includes(\n rawDirectiveName.toUpperCase()\n )\n )\n continue;\n yield;\n\n // If affected, then push to render queue\n if (isStatic) {\n const directiveProps = {\n el: node.el,\n parts: directiveName.split(rawDirectiveSplitRE()),\n data: directiveData,\n node,\n };\n\n renderDirective(directiveProps, directives);\n\n // [TODO] Remove this after testing\n delete node.directives[directiveName];\n }\n }\n }\n })();\n};\n\nexport default render;\n","/**\n * @author Aiden Bai \n * @package lucia\n */\n// Lazy allows us to delay render calls if the main thread is blocked\n// This is kind of like time slicing in React but less advanced\n// It's a generator function that yields after a certain amount of time\n// This allows the browser to render other things while the generator is running\n// It's a bit like a setTimeout but it's more accurate\n\nexport const lazy = (\n threshold: number,\n generatorFunction: () => Generator,\n): (() => void) => {\n const generator = generatorFunction();\n return function next() {\n const start = performance.now();\n let task = null;\n do {\n task = generator.next();\n } while (performance.now() - start < threshold && !task.done);\n\n if (task.done) return;\n setTimeout(next);\n };\n};\n\nexport default lazy;\n","import { init } from './core';\nimport { monkeyPatchDomSetAttributeToAllowAtSymbols } from './utils/reset';\nexport * from './@types';\n\ndocument.addEventListener('DOMContentLoaded', () => {\n monkeyPatchDomSetAttributeToAllowAtSymbols();\n init();\n\n document.querySelectorAll('[ui-lazy]').forEach(el => {\n el.removeAttribute('ui-lazy');\n });\n});\n","/**\n * @author Caleb Porzio\n * @package livewire/livewire\n */\nexport function monkeyPatchDomSetAttributeToAllowAtSymbols() {\n // Because morphdom may add attributes to elements containing \"@\" symbols\n // like in the case of an Alpine `@click` directive, we have to patch\n // the standard Element.setAttribute method to allow this to work.\n let original = Element.prototype.setAttribute;\n\n let hostDiv = document.createElement('div');\n\n Element.prototype.setAttribute = function newSetAttribute(name, value) {\n if (!name.includes('@')) {\n return original.call(this, name, value);\n }\n\n hostDiv.innerHTML = ``;\n\n let attr = (hostDiv.firstElementChild)!.getAttributeNode(name)!;\n\n (hostDiv.firstElementChild)!.removeAttributeNode(attr);\n\n this.setAttributeNode(attr);\n };\n}\n","import Component from './component';\n\n/**\n * Initialize Your Leaf UI root component\n * @param {HTMLElement|Document} element - Root element to find uninitialized components\n */\nexport const init = (element: HTMLElement | Document = document): void => {\n const leafUI = new Component();\n const rootElement = element instanceof Document ? element.body : element;\n\n leafUI.mount(rootElement);\n};\n"],"names":["UINodeType","DIRECTIVE_SHORTHANDS","error","err","expression","el","message","console","warn","Connection","connect","type","uiData","dom","componentData","element","closest","getAttribute","fetch","window","location","href","JSON","stringify","payload","params","method","methodArgs","data","config","credentials","headers","Content-Type","Accept","X-Leaf-UI","this","Referer","then","response","ok","_context","text","parse","_leafUIConfig","state","diff","html","document","body","res","arraysMatch","a","b","Array","isArray","length","every","val","index","leafUI","Dom","getBody","removeScripts","DOMParser","parseFromString","scripts","getElementsByTagName","i","remove","getNodeType","node","nodeType","tagName","toLowerCase","getNodeContent","children","textContent","newNode","oldNode","diffElements","newNodes","prototype","slice","call","oldNodes","count","parentNode","removeChild","HTMLScriptElement","src","innerHTML","newNodeClone","cloneNode","replaceChild","Object","keys","_oldNodes$index","attributes","_oldNodes$index2","templateContent","fragment","createDocumentFragment","appendChild","initComponent","compute","refs","computeFunction","Function","join","emit","name","options","dispatchGlobal","event","CustomEvent","dispatchEvent","directives","ON","parts","eventProps","EVENT_REGISTERED_FLAG","target","some","prop","String","includes","once","passive","addEventListener","KeyboardEvent","test","whitelistedKeycodes","forEach","eventProp","isNaN","push","Number","keyCode","preventDefault","stopPropagation","contains","offsetWidth","offsetHeight","key","ctrlKey","altKey","shiftKey","button","renderDirective","props","toUpperCase","Component","uiNodes","_proto","mount","rootEl","HTMLElement","querySelector","ignoreRootElement","flattenElementChildren","rootElement","collection","childElement","newASTNode","refElements","querySelectorAll","refElement","collectRefs","value","hasDirectivePrefix","startsWith","hasDirectiveShorthandPrefix","shorthand","directiveData","directiveName","initDirectives","STATIC","undefined","createASTNode","compile","render","component","generator","legalDirectiveNames","_iterator","NULL","isStatic","_i","entries","_Object$entries$_i","rawDirectiveName","split","directiveProps","generatorFunction","next","start","performance","now","task","done","setTimeout","original","hostDiv","Element","setAttribute","createElement","attr","firstElementChild","getAttributeNode","removeAttributeNode","setAttributeNode","Document","init","removeAttribute"],"mappings":"gnPAsBA,IAAYA,GAAZ,SAAYA,GACRA,oBACAA,uBACAA,yBAHJ,CAAYA,IAAAA,OCtBL,ICmBKC,EDnBCC,EAAQ,SACjBC,EACAC,EACAC,GAEA,IAAIC,oBAA4BH,MAC5BC,IAAYE,uBAA+BF,OAC3CC,IAAIC,iBACRC,QAAQC,KAAKF,EAASD,IELLI,aAAU,cAoD1B,OApD0BA,EAGbC,QAAP,SACHC,EACAC,EACAC,SAGMC,WADqBF,EAAOG,QAAQC,QAAQ,cAClBC,aAAa,eAAe,KAY5D,OAAOC,MACAC,OAAOC,SAASC,yBAAwBC,KAAKC,UAXpC,CACZZ,KAAAA,EACAa,QAAS,CACLC,OAAQ,GACRC,OAAQd,EAAOc,OACfC,WAAYf,EAAOe,WACnBC,KAAMd,KAQV,CACIY,OAAQd,EAAOiB,OAAOH,OAEtBI,YAAa,cACbC,WACIC,eAAgB,mBAChBC,OAAQ,mCACRC,YAAa,QAGVC,KAAKJ,SAGRK,QAASjB,OAAOC,SAASC,SAGnCgB,gBAAI,qBAAC,WAAMC,GAAQ,6BAAA,6BAAA,OAAA,IACbA,EAASC,IAAEC,SAAA,MACXF,EAASG,OAAOJ,MAAK,SAAAC,GACjB,IAAMV,EAAON,KAAKoB,MAAMJ,GACxBnB,OAAOwB,cAAcf,KAAOA,EAAKgB,MACjC/B,EAAIgC,KAAKjB,EAAKkB,KAAMC,SAASC,SAC9BR,SAAA,MAAA,OAEE,O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AAK1D,EAAKe,SAAS,KACf,OAAO4E,EAAStH,KAAKhD,KAAM2E,EAAM0D,GAGrCkC,EAAQhH,mBAAqBoB,OAAS0D,cAEtC,IAAIsC,EAAQJ,EAAQK,kBAAoBC,iBAAiBlG,GAExD4F,EAAQK,kBAAoBE,oBAAoBH,GAEjD3K,KAAK+K,iBAAiBJ,ICjBV,SAAC/L,YAAAA,IAAAA,EAAkCgC,UACnD,IAAMY,EAAS,IAAI4F,EACbS,EAAcjJ,aAAmBoM,SAAWpM,EAAQiC,KAAOjC,EAEjE4C,EAAO+F,MAAMM,GFJboD,GAEArK,SAASsH,iBAAiB,aAAajC,SAAQ,SAAA/H,GAC3CA,EAAGgN,gBAAgB"} \ No newline at end of file +{"version":3,"file":"ui.cjs.production.min.js","sources":["../src/@types/core.ts","../src/utils/error.ts","../src/utils/data.ts","../src/server/connection.ts","../src/engine/dom.ts","../src/engine/compute.ts","../src/core/directives.ts","../src/core/directives/on.ts","../src/core/component.ts","../src/engine/compile.ts","../src/engine/render.ts","../src/utils/lazy.ts","../src/index.ts","../src/utils/reset.ts","../src/core/index.ts"],"sourcesContent":["export type Directives = Record void>;\n\nexport interface DirectiveProps {\n el: HTMLElement;\n parts: string[];\n data: DirectiveData;\n node?: UINode;\n}\n\nexport type KeyedEvent = KeyboardEvent | MouseEvent | TouchEvent;\n\nexport interface DirectiveData {\n compute: (event?: Event) => any;\n value: string;\n}\n\nexport interface UINode {\n directives: Record;\n el: HTMLElement;\n type: UINodeType;\n}\n\nexport enum UINodeType {\n NULL = -1,\n STATIC = 0,\n DYNAMIC = 1\n}\n\nexport interface LeafUIConfig {\n el: HTMLElement;\n data: Record;\n methods: string[];\n id: string;\n path: string;\n requestMethod: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD';\n component: string;\n}\n","export const error = (\n err: string,\n expression?: string,\n el?: HTMLElement\n): void => {\n let message = `LeafUI Error: \"${err}\"`;\n if (expression) message += `\\n\\nExpression: \"${expression}\"`;\n if (el) message += `\\nElement:`;\n console.warn(message, el);\n};\n","import Component from './../core/component';\nimport { LeafUIConfig } from './../@types/core';\n\nexport const eventDirectivePrefixRE = (): RegExp => /on|@/gim;\nexport const rawDirectiveSplitRE = (): RegExp => /:|\\./gim;\n\nexport const hasDirectiveRE = (): RegExp => {\n return new RegExp(\n `(ui-|${Object.keys(DIRECTIVE_SHORTHANDS).join('|')})\\\\w+`,\n 'gim'\n );\n};\n\nexport const expressionPropRE = (prop: string): RegExp => {\n // Utilizes \\b (word boundary) for prop differentiation.\n // Fails when next character is a \\w (Word).\n return new RegExp(`\\\\b${prop}\\\\b`, 'gim');\n};\n\nexport enum DIRECTIVE_SHORTHANDS {\n '@' = 'on',\n ':' = 'bind'\n}\n\nexport function arraysMatch(a: any[], b: any[]) {\n return (\n Array.isArray(a) &&\n Array.isArray(b) &&\n a.length === b.length &&\n a.every((val, index) => val === b[index])\n );\n}\n\ndeclare global {\n interface Window {\n leafUI: {\n rootEl?: HTMLElement;\n component: Component;\n };\n _leafUIConfig: LeafUIConfig;\n }\n\n interface HTMLElement {\n component: Component;\n compile: () => void;\n }\n}\n\nwindow.leafUI = window.leafUI || {};\n","import Dom from './../engine/dom';\nimport { error } from './../utils/error';\n\nexport default class Connection {\n protected static headers: Record;\n\n public static connect(\n type: string,\n uiData: Record,\n dom: typeof Dom\n ) {\n const pageState: Record = {};\n const component: HTMLElement = uiData.element.closest('[ui-state]');\n const componentData = JSON.parse(component?.getAttribute('ui-state') ?? '{}');\n const components = document.querySelectorAll('[ui-state]');\n\n components.forEach((i) => {\n const attr = JSON.parse(i.getAttribute('ui-state') ?? '{}');\n pageState[attr.key] = attr;\n });\n\n const payload = {\n type,\n payload: {\n params: [],\n method: uiData.method,\n methodArgs: uiData.methodArgs,\n component: componentData?.key,\n data: pageState,\n }\n };\n\n return fetch(\n `${window.location.href}?_leaf_ui_config=${JSON.stringify(\n payload\n )}`,\n {\n method: uiData.config.method,\n // This enables \"cookies\".\n credentials: 'same-origin',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'text/html, application/xhtml+xml',\n 'X-Leaf-UI': 'true',\n\n // set Custom Headers\n ...this.headers,\n\n // We'll set this explicitly to mitigate potential interference from ad-blockers/etc.\n Referer: window.location.href\n }\n }\n ).then(async response => {\n if (response.ok) {\n response.text().then(response => {\n const data = JSON.parse(response);\n window._leafUIConfig.data = data.state;\n dom.diff(\n data.html,\n component.nodeName === 'HTML' || !component\n ? document.body!\n : component\n );\n });\n } else {\n error(await response.text().then(res => res));\n }\n });\n }\n}\n","import { initComponent } from './../core/component';\nimport { arraysMatch } from './../utils/data';\n\nexport default class Dom {\n /**\n * Get the body of an HTML string\n *\n * @param html The html to parse\n * @param removeScripts Whether to remove scripts from the html\n * @returns The body of the html\n */\n public static getBody(\n html: string,\n removeScripts: boolean = false\n ): HTMLElement {\n const parser = new DOMParser();\n const dom = parser.parseFromString(html, 'text/html');\n\n if (removeScripts === true) {\n const scripts = dom.body.getElementsByTagName('script');\n\n for (let i = 0; i < scripts.length; i++) {\n scripts[i].remove();\n }\n }\n\n return dom.body;\n }\n\n /**\n * Wrap DOM node with a template element\n */\n public static wrap(node: Node): HTMLElement {\n const wrapper = document.createElement('x-leafui-wrapper');\n wrapper.appendChild(node);\n return wrapper;\n }\n\n /**\n * Parse string to DOM\n *\n * @param html The html to parse\n */\n public static parse(html: string): HTMLElement {\n const parser = new DOMParser();\n const dom = parser.parseFromString(html, 'text/html');\n\n return dom.getRootNode().firstChild as HTMLElement;\n }\n\n /**\n * Get the type for a node\n * @param {HTMLElement} node The node\n * @return {String} The type\n */\n public static getNodeType(node: HTMLElement): string {\n if (node.nodeType === 3) return 'text';\n if (node.nodeType === 8) return 'comment';\n return node.tagName.toLowerCase();\n }\n\n /**\n * Get the content from a node\n * @param {Node} node The node\n * @return {String} The type\n */\n public static getNodeContent(node: HTMLElement) {\n if (node.children && node.children.length > 0) return null;\n return node.textContent;\n }\n\n /**\n * Diff the DOM from a string and an element\n *\n * @param newNode The new node\n * @param oldNode The old node\n * @returns The diffed node\n */\n public static diff(newNode: string, oldNode: HTMLElement): void {\n const structuredNewNode =\n oldNode.nodeName === 'BODY'\n ? Dom.getBody(newNode, false)\n : Dom.getBody(newNode, true).children[0];\n const structuredOldNode = oldNode;\n\n Dom.diffElements(structuredNewNode as HTMLElement, structuredOldNode);\n }\n\n /**\n * Diff the DOM from two elements\n *\n * @param newNode The new node\n * @param oldNode The old node\n * @returns The diffed node\n */\n public static diffElements(\n newNode: HTMLElement,\n oldNode: HTMLElement\n ): void {\n const newNodes = Array.prototype.slice.call(newNode.children);\n const oldNodes = Array.prototype.slice.call(oldNode.children);\n\n let count = oldNodes.length - newNodes.length;\n\n if (count > 0) {\n for (; count > 0; count--) {\n oldNodes[oldNodes.length - count].parentNode.removeChild(\n oldNodes[oldNodes.length - count]\n );\n }\n }\n\n for (let index = 0; index < newNodes.length; index++) {\n const node = newNodes[index];\n\n if (!oldNodes[index]) {\n const newNodeClone = node.cloneNode(true);\n oldNode.appendChild(newNodeClone);\n initComponent(newNodeClone);\n continue;\n }\n\n if (\n node instanceof HTMLScriptElement &&\n oldNodes[index] instanceof HTMLScriptElement\n ) {\n if (\n node.src !== oldNodes[index].src ||\n node.innerHTML !== oldNodes[index].innerHTML\n ) {\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n }\n\n continue;\n }\n\n if (\n !arraysMatch(\n Object.values(node.parentNode?.attributes ?? {}),\n Object.values(oldNodes[index].parentNode?.attributes ?? {})\n )\n ) {\n for (\n let nIndex = 0;\n nIndex < node.parentNode.attributes?.length;\n nIndex++\n ) {\n const attribute = node.parentNode.attributes[nIndex];\n oldNodes[index]?.parentNode?.setAttribute(\n attribute.name,\n attribute.value\n );\n }\n }\n\n if (\n Dom.getNodeType(node) !== Dom.getNodeType(oldNodes[index]) ||\n !arraysMatch(\n Object.keys(oldNodes[index]?.attributes) ?? [],\n Object.keys(node.attributes)\n ) ||\n oldNodes[index]?.innerHTML !== node.innerHTML\n ) {\n const newNodeClone = node.cloneNode(true);\n\n if (!oldNodes[index].parentNode) {\n oldNodes[index].replaceWith(newNodeClone);\n initComponent(newNodeClone);\n } else {\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n initComponent(newNodeClone);\n }\n\n continue;\n }\n\n // If content is different, update it\n const templateContent = Dom.getNodeContent(node);\n if (\n templateContent &&\n templateContent !== Dom.getNodeContent(oldNodes[index])\n ) {\n oldNodes[index].textContent = templateContent;\n }\n\n if (\n oldNodes[index].children.length > 0 &&\n node.children.length < 1\n ) {\n oldNodes[index].innerHTML = '';\n continue;\n }\n\n if (\n oldNodes[index].children.length < 1 &&\n node.children.length > 0\n ) {\n const fragment = document.createDocumentFragment();\n Dom.diffElements(node, fragment as any);\n oldNodes[index].appendChild(fragment);\n continue;\n }\n\n if (node.children.length > 0) {\n Dom.diffElements(node, oldNodes[index]);\n }\n }\n }\n}\n","import { error } from '../utils/error';\nimport Connection from './../server/connection';\nimport Dom from './dom';\n\nexport const compute = (\n expression: string,\n el?: HTMLElement,\n refs: Record = {}\n): ((event?: Event) => any) => {\n const specialPropertiesNames = ['$el', '$emit', '$event', '$refs', '$dom'];\n\n // This \"revives\" a function from a string, only using the new Function syntax once during compilation.\n // This is because raw function is ~50,000x faster than new Function\n const computeFunction = new Function(\n `return (${specialPropertiesNames.join(',')}) => {\n const method = ${JSON.stringify(expression)}.split('(')[0];\n const methodArgs = ${JSON.stringify(expression)}.substring(${JSON.stringify(expression)}.indexOf('(') + 1, ${JSON.stringify(expression)}.lastIndexOf(')'));\n\n if (!window._leafUIConfig.methods.includes(method)) {\n return error(new ReferenceError(method + ' is not defined'), method, $el);\n }\n\n (${\n Connection.connect\n })('callMethod', { element: $el, method, methodArgs, config: window._leafUIConfig }, $dom);\n }`\n )();\n\n const emit = (\n name: string,\n options?: CustomEventInit,\n dispatchGlobal = true\n ) => {\n const event = new CustomEvent(name, options);\n const target = dispatchGlobal ? window : el || window;\n\n target.dispatchEvent(event);\n };\n\n return (event?: Event) => {\n try {\n return computeFunction(el, emit, event, refs, Dom);\n } catch (err) {\n error(err as string, expression, el);\n }\n };\n};\n","import { DirectiveProps, Directives } from './../@types/core';\n// import { bindDirective } from './directives/bind';\n// import { modelDirective } from './directives/model';\nimport { onDirective } from './directives/on';\n\nexport const directives: Directives = {\n // BIND: bindDirective,\n // MODEL: modelDirective,\n ON: onDirective,\n};\n\nexport const renderDirective = (\n props: DirectiveProps,\n directives: Directives\n): void => {\n directives[props.parts[0].toUpperCase()](props);\n};\n","import { DirectiveProps, KeyedEvent } from './../../@types/core';\n\nexport const onDirective = ({ el, parts, data }: DirectiveProps): void => {\n const options: Record = {};\n const globalScopeEventProps = ['outside', 'global'];\n const eventProps = parts.slice(2);\n const EVENT_REGISTERED_FLAG = `__on_${parts[1]}_registered`;\n\n // @ts-expect-error: We're adding a custom property to the element\n if (el[EVENT_REGISTERED_FLAG]) return;\n\n const target = globalScopeEventProps.some(prop =>\n String(eventProps).includes(prop)\n )\n ? window\n : el;\n\n const handler = (event: Event) => { \n if (eventProps.length > 0) {\n if (\n event instanceof KeyboardEvent &&\n /\\d/gim.test(String(eventProps))\n ) {\n const whitelistedKeycodes: number[] = [];\n eventProps.forEach(eventProp => {\n // @ts-expect-error: eventProp can be a string, but isNaN only accepts number\n if (!isNaN(eventProp)) {\n whitelistedKeycodes.push(Number(eventProp));\n }\n });\n\n if (!whitelistedKeycodes.includes(event.keyCode)) return;\n }\n\n // Parse event modifiers based on directive prop\n if (eventProps.includes('prevent')) event.preventDefault();\n if (eventProps.includes('stop')) event.stopPropagation();\n if (eventProps.includes('self')) {\n if (event.target !== el) return;\n }\n /* istanbul ignore next */\n if (eventProps.includes('outside')) {\n if (el.contains(event.target as Node)) return;\n if (el.offsetWidth < 1 && el.offsetHeight < 1) return;\n }\n\n if (eventProps.includes('enter') || eventProps.includes('meta')) {\n if ((event as KeyboardEvent).key === 'Enter') {\n data.compute(event);\n }\n }\n\n if (\n (eventProps.includes('ctrl') &&\n (event as KeyedEvent).ctrlKey) ||\n (eventProps.includes('alt') && (event as KeyedEvent).altKey) ||\n (eventProps.includes('shift') &&\n (event as KeyedEvent).shiftKey) ||\n (eventProps.includes('left') &&\n 'button' in event &&\n (event as MouseEvent).button === 0) ||\n (eventProps.includes('middle') &&\n 'button' in event &&\n (event as MouseEvent).button === 1) ||\n (eventProps.includes('right') &&\n 'button' in event &&\n (event as MouseEvent).button === 2)\n ) {\n data.compute(event);\n }\n } else {\n data.compute(event);\n }\n };\n\n options.once = eventProps.includes('once');\n options.passive = eventProps.includes('passive');\n\n target.addEventListener(parts[1], handler, options);\n\n // @ts-expect-error: We're adding a custom property to the element\n el[EVENT_REGISTERED_FLAG] = true;\n};\n","import { UINode } from './../@types/core';\nimport { compile } from '../engine/compile';\nimport render from '../engine/render';\nimport { directives } from './directives';\n\nexport default class Component {\n public uiNodes: UINode[] = [];\n\n constructor() {\n this.uiNodes = [];\n }\n\n public mount(el: HTMLElement | string) {\n const rootEl =\n el instanceof HTMLElement\n ? el\n : document.querySelector(el) || document.body;\n\n this.uiNodes = compile(rootEl);\n this.render();\n rootEl['component'] = this;\n\n window.leafUI = {\n rootEl,\n component: this\n };\n\n return this;\n }\n\n /**\n * Force renders the DOM based on props\n * @param {string[]=} props - Array of root level properties in state\n * @returns {undefined}\n */\n public render() {\n render(this.uiNodes, directives);\n }\n}\n\nexport const initComponent = (element: Element) =>\n new Component().mount(element as HTMLElement);\n","import { DirectiveData, UINode, UINodeType } from '../@types/core';\nimport { compute } from './compute';\nimport { DIRECTIVE_SHORTHANDS } from '../utils/data';\n\nexport const flattenElementChildren = (\n rootElement: HTMLElement,\n ignoreRootElement = false\n): HTMLElement[] => {\n const collection: HTMLElement[] = [];\n\n if (!ignoreRootElement) {\n collection.push(rootElement);\n }\n\n for (const childElement of rootElement.children as any) {\n if (childElement instanceof HTMLElement) {\n collection.push(\n ...flattenElementChildren(\n childElement,\n childElement.attributes.length === 0\n )\n );\n }\n }\n\n return collection;\n};\n\nexport const collectRefs = (\n element: HTMLElement | Document = document\n): Record => {\n const refDirective = 'ui-ref';\n const refElements: NodeListOf = element.querySelectorAll(\n `[${refDirective}]`\n );\n const refs: Record = {};\n\n refElements.forEach(refElement => {\n const name = refElement.getAttribute(refDirective);\n\n if (name) {\n refs[name] = refElement;\n }\n });\n\n return refs;\n};\n\nexport const initDirectives = (\n el: HTMLElement\n): Record => {\n const directives: Record = {};\n const refs = collectRefs();\n\n // @ts-ignore\n for (const { name, value } of el.attributes) {\n const hasDirectivePrefix = name.startsWith('ui-');\n const hasDirectiveShorthandPrefix = Object.keys(\n DIRECTIVE_SHORTHANDS\n ).some(shorthand => name.startsWith(shorthand));\n\n if (!(hasDirectivePrefix || hasDirectiveShorthandPrefix)) {\n continue;\n }\n\n const directiveData = {\n compute: compute(value, el, refs),\n value\n };\n\n // Handle normal and shorthand directives=\n const directiveName = hasDirectivePrefix\n ? name.slice('ui-'.length)\n : // @ts-ignore\n `${DIRECTIVE_SHORTHANDS[name[0]]}:${name.slice(1)}`;\n\n directives[directiveName.toLowerCase()] = directiveData;\n }\n\n return directives;\n};\n\nexport const createASTNode = (el: HTMLElement): UINode | undefined => {\n const directives = initDirectives(el);\n const hasDirectives = Object.keys(directives).length > 0;\n const node = { el, directives, type: UINodeType.STATIC };\n\n return hasDirectives ? node : undefined;\n};\n\nexport const compile = (\n el: HTMLElement,\n ignoreRootElement = false\n): UINode[] => {\n const uiNodes: UINode[] = [];\n const elements = flattenElementChildren(el, ignoreRootElement);\n\n elements.forEach(element => {\n const newASTNode = createASTNode(element);\n\n if (newASTNode) {\n uiNodes.push(newASTNode);\n }\n });\n\n return uiNodes;\n};\n","import lazy from './../utils/lazy';\nimport { renderDirective } from './../core/directives';\nimport { rawDirectiveSplitRE } from './../utils/data';\nimport { Directives, UINode, UINodeType } from './../@types/core';\n\nconst render = (\n uiNodes: UINode[],\n directives: Directives,\n): void => {\n const legalDirectiveNames = Object.keys(directives);\n const LAZY_MODE_TIMEOUT = 25;\n\n lazy(LAZY_MODE_TIMEOUT, function*() {\n for (const node of uiNodes) {\n if (node.type === UINodeType.NULL) continue;\n const isStatic = node.type === UINodeType.STATIC;\n if (isStatic) node.type = UINodeType.NULL;\n yield;\n\n if (!isStatic) continue;\n\n for (const [directiveName, directiveData] of Object.entries(\n node.directives\n )) {\n const rawDirectiveName = directiveName.split(\n rawDirectiveSplitRE()\n )[0];\n\n if (\n !legalDirectiveNames.includes(\n rawDirectiveName.toUpperCase()\n )\n )\n continue;\n yield;\n\n // If affected, then push to render queue\n if (isStatic) {\n const directiveProps = {\n el: node.el,\n parts: directiveName.split(rawDirectiveSplitRE()),\n data: directiveData,\n node,\n };\n\n renderDirective(directiveProps, directives);\n\n // [TODO] Remove this after testing\n delete node.directives[directiveName];\n }\n }\n }\n })();\n};\n\nexport default render;\n","/**\n * @author Aiden Bai \n * @package lucia\n */\n// Lazy allows us to delay render calls if the main thread is blocked\n// This is kind of like time slicing in React but less advanced\n// It's a generator function that yields after a certain amount of time\n// This allows the browser to render other things while the generator is running\n// It's a bit like a setTimeout but it's more accurate\n\nexport const lazy = (\n threshold: number,\n generatorFunction: () => Generator,\n): (() => void) => {\n const generator = generatorFunction();\n return function next() {\n const start = performance.now();\n let task = null;\n do {\n task = generator.next();\n } while (performance.now() - start < threshold && !task.done);\n\n if (task.done) return;\n setTimeout(next);\n };\n};\n\nexport default lazy;\n","import { init } from './core';\nimport { monkeyPatchDomSetAttributeToAllowAtSymbols } from './utils/reset';\nexport * from './@types';\n\ndocument.addEventListener('DOMContentLoaded', () => {\n monkeyPatchDomSetAttributeToAllowAtSymbols();\n init();\n\n document.querySelectorAll('[ui-lazy]').forEach(el => {\n el.removeAttribute('ui-lazy');\n });\n});\n","/**\n * @author Caleb Porzio\n * @package livewire/livewire\n */\nexport function monkeyPatchDomSetAttributeToAllowAtSymbols() {\n // Because morphdom may add attributes to elements containing \"@\" symbols\n // like in the case of an Alpine `@click` directive, we have to patch\n // the standard Element.setAttribute method to allow this to work.\n let original = Element.prototype.setAttribute;\n\n let hostDiv = document.createElement('div');\n\n Element.prototype.setAttribute = function newSetAttribute(name, value) {\n if (!name.includes('@')) {\n return original.call(this, name, value);\n }\n\n hostDiv.innerHTML = ``;\n\n let attr = (hostDiv.firstElementChild)!.getAttributeNode(name)!;\n\n (hostDiv.firstElementChild)!.removeAttributeNode(attr);\n\n this.setAttributeNode(attr);\n };\n}\n","import Component from './component';\n\n/**\n * Initialize Your Leaf UI root component\n * @param {HTMLElement|Document} element - Root element to find uninitialized components\n */\nexport const init = (element: HTMLElement | Document = document): void => {\n const leafUI = new Component();\n const rootElement = element instanceof Document ? element.body : element;\n\n leafUI.mount(rootElement);\n};\n"],"names":["UINodeType","DIRECTIVE_SHORTHANDS","error","err","expression","el","message","console","warn","Connection","connect","type","uiData","dom","pageState","component","element","closest","componentData","JSON","parse","getAttribute","document","querySelectorAll","forEach","i","attr","key","fetch","window","location","href","stringify","payload","params","method","methodArgs","data","config","credentials","headers","Content-Type","Accept","X-Leaf-UI","this","Referer","then","response","ok","_context","text","_leafUIConfig","state","diff","html","nodeName","body","res","arraysMatch","a","b","Array","isArray","length","every","val","index","leafUI","Dom","getBody","removeScripts","DOMParser","parseFromString","scripts","getElementsByTagName","remove","wrap","node","wrapper","createElement","appendChild","getRootNode","firstChild","getNodeType","nodeType","tagName","toLowerCase","getNodeContent","children","textContent","newNode","oldNode","structuredNewNode","diffElements","newNodes","prototype","slice","call","oldNodes","count","parentNode","removeChild","HTMLScriptElement","src","innerHTML","newNodeClone","cloneNode","replaceChild","Object","values","_node$parentNode","attributes","_oldNodes$index$paren2","nIndex","_node$parentNode$attr2","attribute","_oldNodes$index","_oldNodes$index$paren3","setAttribute","name","value","keys","_oldNodes$index2","_oldNodes$index3","templateContent","fragment","createDocumentFragment","initComponent","replaceWith","compute","refs","computeFunction","Function","join","emit","options","dispatchGlobal","event","CustomEvent","dispatchEvent","directives","ON","parts","eventProps","EVENT_REGISTERED_FLAG","target","some","prop","String","includes","once","passive","addEventListener","KeyboardEvent","test","whitelistedKeycodes","eventProp","isNaN","push","Number","keyCode","preventDefault","stopPropagation","contains","offsetWidth","offsetHeight","ctrlKey","altKey","shiftKey","button","renderDirective","props","toUpperCase","Component","uiNodes","_proto","mount","rootEl","HTMLElement","querySelector","ignoreRootElement","flattenElementChildren","rootElement","collection","childElement","newASTNode","refElements","refElement","collectRefs","hasDirectivePrefix","startsWith","hasDirectiveShorthandPrefix","shorthand","directiveData","directiveName","initDirectives","STATIC","undefined","createASTNode","compile","render","generator","legalDirectiveNames","_iterator","NULL","isStatic","_i","entries","_Object$entries$_i","rawDirectiveName","split","directiveProps","generatorFunction","next","start","performance","now","task","done","setTimeout","original","hostDiv","Element","firstElementChild","getAttributeNode","removeAttributeNode","setAttributeNode","Document","init","removeAttribute"],"mappings":"gnPAsBA,IAAYA,GAAZ,SAAYA,GACRA,oBACAA,uBACAA,yBAHJ,CAAYA,IAAAA,OCtBL,ICmBKC,EDnBCC,EAAQ,SACjBC,EACAC,EACAC,GAEA,IAAIC,oBAA4BH,MAC5BC,IAAYE,uBAA+BF,OAC3CC,IAAIC,iBACRC,QAAQC,KAAKF,EAASD,IELLI,aAAU,cAiE1B,OAjE0BA,EAGbC,QAAP,SACHC,EACAC,EACAC,SAEMC,EAAiC,GACjCC,EAAyBH,EAAOI,QAAQC,QAAQ,cAChDC,EAAgBC,KAAKC,qBAAML,SAAAA,EAAWM,aAAa,eAAe,MAmBxE,OAlBmBC,SAASC,iBAAiB,cAElCC,SAAQ,SAACC,SACVC,EAAOP,KAAKC,eAAMK,EAAEJ,aAAa,eAAe,MACtDP,EAAUY,EAAKC,KAAOD,KAcnBE,MACAC,OAAOC,SAASC,yBAAwBZ,KAAKa,UAZpC,CACZrB,KAAAA,EACAsB,QAAS,CACLC,OAAQ,GACRC,OAAQvB,EAAOuB,OACfC,WAAYxB,EAAOwB,WACnBrB,gBAAWG,S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H,mBAAqBe,OAASC,cAEtC,IAAI9F,EAAQmM,EAAQE,kBAAoBC,iBAAiBzG,GAExDsG,EAAQE,kBAAoBE,oBAAoBvM,GAEjDkB,KAAKsL,iBAAiBxM,ICjBV,SAACV,YAAAA,IAAAA,EAAkCM,UACnD,IAAM6C,EAAS,IAAI0G,EACbS,EAActK,aAAmBmN,SAAWnN,EAAQwC,KAAOxC,EAEjEmD,EAAO6G,MAAMM,GFJb8C,GAEA9M,SAASC,iBAAiB,aAAaC,SAAQ,SAAAnB,GAC3CA,EAAGgO,gBAAgB"} \ No newline at end of file diff --git a/client/dist/ui.esm.js b/client/dist/ui.esm.js index c89cb0b..66c546d 100644 --- a/client/dist/ui.esm.js +++ b/client/dist/ui.esm.js @@ -393,15 +393,23 @@ var Connection = /*#__PURE__*/function () { function Connection() {} Connection.connect = function connect(type, uiData, dom) { var _component$getAttribu; + var pageState = {}; var component = uiData.element.closest('[ui-state]'); - var componentData = (_component$getAttribu = component.getAttribute('ui-state')) != null ? _component$getAttribu : '{}'; + var componentData = JSON.parse((_component$getAttribu = component == null ? void 0 : component.getAttribute('ui-state')) != null ? _component$getAttribu : '{}'); + var components = document.querySelectorAll('[ui-state]'); + components.forEach(function (i) { + var _i$getAttribute; + var attr = JSON.parse((_i$getAttribute = i.getAttribute('ui-state')) != null ? _i$getAttribute : '{}'); + pageState[attr.key] = attr; + }); var payload = { type: type, payload: { params: [], method: uiData.method, methodArgs: uiData.methodArgs, - data: componentData + component: componentData == null ? void 0 : componentData.key, + data: pageState } }; return fetch(window.location.href + "?_leaf_ui_config=" + JSON.stringify(payload), { @@ -428,7 +436,7 @@ var Connection = /*#__PURE__*/function () { response.text().then(function (response) { var data = JSON.parse(response); window._leafUIConfig.data = data.state; - dom.diff(data.html, document.body); + dom.diff(data.html, component.nodeName === 'HTML' || !component ? document.body : component); }); _context.next = 9; break; @@ -493,6 +501,24 @@ var Dom = /*#__PURE__*/function () { } return dom.body; } + /** + * Wrap DOM node with a template element + */; + Dom.wrap = function wrap(node) { + var wrapper = document.createElement('x-leafui-wrapper'); + wrapper.appendChild(node); + return wrapper; + } + /** + * Parse string to DOM + * + * @param html The html to parse + */; + Dom.parse = function parse(html) { + var parser = new DOMParser(); + var dom = parser.parseFromString(html, 'text/html'); + return dom.getRootNode().firstChild; + } /** * Get the type for a node * @param {HTMLElement} node The node @@ -520,7 +546,9 @@ var Dom = /*#__PURE__*/function () { * @returns The diffed node */; Dom.diff = function diff(newNode, oldNode) { - Dom.diffElements(Dom.getBody(newNode, false), oldNode); + var structuredNewNode = oldNode.nodeName === 'BODY' ? Dom.getBody(newNode, false) : Dom.getBody(newNode, true).children[0]; + var structuredOldNode = oldNode; + Dom.diffElements(structuredNewNode, structuredOldNode); } /** * Diff the DOM from two elements @@ -539,7 +567,7 @@ var Dom = /*#__PURE__*/function () { } } for (var index = 0; index < newNodes.length; index++) { - var _Object$keys, _oldNodes$index, _oldNodes$index2; + var _node$parentNode$attr, _node$parentNode, _oldNodes$index$paren, _oldNodes$index$paren2, _Object$keys, _oldNodes$index2, _oldNodes$index3; var node = newNodes[index]; if (!oldNodes[index]) { var newNodeClone = node.cloneNode(true); @@ -554,10 +582,22 @@ var Dom = /*#__PURE__*/function () { } continue; } - if (Dom.getNodeType(node) !== Dom.getNodeType(oldNodes[index]) || !arraysMatch((_Object$keys = Object.keys((_oldNodes$index = oldNodes[index]) == null ? void 0 : _oldNodes$index.attributes)) != null ? _Object$keys : [], Object.keys(node.attributes)) || ((_oldNodes$index2 = oldNodes[index]) == null ? void 0 : _oldNodes$index2.innerHTML) !== node.innerHTML) { + if (!arraysMatch(Object.values((_node$parentNode$attr = (_node$parentNode = node.parentNode) == null ? void 0 : _node$parentNode.attributes) != null ? _node$parentNode$attr : {}), Object.values((_oldNodes$index$paren = (_oldNodes$index$paren2 = oldNodes[index].parentNode) == null ? void 0 : _oldNodes$index$paren2.attributes) != null ? _oldNodes$index$paren : {}))) { + for (var nIndex = 0; nIndex < ((_node$parentNode$attr2 = node.parentNode.attributes) == null ? void 0 : _node$parentNode$attr2.length); nIndex++) { + var _node$parentNode$attr2, _oldNodes$index, _oldNodes$index$paren3; + var attribute = node.parentNode.attributes[nIndex]; + (_oldNodes$index = oldNodes[index]) == null ? void 0 : (_oldNodes$index$paren3 = _oldNodes$index.parentNode) == null ? void 0 : _oldNodes$index$paren3.setAttribute(attribute.name, attribute.value); + } + } + if (Dom.getNodeType(node) !== Dom.getNodeType(oldNodes[index]) || !arraysMatch((_Object$keys = Object.keys((_oldNodes$index2 = oldNodes[index]) == null ? void 0 : _oldNodes$index2.attributes)) != null ? _Object$keys : [], Object.keys(node.attributes)) || ((_oldNodes$index3 = oldNodes[index]) == null ? void 0 : _oldNodes$index3.innerHTML) !== node.innerHTML) { var _newNodeClone2 = node.cloneNode(true); - oldNodes[index].parentNode.replaceChild(_newNodeClone2, oldNodes[index]); - initComponent(_newNodeClone2); + if (!oldNodes[index].parentNode) { + oldNodes[index].replaceWith(_newNodeClone2); + initComponent(_newNodeClone2); + } else { + oldNodes[index].parentNode.replaceChild(_newNodeClone2, oldNodes[index]); + initComponent(_newNodeClone2); + } continue; } // If content is different, update it diff --git a/client/dist/ui.esm.js.map b/client/dist/ui.esm.js.map index ef06554..de6cc3c 100644 --- a/client/dist/ui.esm.js.map +++ b/client/dist/ui.esm.js.map @@ -1 +1 @@ -{"version":3,"file":"ui.esm.js","sources":["../src/@types/core.ts","../src/utils/error.ts","../src/server/connection.ts","../src/utils/data.ts","../src/engine/dom.ts","../src/engine/compute.ts","../src/engine/compile.ts","../src/utils/lazy.ts","../src/core/directives/on.ts","../src/core/directives.ts","../src/engine/render.ts","../src/core/component.ts","../src/core/index.ts","../src/utils/reset.ts","../src/index.ts"],"sourcesContent":["export type Directives = Record void>;\n\nexport interface DirectiveProps {\n el: HTMLElement;\n parts: string[];\n data: DirectiveData;\n node?: UINode;\n}\n\nexport type KeyedEvent = KeyboardEvent | MouseEvent | TouchEvent;\n\nexport interface DirectiveData {\n compute: (event?: Event) => any;\n value: string;\n}\n\nexport interface UINode {\n directives: Record;\n el: HTMLElement;\n type: UINodeType;\n}\n\nexport enum UINodeType {\n NULL = -1,\n STATIC = 0,\n DYNAMIC = 1\n}\n\nexport interface LeafUIConfig {\n el: HTMLElement;\n data: Record;\n methods: string[];\n id: string;\n path: string;\n requestMethod: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD';\n component: string;\n}\n","export const error = (\n err: string,\n expression?: string,\n el?: HTMLElement\n): void => {\n let message = `LeafUI Error: \"${err}\"`;\n if (expression) message += `\\n\\nExpression: \"${expression}\"`;\n if (el) message += `\\nElement:`;\n console.warn(message, el);\n};\n","import Dom from './../engine/dom';\nimport { error } from './../utils/error';\n\nexport default class Connection {\n protected static headers: Record;\n\n public static connect(\n type: string,\n uiData: Record,\n dom: typeof Dom\n ) {\n const component: Element = uiData.element.closest('[ui-state]');\n const componentData = component.getAttribute('ui-state') ?? '{}';\n\n const payload = {\n type,\n payload: {\n params: [],\n method: uiData.method,\n methodArgs: uiData.methodArgs,\n data: componentData,\n }\n };\n\n return fetch(\n `${window.location.href}?_leaf_ui_config=${JSON.stringify(\n payload\n )}`,\n {\n method: uiData.config.method,\n // This enables \"cookies\".\n credentials: 'same-origin',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'text/html, application/xhtml+xml',\n 'X-Leaf-UI': 'true',\n\n // set Custom Headers\n ...this.headers,\n\n // We'll set this explicitly to mitigate potential interference from ad-blockers/etc.\n Referer: window.location.href\n }\n }\n ).then(async response => {\n if (response.ok) {\n response.text().then(response => {\n const data = JSON.parse(response);\n window._leafUIConfig.data = data.state;\n dom.diff(data.html, document.body!);\n });\n } else {\n error(await response.text().then(res => res));\n }\n });\n }\n}\n","import Component from './../core/component';\nimport { LeafUIConfig } from './../@types/core';\n\nexport const eventDirectivePrefixRE = (): RegExp => /on|@/gim;\nexport const rawDirectiveSplitRE = (): RegExp => /:|\\./gim;\n\nexport const hasDirectiveRE = (): RegExp => {\n return new RegExp(\n `(ui-|${Object.keys(DIRECTIVE_SHORTHANDS).join('|')})\\\\w+`,\n 'gim'\n );\n};\n\nexport const expressionPropRE = (prop: string): RegExp => {\n // Utilizes \\b (word boundary) for prop differentiation.\n // Fails when next character is a \\w (Word).\n return new RegExp(`\\\\b${prop}\\\\b`, 'gim');\n};\n\nexport enum DIRECTIVE_SHORTHANDS {\n '@' = 'on',\n ':' = 'bind'\n}\n\nexport function arraysMatch(a: any[], b: any[]) {\n return (\n Array.isArray(a) &&\n Array.isArray(b) &&\n a.length === b.length &&\n a.every((val, index) => val === b[index])\n );\n}\n\ndeclare global {\n interface Window {\n leafUI: {\n rootEl?: HTMLElement;\n component: Component;\n };\n _leafUIConfig: LeafUIConfig;\n }\n\n interface HTMLElement {\n component: Component;\n compile: () => void;\n }\n}\n\nwindow.leafUI = window.leafUI || {};\n","import { initComponent } from './../core/component';\nimport { arraysMatch } from './../utils/data';\n\nexport default class Dom {\n /**\n * Get the body of an HTML string\n *\n * @param html The html to parse\n * @param removeScripts Whether to remove scripts from the html\n * @returns The body of the html\n */\n public static getBody(\n html: string,\n removeScripts: boolean = false\n ): HTMLElement {\n const parser = new DOMParser();\n const dom = parser.parseFromString(html, 'text/html');\n\n if (removeScripts === true) {\n const scripts = dom.body.getElementsByTagName('script');\n\n for (let i = 0; i < scripts.length; i++) {\n scripts[i].remove();\n }\n }\n\n return dom.body;\n }\n\n /**\n * Get the type for a node\n * @param {HTMLElement} node The node\n * @return {String} The type\n */\n public static getNodeType(node: HTMLElement): string {\n if (node.nodeType === 3) return 'text';\n if (node.nodeType === 8) return 'comment';\n return node.tagName.toLowerCase();\n }\n\n /**\n * Get the content from a node\n * @param {Node} node The node\n * @return {String} The type\n */\n public static getNodeContent(node: HTMLElement) {\n if (node.children && node.children.length > 0) return null;\n return node.textContent;\n }\n\n /**\n * Diff the DOM from a string and an element\n *\n * @param newNode The new node\n * @param oldNode The old node\n * @returns The diffed node\n */\n public static diff(newNode: string, oldNode: HTMLElement): void {\n Dom.diffElements(Dom.getBody(newNode, false), oldNode);\n }\n\n /**\n * Diff the DOM from two elements\n *\n * @param newNode The new node\n * @param oldNode The old node\n * @returns The diffed node\n */\n public static diffElements(\n newNode: HTMLElement,\n oldNode: HTMLElement\n ): void {\n const newNodes = Array.prototype.slice.call(newNode.children);\n const oldNodes = Array.prototype.slice.call(oldNode.children);\n\n let count = oldNodes.length - newNodes.length;\n if (count > 0) {\n for (; count > 0; count--) {\n oldNodes[oldNodes.length - count].parentNode.removeChild(\n oldNodes[oldNodes.length - count]\n );\n }\n }\n\n for (let index = 0; index < newNodes.length; index++) {\n const node = newNodes[index];\n\n if (!oldNodes[index]) {\n const newNodeClone = node.cloneNode(true);\n oldNode.appendChild(newNodeClone);\n initComponent(newNodeClone);\n continue;\n }\n\n if (\n node instanceof HTMLScriptElement &&\n oldNodes[index] instanceof HTMLScriptElement\n ) {\n if (\n node.src !== oldNodes[index].src ||\n node.innerHTML !== oldNodes[index].innerHTML\n ) {\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n }\n\n continue;\n }\n\n if (\n Dom.getNodeType(node) !== Dom.getNodeType(oldNodes[index]) ||\n !arraysMatch(\n Object.keys(oldNodes[index]?.attributes) ?? [],\n Object.keys(node.attributes)\n ) ||\n oldNodes[index]?.innerHTML !== node.innerHTML\n ) {\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n initComponent(newNodeClone);\n continue;\n }\n\n // If content is different, update it\n const templateContent = Dom.getNodeContent(node);\n if (\n templateContent &&\n templateContent !== Dom.getNodeContent(oldNodes[index])\n ) {\n oldNodes[index].textContent = templateContent;\n }\n\n if (\n oldNodes[index].children.length > 0 &&\n node.children.length < 1\n ) {\n oldNodes[index].innerHTML = '';\n continue;\n }\n\n if (\n oldNodes[index].children.length < 1 &&\n node.children.length > 0\n ) {\n const fragment = document.createDocumentFragment();\n Dom.diffElements(node, fragment as any);\n oldNodes[index].appendChild(fragment);\n continue;\n }\n\n if (node.children.length > 0) {\n Dom.diffElements(node, oldNodes[index]);\n }\n }\n }\n}\n","import { error } from '../utils/error';\nimport Connection from './../server/connection';\nimport Dom from './dom';\n\nexport const compute = (\n expression: string,\n el?: HTMLElement,\n refs: Record = {}\n): ((event?: Event) => any) => {\n const specialPropertiesNames = ['$el', '$emit', '$event', '$refs', '$dom'];\n\n // This \"revives\" a function from a string, only using the new Function syntax once during compilation.\n // This is because raw function is ~50,000x faster than new Function\n const computeFunction = new Function(\n `return (${specialPropertiesNames.join(',')}) => {\n const method = ${JSON.stringify(expression)}.split('(')[0];\n const methodArgs = ${JSON.stringify(expression)}.substring(${JSON.stringify(expression)}.indexOf('(') + 1, ${JSON.stringify(expression)}.lastIndexOf(')'));\n\n if (!window._leafUIConfig.methods.includes(method)) {\n return error(new ReferenceError(method + ' is not defined'), method, $el);\n }\n\n (${\n Connection.connect\n })('callMethod', { element: $el, method, methodArgs, config: window._leafUIConfig }, $dom);\n }`\n )();\n\n const emit = (\n name: string,\n options?: CustomEventInit,\n dispatchGlobal = true\n ) => {\n const event = new CustomEvent(name, options);\n const target = dispatchGlobal ? window : el || window;\n\n target.dispatchEvent(event);\n };\n\n return (event?: Event) => {\n try {\n return computeFunction(el, emit, event, refs, Dom);\n } catch (err) {\n error(err as string, expression, el);\n }\n };\n};\n","import { DirectiveData, UINode, UINodeType } from '../@types/core';\nimport { compute } from './compute';\nimport { DIRECTIVE_SHORTHANDS } from '../utils/data';\n\nexport const flattenElementChildren = (\n rootElement: HTMLElement,\n ignoreRootElement = false\n): HTMLElement[] => {\n const collection: HTMLElement[] = [];\n\n if (!ignoreRootElement) {\n collection.push(rootElement);\n }\n\n for (const childElement of rootElement.children as any) {\n if (childElement instanceof HTMLElement) {\n collection.push(\n ...flattenElementChildren(\n childElement,\n childElement.attributes.length === 0\n )\n );\n }\n }\n\n return collection;\n};\n\nexport const collectRefs = (\n element: HTMLElement | Document = document\n): Record => {\n const refDirective = 'ui-ref';\n const refElements: NodeListOf = element.querySelectorAll(\n `[${refDirective}]`\n );\n const refs: Record = {};\n\n refElements.forEach(refElement => {\n const name = refElement.getAttribute(refDirective);\n\n if (name) {\n refs[name] = refElement;\n }\n });\n\n return refs;\n};\n\nexport const initDirectives = (\n el: HTMLElement\n): Record => {\n const directives: Record = {};\n const refs = collectRefs();\n\n // @ts-ignore\n for (const { name, value } of el.attributes) {\n const hasDirectivePrefix = name.startsWith('ui-');\n const hasDirectiveShorthandPrefix = Object.keys(\n DIRECTIVE_SHORTHANDS\n ).some(shorthand => name.startsWith(shorthand));\n\n if (!(hasDirectivePrefix || hasDirectiveShorthandPrefix)) {\n continue;\n }\n\n const directiveData = {\n compute: compute(value, el, refs),\n value\n };\n\n // Handle normal and shorthand directives=\n const directiveName = hasDirectivePrefix\n ? name.slice('ui-'.length)\n : // @ts-ignore\n `${DIRECTIVE_SHORTHANDS[name[0]]}:${name.slice(1)}`;\n\n directives[directiveName.toLowerCase()] = directiveData;\n }\n\n return directives;\n};\n\nexport const createASTNode = (el: HTMLElement): UINode | undefined => {\n const directives = initDirectives(el);\n const hasDirectives = Object.keys(directives).length > 0;\n const node = { el, directives, type: UINodeType.STATIC };\n\n return hasDirectives ? node : undefined;\n};\n\nexport const compile = (\n el: HTMLElement,\n ignoreRootElement = false\n): UINode[] => {\n const uiNodes: UINode[] = [];\n const elements = flattenElementChildren(el, ignoreRootElement);\n\n elements.forEach(element => {\n const newASTNode = createASTNode(element);\n\n if (newASTNode) {\n uiNodes.push(newASTNode);\n }\n });\n\n return uiNodes;\n};\n","/**\n * @author Aiden Bai \n * @package lucia\n */\n// Lazy allows us to delay render calls if the main thread is blocked\n// This is kind of like time slicing in React but less advanced\n// It's a generator function that yields after a certain amount of time\n// This allows the browser to render other things while the generator is running\n// It's a bit like a setTimeout but it's more accurate\n\nexport const lazy = (\n threshold: number,\n generatorFunction: () => Generator,\n): (() => void) => {\n const generator = generatorFunction();\n return function next() {\n const start = performance.now();\n let task = null;\n do {\n task = generator.next();\n } while (performance.now() - start < threshold && !task.done);\n\n if (task.done) return;\n setTimeout(next);\n };\n};\n\nexport default lazy;\n","import { DirectiveProps, KeyedEvent } from './../../@types/core';\n\nexport const onDirective = ({ el, parts, data }: DirectiveProps): void => {\n const options: Record = {};\n const globalScopeEventProps = ['outside', 'global'];\n const eventProps = parts.slice(2);\n const EVENT_REGISTERED_FLAG = `__on_${parts[1]}_registered`;\n\n // @ts-expect-error: We're adding a custom property to the element\n if (el[EVENT_REGISTERED_FLAG]) return;\n\n const target = globalScopeEventProps.some(prop =>\n String(eventProps).includes(prop)\n )\n ? window\n : el;\n\n const handler = (event: Event) => { \n if (eventProps.length > 0) {\n if (\n event instanceof KeyboardEvent &&\n /\\d/gim.test(String(eventProps))\n ) {\n const whitelistedKeycodes: number[] = [];\n eventProps.forEach(eventProp => {\n // @ts-expect-error: eventProp can be a string, but isNaN only accepts number\n if (!isNaN(eventProp)) {\n whitelistedKeycodes.push(Number(eventProp));\n }\n });\n\n if (!whitelistedKeycodes.includes(event.keyCode)) return;\n }\n\n // Parse event modifiers based on directive prop\n if (eventProps.includes('prevent')) event.preventDefault();\n if (eventProps.includes('stop')) event.stopPropagation();\n if (eventProps.includes('self')) {\n if (event.target !== el) return;\n }\n /* istanbul ignore next */\n if (eventProps.includes('outside')) {\n if (el.contains(event.target as Node)) return;\n if (el.offsetWidth < 1 && el.offsetHeight < 1) return;\n }\n\n if (eventProps.includes('enter') || eventProps.includes('meta')) {\n if ((event as KeyboardEvent).key === 'Enter') {\n data.compute(event);\n }\n }\n\n if (\n (eventProps.includes('ctrl') &&\n (event as KeyedEvent).ctrlKey) ||\n (eventProps.includes('alt') && (event as KeyedEvent).altKey) ||\n (eventProps.includes('shift') &&\n (event as KeyedEvent).shiftKey) ||\n (eventProps.includes('left') &&\n 'button' in event &&\n (event as MouseEvent).button === 0) ||\n (eventProps.includes('middle') &&\n 'button' in event &&\n (event as MouseEvent).button === 1) ||\n (eventProps.includes('right') &&\n 'button' in event &&\n (event as MouseEvent).button === 2)\n ) {\n data.compute(event);\n }\n } else {\n data.compute(event);\n }\n };\n\n options.once = eventProps.includes('once');\n options.passive = eventProps.includes('passive');\n\n target.addEventListener(parts[1], handler, options);\n\n // @ts-expect-error: We're adding a custom property to the element\n el[EVENT_REGISTERED_FLAG] = true;\n};\n","import { DirectiveProps, Directives } from './../@types/core';\n// import { bindDirective } from './directives/bind';\n// import { modelDirective } from './directives/model';\nimport { onDirective } from './directives/on';\n\nexport const directives: Directives = {\n // BIND: bindDirective,\n // MODEL: modelDirective,\n ON: onDirective,\n};\n\nexport const renderDirective = (\n props: DirectiveProps,\n directives: Directives\n): void => {\n directives[props.parts[0].toUpperCase()](props);\n};\n","import lazy from './../utils/lazy';\nimport { renderDirective } from './../core/directives';\nimport { rawDirectiveSplitRE } from './../utils/data';\nimport { Directives, UINode, UINodeType } from './../@types/core';\n\nconst render = (\n uiNodes: UINode[],\n directives: Directives,\n): void => {\n const legalDirectiveNames = Object.keys(directives);\n const LAZY_MODE_TIMEOUT = 25;\n\n lazy(LAZY_MODE_TIMEOUT, function*() {\n for (const node of uiNodes) {\n if (node.type === UINodeType.NULL) continue;\n const isStatic = node.type === UINodeType.STATIC;\n if (isStatic) node.type = UINodeType.NULL;\n yield;\n\n if (!isStatic) continue;\n\n for (const [directiveName, directiveData] of Object.entries(\n node.directives\n )) {\n const rawDirectiveName = directiveName.split(\n rawDirectiveSplitRE()\n )[0];\n\n if (\n !legalDirectiveNames.includes(\n rawDirectiveName.toUpperCase()\n )\n )\n continue;\n yield;\n\n // If affected, then push to render queue\n if (isStatic) {\n const directiveProps = {\n el: node.el,\n parts: directiveName.split(rawDirectiveSplitRE()),\n data: directiveData,\n node,\n };\n\n renderDirective(directiveProps, directives);\n\n // [TODO] Remove this after testing\n delete node.directives[directiveName];\n }\n }\n }\n })();\n};\n\nexport default render;\n","import { UINode } from './../@types/core';\nimport { compile } from '../engine/compile';\nimport render from '../engine/render';\nimport { directives } from './directives';\n\nexport default class Component {\n public uiNodes: UINode[] = [];\n\n constructor() {\n this.uiNodes = [];\n }\n\n public mount(el: HTMLElement | string) {\n const rootEl =\n el instanceof HTMLElement\n ? el\n : document.querySelector(el) || document.body;\n\n this.uiNodes = compile(rootEl);\n this.render();\n rootEl['component'] = this;\n\n window.leafUI = {\n rootEl,\n component: this\n };\n\n return this;\n }\n\n /**\n * Force renders the DOM based on props\n * @param {string[]=} props - Array of root level properties in state\n * @returns {undefined}\n */\n public render() {\n render(this.uiNodes, directives);\n }\n}\n\nexport const initComponent = (element: Element) =>\n new Component().mount(element as HTMLElement);\n","import Component from './component';\n\n/**\n * Initialize Your Leaf UI root component\n * @param {HTMLElement|Document} element - Root element to find uninitialized components\n */\nexport const init = (element: HTMLElement | Document = document): void => {\n const leafUI = new Component();\n const rootElement = element instanceof Document ? element.body : element;\n\n leafUI.mount(rootElement);\n};\n","/**\n * @author Caleb Porzio\n * @package livewire/livewire\n */\nexport function monkeyPatchDomSetAttributeToAllowAtSymbols() {\n // Because morphdom may add attributes to elements containing \"@\" symbols\n // like in the case of an Alpine `@click` directive, we have to patch\n // the standard Element.setAttribute method to allow this to work.\n let original = Element.prototype.setAttribute;\n\n let hostDiv = document.createElement('div');\n\n Element.prototype.setAttribute = function newSetAttribute(name, value) {\n if (!name.includes('@')) {\n return original.call(this, name, value);\n }\n\n hostDiv.innerHTML = ``;\n\n let attr = (hostDiv.firstElementChild)!.getAttributeNode(name)!;\n\n (hostDiv.firstElementChild)!.removeAttributeNode(attr);\n\n this.setAttributeNode(attr);\n };\n}\n","import { init } from './core';\nimport { monkeyPatchDomSetAttributeToAllowAtSymbols } from './utils/reset';\nexport * from './@types';\n\ndocument.addEventListener('DOMContentLoaded', () => {\n monkeyPatchDomSetAttributeToAllowAtSymbols();\n init();\n\n document.querySelectorAll('[ui-lazy]').forEach(el => {\n el.removeAttribute('ui-lazy');\n });\n});\n"],"names":["UINodeType","error","err","expression","el","message","console","warn","Connection","connect","type","uiData","dom","component","element","closest","componentData","getAttribute","payload","params","method","methodArgs","data","fetch","window","location","href","JSON","stringify","config","credentials","headers","Accept","Referer","then","response","ok","text","parse","_leafUIConfig","state","diff","html","document","body","res","rawDirectiveSplitRE","DIRECTIVE_SHORTHANDS","arraysMatch","a","b","Array","isArray","length","every","val","index","leafUI","Dom","getBody","removeScripts","parser","DOMParser","parseFromString","scripts","getElementsByTagName","i","remove","getNodeType","node","nodeType","tagName","toLowerCase","getNodeContent","children","textContent","newNode","oldNode","diffElements","newNodes","prototype","slice","call","oldNodes","count","parentNode","removeChild","newNodeClone","cloneNode","appendChild","initComponent","HTMLScriptElement","src","innerHTML","replaceChild","Object","keys","attributes","templateContent","fragment","createDocumentFragment","compute","refs","specialPropertiesNames","computeFunction","Function","join","emit","name","options","dispatchGlobal","event","CustomEvent","target","dispatchEvent","flattenElementChildren","rootElement","ignoreRootElement","collection","push","childElement","HTMLElement","collectRefs","refDirective","refElements","querySelectorAll","forEach","refElement","initDirectives","directives","value","hasDirectivePrefix","startsWith","hasDirectiveShorthandPrefix","some","shorthand","directiveData","directiveName","createASTNode","hasDirectives","STATIC","undefined","compile","uiNodes","elements","newASTNode","lazy","threshold","generatorFunction","generator","next","start","performance","now","task","done","setTimeout","onDirective","parts","globalScopeEventProps","eventProps","EVENT_REGISTERED_FLAG","prop","String","includes","handler","KeyboardEvent","test","whitelistedKeycodes","eventProp","isNaN","Number","keyCode","preventDefault","stopPropagation","contains","offsetWidth","offsetHeight","key","ctrlKey","altKey","shiftKey","button","once","passive","addEventListener","ON","renderDirective","props","toUpperCase","render","legalDirectiveNames","LAZY_MODE_TIMEOUT","NULL","isStatic","entries","rawDirectiveName","split","directiveProps","Component","mount","rootEl","querySelector","init","Document","monkeyPatchDomSetAttributeToAllowAtSymbols","original","Element","setAttribute","hostDiv","createElement","newSetAttribute","attr","firstElementChild","getAttributeNode","removeAttributeNode","setAttributeNode","removeAttribute"],"mapp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;IAG3C+E,OAAO,CAACpH,SAAS,cAAYe,IAAI,WAAKsB,KAAK,eAAW;IAEtD,IAAIkF,IAAI,GAAIH,OAAO,CAACI,iBAAiB,CAAGC,gBAAgB,CAAC1G,IAAI,CAAE;IAE9DqG,OAAO,CAACI,iBAAiB,CAAGE,mBAAmB,CAACH,IAAI,CAAC;IAEtD,IAAI,CAACI,gBAAgB,CAACJ,IAAI,CAAC;GAC9B;AACL;;ACrBAzK,QAAQ,CAAC8I,gBAAgB,CAAC,kBAAkB,EAAE;EAC1CoB,0CAA0C,EAAE;EAC5CF,IAAI,EAAE;EAENhK,QAAQ,CAACkF,gBAAgB,CAAC,WAAW,CAAC,CAACC,OAAO,CAAC,UAAA1H,EAAE;IAC7CA,EAAE,CAACqN,eAAe,CAAC,SAAS,CAAC;GAChC,CAAC;AACN,CAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"ui.esm.js","sources":["../src/@types/core.ts","../src/utils/error.ts","../src/server/connection.ts","../src/utils/data.ts","../src/engine/dom.ts","../src/engine/compute.ts","../src/engine/compile.ts","../src/utils/lazy.ts","../src/core/directives/on.ts","../src/core/directives.ts","../src/engine/render.ts","../src/core/component.ts","../src/core/index.ts","../src/utils/reset.ts","../src/index.ts"],"sourcesContent":["export type Directives = Record void>;\n\nexport interface DirectiveProps {\n el: HTMLElement;\n parts: string[];\n data: DirectiveData;\n node?: UINode;\n}\n\nexport type KeyedEvent = KeyboardEvent | MouseEvent | TouchEvent;\n\nexport interface DirectiveData {\n compute: (event?: Event) => any;\n value: string;\n}\n\nexport interface UINode {\n directives: Record;\n el: HTMLElement;\n type: UINodeType;\n}\n\nexport enum UINodeType {\n NULL = -1,\n STATIC = 0,\n DYNAMIC = 1\n}\n\nexport interface LeafUIConfig {\n el: HTMLElement;\n data: Record;\n methods: string[];\n id: string;\n path: string;\n requestMethod: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD';\n component: string;\n}\n","export const error = (\n err: string,\n expression?: string,\n el?: HTMLElement\n): void => {\n let message = `LeafUI Error: \"${err}\"`;\n if (expression) message += `\\n\\nExpression: \"${expression}\"`;\n if (el) message += `\\nElement:`;\n console.warn(message, el);\n};\n","import Dom from './../engine/dom';\nimport { error } from './../utils/error';\n\nexport default class Connection {\n protected static headers: Record;\n\n public static connect(\n type: string,\n uiData: Record,\n dom: typeof Dom\n ) {\n const pageState: Record = {};\n const component: HTMLElement = uiData.element.closest('[ui-state]');\n const componentData = JSON.parse(component?.getAttribute('ui-state') ?? '{}');\n const components = document.querySelectorAll('[ui-state]');\n\n components.forEach((i) => {\n const attr = JSON.parse(i.getAttribute('ui-state') ?? '{}');\n pageState[attr.key] = attr;\n });\n\n const payload = {\n type,\n payload: {\n params: [],\n method: uiData.method,\n methodArgs: uiData.methodArgs,\n component: componentData?.key,\n data: pageState,\n }\n };\n\n return fetch(\n `${window.location.href}?_leaf_ui_config=${JSON.stringify(\n payload\n )}`,\n {\n method: uiData.config.method,\n // This enables \"cookies\".\n credentials: 'same-origin',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'text/html, application/xhtml+xml',\n 'X-Leaf-UI': 'true',\n\n // set Custom Headers\n ...this.headers,\n\n // We'll set this explicitly to mitigate potential interference from ad-blockers/etc.\n Referer: window.location.href\n }\n }\n ).then(async response => {\n if (response.ok) {\n response.text().then(response => {\n const data = JSON.parse(response);\n window._leafUIConfig.data = data.state;\n dom.diff(\n data.html,\n component.nodeName === 'HTML' || !component\n ? document.body!\n : component\n );\n });\n } else {\n error(await response.text().then(res => res));\n }\n });\n }\n}\n","import Component from './../core/component';\nimport { LeafUIConfig } from './../@types/core';\n\nexport const eventDirectivePrefixRE = (): RegExp => /on|@/gim;\nexport const rawDirectiveSplitRE = (): RegExp => /:|\\./gim;\n\nexport const hasDirectiveRE = (): RegExp => {\n return new RegExp(\n `(ui-|${Object.keys(DIRECTIVE_SHORTHANDS).join('|')})\\\\w+`,\n 'gim'\n );\n};\n\nexport const expressionPropRE = (prop: string): RegExp => {\n // Utilizes \\b (word boundary) for prop differentiation.\n // Fails when next character is a \\w (Word).\n return new RegExp(`\\\\b${prop}\\\\b`, 'gim');\n};\n\nexport enum DIRECTIVE_SHORTHANDS {\n '@' = 'on',\n ':' = 'bind'\n}\n\nexport function arraysMatch(a: any[], b: any[]) {\n return (\n Array.isArray(a) &&\n Array.isArray(b) &&\n a.length === b.length &&\n a.every((val, index) => val === b[index])\n );\n}\n\ndeclare global {\n interface Window {\n leafUI: {\n rootEl?: HTMLElement;\n component: Component;\n };\n _leafUIConfig: LeafUIConfig;\n }\n\n interface HTMLElement {\n component: Component;\n compile: () => void;\n }\n}\n\nwindow.leafUI = window.leafUI || {};\n","import { initComponent } from './../core/component';\nimport { arraysMatch } from './../utils/data';\n\nexport default class Dom {\n /**\n * Get the body of an HTML string\n *\n * @param html The html to parse\n * @param removeScripts Whether to remove scripts from the html\n * @returns The body of the html\n */\n public static getBody(\n html: string,\n removeScripts: boolean = false\n ): HTMLElement {\n const parser = new DOMParser();\n const dom = parser.parseFromString(html, 'text/html');\n\n if (removeScripts === true) {\n const scripts = dom.body.getElementsByTagName('script');\n\n for (let i = 0; i < scripts.length; i++) {\n scripts[i].remove();\n }\n }\n\n return dom.body;\n }\n\n /**\n * Wrap DOM node with a template element\n */\n public static wrap(node: Node): HTMLElement {\n const wrapper = document.createElement('x-leafui-wrapper');\n wrapper.appendChild(node);\n return wrapper;\n }\n\n /**\n * Parse string to DOM\n *\n * @param html The html to parse\n */\n public static parse(html: string): HTMLElement {\n const parser = new DOMParser();\n const dom = parser.parseFromString(html, 'text/html');\n\n return dom.getRootNode().firstChild as HTMLElement;\n }\n\n /**\n * Get the type for a node\n * @param {HTMLElement} node The node\n * @return {String} The type\n */\n public static getNodeType(node: HTMLElement): string {\n if (node.nodeType === 3) return 'text';\n if (node.nodeType === 8) return 'comment';\n return node.tagName.toLowerCase();\n }\n\n /**\n * Get the content from a node\n * @param {Node} node The node\n * @return {String} The type\n */\n public static getNodeContent(node: HTMLElement) {\n if (node.children && node.children.length > 0) return null;\n return node.textContent;\n }\n\n /**\n * Diff the DOM from a string and an element\n *\n * @param newNode The new node\n * @param oldNode The old node\n * @returns The diffed node\n */\n public static diff(newNode: string, oldNode: HTMLElement): void {\n const structuredNewNode =\n oldNode.nodeName === 'BODY'\n ? Dom.getBody(newNode, false)\n : Dom.getBody(newNode, true).children[0];\n const structuredOldNode = oldNode;\n\n Dom.diffElements(structuredNewNode as HTMLElement, structuredOldNode);\n }\n\n /**\n * Diff the DOM from two elements\n *\n * @param newNode The new node\n * @param oldNode The old node\n * @returns The diffed node\n */\n public static diffElements(\n newNode: HTMLElement,\n oldNode: HTMLElement\n ): void {\n const newNodes = Array.prototype.slice.call(newNode.children);\n const oldNodes = Array.prototype.slice.call(oldNode.children);\n\n let count = oldNodes.length - newNodes.length;\n\n if (count > 0) {\n for (; count > 0; count--) {\n oldNodes[oldNodes.length - count].parentNode.removeChild(\n oldNodes[oldNodes.length - count]\n );\n }\n }\n\n for (let index = 0; index < newNodes.length; index++) {\n const node = newNodes[index];\n\n if (!oldNodes[index]) {\n const newNodeClone = node.cloneNode(true);\n oldNode.appendChild(newNodeClone);\n initComponent(newNodeClone);\n continue;\n }\n\n if (\n node instanceof HTMLScriptElement &&\n oldNodes[index] instanceof HTMLScriptElement\n ) {\n if (\n node.src !== oldNodes[index].src ||\n node.innerHTML !== oldNodes[index].innerHTML\n ) {\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n }\n\n continue;\n }\n\n if (\n !arraysMatch(\n Object.values(node.parentNode?.attributes ?? {}),\n Object.values(oldNodes[index].parentNode?.attributes ?? {})\n )\n ) {\n for (\n let nIndex = 0;\n nIndex < node.parentNode.attributes?.length;\n nIndex++\n ) {\n const attribute = node.parentNode.attributes[nIndex];\n oldNodes[index]?.parentNode?.setAttribute(\n attribute.name,\n attribute.value\n );\n }\n }\n\n if (\n Dom.getNodeType(node) !== Dom.getNodeType(oldNodes[index]) ||\n !arraysMatch(\n Object.keys(oldNodes[index]?.attributes) ?? [],\n Object.keys(node.attributes)\n ) ||\n oldNodes[index]?.innerHTML !== node.innerHTML\n ) {\n const newNodeClone = node.cloneNode(true);\n\n if (!oldNodes[index].parentNode) {\n oldNodes[index].replaceWith(newNodeClone);\n initComponent(newNodeClone);\n } else {\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n initComponent(newNodeClone);\n }\n\n continue;\n }\n\n // If content is different, update it\n const templateContent = Dom.getNodeContent(node);\n if (\n templateContent &&\n templateContent !== Dom.getNodeContent(oldNodes[index])\n ) {\n oldNodes[index].textContent = templateContent;\n }\n\n if (\n oldNodes[index].children.length > 0 &&\n node.children.length < 1\n ) {\n oldNodes[index].innerHTML = '';\n continue;\n }\n\n if (\n oldNodes[index].children.length < 1 &&\n node.children.length > 0\n ) {\n const fragment = document.createDocumentFragment();\n Dom.diffElements(node, fragment as any);\n oldNodes[index].appendChild(fragment);\n continue;\n }\n\n if (node.children.length > 0) {\n Dom.diffElements(node, oldNodes[index]);\n }\n }\n }\n}\n","import { error } from '../utils/error';\nimport Connection from './../server/connection';\nimport Dom from './dom';\n\nexport const compute = (\n expression: string,\n el?: HTMLElement,\n refs: Record = {}\n): ((event?: Event) => any) => {\n const specialPropertiesNames = ['$el', '$emit', '$event', '$refs', '$dom'];\n\n // This \"revives\" a function from a string, only using the new Function syntax once during compilation.\n // This is because raw function is ~50,000x faster than new Function\n const computeFunction = new Function(\n `return (${specialPropertiesNames.join(',')}) => {\n const method = ${JSON.stringify(expression)}.split('(')[0];\n const methodArgs = ${JSON.stringify(expression)}.substring(${JSON.stringify(expression)}.indexOf('(') + 1, ${JSON.stringify(expression)}.lastIndexOf(')'));\n\n if (!window._leafUIConfig.methods.includes(method)) {\n return error(new ReferenceError(method + ' is not defined'), method, $el);\n }\n\n (${\n Connection.connect\n })('callMethod', { element: $el, method, methodArgs, config: window._leafUIConfig }, $dom);\n }`\n )();\n\n const emit = (\n name: string,\n options?: CustomEventInit,\n dispatchGlobal = true\n ) => {\n const event = new CustomEvent(name, options);\n const target = dispatchGlobal ? window : el || window;\n\n target.dispatchEvent(event);\n };\n\n return (event?: Event) => {\n try {\n return computeFunction(el, emit, event, refs, Dom);\n } catch (err) {\n error(err as string, expression, el);\n }\n };\n};\n","import { DirectiveData, UINode, UINodeType } from '../@types/core';\nimport { compute } from './compute';\nimport { DIRECTIVE_SHORTHANDS } from '../utils/data';\n\nexport const flattenElementChildren = (\n rootElement: HTMLElement,\n ignoreRootElement = false\n): HTMLElement[] => {\n const collection: HTMLElement[] = [];\n\n if (!ignoreRootElement) {\n collection.push(rootElement);\n }\n\n for (const childElement of rootElement.children as any) {\n if (childElement instanceof HTMLElement) {\n collection.push(\n ...flattenElementChildren(\n childElement,\n childElement.attributes.length === 0\n )\n );\n }\n }\n\n return collection;\n};\n\nexport const collectRefs = (\n element: HTMLElement | Document = document\n): Record => {\n const refDirective = 'ui-ref';\n const refElements: NodeListOf = element.querySelectorAll(\n `[${refDirective}]`\n );\n const refs: Record = {};\n\n refElements.forEach(refElement => {\n const name = refElement.getAttribute(refDirective);\n\n if (name) {\n refs[name] = refElement;\n }\n });\n\n return refs;\n};\n\nexport const initDirectives = (\n el: HTMLElement\n): Record => {\n const directives: Record = {};\n const refs = collectRefs();\n\n // @ts-ignore\n for (const { name, value } of el.attributes) {\n const hasDirectivePrefix = name.startsWith('ui-');\n const hasDirectiveShorthandPrefix = Object.keys(\n DIRECTIVE_SHORTHANDS\n ).some(shorthand => name.startsWith(shorthand));\n\n if (!(hasDirectivePrefix || hasDirectiveShorthandPrefix)) {\n continue;\n }\n\n const directiveData = {\n compute: compute(value, el, refs),\n value\n };\n\n // Handle normal and shorthand directives=\n const directiveName = hasDirectivePrefix\n ? name.slice('ui-'.length)\n : // @ts-ignore\n `${DIRECTIVE_SHORTHANDS[name[0]]}:${name.slice(1)}`;\n\n directives[directiveName.toLowerCase()] = directiveData;\n }\n\n return directives;\n};\n\nexport const createASTNode = (el: HTMLElement): UINode | undefined => {\n const directives = initDirectives(el);\n const hasDirectives = Object.keys(directives).length > 0;\n const node = { el, directives, type: UINodeType.STATIC };\n\n return hasDirectives ? node : undefined;\n};\n\nexport const compile = (\n el: HTMLElement,\n ignoreRootElement = false\n): UINode[] => {\n const uiNodes: UINode[] = [];\n const elements = flattenElementChildren(el, ignoreRootElement);\n\n elements.forEach(element => {\n const newASTNode = createASTNode(element);\n\n if (newASTNode) {\n uiNodes.push(newASTNode);\n }\n });\n\n return uiNodes;\n};\n","/**\n * @author Aiden Bai \n * @package lucia\n */\n// Lazy allows us to delay render calls if the main thread is blocked\n// This is kind of like time slicing in React but less advanced\n// It's a generator function that yields after a certain amount of time\n// This allows the browser to render other things while the generator is running\n// It's a bit like a setTimeout but it's more accurate\n\nexport const lazy = (\n threshold: number,\n generatorFunction: () => Generator,\n): (() => void) => {\n const generator = generatorFunction();\n return function next() {\n const start = performance.now();\n let task = null;\n do {\n task = generator.next();\n } while (performance.now() - start < threshold && !task.done);\n\n if (task.done) return;\n setTimeout(next);\n };\n};\n\nexport default lazy;\n","import { DirectiveProps, KeyedEvent } from './../../@types/core';\n\nexport const onDirective = ({ el, parts, data }: DirectiveProps): void => {\n const options: Record = {};\n const globalScopeEventProps = ['outside', 'global'];\n const eventProps = parts.slice(2);\n const EVENT_REGISTERED_FLAG = `__on_${parts[1]}_registered`;\n\n // @ts-expect-error: We're adding a custom property to the element\n if (el[EVENT_REGISTERED_FLAG]) return;\n\n const target = globalScopeEventProps.some(prop =>\n String(eventProps).includes(prop)\n )\n ? window\n : el;\n\n const handler = (event: Event) => { \n if (eventProps.length > 0) {\n if (\n event instanceof KeyboardEvent &&\n /\\d/gim.test(String(eventProps))\n ) {\n const whitelistedKeycodes: number[] = [];\n eventProps.forEach(eventProp => {\n // @ts-expect-error: eventProp can be a string, but isNaN only accepts number\n if (!isNaN(eventProp)) {\n whitelistedKeycodes.push(Number(eventProp));\n }\n });\n\n if (!whitelistedKeycodes.includes(event.keyCode)) return;\n }\n\n // Parse event modifiers based on directive prop\n if (eventProps.includes('prevent')) event.preventDefault();\n if (eventProps.includes('stop')) event.stopPropagation();\n if (eventProps.includes('self')) {\n if (event.target !== el) return;\n }\n /* istanbul ignore next */\n if (eventProps.includes('outside')) {\n if (el.contains(event.target as Node)) return;\n if (el.offsetWidth < 1 && el.offsetHeight < 1) return;\n }\n\n if (eventProps.includes('enter') || eventProps.includes('meta')) {\n if ((event as KeyboardEvent).key === 'Enter') {\n data.compute(event);\n }\n }\n\n if (\n (eventProps.includes('ctrl') &&\n (event as KeyedEvent).ctrlKey) ||\n (eventProps.includes('alt') && (event as KeyedEvent).altKey) ||\n (eventProps.includes('shift') &&\n (event as KeyedEvent).shiftKey) ||\n (eventProps.includes('left') &&\n 'button' in event &&\n (event as MouseEvent).button === 0) ||\n (eventProps.includes('middle') &&\n 'button' in event &&\n (event as MouseEvent).button === 1) ||\n (eventProps.includes('right') &&\n 'button' in event &&\n (event as MouseEvent).button === 2)\n ) {\n data.compute(event);\n }\n } else {\n data.compute(event);\n }\n };\n\n options.once = eventProps.includes('once');\n options.passive = eventProps.includes('passive');\n\n target.addEventListener(parts[1], handler, options);\n\n // @ts-expect-error: We're adding a custom property to the element\n el[EVENT_REGISTERED_FLAG] = true;\n};\n","import { DirectiveProps, Directives } from './../@types/core';\n// import { bindDirective } from './directives/bind';\n// import { modelDirective } from './directives/model';\nimport { onDirective } from './directives/on';\n\nexport const directives: Directives = {\n // BIND: bindDirective,\n // MODEL: modelDirective,\n ON: onDirective,\n};\n\nexport const renderDirective = (\n props: DirectiveProps,\n directives: Directives\n): void => {\n directives[props.parts[0].toUpperCase()](props);\n};\n","import lazy from './../utils/lazy';\nimport { renderDirective } from './../core/directives';\nimport { rawDirectiveSplitRE } from './../utils/data';\nimport { Directives, UINode, UINodeType } from './../@types/core';\n\nconst render = (\n uiNodes: UINode[],\n directives: Directives,\n): void => {\n const legalDirectiveNames = Object.keys(directives);\n const LAZY_MODE_TIMEOUT = 25;\n\n lazy(LAZY_MODE_TIMEOUT, function*() {\n for (const node of uiNodes) {\n if (node.type === UINodeType.NULL) continue;\n const isStatic = node.type === UINodeType.STATIC;\n if (isStatic) node.type = UINodeType.NULL;\n yield;\n\n if (!isStatic) continue;\n\n for (const [directiveName, directiveData] of Object.entries(\n node.directives\n )) {\n const rawDirectiveName = directiveName.split(\n rawDirectiveSplitRE()\n )[0];\n\n if (\n !legalDirectiveNames.includes(\n rawDirectiveName.toUpperCase()\n )\n )\n continue;\n yield;\n\n // If affected, then push to render queue\n if (isStatic) {\n const directiveProps = {\n el: node.el,\n parts: directiveName.split(rawDirectiveSplitRE()),\n data: directiveData,\n node,\n };\n\n renderDirective(directiveProps, directives);\n\n // [TODO] Remove this after testing\n delete node.directives[directiveName];\n }\n }\n }\n })();\n};\n\nexport default render;\n","import { UINode } from './../@types/core';\nimport { compile } from '../engine/compile';\nimport render from '../engine/render';\nimport { directives } from './directives';\n\nexport default class Component {\n public uiNodes: UINode[] = [];\n\n constructor() {\n this.uiNodes = [];\n }\n\n public mount(el: HTMLElement | string) {\n const rootEl =\n el instanceof HTMLElement\n ? el\n : document.querySelector(el) || document.body;\n\n this.uiNodes = compile(rootEl);\n this.render();\n rootEl['component'] = this;\n\n window.leafUI = {\n rootEl,\n component: this\n };\n\n return this;\n }\n\n /**\n * Force renders the DOM based on props\n * @param {string[]=} props - Array of root level properties in state\n * @returns {undefined}\n */\n public render() {\n render(this.uiNodes, directives);\n }\n}\n\nexport const initComponent = (element: Element) =>\n new Component().mount(element as HTMLElement);\n","import Component from './component';\n\n/**\n * Initialize Your Leaf UI root component\n * @param {HTMLElement|Document} element - Root element to find uninitialized components\n */\nexport const init = (element: HTMLElement | Document = document): void => {\n const leafUI = new Component();\n const rootElement = element instanceof Document ? element.body : element;\n\n leafUI.mount(rootElement);\n};\n","/**\n * @author Caleb Porzio\n * @package livewire/livewire\n */\nexport function monkeyPatchDomSetAttributeToAllowAtSymbols() {\n // Because morphdom may add attributes to elements containing \"@\" symbols\n // like in the case of an Alpine `@click` directive, we have to patch\n // the standard Element.setAttribute method to allow this to work.\n let original = Element.prototype.setAttribute;\n\n let hostDiv = document.createElement('div');\n\n Element.prototype.setAttribute = function newSetAttribute(name, value) {\n if (!name.includes('@')) {\n return original.call(this, name, value);\n }\n\n hostDiv.innerHTML = ``;\n\n let attr = (hostDiv.firstElementChild)!.getAttributeNode(name)!;\n\n (hostDiv.firstElementChild)!.removeAttributeNode(attr);\n\n this.setAttributeNode(attr);\n };\n}\n","import { init } from './core';\nimport { monkeyPatchDomSetAttributeToAllowAtSymbols } from './utils/reset';\nexport * from './@types';\n\ndocument.addEventListener('DOMContentLoaded', () => {\n monkeyPatchDomSetAttributeToAllowAtSymbols();\n init();\n\n document.querySelectorAll('[ui-lazy]').forEach(el => {\n el.removeAttribute('ui-lazy');\n });\n});\n"],"names":["UINodeType","error","err","expression","el","message","console","warn","Connection","connect","type","uiData","dom","pageState","component","element","closest","componentData","JSON","parse","getAttribute","components","document","querySelectorAll","forEach","i","attr","key","payload","params","method","methodArgs","data","fetch","window","location","href","stringify","config","credentials","headers","Accept","Referer","then","response","ok","text","_leafUIConfig","state","diff","html","nodeName","body","res","rawDirectiveSplitRE","DIRECTIVE_SHORTHANDS","arraysMatch","a","b","Array","isArray","length","every","val","index","leafUI","Dom","getBody","removeScripts","parser","DOMParser","parseFromString","scripts","getElementsByTagName","remove","wrap","node","wrapper","createElement","appendChild","getRootNode","firstChild","getNodeType","nodeType","tagName","toLowerCase","getNodeContent","children","textContent","newNode","oldNode","structuredNewNode","structuredOldNode","diffElements","newNodes","prototype","slice","call","oldNodes","count","parentNode","removeChild","newNodeClone","cloneNode","initComponent","HTMLScriptElement","src","innerHTML","replaceChild","Object","values","attributes","nIndex","attribute","setAttribute","name","value","keys","replaceWith","templateContent","fragment","createDocumentFragment","compute","refs","specialPropertiesNames","computeFunction","Function","join","emit","options","dispatchGlobal","event","CustomEvent","target","dispatchEvent","flattenElementChildren","rootElement","ignoreRootElement","collection","push","childElement","HTMLElement","collectRefs","refDirective","refElements","refElement","initDirectives","directives","hasDirectivePrefix","startsWith","hasDirectiveShorthandPrefix","some","shorthand","directiveData","directiveName","createASTNode","hasDirectives","STATIC","undefined","compile","uiNodes","elements","newASTNode","lazy","threshold","generatorFunction","generator","next","start","performance","now","task","done","setTimeout","onDirective","parts","globalScopeEventProps","eventProps","EVENT_REGISTERED_FLAG","prop","String","includes","handler","KeyboardEvent","test","whitelistedKeycodes","eventProp","isNaN","Number","keyCode","preventDefault","stopPropagation","contains","offsetWidth","offsetHeight","ctrlKey","altKey","shiftKey","button","once","passive","addEventListener","ON","renderDirective","props","toUpperCase","render","legalDirectiveNames","LAZY_MODE_TIMEOUT","NULL","isStatic","entries","rawDirectiveName","split","directiveProps","Component","mount","rootEl","querySelector","init","Document","monkeyPatchDomSetAttributeToAllowAtSymbols","original","Element","hostDiv","newSetAttribute","firstElementChild","getAttributeNode","removeAttributeNode","setAttributeNode","removeAttribute"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,IAAYA,UAIX;AAJD,WAAYA,UAAU;EAClBA,4CAAS;EACTA,+CAAU;EACVA,iDAAW;AACf,CAAC,EAJWA,UAAU,KAAVA,UAAU;;ACtBf,IA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AAQ,CAAC,GAAG,CAAC,EAAE;MACrB,OAAOyC,QAAQ,CAAC7H,IAAI,CAAC,IAAI,EAAEkB,IAAI,EAAEC,KAAK,CAAC;;IAG3C4G,OAAO,CAACrH,SAAS,cAAYQ,IAAI,WAAKC,KAAK,eAAW;IAEtD,IAAI1F,IAAI,GAAIsM,OAAO,CAACE,iBAAiB,CAAGC,gBAAgB,CAAChH,IAAI,CAAE;IAE9D6G,OAAO,CAACE,iBAAiB,CAAGE,mBAAmB,CAAC1M,IAAI,CAAC;IAEtD,IAAI,CAAC2M,gBAAgB,CAAC3M,IAAI,CAAC;GAC9B;AACL;;ACrBAJ,QAAQ,CAACmL,gBAAgB,CAAC,kBAAkB,EAAE;EAC1CoB,0CAA0C,EAAE;EAC5CF,IAAI,EAAE;EAENrM,QAAQ,CAACC,gBAAgB,CAAC,WAAW,CAAC,CAACC,OAAO,CAAC,UAAApB,EAAE;IAC7CA,EAAE,CAACkO,eAAe,CAAC,SAAS,CAAC;GAChC,CAAC;AACN,CAAC,CAAC"} \ No newline at end of file diff --git a/client/src/engine/dom.ts b/client/src/engine/dom.ts index e1e3343..7520524 100644 --- a/client/src/engine/dom.ts +++ b/client/src/engine/dom.ts @@ -27,6 +27,27 @@ export default class Dom { return dom.body; } + /** + * Wrap DOM node with a template element + */ + public static wrap(node: Node): HTMLElement { + const wrapper = document.createElement('x-leafui-wrapper'); + wrapper.appendChild(node); + return wrapper; + } + + /** + * Parse string to DOM + * + * @param html The html to parse + */ + public static parse(html: string): HTMLElement { + const parser = new DOMParser(); + const dom = parser.parseFromString(html, 'text/html'); + + return dom.getRootNode().firstChild as HTMLElement; + } + /** * Get the type for a node * @param {HTMLElement} node The node @@ -56,7 +77,13 @@ export default class Dom { * @returns The diffed node */ public static diff(newNode: string, oldNode: HTMLElement): void { - Dom.diffElements(Dom.getBody(newNode, false), oldNode); + const structuredNewNode = + oldNode.nodeName === 'BODY' + ? Dom.getBody(newNode, false) + : Dom.getBody(newNode, true).children[0]; + const structuredOldNode = oldNode; + + Dom.diffElements(structuredNewNode as HTMLElement, structuredOldNode); } /** @@ -74,6 +101,7 @@ export default class Dom { const oldNodes = Array.prototype.slice.call(oldNode.children); let count = oldNodes.length - newNodes.length; + if (count > 0) { for (; count > 0; count--) { oldNodes[oldNodes.length - count].parentNode.removeChild( @@ -110,6 +138,25 @@ export default class Dom { continue; } + if ( + !arraysMatch( + Object.values(node.parentNode?.attributes ?? {}), + Object.values(oldNodes[index].parentNode?.attributes ?? {}) + ) + ) { + for ( + let nIndex = 0; + nIndex < node.parentNode.attributes?.length; + nIndex++ + ) { + const attribute = node.parentNode.attributes[nIndex]; + oldNodes[index]?.parentNode?.setAttribute( + attribute.name, + attribute.value + ); + } + } + if ( Dom.getNodeType(node) !== Dom.getNodeType(oldNodes[index]) || !arraysMatch( @@ -119,11 +166,18 @@ export default class Dom { oldNodes[index]?.innerHTML !== node.innerHTML ) { const newNodeClone = node.cloneNode(true); - oldNodes[index].parentNode.replaceChild( - newNodeClone, - oldNodes[index] - ); - initComponent(newNodeClone); + + if (!oldNodes[index].parentNode) { + oldNodes[index].replaceWith(newNodeClone); + initComponent(newNodeClone); + } else { + oldNodes[index].parentNode.replaceChild( + newNodeClone, + oldNodes[index] + ); + initComponent(newNodeClone); + } + continue; }