From e6d4ea31d0e16046702736e7ba29609d41306072 Mon Sep 17 00:00:00 2001 From: mychidarko Date: Sat, 11 Feb 2023 00:09:05 +0000 Subject: [PATCH] fix: patch up script tag diffing --- client/dist/ui.cjs.development.js | 39 ++++++++++++++++-------- 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 | 39 ++++++++++++++++-------- client/dist/ui.esm.js.map | 2 +- client/src/engine/dom.ts | 35 ++++++++++++++++++--- 7 files changed, 89 insertions(+), 32 deletions(-) diff --git a/client/dist/ui.cjs.development.js b/client/dist/ui.cjs.development.js index ffe7bf1..99c9b28 100644 --- a/client/dist/ui.cjs.development.js +++ b/client/dist/ui.cjs.development.js @@ -497,7 +497,6 @@ var Dom = /*#__PURE__*/function () { if (node.children && node.children.length > 0) return null; return node.textContent; }; - // const diff = Dom.compareNodesAndReturnChanges(newDomBody, oldNode); // If extra elements in DOM, remove them var count = oldNodes.length - newNodes.length; if (count > 0) { @@ -505,19 +504,29 @@ var Dom = /*#__PURE__*/function () { oldNodes[oldNodes.length - count].parentNode.removeChild(oldNodes[oldNodes.length - count]); } } - // Diff each item in the newNodes var _loop = function _loop(index) { var _Object$keys, _oldNodes$index, _Object$values, _oldNodes$index2, _oldNodes$index3; var node = newNodes[index]; + console.log('diffing node', node); if (!oldNodes[index]) { var newNodeClone = node.cloneNode(true); oldNode.appendChild(newNodeClone); + console.log('adding new UI node', newNodeClone); initComponent(newNodeClone); return { v: void 0 }; } + if (node instanceof HTMLScriptElement && oldNodes[index] instanceof HTMLScriptElement) { + if (node.src !== oldNodes[index].src || node.innerHTML !== oldNodes[index].innerHTML) { + var _newNodeClone = node.cloneNode(true); + oldNodes[index].parentNode.replaceChild(_newNodeClone, oldNodes[index]); + console.log('replacing script UI node', _newNodeClone, oldNodes[index]); + } + return "continue"; + } if (arraysMatch((_Object$keys = Object.keys((_oldNodes$index = oldNodes[index]) == null ? void 0 : _oldNodes$index.attributes)) != null ? _Object$keys : [], Object.keys(node.attributes)) && arraysMatch((_Object$values = Object.values((_oldNodes$index2 = oldNodes[index]) == null ? void 0 : _oldNodes$index2.attributes)) != null ? _Object$values : [], Object.values(node.attributes)) && ((_oldNodes$index3 = oldNodes[index]) == null ? void 0 : _oldNodes$index3.innerHTML) === node.innerHTML) { + console.log('no changes to UI node', oldNodes[index]); return "continue"; } var hasDirectivePrefix = Object.values(oldNodes[index].attributes).map(function (attr) { @@ -538,23 +547,26 @@ var Dom = /*#__PURE__*/function () { }).includes(true); })) { if (oldNodes[index].getAttribute(attr.name) !== attr.value) { - var _newNodeClone = node.cloneNode(true); - oldNodes[index].parentNode.replaceChild(_newNodeClone, oldNodes[index]); - initComponent(_newNodeClone); + var _newNodeClone2 = node.cloneNode(true); + oldNodes[index].parentNode.replaceChild(_newNodeClone2, oldNodes[index]); + console.log('replacing directive UI node', _newNodeClone2, oldNodes[index]); + initComponent(_newNodeClone2); } continue; } - var _newNodeClone2 = node.cloneNode(true); - oldNodes[index].parentNode.replaceChild(_newNodeClone2, oldNodes[index]); - initComponent(_newNodeClone2); + var _newNodeClone3 = node.cloneNode(true); + oldNodes[index].parentNode.replaceChild(_newNodeClone3, oldNodes[index]); + console.log('replacing leaf UI node', _newNodeClone3, oldNodes[index]); + initComponent(_newNodeClone3); } return "continue"; } // If element is not the same type, replace it with new element if (getNodeType(node) !== getNodeType(oldNodes[index])) { - var _newNodeClone3 = node.cloneNode(true); - oldNodes[index].parentNode.replaceChild(_newNodeClone3, oldNodes[index]); - initComponent(_newNodeClone3); + var _newNodeClone4 = node.cloneNode(true); + oldNodes[index].parentNode.replaceChild(_newNodeClone4, oldNodes[index]); + console.log('replacing node', _newNodeClone4, oldNodes[index]); + initComponent(_newNodeClone4); return { v: void 0 }; @@ -562,20 +574,23 @@ var Dom = /*#__PURE__*/function () { // If content is different, update it var templateContent = getNodeContent(node); if (templateContent && templateContent !== getNodeContent(oldNodes[index])) { + console.log('updating textContent', templateContent, oldNodes[index]); oldNodes[index].textContent = templateContent; } if (oldNodes[index].children.length > 0 && node.children.length < 1) { + console.log('clearing innerHTMl', node, oldNodes[index]); oldNodes[index].innerHTML = ''; return "continue"; } if (oldNodes[index].children.length < 1 && node.children.length > 0) { var fragment = document.createDocumentFragment(); + console.log('fragmenting', node, fragment); Dom.diff(node, fragment); oldNodes[index].appendChild(fragment); return "continue"; } if (node.children.length > 0) { - console.log('diffing children', newNode, oldNode); + console.log('diffing children', node, oldNodes[index]); Dom.diffElements(node, oldNodes[index]); } }; diff --git a/client/dist/ui.cjs.development.js.map b/client/dist/ui.cjs.development.js.map index 0b793f2..84c7a4a 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 payload = {\n type,\n payload: {\n params: [],\n method: uiData.method,\n methodArgs: uiData.methodArgs,\n component: uiData.config.component,\n data: uiData.config.data\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 // public sendMessage(message) {\n // // Forward the query string for the ajax requests.\n\n // .then(response => {\n // if (response.ok) {\n // response.text().then(response => {\n // if (this.isOutputFromDump(response)) {\n // this.onError(message);\n // this.showHtmlModal(response);\n // } else {\n // this.onMessage(\n // message,\n // JSON.parse(response)\n // );\n // }\n // });\n // } else {\n // if (\n // this.onError(\n // message,\n // response.status,\n // response\n // ) === false\n // )\n // return;\n\n // if (response.status === 419) {\n // if (store.sessionHasExpired) return;\n\n // store.sessionHasExpired = true;\n\n // this.showExpiredMessage(\n // response,\n // message\n // );\n // } else {\n // response.text().then(response => {\n // this.showHtmlModal(response);\n // });\n // }\n // }\n // })\n // .catch(() => {\n // this.onError(message);\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 { DIRECTIVE_SHORTHANDS, arraysMatch } from './../utils/data';\n\nexport default class Dom {\n static diff(newNode: string, oldNode: HTMLElement): void {\n Dom.diffElements(Dom.getBody(newNode, false), oldNode);\n }\n\n static diffElements(newNode: HTMLElement, oldNode: HTMLElement): void {\n const newNodes = Array.prototype.slice.call(newNode.children);\n const oldNodes = Array.prototype.slice.call(oldNode.children);\n\n /**\n * Get the type for a node\n * @param {Node} node The node\n * @return {String} The type\n */\n const getNodeType = (node: HTMLElement) => {\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 const getNodeContent = (node: HTMLElement) => {\n if (node.children && node.children.length > 0) return null;\n return node.textContent;\n };\n\n // const diff = Dom.compareNodesAndReturnChanges(newDomBody, oldNode);\n\n // If extra elements in DOM, remove them\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 // Diff each item in the newNodes\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 return;\n }\n\n if (\n arraysMatch(\n Object.keys(oldNodes[index]?.attributes) ?? [],\n Object.keys(node.attributes)\n ) &&\n arraysMatch(\n Object.values(oldNodes[index]?.attributes) ?? [],\n Object.values(node.attributes)\n ) &&\n oldNodes[index]?.innerHTML === node.innerHTML\n ) {\n continue;\n }\n\n const hasDirectivePrefix = Object.values(oldNodes[index].attributes)\n .map((attr: any) => attr.name.startsWith('ui-'))\n .includes(true);\n const hasDirectiveShorthandPrefix = Object.keys(\n DIRECTIVE_SHORTHANDS\n ).some(shorthand =>\n Object.values(oldNodes[index].attributes)\n .map((attr: any) => attr.name.startsWith(shorthand))\n .includes(true)\n );\n\n if (hasDirectivePrefix || hasDirectiveShorthandPrefix) {\n oldNodes[index].innerHTML = node.innerHTML;\n\n for (let j = 0; j < node.attributes.length; j++) {\n const attr = node.attributes[j];\n\n if (\n attr.name.startsWith('ui-') ||\n Object.keys(DIRECTIVE_SHORTHANDS).some(shorthand =>\n Object.values(oldNodes[index].attributes)\n .map((attr: any) =>\n attr.name.startsWith(shorthand)\n )\n .includes(true)\n )\n ) {\n if (\n oldNodes[index].getAttribute(attr.name) !==\n attr.value\n ) {\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n initComponent(newNodeClone);\n }\n\n continue;\n }\n\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n initComponent(newNodeClone);\n }\n continue;\n }\n\n // If element is not the same type, replace it with new element\n if (getNodeType(node) !== getNodeType(oldNodes[index])) {\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n initComponent(newNodeClone);\n return;\n }\n\n // If content is different, update it\n const templateContent = getNodeContent(node);\n if (\n templateContent &&\n templateContent !== 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.diff(node, fragment as any);\n oldNodes[index].appendChild(fragment);\n continue;\n }\n\n if (node.children.length > 0) {\n console.log('diffing children', newNode, oldNode);\n Dom.diffElements(node, oldNodes[index]);\n }\n }\n }\n\n static getBody(html: string, removeScripts: boolean = false): 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 static flattenDomIntoArray(node: HTMLElement): HTMLCollection {\n return node.getElementsByTagName('*');\n }\n\n static compareNodesAndReturnChanges(\n newNode: HTMLElement,\n oldNode: HTMLElement\n ): Record[] {\n const newNodes = Dom.flattenDomIntoArray(newNode);\n const oldNodes = Dom.flattenDomIntoArray(oldNode);\n const changes = [];\n\n for (let i = 0; i < newNodes.length; i++) {\n if (newNodes[i] !== oldNodes[i]) {\n if (newNodes[i].tagName !== oldNodes[i].tagName) {\n changes.push({\n oldNode: null,\n newNode: newNodes[i]\n });\n } else {\n changes.push({\n oldNode: oldNodes[i],\n newNode: newNodes[i]\n });\n }\n }\n }\n\n return changes;\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', { 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","payload","params","method","methodArgs","component","config","data","fetch","window","location","href","JSON","stringify","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","newNode","oldNode","diffElements","getBody","newNodes","prototype","slice","call","children","oldNodes","getNodeType","node","nodeType","tagName","toLowerCase","getNodeContent","textContent","count","parentNode","removeChild","newNodeClone","cloneNode","appendChild","initComponent","Object","keys","attributes","values","innerHTML","hasDirectivePrefix","map","attr","name","startsWith","includes","hasDirectiveShorthandPrefix","some","shorthand","j","getAttribute","value","replaceChild","templateContent","fragment","createDocumentFragment","log","removeScripts","parser","DOMParser","parseFromString","scripts","getElementsByTagName","i","remove","flattenDomIntoArray","compareNodesAndReturnChanges","changes","push","compute","refs","specialPropertiesNames","computeFunction","Function","join","emit","options","dispatchGlobal","event","CustomEvent","target","dispatchEvent","flattenElementChildren","rootElement","ignoreRootElement","collection","childElement","HTMLElement","collectRefs","element","refDirective","refElements","querySelectorAll","forEach","refElement","initDirectives","directives","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","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","firstElementChild","getAttributeNode","removeAttributeNode","setAttributeNode","removeAttribute"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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ACrBA/C,QAAQ,CAACsJ,gBAAgB,CAAC,kBAAkB,EAAE;EAC1CoB,0CAA0C,EAAE;EAC5CF,IAAI,EAAE;EAENxK,QAAQ,CAACiG,gBAAgB,CAAC,WAAW,CAAC,CAACC,OAAO,CAAC,UAAArI,EAAE;IAC7CA,EAAE,CAACwN,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 payload = {\n type,\n payload: {\n params: [],\n method: uiData.method,\n methodArgs: uiData.methodArgs,\n component: uiData.config.component,\n data: uiData.config.data\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 // public sendMessage(message) {\n // // Forward the query string for the ajax requests.\n\n // .then(response => {\n // if (response.ok) {\n // response.text().then(response => {\n // if (this.isOutputFromDump(response)) {\n // this.onError(message);\n // this.showHtmlModal(response);\n // } else {\n // this.onMessage(\n // message,\n // JSON.parse(response)\n // );\n // }\n // });\n // } else {\n // if (\n // this.onError(\n // message,\n // response.status,\n // response\n // ) === false\n // )\n // return;\n\n // if (response.status === 419) {\n // if (store.sessionHasExpired) return;\n\n // store.sessionHasExpired = true;\n\n // this.showExpiredMessage(\n // response,\n // message\n // );\n // } else {\n // response.text().then(response => {\n // this.showHtmlModal(response);\n // });\n // }\n // }\n // })\n // .catch(() => {\n // this.onError(message);\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 { DIRECTIVE_SHORTHANDS, arraysMatch } from './../utils/data';\n\nexport default class Dom {\n static diff(newNode: string, oldNode: HTMLElement): void {\n Dom.diffElements(Dom.getBody(newNode, false), oldNode);\n }\n\n static diffElements(newNode: HTMLElement, oldNode: HTMLElement): void {\n const newNodes = Array.prototype.slice.call(newNode.children);\n const oldNodes = Array.prototype.slice.call(oldNode.children);\n\n /**\n * Get the type for a node\n * @param {Node} node The node\n * @return {String} The type\n */\n const getNodeType = (node: HTMLElement) => {\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 const getNodeContent = (node: HTMLElement) => {\n if (node.children && node.children.length > 0) return null;\n return node.textContent;\n };\n\n // If extra elements in DOM, remove them\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 console.log('diffing node', node);\n\n if (!oldNodes[index]) {\n const newNodeClone = node.cloneNode(true);\n oldNode.appendChild(newNodeClone);\n console.log('adding new UI node', newNodeClone);\n initComponent(newNodeClone);\n return;\n }\n\n if (node instanceof HTMLScriptElement && oldNodes[index] instanceof HTMLScriptElement) {\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 console.log(\n 'replacing script UI node',\n newNodeClone,\n oldNodes[index]\n );\n }\n\n continue;\n }\n\n if (\n arraysMatch(\n Object.keys(oldNodes[index]?.attributes) ?? [],\n Object.keys(node.attributes)\n ) &&\n arraysMatch(\n Object.values(oldNodes[index]?.attributes) ?? [],\n Object.values(node.attributes)\n ) &&\n oldNodes[index]?.innerHTML === node.innerHTML\n ) {\n console.log('no changes to UI node', oldNodes[index]);\n continue;\n }\n\n const hasDirectivePrefix = Object.values(oldNodes[index].attributes)\n .map((attr: any) => attr.name.startsWith('ui-'))\n .includes(true);\n const hasDirectiveShorthandPrefix = Object.keys(\n DIRECTIVE_SHORTHANDS\n ).some(shorthand =>\n Object.values(oldNodes[index].attributes)\n .map((attr: any) => attr.name.startsWith(shorthand))\n .includes(true)\n );\n\n if (hasDirectivePrefix || hasDirectiveShorthandPrefix) {\n oldNodes[index].innerHTML = node.innerHTML;\n\n for (let j = 0; j < node.attributes.length; j++) {\n const attr = node.attributes[j];\n\n if (\n attr.name.startsWith('ui-') ||\n Object.keys(DIRECTIVE_SHORTHANDS).some(shorthand =>\n Object.values(oldNodes[index].attributes)\n .map((attr: any) =>\n attr.name.startsWith(shorthand)\n )\n .includes(true)\n )\n ) {\n if (\n oldNodes[index].getAttribute(attr.name) !==\n attr.value\n ) {\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n console.log('replacing directive UI node', newNodeClone, oldNodes[index]);\n initComponent(newNodeClone);\n }\n\n continue;\n }\n\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n console.log('replacing leaf UI node', newNodeClone, oldNodes[index]);\n initComponent(newNodeClone);\n }\n continue;\n }\n\n // If element is not the same type, replace it with new element\n if (getNodeType(node) !== getNodeType(oldNodes[index])) {\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n console.log('replacing node', newNodeClone, oldNodes[index]);\n initComponent(newNodeClone);\n return;\n }\n\n // If content is different, update it\n const templateContent = getNodeContent(node);\n if (\n templateContent &&\n templateContent !== getNodeContent(oldNodes[index])\n ) {\n console.log('updating textContent', templateContent, oldNodes[index]);\n oldNodes[index].textContent = templateContent;\n }\n\n if (\n oldNodes[index].children.length > 0 &&\n node.children.length < 1\n ) {\n console.log('clearing innerHTMl', node, oldNodes[index]);\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 console.log('fragmenting', node, fragment);\n Dom.diff(node, fragment as any);\n oldNodes[index].appendChild(fragment);\n continue;\n }\n\n if (node.children.length > 0) {\n console.log('diffing children', node, oldNodes[index]);\n Dom.diffElements(node, oldNodes[index]);\n }\n }\n }\n\n static getBody(html: string, removeScripts: boolean = false): 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 static flattenDomIntoArray(node: HTMLElement): HTMLCollection {\n return node.getElementsByTagName('*');\n }\n\n static compareNodesAndReturnChanges(\n newNode: HTMLElement,\n oldNode: HTMLElement\n ): Record[] {\n const newNodes = Dom.flattenDomIntoArray(newNode);\n const oldNodes = Dom.flattenDomIntoArray(oldNode);\n const changes = [];\n\n for (let i = 0; i < newNodes.length; i++) {\n if (newNodes[i] !== oldNodes[i]) {\n if (newNodes[i].tagName !== oldNodes[i].tagName) {\n changes.push({\n oldNode: null,\n newNode: newNodes[i]\n });\n } else {\n changes.push({\n oldNode: oldNodes[i],\n newNode: newNodes[i]\n });\n }\n }\n }\n\n return changes;\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', { 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","payload","params","method","methodArgs","component","config","data","fetch","window","location","href","JSON","stringify","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","newNode","oldNode","diffElements","getBody","newNodes","prototype","slice","call","children","oldNodes","getNodeType","node","nodeType","tagName","toLowerCase","getNodeContent","textContent","count","parentNode","removeChild","log","newNodeClone","cloneNode","appendChild","initComponent","HTMLScriptElement","src","innerHTML","replaceChild","Object","keys","attributes","values","hasDirectivePrefix","map","attr","name","startsWith","includes","hasDirectiveShorthandPrefix","some","shorthand","j","getAttribute","value","templateContent","fragment","createDocumentFragment","removeScripts","parser","DOMParser","parseFromString","scripts","getElementsByTagName","i","remove","flattenDomIntoArray","compareNodesAndReturnChanges","changes","push","compute","refs","specialPropertiesNames","computeFunction","Function","join","emit","options","dispatchGlobal","event","CustomEvent","target","dispatchEvent","flattenElementChildren","rootElement","ignoreRootElement","collection","childElement","HTMLElement","collectRefs","element","refDirective","refElements","querySelectorAll","forEach","refElement","initDirectives","directives","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","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","firstElementChild","getAttributeNode","removeAttributeNode","setAttributeNode","removeAttribute"],"mappings":";;;;;;;;;;;;;;;;;;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AE6B,IAAI,EAAEQ,KAAK,CAAC;;IAG3CoH,OAAO,CAACrI,SAAS,cAAYS,IAAI,WAAKQ,KAAK,eAAW;IAEtD,IAAIT,IAAI,GAAI6H,OAAO,CAACG,iBAAiB,CAAGC,gBAAgB,CAAChI,IAAI,CAAE;IAE9D4H,OAAO,CAACG,iBAAiB,CAAGE,mBAAmB,CAAClI,IAAI,CAAC;IAEtD,IAAI,CAACmI,gBAAgB,CAACnI,IAAI,CAAC;GAC9B;AACL;;ACrBAnD,QAAQ,CAACwJ,gBAAgB,CAAC,kBAAkB,EAAE;EAC1CoB,0CAA0C,EAAE;EAC5CF,IAAI,EAAE;EAEN1K,QAAQ,CAACmG,gBAAgB,CAAC,WAAW,CAAC,CAACC,OAAO,CAAC,UAAAvI,EAAE;IAC7CA,EAAE,CAAC0N,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 035b686..4ae83f7 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",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: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 v(){}function p(){}var m={};l(m,a,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(j([])));g&&g!==n&&r.call(g,a)&&(m=g);var b=p.prototype=h.prototype=Object.create(m);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 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 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 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 j(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:j(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){return fetch(window.location.href+"?_leaf_ui_config="+JSON.stringify({type:r,payload:{params:[],method:o.method,methodArgs:o.methodArgs,component:o.config.component,data:o.config.data}}),{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=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.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=function(t){return 3===t.nodeType?"text":8===t.nodeType?"comment":t.tagName.toLowerCase()},u=function(t){return t.children&&t.children.length>0?null:t.textContent},c=o.length-r.length;if(c>0)for(;c>0;c--)o[o.length-c].parentNode.removeChild(o[o.length-c]);for(var s=function(c){var s,f,d,h,v,m=r[c];if(!o[c]){var y=m.cloneNode(!0);return n.appendChild(y),p(y),{v:void 0}}if(l(null!=(s=Object.keys(null==(f=o[c])?void 0:f.attributes))?s:[],Object.keys(m.attributes))&&l(null!=(d=Object.values(null==(h=o[c])?void 0:h.attributes))?d:[],Object.values(m.attributes))&&(null==(v=o[c])?void 0:v.innerHTML)===m.innerHTML)return"continue";var g=Object.values(o[c].attributes).map((function(t){return t.name.startsWith("ui-")})).includes(!0),b=Object.keys(a).some((function(t){return Object.values(o[c].attributes).map((function(e){return e.name.startsWith(t)})).includes(!0)}));if(g||b){o[c].innerHTML=m.innerHTML;for(var w=0;w0&&m.children.length<1)return o[c].innerHTML="","continue";if(o[c].children.length<1&&m.children.length>0){var A=document.createDocumentFragment();return t.diff(m,A),o[c].appendChild(A),"continue"}m.children.length>0&&(console.log("diffing children",e,n),t.diffElements(m,o[c]))},f=0;f {\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', { 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)},v=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,v,p,m,y,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 v,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",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 m={};l(m,a,(function(){return this}));var g=Object.getPrototypeOf,y=g&&g(g(j([])));y&&y!==n&&r.call(y,a)&&(m=y);var b=v.prototype=h.prototype=Object.create(m);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,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 j(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:j(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){return fetch(window.location.href+"?_leaf_ui_config="+JSON.stringify({type:r,payload:{params:[],method:o.method,methodArgs:o.methodArgs,component:o.config.component,data:o.config.data}}),{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.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=function(t){return 3===t.nodeType?"text":8===t.nodeType?"comment":t.tagName.toLowerCase()},c=function(t){return t.children&&t.children.length>0?null:t.textContent},u=o.length-r.length;if(u>0)for(;u>0;u--)o[o.length-u].parentNode.removeChild(o[o.length-u]);for(var s=function(e){var u,s,f,d,h,p=r[e];if(console.log("diffing node",p),!o[e]){var m=p.cloneNode(!0);return n.appendChild(m),console.log("adding new UI node",m),v(m),{v:void 0}}if(p instanceof HTMLScriptElement&&o[e]instanceof HTMLScriptElement){if(p.src!==o[e].src||p.innerHTML!==o[e].innerHTML){var g=p.cloneNode(!0);o[e].parentNode.replaceChild(g,o[e]),console.log("replacing script UI node",g,o[e])}return"continue"}if(l(null!=(u=Object.keys(null==(s=o[e])?void 0:s.attributes))?u:[],Object.keys(p.attributes))&&l(null!=(f=Object.values(null==(d=o[e])?void 0:d.attributes))?f:[],Object.values(p.attributes))&&(null==(h=o[e])?void 0:h.innerHTML)===p.innerHTML)return console.log("no changes to UI node",o[e]),"continue";var y=Object.values(o[e].attributes).map((function(t){return t.name.startsWith("ui-")})).includes(!0),b=Object.keys(a).some((function(t){return Object.values(o[e].attributes).map((function(e){return e.name.startsWith(t)})).includes(!0)}));if(y||b){o[e].innerHTML=p.innerHTML;for(var w=0;w0&&p.children.length<1)return console.log("clearing innerHTMl",p,o[e]),o[e].innerHTML="","continue";if(o[e].children.length<1&&p.children.length>0){var A=document.createDocumentFragment();return console.log("fragmenting",p,A),t.diff(p,A),o[e].appendChild(A),"continue"}p.children.length>0&&(console.log("diffing children",p,o[e]),t.diffElements(p,o[e]))},f=0;f {\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', { 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,m,g,y;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")}))})); //# 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 d8dae6f..77c2734 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 payload = {\n type,\n payload: {\n params: [],\n method: uiData.method,\n methodArgs: uiData.methodArgs,\n component: uiData.config.component,\n data: uiData.config.data\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 // public sendMessage(message) {\n // // Forward the query string for the ajax requests.\n\n // .then(response => {\n // if (response.ok) {\n // response.text().then(response => {\n // if (this.isOutputFromDump(response)) {\n // this.onError(message);\n // this.showHtmlModal(response);\n // } else {\n // this.onMessage(\n // message,\n // JSON.parse(response)\n // );\n // }\n // });\n // } else {\n // if (\n // this.onError(\n // message,\n // response.status,\n // response\n // ) === false\n // )\n // return;\n\n // if (response.status === 419) {\n // if (store.sessionHasExpired) return;\n\n // store.sessionHasExpired = true;\n\n // this.showExpiredMessage(\n // response,\n // message\n // );\n // } else {\n // response.text().then(response => {\n // this.showHtmlModal(response);\n // });\n // }\n // }\n // })\n // .catch(() => {\n // this.onError(message);\n // });\n // }\n}\n","import { initComponent } from './../core/component';\nimport { DIRECTIVE_SHORTHANDS, arraysMatch } from './../utils/data';\n\nexport default class Dom {\n static diff(newNode: string, oldNode: HTMLElement): void {\n Dom.diffElements(Dom.getBody(newNode, false), oldNode);\n }\n\n static diffElements(newNode: HTMLElement, oldNode: HTMLElement): void {\n const newNodes = Array.prototype.slice.call(newNode.children);\n const oldNodes = Array.prototype.slice.call(oldNode.children);\n\n /**\n * Get the type for a node\n * @param {Node} node The node\n * @return {String} The type\n */\n const getNodeType = (node: HTMLElement) => {\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 const getNodeContent = (node: HTMLElement) => {\n if (node.children && node.children.length > 0) return null;\n return node.textContent;\n };\n\n // const diff = Dom.compareNodesAndReturnChanges(newDomBody, oldNode);\n\n // If extra elements in DOM, remove them\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 // Diff each item in the newNodes\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 return;\n }\n\n if (\n arraysMatch(\n Object.keys(oldNodes[index]?.attributes) ?? [],\n Object.keys(node.attributes)\n ) &&\n arraysMatch(\n Object.values(oldNodes[index]?.attributes) ?? [],\n Object.values(node.attributes)\n ) &&\n oldNodes[index]?.innerHTML === node.innerHTML\n ) {\n continue;\n }\n\n const hasDirectivePrefix = Object.values(oldNodes[index].attributes)\n .map((attr: any) => attr.name.startsWith('ui-'))\n .includes(true);\n const hasDirectiveShorthandPrefix = Object.keys(\n DIRECTIVE_SHORTHANDS\n ).some(shorthand =>\n Object.values(oldNodes[index].attributes)\n .map((attr: any) => attr.name.startsWith(shorthand))\n .includes(true)\n );\n\n if (hasDirectivePrefix || hasDirectiveShorthandPrefix) {\n oldNodes[index].innerHTML = node.innerHTML;\n\n for (let j = 0; j < node.attributes.length; j++) {\n const attr = node.attributes[j];\n\n if (\n attr.name.startsWith('ui-') ||\n Object.keys(DIRECTIVE_SHORTHANDS).some(shorthand =>\n Object.values(oldNodes[index].attributes)\n .map((attr: any) =>\n attr.name.startsWith(shorthand)\n )\n .includes(true)\n )\n ) {\n if (\n oldNodes[index].getAttribute(attr.name) !==\n attr.value\n ) {\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n initComponent(newNodeClone);\n }\n\n continue;\n }\n\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n initComponent(newNodeClone);\n }\n continue;\n }\n\n // If element is not the same type, replace it with new element\n if (getNodeType(node) !== getNodeType(oldNodes[index])) {\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n initComponent(newNodeClone);\n return;\n }\n\n // If content is different, update it\n const templateContent = getNodeContent(node);\n if (\n templateContent &&\n templateContent !== 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.diff(node, fragment as any);\n oldNodes[index].appendChild(fragment);\n continue;\n }\n\n if (node.children.length > 0) {\n console.log('diffing children', newNode, oldNode);\n Dom.diffElements(node, oldNodes[index]);\n }\n }\n }\n\n static getBody(html: string, removeScripts: boolean = false): 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 static flattenDomIntoArray(node: HTMLElement): HTMLCollection {\n return node.getElementsByTagName('*');\n }\n\n static compareNodesAndReturnChanges(\n newNode: HTMLElement,\n oldNode: HTMLElement\n ): Record[] {\n const newNodes = Dom.flattenDomIntoArray(newNode);\n const oldNodes = Dom.flattenDomIntoArray(oldNode);\n const changes = [];\n\n for (let i = 0; i < newNodes.length; i++) {\n if (newNodes[i] !== oldNodes[i]) {\n if (newNodes[i].tagName !== oldNodes[i].tagName) {\n changes.push({\n oldNode: null,\n newNode: newNodes[i]\n });\n } else {\n changes.push({\n oldNode: oldNodes[i],\n newNode: newNodes[i]\n });\n }\n }\n }\n\n return changes;\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', { 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","fetch","window","location","href","JSON","stringify","payload","params","method","methodArgs","component","config","data","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","newNode","oldNode","diffElements","getBody","newNodes","prototype","slice","call","children","oldNodes","getNodeType","node","nodeType","tagName","toLowerCase","getNodeContent","textContent","count","parentNode","removeChild","newNodeClone","cloneNode","appendChild","initComponent","v","Object","keys","_oldNodes$index","attributes","values","_oldNodes$index2","_oldNodes$index3","innerHTML","hasDirectivePrefix","map","attr","name","startsWith","includes","hasDirectiveShorthandPrefix","some","shorthand","j","getAttribute","value","replaceChild","templateContent","fragment","createDocumentFragment","log","removeScripts","DOMParser","parseFromString","scripts","getElementsByTagName","i","remove","flattenDomIntoArray","compareNodesAndReturnChanges","changes","push","compute","refs","computeFunction","Function","join","emit","options","dispatchGlobal","event","CustomEvent","dispatchEvent","directives","ON","parts","eventProps","EVENT_REGISTERED_FLAG","target","prop","String","once","passive","addEventListener","KeyboardEvent","test","whitelistedKeycodes","forEach","eventProp","isNaN","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","element","newASTNode","refElements","querySelectorAll","refElement","collectRefs","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","setAttribute","createElement","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,cAkD1B,OAlD0BA,EAGbC,QAAP,SACHC,EACAC,EACAC,GAaA,OAAOC,MACAC,OAAOC,SAASC,yBAAwBC,KAAKC,UAZpC,CACZR,KAAAA,EACAS,QAAS,CACLC,OAAQ,GACRC,OAAQV,EAAOU,OACfC,WAAYX,EAAOW,WACnBC,UAAWZ,EAAOa,OAAOD,UACzBE,KAAMd,EAAOa,OAAOC,QAQxB,CACIJ,OAAQV,EAAOa,OAAOH,OAEtBK,YAAa,cACbC,WACIC,eAAgB,mBAChBC,OAAQ,mCACRC,YAAa,QAGVC,KAAKJ,SAGRK,QAASlB,OAAOC,SAASC,SAGnCiB,gBAAI,qBAAC,WAAMC,GAAQ,6BAAA,6BAAA,OAAA,IACbA,EAASC,IAAEC,SAAA,MACXF,EAASG,OAAOJ,MAAK,SAAAC,GACjB,IAAMT,EAAOR,KAAKqB,MAAMJ,GACxBpB,OAAOyB,cAAcd,KAAOA,EAAKe,MACjC5B,EAAI6B,KAAKhB,EAAKiB,K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AErCF,QAAQlJ,UAAUmJ,aAAe,SAAyBpH,EAAMQ,GAC5D,IAAKR,EAAKE,SAAS,KACf,OAAO+G,EAAS9I,KAAKjC,KAAM8D,EAAMQ,GAGrC0G,EAAQtH,mBAAqBI,OAASQ,cAEtC,IAAIT,EAAQmH,EAAQI,kBAAoBC,iBAAiBvH,GAExDkH,EAAQI,kBAAoBE,oBAAoBzH,GAEjD7D,KAAKuL,iBAAiB1H,ICjBV,SAACiF,YAAAA,IAAAA,EAAkClI,UACnD,IAAMY,EAAS,IAAI0G,EACbS,EAAcG,aAAmB0C,SAAW1C,EAAQjI,KAAOiI,EAEjEtH,EAAO6G,MAAMM,GFJb8C,GAEA7K,SAASqI,iBAAiB,aAAajC,SAAQ,SAAA3I,GAC3CA,EAAGqN,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 payload = {\n type,\n payload: {\n params: [],\n method: uiData.method,\n methodArgs: uiData.methodArgs,\n component: uiData.config.component,\n data: uiData.config.data\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 // public sendMessage(message) {\n // // Forward the query string for the ajax requests.\n\n // .then(response => {\n // if (response.ok) {\n // response.text().then(response => {\n // if (this.isOutputFromDump(response)) {\n // this.onError(message);\n // this.showHtmlModal(response);\n // } else {\n // this.onMessage(\n // message,\n // JSON.parse(response)\n // );\n // }\n // });\n // } else {\n // if (\n // this.onError(\n // message,\n // response.status,\n // response\n // ) === false\n // )\n // return;\n\n // if (response.status === 419) {\n // if (store.sessionHasExpired) return;\n\n // store.sessionHasExpired = true;\n\n // this.showExpiredMessage(\n // response,\n // message\n // );\n // } else {\n // response.text().then(response => {\n // this.showHtmlModal(response);\n // });\n // }\n // }\n // })\n // .catch(() => {\n // this.onError(message);\n // });\n // }\n}\n","import { initComponent } from './../core/component';\nimport { DIRECTIVE_SHORTHANDS, arraysMatch } from './../utils/data';\n\nexport default class Dom {\n static diff(newNode: string, oldNode: HTMLElement): void {\n Dom.diffElements(Dom.getBody(newNode, false), oldNode);\n }\n\n static diffElements(newNode: HTMLElement, oldNode: HTMLElement): void {\n const newNodes = Array.prototype.slice.call(newNode.children);\n const oldNodes = Array.prototype.slice.call(oldNode.children);\n\n /**\n * Get the type for a node\n * @param {Node} node The node\n * @return {String} The type\n */\n const getNodeType = (node: HTMLElement) => {\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 const getNodeContent = (node: HTMLElement) => {\n if (node.children && node.children.length > 0) return null;\n return node.textContent;\n };\n\n // If extra elements in DOM, remove them\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 console.log('diffing node', node);\n\n if (!oldNodes[index]) {\n const newNodeClone = node.cloneNode(true);\n oldNode.appendChild(newNodeClone);\n console.log('adding new UI node', newNodeClone);\n initComponent(newNodeClone);\n return;\n }\n\n if (node instanceof HTMLScriptElement && oldNodes[index] instanceof HTMLScriptElement) {\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 console.log(\n 'replacing script UI node',\n newNodeClone,\n oldNodes[index]\n );\n }\n\n continue;\n }\n\n if (\n arraysMatch(\n Object.keys(oldNodes[index]?.attributes) ?? [],\n Object.keys(node.attributes)\n ) &&\n arraysMatch(\n Object.values(oldNodes[index]?.attributes) ?? [],\n Object.values(node.attributes)\n ) &&\n oldNodes[index]?.innerHTML === node.innerHTML\n ) {\n console.log('no changes to UI node', oldNodes[index]);\n continue;\n }\n\n const hasDirectivePrefix = Object.values(oldNodes[index].attributes)\n .map((attr: any) => attr.name.startsWith('ui-'))\n .includes(true);\n const hasDirectiveShorthandPrefix = Object.keys(\n DIRECTIVE_SHORTHANDS\n ).some(shorthand =>\n Object.values(oldNodes[index].attributes)\n .map((attr: any) => attr.name.startsWith(shorthand))\n .includes(true)\n );\n\n if (hasDirectivePrefix || hasDirectiveShorthandPrefix) {\n oldNodes[index].innerHTML = node.innerHTML;\n\n for (let j = 0; j < node.attributes.length; j++) {\n const attr = node.attributes[j];\n\n if (\n attr.name.startsWith('ui-') ||\n Object.keys(DIRECTIVE_SHORTHANDS).some(shorthand =>\n Object.values(oldNodes[index].attributes)\n .map((attr: any) =>\n attr.name.startsWith(shorthand)\n )\n .includes(true)\n )\n ) {\n if (\n oldNodes[index].getAttribute(attr.name) !==\n attr.value\n ) {\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n console.log('replacing directive UI node', newNodeClone, oldNodes[index]);\n initComponent(newNodeClone);\n }\n\n continue;\n }\n\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n console.log('replacing leaf UI node', newNodeClone, oldNodes[index]);\n initComponent(newNodeClone);\n }\n continue;\n }\n\n // If element is not the same type, replace it with new element\n if (getNodeType(node) !== getNodeType(oldNodes[index])) {\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n console.log('replacing node', newNodeClone, oldNodes[index]);\n initComponent(newNodeClone);\n return;\n }\n\n // If content is different, update it\n const templateContent = getNodeContent(node);\n if (\n templateContent &&\n templateContent !== getNodeContent(oldNodes[index])\n ) {\n console.log('updating textContent', templateContent, oldNodes[index]);\n oldNodes[index].textContent = templateContent;\n }\n\n if (\n oldNodes[index].children.length > 0 &&\n node.children.length < 1\n ) {\n console.log('clearing innerHTMl', node, oldNodes[index]);\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 console.log('fragmenting', node, fragment);\n Dom.diff(node, fragment as any);\n oldNodes[index].appendChild(fragment);\n continue;\n }\n\n if (node.children.length > 0) {\n console.log('diffing children', node, oldNodes[index]);\n Dom.diffElements(node, oldNodes[index]);\n }\n }\n }\n\n static getBody(html: string, removeScripts: boolean = false): 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 static flattenDomIntoArray(node: HTMLElement): HTMLCollection {\n return node.getElementsByTagName('*');\n }\n\n static compareNodesAndReturnChanges(\n newNode: HTMLElement,\n oldNode: HTMLElement\n ): Record[] {\n const newNodes = Dom.flattenDomIntoArray(newNode);\n const oldNodes = Dom.flattenDomIntoArray(oldNode);\n const changes = [];\n\n for (let i = 0; i < newNodes.length; i++) {\n if (newNodes[i] !== oldNodes[i]) {\n if (newNodes[i].tagName !== oldNodes[i].tagName) {\n changes.push({\n oldNode: null,\n newNode: newNodes[i]\n });\n } else {\n changes.push({\n oldNode: oldNodes[i],\n newNode: newNodes[i]\n });\n }\n }\n }\n\n return changes;\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', { 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","fetch","window","location","href","JSON","stringify","payload","params","method","methodArgs","component","config","data","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","newNode","oldNode","diffElements","getBody","newNodes","prototype","slice","call","children","oldNodes","getNodeType","node","nodeType","tagName","toLowerCase","getNodeContent","textContent","count","parentNode","removeChild","log","newNodeClone","cloneNode","appendChild","initComponent","v","HTMLScriptElement","src","innerHTML","replaceChild","Object","keys","_oldNodes$index","attributes","values","_oldNodes$index2","_oldNodes$index3","hasDirectivePrefix","map","attr","name","startsWith","includes","hasDirectiveShorthandPrefix","some","shorthand","j","getAttribute","value","templateContent","fragment","createDocumentFragment","removeScripts","DOMParser","parseFromString","scripts","getElementsByTagName","i","remove","flattenDomIntoArray","compareNodesAndReturnChanges","changes","push","compute","refs","computeFunction","Function","join","emit","options","dispatchGlobal","event","CustomEvent","dispatchEvent","directives","ON","parts","eventProps","EVENT_REGISTERED_FLAG","target","prop","String","once","passive","addEventListener","KeyboardEvent","test","whitelistedKeycodes","forEach","eventProp","isNaN","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","element","newASTNode","refElements","querySelectorAll","refElement","collectRefs","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","setAttribute","createElement","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,cAkD1B,OAlD0BA,EAGbC,QAAP,SACHC,EACAC,EACAC,GAaA,OAAOC,MACAC,OAAOC,SAASC,yBAAwBC,KAAKC,UAZpC,CACZR,KAAAA,EACAS,QAAS,CACLC,OAAQ,GACRC,OAAQV,EAAOU,OACfC,WAAYX,EAAOW,WACnBC,UAAWZ,EAAOa,OAAOD,UACzBE,KAAMd,EAAOa,OAAOC,QAQxB,CACIJ,OAAQV,EAAOa,OAAOH,OAEtBK,YAAa,cACbC,WACIC,eAAgB,mBAChBC,OAAQ,mCACRC,YAAa,QAGVC,KAAKJ,SAGRK,QAASlB,OAAOC,SAASC,SAGnCiB,gBAAI,qBAAC,WAAMC,GAAQ,6BAAA,6BAAA,OAAA,IACbA,EAASC,IAAEC,SAAA,MACXF,EAASG,OAAOJ,MAAK,SAAAC,GACjB,IAAMT,EAAOR,KAAKqB,MAAMJ,GACxBpB,OAAOyB,cAAcd,KAAOA,EAAKe,MACjC5B,EAAI6B,KAAKhB,EAAKiB,KAAMC,SAASC,SAC9BR,SAAA,MAAA,OAEE,OAFFA,KAEHnC,EAAKmC,SAAOF,EAASG,OAAOJ,MAAK,SAAAY,GAAG,OAAIA,KAAI,OAAAT,aAAA,cAAA,OAAA,UAAA,wMAEnD,mBAAA,mDD5BOU,EAAYC,EAAUC,GAClC,OACIC,MAAMC,QAAQH,IACd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GzB/D,EAAK+D,WAAWmD,IAC1B,QAAAY,IAAA9J,UAAA,MAAA,QAAAA,SAAA,MAAA,QAAA,UAAA,wBCnCGoK,GACX,SAASC,IACd,IAAMC,EAAQC,YAAYC,MACtBC,EAAO,KACX,GACEA,EAAOhB,EAAUY,aACVE,YAAYC,MAAQF,EDVH,KCUyBG,EAAKC,MAEpDD,EAAKC,MACTC,WAAWN,OHaPb,CAAO7J,KAAKqI,QAASjC,SAIhBlD,EAAgB,SAAC8F,GAAgB,OAC1C,IAAIZ,GAAYG,MAAMS,IIrC1BpI,SAASkG,iBAAiB,oBAAoB,WCA9C,IAIQmE,EAEAC,EAFAD,EAAWE,QAAQpJ,UAAUqJ,aAE7BF,EAAUtK,SAASyK,cAAc,OAErCF,QAAQpJ,UAAUqJ,aAAe,SAAyBlH,EAAMQ,GAC5D,IAAKR,EAAKE,SAAS,KACf,OAAO6G,EAAShJ,KAAKjC,KAAMkE,EAAMQ,GAGrCwG,EAAQ5H,mBAAqBY,OAASQ,cAEtC,IAAIT,EAAQiH,EAAQI,kBAAoBC,iBAAiBrH,GAExDgH,EAAQI,kBAAoBE,oBAAoBvH,GAEjDjE,KAAKyL,iBAAiBxH,ICjBV,SAAC+E,YAAAA,IAAAA,EAAkCpI,UACnD,IAAMY,EAAS,IAAI4G,EACbS,EAAcG,aAAmB0C,SAAW1C,EAAQnI,KAAOmI,EAEjExH,EAAO+G,MAAMM,GFJb8C,GAEA/K,SAASuI,iBAAiB,aAAajC,SAAQ,SAAA7I,GAC3CA,EAAGuN,gBAAgB"} \ No newline at end of file diff --git a/client/dist/ui.esm.js b/client/dist/ui.esm.js index e8bd802..66803ae 100644 --- a/client/dist/ui.esm.js +++ b/client/dist/ui.esm.js @@ -495,7 +495,6 @@ var Dom = /*#__PURE__*/function () { if (node.children && node.children.length > 0) return null; return node.textContent; }; - // const diff = Dom.compareNodesAndReturnChanges(newDomBody, oldNode); // If extra elements in DOM, remove them var count = oldNodes.length - newNodes.length; if (count > 0) { @@ -503,19 +502,29 @@ var Dom = /*#__PURE__*/function () { oldNodes[oldNodes.length - count].parentNode.removeChild(oldNodes[oldNodes.length - count]); } } - // Diff each item in the newNodes var _loop = function _loop(index) { var _Object$keys, _oldNodes$index, _Object$values, _oldNodes$index2, _oldNodes$index3; var node = newNodes[index]; + console.log('diffing node', node); if (!oldNodes[index]) { var newNodeClone = node.cloneNode(true); oldNode.appendChild(newNodeClone); + console.log('adding new UI node', newNodeClone); initComponent(newNodeClone); return { v: void 0 }; } + if (node instanceof HTMLScriptElement && oldNodes[index] instanceof HTMLScriptElement) { + if (node.src !== oldNodes[index].src || node.innerHTML !== oldNodes[index].innerHTML) { + var _newNodeClone = node.cloneNode(true); + oldNodes[index].parentNode.replaceChild(_newNodeClone, oldNodes[index]); + console.log('replacing script UI node', _newNodeClone, oldNodes[index]); + } + return "continue"; + } if (arraysMatch((_Object$keys = Object.keys((_oldNodes$index = oldNodes[index]) == null ? void 0 : _oldNodes$index.attributes)) != null ? _Object$keys : [], Object.keys(node.attributes)) && arraysMatch((_Object$values = Object.values((_oldNodes$index2 = oldNodes[index]) == null ? void 0 : _oldNodes$index2.attributes)) != null ? _Object$values : [], Object.values(node.attributes)) && ((_oldNodes$index3 = oldNodes[index]) == null ? void 0 : _oldNodes$index3.innerHTML) === node.innerHTML) { + console.log('no changes to UI node', oldNodes[index]); return "continue"; } var hasDirectivePrefix = Object.values(oldNodes[index].attributes).map(function (attr) { @@ -536,23 +545,26 @@ var Dom = /*#__PURE__*/function () { }).includes(true); })) { if (oldNodes[index].getAttribute(attr.name) !== attr.value) { - var _newNodeClone = node.cloneNode(true); - oldNodes[index].parentNode.replaceChild(_newNodeClone, oldNodes[index]); - initComponent(_newNodeClone); + var _newNodeClone2 = node.cloneNode(true); + oldNodes[index].parentNode.replaceChild(_newNodeClone2, oldNodes[index]); + console.log('replacing directive UI node', _newNodeClone2, oldNodes[index]); + initComponent(_newNodeClone2); } continue; } - var _newNodeClone2 = node.cloneNode(true); - oldNodes[index].parentNode.replaceChild(_newNodeClone2, oldNodes[index]); - initComponent(_newNodeClone2); + var _newNodeClone3 = node.cloneNode(true); + oldNodes[index].parentNode.replaceChild(_newNodeClone3, oldNodes[index]); + console.log('replacing leaf UI node', _newNodeClone3, oldNodes[index]); + initComponent(_newNodeClone3); } return "continue"; } // If element is not the same type, replace it with new element if (getNodeType(node) !== getNodeType(oldNodes[index])) { - var _newNodeClone3 = node.cloneNode(true); - oldNodes[index].parentNode.replaceChild(_newNodeClone3, oldNodes[index]); - initComponent(_newNodeClone3); + var _newNodeClone4 = node.cloneNode(true); + oldNodes[index].parentNode.replaceChild(_newNodeClone4, oldNodes[index]); + console.log('replacing node', _newNodeClone4, oldNodes[index]); + initComponent(_newNodeClone4); return { v: void 0 }; @@ -560,20 +572,23 @@ var Dom = /*#__PURE__*/function () { // If content is different, update it var templateContent = getNodeContent(node); if (templateContent && templateContent !== getNodeContent(oldNodes[index])) { + console.log('updating textContent', templateContent, oldNodes[index]); oldNodes[index].textContent = templateContent; } if (oldNodes[index].children.length > 0 && node.children.length < 1) { + console.log('clearing innerHTMl', node, oldNodes[index]); oldNodes[index].innerHTML = ''; return "continue"; } if (oldNodes[index].children.length < 1 && node.children.length > 0) { var fragment = document.createDocumentFragment(); + console.log('fragmenting', node, fragment); Dom.diff(node, fragment); oldNodes[index].appendChild(fragment); return "continue"; } if (node.children.length > 0) { - console.log('diffing children', newNode, oldNode); + console.log('diffing children', node, oldNodes[index]); Dom.diffElements(node, oldNodes[index]); } }; diff --git a/client/dist/ui.esm.js.map b/client/dist/ui.esm.js.map index cc6866f..6280e3f 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 payload = {\n type,\n payload: {\n params: [],\n method: uiData.method,\n methodArgs: uiData.methodArgs,\n component: uiData.config.component,\n data: uiData.config.data\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 // public sendMessage(message) {\n // // Forward the query string for the ajax requests.\n\n // .then(response => {\n // if (response.ok) {\n // response.text().then(response => {\n // if (this.isOutputFromDump(response)) {\n // this.onError(message);\n // this.showHtmlModal(response);\n // } else {\n // this.onMessage(\n // message,\n // JSON.parse(response)\n // );\n // }\n // });\n // } else {\n // if (\n // this.onError(\n // message,\n // response.status,\n // response\n // ) === false\n // )\n // return;\n\n // if (response.status === 419) {\n // if (store.sessionHasExpired) return;\n\n // store.sessionHasExpired = true;\n\n // this.showExpiredMessage(\n // response,\n // message\n // );\n // } else {\n // response.text().then(response => {\n // this.showHtmlModal(response);\n // });\n // }\n // }\n // })\n // .catch(() => {\n // this.onError(message);\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 { DIRECTIVE_SHORTHANDS, arraysMatch } from './../utils/data';\n\nexport default class Dom {\n static diff(newNode: string, oldNode: HTMLElement): void {\n Dom.diffElements(Dom.getBody(newNode, false), oldNode);\n }\n\n static diffElements(newNode: HTMLElement, oldNode: HTMLElement): void {\n const newNodes = Array.prototype.slice.call(newNode.children);\n const oldNodes = Array.prototype.slice.call(oldNode.children);\n\n /**\n * Get the type for a node\n * @param {Node} node The node\n * @return {String} The type\n */\n const getNodeType = (node: HTMLElement) => {\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 const getNodeContent = (node: HTMLElement) => {\n if (node.children && node.children.length > 0) return null;\n return node.textContent;\n };\n\n // const diff = Dom.compareNodesAndReturnChanges(newDomBody, oldNode);\n\n // If extra elements in DOM, remove them\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 // Diff each item in the newNodes\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 return;\n }\n\n if (\n arraysMatch(\n Object.keys(oldNodes[index]?.attributes) ?? [],\n Object.keys(node.attributes)\n ) &&\n arraysMatch(\n Object.values(oldNodes[index]?.attributes) ?? [],\n Object.values(node.attributes)\n ) &&\n oldNodes[index]?.innerHTML === node.innerHTML\n ) {\n continue;\n }\n\n const hasDirectivePrefix = Object.values(oldNodes[index].attributes)\n .map((attr: any) => attr.name.startsWith('ui-'))\n .includes(true);\n const hasDirectiveShorthandPrefix = Object.keys(\n DIRECTIVE_SHORTHANDS\n ).some(shorthand =>\n Object.values(oldNodes[index].attributes)\n .map((attr: any) => attr.name.startsWith(shorthand))\n .includes(true)\n );\n\n if (hasDirectivePrefix || hasDirectiveShorthandPrefix) {\n oldNodes[index].innerHTML = node.innerHTML;\n\n for (let j = 0; j < node.attributes.length; j++) {\n const attr = node.attributes[j];\n\n if (\n attr.name.startsWith('ui-') ||\n Object.keys(DIRECTIVE_SHORTHANDS).some(shorthand =>\n Object.values(oldNodes[index].attributes)\n .map((attr: any) =>\n attr.name.startsWith(shorthand)\n )\n .includes(true)\n )\n ) {\n if (\n oldNodes[index].getAttribute(attr.name) !==\n attr.value\n ) {\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n initComponent(newNodeClone);\n }\n\n continue;\n }\n\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n initComponent(newNodeClone);\n }\n continue;\n }\n\n // If element is not the same type, replace it with new element\n if (getNodeType(node) !== getNodeType(oldNodes[index])) {\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n initComponent(newNodeClone);\n return;\n }\n\n // If content is different, update it\n const templateContent = getNodeContent(node);\n if (\n templateContent &&\n templateContent !== 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.diff(node, fragment as any);\n oldNodes[index].appendChild(fragment);\n continue;\n }\n\n if (node.children.length > 0) {\n console.log('diffing children', newNode, oldNode);\n Dom.diffElements(node, oldNodes[index]);\n }\n }\n }\n\n static getBody(html: string, removeScripts: boolean = false): 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 static flattenDomIntoArray(node: HTMLElement): HTMLCollection {\n return node.getElementsByTagName('*');\n }\n\n static compareNodesAndReturnChanges(\n newNode: HTMLElement,\n oldNode: HTMLElement\n ): Record[] {\n const newNodes = Dom.flattenDomIntoArray(newNode);\n const oldNodes = Dom.flattenDomIntoArray(oldNode);\n const changes = [];\n\n for (let i = 0; i < newNodes.length; i++) {\n if (newNodes[i] !== oldNodes[i]) {\n if (newNodes[i].tagName !== oldNodes[i].tagName) {\n changes.push({\n oldNode: null,\n newNode: newNodes[i]\n });\n } else {\n changes.push({\n oldNode: oldNodes[i],\n newNode: newNodes[i]\n });\n }\n }\n }\n\n return changes;\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', { 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","payload","params","method","methodArgs","component","config","data","fetch","window","location","href","JSON","stringify","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","newNode","oldNode","diffElements","getBody","newNodes","prototype","slice","call","children","oldNodes","getNodeType","node","nodeType","tagName","toLowerCase","getNodeContent","textContent","count","parentNode","removeChild","newNodeClone","cloneNode","appendChild","initComponent","Object","keys","attributes","values","innerHTML","hasDirectivePrefix","map","attr","name","startsWith","includes","hasDirectiveShorthandPrefix","some","shorthand","j","getAttribute","value","replaceChild","templateContent","fragment","createDocumentFragment","log","removeScripts","parser","DOMParser","parseFromString","scripts","getElementsByTagName","i","remove","flattenDomIntoArray","compareNodesAndReturnChanges","changes","push","compute","refs","specialPropertiesNames","computeFunction","Function","join","emit","options","dispatchGlobal","event","CustomEvent","target","dispatchEvent","flattenElementChildren","rootElement","ignoreRootElement","collection","childElement","HTMLElement","collectRefs","element","refDirective","refElements","querySelectorAll","forEach","refElement","initDirectives","directives","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","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","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;AAC7B,CAAC;;ACRwC,IAEpBI,UAAU;EAAA;EAAA,WAGbC,OAAO,GAAd,iBACHC,IAAY,EACZC,M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C,OAAO,GAAG9K,QAAQ,CAAC+K,aAAa,CAAC,KAAK,CAAC;EAE3CH,OAAO,CAACvJ,SAAS,CAACwJ,YAAY,GAAG,SAASG,eAAe,CAAChI,IAAI,EAAEQ,KAAK;IACjE,IAAI,CAACR,IAAI,CAACE,QAAQ,CAAC,GAAG,CAAC,EAAE;MACrB,OAAOyH,QAAQ,CAACpJ,IAAI,CAAC,IAAI,EAAEyB,IAAI,EAAEQ,KAAK,CAAC;;IAG3CsH,OAAO,CAAClI,SAAS,cAAYI,IAAI,WAAKQ,KAAK,eAAW;IAEtD,IAAIT,IAAI,GAAI+H,OAAO,CAACG,iBAAiB,CAAGC,gBAAgB,CAAClI,IAAI,CAAE;IAE9D8H,OAAO,CAACG,iBAAiB,CAAGE,mBAAmB,CAACpI,IAAI,CAAC;IAEtD,IAAI,CAACqI,gBAAgB,CAACrI,IAAI,CAAC;GAC9B;AACL;;ACrBA/C,QAAQ,CAACsJ,gBAAgB,CAAC,kBAAkB,EAAE;EAC1CoB,0CAA0C,EAAE;EAC5CF,IAAI,EAAE;EAENxK,QAAQ,CAACiG,gBAAgB,CAAC,WAAW,CAAC,CAACC,OAAO,CAAC,UAAArI,EAAE;IAC7CA,EAAE,CAACwN,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 payload = {\n type,\n payload: {\n params: [],\n method: uiData.method,\n methodArgs: uiData.methodArgs,\n component: uiData.config.component,\n data: uiData.config.data\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 // public sendMessage(message) {\n // // Forward the query string for the ajax requests.\n\n // .then(response => {\n // if (response.ok) {\n // response.text().then(response => {\n // if (this.isOutputFromDump(response)) {\n // this.onError(message);\n // this.showHtmlModal(response);\n // } else {\n // this.onMessage(\n // message,\n // JSON.parse(response)\n // );\n // }\n // });\n // } else {\n // if (\n // this.onError(\n // message,\n // response.status,\n // response\n // ) === false\n // )\n // return;\n\n // if (response.status === 419) {\n // if (store.sessionHasExpired) return;\n\n // store.sessionHasExpired = true;\n\n // this.showExpiredMessage(\n // response,\n // message\n // );\n // } else {\n // response.text().then(response => {\n // this.showHtmlModal(response);\n // });\n // }\n // }\n // })\n // .catch(() => {\n // this.onError(message);\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 { DIRECTIVE_SHORTHANDS, arraysMatch } from './../utils/data';\n\nexport default class Dom {\n static diff(newNode: string, oldNode: HTMLElement): void {\n Dom.diffElements(Dom.getBody(newNode, false), oldNode);\n }\n\n static diffElements(newNode: HTMLElement, oldNode: HTMLElement): void {\n const newNodes = Array.prototype.slice.call(newNode.children);\n const oldNodes = Array.prototype.slice.call(oldNode.children);\n\n /**\n * Get the type for a node\n * @param {Node} node The node\n * @return {String} The type\n */\n const getNodeType = (node: HTMLElement) => {\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 const getNodeContent = (node: HTMLElement) => {\n if (node.children && node.children.length > 0) return null;\n return node.textContent;\n };\n\n // If extra elements in DOM, remove them\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 console.log('diffing node', node);\n\n if (!oldNodes[index]) {\n const newNodeClone = node.cloneNode(true);\n oldNode.appendChild(newNodeClone);\n console.log('adding new UI node', newNodeClone);\n initComponent(newNodeClone);\n return;\n }\n\n if (node instanceof HTMLScriptElement && oldNodes[index] instanceof HTMLScriptElement) {\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 console.log(\n 'replacing script UI node',\n newNodeClone,\n oldNodes[index]\n );\n }\n\n continue;\n }\n\n if (\n arraysMatch(\n Object.keys(oldNodes[index]?.attributes) ?? [],\n Object.keys(node.attributes)\n ) &&\n arraysMatch(\n Object.values(oldNodes[index]?.attributes) ?? [],\n Object.values(node.attributes)\n ) &&\n oldNodes[index]?.innerHTML === node.innerHTML\n ) {\n console.log('no changes to UI node', oldNodes[index]);\n continue;\n }\n\n const hasDirectivePrefix = Object.values(oldNodes[index].attributes)\n .map((attr: any) => attr.name.startsWith('ui-'))\n .includes(true);\n const hasDirectiveShorthandPrefix = Object.keys(\n DIRECTIVE_SHORTHANDS\n ).some(shorthand =>\n Object.values(oldNodes[index].attributes)\n .map((attr: any) => attr.name.startsWith(shorthand))\n .includes(true)\n );\n\n if (hasDirectivePrefix || hasDirectiveShorthandPrefix) {\n oldNodes[index].innerHTML = node.innerHTML;\n\n for (let j = 0; j < node.attributes.length; j++) {\n const attr = node.attributes[j];\n\n if (\n attr.name.startsWith('ui-') ||\n Object.keys(DIRECTIVE_SHORTHANDS).some(shorthand =>\n Object.values(oldNodes[index].attributes)\n .map((attr: any) =>\n attr.name.startsWith(shorthand)\n )\n .includes(true)\n )\n ) {\n if (\n oldNodes[index].getAttribute(attr.name) !==\n attr.value\n ) {\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n console.log('replacing directive UI node', newNodeClone, oldNodes[index]);\n initComponent(newNodeClone);\n }\n\n continue;\n }\n\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n console.log('replacing leaf UI node', newNodeClone, oldNodes[index]);\n initComponent(newNodeClone);\n }\n continue;\n }\n\n // If element is not the same type, replace it with new element\n if (getNodeType(node) !== getNodeType(oldNodes[index])) {\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n console.log('replacing node', newNodeClone, oldNodes[index]);\n initComponent(newNodeClone);\n return;\n }\n\n // If content is different, update it\n const templateContent = getNodeContent(node);\n if (\n templateContent &&\n templateContent !== getNodeContent(oldNodes[index])\n ) {\n console.log('updating textContent', templateContent, oldNodes[index]);\n oldNodes[index].textContent = templateContent;\n }\n\n if (\n oldNodes[index].children.length > 0 &&\n node.children.length < 1\n ) {\n console.log('clearing innerHTMl', node, oldNodes[index]);\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 console.log('fragmenting', node, fragment);\n Dom.diff(node, fragment as any);\n oldNodes[index].appendChild(fragment);\n continue;\n }\n\n if (node.children.length > 0) {\n console.log('diffing children', node, oldNodes[index]);\n Dom.diffElements(node, oldNodes[index]);\n }\n }\n }\n\n static getBody(html: string, removeScripts: boolean = false): 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 static flattenDomIntoArray(node: HTMLElement): HTMLCollection {\n return node.getElementsByTagName('*');\n }\n\n static compareNodesAndReturnChanges(\n newNode: HTMLElement,\n oldNode: HTMLElement\n ): Record[] {\n const newNodes = Dom.flattenDomIntoArray(newNode);\n const oldNodes = Dom.flattenDomIntoArray(oldNode);\n const changes = [];\n\n for (let i = 0; i < newNodes.length; i++) {\n if (newNodes[i] !== oldNodes[i]) {\n if (newNodes[i].tagName !== oldNodes[i].tagName) {\n changes.push({\n oldNode: null,\n newNode: newNodes[i]\n });\n } else {\n changes.push({\n oldNode: oldNodes[i],\n newNode: newNodes[i]\n });\n }\n }\n }\n\n return changes;\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', { 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","payload","params","method","methodArgs","component","config","data","fetch","window","location","href","JSON","stringify","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","newNode","oldNode","diffElements","getBody","newNodes","prototype","slice","call","children","oldNodes","getNodeType","node","nodeType","tagName","toLowerCase","getNodeContent","textContent","count","parentNode","removeChild","log","newNodeClone","cloneNode","appendChild","initComponent","HTMLScriptElement","src","innerHTML","replaceChild","Object","keys","attributes","values","hasDirectivePrefix","map","attr","name","startsWith","includes","hasDirectiveShorthandPrefix","some","shorthand","j","getAttribute","value","templateContent","fragment","createDocumentFragment","removeScripts","parser","DOMParser","parseFromString","scripts","getElementsByTagName","i","remove","flattenDomIntoArray","compareNodesAndReturnChanges","changes","push","compute","refs","specialPropertiesNames","computeFunction","Function","join","emit","options","dispatchGlobal","event","CustomEvent","target","dispatchEvent","flattenElementChildren","rootElement","ignoreRootElement","collection","childElement","HTMLElement","collectRefs","element","refDirective","refElements","querySelectorAll","forEach","refElement","initDirectives","directives","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","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","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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MAAM,GAAG,IAAIwJ,SAAS,EAAE;EAC9B,IAAM5E,WAAW,GAAGM,OAAO,YAAY2E,QAAQ,GAAG3E,OAAO,CAAC/F,IAAI,GAAG+F,OAAO;EAExElF,MAAM,CAACyJ,KAAK,CAAC7E,WAAW,CAAC;AAC7B,CAAC;;ACXD;;;;AAIA,SAAgBkF,0CAA0C;;;;EAItD,IAAIC,QAAQ,GAAGC,OAAO,CAACzJ,SAAS,CAAC0J,YAAY;EAE7C,IAAIC,OAAO,GAAGhL,QAAQ,CAACiL,aAAa,CAAC,KAAK,CAAC;EAE3CH,OAAO,CAACzJ,SAAS,CAAC0J,YAAY,GAAG,SAASG,eAAe,CAAC9H,IAAI,EAAEQ,KAAK;IACjE,IAAI,CAACR,IAAI,CAACE,QAAQ,CAAC,GAAG,CAAC,EAAE;MACrB,OAAOuH,QAAQ,CAACtJ,IAAI,CAAC,IAAI,EAAE6B,IAAI,EAAEQ,KAAK,CAAC;;IAG3CoH,OAAO,CAACrI,SAAS,cAAYS,IAAI,WAAKQ,KAAK,eAAW;IAEtD,IAAIT,IAAI,GAAI6H,OAAO,CAACG,iBAAiB,CAAGC,gBAAgB,CAAChI,IAAI,CAAE;IAE9D4H,OAAO,CAACG,iBAAiB,CAAGE,mBAAmB,CAAClI,IAAI,CAAC;IAEtD,IAAI,CAACmI,gBAAgB,CAACnI,IAAI,CAAC;GAC9B;AACL;;ACrBAnD,QAAQ,CAACwJ,gBAAgB,CAAC,kBAAkB,EAAE;EAC1CoB,0CAA0C,EAAE;EAC5CF,IAAI,EAAE;EAEN1K,QAAQ,CAACmG,gBAAgB,CAAC,WAAW,CAAC,CAACC,OAAO,CAAC,UAAAvI,EAAE;IAC7CA,EAAE,CAAC0N,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 520f9c8..2c62cb2 100644 --- a/client/src/engine/dom.ts +++ b/client/src/engine/dom.ts @@ -31,8 +31,6 @@ export default class Dom { return node.textContent; }; - // const diff = Dom.compareNodesAndReturnChanges(newDomBody, oldNode); - // If extra elements in DOM, remove them let count = oldNodes.length - newNodes.length; if (count > 0) { @@ -43,17 +41,39 @@ export default class Dom { } } - // Diff each item in the newNodes for (let index = 0; index < newNodes.length; index++) { const node = newNodes[index]; + console.log('diffing node', node); + if (!oldNodes[index]) { const newNodeClone = node.cloneNode(true); oldNode.appendChild(newNodeClone); + console.log('adding new UI node', newNodeClone); initComponent(newNodeClone); return; } + if (node instanceof HTMLScriptElement && oldNodes[index] instanceof HTMLScriptElement) { + if ( + node.src !== oldNodes[index].src || + node.innerHTML !== oldNodes[index].innerHTML + ) { + const newNodeClone = node.cloneNode(true); + oldNodes[index].parentNode.replaceChild( + newNodeClone, + oldNodes[index] + ); + console.log( + 'replacing script UI node', + newNodeClone, + oldNodes[index] + ); + } + + continue; + } + if ( arraysMatch( Object.keys(oldNodes[index]?.attributes) ?? [], @@ -65,6 +85,7 @@ export default class Dom { ) && oldNodes[index]?.innerHTML === node.innerHTML ) { + console.log('no changes to UI node', oldNodes[index]); continue; } @@ -104,6 +125,7 @@ export default class Dom { newNodeClone, oldNodes[index] ); + console.log('replacing directive UI node', newNodeClone, oldNodes[index]); initComponent(newNodeClone); } @@ -115,6 +137,7 @@ export default class Dom { newNodeClone, oldNodes[index] ); + console.log('replacing leaf UI node', newNodeClone, oldNodes[index]); initComponent(newNodeClone); } continue; @@ -127,6 +150,7 @@ export default class Dom { newNodeClone, oldNodes[index] ); + console.log('replacing node', newNodeClone, oldNodes[index]); initComponent(newNodeClone); return; } @@ -137,6 +161,7 @@ export default class Dom { templateContent && templateContent !== getNodeContent(oldNodes[index]) ) { + console.log('updating textContent', templateContent, oldNodes[index]); oldNodes[index].textContent = templateContent; } @@ -144,6 +169,7 @@ export default class Dom { oldNodes[index].children.length > 0 && node.children.length < 1 ) { + console.log('clearing innerHTMl', node, oldNodes[index]); oldNodes[index].innerHTML = ''; continue; } @@ -153,13 +179,14 @@ export default class Dom { node.children.length > 0 ) { const fragment = document.createDocumentFragment(); + console.log('fragmenting', node, fragment); Dom.diff(node, fragment as any); oldNodes[index].appendChild(fragment); continue; } if (node.children.length > 0) { - console.log('diffing children', newNode, oldNode); + console.log('diffing children', node, oldNodes[index]); Dom.diffElements(node, oldNodes[index]); } }