From f469c0e3d10bba6a486e5ae6a82d98eb40d2f237 Mon Sep 17 00:00:00 2001 From: mychidarko Date: Fri, 17 Feb 2023 11:52:46 +0000 Subject: [PATCH] fix: patch up dom diffing algorithm --- client/dist/ui.cjs.development.js | 62 ++++--------------- 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 | 62 ++++--------------- client/dist/ui.esm.js.map | 2 +- client/src/engine/dom.ts | 79 ++++-------------------- 7 files changed, 42 insertions(+), 169 deletions(-) diff --git a/client/dist/ui.cjs.development.js b/client/dist/ui.cjs.development.js index f9ddbd6..dacfe77 100644 --- a/client/dist/ui.cjs.development.js +++ b/client/dist/ui.cjs.development.js @@ -504,61 +504,29 @@ var Dom = /*#__PURE__*/function () { oldNodes[oldNodes.length - count].parentNode.removeChild(oldNodes[oldNodes.length - count]); } } - var _loop = function _loop(index) { - var _Object$keys, _oldNodes$index, _Object$values, _oldNodes$index2, _oldNodes$index3; + for (var index = 0; index < newNodes.length; index++) { + var _Object$keys, _oldNodes$index, _oldNodes$index2; var node = newNodes[index]; if (!oldNodes[index]) { var newNodeClone = node.cloneNode(true); oldNode.appendChild(newNodeClone); initComponent(newNodeClone); - return "continue"; + continue; } 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]); } - 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) { - return "continue"; - } - var hasDirectivePrefix = Object.values(oldNodes[index].attributes).map(function (attr) { - return attr.name.startsWith('ui-'); - }).includes(true); - var hasDirectiveShorthandPrefix = Object.keys(DIRECTIVE_SHORTHANDS).some(function (shorthand) { - return Object.values(oldNodes[index].attributes).map(function (attr) { - return attr.name.startsWith(shorthand); - }).includes(true); - }); - if (hasDirectivePrefix || hasDirectiveShorthandPrefix) { - oldNodes[index].innerHTML = node.innerHTML; - for (var j = 0; j < node.attributes.length; j++) { - var attr = node.attributes[j]; - if (attr.name.startsWith('ui-') || Object.keys(DIRECTIVE_SHORTHANDS).some(function (shorthand) { - return Object.values(oldNodes[index].attributes).map(function (attr) { - return attr.name.startsWith(shorthand); - }).includes(true); - })) { - if (oldNodes[index].getAttribute(attr.name) !== attr.value) { - var _newNodeClone2 = node.cloneNode(true); - oldNodes[index].parentNode.replaceChild(_newNodeClone2, oldNodes[index]); - initComponent(_newNodeClone2); - } - continue; - } - var _newNodeClone3 = node.cloneNode(true); - oldNodes[index].parentNode.replaceChild(_newNodeClone3, oldNodes[index]); - initComponent(_newNodeClone3); - } - return "continue"; + continue; } // If element is not the same type, replace it with new element - if (getNodeType(node) !== getNodeType(oldNodes[index])) { - var _newNodeClone4 = node.cloneNode(true); - oldNodes[index].parentNode.replaceChild(_newNodeClone4, oldNodes[index]); - initComponent(_newNodeClone4); - return "continue"; + if (getNodeType(node) !== getNodeType(oldNodes[index]) || !arraysMatch((_Object$keys = Object.keys((_oldNodes$index = oldNodes[index]) == null ? void 0 : _oldNodes$index.attributes)) != null ? _Object$keys : [], Object.keys(node.attributes)) || ((_oldNodes$index2 = oldNodes[index]) == null ? void 0 : _oldNodes$index2.innerHTML) !== node.innerHTML) { + console.log('replace', node, oldNodes[index]); + var _newNodeClone2 = node.cloneNode(true); + oldNodes[index].parentNode.replaceChild(_newNodeClone2, oldNodes[index]); + initComponent(_newNodeClone2); + continue; } // If content is different, update it var templateContent = getNodeContent(node); @@ -567,21 +535,17 @@ var Dom = /*#__PURE__*/function () { } if (oldNodes[index].children.length > 0 && node.children.length < 1) { oldNodes[index].innerHTML = ''; - return "continue"; + continue; } if (oldNodes[index].children.length < 1 && node.children.length > 0) { var fragment = document.createDocumentFragment(); - Dom.diff(node, fragment); + Dom.diffElements(node, fragment); oldNodes[index].appendChild(fragment); - return "continue"; + continue; } if (node.children.length > 0) { Dom.diffElements(node, oldNodes[index]); } - }; - for (var index = 0; index < newNodes.length; index++) { - var _ret = _loop(index); - if (_ret === "continue") continue; } }; Dom.getBody = function getBody(html, removeScripts) { diff --git a/client/dist/ui.cjs.development.js.map b/client/dist/ui.cjs.development.js.map index e5c02a1..0949390 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 // 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 if (!oldNodes[index]) {\n const newNodeClone = node.cloneNode(true);\n oldNode.appendChild(newNodeClone);\n initComponent(newNodeClone);\n continue;\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 }\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 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 continue;\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 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","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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AG,SAASG,eAAe,CAAC9H,IAAI,EAAEQ,KAAK;IACjE,IAAI,CAACR,IAAI,CAACE,QAAQ,CAAC,GAAG,CAAC,EAAE;MACrB,OAAOuH,QAAQ,CAACrJ,IAAI,CAAC,IAAI,EAAE4B,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;;ACrBAlD,QAAQ,CAACuJ,gBAAgB,CAAC,kBAAkB,EAAE;EAC1CoB,0CAA0C,EAAE;EAC5CF,IAAI,EAAE;EAENzK,QAAQ,CAACkG,gBAAgB,CAAC,WAAW,CAAC,CAACC,OAAO,CAAC,UAAAtI,EAAE;IAC7CA,EAAE,CAACyN,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 { 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 if (!oldNodes[index]) {\n const newNodeClone = node.cloneNode(true);\n oldNode.appendChild(newNodeClone);\n initComponent(newNodeClone);\n continue;\n }\n\n if (\n node instanceof HTMLScriptElement &&\n oldNodes[index] instanceof HTMLScriptElement\n ) {\n if (\n node.src !== oldNodes[index].src ||\n node.innerHTML !== oldNodes[index].innerHTML\n ) {\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n }\n\n continue;\n }\n\n // If element is not the same type, replace it with new element\n if (\n getNodeType(node) !== getNodeType(oldNodes[index]) ||\n !arraysMatch(\n Object.keys(oldNodes[index]?.attributes) ?? [],\n Object.keys(node.attributes)\n ) ||\n oldNodes[index]?.innerHTML !== node.innerHTML\n ) {\n console.log('replace', node, oldNodes[index]);\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n initComponent(newNodeClone);\n continue;\n }\n\n // If content is different, update it\n const templateContent = 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.diffElements(node, fragment as any);\n oldNodes[index].appendChild(fragment);\n continue;\n }\n\n if (node.children.length > 0) {\n Dom.diffElements(node, oldNodes[index]);\n }\n }\n }\n\n 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","HTMLScriptElement","src","innerHTML","replaceChild","Object","keys","attributes","log","templateContent","fragment","createDocumentFragment","removeScripts","parser","DOMParser","parseFromString","scripts","getElementsByTagName","i","remove","flattenDomIntoArray","compareNodesAndReturnChanges","changes","push","compute","refs","specialPropertiesNames","computeFunction","Function","join","emit","name","options","dispatchGlobal","event","CustomEvent","target","dispatchEvent","flattenElementChildren","rootElement","ignoreRootElement","collection","childElement","HTMLElement","collectRefs","element","refDirective","refElements","querySelectorAll","forEach","refElement","getAttribute","initDirectives","directives","value","hasDirectivePrefix","startsWith","hasDirectiveShorthandPrefix","some","shorthand","directiveData","directiveName","createASTNode","hasDirectives","STATIC","undefined","compile","uiNodes","elements","newASTNode","lazy","threshold","generatorFunction","generator","next","start","performance","now","task","done","setTimeout","onDirective","parts","globalScopeEventProps","eventProps","EVENT_REGISTERED_FLAG","prop","String","includes","handler","KeyboardEvent","test","whitelistedKeycodes","eventProp","isNaN","Number","keyCode","preventDefault","stopPropagation","contains","offsetWidth","offsetHeight","key","ctrlKey","altKey","shiftKey","button","once","passive","addEventListener","ON","renderDirective","props","toUpperCase","render","legalDirectiveNames","LAZY_MODE_TIMEOUT","NULL","isStatic","entries","rawDirectiveName","split","directiveProps","Component","mount","rootEl","querySelector","init","Document","monkeyPatchDomSetAttributeToAllowAtSymbols","original","Element","setAttribute","hostDiv","createElement","newSetAttribute","attr","firstElementChild","getAttributeNode","removeAttributeNode","setAttributeNode","removeAttribute"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,IAAYA,UAIX;AAJD,WAAYA,UAAU;EAClBA,4CAAS;EACTA,+CAAU;EACVA,iDAAW;AACf,CAAC,EAJWA,UAAU,KAAVA,UAAU;;ACtBf,IAAMC,KAAK,GAAG,SAARA,KAAK,CACdC,GAAW,EACXC,UAAmB,EACnBC,EAAgB;EAEhB,IAAIC,OAAO,wBAAqBH,GAAG,OAAG;EACtC,IAAI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,QAAQ,CAAC,GAAG,CAAC,EAAE;MACrB,OAAO0C,QAAQ,CAAClJ,IAAI,CAAC,IAAI,EAAE+C,IAAI,EAAEuB,KAAK,CAAC;;IAG3C+E,OAAO,CAAClI,SAAS,cAAY4B,IAAI,WAAKuB,KAAK,eAAW;IAEtD,IAAIkF,IAAI,GAAIH,OAAO,CAACI,iBAAiB,CAAGC,gBAAgB,CAAC3G,IAAI,CAAE;IAE9DsG,OAAO,CAACI,iBAAiB,CAAGE,mBAAmB,CAACH,IAAI,CAAC;IAEtD,IAAI,CAACI,gBAAgB,CAACJ,IAAI,CAAC;GAC9B;AACL;;ACrBA/K,QAAQ,CAACoJ,gBAAgB,CAAC,kBAAkB,EAAE;EAC1CoB,0CAA0C,EAAE;EAC5CF,IAAI,EAAE;EAENtK,QAAQ,CAACuF,gBAAgB,CAAC,WAAW,CAAC,CAACC,OAAO,CAAC,UAAA3H,EAAE;IAC7CA,EAAE,CAACuN,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 990b083..95ecfe5 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 p(){}function v(){}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=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,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(e){var c,s,f,d,h,p=r[e];if(!o[e]){var m=p.cloneNode(!0);return n.appendChild(m),v(m),"continue"}if(p instanceof HTMLScriptElement&&o[e]instanceof HTMLScriptElement){if(p.src!==o[e].src||p.innerHTML!==o[e].innerHTML){var y=p.cloneNode(!0);o[e].parentNode.replaceChild(y,o[e])}return"continue"}if(l(null!=(c=Object.keys(null==(s=o[e])?void 0:s.attributes))?c:[],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"continue";var g=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(g||b){o[e].innerHTML=p.innerHTML;for(var w=0;w0&&p.children.length<1)return o[e].innerHTML="","continue";if(o[e].children.length<1&&p.children.length>0){var A=document.createDocumentFragment();return t.diff(p,A),o[e].appendChild(A),"continue"}p.children.length>0&&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 ("+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)},p=function(){function e(){this.uiNodes=[],this.uiNodes=[]}var n=e.prototype;return n.mount=function(t){var e=t instanceof HTMLElement?t:document.querySelector(t)||document.body;return this.uiNodes=function(t,e){void 0===e&&(e=!1);var n=[];return function t(e,n){void 0===n&&(n=!1);var r=[];n||r.push(e);for(var i,a=o(e.children);!(i=a()).done;){var u=i.value;u instanceof HTMLElement&&r.push.apply(r,t(u,0===u.attributes.length))}return r}(t,e).forEach((function(t){var e=function(t){var e=function(t){for(var e,n={},r=function(t){void 0===t&&(t=document);var e=t.querySelectorAll("[ui-ref]"),n={};return e.forEach((function(t){var e=t.getAttribute("ui-ref");e&&(n[e]=t)})),n}(),i=function(){var o=e.value,i=o.name,u=o.value,c=i.startsWith("ui-"),l=Object.keys(a).some((function(t){return i.startsWith(t)}));if(!c&&!l)return"continue";var s={compute:f(u,t,r),value:u},d=c?i.slice("ui-".length):a[i[0]]+":"+i.slice(1);n[d.toLowerCase()]=s},u=o(t.attributes);!(e=u()).done;)i();return n}(t);return Object.keys(e).length>0?{el:t,directives:e,type:i.STATIC}:void 0}(t);e&&n.push(e)})),n}(e),this.render(),e.component=this,window.leafUI={rootEl:e,component:this},this},n.render=function(){!function(e,n){var r,a=Object.keys(n);(r=t().mark((function r(){var u,c,l,s,f,d,p,v,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 p,n=t instanceof Document?t.body:t;e.mount(n)}(),document.querySelectorAll("[ui-lazy]").forEach((function(t){t.removeAttribute("ui-lazy")}))})); +"use strict";function t(){t=function(){return e};var e={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",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 O(r||[]);return o(i,"_invoke",{value:E(t,n,a)}),i}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=s;var d={};function h(){}function p(){}function v(){}var y={};l(y,a,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(S([])));g&&g!==n&&r.call(g,a)&&(y=g);var w=v.prototype=h.prototype=Object.create(y);function b(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){var n;o(this,"_invoke",{value:function(o,i){function a(){return new e((function(n,a){!function n(o,i,a,c){var u=f(t[o],t,i);if("throw"!==u.type){var l=u.arg,s=l.value;return s&&"object"==typeof s&&r.call(s,"__await")?e.resolve(s.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(s).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}})}function E(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=L(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 L(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,L(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 A(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(N,this),this.reset(!0)}function S(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var 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),A(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;A(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:S(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),d}},e}function e(t,e,n,r,o,i,a){try{var 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()},a=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 u=0;u0&&h.children.length<1)o[u].innerHTML="";else if(o[u].children.length<1&&h.children.length>0){var m=document.createDocumentFragment();t.diffElements(h,m),o[u].appendChild(m)}else h.children.length>0&&t.diffElements(h,o[u])}else{console.log("replace",h,o[u]);var g=h.cloneNode(!0);o[u].parentNode.replaceChild(g,o[u]),v(g)}else{var w=h.cloneNode(!0);n.appendChild(w),v(w)}}},t.getBody=function(t,e){void 0===e&&(e=!1);var n=(new DOMParser).parseFromString(t,"text/html");if(!0===e)for(var r=n.body.getElementsByTagName("script"),o=0;o {\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,y,m,g;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:c=o(e);case 1:if((u=c()).done){t.next=25;break}if((l=u.value).type!==i.NULL){t.next=5;break}return t.abrupt("continue",23);case 5:return(s=l.type===i.STATIC)&&(l.type=i.NULL),void(t.next=9);case 9:if(s){t.next=11;break}return t.abrupt("continue",23);case 11:f=0,d=Object.entries(l.directives);case 12:if(!(f';var o=e.firstElementChild.getAttributeNode(n);e.firstElementChild.removeAttributeNode(o),this.setAttributeNode(o)},function(t){void 0===t&&(t=document);var e=new p,n=t instanceof Document?t.body:t;e.mount(n)}(),document.querySelectorAll("[ui-lazy]").forEach((function(t){t.removeAttribute("ui-lazy")}))})); //# 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 ee7c43b..c89eb0d 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 // 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 if (!oldNodes[index]) {\n const newNodeClone = node.cloneNode(true);\n oldNode.appendChild(newNodeClone);\n initComponent(newNodeClone);\n continue;\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 }\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 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 continue;\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 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","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,m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Ac,OAErCF,QAAQlJ,UAAUmJ,aAAe,SAAyBlH,EAAMQ,GAC5D,IAAKR,EAAKE,SAAS,KACf,OAAO6G,EAAS9I,KAAKjC,KAAMgE,EAAMQ,GAGrCwG,EAAQ5H,mBAAqBY,OAASQ,cAEtC,IAAIT,EAAQiH,EAAQI,kBAAoBC,iBAAiBrH,GAExDgH,EAAQI,kBAAoBE,oBAAoBvH,GAEjD/D,KAAKuL,iBAAiBxH,ICjBV,SAAC+E,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 { 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 if (!oldNodes[index]) {\n const newNodeClone = node.cloneNode(true);\n oldNode.appendChild(newNodeClone);\n initComponent(newNodeClone);\n continue;\n }\n\n if (\n node instanceof HTMLScriptElement &&\n oldNodes[index] instanceof HTMLScriptElement\n ) {\n if (\n node.src !== oldNodes[index].src ||\n node.innerHTML !== oldNodes[index].innerHTML\n ) {\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n }\n\n continue;\n }\n\n // If element is not the same type, replace it with new element\n if (\n getNodeType(node) !== getNodeType(oldNodes[index]) ||\n !arraysMatch(\n Object.keys(oldNodes[index]?.attributes) ?? [],\n Object.keys(node.attributes)\n ) ||\n oldNodes[index]?.innerHTML !== node.innerHTML\n ) {\n console.log('replace', node, oldNodes[index]);\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n initComponent(newNodeClone);\n continue;\n }\n\n // If content is different, update it\n const templateContent = 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.diffElements(node, fragment as any);\n oldNodes[index].appendChild(fragment);\n continue;\n }\n\n if (node.children.length > 0) {\n Dom.diffElements(node, oldNodes[index]);\n }\n }\n }\n\n 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","HTMLScriptElement","src","innerHTML","newNodeClone","cloneNode","replaceChild","Object","keys","_oldNodes$index","attributes","_oldNodes$index2","templateContent","fragment","createDocumentFragment","appendChild","log","initComponent","removeScripts","DOMParser","parseFromString","scripts","getElementsByTagName","i","remove","flattenDomIntoArray","compareNodesAndReturnChanges","changes","push","compute","refs","computeFunction","Function","join","emit","name","options","dispatchGlobal","event","CustomEvent","dispatchEvent","directives","ON","parts","eventProps","EVENT_REGISTERED_FLAG","target","some","prop","String","includes","once","passive","addEventListener","KeyboardEvent","test","whitelistedKeycodes","forEach","eventProp","isNaN","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","getAttribute","collectRefs","value","hasDirectivePrefix","startsWith","hasDirectiveShorthandPrefix","shorthand","directiveData","directiveName","initDirectives","STATIC","undefined","createASTNode","compile","render","generator","legalDirectiveNames","_iterator","NULL","isStatic","_i","entries","_Object$entries$_i","rawDirectiveName","split","directiveProps","generatorFunction","next","start","performance","now","task","done","setTimeout","original","hostDiv","Element","setAttribute","createElement","attr","firstElementChild","getAttributeNode","removeAttributeNode","setAttributeNode","Document","init","removeAttribute"],"mappings":"gnPAsBA,IAAYA,GAAZ,SAAYA,GACRA,oBACAA,uBACAA,yBAHJ,CAAYA,IAAAA,OCtBL,ICmBKC,EDnBCC,EAAQ,SACjBC,EACAC,EACAC,GAEA,IAAIC,oBAA4BH,MAC5BC,IAAYE,uBAA+BF,OAC3CC,IAAIC,iBACRC,QAAQC,KAAKF,EAASD,IELLI,aAAU,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,U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nC,SAIhBxB,EAAgB,SAACsE,GAAgB,OAC1C,IAAIZ,GAAYG,MAAMS,IIrC1BxH,SAASsF,iBAAiB,oBAAoB,WCA9C,IAIQyE,EAEAC,EAFAD,EAAWE,QAAQ9I,UAAU+I,aAE7BF,EAAUhK,SAASmK,cAAc,OAErCF,QAAQ9I,UAAU+I,aAAe,SAAyB9F,EAAM2D,GAC5D,IAAK3D,EAAKe,SAAS,KACf,OAAO4E,EAAS1I,KAAKjC,KAAMgF,EAAM2D,GAGrCiC,EAAQ5H,mBAAqBgC,OAAS2D,cAEtC,IAAIqC,EAAQJ,EAAQK,kBAAoBC,iBAAiBlG,GAExD4F,EAAQK,kBAAoBE,oBAAoBH,GAEjDhL,KAAKoL,iBAAiBJ,ICjBV,SAAC5C,YAAAA,IAAAA,EAAkCxH,UACnD,IAAMY,EAAS,IAAIgG,EACbS,EAAcG,aAAmBiD,SAAWjD,EAAQvH,KAAOuH,EAEjE5G,EAAOmG,MAAMM,GFJbqD,GAEA1K,SAAS2H,iBAAiB,aAAajC,SAAQ,SAAAjI,GAC3CA,EAAGkN,gBAAgB"} \ No newline at end of file diff --git a/client/dist/ui.esm.js b/client/dist/ui.esm.js index 6410304..a32f4ba 100644 --- a/client/dist/ui.esm.js +++ b/client/dist/ui.esm.js @@ -502,61 +502,29 @@ var Dom = /*#__PURE__*/function () { oldNodes[oldNodes.length - count].parentNode.removeChild(oldNodes[oldNodes.length - count]); } } - var _loop = function _loop(index) { - var _Object$keys, _oldNodes$index, _Object$values, _oldNodes$index2, _oldNodes$index3; + for (var index = 0; index < newNodes.length; index++) { + var _Object$keys, _oldNodes$index, _oldNodes$index2; var node = newNodes[index]; if (!oldNodes[index]) { var newNodeClone = node.cloneNode(true); oldNode.appendChild(newNodeClone); initComponent(newNodeClone); - return "continue"; + continue; } 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]); } - 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) { - return "continue"; - } - var hasDirectivePrefix = Object.values(oldNodes[index].attributes).map(function (attr) { - return attr.name.startsWith('ui-'); - }).includes(true); - var hasDirectiveShorthandPrefix = Object.keys(DIRECTIVE_SHORTHANDS).some(function (shorthand) { - return Object.values(oldNodes[index].attributes).map(function (attr) { - return attr.name.startsWith(shorthand); - }).includes(true); - }); - if (hasDirectivePrefix || hasDirectiveShorthandPrefix) { - oldNodes[index].innerHTML = node.innerHTML; - for (var j = 0; j < node.attributes.length; j++) { - var attr = node.attributes[j]; - if (attr.name.startsWith('ui-') || Object.keys(DIRECTIVE_SHORTHANDS).some(function (shorthand) { - return Object.values(oldNodes[index].attributes).map(function (attr) { - return attr.name.startsWith(shorthand); - }).includes(true); - })) { - if (oldNodes[index].getAttribute(attr.name) !== attr.value) { - var _newNodeClone2 = node.cloneNode(true); - oldNodes[index].parentNode.replaceChild(_newNodeClone2, oldNodes[index]); - initComponent(_newNodeClone2); - } - continue; - } - var _newNodeClone3 = node.cloneNode(true); - oldNodes[index].parentNode.replaceChild(_newNodeClone3, oldNodes[index]); - initComponent(_newNodeClone3); - } - return "continue"; + continue; } // If element is not the same type, replace it with new element - if (getNodeType(node) !== getNodeType(oldNodes[index])) { - var _newNodeClone4 = node.cloneNode(true); - oldNodes[index].parentNode.replaceChild(_newNodeClone4, oldNodes[index]); - initComponent(_newNodeClone4); - return "continue"; + if (getNodeType(node) !== getNodeType(oldNodes[index]) || !arraysMatch((_Object$keys = Object.keys((_oldNodes$index = oldNodes[index]) == null ? void 0 : _oldNodes$index.attributes)) != null ? _Object$keys : [], Object.keys(node.attributes)) || ((_oldNodes$index2 = oldNodes[index]) == null ? void 0 : _oldNodes$index2.innerHTML) !== node.innerHTML) { + console.log('replace', node, oldNodes[index]); + var _newNodeClone2 = node.cloneNode(true); + oldNodes[index].parentNode.replaceChild(_newNodeClone2, oldNodes[index]); + initComponent(_newNodeClone2); + continue; } // If content is different, update it var templateContent = getNodeContent(node); @@ -565,21 +533,17 @@ var Dom = /*#__PURE__*/function () { } if (oldNodes[index].children.length > 0 && node.children.length < 1) { oldNodes[index].innerHTML = ''; - return "continue"; + continue; } if (oldNodes[index].children.length < 1 && node.children.length > 0) { var fragment = document.createDocumentFragment(); - Dom.diff(node, fragment); + Dom.diffElements(node, fragment); oldNodes[index].appendChild(fragment); - return "continue"; + continue; } if (node.children.length > 0) { Dom.diffElements(node, oldNodes[index]); } - }; - for (var index = 0; index < newNodes.length; index++) { - var _ret = _loop(index); - if (_ret === "continue") continue; } }; Dom.getBody = function getBody(html, removeScripts) { diff --git a/client/dist/ui.esm.js.map b/client/dist/ui.esm.js.map index 5a2c575..8fde596 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 // 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 if (!oldNodes[index]) {\n const newNodeClone = node.cloneNode(true);\n oldNode.appendChild(newNodeClone);\n initComponent(newNodeClone);\n continue;\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 }\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 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 continue;\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 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","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;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,MAA2B,EAC3BC,GAAe;IAEf,IAAMC,OAAO,GAAG;MACZH,IAAI,EAAJA,IAAI;MACJG,OAAO,EAAE;QACLC,MAAM,EAAE,EAAE;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AC9F,IAAI,GAAG8F,OAAO;EAExEjF,MAAM,CAACwJ,KAAK,CAAC7E,WAAW,CAAC;AAC7B,CAAC;;ACXD;;;;AAIA,SAAgBkF,0CAA0C;;;;EAItD,IAAIC,QAAQ,GAAGC,OAAO,CAACxJ,SAAS,CAACyJ,YAAY;EAE7C,IAAIC,OAAO,GAAG/K,QAAQ,CAACgL,aAAa,CAAC,KAAK,CAAC;EAE3CH,OAAO,CAACxJ,SAAS,CAACyJ,YAAY,GAAG,SAASG,eAAe,CAAC9H,IAAI,EAAEQ,KAAK;IACjE,IAAI,CAACR,IAAI,CAACE,QAAQ,CAAC,GAAG,CAAC,EAAE;MACrB,OAAOuH,QAAQ,CAACrJ,IAAI,CAAC,IAAI,EAAE4B,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;;ACrBAlD,QAAQ,CAACuJ,gBAAgB,CAAC,kBAAkB,EAAE;EAC1CoB,0CAA0C,EAAE;EAC5CF,IAAI,EAAE;EAENzK,QAAQ,CAACkG,gBAAgB,CAAC,WAAW,CAAC,CAACC,OAAO,CAAC,UAAAtI,EAAE;IAC7CA,EAAE,CAACyN,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 { 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 if (!oldNodes[index]) {\n const newNodeClone = node.cloneNode(true);\n oldNode.appendChild(newNodeClone);\n initComponent(newNodeClone);\n continue;\n }\n\n if (\n node instanceof HTMLScriptElement &&\n oldNodes[index] instanceof HTMLScriptElement\n ) {\n if (\n node.src !== oldNodes[index].src ||\n node.innerHTML !== oldNodes[index].innerHTML\n ) {\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n }\n\n continue;\n }\n\n // If element is not the same type, replace it with new element\n if (\n getNodeType(node) !== getNodeType(oldNodes[index]) ||\n !arraysMatch(\n Object.keys(oldNodes[index]?.attributes) ?? [],\n Object.keys(node.attributes)\n ) ||\n oldNodes[index]?.innerHTML !== node.innerHTML\n ) {\n console.log('replace', node, oldNodes[index]);\n const newNodeClone = node.cloneNode(true);\n oldNodes[index].parentNode.replaceChild(\n newNodeClone,\n oldNodes[index]\n );\n initComponent(newNodeClone);\n continue;\n }\n\n // If content is different, update it\n const templateContent = 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.diffElements(node, fragment as any);\n oldNodes[index].appendChild(fragment);\n continue;\n }\n\n if (node.children.length > 0) {\n Dom.diffElements(node, oldNodes[index]);\n }\n }\n }\n\n 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","HTMLScriptElement","src","innerHTML","replaceChild","Object","keys","attributes","log","templateContent","fragment","createDocumentFragment","removeScripts","parser","DOMParser","parseFromString","scripts","getElementsByTagName","i","remove","flattenDomIntoArray","compareNodesAndReturnChanges","changes","push","compute","refs","specialPropertiesNames","computeFunction","Function","join","emit","name","options","dispatchGlobal","event","CustomEvent","target","dispatchEvent","flattenElementChildren","rootElement","ignoreRootElement","collection","childElement","HTMLElement","collectRefs","element","refDirective","refElements","querySelectorAll","forEach","refElement","getAttribute","initDirectives","directives","value","hasDirectivePrefix","startsWith","hasDirectiveShorthandPrefix","some","shorthand","directiveData","directiveName","createASTNode","hasDirectives","STATIC","undefined","compile","uiNodes","elements","newASTNode","lazy","threshold","generatorFunction","generator","next","start","performance","now","task","done","setTimeout","onDirective","parts","globalScopeEventProps","eventProps","EVENT_REGISTERED_FLAG","prop","String","includes","handler","KeyboardEvent","test","whitelistedKeycodes","eventProp","isNaN","Number","keyCode","preventDefault","stopPropagation","contains","offsetWidth","offsetHeight","key","ctrlKey","altKey","shiftKey","button","once","passive","addEventListener","ON","renderDirective","props","toUpperCase","render","legalDirectiveNames","LAZY_MODE_TIMEOUT","NULL","isStatic","entries","rawDirectiveName","split","directiveProps","Component","mount","rootEl","querySelector","init","Document","monkeyPatchDomSetAttributeToAllowAtSymbols","original","Element","setAttribute","hostDiv","createElement","newSetAttribute","attr","firstElementChild","getAttributeNode","removeAttributeNode","setAttributeNode","removeAttribute"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAAC;;ACXD;;;;AAIA,SAAgB0F,0CAA0C;;;;EAItD,IAAIC,QAAQ,GAAGC,OAAO,CAACrJ,SAAS,CAACsJ,YAAY;EAE7C,IAAIC,OAAO,GAAG5K,QAAQ,CAAC6K,aAAa,CAAC,KAAK,CAAC;EAE3CH,OAAO,CAACrJ,SAAS,CAACsJ,YAAY,GAAG,SAASG,eAAe,CAACxG,IAAI,EAAEuB,KAAK;IACjE,IAAI,CAACvB,IAAI,CAACyD,QAAQ,CAAC,GAAG,CAAC,EAAE;MACrB,OAAO0C,QAAQ,CAAClJ,IAAI,CAAC,IAAI,EAAE+C,IAAI,EAAEuB,KAAK,CAAC;;IAG3C+E,OAAO,CAAClI,SAAS,cAAY4B,IAAI,WAAKuB,KAAK,eAAW;IAEtD,IAAIkF,IAAI,GAAIH,OAAO,CAACI,iBAAiB,CAAGC,gBAAgB,CAAC3G,IAAI,CAAE;IAE9DsG,OAAO,CAACI,iBAAiB,CAAGE,mBAAmB,CAACH,IAAI,CAAC;IAEtD,IAAI,CAACI,gBAAgB,CAACJ,IAAI,CAAC;GAC9B;AACL;;ACrBA/K,QAAQ,CAACoJ,gBAAgB,CAAC,kBAAkB,EAAE;EAC1CoB,0CAA0C,EAAE;EAC5CF,IAAI,EAAE;EAENtK,QAAQ,CAACuF,gBAAgB,CAAC,WAAW,CAAC,CAACC,OAAO,CAAC,UAAA3H,EAAE;IAC7CA,EAAE,CAACuN,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 2c8e031..a588180 100644 --- a/client/src/engine/dom.ts +++ b/client/src/engine/dom.ts @@ -1,5 +1,5 @@ import { initComponent } from './../core/component'; -import { DIRECTIVE_SHORTHANDS, arraysMatch } from './../utils/data'; +import { arraysMatch } from './../utils/data'; export default class Dom { static diff(newNode: string, oldNode: HTMLElement): void { @@ -51,7 +51,10 @@ export default class Dom { continue; } - if (node instanceof HTMLScriptElement && oldNodes[index] instanceof HTMLScriptElement) { + if ( + node instanceof HTMLScriptElement && + oldNodes[index] instanceof HTMLScriptElement + ) { if ( node.src !== oldNodes[index].src || node.innerHTML !== oldNodes[index].innerHTML @@ -66,74 +69,16 @@ export default class Dom { continue; } + // If element is not the same type, replace it with new element if ( - arraysMatch( + getNodeType(node) !== getNodeType(oldNodes[index]) || + !arraysMatch( Object.keys(oldNodes[index]?.attributes) ?? [], Object.keys(node.attributes) - ) && - arraysMatch( - Object.values(oldNodes[index]?.attributes) ?? [], - Object.values(node.attributes) - ) && - oldNodes[index]?.innerHTML === node.innerHTML + ) || + oldNodes[index]?.innerHTML !== node.innerHTML ) { - continue; - } - - const hasDirectivePrefix = Object.values(oldNodes[index].attributes) - .map((attr: any) => attr.name.startsWith('ui-')) - .includes(true); - const hasDirectiveShorthandPrefix = Object.keys( - DIRECTIVE_SHORTHANDS - ).some(shorthand => - Object.values(oldNodes[index].attributes) - .map((attr: any) => attr.name.startsWith(shorthand)) - .includes(true) - ); - - if (hasDirectivePrefix || hasDirectiveShorthandPrefix) { - oldNodes[index].innerHTML = node.innerHTML; - - for (let j = 0; j < node.attributes.length; j++) { - const attr = node.attributes[j]; - - if ( - attr.name.startsWith('ui-') || - Object.keys(DIRECTIVE_SHORTHANDS).some(shorthand => - Object.values(oldNodes[index].attributes) - .map((attr: any) => - attr.name.startsWith(shorthand) - ) - .includes(true) - ) - ) { - if ( - oldNodes[index].getAttribute(attr.name) !== - attr.value - ) { - const newNodeClone = node.cloneNode(true); - oldNodes[index].parentNode.replaceChild( - newNodeClone, - oldNodes[index] - ); - initComponent(newNodeClone); - } - - continue; - } - - const newNodeClone = node.cloneNode(true); - oldNodes[index].parentNode.replaceChild( - newNodeClone, - oldNodes[index] - ); - initComponent(newNodeClone); - } - continue; - } - - // If element is not the same type, replace it with new element - if (getNodeType(node) !== getNodeType(oldNodes[index])) { + console.log('replace', node, oldNodes[index]); const newNodeClone = node.cloneNode(true); oldNodes[index].parentNode.replaceChild( newNodeClone, @@ -165,7 +110,7 @@ export default class Dom { node.children.length > 0 ) { const fragment = document.createDocumentFragment(); - Dom.diff(node, fragment as any); + Dom.diffElements(node, fragment as any); oldNodes[index].appendChild(fragment); continue; }