valyrian.js 7.2.8 → 7.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../lib/dataset/index.ts"],
4
+ "sourcesContent": ["import { VnodeInterface, VnodeWithDom, createDomElement, directive, patch, updateAttributes } from \"valyrian.js\";\n\ninterface DataSetInterface<T> {\n data: T[];\n // eslint-disable-next-line no-unused-vars\n reset: (data: T[]) => void;\n // eslint-disable-next-line no-unused-vars\n add: (...data: T[]) => void;\n // eslint-disable-next-line no-unused-vars\n update: (index: number, data: T) => void;\n // eslint-disable-next-line no-unused-vars\n delete: (index: number) => void;\n}\ninterface DataSetHandler<T> {\n // eslint-disable-next-line no-unused-vars\n (data: T, index: number): VnodeInterface;\n}\n\nfunction deepFreeze(obj: any) {\n if (typeof obj === \"object\" && obj !== null && !Object.isFrozen(obj)) {\n if (Array.isArray(obj)) {\n for (let i = 0, l = obj.length; i < l; i++) {\n deepFreeze(obj[i]);\n }\n } else {\n let props = Reflect.ownKeys(obj);\n for (let i = 0, l = props.length; i < l; i++) {\n deepFreeze(obj[props[i]]);\n }\n }\n Object.freeze(obj);\n }\n\n return obj;\n}\n\nexport class DataSet<T> implements DataSetInterface<T> {\n #vnode: VnodeWithDom;\n // eslint-disable-next-line no-unused-vars\n #handler: DataSetHandler<T>;\n #data: T[] = [];\n #isFrozen = false;\n #dataProxy: T[] | null = null;\n\n get data() {\n if (this.#dataProxy === null) {\n throw new Error(\"DataSet is not initialized\");\n }\n\n return this.#dataProxy;\n }\n\n set data(data: T[]) {\n throw new Error(\"You need to use the reset method to set the data\");\n }\n\n #setData(data: T[]) {\n if (this.#isFrozen) {\n this.#data = deepFreeze([...data]);\n } else {\n this.#data = data;\n }\n this.#dataProxy = new Proxy(this.#data as T[], {\n set: () => {\n throw new Error(\"You need to use the add, update or delete methods to change the data\");\n },\n get(target, prop) {\n return target[prop];\n },\n deleteProperty: () => {\n throw new Error(\"You need to use the add, update or delete methods to change the data\");\n }\n }) as T[];\n }\n\n constructor(data: T[] = [], shouldFreeze = true) {\n this.#isFrozen = shouldFreeze;\n this.#setData(data);\n }\n\n setVnodeAndHandler(vnode: VnodeWithDom, handler: DataSetHandler<T>) {\n this.#vnode = vnode;\n this.#handler = handler;\n this.reset(this.#data);\n }\n\n reset(data: T[]) {\n this.#setData(data);\n let vnode = this.#vnode;\n let handler = this.#handler;\n\n if (data.length === 0) {\n vnode.children = [];\n vnode.dom.textContent = \"\";\n return;\n }\n\n let childrenLength = vnode.children.length;\n for (let i = 0, l = data.length; i < l; i++) {\n let child = handler(this.data[i], i);\n\n if (i < childrenLength) {\n let oldChild = vnode.children[i];\n child.isSVG = oldChild.isSVG;\n child.dom = oldChild.dom;\n updateAttributes(child as VnodeWithDom, oldChild);\n vnode.children[i] = child;\n patch(child as VnodeWithDom, oldChild);\n continue;\n }\n\n child.isSVG = vnode.isSVG || child.tag === \"svg\";\n child.dom = createDomElement(child.tag as string, child.isSVG);\n vnode.dom.appendChild(child.dom);\n updateAttributes(child as VnodeWithDom);\n vnode.children.push(child);\n patch(child as VnodeWithDom);\n }\n\n for (let i = data.length; i < childrenLength; i++) {\n vnode.dom.removeChild(vnode.children[i].dom);\n }\n vnode.children.length = data.length;\n }\n\n add(...data: T[]) {\n if (this.#data) {\n let oldLength = this.#data.length;\n if (this.#isFrozen) {\n this.#setData([...this.#data, ...data]);\n } else {\n this.#data.push(...data);\n }\n\n let vnode = this.#vnode;\n let handler = this.#handler;\n\n for (let i = 0, ii = oldLength, l = data.length; i < l; i++, ii++) {\n let child = handler(this.#data[i], ii);\n child.isSVG = vnode.isSVG || child.tag === \"svg\";\n child.dom = createDomElement(child.tag as string, child.isSVG);\n vnode.dom.appendChild(child.dom);\n updateAttributes(child as VnodeWithDom);\n vnode.children.push(child);\n patch(child as VnodeWithDom);\n }\n }\n }\n\n delete(index) {\n if (this.#data) {\n let child = this.#vnode.children[index];\n if (this.#isFrozen) {\n this.#setData(this.data.filter((_, i) => i !== index));\n } else {\n this.#data.splice(index, 1);\n }\n\n this.#vnode.dom.removeChild(child.dom);\n this.#vnode.children.splice(index, 1);\n }\n }\n\n update(index, item: Partial<T>) {\n if (this.#data) {\n let child = this.#vnode.children[index];\n if (this.#isFrozen) {\n this.#setData(this.#data.map((d, i) => (i === index ? { ...d, ...item } : d)));\n } else {\n this.#data[index] = { ...this.#data[index], ...item };\n }\n let newChild = this.#handler(this.#data[index], index);\n newChild.isSVG = this.#vnode.isSVG || newChild.tag === \"svg\";\n newChild.dom = child.dom;\n this.#vnode.children[index] = newChild;\n updateAttributes(newChild as VnodeWithDom, child);\n patch(newChild as VnodeWithDom, child);\n }\n }\n}\n\ndirective(\"with-dataset\", (dataSet, vnode) => {\n dataSet.setVnodeAndHandler(vnode as VnodeWithDom, vnode.children[0]);\n return false;\n});\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAmG;AAkBnG,SAAS,WAAW,KAAU;AAC5B,MAAI,OAAO,QAAQ,YAAY,QAAQ,QAAQ,CAAC,OAAO,SAAS,GAAG,GAAG;AACpE,QAAI,MAAM,QAAQ,GAAG,GAAG;AACtB,eAAS,IAAI,GAAG,IAAI,IAAI,QAAQ,IAAI,GAAG,KAAK;AAC1C,mBAAW,IAAI,CAAC,CAAC;AAAA,MACnB;AAAA,IACF,OAAO;AACL,UAAI,QAAQ,QAAQ,QAAQ,GAAG;AAC/B,eAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,IAAI,GAAG,KAAK;AAC5C,mBAAW,IAAI,MAAM,CAAC,CAAC,CAAC;AAAA,MAC1B;AAAA,IACF;AACA,WAAO,OAAO,GAAG;AAAA,EACnB;AAEA,SAAO;AACT;AAEO,IAAM,UAAN,MAAgD;AAAA,EACrD;AAAA;AAAA,EAEA;AAAA,EACA,QAAa,CAAC;AAAA,EACd,YAAY;AAAA,E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O,OAAO;AACZ,QAAI,KAAK,OAAO;AACd,UAAI,QAAQ,KAAK,OAAO,SAAS,KAAK;AACtC,UAAI,KAAK,WAAW;AAClB,aAAK,SAAS,KAAK,KAAK,OAAO,CAAC,GAAG,MAAM,MAAM,KAAK,CAAC;AAAA,MACvD,OAAO;AACL,aAAK,MAAM,OAAO,OAAO,CAAC;AAAA,MAC5B;AAEA,WAAK,OAAO,IAAI,YAAY,MAAM,GAAG;AACrC,WAAK,OAAO,SAAS,OAAO,OAAO,CAAC;AAAA,IACtC;AAAA,EACF;AAAA,EAEA,OAAO,OAAO,MAAkB;AAC9B,QAAI,KAAK,OAAO;AACd,UAAI,QAAQ,KAAK,OAAO,SAAS,KAAK;AACtC,UAAI,KAAK,WAAW;AAClB,aAAK,SAAS,KAAK,MAAM,IAAI,CAAC,GAAG,MAAO,MAAM,QAAQ,EAAE,GAAG,GAAG,GAAG,KAAK,IAAI,CAAE,CAAC;AAAA,MAC/E,OAAO;AACL,aAAK,MAAM,KAAK,IAAI,EAAE,GAAG,KAAK,MAAM,KAAK,GAAG,GAAG,KAAK;AAAA,MACtD;AACA,UAAI,WAAW,KAAK,SAAS,KAAK,MAAM,KAAK,GAAG,KAAK;AACrD,eAAS,QAAQ,KAAK,OAAO,SAAS,SAAS,QAAQ;AACvD,eAAS,MAAM,MAAM;AACrB,WAAK,OAAO,SAAS,KAAK,IAAI;AAC9B,4CAAiB,UAA0B,KAAK;AAChD,iCAAM,UAA0B,KAAK;AAAA,IACvC;AAAA,EACF;AACF;AAAA,IAEA,2BAAU,gBAAgB,CAAC,SAAS,UAAU;AAC5C,UAAQ,mBAAmB,OAAuB,MAAM,SAAS,CAAC,CAAC;AACnE,SAAO;AACT,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../lib/dataset/index.ts"],
4
+ "sourcesContent": ["import { VnodeInterface, VnodeWithDom, createDomElement, directive, patch, updateAttributes } from \"valyrian.js\";\n\ninterface DataSetInterface<T> {\n data: T[];\n // eslint-disable-next-line no-unused-vars\n reset: (data: T[]) => void;\n // eslint-disable-next-line no-unused-vars\n add: (...data: T[]) => void;\n // eslint-disable-next-line no-unused-vars\n update: (index: number, data: T) => void;\n // eslint-disable-next-line no-unused-vars\n delete: (index: number) => void;\n}\ninterface DataSetHandler<T> {\n // eslint-disable-next-line no-unused-vars\n (data: T, index: number): VnodeInterface;\n}\n\nfunction deepFreeze(obj: any) {\n if (typeof obj === \"object\" && obj !== null && !Object.isFrozen(obj)) {\n if (Array.isArray(obj)) {\n for (let i = 0, l = obj.length; i < l; i++) {\n deepFreeze(obj[i]);\n }\n } else {\n let props = Reflect.ownKeys(obj);\n for (let i = 0, l = props.length; i < l; i++) {\n deepFreeze(obj[props[i]]);\n }\n }\n Object.freeze(obj);\n }\n\n return obj;\n}\n\nexport class DataSet<T> implements DataSetInterface<T> {\n #vnode: VnodeWithDom;\n // eslint-disable-next-line no-unused-vars\n #handler: DataSetHandler<T>;\n #data: T[] = [];\n #isFrozen = false;\n #dataProxy: T[] | null = null;\n\n get data() {\n if (this.#dataProxy === null) {\n throw new Error(\"DataSet is not initialized\");\n }\n\n return this.#dataProxy;\n }\n\n set data(data: T[]) {\n throw new Error(\"You need to use the reset method to set the data\");\n }\n\n #setData(data: T[]) {\n if (this.#isFrozen) {\n this.#data = deepFreeze([...data]);\n } else {\n this.#data = data;\n }\n this.#dataProxy = new Proxy(this.#data as T[], {\n set: () => {\n throw new Error(\"You need to use the add, update or delete methods to change the data\");\n },\n get(target, prop) {\n return target[prop];\n },\n deleteProperty: () => {\n throw new Error(\"You need to use the add, update or delete methods to change the data\");\n }\n }) as T[];\n }\n\n constructor(data: T[] = [], shouldFreeze = true) {\n this.#isFrozen = shouldFreeze;\n this.#setData(data);\n }\n\n setVnodeAndHandler(vnode: VnodeWithDom, handler: DataSetHandler<T>) {\n this.#vnode = vnode;\n this.#handler = handler;\n this.reset(this.#data);\n }\n\n reset(data: T[]) {\n this.#setData(data);\n let vnode = this.#vnode;\n let handler = this.#handler;\n\n if (data.length === 0) {\n vnode.children = [];\n vnode.dom.textContent = \"\";\n return;\n }\n\n let childrenLength = vnode.children.length;\n for (let i = 0, l = data.length; i < l; i++) {\n let child = handler(this.data[i], i);\n\n if (i < childrenLength) {\n let oldChild = vnode.children[i];\n child.isSVG = oldChild.isSVG;\n child.dom = oldChild.dom;\n updateAttributes(child as VnodeWithDom, oldChild);\n vnode.children[i] = child;\n patch(child as VnodeWithDom, oldChild);\n continue;\n }\n\n child.isSVG = vnode.isSVG || child.tag === \"svg\";\n child.dom = createDomElement(child.tag as string, child.isSVG);\n vnode.dom.appendChild(child.dom);\n updateAttributes(child as VnodeWithDom);\n vnode.children.push(child);\n patch(child as VnodeWithDom);\n }\n\n for (let i = data.length; i < childrenLength; i++) {\n vnode.dom.removeChild(vnode.children[i].dom);\n }\n vnode.children.length = data.length;\n }\n\n add(...data: T[]) {\n if (this.#data) {\n let oldLength = this.#data.length;\n if (this.#isFrozen) {\n this.#setData([...this.#data, ...data]);\n } else {\n this.#data.push(...data);\n }\n\n let vnode = this.#vnode;\n let handler = this.#handler;\n\n for (let i = 0, ii = oldLength, l = data.length; i < l; i++, ii++) {\n let child = handler(this.#data[i], ii);\n child.isSVG = vnode.isSVG || child.tag === \"svg\";\n child.dom = createDomElement(child.tag as string, child.isSVG);\n vnode.dom.appendChild(child.dom);\n updateAttributes(child as VnodeWithDom);\n vnode.children.push(child);\n patch(child as VnodeWithDom);\n }\n }\n }\n\n delete(index) {\n if (this.#data) {\n let child = this.#vnode.children[index];\n if (this.#isFrozen) {\n this.#setData(this.data.filter((_, i) => i !== index));\n } else {\n this.#data.splice(index, 1);\n }\n\n this.#vnode.dom.removeChild(child.dom);\n this.#vnode.children.splice(index, 1);\n }\n }\n\n update(index, item: Partial<T>) {\n if (this.#data) {\n let child = this.#vnode.children[index];\n if (this.#isFrozen) {\n this.#setData(this.#data.map((d, i) => (i === index ? { ...d, ...item } : d)));\n } else {\n this.#data[index] = { ...this.#data[index], ...item };\n }\n let newChild = this.#handler(this.#data[index], index);\n newChild.isSVG = this.#vnode.isSVG || newChild.tag === \"svg\";\n newChild.dom = child.dom;\n this.#vnode.children[index] = newChild;\n updateAttributes(newChild as VnodeWithDom, child);\n patch(newChild as VnodeWithDom, child);\n }\n }\n}\n\ndirective(\"with-dataset\", (dataSet, vnode) => {\n dataSet.setVnodeAndHandler(vnode as VnodeWithDom, vnode.children[0]);\n return false;\n});\n"],
5
+ "mappings": ";AAAA,SAAuC,kBAAkB,WAAW,OAAO,wBAAwB;AAkBnG,SAAS,WAAW,KAAU;AAC5B,MAAI,OAAO,QAAQ,YAAY,QAAQ,QAAQ,CAAC,OAAO,SAAS,GAAG,GAAG;AACpE,QAAI,MAAM,QAAQ,GAAG,GAAG;AACtB,eAAS,IAAI,GAAG,IAAI,IAAI,QAAQ,IAAI,GAAG,KAAK;AAC1C,mBAAW,IAAI,CAAC,CAAC;AAAA,MACnB;AAAA,IACF,OAAO;AACL,UAAI,QAAQ,QAAQ,QAAQ,GAAG;AAC/B,eAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,IAAI,GAAG,KAAK;AAC5C,mBAAW,IAAI,MAAM,CAAC,CAAC,CAAC;AAAA,MAC1B;AAAA,IACF;AACA,WAAO,OAAO,GAAG;AAAA,EACnB;AAEA,SAAO;AACT;AAEO,IAAM,UAAN,MAAgD;AAAA,EACrD;AAAA;AAAA,EAEA;AAAA,EACA,QAAa,CAAC;AAAA,EACd,YAAY;AAAA,EACZ,aAAyB;AAAA,EAEzB,IAAI,OAAO;AACT,QAAI,KAAK,eAAe,MAAM;AAC5B,YAAM,IAAI,MAAM,4BAA4B;AAAA,IAC9C;AAEA,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,KAAK,MAAW;AAClB,UAAM,IAAI,MAAM,kDAAkD;AAAA,EACpE;AAAA,EAEA,SAAS,MAAW;AAClB,QAAI,KAAK,WAAW;AAClB,WAAK,Q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rC,WAAK,OAAO,SAAS,OAAO,OAAO,CAAC;AAAA,IACtC;AAAA,EACF;AAAA,EAEA,OAAO,OAAO,MAAkB;AAC9B,QAAI,KAAK,OAAO;AACd,UAAI,QAAQ,KAAK,OAAO,SAAS,KAAK;AACtC,UAAI,KAAK,WAAW;AAClB,aAAK,SAAS,KAAK,MAAM,IAAI,CAAC,GAAG,MAAO,MAAM,QAAQ,EAAE,GAAG,GAAG,GAAG,KAAK,IAAI,CAAE,CAAC;AAAA,MAC/E,OAAO;AACL,aAAK,MAAM,KAAK,IAAI,EAAE,GAAG,KAAK,MAAM,KAAK,GAAG,GAAG,KAAK;AAAA,MACtD;AACA,UAAI,WAAW,KAAK,SAAS,KAAK,MAAM,KAAK,GAAG,KAAK;AACrD,eAAS,QAAQ,KAAK,OAAO,SAAS,SAAS,QAAQ;AACvD,eAAS,MAAM,MAAM;AACrB,WAAK,OAAO,SAAS,KAAK,IAAI;AAC9B,uBAAiB,UAA0B,KAAK;AAChD,YAAM,UAA0B,KAAK;AAAA,IACvC;AAAA,EACF;AACF;AAEA,UAAU,gBAAgB,CAAC,SAAS,UAAU;AAC5C,UAAQ,mBAAmB,OAAuB,MAAM,SAAS,CAAC,CAAC;AACnE,SAAO;AACT,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../lib/hooks/index.ts"],
4
+ "sourcesContent": ["import { Component, POJOComponent, VnodeWithDom, current, directive, onCleanup, onUnmount, update } from \"valyrian.js\";\n\ninterface CurrentOnPatch {\n component: Component | POJOComponent;\n vnode: VnodeWithDom;\n oldVnode: VnodeWithDom;\n}\n\nexport type Hook = any;\n\nexport interface HookDefinition {\n // eslint-disable-next-line no-unused-vars\n onCreate: (...args: any[]) => any;\n // eslint-disable-next-line no-unused-vars\n onUpdate?: (hook: Hook, ...args: any[]) => any;\n // eslint-disable-next-line no-unused-vars\n onCleanup?: (hook: Hook) => any;\n // eslint-disable-next-line no-unused-vars\n onRemove?: (hook: Hook) => any;\n // eslint-disable-next-line no-unused-vars\n returnValue?: (hook: Hook) => any;\n}\n\nexport interface CreateHook {\n // eslint-disable-next-line no-unused-vars\n (HookDefinition: HookDefinition): (...args: any[]) => any;\n}\n\nexport const createHook = function createHook({\n onCreate,\n onUpdate: onUpdateHook,\n onCleanup: onCleanupHook,\n onRemove,\n returnValue\n}: HookDefinition): Hook {\n return (...args: any[]) => {\n let { component, vnode } = current as CurrentOnPatch;\n\n let hook = null;\n\n if (vnode) {\n // Init the components array for the current vnode\n if (!vnode.components) {\n vnode.components = [];\n }\n\n if (vnode.components.indexOf(component) === -1) {\n vnode.hook_calls = -1;\n vnode.components.push(component);\n if (!component.hooks) {\n component.hooks = [];\n onUnmount(() => Reflect.deleteProperty(component, \"hooks\"));\n }\n }\n\n hook = component.hooks[++vnode.hook_calls];\n }\n\n // If the hook doesn't exist, create it\n if (!hook) {\n // create a new hook\n hook = onCreate(...args);\n\n if (vnode) {\n // Add the hook to the component\n component.hooks.push(hook);\n }\n\n // if we have a onRemove hook, add it to the onUnmount set\n if (onRemove) {\n // Add the hook to the onRemove array\n onUnmount(() => onRemove(hook));\n }\n } else {\n if (onUpdateHook) {\n onUpdateHook(hook, ...args);\n }\n }\n\n // If we have an onCleanup function, add it to the cleanup set\n if (onCleanupHook) {\n // Add the hook to the onCleanup set\n onCleanup(() => onCleanupHook(hook));\n }\n\n // If we have a returnValue function, call it and return the result instead of the hook\n if (returnValue) {\n return returnValue(hook);\n }\n\n // Return the hook\n return hook;\n };\n} as unknown as CreateHook;\n\nlet updateTimeout: any;\nfunction delayedUpdate() {\n clearTimeout(updateTimeout);\n updateTimeout = setTimeout(update);\n}\n\n// Use state hook\nexport const useState = createHook({\n onCreate: (value) => {\n function get() {\n return value;\n }\n get.value = value;\n get.toJSON = get.valueOf = get;\n get.toString = () => `${value}`;\n\n function set(newValue) {\n // Prevent default event if it exists\n if (current.event) {\n current.event.preventDefault();\n }\n\n if (value !== newValue) {\n value = newValue;\n get.value = newValue;\n delayedUpdate();\n }\n }\n\n return [get, set];\n }\n});\n\n// Effect hook\nexport const useEffect = createHook({\n onCreate: (effect: Function, changes: any[]) => {\n let hook: {\n effect: Function;\n prev: any[];\n onRemove?: Function;\n onCleanup?: Function;\n } = { effect, prev: [] };\n // on unmount\n if (changes === null) {\n hook.onRemove = effect;\n return hook;\n }\n\n // on create\n hook.prev = changes;\n hook.onCleanup = hook.effect();\n return hook;\n },\n onUpdate: (hook, effect, changes) => {\n // on update\n if (typeof changes === \"undefined\") {\n hook.prev = changes;\n if (typeof hook.onCleanup === \"function\") {\n hook.onCleanup();\n }\n hook.onCleanup = hook.effect();\n return;\n }\n\n // on update if there are changes\n if (Array.isArray(changes)) {\n for (let i = 0, l = changes.length; i < l; i++) {\n if (changes[i] !== hook.prev[i]) {\n hook.prev = changes;\n if (typeof hook.onCleanup === \"function\") {\n hook.onCleanup();\n }\n hook.onCleanup = hook.effect();\n return;\n }\n }\n }\n },\n onRemove: (hook) => {\n if (typeof hook.onCleanup === \"function\") {\n hook.onCleanup();\n }\n if (typeof hook.onRemove === \"function\") {\n hook.onRemove();\n }\n }\n});\n\nexport const useRef = createHook({\n onCreate: (initialValue) => {\n directive(\"ref\", (ref, vnode) => {\n ref.current = vnode.dom;\n });\n return { current: initialValue };\n }\n});\n\nexport const useCallback = createHook({\n onCreate: (callback, changes) => {\n callback();\n return { callback, changes };\n },\n onUpdate: (hook, callback, changes) => {\n for (let i = 0, l = changes.length; i < l; i++) {\n if (changes[i] !== hook.changes[i]) {\n hook.changes = changes;\n hook.callback();\n return;\n }\n }\n }\n});\n\nexport const useMemo = createHook({\n onCreate: (callback, changes) => {\n return { callback, changes, value: callback() };\n },\n onUpdate: (hook, callback, changes) => {\n for (let i = 0, l = changes.length; i < l; i++) {\n if (changes[i] !== hook.changes[i]) {\n hook.changes = changes;\n hook.value = callback();\n return;\n }\n }\n },\n returnValue: (hook) => {\n return hook.value;\n }\n});\n"],
5
+ "mappings":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,QAAI,OAAO,KAAK,aAAa,YAAY;AACvC,WAAK,SAAS;AAAA,IAChB;AAAA,EACF;AACF,CAAC;AAEM,IAAM,SAAS,WAAW;AAAA,EAC/B,UAAU,CAAC,iBAAiB;AAC1B,mCAAU,OAAO,CAAC,KAAK,UAAU;AAC/B,UAAI,UAAU,MAAM;AAAA,IACtB,CAAC;AACD,WAAO,EAAE,SAAS,aAAa;AAAA,EACjC;AACF,CAAC;AAEM,IAAM,cAAc,WAAW;AAAA,EACpC,UAAU,CAAC,UAAU,YAAY;AAC/B,aAAS;AACT,WAAO,EAAE,UAAU,QAAQ;AAAA,EAC7B;AAAA,EACA,UAAU,CAAC,MAAM,UAAU,YAAY;AACrC,aAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,IAAI,GAAG,KAAK;AAC9C,UAAI,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,GAAG;AAClC,aAAK,UAAU;AACf,aAAK,SAAS;AACd;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;AAEM,IAAM,UAAU,WAAW;AAAA,EAChC,UAAU,CAAC,UAAU,YAAY;AAC/B,WAAO,EAAE,UAAU,SAAS,OAAO,SAAS,EAAE;AAAA,EAChD;AAAA,EACA,UAAU,CAAC,MAAM,UAAU,YAAY;AACrC,aAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,IAAI,GAAG,KAAK;AAC9C,UAAI,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,GAAG;AAClC,aAAK,UAAU;AACf,aAAK,QAAQ,SAAS;AACtB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,aAAa,CAAC,SAAS;AACrB,WAAO,KAAK;AAAA,EACd;AACF,CAAC;",
6
+ "names": ["createHook"]
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../lib/hooks/index.ts"],
4
+ "sourcesContent": ["import { Component, POJOComponent, VnodeWithDom, current, directive, onCleanup, onUnmount, update } from \"valyrian.js\";\n\ninterface CurrentOnPatch {\n component: Component | POJOComponent;\n vnode: VnodeWithDom;\n oldVnode: VnodeWithDom;\n}\n\nexport type Hook = any;\n\nexport interface HookDefinition {\n // eslint-disable-next-line no-unused-vars\n onCreate: (...args: any[]) => any;\n // eslint-disable-next-line no-unused-vars\n onUpdate?: (hook: Hook, ...args: any[]) => any;\n // eslint-disable-next-line no-unused-vars\n onCleanup?: (hook: Hook) => any;\n // eslint-disable-next-line no-unused-vars\n onRemove?: (hook: Hook) => any;\n // eslint-disable-next-line no-unused-vars\n returnValue?: (hook: Hook) => any;\n}\n\nexport interface CreateHook {\n // eslint-disable-next-line no-unused-vars\n (HookDefinition: HookDefinition): (...args: any[]) => any;\n}\n\nexport const createHook = function createHook({\n onCreate,\n onUpdate: onUpdateHook,\n onCleanup: onCleanupHook,\n onRemove,\n returnValue\n}: HookDefinition): Hook {\n return (...args: any[]) => {\n let { component, vnode } = current as CurrentOnPatch;\n\n let hook = null;\n\n if (vnode) {\n // Init the components array for the current vnode\n if (!vnode.components) {\n vnode.components = [];\n }\n\n if (vnode.components.indexOf(component) === -1) {\n vnode.hook_calls = -1;\n vnode.components.push(component);\n if (!component.hooks) {\n component.hooks = [];\n onUnmount(() => Reflect.deleteProperty(component, \"hooks\"));\n }\n }\n\n hook = component.hooks[++vnode.hook_calls];\n }\n\n // If the hook doesn't exist, create it\n if (!hook) {\n // create a new hook\n hook = onCreate(...args);\n\n if (vnode) {\n // Add the hook to the component\n component.hooks.push(hook);\n }\n\n // if we have a onRemove hook, add it to the onUnmount set\n if (onRemove) {\n // Add the hook to the onRemove array\n onUnmount(() => onRemove(hook));\n }\n } else {\n if (onUpdateHook) {\n onUpdateHook(hook, ...args);\n }\n }\n\n // If we have an onCleanup function, add it to the cleanup set\n if (onCleanupHook) {\n // Add the hook to the onCleanup set\n onCleanup(() => onCleanupHook(hook));\n }\n\n // If we have a returnValue function, call it and return the result instead of the hook\n if (returnValue) {\n return returnValue(hook);\n }\n\n // Return the hook\n return hook;\n };\n} as unknown as CreateHook;\n\nlet updateTimeout: any;\nfunction delayedUpdate() {\n clearTimeout(updateTimeout);\n updateTimeout = setTimeout(update);\n}\n\n// Use state hook\nexport const useState = createHook({\n onCreate: (value) => {\n function get() {\n return value;\n }\n get.value = value;\n get.toJSON = get.valueOf = get;\n get.toString = () => `${value}`;\n\n function set(newValue) {\n // Prevent default event if it exists\n if (current.event) {\n current.event.preventDefault();\n }\n\n if (value !== newValue) {\n value = newValue;\n get.value = newValue;\n delayedUpdate();\n }\n }\n\n return [get, set];\n }\n});\n\n// Effect hook\nexport const useEffect = createHook({\n onCreate: (effect: Function, changes: any[]) => {\n let hook: {\n effect: Function;\n prev: any[];\n onRemove?: Function;\n onCleanup?: Function;\n } = { effect, prev: [] };\n // on unmount\n if (changes === null) {\n hook.onRemove = effect;\n return hook;\n }\n\n // on create\n hook.prev = changes;\n hook.onCleanup = hook.effect();\n return hook;\n },\n onUpdate: (hook, effect, changes) => {\n // on update\n if (typeof changes === \"undefined\") {\n hook.prev = changes;\n if (typeof hook.onCleanup === \"function\") {\n hook.onCleanup();\n }\n hook.onCleanup = hook.effect();\n return;\n }\n\n // on update if there are changes\n if (Array.isArray(changes)) {\n for (let i = 0, l = changes.length; i < l; i++) {\n if (changes[i] !== hook.prev[i]) {\n hook.prev = changes;\n if (typeof hook.onCleanup === \"function\") {\n hook.onCleanup();\n }\n hook.onCleanup = hook.effect();\n return;\n }\n }\n }\n },\n onRemove: (hook) => {\n if (typeof hook.onCleanup === \"function\") {\n hook.onCleanup();\n }\n if (typeof hook.onRemove === \"function\") {\n hook.onRemove();\n }\n }\n});\n\nexport const useRef = createHook({\n onCreate: (initialValue) => {\n directive(\"ref\", (ref, vnode) => {\n ref.current = vnode.dom;\n });\n return { current: initialValue };\n }\n});\n\nexport const useCallback = createHook({\n onCreate: (callback, changes) => {\n callback();\n return { callback, changes };\n },\n onUpdate: (hook, callback, changes) => {\n for (let i = 0, l = changes.length; i < l; i++) {\n if (changes[i] !== hook.changes[i]) {\n hook.changes = changes;\n hook.callback();\n return;\n }\n }\n }\n});\n\nexport const useMemo = createHook({\n onCreate: (callback, changes) => {\n return { callback, changes, value: callback() };\n },\n onUpdate: (hook, callback, changes) => {\n for (let i = 0, l = changes.length; i < l; i++) {\n if (changes[i] !== hook.changes[i]) {\n hook.changes = changes;\n hook.value = callback();\n return;\n }\n }\n },\n returnValue: (hook) => {\n return hook.value;\n }\n});\n"],
5
+ "mappings": ";AAAA,SAAiD,SAAS,WAAW,WAAW,WAAW,cAAc;AA4BlG,IAAM,aAAa,SAASA,YAAW;AAAA,EAC5C;AAAA,EACA,UAAU;AAAA,EACV,WAAW;AAAA,EACX;AAAA,EACA;AACF,GAAyB;AACvB,SAAO,IAAI,SAAgB;AACzB,QAAI,EAAE,WAAW,MAAM,IAAI;AAE3B,QAAI,OAAO;AAEX,QAAI,OAAO;AAET,UAAI,CAAC,MAAM,YAAY;AACrB,cAAM,aAAa,CAAC;AAAA,MACtB;AAEA,UAAI,MAAM,WAAW,QAAQ,SAAS,MAAM,IAAI;AAC9C,cAAM,aAAa;AACnB,cAAM,WAAW,KAAK,SAAS;AAC/B,YAAI,CAAC,UAAU,OAAO;AACpB,oBAAU,QAAQ,CAAC;AACnB,oBAAU,MAAM,QAAQ,eAAe,WAAW,OAAO,CAAC;AAAA,QAC5D;AAAA,MACF;AAEA,aAAO,UAAU,MAAM,EAAE,MAAM,UAAU;AAAA,IAC3C;AAGA,QAAI,CAAC,MAAM;AAET,aAAO,SAAS,GAAG,IAAI;AAEvB,UAAI,OAAO;AAET,kBAAU,MAAM,KAAK,IAAI;AAAA,MAC3B;AAGA,UAAI,UAAU;AAEZ,kBAAU,MAAM,SAAS,IAAI,CAAC;AAAA,MAChC;AAAA,IACF,OAAO;AACL,UAAI,cAAc;AAChB,qBAAa,MAAM,GAAG,IAAI;AAAA,MAC5B;AAAA,IACF;AAGA,QAAI,eAAe;AAEjB,gBAAU,MAAM,cAAc,IAAI,C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AA,EACF;AAAA,EACA,aAAa,CAAC,SAAS;AACrB,WAAO,KAAK;AAAA,EACd;AACF,CAAC;",
6
+ "names": ["createHook"]
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../lib/index.ts"],
4
+ "sourcesContent": ["/* eslint-disable no-use-before-define */\n/* eslint-disable indent */\n/* eslint-disable sonarjs/cognitive-complexity */\n/* eslint-disable complexity */\n\n// The VnodeProperties interface represents properties that can be passed to a virtual node.\nexport interface VnodeProperties {\n // A unique key for the virtual node, which can be a string or a number.\n // This is useful for optimizing updates in a list of nodes.\n key?: string | number;\n // A state object that is associated with the virtual node.\n state?: any;\n // An index signature that allows for any other properties to be added.\n [key: string | number | symbol]: any;\n}\n\n// The DomElement interface extends the Element interface with an index signature.\n// This allows for any additional properties to be added to DOM elements.\nexport interface DomElement extends Element {\n [key: string]: any;\n}\n\n// The VnodeInterface represents a virtual node. It has a number of optional fields,\n// including a tag, props, children, and a DOM element.\nexport interface VnodeInterface {\n // The constructor for the virtual node. It takes a tag, props, and children as arguments.\n // The tag can be a string, a component, or a POJO component.\n // eslint-disable-next-line no-unused-vars\n new (tag: string | Component | POJOComponent, props: VnodeProperties, children: Children): VnodeInterface;\n // The tag for the virtual node. It can be a string, a component, or a POJO component.\n tag: string | Component | POJOComponent;\n // The props for the virtual node.\n props: VnodeProperties;\n // The children for the virtual node.\n children: Children;\n // A boolean indicating whether the virtual node is an SVG element.\n isSVG?: boolean;\n // The DOM element that corresponds to the virtual node.\n dom?: DomElement;\n // A boolean indicating whether the virtual node has been processed in the keyed diffing algorithm.\n processed?: boolean;\n // An index signature that allows for any additional properties to be added to the virtual node.\n [key: string | number | symbol]: any;\n}\n\n// The VnodeWithDom interface represents a virtual node that has a DOM element associated with it.\nexport interface VnodeWithDom extends VnodeInterface {\n dom: DomElement;\n}\n\n// The Component interface represents a function that returns a virtual node or a list of virtual nodes.\n// It can also have additional properties.\nexport interface Component {\n // The function that returns a virtual node or a list of virtual nodes.\n // It can take props and children as arguments.\n // eslint-disable-next-line no-unused-vars\n (props?: VnodeProperties | null, ...children: any[]): VnodeInterface | Children | any;\n // An index signature that allows for any additional properties to be added to the component.\n [key: string]: any;\n}\n\n// The POJOComponent interface represents a \"plain old JavaScript object\" (POJO) component.\n// It has a view function that returns a virtual node or a list of virtual nodes,\n// as well as optional props and children.\n// It can be used also to identify class instance components.\nexport interface POJOComponent {\n // The view function that returns a virtual node or a list of virtual nodes.\n view: Component;\n // The props for the component.\n props?: VnodeProperties | null;\n // The children for the component.\n children?: any[];\n // An index signature that allows for any additional properties to be added to the POJO component.\n [key: string]: any;\n}\n\n// The VnodeComponentInterface represents a virtual node that has a component as its tag.\n// It has props and children, just like a regular virtual node.\nexport interface VnodeComponentInterface extends VnodeInterface {\n tag: Component | POJOComponent;\n props: VnodeProperties;\n children: Children;\n}\n\n// The Children interface represents a list of virtual nodes or other values.\nexport interface Children extends Array<VnodeInterface | VnodeComponentInterface | any> {}\n\n// The Directive interface represents a function that can be applied to a virtual node.\n// It receives the value, virtual node, and old virtual node as arguments, and can return a boolean value.\n// If only the virtual node is passed, it means its the on create phase for the v-node.\n// If the old virtual node is also passed, it means its the on update phase for the v-node.\nexport interface Directive {\n // eslint-disable-next-line no-unused-vars\n (value: any, vnode: VnodeWithDom, oldVnode?: VnodeWithDom): void | boolean;\n}\n\n// The Directives interface is a mapping of directive names to Directive functions.\nexport interface Directives {\n [key: string]: Directive;\n}\n\n// The ReservedProps interface is a mapping of reserved prop names to the value `true`.\n// These prop names cannot be used as custom prop names.\nexport interface ReservedProps {\n [key: string]: true;\n}\n\n// The Current interface represents the current component and virtual node that are being processed.\nexport interface Current {\n // The current component. It can be a component, a POJO component, or null.\n component: Component | POJOComponent | null;\n // The current virtual node. It must have a DOM element associated with it.\n vnode: VnodeWithDom | null;\n // The old virtual node. It must have a DOM element associated with it.\n oldVnode?: VnodeWithDom | null;\n // The current event. It can be an event or null.\n event: Event | null;\n}\n\n// The V function is the main function for creating virtual nodes.\n// It takes a tag or component, props, and children as arguments, and returns a virtual node.\nexport interface V {\n // eslint-disable-next-line no-unused-vars, no-use-before-define\n (tagOrComponent: string | Component | POJOComponent, props: VnodeProperties | null, ...children: Children):\n | VnodeInterface\n | VnodeComponentInterface;\n // eslint-disable-next-line no-unused-vars, no-use-before-define\n fragment(_: any, ...children: Children): Children;\n}\n// 'textTag' is a constant string that is used to represent text nodes in the virtual DOM.\nconst textTag = \"#text\";\n\n// 'isNodeJs' is a boolean that is true if the code is running in a Node.js environment and false otherwise.\n// It is determined by checking if the 'process' global object is defined and has a 'versions' property.\nexport let isNodeJs = Boolean(typeof process !== \"undefined\" && process.versions && process.versions.node);\n\n// 'createDomElement' is a function that creates a new DOM element with the specified tag name.\n// If 'isSVG' is true, it creates an SVG element instead of a regular DOM element.\nexport function createDomElement(tag: string, isSVG: boolean = false): DomElement {\n return isSVG ? document.createElementNS(\"http://www.w3.org/2000/svg\", tag) : document.createElement(tag);\n}\n\n// 'Vnode' is a class that represents a virtual DOM node.\n// It has three properties: 'tag', 'props', and 'children'.\n// 'Vnode' is exported as an object with a type of 'VnodeInterface'.\n// The 'as unknown as VnodeInterface' is used to tell TypeScript that the 'Vnode' function has the same type as 'VnodeInterface'.\nexport const Vnode = function Vnode(this: VnodeInterface, tag: string, props: VnodeProperties, children: Children) {\n // 'this' refers to the current instance of 'Vnode'.\n this.tag = tag;\n this.props = props;\n this.children = children;\n} as unknown as VnodeInterface;\n\n// 'isComponent' is a function that returns true if the given 'component' is a valid component and false otherwise.\n// A component is either a function or an object with a 'view' function.\nexport function isComponent(component): component is Component {\n return component && (typeof component === \"function\" || (typeof component === \"object\" && \"view\" in component));\n}\n\n// 'isVnode' is a function that returns true if the given 'object' is a 'Vnode' instance and false otherwise.\nexport const isVnode = (object?: unknown | VnodeInterface): object is VnodeInterface => {\n // Use the 'instanceof' operator to check if 'object' is an instance of 'Vnode'.\n return object instanceof Vnode;\n};\n\n// 'isVnodeComponent' is a function that returns true if the given 'object' is a 'Vnode' instance with a 'tag' property that is a valid component.\n// It returns false otherwise.\nexport const isVnodeComponent = (object?: unknown | VnodeComponentInterface): object is VnodeComponentInterface => {\n // Check if 'object' is a 'Vnode' instance and its 'tag' property is a valid component.\n return isVnode(object) && isComponent(object.tag);\n};\n\n// 'domToVnode' is a function that converts a DOM node to a 'Vnode' instance.\nexport function domToVnode(dom: any): VnodeWithDom {\n // If the child node is a text node, create a 'Vnode' instance with the 'textTag' constant as the 'tag' property.\n // Set the 'dom' property of the 'Vnode' instance to the child DOM node.\n // Push the 'Vnode' instance to the 'children' array.\n if (dom.nodeType === 3) {\n let vnode = new Vnode(textTag, {}, [dom.nodeValue]);\n vnode.dom = dom;\n return vnode as VnodeWithDom;\n }\n\n let children: VnodeWithDom[] = [];\n // Iterate through all child nodes of 'dom'.\n for (let i = 0, l = dom.childNodes.length; i < l; i++) {\n let childDom = dom.childNodes[i];\n // If the child node is an element node, recursively call 'domToVnode' to convert it to a 'Vnode' instance.\n // Push the 'Vnode' instance to the 'children' array.\n if (childDom.nodeType === 1 || childDom.nodeType === 3) {\n children.push(domToVnode(childDom));\n }\n }\n\n let props: VnodeProperties = {};\n // Iterate through all attributes of 'dom'.\n for (let i = 0, l = dom.attributes.length; i < l; i++) {\n let attr = dom.attributes[i];\n // Add the attribute to the 'props' object, using the attribute's name as the key and its value as the value.\n props[attr.nodeName] = attr.nodeValue;\n }\n\n // Create a new 'Vnode' instance with the 'tag' property set to the lowercase version of the DOM node's tag name.\n // Set the 'props' and 'children' properties to the 'props' and 'children' arrays respectively.\n // Set the 'dom' property of the 'Vnode' instance to the DOM node.\n let vnode = new Vnode(dom.tagName.toLowerCase(), props, children);\n vnode.dom = dom;\n return vnode as VnodeWithDom;\n}\n\n// This function takes in an HTML string and creates a virtual node representation of it\n// using the `domToVnode` function. It does this by creating a new `div` element, setting\n// its `innerHTML` to the provided HTML string, and then using `map` to iterate over the\n// `childNodes` of the `div` element, passing each one to `domToVnode` to create a virtual\n// node representation of it. The resulting array of virtual nodes is then returned.\nexport function trust(htmlString: string) {\n let div = createDomElement(\"div\");\n div.innerHTML = htmlString.trim();\n\n return [].map.call(div.childNodes, (item) => domToVnode(item));\n}\n\n/* ========================================================================== */\n/* Main Component implementation */\n/* ========================================================================== */\n\n// These variables are used to store the main component, the main virtual node, and whether\n// the main component is currently mounted.\nlet mainComponent: VnodeComponentInterface | null = null;\nlet mainVnode: VnodeWithDom | null = null;\nlet isMounted = false;\n\n// This object is used to store the current virtual node and component being rendered.\nexport const current: Current = {\n vnode: null,\n oldVnode: null,\n component: null,\n event: null\n};\n\n/* Reserved props ----------------------------------------------------------- */\n// This object is used to store the names of reserved props, which are props that are reserved\n// for special purposes and should not be used as regular component props.\nexport const reservedProps: Record<string, true> = {\n key: true,\n state: true,\n \"v-keep\": true,\n\n // Built in directives\n \"v-if\": true,\n \"v-unless\": true,\n \"v-for\": true,\n \"v-show\": true,\n \"v-class\": true,\n \"v-html\": true,\n \"v-model\": true,\n \"v-create\": true,\n \"v-update\": true,\n \"v-cleanup\": true\n};\n\n/* Mounting, Updating, Cleanup and Unmounting ------------------------------- */\n// These sets are used to store callbacks for various lifecycle events: mounting, updating,\n// cleaning up, and unmounting.\nconst onCleanupSet: Set<Function> = new Set();\nconst onMountSet: Set<Function> = new Set();\nconst onUpdateSet: Set<Function> = new Set();\nconst onUnmountSet: Set<Function> = new Set();\n\n// These functions allow users to register callbacks for the corresponding lifecycle events.\nexport function onMount(callback) {\n if (!isMounted) {\n onMountSet.add(callback);\n }\n}\n\nexport function onUpdate(callback) {\n onUpdateSet.add(callback);\n}\n\nexport function onCleanup(callback) {\n onCleanupSet.add(callback);\n}\n\nexport function onUnmount(callback) {\n if (!isMounted) {\n onUnmountSet.add(callback);\n }\n}\n\n// This function is used to call all the callbacks in a given set.\nfunction callSet(set) {\n for (let callback of set) {\n callback();\n }\n\n set.clear();\n}\n\n/* Event listener ----------------------------------------------------------- */\n\n// This object stores the names of event listeners that have been added\nconst eventListenerNames: Record<string, true> = {};\n\n// This function is called when an event occurs\nfunction eventListener(e: Event) {\n // Set the current event to the event that occurred so that it can be prevented if necessary\n current.event = e;\n\n // Convert the target of the event to a DOM element\n let dom = e.target as DomElement;\n\n // Create the name of the event listener by adding \"v-on\" to the event type\n let name = `v-on${e.type}`;\n\n // Keep going up the DOM tree until we find an element with an event listener\n // matching the event type\n while (dom) {\n if (dom[name]) {\n // Call the event listener function\n dom[name](e, dom);\n\n // If the default action of the event hasn't been prevented, update the DOM\n if (!e.defaultPrevented) {\n update();\n }\n return;\n }\n dom = dom.parentNode as DomElement;\n }\n\n current.event = null;\n}\n\n/* Directives --------------------------------------------------------------- */\n\n// This function creates a directive that hides an element based on a condition\nlet hideDirective = (test: boolean) => (bool: boolean, vnode: VnodeInterface, oldnode?: VnodeInterface) => {\n // If test is true, use the value of bool. Otherwise, use the opposite of bool.\n let value = test ? bool : !bool;\n\n // If the value is true, hide the element by replacing it with a text node\n if (value) {\n let newdom = document.createTextNode(\"\");\n if (oldnode && oldnode.dom && oldnode.dom.parentNode) {\n oldnode.dom.parentNode.replaceChild(newdom, oldnode.dom);\n }\n vnode.tag = \"#text\";\n vnode.children = [];\n vnode.props = {};\n vnode.dom = newdom as unknown as DomElement;\n return false;\n }\n};\n\n// This object stores all the available directives\nexport const directives: Directives = {\n // The \"v-if\" directive hides an element if the given condition is false\n \"v-if\": hideDirective(false),\n\n // The \"v-unless\" directive hides an element if the given condition is true\n \"v-unless\": hideDirective(true),\n\n // The \"v-for\" directive creates a loop and applies a callback function to each item in the loop\n \"v-for\": (set: unknown[], vnode: VnodeWithDom) => {\n let newChildren: VnodeInterface[] = [];\n let callback = vnode.children[0];\n for (let i = 0, l = set.length; i < l; i++) {\n newChildren.push(callback(set[i], i));\n }\n vnode.children = newChildren;\n },\n\n // The \"v-show\" directive shows or hides an element by setting the \"display\" style property\n \"v-show\": (bool: boolean, vnode: VnodeWithDom) => {\n (\n vnode.dom as unknown as {\n style: { display: string };\n }\n ).style.display = bool ? \"\" : \"none\";\n },\n\n // The \"v-class\" directive adds or removes class names from an element based on a condition\n \"v-class\": (classes: { [x: string]: boolean }, vnode: VnodeWithDom) => {\n // Loop through all the class names in the classes object\n for (let name in classes) {\n // Add or remove the class name from the element's class list based on the value in the classes object\n (vnode.dom as DomElement).classList.toggle(name, classes[name]);\n }\n },\n\n // The \"v-html\" directive sets the inner HTML of an element to the given HTML string\n \"v-html\": (html: string, vnode: VnodeWithDom) => {\n // Set the children of the vnode to a trusted version of the HTML string\n vnode.children = [trust(html)];\n },\n\n // The \"v-model\" directive binds the value of an input element to a model property\n \"v-model\": ([model, property, event]: any[], vnode: VnodeWithDom, oldVnode?: VnodeWithDom) => {\n let value;\n // This function updates the model property when the input element's value changes\n let handler = (e: Event) => (model[property] = (e.target as DomElement & Record<string, any>).value);\n if (vnode.tag === \"input\") {\n // If the element is an input, use the \"input\" event by default\n event = event || \"oninput\";\n // Depending on the type of input element, use a different handler function\n switch (vnode.props.type) {\n case \"checkbox\": {\n if (Array.isArray(model[property])) {\n // If the model property is an array, add or remove the value from the array when the checkbox is checked or unchecked\n handler = (e: Event) => {\n let val = (e.target as DomElement & Record<string, any>).value;\n let idx = model[property].indexOf(val);\n if (idx === -1) {\n model[property].push(val);\n } else {\n model[property].splice(idx, 1);\n }\n };\n // If the value is in the array, set the checkbox to be checked\n value = model[property].indexOf(vnode.dom.value) !== -1;\n } else if (\"value\" in vnode.props) {\n // If the input element has a \"value\" attribute, use it to determine the checked state\n handler = () => {\n if (model[property] === vnode.props.value) {\n model[property] = null;\n } else {\n model[property] = vnode.props.value;\n }\n };\n value = model[property] === vnode.props.value;\n } else {\n // If there is no \"value\" attribute, use a boolean value for the model property\n handler = () => (model[property] = !model[property]);\n value = model[property];\n }\n // Set the \"checked\" attribute on the input element\n // eslint-disable-next-line no-use-before-define\n sharedSetAttribute(\"checked\", value, vnode);\n break;\n }\n case \"radio\": {\n // If the element is a radio button, set the \"checked\" attribute based on the value of the model property\n // eslint-disable-next-line no-use-before-define\n sharedSetAttribute(\"checked\", model[property] === vnode.dom.value, vnode);\n break;\n }\n default: {\n // For all other input types, set the \"value\" attribute based on the value of the model property\n // eslint-disable-next-line no-use-before-define\n sharedSetAttribute(\"value\", model[property], vnode);\n }\n }\n } else if (vnode.tag === \"select\") {\n // If the element is a select element, use the \"click\" event by default\n event = event || \"onclick\";\n if (vnode.props.multiple) {\n // If the select element allows multiple selections, update the model property with an array of selected values\n handler = (e: Event & Record<string, any>) => {\n let val = (e.target as DomElement & Record<string, any>).value;\n if (e.ctrlKey) {\n // If the Ctrl key is pressed, add or remove the value from the array\n let idx = model[property].indexOf(val);\n if (idx === -1) {\n model[property].push(val);\n } else {\n model[property].splice(idx, 1);\n }\n } else {\n // If the Ctrl key is not pressed, set the model property to an array with the selected value\n model[property].splice(0, model[property].length);\n model[property].push(val);\n }\n };\n // Set the \"selected\" attribute on the options based on whether they are in the model property array\n vnode.children.forEach((child: VnodeInterface) => {\n if (child.tag === \"option\") {\n let value = \"value\" in child.props ? child.props.value : child.children.join(\"\").trim();\n child.props.selected = model[property].indexOf(value) !== -1;\n }\n });\n } else {\n // If the select element does not allow multiple selections, set the \"selected\" attribute on the options based on the value of the model property\n vnode.children.forEach((child: VnodeInterface) => {\n if (child.tag === \"option\") {\n let value = \"value\" in child.props ? child.props.value : child.children.join(\"\").trim();\n child.props.selected = value === model[property];\n }\n });\n }\n } else if (vnode.tag === \"textarea\") {\n // If the element is a textarea, use the \"input\" event by default\n event = event || \"oninput\";\n // Set the textarea's content to the value of the model property\n vnode.children = [model[property]];\n }\n\n // We assume that the prev handler if any will not be changed by the user across patchs\n let prevHandler = vnode.props[event];\n\n // Set the event handler on the element\n // eslint-disable-next-line no-use-before-define\n sharedSetAttribute(\n event,\n (e: Event) => {\n handler(e);\n\n // If the previous handler is defined, call it after the model has been updated\n if (prevHandler) {\n prevHandler(e);\n }\n },\n vnode,\n oldVnode\n );\n },\n\n // The \"v-create\" directive is called when a new virtual node is created.\n // The provided callback function is called with the new virtual node as an argument.\n // This directive is only called once per virtual node, when it is first created.\n // eslint-disable-next-line no-unused-vars\n \"v-create\": (callback: (vnode: VnodeWithDom) => void, vnode: VnodeWithDom, oldVnode?: VnodeWithDom) => {\n // If this is not an update, call the callback function with the new virtual node\n if (!oldVnode) {\n let cleanup = callback(vnode);\n\n // If the callback function returns a function, call it when the update is gonna be cleaned up\n if (typeof cleanup === \"function\") {\n onCleanup(cleanup);\n }\n }\n },\n\n // The \"v-update\" directive is called when an existing virtual node is updated.\n // The provided callback function is called with the new and old virtual nodes as arguments.\n // This directive is only called once per virtual node update.\n \"v-update\": (\n // eslint-disable-next-line no-unused-vars\n callback: (vnode: VnodeWithDom, oldVnode: VnodeWithDom) => void,\n vnode: VnodeWithDom,\n oldVnode?: VnodeWithDom\n ) => {\n // If this is an update, call the callback function with the new and old virtual nodes\n if (oldVnode) {\n let cleanup = callback(vnode, oldVnode);\n\n // If the callback function returns a function, call it when the update is gonna be cleaned up\n if (typeof cleanup === \"function\") {\n onCleanup(cleanup);\n }\n }\n },\n\n // The \"v-cleanup\" directive is called when the update is cleaned up.\n // The provided callback function is called with the old virtual node as an argument.\n // This directive is only called once per virtual node, when the update is cleaned up.\n \"v-cleanup\": (\n // eslint-disable-next-line no-unused-vars\n callback: (vnode: VnodeWithDom, oldVnode?: VnodeWithDom) => void,\n vnode: VnodeWithDom,\n oldVnode?: VnodeWithDom\n ) => {\n // Add the callback function to the list of cleanup functions to be called when the update is cleaned up\n onCleanup(() => callback(vnode, oldVnode));\n }\n};\n// Add a directive to the global directives object, with the key being the name\n// preceded by \"v-\". Also add the name to the global reservedProps object.\nexport function directive(name: string, directive: Directive) {\n let directiveName = `v-${name}`;\n directives[directiveName] = directive;\n reservedProps[directiveName] = true;\n}\n\n// Set an attribute on a virtual DOM node and update the actual DOM element.\n// If the attribute value is a function, add an event listener for the attribute\n// name to the DOM element represented by mainVnode.\n// If oldVnode is provided, compare the new attribute value to the old value\n// and only update the attribute if the values are different.\nfunction sharedSetAttribute(name: string, value: any, newVnode: VnodeWithDom, oldVnode?: VnodeWithDom): void | boolean {\n // If the attribute value is a function, add an event listener for the attribute\n // name to the DOM element represented by mainVnode.\n if (typeof value === \"function\") {\n // Only add the event listener if it hasn't been added yet.\n if (name in eventListenerNames === false) {\n (mainVnode as VnodeWithDom).dom.addEventListener(name.slice(2), eventListener);\n eventListenerNames[name] = true;\n }\n newVnode.dom[`v-${name}`] = value;\n return;\n }\n\n // If the attribute is present on the DOM element and newVnode is not an SVG,\n // update the attribute if the value has changed.\n if (name in newVnode.dom && newVnode.isSVG === false) {\n // eslint-disable-next-line eqeqeq\n if (newVnode.dom[name] != value) {\n newVnode.dom[name] = value;\n }\n return;\n }\n\n // If oldVnode is not provided or the attribute value has changed, update the\n // attribute on the DOM element.\n if (!oldVnode || value !== oldVnode.props[name]) {\n if (value === false) {\n newVnode.dom.removeAttribute(name);\n } else {\n newVnode.dom.setAttribute(name, value);\n }\n }\n}\n\n// Set an attribute on a virtual DOM node and update the actual DOM element.\n// Skip the attribute if it is in the reservedProps object.\nexport function setAttribute(name: string, value: any, newVnode: VnodeWithDom, oldVnode?: VnodeWithDom): void {\n if (name in reservedProps) {\n return;\n }\n newVnode.props[name] = value;\n sharedSetAttribute(name, value, newVnode as VnodeWithDom, oldVnode);\n}\n\n// Update the attributes on a virtual DOM node. If oldVnode is provided, remove\n// attributes from the DOM element that are not present in newVnode.props but are\n// present in oldVnode.props. Then, iterate over the attributes in newVnode.props\n// and update the DOM element with the attributes using the sharedSetAttribute\n// function. If an attribute is in the reservedProps object and has a corresponding\n// directive in the directives object, call the directive with the attribute value\n// and the two virtual DOM nodes as arguments. If the directive returns false, exit\n// the loop.\nexport function updateAttributes(newVnode: VnodeWithDom, oldVnode?: VnodeWithDom): void {\n // If oldVnode is provided, remove attributes from the DOM element that are not\n // present in newVnode.props but are present in oldVnode.props.\n if (oldVnode) {\n for (let name in oldVnode.props) {\n if (name in newVnode.props === false && name in eventListenerNames === false && name in reservedProps === false) {\n if (name in newVnode.dom && newVnode.isSVG === false) {\n newVnode.dom[name] = null;\n } else {\n newVnode.dom.removeAttribute(name);\n }\n }\n }\n }\n\n // Iterate over the attributes in newVnode.props and update the DOM element with\n // the attributes using the sharedSetAttribute function.\n for (let name in newVnode.props) {\n if (name in reservedProps) {\n // If there is a directive for the attribute, call it with the attribute value\n // and the two virtual DOM nodes as arguments. If the directive returns false,\n // exit the loop.\n if (name in directives && directives[name](newVnode.props[name], newVnode, oldVnode) === false) {\n break;\n }\n continue;\n }\n sharedSetAttribute(name, newVnode.props[name], newVnode, oldVnode);\n }\n}\n\n/* patch ------------------------------------------------------------------- */\n\n// Patch a DOM node with a new VNode tree\nexport function patch(newVnode: VnodeWithDom, oldVnode?: VnodeWithDom): void {\n // If the new tree has no children, set the text content of the parent DOM element to an empty string\n if (newVnode.children.length === 0) {\n newVnode.dom.textContent = \"\";\n return;\n }\n\n // Get the children of the new and old virtual DOM nodes\n let newTree = newVnode.children;\n let oldTree = oldVnode?.children || [];\n // Get the length of the old tree\n let oldTreeLength = oldTree.length;\n\n // If the old tree has children and the first child of the new tree is a VNode with a \"key\"\n // attribute and the first child of the old tree is a VNode with a \"key\" attribute, update\n // the DOM element in place by comparing the keys of the nodes in the trees.\n if (oldTreeLength && newTree[0] instanceof Vnode && \"key\" in newTree[0].props && \"key\" in oldTree[0].props) {\n // Get the lengths of the new and old trees\n let newTreeLength = newTree.length;\n\n // Create an object that maps keys to indices in the old tree\n let oldKeyedList: { [key: string]: number } = {};\n for (let i = 0; i < oldTreeLength; i++) {\n oldKeyedList[oldTree[i].props.key] = i;\n }\n\n // Create an object that maps keys to indices in the new tree\n let newKeyedList: { [key: string]: number } = {};\n for (let i = 0; i < newTreeLength; i++) {\n newKeyedList[newTree[i].props.key] = i;\n }\n\n // Iterate over the new tree\n for (let i = 0; i < newTreeLength; i++) {\n // Get the current new child and the corresponding old child\n let newChild = newTree[i];\n let oldChild = oldTree[oldKeyedList[newChild.props.key]];\n // Initialize a flag to determine whether to patch the child\n let shouldPatch = true;\n\n // If the old child exists, update the DOM element of the new child to match the old child's DOM element\n if (oldChild) {\n newChild.dom = oldChild.dom;\n // If the new and old children have the same \"v-keep\" attribute value, update the children of the new child to match the old child's children\n if (\"v-keep\" in newChild.props && newChild.props[\"v-keep\"] === oldChild.props[\"v-keep\"]) {\n newChild.children = oldChild.children;\n // Set the shouldPatch flag to false\n shouldPatch = false;\n } else {\n updateAttributes(newChild, oldChild);\n }\n\n // If the old child does not exist, create a new DOM element for the new child and update its attributes\n } else {\n newChild.dom = createDomElement(newChild.tag, newChild.isSVG);\n updateAttributes(newChild);\n }\n\n // If the new child's DOM element is not the i-th child of the parent DOM element, insert it\n if (!newVnode.dom.childNodes[i]) {\n newVnode.dom.appendChild(newChild.dom);\n\n // If the new child's DOM element is not the same as the i-th child of the parent DOM element, replace the i-th child with the new child's DOM element\n } else if (newVnode.dom.childNodes[i] !== newChild.dom) {\n newVnode.dom.replaceChild(newChild.dom, newVnode.dom.childNodes[i]);\n }\n\n // If the shouldPatch flag is true, recursively call the patch function on the new child, passing in the old child as the second argument\n shouldPatch && patch(newChild, oldChild);\n }\n\n // For the rest of the children, we should remove them from the DOM\n for (let i = newTreeLength; i < oldTreeLength; i++) {\n // If the i-th child of the old tree does not have a corresponding key in the new tree, remove its DOM element from the parent DOM element\n if (!newKeyedList[oldTree[i].props.key]) {\n oldTree[i].dom.parentNode && oldTree[i].dom.parentNode.removeChild(oldTree[i].dom);\n }\n }\n return;\n }\n\n // If the new tree has no children, set the text content of the parent DOM element to an empty string\n if (newTree.length === 0) {\n newVnode.dom.textContent = \"\";\n return;\n }\n\n // Set the global current object to the new and old virtual DOM nodes\n current.vnode = newVnode;\n current.oldVnode = oldVnode;\n\n // Flatten the new tree\n // Take into account that is necessary to flatten the tree before the patch process\n // to let the hooks and signals work properly\n for (let i = 0; i < newTree.length; i++) {\n let newChild = newTree[i];\n\n // If the new child is a Vnode and is not a text node\n if (newChild instanceof Vnode) {\n // If the tag of the new child is not a string, it is a component\n if (typeof newChild.tag !== \"string\") {\n // Set the current component to the tag of the new child\n current.component = newChild.tag;\n // Replace the new child with the result of calling its view or bind method, passing in the props and children as arguments\n newTree.splice(\n i--,\n 1,\n (\"view\" in newChild.tag ? newChild.tag.view.bind(newChild.tag) : newChild.tag.bind(newChild.tag))(\n newChild.props,\n ...newChild.children\n )\n );\n }\n\n continue;\n }\n\n // If the new child is an array, flatten it and continue the loop\n if (Array.isArray(newChild)) {\n newTree.splice(i--, 1, ...newChild);\n continue;\n }\n\n // If the new child is null or undefined, remove it from the new tree and continue the loop\n if (newChild === null || newChild === undefined) {\n newTree.splice(i--, 1);\n continue;\n }\n\n // If the new child is a Vnode, set the text of the Vnode to the text content of its dom property\n newTree[i] = new Vnode(textTag, {}, [newChild]);\n }\n\n // Patch the the old tree\n for (let i = 0; i < newTree.length; i++) {\n let newChild = newTree[i];\n\n if (newChild.tag === textTag) {\n // If no old child exists at the same index\n if (i >= oldTreeLength) {\n // Create a new text node for the new child\n newChild.dom = document.createTextNode(newChild.children[0]);\n // Append the new text node to the dom\n newVnode.dom.appendChild(newChild.dom);\n continue;\n }\n\n // If there is an old child at the same index\n let oldChild = oldTree[i];\n\n // If the old child is not a text node\n if (oldChild.tag !== textTag) {\n // Create a new text node for the new child\n newChild.dom = document.createTextNode(newChild.children[0]);\n // Replace the old child in the dom with the new text node\n newVnode.dom.replaceChild(newChild.dom, oldChild.dom);\n continue;\n }\n\n // If the old child is a text node\n // Set the dom property of the text Vnode to the dom property of the old child\n newChild.dom = oldChild.dom;\n // If the text content of the old child is different from the new child, update the text content of the old child\n // eslint-disable-next-line eqeqeq\n if (newChild.children[0] != oldChild.dom.textContent) {\n oldChild.dom.textContent = newChild.children[0];\n }\n continue;\n }\n\n // If the new child is not a text node\n // Set the isSVG flag for the new child if it is an SVG element or if the parent is an SVG element\n newChild.isSVG = newVnode.isSVG || newChild.tag === \"svg\";\n\n // If there is no old child at the same index\n if (i >= oldTreeLength) {\n // Create a new dom element for the new child\n newChild.dom = createDomElement(newChild.tag as string, newChild.isSVG);\n // Update the attributes of the new child\n updateAttributes(newChild as VnodeWithDom);\n // Append the new child to the dom\n newVnode.dom.appendChild(newChild.dom);\n // Recursively patch the new child\n patch(newChild as VnodeWithDom);\n continue;\n }\n\n // If there is an old child at the same index\n let oldChild = oldTree[i];\n\n // If the tag of the new child is different from the tag of the old child\n if (newChild.tag !== oldChild.tag) {\n // Create a new dom element for the new child\n newChild.dom = createDomElement(newChild.tag as string, newChild.isSVG);\n // Update the attributes of the new child\n updateAttributes(newChild as VnodeWithDom);\n // Replace the old child in the dom with the new child\n newVnode.dom.replaceChild(newChild.dom, oldChild.dom);\n // Recursively patch the new child\n patch(newChild as VnodeWithDom);\n continue;\n }\n\n // If the tag of the new child is the same as the tag of the old child\n // Set the dom property of the new child to the dom property of the old child\n newChild.dom = oldChild.dom;\n // If the v-keep prop is the same for both the new and old child, set the children of the new child to the children of the old child\n if (\"v-keep\" in newChild.props && newChild.props[\"v-keep\"] === oldChild.props[\"v-keep\"]) {\n newChild.children = oldChild.children;\n continue;\n }\n\n // Update the attributes of the new child based on the old child\n updateAttributes(newChild as VnodeWithDom, oldChild);\n // Recursively patch the new and old children\n patch(newChild as VnodeWithDom, oldChild);\n }\n\n // Remove any old children that are no longer present in the new tree\n for (let i = newTree.length; i < oldTreeLength; i++) {\n newVnode.dom.removeChild(oldTree[i].dom);\n }\n}\n\n// Update the main Vnode\nexport function update(): void | string {\n // If the main Vnode exists\n if (mainVnode) {\n // Call any cleanup functions that are registered with the onCleanupSet set\n callSet(onCleanupSet);\n // Store a reference to the old main Vnode\n let oldMainVnode = mainVnode;\n // Create a new main Vnode with the main component as its only child\n mainVnode = new Vnode(oldMainVnode.tag, oldMainVnode.props, [mainComponent]) as VnodeWithDom;\n mainVnode.dom = oldMainVnode.dom;\n mainVnode.isSVG = oldMainVnode.isSVG;\n\n // Recursively patch the new and old main Vnodes\n patch(mainVnode, oldMainVnode);\n\n // Call any update or mount functions that are registered with the onUpdateSet or onMountSet set\n callSet(isMounted ? onUpdateSet : onMountSet);\n\n // Set the isMounted flag to true\n isMounted = true;\n\n // Reset the current vnode, oldVnode, and component properties\n current.vnode = null;\n current.oldVnode = null;\n current.component = null;\n\n // If the code is running in a Node.js environment, return the inner HTML of the main Vnode's dom element\n if (isNodeJs) {\n return mainVnode.dom.innerHTML;\n }\n }\n}\n\n// Update custom Vnode\n// It is assumed that a first mount has already occurred, so,\n// the oldVnode is not null and the dom property of the oldVnode is not null\n// You need to set the dom property of the newVnode to the dom property of the oldVnode\n// The same with the isSVG property\n// Prefer this function over patch to allow for cleanup, onUpdate and onMount sets to be called\nexport function updateVnode(vnode: VnodeWithDom, oldVnode: VnodeWithDom): string | void {\n // Call any cleanup functions that are registered with the onCleanupSet set\n callSet(onCleanupSet);\n\n // Recursively patch the new and old main Vnodes\n patch(vnode, oldVnode);\n\n // Set the oldVnode's tag, props, children, dom, and isSVG properties to the newVnode's tag, props, children, dom, and isSVG properties\n // This is necessary to allow for the oldVnode to be used as the newVnode in the next update with the normal update function\n oldVnode.tag = vnode.tag;\n oldVnode.props = { ...vnode.props };\n oldVnode.children = [...vnode.children];\n oldVnode.dom = vnode.dom;\n oldVnode.isSVG = vnode.isSVG;\n\n // Call any update or mount functions that are registered with the onUpdateSet or onMountSet set\n callSet(isMounted ? onUpdateSet : onMountSet);\n\n // Set the isMounted flag to true\n isMounted = true;\n\n // Reset the current vnode, oldVnode, and component properties\n current.vnode = null;\n current.oldVnode = null;\n current.component = null;\n\n if (isNodeJs) {\n return vnode.dom.innerHTML;\n }\n}\n\n// Unmount the main Vnode\nexport function unmount() {\n // If the main Vnode exists\n if (mainVnode) {\n // Set the main component to a null Vnode\n mainComponent = new Vnode(() => null, {}, []) as VnodeComponentInterface;\n // Update the main Vnode\n let result = update();\n // Call any unmount functions that are registered with the onUnmountSet set\n callSet(onUnmountSet);\n\n // Remove any event listeners that were added to the main Vnode's dom element\n for (let name in eventListenerNames) {\n mainVnode.dom.removeEventListener(name.slice(2).toLowerCase(), eventListener);\n Reflect.deleteProperty(eventListenerNames, name);\n }\n\n // Reset the main component and main Vnode\n mainComponent = null;\n mainVnode = null;\n // Set the isMounted flag to false\n isMounted = false;\n // Reset the current vnode, oldVnode, and component properties\n current.vnode = null;\n current.oldVnode = null;\n current.component = null;\n // Return the result of updating the main Vnode\n return result;\n }\n}\n// This function takes in a DOM element or a DOM element selector and a component to be mounted on it.\nexport function mount(dom, component) {\n // Check if the 'dom' argument is a string. If it is, select the first element that matches the given selector.\n // Otherwise, use the 'dom' argument as the container.\n let container =\n typeof dom === \"string\"\n ? isNodeJs\n ? createDomElement(dom, dom === \"svg\")\n : document.querySelectorAll(dom)[0]\n : dom;\n\n // Check if the 'component' argument is a Vnode component or a regular component.\n // If it's a regular component, create a new Vnode component using the 'component' argument as the tag.\n // If it's not a component at all, create a new Vnode component with the 'component' argument as the rendering function.\n let vnodeComponent = isVnodeComponent(component)\n ? component\n : isComponent(component)\n ? new Vnode(component, {}, [])\n : new Vnode(() => component, {}, []);\n\n // If a main component already exists and it's not the same as the current 'vnodeComponent', unmount it.\n if (mainComponent && mainComponent.tag !== vnodeComponent.tag) {\n unmount();\n }\n\n // Set the 'vnodeComponent' as the main component.\n mainComponent = vnodeComponent as VnodeComponentInterface;\n // Convert the container element to a Vnode.\n mainVnode = domToVnode(container);\n // Update the DOM with the new component.\n return update();\n}\n\n// This is a utility function for creating Vnode objects.\n// It takes in a tag or component, and optional props and children arguments.\nexport const v: V = (tagOrComponent, props = {}, ...children) => {\n // Return a new Vnode object using the given arguments.\n return new Vnode(tagOrComponent, props || {}, children);\n};\n\n// This utility function creates a fragment Vnode.\n// It takes in a placeholder and the children arguments, returns only the children.\nv.fragment = (_: VnodeProperties, ...children: Children) => children;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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ACT;AACF;AAEO,SAAS,MAAM,KAAK,WAAW;AAGpC,MAAI,YACF,OAAO,QAAQ,WACX,WACE,iBAAiB,KAAK,QAAQ,KAAK,IACnC,SAAS,iBAAiB,GAAG,EAAE,CAAC,IAClC;AAKN,MAAI,iBAAiB,iBAAiB,SAAS,IAC3C,YACA,YAAY,SAAS,IACrB,IAAI,MAAM,WAAW,CAAC,GAAG,CAAC,CAAC,IAC3B,IAAI,MAAM,MAAM,WAAW,CAAC,GAAG,CAAC,CAAC;AAGrC,MAAI,iBAAiB,cAAc,QAAQ,eAAe,KAAK;AAC7D,YAAQ;AAAA,EACV;AAGA,kBAAgB;AAEhB,cAAY,WAAW,SAAS;AAEhC,SAAO,OAAO;AAChB;AAIO,IAAM,IAAO,CAAC,gBAAgB,QAAQ,CAAC,MAAM,aAAa;AAE/D,SAAO,IAAI,MAAM,gBAAgB,SAAS,CAAC,GAAG,QAAQ;AACxD;AAIA,EAAE,WAAW,CAAC,MAAuB,aAAuB;",
6
+ "names": ["Vnode", "vnode", "value", "directive", "oldChild"]
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../lib/index.ts"],
4
+ "sourcesContent": ["/* eslint-disable no-use-before-define */\n/* eslint-disable indent */\n/* eslint-disable sonarjs/cognitive-complexity */\n/* eslint-disable complexity */\n\n// The VnodeProperties interface represents properties that can be passed to a virtual node.\nexport interface VnodeProperties {\n // A unique key for the virtual node, which can be a string or a number.\n // This is useful for optimizing updates in a list of nodes.\n key?: string | number;\n // A state object that is associated with the virtual node.\n state?: any;\n // An index signature that allows for any other properties to be added.\n [key: string | number | symbol]: any;\n}\n\n// The DomElement interface extends the Element interface with an index signature.\n// This allows for any additional properties to be added to DOM elements.\nexport interface DomElement extends Element {\n [key: string]: any;\n}\n\n// The VnodeInterface represents a virtual node. It has a number of optional fields,\n// including a tag, props, children, and a DOM element.\nexport interface VnodeInterface {\n // The constructor for the virtual node. It takes a tag, props, and children as arguments.\n // The tag can be a string, a component, or a POJO component.\n // eslint-disable-next-line no-unused-vars\n new (tag: string | Component | POJOComponent, props: VnodeProperties, children: Children): VnodeInterface;\n // The tag for the virtual node. It can be a string, a component, or a POJO component.\n tag: string | Component | POJOComponent;\n // The props for the virtual node.\n props: VnodeProperties;\n // The children for the virtual node.\n children: Children;\n // A boolean indicating whether the virtual node is an SVG element.\n isSVG?: boolean;\n // The DOM element that corresponds to the virtual node.\n dom?: DomElement;\n // A boolean indicating whether the virtual node has been processed in the keyed diffing algorithm.\n processed?: boolean;\n // An index signature that allows for any additional properties to be added to the virtual node.\n [key: string | number | symbol]: any;\n}\n\n// The VnodeWithDom interface represents a virtual node that has a DOM element associated with it.\nexport interface VnodeWithDom extends VnodeInterface {\n dom: DomElement;\n}\n\n// The Component interface represents a function that returns a virtual node or a list of virtual nodes.\n// It can also have additional properties.\nexport interface Component {\n // The function that returns a virtual node or a list of virtual nodes.\n // It can take props and children as arguments.\n // eslint-disable-next-line no-unused-vars\n (props?: VnodeProperties | null, ...children: any[]): VnodeInterface | Children | any;\n // An index signature that allows for any additional properties to be added to the component.\n [key: string]: any;\n}\n\n// The POJOComponent interface represents a \"plain old JavaScript object\" (POJO) component.\n// It has a view function that returns a virtual node or a list of virtual nodes,\n// as well as optional props and children.\n// It can be used also to identify class instance components.\nexport interface POJOComponent {\n // The view function that returns a virtual node or a list of virtual nodes.\n view: Component;\n // The props for the component.\n props?: VnodeProperties | null;\n // The children for the component.\n children?: any[];\n // An index signature that allows for any additional properties to be added to the POJO component.\n [key: string]: any;\n}\n\n// The VnodeComponentInterface represents a virtual node that has a component as its tag.\n// It has props and children, just like a regular virtual node.\nexport interface VnodeComponentInterface extends VnodeInterface {\n tag: Component | POJOComponent;\n props: VnodeProperties;\n children: Children;\n}\n\n// The Children interface represents a list of virtual nodes or other values.\nexport interface Children extends Array<VnodeInterface | VnodeComponentInterface | any> {}\n\n// The Directive interface represents a function that can be applied to a virtual node.\n// It receives the value, virtual node, and old virtual node as arguments, and can return a boolean value.\n// If only the virtual node is passed, it means its the on create phase for the v-node.\n// If the old virtual node is also passed, it means its the on update phase for the v-node.\nexport interface Directive {\n // eslint-disable-next-line no-unused-vars\n (value: any, vnode: VnodeWithDom, oldVnode?: VnodeWithDom): void | boolean;\n}\n\n// The Directives interface is a mapping of directive names to Directive functions.\nexport interface Directives {\n [key: string]: Directive;\n}\n\n// The ReservedProps interface is a mapping of reserved prop names to the value `true`.\n// These prop names cannot be used as custom prop names.\nexport interface ReservedProps {\n [key: string]: true;\n}\n\n// The Current interface represents the current component and virtual node that are being processed.\nexport interface Current {\n // The current component. It can be a component, a POJO component, or null.\n component: Component | POJOComponent | null;\n // The current virtual node. It must have a DOM element associated with it.\n vnode: VnodeWithDom | null;\n // The old virtual node. It must have a DOM element associated with it.\n oldVnode?: VnodeWithDom | null;\n // The current event. It can be an event or null.\n event: Event | null;\n}\n\n// The V function is the main function for creating virtual nodes.\n// It takes a tag or component, props, and children as arguments, and returns a virtual node.\nexport interface V {\n // eslint-disable-next-line no-unused-vars, no-use-before-define\n (tagOrComponent: string | Component | POJOComponent, props: VnodeProperties | null, ...children: Children):\n | VnodeInterface\n | VnodeComponentInterface;\n // eslint-disable-next-line no-unused-vars, no-use-before-define\n fragment(_: any, ...children: Children): Children;\n}\n// 'textTag' is a constant string that is used to represent text nodes in the virtual DOM.\nconst textTag = \"#text\";\n\n// 'isNodeJs' is a boolean that is true if the code is running in a Node.js environment and false otherwise.\n// It is determined by checking if the 'process' global object is defined and has a 'versions' property.\nexport let isNodeJs = Boolean(typeof process !== \"undefined\" && process.versions && process.versions.node);\n\n// 'createDomElement' is a function that creates a new DOM element with the specified tag name.\n// If 'isSVG' is true, it creates an SVG element instead of a regular DOM element.\nexport function createDomElement(tag: string, isSVG: boolean = false): DomElement {\n return isSVG ? document.createElementNS(\"http://www.w3.org/2000/svg\", tag) : document.createElement(tag);\n}\n\n// 'Vnode' is a class that represents a virtual DOM node.\n// It has three properties: 'tag', 'props', and 'children'.\n// 'Vnode' is exported as an object with a type of 'VnodeInterface'.\n// The 'as unknown as VnodeInterface' is used to tell TypeScript that the 'Vnode' function has the same type as 'VnodeInterface'.\nexport const Vnode = function Vnode(this: VnodeInterface, tag: string, props: VnodeProperties, children: Children) {\n // 'this' refers to the current instance of 'Vnode'.\n this.tag = tag;\n this.props = props;\n this.children = children;\n} as unknown as VnodeInterface;\n\n// 'isComponent' is a function that returns true if the given 'component' is a valid component and false otherwise.\n// A component is either a function or an object with a 'view' function.\nexport function isComponent(component): component is Component {\n return component && (typeof component === \"function\" || (typeof component === \"object\" && \"view\" in component));\n}\n\n// 'isVnode' is a function that returns true if the given 'object' is a 'Vnode' instance and false otherwise.\nexport const isVnode = (object?: unknown | VnodeInterface): object is VnodeInterface => {\n // Use the 'instanceof' operator to check if 'object' is an instance of 'Vnode'.\n return object instanceof Vnode;\n};\n\n// 'isVnodeComponent' is a function that returns true if the given 'object' is a 'Vnode' instance with a 'tag' property that is a valid component.\n// It returns false otherwise.\nexport const isVnodeComponent = (object?: unknown | VnodeComponentInterface): object is VnodeComponentInterface => {\n // Check if 'object' is a 'Vnode' instance and its 'tag' property is a valid component.\n return isVnode(object) && isComponent(object.tag);\n};\n\n// 'domToVnode' is a function that converts a DOM node to a 'Vnode' instance.\nexport function domToVnode(dom: any): VnodeWithDom {\n // If the child node is a text node, create a 'Vnode' instance with the 'textTag' constant as the 'tag' property.\n // Set the 'dom' property of the 'Vnode' instance to the child DOM node.\n // Push the 'Vnode' instance to the 'children' array.\n if (dom.nodeType === 3) {\n let vnode = new Vnode(textTag, {}, [dom.nodeValue]);\n vnode.dom = dom;\n return vnode as VnodeWithDom;\n }\n\n let children: VnodeWithDom[] = [];\n // Iterate through all child nodes of 'dom'.\n for (let i = 0, l = dom.childNodes.length; i < l; i++) {\n let childDom = dom.childNodes[i];\n // If the child node is an element node, recursively call 'domToVnode' to convert it to a 'Vnode' instance.\n // Push the 'Vnode' instance to the 'children' array.\n if (childDom.nodeType === 1 || childDom.nodeType === 3) {\n children.push(domToVnode(childDom));\n }\n }\n\n let props: VnodeProperties = {};\n // Iterate through all attributes of 'dom'.\n for (let i = 0, l = dom.attributes.length; i < l; i++) {\n let attr = dom.attributes[i];\n // Add the attribute to the 'props' object, using the attribute's name as the key and its value as the value.\n props[attr.nodeName] = attr.nodeValue;\n }\n\n // Create a new 'Vnode' instance with the 'tag' property set to the lowercase version of the DOM node's tag name.\n // Set the 'props' and 'children' properties to the 'props' and 'children' arrays respectively.\n // Set the 'dom' property of the 'Vnode' instance to the DOM node.\n let vnode = new Vnode(dom.tagName.toLowerCase(), props, children);\n vnode.dom = dom;\n return vnode as VnodeWithDom;\n}\n\n// This function takes in an HTML string and creates a virtual node representation of it\n// using the `domToVnode` function. It does this by creating a new `div` element, setting\n// its `innerHTML` to the provided HTML string, and then using `map` to iterate over the\n// `childNodes` of the `div` element, passing each one to `domToVnode` to create a virtual\n// node representation of it. The resulting array of virtual nodes is then returned.\nexport function trust(htmlString: string) {\n let div = createDomElement(\"div\");\n div.innerHTML = htmlString.trim();\n\n return [].map.call(div.childNodes, (item) => domToVnode(item));\n}\n\n/* ========================================================================== */\n/* Main Component implementation */\n/* ========================================================================== */\n\n// These variables are used to store the main component, the main virtual node, and whether\n// the main component is currently mounted.\nlet mainComponent: VnodeComponentInterface | null = null;\nlet mainVnode: VnodeWithDom | null = null;\nlet isMounted = false;\n\n// This object is used to store the current virtual node and component being rendered.\nexport const current: Current = {\n vnode: null,\n oldVnode: null,\n component: null,\n event: null\n};\n\n/* Reserved props ----------------------------------------------------------- */\n// This object is used to store the names of reserved props, which are props that are reserved\n// for special purposes and should not be used as regular component props.\nexport const reservedProps: Record<string, true> = {\n key: true,\n state: true,\n \"v-keep\": true,\n\n // Built in directives\n \"v-if\": true,\n \"v-unless\": true,\n \"v-for\": true,\n \"v-show\": true,\n \"v-class\": true,\n \"v-html\": true,\n \"v-model\": true,\n \"v-create\": true,\n \"v-update\": true,\n \"v-cleanup\": true\n};\n\n/* Mounting, Updating, Cleanup and Unmounting ------------------------------- */\n// These sets are used to store callbacks for various lifecycle events: mounting, updating,\n// cleaning up, and unmounting.\nconst onCleanupSet: Set<Function> = new Set();\nconst onMountSet: Set<Function> = new Set();\nconst onUpdateSet: Set<Function> = new Set();\nconst onUnmountSet: Set<Function> = new Set();\n\n// These functions allow users to register callbacks for the corresponding lifecycle events.\nexport function onMount(callback) {\n if (!isMounted) {\n onMountSet.add(callback);\n }\n}\n\nexport function onUpdate(callback) {\n onUpdateSet.add(callback);\n}\n\nexport function onCleanup(callback) {\n onCleanupSet.add(callback);\n}\n\nexport function onUnmount(callback) {\n if (!isMounted) {\n onUnmountSet.add(callback);\n }\n}\n\n// This function is used to call all the callbacks in a given set.\nfunction callSet(set) {\n for (let callback of set) {\n callback();\n }\n\n set.clear();\n}\n\n/* Event listener ----------------------------------------------------------- */\n\n// This object stores the names of event listeners that have been added\nconst eventListenerNames: Record<string, true> = {};\n\n// This function is called when an event occurs\nfunction eventListener(e: Event) {\n // Set the current event to the event that occurred so that it can be prevented if necessary\n current.event = e;\n\n // Convert the target of the event to a DOM element\n let dom = e.target as DomElement;\n\n // Create the name of the event listener by adding \"v-on\" to the event type\n let name = `v-on${e.type}`;\n\n // Keep going up the DOM tree until we find an element with an event listener\n // matching the event type\n while (dom) {\n if (dom[name]) {\n // Call the event listener function\n dom[name](e, dom);\n\n // If the default action of the event hasn't been prevented, update the DOM\n if (!e.defaultPrevented) {\n update();\n }\n return;\n }\n dom = dom.parentNode as DomElement;\n }\n\n current.event = null;\n}\n\n/* Directives --------------------------------------------------------------- */\n\n// This function creates a directive that hides an element based on a condition\nlet hideDirective = (test: boolean) => (bool: boolean, vnode: VnodeInterface, oldnode?: VnodeInterface) => {\n // If test is true, use the value of bool. Otherwise, use the opposite of bool.\n let value = test ? bool : !bool;\n\n // If the value is true, hide the element by replacing it with a text node\n if (value) {\n let newdom = document.createTextNode(\"\");\n if (oldnode && oldnode.dom && oldnode.dom.parentNode) {\n oldnode.dom.parentNode.replaceChild(newdom, oldnode.dom);\n }\n vnode.tag = \"#text\";\n vnode.children = [];\n vnode.props = {};\n vnode.dom = newdom as unknown as DomElement;\n return false;\n }\n};\n\n// This object stores all the available directives\nexport const directives: Directives = {\n // The \"v-if\" directive hides an element if the given condition is false\n \"v-if\": hideDirective(false),\n\n // The \"v-unless\" directive hides an element if the given condition is true\n \"v-unless\": hideDirective(true),\n\n // The \"v-for\" directive creates a loop and applies a callback function to each item in the loop\n \"v-for\": (set: unknown[], vnode: VnodeWithDom) => {\n let newChildren: VnodeInterface[] = [];\n let callback = vnode.children[0];\n for (let i = 0, l = set.length; i < l; i++) {\n newChildren.push(callback(set[i], i));\n }\n vnode.children = newChildren;\n },\n\n // The \"v-show\" directive shows or hides an element by setting the \"display\" style property\n \"v-show\": (bool: boolean, vnode: VnodeWithDom) => {\n (\n vnode.dom as unknown as {\n style: { display: string };\n }\n ).style.display = bool ? \"\" : \"none\";\n },\n\n // The \"v-class\" directive adds or removes class names from an element based on a condition\n \"v-class\": (classes: { [x: string]: boolean }, vnode: VnodeWithDom) => {\n // Loop through all the class names in the classes object\n for (let name in classes) {\n // Add or remove the class name from the element's class list based on the value in the classes object\n (vnode.dom as DomElement).classList.toggle(name, classes[name]);\n }\n },\n\n // The \"v-html\" directive sets the inner HTML of an element to the given HTML string\n \"v-html\": (html: string, vnode: VnodeWithDom) => {\n // Set the children of the vnode to a trusted version of the HTML string\n vnode.children = [trust(html)];\n },\n\n // The \"v-model\" directive binds the value of an input element to a model property\n \"v-model\": ([model, property, event]: any[], vnode: VnodeWithDom, oldVnode?: VnodeWithDom) => {\n let value;\n // This function updates the model property when the input element's value changes\n let handler = (e: Event) => (model[property] = (e.target as DomElement & Record<string, any>).value);\n if (vnode.tag === \"input\") {\n // If the element is an input, use the \"input\" event by default\n event = event || \"oninput\";\n // Depending on the type of input element, use a different handler function\n switch (vnode.props.type) {\n case \"checkbox\": {\n if (Array.isArray(model[property])) {\n // If the model property is an array, add or remove the value from the array when the checkbox is checked or unchecked\n handler = (e: Event) => {\n let val = (e.target as DomElement & Record<string, any>).value;\n let idx = model[property].indexOf(val);\n if (idx === -1) {\n model[property].push(val);\n } else {\n model[property].splice(idx, 1);\n }\n };\n // If the value is in the array, set the checkbox to be checked\n value = model[property].indexOf(vnode.dom.value) !== -1;\n } else if (\"value\" in vnode.props) {\n // If the input element has a \"value\" attribute, use it to determine the checked state\n handler = () => {\n if (model[property] === vnode.props.value) {\n model[property] = null;\n } else {\n model[property] = vnode.props.value;\n }\n };\n value = model[property] === vnode.props.value;\n } else {\n // If there is no \"value\" attribute, use a boolean value for the model property\n handler = () => (model[property] = !model[property]);\n value = model[property];\n }\n // Set the \"checked\" attribute on the input element\n // eslint-disable-next-line no-use-before-define\n sharedSetAttribute(\"checked\", value, vnode);\n break;\n }\n case \"radio\": {\n // If the element is a radio button, set the \"checked\" attribute based on the value of the model property\n // eslint-disable-next-line no-use-before-define\n sharedSetAttribute(\"checked\", model[property] === vnode.dom.value, vnode);\n break;\n }\n default: {\n // For all other input types, set the \"value\" attribute based on the value of the model property\n // eslint-disable-next-line no-use-before-define\n sharedSetAttribute(\"value\", model[property], vnode);\n }\n }\n } else if (vnode.tag === \"select\") {\n // If the element is a select element, use the \"click\" event by default\n event = event || \"onclick\";\n if (vnode.props.multiple) {\n // If the select element allows multiple selections, update the model property with an array of selected values\n handler = (e: Event & Record<string, any>) => {\n let val = (e.target as DomElement & Record<string, any>).value;\n if (e.ctrlKey) {\n // If the Ctrl key is pressed, add or remove the value from the array\n let idx = model[property].indexOf(val);\n if (idx === -1) {\n model[property].push(val);\n } else {\n model[property].splice(idx, 1);\n }\n } else {\n // If the Ctrl key is not pressed, set the model property to an array with the selected value\n model[property].splice(0, model[property].length);\n model[property].push(val);\n }\n };\n // Set the \"selected\" attribute on the options based on whether they are in the model property array\n vnode.children.forEach((child: VnodeInterface) => {\n if (child.tag === \"option\") {\n let value = \"value\" in child.props ? child.props.value : child.children.join(\"\").trim();\n child.props.selected = model[property].indexOf(value) !== -1;\n }\n });\n } else {\n // If the select element does not allow multiple selections, set the \"selected\" attribute on the options based on the value of the model property\n vnode.children.forEach((child: VnodeInterface) => {\n if (child.tag === \"option\") {\n let value = \"value\" in child.props ? child.props.value : child.children.join(\"\").trim();\n child.props.selected = value === model[property];\n }\n });\n }\n } else if (vnode.tag === \"textarea\") {\n // If the element is a textarea, use the \"input\" event by default\n event = event || \"oninput\";\n // Set the textarea's content to the value of the model property\n vnode.children = [model[property]];\n }\n\n // We assume that the prev handler if any will not be changed by the user across patchs\n let prevHandler = vnode.props[event];\n\n // Set the event handler on the element\n // eslint-disable-next-line no-use-before-define\n sharedSetAttribute(\n event,\n (e: Event) => {\n handler(e);\n\n // If the previous handler is defined, call it after the model has been updated\n if (prevHandler) {\n prevHandler(e);\n }\n },\n vnode,\n oldVnode\n );\n },\n\n // The \"v-create\" directive is called when a new virtual node is created.\n // The provided callback function is called with the new virtual node as an argument.\n // This directive is only called once per virtual node, when it is first created.\n // eslint-disable-next-line no-unused-vars\n \"v-create\": (callback: (vnode: VnodeWithDom) => void, vnode: VnodeWithDom, oldVnode?: VnodeWithDom) => {\n // If this is not an update, call the callback function with the new virtual node\n if (!oldVnode) {\n let cleanup = callback(vnode);\n\n // If the callback function returns a function, call it when the update is gonna be cleaned up\n if (typeof cleanup === \"function\") {\n onCleanup(cleanup);\n }\n }\n },\n\n // The \"v-update\" directive is called when an existing virtual node is updated.\n // The provided callback function is called with the new and old virtual nodes as arguments.\n // This directive is only called once per virtual node update.\n \"v-update\": (\n // eslint-disable-next-line no-unused-vars\n callback: (vnode: VnodeWithDom, oldVnode: VnodeWithDom) => void,\n vnode: VnodeWithDom,\n oldVnode?: VnodeWithDom\n ) => {\n // If this is an update, call the callback function with the new and old virtual nodes\n if (oldVnode) {\n let cleanup = callback(vnode, oldVnode);\n\n // If the callback function returns a function, call it when the update is gonna be cleaned up\n if (typeof cleanup === \"function\") {\n onCleanup(cleanup);\n }\n }\n },\n\n // The \"v-cleanup\" directive is called when the update is cleaned up.\n // The provided callback function is called with the old virtual node as an argument.\n // This directive is only called once per virtual node, when the update is cleaned up.\n \"v-cleanup\": (\n // eslint-disable-next-line no-unused-vars\n callback: (vnode: VnodeWithDom, oldVnode?: VnodeWithDom) => void,\n vnode: VnodeWithDom,\n oldVnode?: VnodeWithDom\n ) => {\n // Add the callback function to the list of cleanup functions to be called when the update is cleaned up\n onCleanup(() => callback(vnode, oldVnode));\n }\n};\n// Add a directive to the global directives object, with the key being the name\n// preceded by \"v-\". Also add the name to the global reservedProps object.\nexport function directive(name: string, directive: Directive) {\n let directiveName = `v-${name}`;\n directives[directiveName] = directive;\n reservedProps[directiveName] = true;\n}\n\n// Set an attribute on a virtual DOM node and update the actual DOM element.\n// If the attribute value is a function, add an event listener for the attribute\n// name to the DOM element represented by mainVnode.\n// If oldVnode is provided, compare the new attribute value to the old value\n// and only update the attribute if the values are different.\nfunction sharedSetAttribute(name: string, value: any, newVnode: VnodeWithDom, oldVnode?: VnodeWithDom): void | boolean {\n // If the attribute value is a function, add an event listener for the attribute\n // name to the DOM element represented by mainVnode.\n if (typeof value === \"function\") {\n // Only add the event listener if it hasn't been added yet.\n if (name in eventListenerNames === false) {\n (mainVnode as VnodeWithDom).dom.addEventListener(name.slice(2), eventListener);\n eventListenerNames[name] = true;\n }\n newVnode.dom[`v-${name}`] = value;\n return;\n }\n\n // If the attribute is present on the DOM element and newVnode is not an SVG,\n // update the attribute if the value has changed.\n if (name in newVnode.dom && newVnode.isSVG === false) {\n // eslint-disable-next-line eqeqeq\n if (newVnode.dom[name] != value) {\n newVnode.dom[name] = value;\n }\n return;\n }\n\n // If oldVnode is not provided or the attribute value has changed, update the\n // attribute on the DOM element.\n if (!oldVnode || value !== oldVnode.props[name]) {\n if (value === false) {\n newVnode.dom.removeAttribute(name);\n } else {\n newVnode.dom.setAttribute(name, value);\n }\n }\n}\n\n// Set an attribute on a virtual DOM node and update the actual DOM element.\n// Skip the attribute if it is in the reservedProps object.\nexport function setAttribute(name: string, value: any, newVnode: VnodeWithDom, oldVnode?: VnodeWithDom): void {\n if (name in reservedProps) {\n return;\n }\n newVnode.props[name] = value;\n sharedSetAttribute(name, value, newVnode as VnodeWithDom, oldVnode);\n}\n\n// Update the attributes on a virtual DOM node. If oldVnode is provided, remove\n// attributes from the DOM element that are not present in newVnode.props but are\n// present in oldVnode.props. Then, iterate over the attributes in newVnode.props\n// and update the DOM element with the attributes using the sharedSetAttribute\n// function. If an attribute is in the reservedProps object and has a corresponding\n// directive in the directives object, call the directive with the attribute value\n// and the two virtual DOM nodes as arguments. If the directive returns false, exit\n// the loop.\nexport function updateAttributes(newVnode: VnodeWithDom, oldVnode?: VnodeWithDom): void {\n // If oldVnode is provided, remove attributes from the DOM element that are not\n // present in newVnode.props but are present in oldVnode.props.\n if (oldVnode) {\n for (let name in oldVnode.props) {\n if (name in newVnode.props === false && name in eventListenerNames === false && name in reservedProps === false) {\n if (name in newVnode.dom && newVnode.isSVG === false) {\n newVnode.dom[name] = null;\n } else {\n newVnode.dom.removeAttribute(name);\n }\n }\n }\n }\n\n // Iterate over the attributes in newVnode.props and update the DOM element with\n // the attributes using the sharedSetAttribute function.\n for (let name in newVnode.props) {\n if (name in reservedProps) {\n // If there is a directive for the attribute, call it with the attribute value\n // and the two virtual DOM nodes as arguments. If the directive returns false,\n // exit the loop.\n if (name in directives && directives[name](newVnode.props[name], newVnode, oldVnode) === false) {\n break;\n }\n continue;\n }\n sharedSetAttribute(name, newVnode.props[name], newVnode, oldVnode);\n }\n}\n\n/* patch ------------------------------------------------------------------- */\n\n// Patch a DOM node with a new VNode tree\nexport function patch(newVnode: VnodeWithDom, oldVnode?: VnodeWithDom): void {\n // If the new tree has no children, set the text content of the parent DOM element to an empty string\n if (newVnode.children.length === 0) {\n newVnode.dom.textContent = \"\";\n return;\n }\n\n // Get the children of the new and old virtual DOM nodes\n let newTree = newVnode.children;\n let oldTree = oldVnode?.children || [];\n // Get the length of the old tree\n let oldTreeLength = oldTree.length;\n\n // If the old tree has children and the first child of the new tree is a VNode with a \"key\"\n // attribute and the first child of the old tree is a VNode with a \"key\" attribute, update\n // the DOM element in place by comparing the keys of the nodes in the trees.\n if (oldTreeLength && newTree[0] instanceof Vnode && \"key\" in newTree[0].props && \"key\" in oldTree[0].props) {\n // Get the lengths of the new and old trees\n let newTreeLength = newTree.length;\n\n // Create an object that maps keys to indices in the old tree\n let oldKeyedList: { [key: string]: number } = {};\n for (let i = 0; i < oldTreeLength; i++) {\n oldKeyedList[oldTree[i].props.key] = i;\n }\n\n // Create an object that maps keys to indices in the new tree\n let newKeyedList: { [key: string]: number } = {};\n for (let i = 0; i < newTreeLength; i++) {\n newKeyedList[newTree[i].props.key] = i;\n }\n\n // Iterate over the new tree\n for (let i = 0; i < newTreeLength; i++) {\n // Get the current new child and the corresponding old child\n let newChild = newTree[i];\n let oldChild = oldTree[oldKeyedList[newChild.props.key]];\n // Initialize a flag to determine whether to patch the child\n let shouldPatch = true;\n\n // If the old child exists, update the DOM element of the new child to match the old child's DOM element\n if (oldChild) {\n newChild.dom = oldChild.dom;\n // If the new and old children have the same \"v-keep\" attribute value, update the children of the new child to match the old child's children\n if (\"v-keep\" in newChild.props && newChild.props[\"v-keep\"] === oldChild.props[\"v-keep\"]) {\n newChild.children = oldChild.children;\n // Set the shouldPatch flag to false\n shouldPatch = false;\n } else {\n updateAttributes(newChild, oldChild);\n }\n\n // If the old child does not exist, create a new DOM element for the new child and update its attributes\n } else {\n newChild.dom = createDomElement(newChild.tag, newChild.isSVG);\n updateAttributes(newChild);\n }\n\n // If the new child's DOM element is not the i-th child of the parent DOM element, insert it\n if (!newVnode.dom.childNodes[i]) {\n newVnode.dom.appendChild(newChild.dom);\n\n // If the new child's DOM element is not the same as the i-th child of the parent DOM element, replace the i-th child with the new child's DOM element\n } else if (newVnode.dom.childNodes[i] !== newChild.dom) {\n newVnode.dom.replaceChild(newChild.dom, newVnode.dom.childNodes[i]);\n }\n\n // If the shouldPatch flag is true, recursively call the patch function on the new child, passing in the old child as the second argument\n shouldPatch && patch(newChild, oldChild);\n }\n\n // For the rest of the children, we should remove them from the DOM\n for (let i = newTreeLength; i < oldTreeLength; i++) {\n // If the i-th child of the old tree does not have a corresponding key in the new tree, remove its DOM element from the parent DOM element\n if (!newKeyedList[oldTree[i].props.key]) {\n oldTree[i].dom.parentNode && oldTree[i].dom.parentNode.removeChild(oldTree[i].dom);\n }\n }\n return;\n }\n\n // If the new tree has no children, set the text content of the parent DOM element to an empty string\n if (newTree.length === 0) {\n newVnode.dom.textContent = \"\";\n return;\n }\n\n // Set the global current object to the new and old virtual DOM nodes\n current.vnode = newVnode;\n current.oldVnode = oldVnode;\n\n // Flatten the new tree\n // Take into account that is necessary to flatten the tree before the patch process\n // to let the hooks and signals work properly\n for (let i = 0; i < newTree.length; i++) {\n let newChild = newTree[i];\n\n // If the new child is a Vnode and is not a text node\n if (newChild instanceof Vnode) {\n // If the tag of the new child is not a string, it is a component\n if (typeof newChild.tag !== \"string\") {\n // Set the current component to the tag of the new child\n current.component = newChild.tag;\n // Replace the new child with the result of calling its view or bind method, passing in the props and children as arguments\n newTree.splice(\n i--,\n 1,\n (\"view\" in newChild.tag ? newChild.tag.view.bind(newChild.tag) : newChild.tag.bind(newChild.tag))(\n newChild.props,\n ...newChild.children\n )\n );\n }\n\n continue;\n }\n\n // If the new child is an array, flatten it and continue the loop\n if (Array.isArray(newChild)) {\n newTree.splice(i--, 1, ...newChild);\n continue;\n }\n\n // If the new child is null or undefined, remove it from the new tree and continue the loop\n if (newChild === null || newChild === undefined) {\n newTree.splice(i--, 1);\n continue;\n }\n\n // If the new child is a Vnode, set the text of the Vnode to the text content of its dom property\n newTree[i] = new Vnode(textTag, {}, [newChild]);\n }\n\n // Patch the the old tree\n for (let i = 0; i < newTree.length; i++) {\n let newChild = newTree[i];\n\n if (newChild.tag === textTag) {\n // If no old child exists at the same index\n if (i >= oldTreeLength) {\n // Create a new text node for the new child\n newChild.dom = document.createTextNode(newChild.children[0]);\n // Append the new text node to the dom\n newVnode.dom.appendChild(newChild.dom);\n continue;\n }\n\n // If there is an old child at the same index\n let oldChild = oldTree[i];\n\n // If the old child is not a text node\n if (oldChild.tag !== textTag) {\n // Create a new text node for the new child\n newChild.dom = document.createTextNode(newChild.children[0]);\n // Replace the old child in the dom with the new text node\n newVnode.dom.replaceChild(newChild.dom, oldChild.dom);\n continue;\n }\n\n // If the old child is a text node\n // Set the dom property of the text Vnode to the dom property of the old child\n newChild.dom = oldChild.dom;\n // If the text content of the old child is different from the new child, update the text content of the old child\n // eslint-disable-next-line eqeqeq\n if (newChild.children[0] != oldChild.dom.textContent) {\n oldChild.dom.textContent = newChild.children[0];\n }\n continue;\n }\n\n // If the new child is not a text node\n // Set the isSVG flag for the new child if it is an SVG element or if the parent is an SVG element\n newChild.isSVG = newVnode.isSVG || newChild.tag === \"svg\";\n\n // If there is no old child at the same index\n if (i >= oldTreeLength) {\n // Create a new dom element for the new child\n newChild.dom = createDomElement(newChild.tag as string, newChild.isSVG);\n // Update the attributes of the new child\n updateAttributes(newChild as VnodeWithDom);\n // Append the new child to the dom\n newVnode.dom.appendChild(newChild.dom);\n // Recursively patch the new child\n patch(newChild as VnodeWithDom);\n continue;\n }\n\n // If there is an old child at the same index\n let oldChild = oldTree[i];\n\n // If the tag of the new child is different from the tag of the old child\n if (newChild.tag !== oldChild.tag) {\n // Create a new dom element for the new child\n newChild.dom = createDomElement(newChild.tag as string, newChild.isSVG);\n // Update the attributes of the new child\n updateAttributes(newChild as VnodeWithDom);\n // Replace the old child in the dom with the new child\n newVnode.dom.replaceChild(newChild.dom, oldChild.dom);\n // Recursively patch the new child\n patch(newChild as VnodeWithDom);\n continue;\n }\n\n // If the tag of the new child is the same as the tag of the old child\n // Set the dom property of the new child to the dom property of the old child\n newChild.dom = oldChild.dom;\n // If the v-keep prop is the same for both the new and old child, set the children of the new child to the children of the old child\n if (\"v-keep\" in newChild.props && newChild.props[\"v-keep\"] === oldChild.props[\"v-keep\"]) {\n newChild.children = oldChild.children;\n continue;\n }\n\n // Update the attributes of the new child based on the old child\n updateAttributes(newChild as VnodeWithDom, oldChild);\n // Recursively patch the new and old children\n patch(newChild as VnodeWithDom, oldChild);\n }\n\n // Remove any old children that are no longer present in the new tree\n for (let i = newTree.length; i < oldTreeLength; i++) {\n newVnode.dom.removeChild(oldTree[i].dom);\n }\n}\n\n// Update the main Vnode\nexport function update(): void | string {\n // If the main Vnode exists\n if (mainVnode) {\n // Call any cleanup functions that are registered with the onCleanupSet set\n callSet(onCleanupSet);\n // Store a reference to the old main Vnode\n let oldMainVnode = mainVnode;\n // Create a new main Vnode with the main component as its only child\n mainVnode = new Vnode(oldMainVnode.tag, oldMainVnode.props, [mainComponent]) as VnodeWithDom;\n mainVnode.dom = oldMainVnode.dom;\n mainVnode.isSVG = oldMainVnode.isSVG;\n\n // Recursively patch the new and old main Vnodes\n patch(mainVnode, oldMainVnode);\n\n // Call any update or mount functions that are registered with the onUpdateSet or onMountSet set\n callSet(isMounted ? onUpdateSet : onMountSet);\n\n // Set the isMounted flag to true\n isMounted = true;\n\n // Reset the current vnode, oldVnode, and component properties\n current.vnode = null;\n current.oldVnode = null;\n current.component = null;\n\n // If the code is running in a Node.js environment, return the inner HTML of the main Vnode's dom element\n if (isNodeJs) {\n return mainVnode.dom.innerHTML;\n }\n }\n}\n\n// Update custom Vnode\n// It is assumed that a first mount has already occurred, so,\n// the oldVnode is not null and the dom property of the oldVnode is not null\n// You need to set the dom property of the newVnode to the dom property of the oldVnode\n// The same with the isSVG property\n// Prefer this function over patch to allow for cleanup, onUpdate and onMount sets to be called\nexport function updateVnode(vnode: VnodeWithDom, oldVnode: VnodeWithDom): string | void {\n // Call any cleanup functions that are registered with the onCleanupSet set\n callSet(onCleanupSet);\n\n // Recursively patch the new and old main Vnodes\n patch(vnode, oldVnode);\n\n // Set the oldVnode's tag, props, children, dom, and isSVG properties to the newVnode's tag, props, children, dom, and isSVG properties\n // This is necessary to allow for the oldVnode to be used as the newVnode in the next update with the normal update function\n oldVnode.tag = vnode.tag;\n oldVnode.props = { ...vnode.props };\n oldVnode.children = [...vnode.children];\n oldVnode.dom = vnode.dom;\n oldVnode.isSVG = vnode.isSVG;\n\n // Call any update or mount functions that are registered with the onUpdateSet or onMountSet set\n callSet(isMounted ? onUpdateSet : onMountSet);\n\n // Set the isMounted flag to true\n isMounted = true;\n\n // Reset the current vnode, oldVnode, and component properties\n current.vnode = null;\n current.oldVnode = null;\n current.component = null;\n\n if (isNodeJs) {\n return vnode.dom.innerHTML;\n }\n}\n\n// Unmount the main Vnode\nexport function unmount() {\n // If the main Vnode exists\n if (mainVnode) {\n // Set the main component to a null Vnode\n mainComponent = new Vnode(() => null, {}, []) as VnodeComponentInterface;\n // Update the main Vnode\n let result = update();\n // Call any unmount functions that are registered with the onUnmountSet set\n callSet(onUnmountSet);\n\n // Remove any event listeners that were added to the main Vnode's dom element\n for (let name in eventListenerNames) {\n mainVnode.dom.removeEventListener(name.slice(2).toLowerCase(), eventListener);\n Reflect.deleteProperty(eventListenerNames, name);\n }\n\n // Reset the main component and main Vnode\n mainComponent = null;\n mainVnode = null;\n // Set the isMounted flag to false\n isMounted = false;\n // Reset the current vnode, oldVnode, and component properties\n current.vnode = null;\n current.oldVnode = null;\n current.component = null;\n // Return the result of updating the main Vnode\n return result;\n }\n}\n// This function takes in a DOM element or a DOM element selector and a component to be mounted on it.\nexport function mount(dom, component) {\n // Check if the 'dom' argument is a string. If it is, select the first element that matches the given selector.\n // Otherwise, use the 'dom' argument as the container.\n let container =\n typeof dom === \"string\"\n ? isNodeJs\n ? createDomElement(dom, dom === \"svg\")\n : document.querySelectorAll(dom)[0]\n : dom;\n\n // Check if the 'component' argument is a Vnode component or a regular component.\n // If it's a regular component, create a new Vnode component using the 'component' argument as the tag.\n // If it's not a component at all, create a new Vnode component with the 'component' argument as the rendering function.\n let vnodeComponent = isVnodeComponent(component)\n ? component\n : isComponent(component)\n ? new Vnode(component, {}, [])\n : new Vnode(() => component, {}, []);\n\n // If a main component already exists and it's not the same as the current 'vnodeComponent', unmount it.\n if (mainComponent && mainComponent.tag !== vnodeComponent.tag) {\n unmount();\n }\n\n // Set the 'vnodeComponent' as the main component.\n mainComponent = vnodeComponent as VnodeComponentInterface;\n // Convert the container element to a Vnode.\n mainVnode = domToVnode(container);\n // Update the DOM with the new component.\n return update();\n}\n\n// This is a utility function for creating Vnode objects.\n// It takes in a tag or component, and optional props and children arguments.\nexport const v: V = (tagOrComponent, props = {}, ...children) => {\n // Return a new Vnode object using the given arguments.\n return new Vnode(tagOrComponent, props || {}, children);\n};\n\n// This utility function creates a fragment Vnode.\n// It takes in a placeholder and the children arguments, returns only the children.\nv.fragment = (_: VnodeProperties, ...children: Children) => children;\n"],
5
+ "mappings": ";AAkIA,IAAM,UAAU;AAIT,IAAI,WAAW,QAAQ,OAAO,YAAY,eAAe,QAAQ,YAAY,QAAQ,SAAS,IAAI;AAIlG,SAAS,iBAAiB,KAAa,QAAiB,OAAmB;AAChF,SAAO,QAAQ,SAAS,gBAAgB,8BAA8B,GAAG,IAAI,SAAS,cAAc,GAAG;AACzG;AAMO,IAAM,QAAQ,SAASA,OAA4B,KAAa,OAAwB,UAAoB;AAEjH,OAAK,MAAM;AACX,OAAK,QAAQ;AACb,OAAK,WAAW;AAClB;AAIO,SAAS,YAAY,WAAmC;AAC7D,SAAO,cAAc,OAAO,cAAc,cAAe,OAAO,cAAc,YAAY,UAAU;AACtG;AAGO,IAAM,UAAU,CAAC,WAAgE;AAEtF,SAAO,kBAAkB;AAC3B;AAIO,IAAM,mBAAmB,CAAC,WAAkF;AAEjH,SAAO,QAAQ,MAAM,KAAK,YAAY,OAAO,GAAG;AAClD;AAGO,SAAS,WAAW,KAAwB;AAIjD,MAAI,IAAI,aAAa,GAAG;AACtB,QAAIC,SAAQ,IAAI,MAAM,SAAS,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC;AAClD,IAAAA,OAAM,MAAM;AACZ,WAAOA;AAAA,EACT;AAEA,MA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AAgB,IAAI,MAAM,MAAM,MAAM,CAAC,GAAG,CAAC,CAAC;AAE5C,QAAI,SAAS,OAAO;AAEpB,YAAQ,YAAY;AAGpB,aAAS,QAAQ,oBAAoB;AACnC,gBAAU,IAAI,oBAAoB,KAAK,MAAM,CAAC,EAAE,YAAY,GAAG,aAAa;AAC5E,cAAQ,eAAe,oBAAoB,IAAI;AAAA,IACjD;AAGA,oBAAgB;AAChB,gBAAY;AAEZ,gBAAY;AAEZ,YAAQ,QAAQ;AAChB,YAAQ,WAAW;AACnB,YAAQ,YAAY;AAEpB,WAAO;AAAA,EACT;AACF;AAEO,SAAS,MAAM,KAAK,WAAW;AAGpC,MAAI,YACF,OAAO,QAAQ,WACX,WACE,iBAAiB,KAAK,QAAQ,KAAK,IACnC,SAAS,iBAAiB,GAAG,EAAE,CAAC,IAClC;AAKN,MAAI,iBAAiB,iBAAiB,SAAS,IAC3C,YACA,YAAY,SAAS,IACrB,IAAI,MAAM,WAAW,CAAC,GAAG,CAAC,CAAC,IAC3B,IAAI,MAAM,MAAM,WAAW,CAAC,GAAG,CAAC,CAAC;AAGrC,MAAI,iBAAiB,cAAc,QAAQ,eAAe,KAAK;AAC7D,YAAQ;AAAA,EACV;AAGA,kBAAgB;AAEhB,cAAY,WAAW,SAAS;AAEhC,SAAO,OAAO;AAChB;AAIO,IAAM,IAAO,CAAC,gBAAgB,QAAQ,CAAC,MAAM,aAAa;AAE/D,SAAO,IAAI,MAAM,gBAAgB,SAAS,CAAC,GAAG,QAAQ;AACxD;AAIA,EAAE,WAAW,CAAC,MAAuB,aAAuB;",
6
+ "names": ["Vnode", "vnode", "value", "directive", "oldChild"]
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../lib/node/index.ts", "../../lib/node/utils/tree-adapter.ts", "../../lib/node/utils/icons.ts", "../../lib/node/utils/inline.ts", "../../lib/node/utils/sw.ts"],
4
+ "sourcesContent": ["import { document, domToHtml, domToHyperscript, htmlToDom, htmlToHyperscript } from \"./utils/tree-adapter\";\nimport { mount, unmount } from \"valyrian.js\";\n\nimport FormData from \"form-data\";\n// import fetch from \"node-fetch\";\nimport { icons } from \"./utils/icons\";\nimport { inline } from \"./utils/inline\";\nimport { sw } from \"./utils/sw\";\n\nglobal.FormData = FormData as any;\nglobal.document = document as any;\n\nfunction render(...args: any[]) {\n let Component = () => args;\n let result = mount(\"div\", Component);\n unmount();\n return result;\n}\n\nexport { domToHtml, domToHyperscript, htmlToDom, htmlToHyperscript, inline, sw, icons, render };\n", "/* eslint-disable no-use-before-define */\n/* eslint-disable complexity */\ninterface ChildNodes extends Array<Node | Element | Text | DocumentFragment> {}\n\nexport class Node implements Node {\n // eslint-disable-next-line no-use-before-define\n childNodes: ChildNodes = [];\n baseURI: string = \"\";\n\n tag_name!: string;\n get nodeName(): string {\n return this.tag_name.toLowerCase();\n }\n set nodeName(name: string) {\n this.tag_name = name;\n }\n get tagName(): string {\n return this.tag_name;\n }\n set tagName(name: string) {\n this.tag_name = name;\n }\n\n node_type!: number;\n get nodeType(): number {\n return this.node_type;\n }\n set nodeType(type: number) {\n this.node_type = type;\n }\n\n node_value = \"\";\n attributes: Attr[] = [];\n set textContent(text) {\n this.node_value = String(text);\n }\n get textContent() {\n return this.node_value;\n }\n set nodeValue(text) {\n this.node_value = String(text);\n }\n get nodeValue() {\n return this.node_value;\n }\n\n // eslint-disable-next-line no-use-before-define\n parent_node: Node | null = null;\n get parentNode() {\n return this.parent_node;\n }\n set parentNode(node) {\n this.parent_node = node;\n }\n\n constructor() {}\n\n appendChild<T extends Node>(node: T): T {\n node.parentNode && node.parentNode.removeChild(node as Node);\n this.childNodes.push(node);\n node.parentNode = this;\n return node;\n }\n\n insertBefore<T extends Node>(node: T, child: Node | null): T {\n node.parentNode && node.parentNode.removeChild(node as Node);\n node.parentNode = this;\n if (child) {\n let idx = this.childNodes.indexOf(child);\n this.childNodes.splice(idx, 0, node);\n } else {\n this.childNodes.push(node);\n }\n return node;\n }\n\n replaceChild<T extends Node>(node: Node, child: T): T {\n if (child && child.parentNode === this) {\n this.insertBefore(node, child);\n child.parentNode && child.parentNode.removeChild(child);\n }\n return child;\n }\n removeChild<T extends Node>(child: T): T {\n if (child && child.parentNode === this) {\n let idx = (this.childNodes as unknown as Node[]).indexOf(child);\n (this.childNodes as unknown as Node[]).splice(idx, 1);\n child.parentNode = null;\n }\n return child;\n }\n cloneNode(deep?: boolean | undefined): Node {\n if (this.nodeType === 3) {\n return new Text(this.nodeValue);\n }\n\n if (this.nodeType === 1) {\n let node = new Element();\n node.nodeType = this.nodeType;\n this.nodeName = this.nodeName;\n if (this.attributes) {\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n node.setAttribute(this.attributes[i].nodeName, this.attributes[i].nodeValue);\n }\n }\n if (deep) {\n for (let i = 0, l = this.childNodes.length; i < l; i++) {\n node.appendChild(this.childNodes[i].cloneNode(deep));\n }\n }\n return node;\n }\n\n let node = new Node();\n node.nodeType = this.nodeType;\n node.nodeName = this.nodeName;\n return node;\n }\n\n setAttribute(name: string, value: any) {\n let attr = {\n nodeName: name,\n nodeValue: value\n };\n let idx = -1;\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n if (this.attributes[i].nodeName === name) {\n idx = i;\n break;\n }\n }\n idx === -1 ? this.attributes.push(attr as Attr) : this.attributes.splice(idx, 1, attr as Attr);\n }\n\n getAttribute(name: string) {\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n if (this.attributes[i].nodeName === name) {\n return this.attributes[i].nodeValue;\n }\n }\n }\n\n removeAttribute(name: string) {\n let idx = -1;\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n if (this.attributes[i].nodeName === name) {\n idx = i;\n break;\n }\n }\n if (idx > -1) {\n this.attributes.splice(idx, 1);\n }\n }\n\n getElementById(id: string): Node | null {\n let elementFound;\n for (let i = 0, l = this.childNodes.length; i < l; i++) {\n if (this.childNodes[i].nodeType === 1) {\n if (this.childNodes[i].getAttribute(\"id\") === id) {\n elementFound = this.childNodes[i];\n break;\n }\n elementFound = this.childNodes[i].getElementById(id);\n if (elementFound) {\n break;\n }\n }\n }\n return elementFound || null;\n }\n\n // Not implemented\n // firstChild!: ChildNode | null;\n // isConnected!: boolean;\n // lastChild!: ChildNode | null;\n // nextSibling!: ChildNode | null;\n // ownerDocument!: Document | null;\n // parentElement!: HTMLElement | null;\n // previousSibling!: ChildNode | null;\n // compareDocumentPosition(other: Node): number {\n // throw new Error(\"Method not implemented.\");\n // }\n // contains(other: Node | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // getRootNode(options?: GetRootNodeOptions | undefined): Node {\n // throw new Error(\"Method not implemented.\");\n // }\n // hasChildNodes(): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // isDefaultNamespace(namespace: string | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // isEqualNode(otherNode: Node | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // isSameNode(otherNode: Node | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // lookupNamespaceURI(prefix: string | null): string | null {\n // throw new Error(\"Method not implemented.\");\n // }\n // lookupPrefix(namespace: string | null): string | null {\n // throw new Error(\"Method not implemented.\");\n // }\n // normalize(): void {\n // throw new Error(\"Method not implemented.\");\n // }\n // ATTRIBUTE_NODE!: number;\n // CDATA_SECTION_NODE!: number;\n // COMMENT_NODE!: number;\n // DOCUMENT_FRAGMENT_NODE!: number;\n // DOCUMENT_NODE!: number;\n // DOCUMENT_POSITION_CONTAINED_BY!: number;\n // DOCUMENT_POSITION_CONTAINS!: number;\n // DOCUMENT_POSITION_DISCONNECTED!: number;\n // DOCUMENT_POSITION_FOLLOWING!: number;\n // DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC!: number;\n // DOCUMENT_POSITION_PRECEDING!: number;\n // DOCUMENT_TYPE_NODE!: number;\n // ELEMENT_NODE!: number;\n // ENTITY_NODE!: number;\n // ENTITY_REFERENCE_NODE!: number;\n // NOTATION_NODE!: number;\n // PROCESSING_INSTRUCTION_NODE!: number;\n // TEXT_NODE!: number;\n addEventListener(\n // eslint-disable-next-line no-unused-vars\n type: string,\n // eslint-disable-next-line no-unused-vars\n callback: EventListenerOrEventListenerObject | null,\n // eslint-disable-next-line no-unused-vars\n options?: boolean | AddEventListenerOptions | undefined\n ): void {\n // throw new Error(\"Method not implemented.\");\n }\n // dispatchEvent(event: Event): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n removeEventListener(\n // eslint-disable-next-line no-unused-vars\n type: string,\n // eslint-disable-next-line no-unused-vars\n callback: EventListenerOrEventListenerObject | null,\n // eslint-disable-next-line no-unused-vars\n options?: boolean | EventListenerOptions | undefined\n ): void {\n // throw new Error(\"Method not implemented.\");\n }\n}\n\nexport class Text extends Node {\n constructor(text: any) {\n super();\n this.nodeType = 3;\n this.nodeName = \"#text\";\n this.node_value = String(text);\n }\n}\n\nfunction updateElementStyles(element: Element, state: Record<string, any>) {\n let str = \"\";\n for (let key in state) {\n let value = state[key];\n if (typeof value !== \"undefined\" && value !== null && String(value).length > 0) {\n str += `${key}: ${state[key]};`;\n }\n }\n if (str.length === 0) {\n element.removeAttribute(\"style\");\n } else {\n element.setAttribute(\"style\", str);\n }\n}\n\nexport class Element extends Node {\n constructor() {\n super();\n this.nodeType = 1;\n this.attributes = [];\n this.childNodes = [];\n }\n\n _style = new Proxy(\n {},\n {\n get: (state: Record<string, any>, prop: string) => state[prop],\n set: (state: Record<string, any>, prop: string, value: any) => {\n state[prop] = value;\n updateElementStyles(this, state);\n return true;\n },\n deleteProperty: (state: Record<string, any>, prop: string) => {\n Reflect.deleteProperty(state, prop);\n updateElementStyles(this, state);\n return true;\n }\n }\n );\n\n get style() {\n return this._style as any;\n }\n\n set style(value: string) {\n if (typeof value === \"string\") {\n // should match pairs like \"color: red; font-size: 12px; background: url(http://example.com/image.png?s=1024x1024&amp;w=is&amp;k=20&amp;c=ASa_AG8uP5Di7azXgJraSA6ME7fbLB0GX4YT_OzCARI=);\"\n const regex = /([^:\\s]+):\\s*((url\\([^)]+\\))|[^;]+(?=(;|$)))/g;\n let match;\n\n while ((match = regex.exec(value)) !== null) {\n this._style[match[1]] = match[2].trim();\n }\n\n return;\n }\n\n throw new Error(\"Cannot set style\");\n }\n\n classList = {\n toggle: (item: any, force: any) => {\n if (item) {\n let classes = (this.getAttribute(\"class\") || \"\").split(\" \");\n let itemIndex = classes.indexOf(item);\n if (force && itemIndex === -1) {\n classes.push(item);\n }\n\n if (!force && itemIndex !== -1) {\n classes.splice(itemIndex, 1);\n }\n\n let final = classes.join(\" \").trim();\n if (final.length) {\n this.setAttribute(\"class\", classes.join(\" \").trim());\n } else {\n this.removeAttribute(\"class\");\n }\n }\n }\n };\n\n set textContent(text) {\n this.nodeValue = String(text);\n this.childNodes = this.nodeValue ? [new Text(this.nodeValue)] : [];\n }\n get textContent() {\n return this.nodeValue;\n }\n\n set innerText(text) {\n this.nodeValue = String(text);\n }\n\n get innerText() {\n return this.nodeValue;\n }\n\n get innerHTML() {\n let str = \"\";\n for (let i = 0, l = this.childNodes.length; i < l; i++) {\n // console.log(\"domToHtml\", this.childNodes[i], domToHtml(this.childNodes[i] as Element));\n str += domToHtml(this.childNodes[i] as Element);\n }\n return str;\n }\n\n set innerHTML(html) {\n this.textContent = \"\";\n let result = htmlToDom(html);\n if (result instanceof DocumentFragment) {\n for (let i = 0, l = result.childNodes.length; i < l; i++) {\n this.appendChild(result.childNodes[i]);\n }\n } else {\n this.appendChild(result);\n }\n }\n\n get outerHTML(): string {\n return domToHtml(this);\n }\n}\n\nexport class DocumentFragment extends Element {\n constructor() {\n super();\n this.nodeType = 11;\n this.nodeName = \"#document-fragment\";\n }\n}\n\nexport class Document extends Element {\n constructor() {\n super();\n this.nodeType = 9;\n this.nodeName = \"#document\";\n }\n\n createDocumentFragment(): DocumentFragment {\n return new DocumentFragment();\n }\n\n createElement(type: string) {\n let element = new Element();\n element.nodeName = type.toUpperCase();\n return element;\n }\n\n createElementNS(ns: string, type: string) {\n let element = this.createElement(type);\n element.baseURI = ns;\n return element;\n }\n\n createTextNode(text: any) {\n return new Text(text);\n }\n}\n\nlet selfClosingTags = [\n \"area\",\n \"base\",\n \"br\",\n \"col\",\n \"embed\",\n \"hr\",\n \"img\",\n \"input\",\n \"link\",\n \"meta\",\n \"param\",\n \"source\",\n \"track\",\n \"wbr\",\n \"!doctype\"\n];\n\nexport function domToHtml(dom: Element): string {\n if (dom.nodeType === 3) {\n return dom.textContent;\n }\n\n if (dom.nodeType === 1) {\n let name = dom.nodeName.toLowerCase();\n let str = \"<\" + name;\n for (let i = 0, l = dom.attributes.length; i < l; i++) {\n str += \" \" + dom.attributes[i].nodeName + '=\"' + dom.attributes[i].nodeValue + '\"';\n }\n\n if (selfClosingTags.indexOf(name) === -1) {\n str += \">\";\n if (dom.childNodes && dom.childNodes.length > 0) {\n for (let i = 0, l = dom.childNodes.length; i < l; i++) {\n let child = domToHtml(dom.childNodes[i] as Element);\n if (child) {\n str += child;\n }\n }\n }\n str += \"</\" + name + \">\";\n } else {\n str += \"/>\";\n }\n\n return str;\n }\n\n return \"\";\n}\n\nexport function domToHyperscript(childNodes: ChildNodes, depth = 1) {\n let spaces = \"\";\n for (let i = 0; i < depth; i++) {\n spaces += \" \";\n }\n\n return childNodes\n .map((item) => {\n if (item.nodeType === 10) {\n return `\\n${spaces}\"<!DOCTYPE html>\"`;\n } else if (item.nodeType === 3) {\n return `\\n${spaces}\"${item.nodeValue}\"`;\n } else {\n let str = `\\n${spaces}v(\"${item.nodeName}\", `;\n\n if (item.attributes) {\n let attrs: Record<string, any> = {};\n for (let i = 0, l = item.attributes.length; i < l; i++) {\n let attr = item.attributes[i];\n attrs[attr.nodeName] = attr.nodeValue;\n }\n str += JSON.stringify(attrs);\n } else {\n str += \"{}\";\n }\n\n str += \", [\";\n if (item.childNodes && item.childNodes.length > 0) {\n str += `${domToHyperscript(item.childNodes as unknown as Element[], depth + 1)}\\n${spaces}`;\n }\n\n str += `])`;\n return str;\n }\n })\n .join(\",\");\n}\n\ninterface ObjectIndexItem {\n tagName: string;\n startsAt: number;\n endsAt: number | null;\n contentStartsAt: number;\n contentEndsAt: number | null;\n attributes: { [key: string]: any };\n children: ObjectIndexItem[];\n nodeValue: string | null;\n}\n\ninterface ObjectIndexItemWithContent extends ObjectIndexItem {\n endsAt: number;\n contentEndsAt: number;\n children: ObjectIndexItemWithContent[];\n}\n\ninterface ObjectIndexList extends Array<ObjectIndexItem> {}\n\nfunction findTexts(item: ObjectIndexItemWithContent, html: string) {\n let newChildren: ObjectIndexItemWithContent[] = [];\n\n // If the item has children\n if (item.children.length) {\n // Search for texts in the children.\n for (let i = 0; i < item.children.length; i++) {\n let child = item.children[i];\n let nextChild = item.children[i + 1];\n\n // If is the first child and the child startsAt is greater than the item contentStartsAt then\n // the content between the item contentStartsAt and the child startsAt is a text child of the item.\n if (i === 0 && child.startsAt > item.contentStartsAt) {\n let childContent = html.substring(item.contentStartsAt, child.startsAt);\n\n let childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: item.contentStartsAt,\n endsAt: item.contentStartsAt + childContent.length,\n contentStartsAt: item.contentStartsAt,\n contentEndsAt: item.contentStartsAt + childContent.length,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n\n // Add the child to the newChildren array.\n newChildren.push(child);\n\n // If there is a next child and the child endsAt is less than the next child startsAt then\n // the content between the child endsAt and the next child startsAt is a text child of the item.\n if (nextChild && child.endsAt < nextChild.startsAt) {\n let childContent = html.substring(child.endsAt, nextChild.startsAt);\n\n let childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: child.endsAt,\n endsAt: child.endsAt + childContent.length,\n contentStartsAt: child.endsAt,\n contentEndsAt: child.endsAt + childContent.length,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n\n // If there are no next child and the child endsAt is less than the item contentEndsAt then\n // the content between the child endsAt and the item contentEndsAt is a text child of the item.\n if (!nextChild && child.endsAt < item.contentEndsAt) {\n let childContent = html.substring(child.endsAt, item.contentEndsAt);\n\n let childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: child.endsAt,\n endsAt: child.endsAt + childContent.length,\n contentStartsAt: child.endsAt,\n contentEndsAt: item.contentEndsAt,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n\n // Find texts in the child.\n findTexts(child, html);\n }\n }\n\n // If the item has no children then set the contents between the item contentStartsAt and the item contentEndsAt\n // as a text child of the item.\n if (!item.children.length) {\n let childContent = html.substring(item.contentStartsAt, item.contentEndsAt);\n\n if (childContent.length) {\n let childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: item.contentStartsAt,\n endsAt: item.contentEndsAt,\n contentStartsAt: item.contentStartsAt,\n contentEndsAt: item.contentEndsAt,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n }\n\n item.children = newChildren;\n}\n\nfunction convertToDom<T extends Node>(item: ObjectIndexItemWithContent): T {\n let node: T;\n\n if (item.tagName === \"#text\") {\n node = document.createTextNode(item.nodeValue as string) as unknown as T;\n } else {\n node = (item.tagName === \"#document-fragment\"\n ? document.createDocumentFragment()\n : document.createElement(item.tagName)) as unknown as T;\n\n for (let key in item.attributes) {\n node.setAttribute(key, item.attributes[key]);\n }\n\n for (let i = 0; i < item.children.length; i++) {\n let child = convertToDom(item.children[i]);\n node.appendChild(child);\n }\n }\n\n return node;\n}\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nfunction getObjectIndexTree(html: string): DocumentFragment {\n let item;\n let regex = RegExp(\"<([^>|^!]+)>\", \"g\");\n let items: ObjectIndexList = [];\n\n // Make the initial list of items.\n while ((item = regex.exec(html))) {\n // If is a closing tag\n if (item[0].startsWith(\"</\")) {\n let lastOpenedItem = [...items].reverse().find((item) => item.endsAt === null);\n if (lastOpenedItem) {\n lastOpenedItem.endsAt = item.index + item[0].length;\n lastOpenedItem.contentEndsAt = item.index;\n\n // Find the last opened item again, this will be the parent of the current item.\n let parent = [...items].reverse().find((item) => item.endsAt === null);\n if (parent) {\n // Find the index of the current item in the items array.\n let index = items.indexOf(lastOpenedItem);\n // Remove the last opened item from the items array.\n items.splice(index, 1);\n\n // Add the last opened item as a child of the parent.\n parent.children.push(lastOpenedItem);\n }\n }\n\n continue;\n }\n\n // If is an opening tag\n let element: ObjectIndexItem = {\n tagName: item[1].split(\" \")[0],\n startsAt: item.index,\n endsAt: null,\n contentStartsAt: item.index + item[0].length,\n contentEndsAt: null,\n attributes: {},\n children: [],\n nodeValue: null\n };\n\n // Find the attributes of the tag.\n let string = (item[1] || \"\").substring(element.tagName.length + 1).replace(/\\/$/g, \"\");\n let attributesWithValues = string.match(/\\S+=\"[^\"]+\"/g);\n\n if (attributesWithValues) {\n for (let attribute of attributesWithValues) {\n const [name, ...value] = attribute.trim().split(\"=\");\n string = string.replace(attribute, \"\");\n if (value) {\n element.attributes[name] = value.join(\"=\").replace(/(^\"|\"$)/g, \"\");\n }\n }\n }\n\n let attributesWithBooleanValues = string.match(/\\s\\S+=[^\"]+/g);\n if (attributesWithBooleanValues) {\n for (let attribute of attributesWithBooleanValues) {\n const [name, ...value] = attribute.trim().split(\"=\");\n string = string.replace(attribute, \"\");\n if (value) {\n element.attributes[name] = value.join(\"=\").replace(/(^\"|\"$)/g, \"\");\n }\n }\n }\n\n let attributesWithEmptyValues = string.match(/\\s?\\S+/g);\n if (attributesWithEmptyValues) {\n for (let attribute of attributesWithEmptyValues) {\n const name = attribute.trim();\n element.attributes[name] = true;\n }\n }\n\n // If the tag is self closing\n if (item[0].endsWith(\"/>\")) {\n element.endsAt = element.startsAt + item[0].length;\n element.contentStartsAt = element.contentEndsAt = element.endsAt;\n\n // Find the last opened item, this will be the parent of the current item.\n let parent = [...items].reverse().find((item) => item.endsAt === null);\n if (parent) {\n // Add the last opened item as a child of the parent.\n parent.children.push(element);\n continue;\n }\n }\n\n items.push(element);\n }\n\n let fragmentItem: ObjectIndexItemWithContent = {\n tagName: \"#document-fragment\",\n startsAt: 0,\n endsAt: html.length,\n contentStartsAt: 0,\n contentEndsAt: html.length,\n attributes: {},\n children: items as ObjectIndexItemWithContent[],\n nodeValue: null\n };\n\n findTexts(fragmentItem, html);\n\n return convertToDom<DocumentFragment>(fragmentItem);\n}\n\n// First we create a tree of object indexes from the HTML string.\n// The resulting array is then reordered to match the order of the html string.\n// And to move the children to the correct position in its parents.\n// This resulting array is populated with a object node version of the object index.\n// If the final result have more than 1 node, then return a document fragment node.\n// If the final result have 1 node, then return the node.\n// eslint-disable-next-line complexity\nexport function htmlToDom(html: string): Element | Text | DocumentFragment {\n // Search for the opening and closing tags of the root element.\n // The opening tag could be in the middle of the string, so we need to\n // search for the first opening tag.\n const openingTag = html.match(/<[^>]+>/g);\n\n let document = new Document();\n\n // If the opening tag is not found, return a document fragment node with the html string as text content.\n if (!openingTag) {\n let documentFragment = document.createDocumentFragment();\n documentFragment.appendChild(document.createTextNode(html));\n return documentFragment;\n }\n\n let fragment = getObjectIndexTree(html);\n\n if (fragment.childNodes.length > 1) {\n return fragment;\n }\n\n return fragment.childNodes[0];\n}\n\nexport function htmlToHyperscript(html: string) {\n let domTree = htmlToDom(html);\n let hyperscript = domToHyperscript(domTree instanceof DocumentFragment ? domTree.childNodes : [domTree]);\n return `[${hyperscript}\\n]`;\n}\n\nexport const document = new Document();\n", "import fs from \"fs\";\nimport { htmlToHyperscript } from \"./tree-adapter\";\n\ninterface IconsOptions {\n iconsPath: string | null;\n linksViewPath: string | null;\n logging: boolean;\n\n // favicons options\n path: string;\n appName?: string;\n appDescription?: string;\n developerName?: string;\n developerURL?: string;\n dir?: \"auto\" | \"ltr\" | \"rtl\";\n lang?: string;\n background?: string;\n theme_color?: string;\n display?: \"browser\" | \"standalone\";\n orientation?: \"any\" | \"portrait\" | \"landscape\";\n start_url?: string;\n version?: string;\n icons: {\n android: boolean;\n appleIcon: boolean;\n appleStartup: boolean;\n coast: boolean;\n favicons: boolean;\n firefox: boolean;\n windows: boolean;\n yandex: boolean;\n };\n}\n\nexport async function icons(source: string, configuration?: IconsOptions) {\n let options = {\n ...icons.options,\n ...(configuration || {})\n };\n\n if (options.iconsPath) {\n options.iconsPath = options.iconsPath.replace(/\\/$/gi, \"\") + \"/\";\n }\n\n if (options.linksViewPath) {\n options.linksViewPath = options.linksViewPath.replace(/\\/$/gi, \"\") + \"/\";\n }\n\n const { favicons } = await import(\"favicons\");\n\n try {\n let response = await favicons(source, options);\n\n if (options.iconsPath) {\n for (let i in response.images) {\n fs.writeFileSync(options.iconsPath + response.images[i].name, response.images[i].contents);\n }\n\n for (let i in response.files) {\n fs.writeFileSync(options.iconsPath + response.files[i].name, response.files[i].contents);\n }\n }\n\n if (options.linksViewPath) {\n let html = `\n function Links(){\n return ${htmlToHyperscript(response.html.join(\"\"))};\n }\n \n Links.default = Links;\n module.exports = Links;\n `;\n\n fs.writeFileSync(`${options.linksViewPath}/links.js`, html);\n }\n } catch (err) {\n process.stdout.write((err as any).status + \"\\n\"); // HTTP error code (e.g. `200`) or `null`\n process.stdout.write((err as any).name + \"\\n\"); // Error name e.g. \"API Error\"\n process.stdout.write((err as any).message + \"\\n\"); // Error description e.g. \"An unknown error has occurred\"\n }\n}\n\nicons.options = {\n iconsPath: null,\n linksViewPath: null,\n\n // favicons options\n path: \"\",\n appName: null,\n appDescription: null,\n developerName: null,\n developerURL: null,\n dir: \"auto\",\n lang: \"en-US\",\n background: \"#fff\",\n theme_color: \"#fff\",\n display: \"standalone\",\n orientation: \"any\",\n start_url: \"/\",\n version: \"1.0\",\n logging: false,\n icons: {\n android: true,\n appleIcon: true,\n appleStartup: true,\n coast: false,\n favicons: true,\n firefox: false,\n windows: true,\n yandex: false // Create Yandex browser icon. `boolean`\n }\n} as unknown as IconsOptions;\n", "import * as tsc from \"tsc-prog\";\n\nimport CleanCSS from \"clean-css\";\nimport { PurgeCSS } from \"purgecss\";\nimport esbuild from \"esbuild\";\n/* eslint-disable sonarjs/cognitive-complexity */\nimport fs from \"fs\";\n\nexport async function inline(file: string | { raw: string; map?: string | null; file: string }, options: Record<string, any> = {}) {\n if (typeof file === \"string\") {\n let ext = file.split(\".\").pop();\n if (ext && /(js|cjs|jsx|mjs|ts|tsx)/.test(ext)) {\n if (/(ts|tsx)/.test(ext) && !options.noValidate) {\n let declarationDir = options.declarationDir;\n let emitDeclaration = !!declarationDir;\n\n let tscProgOptions = {\n basePath: process.cwd(), // always required, used for relative paths\n configFilePath: \"tsconfig.json\", // config to inherit from (optional)\n files: [file],\n include: [\"**/*.ts\", \"**/*.js\", \"**/*.tsx\", \"**/*.jsx\", \"**/*.mjs\"],\n exclude: [\"test*/**/*\", \"**/*.test.ts\", \"**/*.spec.ts\", \"dist/**\"],\n pretty: true,\n copyOtherToOutDir: false,\n clean: emitDeclaration ? [declarationDir] : [],\n ...(options.tsc || {}),\n compilerOptions: {\n rootDir: \"./\",\n outDir: \"dist\",\n noEmitOnError: true,\n noEmit: !emitDeclaration,\n declaration: emitDeclaration,\n declarationDir,\n emitDeclarationOnly: emitDeclaration,\n allowJs: true,\n esModuleInterop: true,\n inlineSourceMap: true,\n resolveJsonModule: true,\n removeComments: true,\n ...(options.tsc || {}).compilerOptions\n },\n jsxFactory: \"v\",\n jsxFragment: \"v.fragment\"\n };\n\n // eslint-disable-next-line no-console\n console.log(\"tsc\", tscProgOptions);\n\n tsc.build(tscProgOptions);\n }\n\n let esbuildOptions = {\n entryPoints: [file],\n bundle: \"bundle\" in options ? options.bundle : true,\n sourcemap: \"external\",\n write: false,\n minify: options.compact,\n outdir: \"out\",\n target: \"esnext\",\n jsxFactory: \"v\",\n jsxFragment: \"v.fragment\",\n loader: {\n \".js\": \"jsx\",\n \".cjs\": \"jsx\",\n \".mjs\": \"jsx\",\n \".ts\": \"tsx\"\n },\n ...(options.esbuild || {})\n };\n\n let result = await esbuild.build(esbuildOptions);\n\n if (options.compact) {\n const terser = await import(\"terser\");\n let result2 = await terser.minify(result.outputFiles[1].text, {\n sourceMap: {\n content: result.outputFiles[0].text.toString()\n },\n compress: {\n booleans_as_integers: false\n },\n output: {\n wrap_func_args: false\n },\n ecma: 2022,\n ...(options.terser || {})\n });\n\n let mapBase64 = Buffer.from(result2.map.toString()).toString(\"base64\");\n let suffix = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${mapBase64}`;\n return { raw: result2.code, map: suffix, file };\n } else {\n let mapBase64 = Buffer.from(result.outputFiles[0].text.toString()).toString(\"base64\");\n let suffix = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${mapBase64}`;\n return { raw: result.outputFiles[1].text, map: suffix, file };\n }\n } else if (ext && /(css|scss|styl)/.test(ext)) {\n let result = await new CleanCSS({\n sourceMap: true,\n level: {\n 1: {\n roundingPrecision: \"all=3\"\n },\n 2: {\n restructureRules: true // controls rule restructuring; defaults to false\n }\n },\n ...(options.cleanCss || {})\n }).minify([file]);\n\n return { raw: result.styles, map: null, file };\n } else {\n return { raw: fs.readFileSync(file, \"utf8\"), map: null, file };\n }\n } else if (typeof file === \"object\" && \"raw\" in file) {\n return { map: null, ...file };\n }\n}\n\ninline.uncss = async function (renderedHtml: (string | Promise<string>)[], css: string, options: Record<string, any> = {}) {\n let html = await Promise.all(renderedHtml);\n\n let contents = html.map((item) => {\n return {\n raw: item,\n extension: \"html\"\n };\n });\n\n let purgecss = new PurgeCSS();\n\n let output = await purgecss.purge({\n fontFace: true,\n keyframes: true,\n variables: true,\n defaultExtractor: (content) => content.match(/[A-Za-z0-9-_/:@]*[A-Za-z0-9-_/:@/]+/g) || [],\n ...options,\n content: contents,\n css: [{ raw: css }]\n });\n\n let cleanCss = await new CleanCSS({\n sourceMap: false,\n level: {\n 1: {\n roundingPrecision: \"all=3\"\n },\n 2: {\n restructureRules: true // controls rule restructuring; defaults to false\n }\n },\n ...(options.cleanCss || {})\n }).minify(output[0].css);\n\n return cleanCss.styles;\n};\n", "import fs from \"fs\";\nimport path from \"path\";\n\nexport function sw(file: string, options = {}) {\n let swfiletemplate = path.resolve(__dirname, \"./node.sw.tpl\");\n let swTpl = fs.readFileSync(swfiletemplate, \"utf8\");\n let opt = Object.assign(\n {\n version: \"v1::\",\n name: \"Valyrian.js\",\n urls: [\"/\"],\n debug: false\n },\n options\n );\n let contents = swTpl\n .replace(\"v1::\", \"v\" + opt.version + \"::\")\n .replace(\"Valyrian.js\", opt.name)\n .replace(\"['/']\", '[\"' + opt.urls.join('\",\"') + '\"]');\n\n if (!opt.debug) {\n contents = contents.replace(\"console.log\", \"() => {}\");\n }\n\n fs.writeFileSync(file, contents, \"utf8\");\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,IAAM,OAAN,MAAM,MAAqB;AAAA;AAAA,EAEhC,aAAyB,CAAC;AAAA,EAC1B,UAAkB;AAAA,EAElB;AAAA,EACA,IAAI,WAAmB;AACrB,WAAO,KAAK,SAAS,YAAY;AAAA,EACnC;AAAA,EACA,IAAI,SAAS,MAAc;AACzB,SAAK,WAAW;AAAA,EAClB;AAAA,EACA,IAAI,UAAkB;AACpB,WAAO,KAAK;AAAA,EACd;AAAA,EACA,IAAI,QAAQ,MAAc;AACxB,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA;AAAA,EACA,IAAI,WAAmB;AACrB,WAAO,KAAK;AAAA,EACd;AAAA,EACA,IAAI,SAAS,MAAc;AACzB,SAAK,YAAY;AAAA,EACnB;AAAA,EAEA,aAAa;AAAA,EACb,aAAqB,CAAC;AAAA,EACtB,IAAI,YAAY,MAAM;AACpB,SAAK,aAAa,OAAO,IAAI;AAAA,EAC/B;AAAA,EACA,IAAI,cAAc;AAChB,WAAO,KAAK;AAAA,EACd;AAAA,EACA,IAAI,UAAU,MAAM;AAClB,SAAK,aAAa,OAAO,IAAI;AAAA,EAC/B;AAAA,EACA,IAAI,YAAY;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SAAS,OAAO,IAAI,KAAK,KAAK,KAAK,IAAI,IAAI;AAEtD,MAAI,CAAC,IAAI,OAAO;AACd,eAAW,SAAS,QAAQ,eAAe,UAAU;AAAA,EACvD;AAEA,aAAAA,QAAG,cAAc,MAAM,UAAU,MAAM;AACzC;;;AJhBA,OAAO,WAAW,iBAAAC;AAClB,OAAO,WAAW;AAElB,SAAS,UAAU,MAAa;AAC9B,MAAI,YAAY,MAAM;AACtB,MAAI,aAAS,uBAAM,OAAO,SAAS;AACnC,+BAAQ;AACR,SAAO;AACT;",
6
+ "names": ["node", "item", "document", "fs", "import_fs", "esbuild", "CleanCSS", "fs", "import_fs", "path", "fs", "FormData"]
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../lib/node/utils/tree-adapter.ts", "../../lib/node/index.ts", "../../lib/node/utils/icons.ts", "../../lib/node/utils/inline.ts", "../../lib/node/utils/sw.ts"],
4
+ "sourcesContent": ["/* eslint-disable no-use-before-define */\n/* eslint-disable complexity */\ninterface ChildNodes extends Array<Node | Element | Text | DocumentFragment> {}\n\nexport class Node implements Node {\n // eslint-disable-next-line no-use-before-define\n childNodes: ChildNodes = [];\n baseURI: string = \"\";\n\n tag_name!: string;\n get nodeName(): string {\n return this.tag_name.toLowerCase();\n }\n set nodeName(name: string) {\n this.tag_name = name;\n }\n get tagName(): string {\n return this.tag_name;\n }\n set tagName(name: string) {\n this.tag_name = name;\n }\n\n node_type!: number;\n get nodeType(): number {\n return this.node_type;\n }\n set nodeType(type: number) {\n this.node_type = type;\n }\n\n node_value = \"\";\n attributes: Attr[] = [];\n set textContent(text) {\n this.node_value = String(text);\n }\n get textContent() {\n return this.node_value;\n }\n set nodeValue(text) {\n this.node_value = String(text);\n }\n get nodeValue() {\n return this.node_value;\n }\n\n // eslint-disable-next-line no-use-before-define\n parent_node: Node | null = null;\n get parentNode() {\n return this.parent_node;\n }\n set parentNode(node) {\n this.parent_node = node;\n }\n\n constructor() {}\n\n appendChild<T extends Node>(node: T): T {\n node.parentNode && node.parentNode.removeChild(node as Node);\n this.childNodes.push(node);\n node.parentNode = this;\n return node;\n }\n\n insertBefore<T extends Node>(node: T, child: Node | null): T {\n node.parentNode && node.parentNode.removeChild(node as Node);\n node.parentNode = this;\n if (child) {\n let idx = this.childNodes.indexOf(child);\n this.childNodes.splice(idx, 0, node);\n } else {\n this.childNodes.push(node);\n }\n return node;\n }\n\n replaceChild<T extends Node>(node: Node, child: T): T {\n if (child && child.parentNode === this) {\n this.insertBefore(node, child);\n child.parentNode && child.parentNode.removeChild(child);\n }\n return child;\n }\n removeChild<T extends Node>(child: T): T {\n if (child && child.parentNode === this) {\n let idx = (this.childNodes as unknown as Node[]).indexOf(child);\n (this.childNodes as unknown as Node[]).splice(idx, 1);\n child.parentNode = null;\n }\n return child;\n }\n cloneNode(deep?: boolean | undefined): Node {\n if (this.nodeType === 3) {\n return new Text(this.nodeValue);\n }\n\n if (this.nodeType === 1) {\n let node = new Element();\n node.nodeType = this.nodeType;\n this.nodeName = this.nodeName;\n if (this.attributes) {\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n node.setAttribute(this.attributes[i].nodeName, this.attributes[i].nodeValue);\n }\n }\n if (deep) {\n for (let i = 0, l = this.childNodes.length; i < l; i++) {\n node.appendChild(this.childNodes[i].cloneNode(deep));\n }\n }\n return node;\n }\n\n let node = new Node();\n node.nodeType = this.nodeType;\n node.nodeName = this.nodeName;\n return node;\n }\n\n setAttribute(name: string, value: any) {\n let attr = {\n nodeName: name,\n nodeValue: value\n };\n let idx = -1;\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n if (this.attributes[i].nodeName === name) {\n idx = i;\n break;\n }\n }\n idx === -1 ? this.attributes.push(attr as Attr) : this.attributes.splice(idx, 1, attr as Attr);\n }\n\n getAttribute(name: string) {\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n if (this.attributes[i].nodeName === name) {\n return this.attributes[i].nodeValue;\n }\n }\n }\n\n removeAttribute(name: string) {\n let idx = -1;\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n if (this.attributes[i].nodeName === name) {\n idx = i;\n break;\n }\n }\n if (idx > -1) {\n this.attributes.splice(idx, 1);\n }\n }\n\n getElementById(id: string): Node | null {\n let elementFound;\n for (let i = 0, l = this.childNodes.length; i < l; i++) {\n if (this.childNodes[i].nodeType === 1) {\n if (this.childNodes[i].getAttribute(\"id\") === id) {\n elementFound = this.childNodes[i];\n break;\n }\n elementFound = this.childNodes[i].getElementById(id);\n if (elementFound) {\n break;\n }\n }\n }\n return elementFound || null;\n }\n\n // Not implemented\n // firstChild!: ChildNode | null;\n // isConnected!: boolean;\n // lastChild!: ChildNode | null;\n // nextSibling!: ChildNode | null;\n // ownerDocument!: Document | null;\n // parentElement!: HTMLElement | null;\n // previousSibling!: ChildNode | null;\n // compareDocumentPosition(other: Node): number {\n // throw new Error(\"Method not implemented.\");\n // }\n // contains(other: Node | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // getRootNode(options?: GetRootNodeOptions | undefined): Node {\n // throw new Error(\"Method not implemented.\");\n // }\n // hasChildNodes(): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // isDefaultNamespace(namespace: string | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // isEqualNode(otherNode: Node | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // isSameNode(otherNode: Node | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // lookupNamespaceURI(prefix: string | null): string | null {\n // throw new Error(\"Method not implemented.\");\n // }\n // lookupPrefix(namespace: string | null): string | null {\n // throw new Error(\"Method not implemented.\");\n // }\n // normalize(): void {\n // throw new Error(\"Method not implemented.\");\n // }\n // ATTRIBUTE_NODE!: number;\n // CDATA_SECTION_NODE!: number;\n // COMMENT_NODE!: number;\n // DOCUMENT_FRAGMENT_NODE!: number;\n // DOCUMENT_NODE!: number;\n // DOCUMENT_POSITION_CONTAINED_BY!: number;\n // DOCUMENT_POSITION_CONTAINS!: number;\n // DOCUMENT_POSITION_DISCONNECTED!: number;\n // DOCUMENT_POSITION_FOLLOWING!: number;\n // DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC!: number;\n // DOCUMENT_POSITION_PRECEDING!: number;\n // DOCUMENT_TYPE_NODE!: number;\n // ELEMENT_NODE!: number;\n // ENTITY_NODE!: number;\n // ENTITY_REFERENCE_NODE!: number;\n // NOTATION_NODE!: number;\n // PROCESSING_INSTRUCTION_NODE!: number;\n // TEXT_NODE!: number;\n addEventListener(\n // eslint-disable-next-line no-unused-vars\n type: string,\n // eslint-disable-next-line no-unused-vars\n callback: EventListenerOrEventListenerObject | null,\n // eslint-disable-next-line no-unused-vars\n options?: boolean | AddEventListenerOptions | undefined\n ): void {\n // throw new Error(\"Method not implemented.\");\n }\n // dispatchEvent(event: Event): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n removeEventListener(\n // eslint-disable-next-line no-unused-vars\n type: string,\n // eslint-disable-next-line no-unused-vars\n callback: EventListenerOrEventListenerObject | null,\n // eslint-disable-next-line no-unused-vars\n options?: boolean | EventListenerOptions | undefined\n ): void {\n // throw new Error(\"Method not implemented.\");\n }\n}\n\nexport class Text extends Node {\n constructor(text: any) {\n super();\n this.nodeType = 3;\n this.nodeName = \"#text\";\n this.node_value = String(text);\n }\n}\n\nfunction updateElementStyles(element: Element, state: Record<string, any>) {\n let str = \"\";\n for (let key in state) {\n let value = state[key];\n if (typeof value !== \"undefined\" && value !== null && String(value).length > 0) {\n str += `${key}: ${state[key]};`;\n }\n }\n if (str.length === 0) {\n element.removeAttribute(\"style\");\n } else {\n element.setAttribute(\"style\", str);\n }\n}\n\nexport class Element extends Node {\n constructor() {\n super();\n this.nodeType = 1;\n this.attributes = [];\n this.childNodes = [];\n }\n\n _style = new Proxy(\n {},\n {\n get: (state: Record<string, any>, prop: string) => state[prop],\n set: (state: Record<string, any>, prop: string, value: any) => {\n state[prop] = value;\n updateElementStyles(this, state);\n return true;\n },\n deleteProperty: (state: Record<string, any>, prop: string) => {\n Reflect.deleteProperty(state, prop);\n updateElementStyles(this, state);\n return true;\n }\n }\n );\n\n get style() {\n return this._style as any;\n }\n\n set style(value: string) {\n if (typeof value === \"string\") {\n // should match pairs like \"color: red; font-size: 12px; background: url(http://example.com/image.png?s=1024x1024&amp;w=is&amp;k=20&amp;c=ASa_AG8uP5Di7azXgJraSA6ME7fbLB0GX4YT_OzCARI=);\"\n const regex = /([^:\\s]+):\\s*((url\\([^)]+\\))|[^;]+(?=(;|$)))/g;\n let match;\n\n while ((match = regex.exec(value)) !== null) {\n this._style[match[1]] = match[2].trim();\n }\n\n return;\n }\n\n throw new Error(\"Cannot set style\");\n }\n\n classList = {\n toggle: (item: any, force: any) => {\n if (item) {\n let classes = (this.getAttribute(\"class\") || \"\").split(\" \");\n let itemIndex = classes.indexOf(item);\n if (force && itemIndex === -1) {\n classes.push(item);\n }\n\n if (!force && itemIndex !== -1) {\n classes.splice(itemIndex, 1);\n }\n\n let final = classes.join(\" \").trim();\n if (final.length) {\n this.setAttribute(\"class\", classes.join(\" \").trim());\n } else {\n this.removeAttribute(\"class\");\n }\n }\n }\n };\n\n set textContent(text) {\n this.nodeValue = String(text);\n this.childNodes = this.nodeValue ? [new Text(this.nodeValue)] : [];\n }\n get textContent() {\n return this.nodeValue;\n }\n\n set innerText(text) {\n this.nodeValue = String(text);\n }\n\n get innerText() {\n return this.nodeValue;\n }\n\n get innerHTML() {\n let str = \"\";\n for (let i = 0, l = this.childNodes.length; i < l; i++) {\n // console.log(\"domToHtml\", this.childNodes[i], domToHtml(this.childNodes[i] as Element));\n str += domToHtml(this.childNodes[i] as Element);\n }\n return str;\n }\n\n set innerHTML(html) {\n this.textContent = \"\";\n let result = htmlToDom(html);\n if (result instanceof DocumentFragment) {\n for (let i = 0, l = result.childNodes.length; i < l; i++) {\n this.appendChild(result.childNodes[i]);\n }\n } else {\n this.appendChild(result);\n }\n }\n\n get outerHTML(): string {\n return domToHtml(this);\n }\n}\n\nexport class DocumentFragment extends Element {\n constructor() {\n super();\n this.nodeType = 11;\n this.nodeName = \"#document-fragment\";\n }\n}\n\nexport class Document extends Element {\n constructor() {\n super();\n this.nodeType = 9;\n this.nodeName = \"#document\";\n }\n\n createDocumentFragment(): DocumentFragment {\n return new DocumentFragment();\n }\n\n createElement(type: string) {\n let element = new Element();\n element.nodeName = type.toUpperCase();\n return element;\n }\n\n createElementNS(ns: string, type: string) {\n let element = this.createElement(type);\n element.baseURI = ns;\n return element;\n }\n\n createTextNode(text: any) {\n return new Text(text);\n }\n}\n\nlet selfClosingTags = [\n \"area\",\n \"base\",\n \"br\",\n \"col\",\n \"embed\",\n \"hr\",\n \"img\",\n \"input\",\n \"link\",\n \"meta\",\n \"param\",\n \"source\",\n \"track\",\n \"wbr\",\n \"!doctype\"\n];\n\nexport function domToHtml(dom: Element): string {\n if (dom.nodeType === 3) {\n return dom.textContent;\n }\n\n if (dom.nodeType === 1) {\n let name = dom.nodeName.toLowerCase();\n let str = \"<\" + name;\n for (let i = 0, l = dom.attributes.length; i < l; i++) {\n str += \" \" + dom.attributes[i].nodeName + '=\"' + dom.attributes[i].nodeValue + '\"';\n }\n\n if (selfClosingTags.indexOf(name) === -1) {\n str += \">\";\n if (dom.childNodes && dom.childNodes.length > 0) {\n for (let i = 0, l = dom.childNodes.length; i < l; i++) {\n let child = domToHtml(dom.childNodes[i] as Element);\n if (child) {\n str += child;\n }\n }\n }\n str += \"</\" + name + \">\";\n } else {\n str += \"/>\";\n }\n\n return str;\n }\n\n return \"\";\n}\n\nexport function domToHyperscript(childNodes: ChildNodes, depth = 1) {\n let spaces = \"\";\n for (let i = 0; i < depth; i++) {\n spaces += \" \";\n }\n\n return childNodes\n .map((item) => {\n if (item.nodeType === 10) {\n return `\\n${spaces}\"<!DOCTYPE html>\"`;\n } else if (item.nodeType === 3) {\n return `\\n${spaces}\"${item.nodeValue}\"`;\n } else {\n let str = `\\n${spaces}v(\"${item.nodeName}\", `;\n\n if (item.attributes) {\n let attrs: Record<string, any> = {};\n for (let i = 0, l = item.attributes.length; i < l; i++) {\n let attr = item.attributes[i];\n attrs[attr.nodeName] = attr.nodeValue;\n }\n str += JSON.stringify(attrs);\n } else {\n str += \"{}\";\n }\n\n str += \", [\";\n if (item.childNodes && item.childNodes.length > 0) {\n str += `${domToHyperscript(item.childNodes as unknown as Element[], depth + 1)}\\n${spaces}`;\n }\n\n str += `])`;\n return str;\n }\n })\n .join(\",\");\n}\n\ninterface ObjectIndexItem {\n tagName: string;\n startsAt: number;\n endsAt: number | null;\n contentStartsAt: number;\n contentEndsAt: number | null;\n attributes: { [key: string]: any };\n children: ObjectIndexItem[];\n nodeValue: string | null;\n}\n\ninterface ObjectIndexItemWithContent extends ObjectIndexItem {\n endsAt: number;\n contentEndsAt: number;\n children: ObjectIndexItemWithContent[];\n}\n\ninterface ObjectIndexList extends Array<ObjectIndexItem> {}\n\nfunction findTexts(item: ObjectIndexItemWithContent, html: string) {\n let newChildren: ObjectIndexItemWithContent[] = [];\n\n // If the item has children\n if (item.children.length) {\n // Search for texts in the children.\n for (let i = 0; i < item.children.length; i++) {\n let child = item.children[i];\n let nextChild = item.children[i + 1];\n\n // If is the first child and the child startsAt is greater than the item contentStartsAt then\n // the content between the item contentStartsAt and the child startsAt is a text child of the item.\n if (i === 0 && child.startsAt > item.contentStartsAt) {\n let childContent = html.substring(item.contentStartsAt, child.startsAt);\n\n let childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: item.contentStartsAt,\n endsAt: item.contentStartsAt + childContent.length,\n contentStartsAt: item.contentStartsAt,\n contentEndsAt: item.contentStartsAt + childContent.length,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n\n // Add the child to the newChildren array.\n newChildren.push(child);\n\n // If there is a next child and the child endsAt is less than the next child startsAt then\n // the content between the child endsAt and the next child startsAt is a text child of the item.\n if (nextChild && child.endsAt < nextChild.startsAt) {\n let childContent = html.substring(child.endsAt, nextChild.startsAt);\n\n let childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: child.endsAt,\n endsAt: child.endsAt + childContent.length,\n contentStartsAt: child.endsAt,\n contentEndsAt: child.endsAt + childContent.length,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n\n // If there are no next child and the child endsAt is less than the item contentEndsAt then\n // the content between the child endsAt and the item contentEndsAt is a text child of the item.\n if (!nextChild && child.endsAt < item.contentEndsAt) {\n let childContent = html.substring(child.endsAt, item.contentEndsAt);\n\n let childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: child.endsAt,\n endsAt: child.endsAt + childContent.length,\n contentStartsAt: child.endsAt,\n contentEndsAt: item.contentEndsAt,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n\n // Find texts in the child.\n findTexts(child, html);\n }\n }\n\n // If the item has no children then set the contents between the item contentStartsAt and the item contentEndsAt\n // as a text child of the item.\n if (!item.children.length) {\n let childContent = html.substring(item.contentStartsAt, item.contentEndsAt);\n\n if (childContent.length) {\n let childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: item.contentStartsAt,\n endsAt: item.contentEndsAt,\n contentStartsAt: item.contentStartsAt,\n contentEndsAt: item.contentEndsAt,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n }\n\n item.children = newChildren;\n}\n\nfunction convertToDom<T extends Node>(item: ObjectIndexItemWithContent): T {\n let node: T;\n\n if (item.tagName === \"#text\") {\n node = document.createTextNode(item.nodeValue as string) as unknown as T;\n } else {\n node = (item.tagName === \"#document-fragment\"\n ? document.createDocumentFragment()\n : document.createElement(item.tagName)) as unknown as T;\n\n for (let key in item.attributes) {\n node.setAttribute(key, item.attributes[key]);\n }\n\n for (let i = 0; i < item.children.length; i++) {\n let child = convertToDom(item.children[i]);\n node.appendChild(child);\n }\n }\n\n return node;\n}\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nfunction getObjectIndexTree(html: string): DocumentFragment {\n let item;\n let regex = RegExp(\"<([^>|^!]+)>\", \"g\");\n let items: ObjectIndexList = [];\n\n // Make the initial list of items.\n while ((item = regex.exec(html))) {\n // If is a closing tag\n if (item[0].startsWith(\"</\")) {\n let lastOpenedItem = [...items].reverse().find((item) => item.endsAt === null);\n if (lastOpenedItem) {\n lastOpenedItem.endsAt = item.index + item[0].length;\n lastOpenedItem.contentEndsAt = item.index;\n\n // Find the last opened item again, this will be the parent of the current item.\n let parent = [...items].reverse().find((item) => item.endsAt === null);\n if (parent) {\n // Find the index of the current item in the items array.\n let index = items.indexOf(lastOpenedItem);\n // Remove the last opened item from the items array.\n items.splice(index, 1);\n\n // Add the last opened item as a child of the parent.\n parent.children.push(lastOpenedItem);\n }\n }\n\n continue;\n }\n\n // If is an opening tag\n let element: ObjectIndexItem = {\n tagName: item[1].split(\" \")[0],\n startsAt: item.index,\n endsAt: null,\n contentStartsAt: item.index + item[0].length,\n contentEndsAt: null,\n attributes: {},\n children: [],\n nodeValue: null\n };\n\n // Find the attributes of the tag.\n let string = (item[1] || \"\").substring(element.tagName.length + 1).replace(/\\/$/g, \"\");\n let attributesWithValues = string.match(/\\S+=\"[^\"]+\"/g);\n\n if (attributesWithValues) {\n for (let attribute of attributesWithValues) {\n const [name, ...value] = attribute.trim().split(\"=\");\n string = string.replace(attribute, \"\");\n if (value) {\n element.attributes[name] = value.join(\"=\").replace(/(^\"|\"$)/g, \"\");\n }\n }\n }\n\n let attributesWithBooleanValues = string.match(/\\s\\S+=[^\"]+/g);\n if (attributesWithBooleanValues) {\n for (let attribute of attributesWithBooleanValues) {\n const [name, ...value] = attribute.trim().split(\"=\");\n string = string.replace(attribute, \"\");\n if (value) {\n element.attributes[name] = value.join(\"=\").replace(/(^\"|\"$)/g, \"\");\n }\n }\n }\n\n let attributesWithEmptyValues = string.match(/\\s?\\S+/g);\n if (attributesWithEmptyValues) {\n for (let attribute of attributesWithEmptyValues) {\n const name = attribute.trim();\n element.attributes[name] = true;\n }\n }\n\n // If the tag is self closing\n if (item[0].endsWith(\"/>\")) {\n element.endsAt = element.startsAt + item[0].length;\n element.contentStartsAt = element.contentEndsAt = element.endsAt;\n\n // Find the last opened item, this will be the parent of the current item.\n let parent = [...items].reverse().find((item) => item.endsAt === null);\n if (parent) {\n // Add the last opened item as a child of the parent.\n parent.children.push(element);\n continue;\n }\n }\n\n items.push(element);\n }\n\n let fragmentItem: ObjectIndexItemWithContent = {\n tagName: \"#document-fragment\",\n startsAt: 0,\n endsAt: html.length,\n contentStartsAt: 0,\n contentEndsAt: html.length,\n attributes: {},\n children: items as ObjectIndexItemWithContent[],\n nodeValue: null\n };\n\n findTexts(fragmentItem, html);\n\n return convertToDom<DocumentFragment>(fragmentItem);\n}\n\n// First we create a tree of object indexes from the HTML string.\n// The resulting array is then reordered to match the order of the html string.\n// And to move the children to the correct position in its parents.\n// This resulting array is populated with a object node version of the object index.\n// If the final result have more than 1 node, then return a document fragment node.\n// If the final result have 1 node, then return the node.\n// eslint-disable-next-line complexity\nexport function htmlToDom(html: string): Element | Text | DocumentFragment {\n // Search for the opening and closing tags of the root element.\n // The opening tag could be in the middle of the string, so we need to\n // search for the first opening tag.\n const openingTag = html.match(/<[^>]+>/g);\n\n let document = new Document();\n\n // If the opening tag is not found, return a document fragment node with the html string as text content.\n if (!openingTag) {\n let documentFragment = document.createDocumentFragment();\n documentFragment.appendChild(document.createTextNode(html));\n return documentFragment;\n }\n\n let fragment = getObjectIndexTree(html);\n\n if (fragment.childNodes.length > 1) {\n return fragment;\n }\n\n return fragment.childNodes[0];\n}\n\nexport function htmlToHyperscript(html: string) {\n let domTree = htmlToDom(html);\n let hyperscript = domToHyperscript(domTree instanceof DocumentFragment ? domTree.childNodes : [domTree]);\n return `[${hyperscript}\\n]`;\n}\n\nexport const document = new Document();\n", "import { document, domToHtml, domToHyperscript, htmlToDom, htmlToHyperscript } from \"./utils/tree-adapter\";\nimport { mount, unmount } from \"valyrian.js\";\n\nimport FormData from \"form-data\";\n// import fetch from \"node-fetch\";\nimport { icons } from \"./utils/icons\";\nimport { inline } from \"./utils/inline\";\nimport { sw } from \"./utils/sw\";\n\nglobal.FormData = FormData as any;\nglobal.document = document as any;\n\nfunction render(...args: any[]) {\n let Component = () => args;\n let result = mount(\"div\", Component);\n unmount();\n return result;\n}\n\nexport { domToHtml, domToHyperscript, htmlToDom, htmlToHyperscript, inline, sw, icons, render };\n", "import fs from \"fs\";\nimport { htmlToHyperscript } from \"./tree-adapter\";\n\ninterface IconsOptions {\n iconsPath: string | null;\n linksViewPath: string | null;\n logging: boolean;\n\n // favicons options\n path: string;\n appName?: string;\n appDescription?: string;\n developerName?: string;\n developerURL?: string;\n dir?: \"auto\" | \"ltr\" | \"rtl\";\n lang?: string;\n background?: string;\n theme_color?: string;\n display?: \"browser\" | \"standalone\";\n orientation?: \"any\" | \"portrait\" | \"landscape\";\n start_url?: string;\n version?: string;\n icons: {\n android: boolean;\n appleIcon: boolean;\n appleStartup: boolean;\n coast: boolean;\n favicons: boolean;\n firefox: boolean;\n windows: boolean;\n yandex: boolean;\n };\n}\n\nexport async function icons(source: string, configuration?: IconsOptions) {\n let options = {\n ...icons.options,\n ...(configuration || {})\n };\n\n if (options.iconsPath) {\n options.iconsPath = options.iconsPath.replace(/\\/$/gi, \"\") + \"/\";\n }\n\n if (options.linksViewPath) {\n options.linksViewPath = options.linksViewPath.replace(/\\/$/gi, \"\") + \"/\";\n }\n\n const { favicons } = await import(\"favicons\");\n\n try {\n let response = await favicons(source, options);\n\n if (options.iconsPath) {\n for (let i in response.images) {\n fs.writeFileSync(options.iconsPath + response.images[i].name, response.images[i].contents);\n }\n\n for (let i in response.files) {\n fs.writeFileSync(options.iconsPath + response.files[i].name, response.files[i].contents);\n }\n }\n\n if (options.linksViewPath) {\n let html = `\n function Links(){\n return ${htmlToHyperscript(response.html.join(\"\"))};\n }\n \n Links.default = Links;\n module.exports = Links;\n `;\n\n fs.writeFileSync(`${options.linksViewPath}/links.js`, html);\n }\n } catch (err) {\n process.stdout.write((err as any).status + \"\\n\"); // HTTP error code (e.g. `200`) or `null`\n process.stdout.write((err as any).name + \"\\n\"); // Error name e.g. \"API Error\"\n process.stdout.write((err as any).message + \"\\n\"); // Error description e.g. \"An unknown error has occurred\"\n }\n}\n\nicons.options = {\n iconsPath: null,\n linksViewPath: null,\n\n // favicons options\n path: \"\",\n appName: null,\n appDescription: null,\n developerName: null,\n developerURL: null,\n dir: \"auto\",\n lang: \"en-US\",\n background: \"#fff\",\n theme_color: \"#fff\",\n display: \"standalone\",\n orientation: \"any\",\n start_url: \"/\",\n version: \"1.0\",\n logging: false,\n icons: {\n android: true,\n appleIcon: true,\n appleStartup: true,\n coast: false,\n favicons: true,\n firefox: false,\n windows: true,\n yandex: false // Create Yandex browser icon. `boolean`\n }\n} as unknown as IconsOptions;\n", "import * as tsc from \"tsc-prog\";\n\nimport CleanCSS from \"clean-css\";\nimport { PurgeCSS } from \"purgecss\";\nimport esbuild from \"esbuild\";\n/* eslint-disable sonarjs/cognitive-complexity */\nimport fs from \"fs\";\n\nexport async function inline(file: string | { raw: string; map?: string | null; file: string }, options: Record<string, any> = {}) {\n if (typeof file === \"string\") {\n let ext = file.split(\".\").pop();\n if (ext && /(js|cjs|jsx|mjs|ts|tsx)/.test(ext)) {\n if (/(ts|tsx)/.test(ext) && !options.noValidate) {\n let declarationDir = options.declarationDir;\n let emitDeclaration = !!declarationDir;\n\n let tscProgOptions = {\n basePath: process.cwd(), // always required, used for relative paths\n configFilePath: \"tsconfig.json\", // config to inherit from (optional)\n files: [file],\n include: [\"**/*.ts\", \"**/*.js\", \"**/*.tsx\", \"**/*.jsx\", \"**/*.mjs\"],\n exclude: [\"test*/**/*\", \"**/*.test.ts\", \"**/*.spec.ts\", \"dist/**\"],\n pretty: true,\n copyOtherToOutDir: false,\n clean: emitDeclaration ? [declarationDir] : [],\n ...(options.tsc || {}),\n compilerOptions: {\n rootDir: \"./\",\n outDir: \"dist\",\n noEmitOnError: true,\n noEmit: !emitDeclaration,\n declaration: emitDeclaration,\n declarationDir,\n emitDeclarationOnly: emitDeclaration,\n allowJs: true,\n esModuleInterop: true,\n inlineSourceMap: true,\n resolveJsonModule: true,\n removeComments: true,\n ...(options.tsc || {}).compilerOptions\n },\n jsxFactory: \"v\",\n jsxFragment: \"v.fragment\"\n };\n\n // eslint-disable-next-line no-console\n console.log(\"tsc\", tscProgOptions);\n\n tsc.build(tscProgOptions);\n }\n\n let esbuildOptions = {\n entryPoints: [file],\n bundle: \"bundle\" in options ? options.bundle : true,\n sourcemap: \"external\",\n write: false,\n minify: options.compact,\n outdir: \"out\",\n target: \"esnext\",\n jsxFactory: \"v\",\n jsxFragment: \"v.fragment\",\n loader: {\n \".js\": \"jsx\",\n \".cjs\": \"jsx\",\n \".mjs\": \"jsx\",\n \".ts\": \"tsx\"\n },\n ...(options.esbuild || {})\n };\n\n let result = await esbuild.build(esbuildOptions);\n\n if (options.compact) {\n const terser = await import(\"terser\");\n let result2 = await terser.minify(result.outputFiles[1].text, {\n sourceMap: {\n content: result.outputFiles[0].text.toString()\n },\n compress: {\n booleans_as_integers: false\n },\n output: {\n wrap_func_args: false\n },\n ecma: 2022,\n ...(options.terser || {})\n });\n\n let mapBase64 = Buffer.from(result2.map.toString()).toString(\"base64\");\n let suffix = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${mapBase64}`;\n return { raw: result2.code, map: suffix, file };\n } else {\n let mapBase64 = Buffer.from(result.outputFiles[0].text.toString()).toString(\"base64\");\n let suffix = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${mapBase64}`;\n return { raw: result.outputFiles[1].text, map: suffix, file };\n }\n } else if (ext && /(css|scss|styl)/.test(ext)) {\n let result = await new CleanCSS({\n sourceMap: true,\n level: {\n 1: {\n roundingPrecision: \"all=3\"\n },\n 2: {\n restructureRules: true // controls rule restructuring; defaults to false\n }\n },\n ...(options.cleanCss || {})\n }).minify([file]);\n\n return { raw: result.styles, map: null, file };\n } else {\n return { raw: fs.readFileSync(file, \"utf8\"), map: null, file };\n }\n } else if (typeof file === \"object\" && \"raw\" in file) {\n return { map: null, ...file };\n }\n}\n\ninline.uncss = async function (renderedHtml: (string | Promise<string>)[], css: string, options: Record<string, any> = {}) {\n let html = await Promise.all(renderedHtml);\n\n let contents = html.map((item) => {\n return {\n raw: item,\n extension: \"html\"\n };\n });\n\n let purgecss = new PurgeCSS();\n\n let output = await purgecss.purge({\n fontFace: true,\n keyframes: true,\n variables: true,\n defaultExtractor: (content) => content.match(/[A-Za-z0-9-_/:@]*[A-Za-z0-9-_/:@/]+/g) || [],\n ...options,\n content: contents,\n css: [{ raw: css }]\n });\n\n let cleanCss = await new CleanCSS({\n sourceMap: false,\n level: {\n 1: {\n roundingPrecision: \"all=3\"\n },\n 2: {\n restructureRules: true // controls rule restructuring; defaults to false\n }\n },\n ...(options.cleanCss || {})\n }).minify(output[0].css);\n\n return cleanCss.styles;\n};\n", "import fs from \"fs\";\nimport path from \"path\";\n\nexport function sw(file: string, options = {}) {\n let swfiletemplate = path.resolve(__dirname, \"./node.sw.tpl\");\n let swTpl = fs.readFileSync(swfiletemplate, \"utf8\");\n let opt = Object.assign(\n {\n version: \"v1::\",\n name: \"Valyrian.js\",\n urls: [\"/\"],\n debug: false\n },\n options\n );\n let contents = swTpl\n .replace(\"v1::\", \"v\" + opt.version + \"::\")\n .replace(\"Valyrian.js\", opt.name)\n .replace(\"['/']\", '[\"' + opt.urls.join('\",\"') + '\"]');\n\n if (!opt.debug) {\n contents = contents.replace(\"console.log\", \"() => {}\");\n }\n\n fs.writeFileSync(file, contents, \"utf8\");\n}\n"],
5
+ "mappings": ";AAIO,IAAM,OAAN,MAAM,MAAqB;AAAA;AAAA,EAEhC,aAAyB,CAAC;AAAA,EAC1B,UAAkB;AAAA,EAElB;AAAA,EACA,IAAI,WAAmB;AACrB,WAAO,KAAK,SAAS,YAAY;AAAA,EACnC;AAAA,EACA,IAAI,SAAS,MAAc;AACzB,S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C,EAAE,OAAO,OAAO,CAAC,EAAE,GAAG;AAEvB,SAAO,SAAS;AAClB;;;AC3JA,OAAOC,SAAQ;AACf,OAAO,UAAU;AAEV,SAAS,GAAG,MAAc,UAAU,CAAC,GAAG;AAC7C,MAAI,iBAAiB,KAAK,QAAQ,WAAW,eAAe;AAC5D,MAAI,QAAQA,IAAG,aAAa,gBAAgB,MAAM;AAClD,MAAI,MAAM,OAAO;AAAA,IACf;AAAA,MACE,SAAS;AAAA,MACT,MAAM;AAAA,MACN,MAAM,CAAC,GAAG;AAAA,MACV,OAAO;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACA,MAAI,WAAW,MACZ,QAAQ,QAAQ,MAAM,IAAI,UAAU,IAAI,EACxC,QAAQ,eAAe,IAAI,IAAI,EAC/B,QAAQ,SAAS,OAAO,IAAI,KAAK,KAAK,KAAK,IAAI,IAAI;AAEtD,MAAI,CAAC,IAAI,OAAO;AACd,eAAW,SAAS,QAAQ,eAAe,UAAU;AAAA,EACvD;AAEA,EAAAA,IAAG,cAAc,MAAM,UAAU,MAAM;AACzC;;;AHhBA,OAAO,WAAW;AAClB,OAAO,WAAW;AAElB,SAAS,UAAU,MAAa;AAC9B,MAAI,YAAY,MAAM;AACtB,MAAI,SAAS,MAAM,OAAO,SAAS;AACnC,UAAQ;AACR,SAAO;AACT;",
6
+ "names": ["node", "item", "document", "fs", "fs"]
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../lib/proxy-signal/index.ts"],
4
+ "sourcesContent": ["import { update } from \"valyrian.js\";\n\n/* eslint-disable no-use-before-define */\ninterface Cleanup {\n (): void;\n}\n\ninterface Subscription {\n // eslint-disable-next-line no-unused-vars\n (value: ProxySignal[\"value\"]): void | Cleanup;\n}\n\ninterface Subscriptions extends Map<Subscription, Cleanup> {}\n\ninterface Getter {\n // eslint-disable-next-line no-unused-vars\n (value: ProxySignal[\"value\"]): any;\n}\n\ninterface Getters {\n [key: string | symbol]: Getter;\n}\n\ninterface ProxySignal {\n // Works as a getter of the value\n (): ProxySignal[\"value\"];\n // Works as a subscription to the value\n // eslint-disable-next-line no-unused-vars\n (value: Subscription): ProxySignal;\n // Works as a setter with a path and a handler\n // eslint-disable-next-line no-unused-vars\n (path: string, handler: (valueAtPathPosition: any) => any): ProxySignal[\"value\"];\n // Works as a setter with a path and a value\n // eslint-disable-next-line no-unused-vars\n (path: string, value: any): ProxySignal[\"value\"];\n // Works as a setter with a value\n // eslint-disable-next-line no-unused-vars\n (value: any): ProxySignal[\"value\"];\n // Gets the current value of the signal.\n value: any;\n // Cleanup function to be called to remove all subscriptions.\n cleanup: () => void;\n // Creates a getter on the signal.\n // eslint-disable-next-line no-unused-vars\n getter: (name: string, handler: Getter) => any;\n // To access the getters on the signal.\n [key: string | number | symbol]: any;\n}\n\nfunction makeUnsubscribe(\n subscriptions: Subscriptions,\n computed: ProxySignal,\n handler: Subscription,\n cleanup?: Cleanup\n) {\n if (typeof cleanup === \"function\") {\n computed.cleanup = cleanup;\n }\n computed.unsubscribe = () => {\n subscriptions.delete(handler);\n computed?.cleanup();\n };\n}\n\nfunction createSubscription(signal: ProxySignal, subscriptions: Subscriptions, handler: Subscription) {\n if (subscriptions.has(handler) === false) {\n // eslint-disable-next-line no-use-before-define\n let computed = ProxySignal(() => handler(signal.value));\n let cleanup = computed(); // Execute to register itself\n makeUnsubscribe(subscriptions, computed, handler, cleanup);\n subscriptions.set(handler, computed);\n }\n\n return subscriptions.get(handler);\n}\n\nlet updateTimeout: any;\nfunction delayedUpdate() {\n clearTimeout(updateTimeout);\n updateTimeout = setTimeout(update);\n}\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport function ProxySignal(value: any): ProxySignal {\n let subscriptions = new Map();\n let getters: Getters = {};\n\n let forceUpdate = false;\n\n let signal: ProxySignal = new Proxy(\n // eslint-disable-next-line no-unused-vars\n function (valOrPath?: any | Subscription, handler?: (valueAtPathPosition: any) => any) {\n // Works as a getter\n if (typeof valOrPath === \"undefined\") {\n return signal.value;\n }\n\n // Works as a subscription\n if (typeof valOrPath === \"function\") {\n return createSubscription(signal, subscriptions, valOrPath);\n }\n\n // Works as a setter with a path\n if (typeof valOrPath === \"string\" && typeof handler !== \"undefined\") {\n let parsed = valOrPath.split(\".\");\n let result = signal.value;\n let next;\n while (parsed.length) {\n next = parsed.shift() as string;\n if (parsed.length > 0) {\n if (typeof result[next] !== \"object\") {\n result[next] = {};\n }\n result = result[next];\n } else {\n result[next] = typeof handler === \"function\" ? handler(result[next]) : handler;\n }\n }\n forceUpdate = true;\n signal.value = signal.value;\n return signal.value;\n }\n\n // Works as a setter with a value\n signal.value = valOrPath;\n return signal.value;\n } as ProxySignal,\n {\n set(state, prop, val) {\n if (prop === \"value\" || prop === \"unsubscribe\" || prop === \"cleanup\") {\n let old = state[prop];\n state[prop] = val;\n if (prop === \"value\" && (forceUpdate || val !== old)) {\n forceUpdate = false;\n for (let [handler, computed] of subscriptions) {\n computed.cleanup();\n let cleanup = handler(val);\n makeUnsubscribe(subscriptions, computed, handler, cleanup);\n }\n delayedUpdate();\n }\n return true;\n }\n return false;\n },\n get(state, prop) {\n if (prop === \"value\") {\n return typeof state.value === \"function\" ? state.value() : state.value;\n }\n\n if (prop === \"cleanup\" || prop === \"unsubscribe\" || prop === \"getter\") {\n return state[prop];\n }\n\n if (prop in getters) {\n return getters[prop](state.value);\n }\n }\n }\n );\n\n Object.defineProperties(signal, {\n value: { value, writable: true, enumerable: true },\n cleanup: {\n value() {\n // eslint-disable-next-line no-unused-vars\n for (let [handler, computed] of subscriptions) {\n computed.unsubscribe();\n }\n },\n writable: true,\n enumerable: true\n },\n getter: {\n value(name: string, handler: Getter) {\n if (name in getters) {\n throw new Error(\"Named computed already exists.\");\n }\n\n getters[name] = handler;\n },\n enumerable: true\n }\n });\n\n return signal;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAuB;AAiDvB,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Q,SAAS;AACnB,gBAAM,IAAI,MAAM,gCAAgC;AAAA,QAClD;AAEA,gBAAQ,IAAI,IAAI;AAAA,MAClB;AAAA,MACA,YAAY;AAAA,IACd;AAAA,EACF,CAAC;AAED,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../lib/proxy-signal/index.ts"],
4
+ "sourcesContent": ["import { update } from \"valyrian.js\";\n\n/* eslint-disable no-use-before-define */\ninterface Cleanup {\n (): void;\n}\n\ninterface Subscription {\n // eslint-disable-next-line no-unused-vars\n (value: ProxySignal[\"value\"]): void | Cleanup;\n}\n\ninterface Subscriptions extends Map<Subscription, Cleanup> {}\n\ninterface Getter {\n // eslint-disable-next-line no-unused-vars\n (value: ProxySignal[\"value\"]): any;\n}\n\ninterface Getters {\n [key: string | symbol]: Getter;\n}\n\ninterface ProxySignal {\n // Works as a getter of the value\n (): ProxySignal[\"value\"];\n // Works as a subscription to the value\n // eslint-disable-next-line no-unused-vars\n (value: Subscription): ProxySignal;\n // Works as a setter with a path and a handler\n // eslint-disable-next-line no-unused-vars\n (path: string, handler: (valueAtPathPosition: any) => any): ProxySignal[\"value\"];\n // Works as a setter with a path and a value\n // eslint-disable-next-line no-unused-vars\n (path: string, value: any): ProxySignal[\"value\"];\n // Works as a setter with a value\n // eslint-disable-next-line no-unused-vars\n (value: any): ProxySignal[\"value\"];\n // Gets the current value of the signal.\n value: any;\n // Cleanup function to be called to remove all subscriptions.\n cleanup: () => void;\n // Creates a getter on the signal.\n // eslint-disable-next-line no-unused-vars\n getter: (name: string, handler: Getter) => any;\n // To access the getters on the signal.\n [key: string | number | symbol]: any;\n}\n\nfunction makeUnsubscribe(\n subscriptions: Subscriptions,\n computed: ProxySignal,\n handler: Subscription,\n cleanup?: Cleanup\n) {\n if (typeof cleanup === \"function\") {\n computed.cleanup = cleanup;\n }\n computed.unsubscribe = () => {\n subscriptions.delete(handler);\n computed?.cleanup();\n };\n}\n\nfunction createSubscription(signal: ProxySignal, subscriptions: Subscriptions, handler: Subscription) {\n if (subscriptions.has(handler) === false) {\n // eslint-disable-next-line no-use-before-define\n let computed = ProxySignal(() => handler(signal.value));\n let cleanup = computed(); // Execute to register itself\n makeUnsubscribe(subscriptions, computed, handler, cleanup);\n subscriptions.set(handler, computed);\n }\n\n return subscriptions.get(handler);\n}\n\nlet updateTimeout: any;\nfunction delayedUpdate() {\n clearTimeout(updateTimeout);\n updateTimeout = setTimeout(update);\n}\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport function ProxySignal(value: any): ProxySignal {\n let subscriptions = new Map();\n let getters: Getters = {};\n\n let forceUpdate = false;\n\n let signal: ProxySignal = new Proxy(\n // eslint-disable-next-line no-unused-vars\n function (valOrPath?: any | Subscription, handler?: (valueAtPathPosition: any) => any) {\n // Works as a getter\n if (typeof valOrPath === \"undefined\") {\n return signal.value;\n }\n\n // Works as a subscription\n if (typeof valOrPath === \"function\") {\n return createSubscription(signal, subscriptions, valOrPath);\n }\n\n // Works as a setter with a path\n if (typeof valOrPath === \"string\" && typeof handler !== \"undefined\") {\n let parsed = valOrPath.split(\".\");\n let result = signal.value;\n let next;\n while (parsed.length) {\n next = parsed.shift() as string;\n if (parsed.length > 0) {\n if (typeof result[next] !== \"object\") {\n result[next] = {};\n }\n result = result[next];\n } else {\n result[next] = typeof handler === \"function\" ? handler(result[next]) : handler;\n }\n }\n forceUpdate = true;\n signal.value = signal.value;\n return signal.value;\n }\n\n // Works as a setter with a value\n signal.value = valOrPath;\n return signal.value;\n } as ProxySignal,\n {\n set(state, prop, val) {\n if (prop === \"value\" || prop === \"unsubscribe\" || prop === \"cleanup\") {\n let old = state[prop];\n state[prop] = val;\n if (prop === \"value\" && (forceUpdate || val !== old)) {\n forceUpdate = false;\n for (let [handler, computed] of subscriptions) {\n computed.cleanup();\n let cleanup = handler(val);\n makeUnsubscribe(subscriptions, computed, handler, cleanup);\n }\n delayedUpdate();\n }\n return true;\n }\n return false;\n },\n get(state, prop) {\n if (prop === \"value\") {\n return typeof state.value === \"function\" ? state.value() : state.value;\n }\n\n if (prop === \"cleanup\" || prop === \"unsubscribe\" || prop === \"getter\") {\n return state[prop];\n }\n\n if (prop in getters) {\n return getters[prop](state.value);\n }\n }\n }\n );\n\n Object.defineProperties(signal, {\n value: { value, writable: true, enumerable: true },\n cleanup: {\n value() {\n // eslint-disable-next-line no-unused-vars\n for (let [handler, computed] of subscriptions) {\n computed.unsubscribe();\n }\n },\n writable: true,\n enumerable: true\n },\n getter: {\n value(name: string, handler: Getter) {\n if (name in getters) {\n throw new Error(\"Named computed already exists.\");\n }\n\n getters[name] = handler;\n },\n enumerable: true\n }\n });\n\n return signal;\n}\n"],
5
+ "mappings": ";AAAA,SAAS,cAAc;AAiDvB,SAAS,gBACP,eACA,UACA,SACA,SACA;AACA,MAAI,OAAO,YAAY,YAAY;AACjC,aAAS,UAAU;AAAA,EACrB;AACA,WAAS,cAAc,MAAM;AAC3B,kBAAc,OAAO,OAAO;AAC5B,cAAU,QAAQ;AAAA,EACpB;AACF;AAEA,SAAS,mBAAmB,QAAqB,eAA8B,SAAuB;AACpG,MAAI,cAAc,IAAI,OAAO,MAAM,OAAO;AAExC,QAAI,WAAW,YAAY,MAAM,QAAQ,OAAO,KAAK,CAAC;AACtD,QAAI,UAAU,SAAS;AACvB,oBAAgB,eAAe,UAAU,SAAS,OAAO;AACzD,kBAAc,IAAI,SAAS,QAAQ;AAAA,EACrC;AAEA,SAAO,cAAc,IAAI,OAAO;AAClC;AAEA,IAAI;AACJ,SAAS,gBAAgB;AACvB,eAAa,aAAa;AAC1B,kBAAgB,WAAW,MAAM;AACnC;AAGO,SAAS,YAAY,OAAyB;AACnD,MAAI,gBAAgB,oBAAI,IAAI;AAC5B,MAAI,UAAmB,CAAC;AAExB,MAAI,cAAc;AAElB,MAAI,SAAsB,IAAI;AAAA;AAAA,IAE5B,SAAU,WAAgC,SAA6C;AAErF,UAAI,OAAO,cAAc,aAAa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S,iBAAiB,SAAS,UAAU;AACrE,iBAAO,MAAM,IAAI;AAAA,QACnB;AAEA,YAAI,QAAQ,SAAS;AACnB,iBAAO,QAAQ,IAAI,EAAE,MAAM,KAAK;AAAA,QAClC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO,iBAAiB,QAAQ;AAAA,IAC9B,OAAO,EAAE,OAAO,UAAU,MAAM,YAAY,KAAK;AAAA,IACjD,SAAS;AAAA,MACP,QAAQ;AAEN,iBAAS,CAAC,SAAS,QAAQ,KAAK,eAAe;AAC7C,mBAAS,YAAY;AAAA,QACvB;AAAA,MACF;AAAA,MACA,UAAU;AAAA,MACV,YAAY;AAAA,IACd;AAAA,IACA,QAAQ;AAAA,MACN,MAAM,MAAc,SAAiB;AACnC,YAAI,QAAQ,SAAS;AACnB,gBAAM,IAAI,MAAM,gCAAgC;AAAA,QAClD;AAEA,gBAAQ,IAAI,IAAI;AAAA,MAClB;AAAA,MACA,YAAY;AAAA,IACd;AAAA,EACF,CAAC;AAED,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../lib/request/index.ts"],
4
+ "sourcesContent": ["import { isNodeJs } from \"valyrian.js\";\n\ninterface UrlOptions {\n base: string; // Used to prefix the url for scoped requests.\n node: string | null; // Used to redirect local requests to node server for server side rendering.\n api: string | null; // Used to redirect api requests to node server for server side rendering.\n}\n\ninterface RequestOptions {\n allowedMethods?: string[];\n urls?: UrlOptions;\n [key: string | number | symbol]: any;\n}\n\ninterface RequestOptionsWithUrls extends RequestOptions {\n urls: UrlOptions;\n allowedMethods: string[];\n}\n\ninterface SendOptions extends RequestOptionsWithUrls, RequestInit {\n allowedMethods: string[];\n method: string;\n headers: Record<string, string>;\n resolveWithFullResponse?: boolean;\n}\n\nexport interface RequestInterface {\n // eslint-disable-next-line no-unused-vars\n (method: string, url: string, data?: Record<string, any>, options?: Partial<SendOptions>): any | Response;\n // eslint-disable-next-line no-unused-vars\n new: (baseUrl: string, options?: RequestOptions) => RequestInterface;\n // eslint-disable-next-line no-unused-vars\n setOptions: (key: string, value: any) => void;\n // eslint-disable-next-line no-unused-vars\n getOptions: (key?: string) => RequestOptions | void;\n // eslint-disable-next-line no-unused-vars\n get: (url: string, data?: Record<string, any>, options?: Record<string, any>) => any | Response;\n // eslint-disable-next-line no-unused-vars\n post: (url: string, data?: Record<string, any>, options?: Record<string, any>) => any | Response;\n // eslint-disable-next-line no-unused-vars\n put: (url: string, data?: Record<string, any>, options?: Record<string, any>) => any | Response;\n // eslint-disable-next-line no-unused-vars\n patch: (url: string, data?: Record<string, any>, options?: Record<string, any>) => any | Response;\n // eslint-disable-next-line no-unused-vars\n delete: (url: string, data?: Record<string, any>, options?: Record<string, any>) => any | Response;\n // eslint-disable-next-line no-unused-vars\n head: (url: string, data?: Record<string, any>, options?: Record<string, any>) => any | Response;\n // eslint-disable-next-line no-unused-vars\n options: (url: string, data?: Record<string, any>, options?: Record<string, any>) => any | Response;\n [key: string | number | symbol]: any;\n}\n\n// This method is used to serialize an object into a query string.\nfunction serialize(obj: Record<string, any>, prefix: string = \"\"): string {\n return Object.keys(obj)\n .map((prop: string) => {\n let k = prefix ? `${prefix}[${prop}]` : prop;\n return typeof obj[prop] === \"object\"\n ? serialize(obj[prop], k)\n : `${encodeURIComponent(k)}=${encodeURIComponent(obj[prop])}`;\n })\n .join(\"&\");\n}\n\nfunction parseUrl(url: string, options: RequestOptionsWithUrls) {\n let u = /^https?/gi.test(url) ? url : options.urls.base + url;\n\n let parts = u.split(\"?\");\n u = parts[0].trim().replace(/^\\/\\//, \"/\").replace(/\\/$/, \"\").trim();\n\n if (parts[1]) {\n u += `?${parts[1]}`;\n }\n\n if (isNodeJs && typeof options.urls.node === \"string\") {\n options.urls.node = options.urls.node;\n\n if (typeof options.urls.api === \"string\") {\n options.urls.api = options.urls.api.replace(/\\/$/gi, \"\").trim();\n u = u.replace(options.urls.api, options.urls.node);\n }\n\n if (!/^https?/gi.test(u)) {\n u = options.urls.node + u;\n }\n }\n\n return u;\n}\n\nconst defaultOptions: RequestOptions = { allowedMethods: [\"get\", \"post\", \"put\", \"patch\", \"delete\", \"head\", \"options\"] };\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nfunction Requester(baseUrl = \"\", options: RequestOptions = defaultOptions) {\n let url = baseUrl.replace(/\\/$/gi, \"\").trim();\n if (!options.urls) {\n options.urls = {\n base: \"\",\n node: null,\n api: null\n };\n }\n\n if (!options.allowedMethods) {\n options.allowedMethods = defaultOptions.allowedMethods;\n }\n\n let opts: RequestOptionsWithUrls = {\n ...(options as RequestOptionsWithUrls),\n urls: {\n node: options.urls.node || null,\n api: options.urls.api || null,\n base: options.urls.base ? options.urls.base + url : url\n }\n };\n\n const request = async function request(method: string, url: string, data?: Record<string, any>, options = {}) {\n let innerOptions: SendOptions = {\n method: method.toUpperCase(),\n headers: {},\n resolveWithFullResponse: false,\n ...opts,\n ...options\n } as SendOptions;\n\n if (!innerOptions.headers.Accept) {\n innerOptions.headers.Accept = \"application/json\";\n }\n\n let acceptType = innerOptions.headers.Accept;\n let contentType = innerOptions.headers[\"Content-Type\"] || innerOptions.headers[\"content-type\"] || \"\";\n\n if (innerOptions.allowedMethods.indexOf(method) === -1) {\n throw new Error(\"Method not allowed\");\n }\n\n if (data) {\n if (innerOptions.method === \"GET\" && typeof data === \"object\") {\n url += `?${serialize(data)}`;\n }\n\n if (innerOptions.method !== \"GET\") {\n if (/json/gi.test(contentType)) {\n innerOptions.body = JSON.stringify(data);\n } else {\n let formData;\n if (data instanceof FormData) {\n formData = data;\n } else {\n formData = new FormData();\n for (let i in data) {\n formData.append(i, data[i]);\n }\n }\n innerOptions.body = formData;\n }\n }\n }\n\n let response = await fetch(parseUrl(url, opts), innerOptions);\n let body = null;\n if (!response.ok) {\n let err = new Error(response.statusText) as Error & { response?: any; body?: any };\n err.response = response;\n if (/text/gi.test(acceptType)) {\n err.body = await response.text();\n }\n\n if (/json/gi.test(acceptType)) {\n try {\n err.body = await response.json();\n } catch (error) {\n // ignore\n }\n }\n\n throw err;\n }\n\n if (innerOptions.resolveWithFullResponse) {\n return response;\n }\n\n if (/text/gi.test(acceptType)) {\n body = await response.text();\n return body;\n }\n\n if (/json/gi.test(acceptType)) {\n try {\n body = await response.json();\n return body;\n } catch (error) {\n // ignore\n }\n }\n\n return response;\n } as unknown as RequestInterface;\n\n request.new = (baseUrl: string, options?: RequestOptions) => Requester(baseUrl, { ...opts, ...(options || {}) });\n\n request.setOption = (key: string, value: any) => {\n let result = opts;\n\n let parsed = key.split(\".\");\n let next;\n\n while (parsed.length) {\n next = parsed.shift() as string;\n\n let nextIsArray = next.indexOf(\"[\") > -1;\n if (nextIsArray) {\n let idx = next.replace(/\\D/gi, \"\");\n next = next.split(\"[\")[0];\n parsed.unshift(idx);\n }\n\n if (parsed.length > 0 && typeof result[next] !== \"object\") {\n result[next] = nextIsArray ? [] : {};\n }\n\n if (parsed.length === 0 && typeof value !== \"undefined\") {\n result[next] = value;\n }\n\n result = result[next];\n }\n\n return result;\n };\n\n request.getOptions = (key?: string) => {\n if (!key) {\n return opts;\n }\n\n let result = opts;\n let parsed = key.split(\".\");\n let next;\n\n while (parsed.length) {\n next = parsed.shift() as string;\n\n let nextIsArray = next.indexOf(\"[\") > -1;\n if (nextIsArray) {\n let idx = next.replace(/\\D/gi, \"\");\n next = next.split(\"[\")[0];\n parsed.unshift(idx);\n }\n\n if (parsed.length > 0 && typeof result[next] !== \"object\") {\n return null;\n }\n\n if (parsed.length === 0) {\n return result[next];\n }\n\n result = result[next];\n }\n };\n\n opts.allowedMethods.forEach(\n (method) =>\n (request[method] = (url: string, data?: Record<string, any>, options?: Record<string, any>) =>\n request(method, url, data, options))\n );\n\n return request;\n}\n\nexport const request = Requester();\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAyB;AAqDzB,SAAS,UAAU,KAA0B,SAAiB,I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Js } from \"valyrian.js\";\n\ninterface UrlOptions {\n base: string; // Used to prefix the url for scoped requests.\n node: string | null; // Used to redirect local requests to node server for server side rendering.\n api: string | null; // Used to redirect api requests to node server for server side rendering.\n}\n\ninterface RequestOptions {\n allowedMethods?: string[];\n urls?: UrlOptions;\n [key: string | number | symbol]: any;\n}\n\ninterface RequestOptionsWithUrls extends RequestOptions {\n urls: UrlOptions;\n allowedMethods: string[];\n}\n\ninterface SendOptions extends RequestOptionsWithUrls, RequestInit {\n allowedMethods: string[];\n method: string;\n headers: Record<string, string>;\n resolveWithFullResponse?: boolean;\n}\n\nexport interface RequestInterface {\n // eslint-disable-next-line no-unused-vars\n (method: string, url: string, data?: Record<string, any>, options?: Partial<SendOptions>): any | Response;\n // eslint-disable-next-line no-unused-vars\n new: (baseUrl: string, options?: RequestOptions) => RequestInterface;\n // eslint-disable-next-line no-unused-vars\n setOptions: (key: string, value: any) => void;\n // eslint-disable-next-line no-unused-vars\n getOptions: (key?: string) => RequestOptions | void;\n // eslint-disable-next-line no-unused-vars\n get: (url: string, data?: Record<string, any>, options?: Record<string, any>) => any | Response;\n // eslint-disable-next-line no-unused-vars\n post: (url: string, data?: Record<string, any>, options?: Record<string, any>) => any | Response;\n // eslint-disable-next-line no-unused-vars\n put: (url: string, data?: Record<string, any>, options?: Record<string, any>) => any | Response;\n // eslint-disable-next-line no-unused-vars\n patch: (url: string, data?: Record<string, any>, options?: Record<string, any>) => any | Response;\n // eslint-disable-next-line no-unused-vars\n delete: (url: string, data?: Record<string, any>, options?: Record<string, any>) => any | Response;\n // eslint-disable-next-line no-unused-vars\n head: (url: string, data?: Record<string, any>, options?: Record<string, any>) => any | Response;\n // eslint-disable-next-line no-unused-vars\n options: (url: string, data?: Record<string, any>, options?: Record<string, any>) => any | Response;\n [key: string | number | symbol]: any;\n}\n\n// This method is used to serialize an object into a query string.\nfunction serialize(obj: Record<string, any>, prefix: string = \"\"): string {\n return Object.keys(obj)\n .map((prop: string) => {\n let k = prefix ? `${prefix}[${prop}]` : prop;\n return typeof obj[prop] === \"object\"\n ? serialize(obj[prop], k)\n : `${encodeURIComponent(k)}=${encodeURIComponent(obj[prop])}`;\n })\n .join(\"&\");\n}\n\nfunction parseUrl(url: string, options: RequestOptionsWithUrls) {\n let u = /^https?/gi.test(url) ? url : options.urls.base + url;\n\n let parts = u.split(\"?\");\n u = parts[0].trim().replace(/^\\/\\//, \"/\").replace(/\\/$/, \"\").trim();\n\n if (parts[1]) {\n u += `?${parts[1]}`;\n }\n\n if (isNodeJs && typeof options.urls.node === \"string\") {\n options.urls.node = options.urls.node;\n\n if (typeof options.urls.api === \"string\") {\n options.urls.api = options.urls.api.replace(/\\/$/gi, \"\").trim();\n u = u.replace(options.urls.api, options.urls.node);\n }\n\n if (!/^https?/gi.test(u)) {\n u = options.urls.node + u;\n }\n }\n\n return u;\n}\n\nconst defaultOptions: RequestOptions = { allowedMethods: [\"get\", \"post\", \"put\", \"patch\", \"delete\", \"head\", \"options\"] };\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nfunction Requester(baseUrl = \"\", options: RequestOptions = defaultOptions) {\n let url = baseUrl.replace(/\\/$/gi, \"\").trim();\n if (!options.urls) {\n options.urls = {\n base: \"\",\n node: null,\n api: null\n };\n }\n\n if (!options.allowedMethods) {\n options.allowedMethods = defaultOptions.allowedMethods;\n }\n\n let opts: RequestOptionsWithUrls = {\n ...(options as RequestOptionsWithUrls),\n urls: {\n node: options.urls.node || null,\n api: options.urls.api || null,\n base: options.urls.base ? options.urls.base + url : url\n }\n };\n\n const request = async function request(method: string, url: string, data?: Record<string, any>, options = {}) {\n let innerOptions: SendOptions = {\n method: method.toUpperCase(),\n headers: {},\n resolveWithFullResponse: false,\n ...opts,\n ...options\n } as SendOptions;\n\n if (!innerOptions.headers.Accept) {\n innerOptions.headers.Accept = \"application/json\";\n }\n\n let acceptType = innerOptions.headers.Accept;\n let contentType = innerOptions.headers[\"Content-Type\"] || innerOptions.headers[\"content-type\"] || \"\";\n\n if (innerOptions.allowedMethods.indexOf(method) === -1) {\n throw new Error(\"Method not allowed\");\n }\n\n if (data) {\n if (innerOptions.method === \"GET\" && typeof data === \"object\") {\n url += `?${serialize(data)}`;\n }\n\n if (innerOptions.method !== \"GET\") {\n if (/json/gi.test(contentType)) {\n innerOptions.body = JSON.stringify(data);\n } else {\n let formData;\n if (data instanceof FormData) {\n formData = data;\n } else {\n formData = new FormData();\n for (let i in data) {\n formData.append(i, data[i]);\n }\n }\n innerOptions.body = formData;\n }\n }\n }\n\n let response = await fetch(parseUrl(url, opts), innerOptions);\n let body = null;\n if (!response.ok) {\n let err = new Error(response.statusText) as Error & { response?: any; body?: any };\n err.response = response;\n if (/text/gi.test(acceptType)) {\n err.body = await response.text();\n }\n\n if (/json/gi.test(acceptType)) {\n try {\n err.body = await response.json();\n } catch (error) {\n // ignore\n }\n }\n\n throw err;\n }\n\n if (innerOptions.resolveWithFullResponse) {\n return response;\n }\n\n if (/text/gi.test(acceptType)) {\n body = await response.text();\n return body;\n }\n\n if (/json/gi.test(acceptType)) {\n try {\n body = await response.json();\n return body;\n } catch (error) {\n // ignore\n }\n }\n\n return response;\n } as unknown as RequestInterface;\n\n request.new = (baseUrl: string, options?: RequestOptions) => Requester(baseUrl, { ...opts, ...(options || {}) });\n\n request.setOption = (key: string, value: any) => {\n let result = opts;\n\n let parsed = key.split(\".\");\n let next;\n\n while (parsed.length) {\n next = parsed.shift() as string;\n\n let nextIsArray = next.indexOf(\"[\") > -1;\n if (nextIsArray) {\n let idx = next.replace(/\\D/gi, \"\");\n next = next.split(\"[\")[0];\n parsed.unshift(idx);\n }\n\n if (parsed.length > 0 && typeof result[next] !== \"object\") {\n result[next] = nextIsArray ? [] : {};\n }\n\n if (parsed.length === 0 && typeof value !== \"undefined\") {\n result[next] = value;\n }\n\n result = result[next];\n }\n\n return result;\n };\n\n request.getOptions = (key?: string) => {\n if (!key) {\n return opts;\n }\n\n let result = opts;\n let parsed = key.split(\".\");\n let next;\n\n while (parsed.length) {\n next = parsed.shift() as string;\n\n let nextIsArray = next.indexOf(\"[\") > -1;\n if (nextIsArray) {\n let idx = next.replace(/\\D/gi, \"\");\n next = next.split(\"[\")[0];\n parsed.unshift(idx);\n }\n\n if (parsed.length > 0 && typeof result[next] !== \"object\") {\n return null;\n }\n\n if (parsed.length === 0) {\n return result[next];\n }\n\n result = result[next];\n }\n };\n\n opts.allowedMethods.forEach(\n (method) =>\n (request[method] = (url: string, data?: Record<string, any>, options?: Record<string, any>) =>\n request(method, url, data, options))\n );\n\n return request;\n}\n\nexport const request = Requester();\n"],
5
+ "mappings": ";AAAA,SAAS,gBAAgB;AAqDzB,SAAS,UAAU,KAA0B,SAAiB,IAAY;AACxE,SAAO,OAAO,KAAK,GAAG,EACnB,IAAI,CAAC,SAAiB;AACrB,QAAI,IAAI,SAAS,GAAG,MAAM,IAAI,IAAI,MAAM;AACxC,WAAO,OAAO,IAAI,IAAI,MAAM,WACxB,UAAU,IAAI,IAAI,GAAG,CAAC,IACtB,GAAG,mBAAmB,CAAC,CAAC,IAAI,mBAAmB,IAAI,IAAI,CAAC,CAAC;AAAA,EAC/D,CAAC,EACA,KAAK,GAAG;AACb;AAEA,SAAS,SAAS,KAAa,SAAiC;AAC9D,MAAI,IAAI,YAAY,KAAK,GAAG,IAAI,MAAM,QAAQ,KAAK,OAAO;AAE1D,MAAI,QAAQ,EAAE,MAAM,GAAG;AACvB,MAAI,MAAM,CAAC,EAAE,KAAK,EAAE,QAAQ,SAAS,GAAG,EAAE,QAAQ,OAAO,EAAE,EAAE,KAAK;AAElE,MAAI,MAAM,CAAC,GAAG;AACZ,SAAK,IAAI,MAAM,CAAC,CAAC;AAAA,EACnB;AAEA,MAAI,YAAY,OAAO,QAAQ,KAAK,SAAS,UAAU;AACrD,YAAQ,KAAK,OAAO,QAAQ,KAAK;AAEjC,QAAI,OAAO,QAAQ,KAAK,QAAQ,UAAU;AACxC,cAAQ,KAAK,MAAM,QAAQ,KAAK,IAAI,QAAQ,SAA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ACT;AAEA,UAAI,OAAO,WAAW,GAAG;AACvB,eAAO,OAAO,IAAI;AAAA,MACpB;AAEA,eAAS,OAAO,IAAI;AAAA,IACtB;AAAA,EACF;AAEA,OAAK,eAAe;AAAA,IAClB,CAAC,WACEA,SAAQ,MAAM,IAAI,CAACC,MAAa,MAA4BC,aAC3DF,SAAQ,QAAQC,MAAK,MAAMC,QAAO;AAAA,EACxC;AAEA,SAAOF;AACT;AAEO,IAAM,UAAU,UAAU;",
6
+ "names": ["request", "url", "options", "baseUrl"]
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../lib/router/index.ts"],
4
+ "sourcesContent": ["/* eslint-disable no-use-before-define */\nimport {\n Component,\n POJOComponent,\n VnodeComponentInterface,\n VnodeWithDom,\n directive,\n isComponent,\n isNodeJs,\n isVnodeComponent,\n mount,\n setAttribute,\n v\n} from \"valyrian.js\";\n\ninterface Request {\n params: Record<string, any>;\n query: Record<string, any>;\n url: string;\n path: string;\n matches: string[];\n // eslint-disable-next-line no-unused-vars\n redirect: (path: string, parentComponent?: Component | POJOComponent | VnodeComponentInterface) => false;\n}\n\ninterface Middleware {\n // eslint-disable-next-line no-unused-vars\n (req: Request, res?: any):\n | Promise<any | Component | POJOComponent | VnodeComponentInterface>\n | any\n | Component\n | POJOComponent\n | VnodeComponentInterface;\n}\n\ninterface Middlewares extends Array<Middleware> {}\n\ninterface Path {\n method: string;\n path: string;\n middlewares: Middlewares;\n params: string[];\n regexp: RegExp;\n}\n\ninterface RouterInterface {\n paths: Path[];\n container: Element | string | null;\n query: Record<string, string | number>;\n options: Record<string, any>;\n url: string;\n path: string;\n params: Record<string, string | number | any>;\n matches: string[];\n pathPrefix: string;\n // eslint-disable-next-line no-unused-vars\n add(method: string, ...args: Middlewares): Router;\n // eslint-disable-next-line no-unused-vars\n use(...args: (string | Middleware | Router)[]): Router;\n\n routes(): string[];\n // eslint-disable-next-line no-unused-vars\n go(path: string, parentComponent?: Component | POJOComponent | VnodeComponentInterface): Promise<string | void>;\n}\n\ninterface RedirectFunction {\n // eslint-disable-next-line no-unused-vars\n (url: string, parentComponent?: Component, preventPushState?: boolean): string | void;\n}\n\nfunction flat(array: any) {\n return Array.isArray(array) ? array.flat(Infinity) : [array];\n}\n\nfunction getPathWithoutPrefix(path: string, prefix: string) {\n return getPathWithoutLastSlash(path.replace(new RegExp(`^${prefix}`), \"\"));\n}\n\nfunction getPathWithoutLastSlash(path: string) {\n let pathWithoutLastSlash = path.replace(/\\/$/, \"\");\n if (pathWithoutLastSlash === \"\") {\n pathWithoutLastSlash = \"/\";\n }\n return pathWithoutLastSlash;\n}\n\nconst addPath = ({\n router,\n method,\n path,\n middlewares\n}: {\n router: Router;\n method: string;\n path: string;\n middlewares: Middleware[];\n}): void => {\n if (!method || !path || !Array.isArray(middlewares) || middlewares.length === 0) {\n throw new Error(`Invalid route input: ${method} ${path} ${middlewares}`);\n }\n\n // Trim trailing slashes from the path\n let realpath = path.replace(/(\\S)(\\/+)$/, \"$1\");\n\n // Find the express-like params in the path\n let params = (realpath.match(/:(\\w+)?/gi) || [])\n // Set the names of the params found\n .map((param) => param.slice(1));\n\n // Generate a regular expression to match the path\n let regexpPath = \"^\" + realpath.replace(/:(\\w+)/gi, \"([^\\\\/\\\\s]+)\") + \"$\";\n\n router.paths.push({\n method,\n path: realpath,\n middlewares: flat(middlewares),\n params,\n regexp: new RegExp(regexpPath, \"i\")\n });\n};\n\n// Parse a query string into an object\nfunction parseQuery(queryParts?: string): Record<string, string> {\n // Split the query string into an array of name-value pairs\n let parts = queryParts ? queryParts.split(\"&\") : [];\n let query: Record<string, string> = {};\n\n // Iterate over the name-value pairs and add them to the query object\n for (let nameValue of parts) {\n let [name, value] = nameValue.split(\"=\", 2);\n query[name] = value || \"\";\n }\n\n return query;\n}\n\n// Search for middlewares that match a given path\nfunction searchMiddlewares(router: RouterInterface, path: string): Middlewares {\n let middlewares: Middlewares = [];\n let params: Record<string, any> = {};\n let matches = [];\n\n // Search for middlewares\n for (let item of router.paths) {\n let match = item.regexp.exec(path);\n\n // If we found middlewares\n if (Array.isArray(match)) {\n middlewares.push(...item.middlewares);\n match.shift();\n\n // Parse params\n for (let [index, key] of item.params.entries()) {\n params[key] = match[index];\n }\n\n // Add remaining matches to the array\n matches.push(...match);\n\n if (item.method === \"add\") {\n router.path = getPathWithoutPrefix(item.path, router.pathPrefix);\n break;\n }\n }\n }\n\n router.params = params;\n router.matches = matches;\n\n return middlewares;\n}\n\nasync function searchComponent(\n router: RouterInterface,\n middlewares: Middlewares\n): Promise<Component | VnodeComponentInterface | false | void> {\n // Define request object with default values\n const request: Request = {\n params: router.params,\n query: router.query,\n url: router.url,\n path: router.path,\n matches: router.matches,\n redirect: (path: string, parentComponent?: Component) => {\n router.go(path, parentComponent);\n // Return false to stop the middleware chain\n return false;\n }\n };\n\n // Initialize response variable\n let response;\n\n // Iterate through middlewares\n for (const middleware of middlewares) {\n // Invoke middleware and update response\n response = await middleware(request, response);\n\n // Return response if it's a valid component\n if (response !== undefined && (isComponent(response) || isVnodeComponent(response))) {\n return response;\n }\n\n // Return false if response is explicitly false to stop the middleware chain\n if (response === false) {\n return false;\n }\n }\n}\n\nexport class Router implements RouterInterface {\n paths: Path[] = [];\n container: Element | string | null = null;\n query: Record<string, string | number> = {};\n options: Record<string, any> = {};\n url: string = \"\";\n path: string = \"\";\n params: Record<string, string | number | any> = {};\n matches: string[] = [];\n pathPrefix: string = \"\";\n\n constructor(pathPrefix: string = \"\") {\n this.pathPrefix = pathPrefix;\n }\n\n add(path: string, ...middlewares: Middlewares): Router {\n let pathWithoutLastSlash = getPathWithoutLastSlash(`${this.pathPrefix}${path}`);\n addPath({ router: this, method: \"add\", path: pathWithoutLastSlash, middlewares });\n return this;\n }\n\n use(...middlewares: Middlewares | Router[] | string[]): Router {\n let path = getPathWithoutLastSlash(\n `${this.pathPrefix}${typeof middlewares[0] === \"string\" ? middlewares.shift() : \"/\"}`\n );\n\n for (const item of middlewares) {\n if (item instanceof Router) {\n const subrouter = item as Router;\n for (const subpath of subrouter.paths) {\n addPath({\n router: this,\n method: subpath.method,\n path: `${path}${subpath.path}`.replace(/^\\/\\//, \"/\"),\n middlewares: subpath.middlewares\n });\n }\n continue;\n }\n\n if (typeof item === \"function\") {\n addPath({ router: this, method: \"use\", path: `${path}.*`, middlewares: [item as Middleware] });\n }\n }\n\n return this;\n }\n\n routes(): string[] {\n return this.paths.filter((path) => path.method === \"add\").map((path) => path.path);\n }\n\n async go(path: string, parentComponent?: Component, preventPushState = false): Promise<string | void> {\n if (!path) {\n throw new Error(\"router.url.required\");\n }\n\n let constructedPath = getPathWithoutLastSlash(`${this.pathPrefix}${path}`);\n const parts = constructedPath.split(\"?\", 2);\n this.url = constructedPath;\n this.query = parseQuery(parts[1]);\n\n const middlewares = searchMiddlewares(this as RouterInterface, parts[0].replace(/(.+)\\/$/, \"$1\").split(\"#\")[0]);\n let component = await searchComponent(this as RouterInterface, middlewares);\n\n if (component === false) {\n return;\n }\n\n if (!component) {\n throw new Error(`The url ${constructedPath} requested wasn't found`);\n }\n\n if (isComponent(parentComponent) || isVnodeComponent(parentComponent)) {\n const childComponent = isVnodeComponent(component) ? component : v(component as Component, {});\n if (isVnodeComponent(parentComponent)) {\n parentComponent.children.push(childComponent);\n component = parentComponent;\n } else {\n component = v(parentComponent, {}, childComponent) as VnodeComponentInterface;\n }\n }\n\n if (!isNodeJs && !preventPushState) {\n window.history.pushState(null, \"\", constructedPath);\n }\n\n if (this.container) {\n return mount(this.container, component);\n }\n }\n\n getOnClickHandler(url: string) {\n return (e: MouseEvent) => {\n if (typeof url === \"string\" && url.length > 0) {\n this.go(url);\n }\n e.preventDefault();\n };\n }\n}\n\nlet localRedirect: RedirectFunction;\n\nexport function redirect(url: string, parentComponent?: Component, preventPushState = false): string | void {\n if (!localRedirect) {\n throw new Error(\"router.redirect.not.found\");\n }\n return localRedirect(url, parentComponent, preventPushState);\n}\n\nexport function mountRouter(elementContainer: string | any, router: Router): void {\n router.container = elementContainer;\n localRedirect = router.go.bind(router);\n\n if (!isNodeJs) {\n function onPopStateGoToRoute(): void {\n let pathWithoutPrefix = getPathWithoutPrefix(document.location.pathname, router.pathPrefix);\n (router as unknown as Router).go(pathWithoutPrefix, undefined, true);\n }\n window.addEventListener(\"popstate\", onPopStateGoToRoute, false);\n onPopStateGoToRoute();\n }\n\n directive(\"route\", (url: string, vnode: VnodeWithDom, oldnode?: VnodeWithDom): void => {\n setAttribute(\"href\", url, vnode, oldnode);\n setAttribute(\"onclick\", router.getOnClickHandler(url), vnode, oldnode);\n });\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAYO;AAyDP,SAAS,KAAK,OAAY;AACxB,SAAO,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAK,QAAQ,IAAI,CAAC,KAAK;AAC7D;AAEA,SAAS,qBAAqB,MAAc,QAAgB;AAC1D,SAAO,wBAAwB,KAAK,QAAQ,IAAI,OAAO,IAAI,MAAM,EAAE,GAAG,EAAE,CAAC;AAC3E;AAEA,SAAS,wBAAwB,MAAc;AAC7C,MAAI,uBAAuB,KAAK,QAAQ,OAAO,EAAE;AACjD,MAAI,yBAAyB,IAAI;AAC/B,2BAAuB;AAAA,EACzB;AACA,SAAO;AACT;AAEA,IAAM,UAAU,CAAC;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAKY;AACV,MAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,QAAQ,WAAW,KAAK,YAAY,WAAW,GAAG;AAC/E,UAAM,IAAI,MAAM,wBAAwB,MAAM,IAAI,IAAI,IAAI,WAAW,EAAE;AAAA,EACzE;AAGA,MAAI,WAAW,KAAK,QAAQ,cAAc,IAAI;AAG9C,MAAI,UAAU,SAAS,MAAM,WAAW,KAAK,CAAC,GAE3C,IAAI,CAAC,UAAU,MAAM,MAAM,CAAC,CAAC;AAGhC,M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Y,CAAC,kBAAkB;AAClC,aAAO,QAAQ,UAAU,MAAM,IAAI,eAAe;AAAA,IACpD;AAEA,QAAI,KAAK,WAAW;AAClB,iBAAO,uBAAM,KAAK,WAAW,SAAS;AAAA,IACxC;AAAA,EACF;AAAA,EAEA,kBAAkB,KAAa;AAC7B,WAAO,CAAC,MAAkB;AACxB,UAAI,OAAO,QAAQ,YAAY,IAAI,SAAS,GAAG;AAC7C,aAAK,GAAG,GAAG;AAAA,MACb;AACA,QAAE,eAAe;AAAA,IACnB;AAAA,EACF;AACF;AAEA,IAAI;AAEG,SAAS,SAAS,KAAa,iBAA6B,mBAAmB,OAAsB;AAC1G,MAAI,CAAC,eAAe;AAClB,UAAM,IAAI,MAAM,2BAA2B;AAAA,EAC7C;AACA,SAAO,cAAc,KAAK,iBAAiB,gBAAgB;AAC7D;AAEO,SAAS,YAAY,kBAAgC,QAAsB;AAChF,SAAO,YAAY;AACnB,kBAAgB,OAAO,GAAG,KAAK,MAAM;AAErC,MAAI,CAAC,0BAAU;AACb,QAAS,sBAAT,WAAqC;AACnC,UAAI,oBAAoB,qBAAqB,SAAS,SAAS,UAAU,OAAO,UAAU;AAC1F,MAAC,OAA6B,GAAG,mBAAmB,QAAW,IAAI;AAAA,IACrE;AACA,WAAO,iBAAiB,YAAY,qBAAqB,KAAK;AAC9D,wBAAoB;AAAA,EACtB;AAEA,iCAAU,SAAS,CAAC,KAAa,OAAqB,YAAiC;AACrF,sCAAa,QAAQ,KAAK,OAAO,OAAO;AACxC,sCAAa,WAAW,OAAO,kBAAkB,GAAG,GAAG,OAAO,OAAO;AAAA,EACvE,CAAC;AACH;",
6
+ "names": []
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../lib/router/index.ts"],
4
+ "sourcesContent": ["/* eslint-disable no-use-before-define */\nimport {\n Component,\n POJOComponent,\n VnodeComponentInterface,\n VnodeWithDom,\n directive,\n isComponent,\n isNodeJs,\n isVnodeComponent,\n mount,\n setAttribute,\n v\n} from \"valyrian.js\";\n\ninterface Request {\n params: Record<string, any>;\n query: Record<string, any>;\n url: string;\n path: string;\n matches: string[];\n // eslint-disable-next-line no-unused-vars\n redirect: (path: string, parentComponent?: Component | POJOComponent | VnodeComponentInterface) => false;\n}\n\ninterface Middleware {\n // eslint-disable-next-line no-unused-vars\n (req: Request, res?: any):\n | Promise<any | Component | POJOComponent | VnodeComponentInterface>\n | any\n | Component\n | POJOComponent\n | VnodeComponentInterface;\n}\n\ninterface Middlewares extends Array<Middleware> {}\n\ninterface Path {\n method: string;\n path: string;\n middlewares: Middlewares;\n params: string[];\n regexp: RegExp;\n}\n\ninterface RouterInterface {\n paths: Path[];\n container: Element | string | null;\n query: Record<string, string | number>;\n options: Record<string, any>;\n url: string;\n path: string;\n params: Record<string, string | number | any>;\n matches: string[];\n pathPrefix: string;\n // eslint-disable-next-line no-unused-vars\n add(method: string, ...args: Middlewares): Router;\n // eslint-disable-next-line no-unused-vars\n use(...args: (string | Middleware | Router)[]): Router;\n\n routes(): string[];\n // eslint-disable-next-line no-unused-vars\n go(path: string, parentComponent?: Component | POJOComponent | VnodeComponentInterface): Promise<string | void>;\n}\n\ninterface RedirectFunction {\n // eslint-disable-next-line no-unused-vars\n (url: string, parentComponent?: Component, preventPushState?: boolean): string | void;\n}\n\nfunction flat(array: any) {\n return Array.isArray(array) ? array.flat(Infinity) : [array];\n}\n\nfunction getPathWithoutPrefix(path: string, prefix: string) {\n return getPathWithoutLastSlash(path.replace(new RegExp(`^${prefix}`), \"\"));\n}\n\nfunction getPathWithoutLastSlash(path: string) {\n let pathWithoutLastSlash = path.replace(/\\/$/, \"\");\n if (pathWithoutLastSlash === \"\") {\n pathWithoutLastSlash = \"/\";\n }\n return pathWithoutLastSlash;\n}\n\nconst addPath = ({\n router,\n method,\n path,\n middlewares\n}: {\n router: Router;\n method: string;\n path: string;\n middlewares: Middleware[];\n}): void => {\n if (!method || !path || !Array.isArray(middlewares) || middlewares.length === 0) {\n throw new Error(`Invalid route input: ${method} ${path} ${middlewares}`);\n }\n\n // Trim trailing slashes from the path\n let realpath = path.replace(/(\\S)(\\/+)$/, \"$1\");\n\n // Find the express-like params in the path\n let params = (realpath.match(/:(\\w+)?/gi) || [])\n // Set the names of the params found\n .map((param) => param.slice(1));\n\n // Generate a regular expression to match the path\n let regexpPath = \"^\" + realpath.replace(/:(\\w+)/gi, \"([^\\\\/\\\\s]+)\") + \"$\";\n\n router.paths.push({\n method,\n path: realpath,\n middlewares: flat(middlewares),\n params,\n regexp: new RegExp(regexpPath, \"i\")\n });\n};\n\n// Parse a query string into an object\nfunction parseQuery(queryParts?: string): Record<string, string> {\n // Split the query string into an array of name-value pairs\n let parts = queryParts ? queryParts.split(\"&\") : [];\n let query: Record<string, string> = {};\n\n // Iterate over the name-value pairs and add them to the query object\n for (let nameValue of parts) {\n let [name, value] = nameValue.split(\"=\", 2);\n query[name] = value || \"\";\n }\n\n return query;\n}\n\n// Search for middlewares that match a given path\nfunction searchMiddlewares(router: RouterInterface, path: string): Middlewares {\n let middlewares: Middlewares = [];\n let params: Record<string, any> = {};\n let matches = [];\n\n // Search for middlewares\n for (let item of router.paths) {\n let match = item.regexp.exec(path);\n\n // If we found middlewares\n if (Array.isArray(match)) {\n middlewares.push(...item.middlewares);\n match.shift();\n\n // Parse params\n for (let [index, key] of item.params.entries()) {\n params[key] = match[index];\n }\n\n // Add remaining matches to the array\n matches.push(...match);\n\n if (item.method === \"add\") {\n router.path = getPathWithoutPrefix(item.path, router.pathPrefix);\n break;\n }\n }\n }\n\n router.params = params;\n router.matches = matches;\n\n return middlewares;\n}\n\nasync function searchComponent(\n router: RouterInterface,\n middlewares: Middlewares\n): Promise<Component | VnodeComponentInterface | false | void> {\n // Define request object with default values\n const request: Request = {\n params: router.params,\n query: router.query,\n url: router.url,\n path: router.path,\n matches: router.matches,\n redirect: (path: string, parentComponent?: Component) => {\n router.go(path, parentComponent);\n // Return false to stop the middleware chain\n return false;\n }\n };\n\n // Initialize response variable\n let response;\n\n // Iterate through middlewares\n for (const middleware of middlewares) {\n // Invoke middleware and update response\n response = await middleware(request, response);\n\n // Return response if it's a valid component\n if (response !== undefined && (isComponent(response) || isVnodeComponent(response))) {\n return response;\n }\n\n // Return false if response is explicitly false to stop the middleware chain\n if (response === false) {\n return false;\n }\n }\n}\n\nexport class Router implements RouterInterface {\n paths: Path[] = [];\n container: Element | string | null = null;\n query: Record<string, string | number> = {};\n options: Record<string, any> = {};\n url: string = \"\";\n path: string = \"\";\n params: Record<string, string | number | any> = {};\n matches: string[] = [];\n pathPrefix: string = \"\";\n\n constructor(pathPrefix: string = \"\") {\n this.pathPrefix = pathPrefix;\n }\n\n add(path: string, ...middlewares: Middlewares): Router {\n let pathWithoutLastSlash = getPathWithoutLastSlash(`${this.pathPrefix}${path}`);\n addPath({ router: this, method: \"add\", path: pathWithoutLastSlash, middlewares });\n return this;\n }\n\n use(...middlewares: Middlewares | Router[] | string[]): Router {\n let path = getPathWithoutLastSlash(\n `${this.pathPrefix}${typeof middlewares[0] === \"string\" ? middlewares.shift() : \"/\"}`\n );\n\n for (const item of middlewares) {\n if (item instanceof Router) {\n const subrouter = item as Router;\n for (const subpath of subrouter.paths) {\n addPath({\n router: this,\n method: subpath.method,\n path: `${path}${subpath.path}`.replace(/^\\/\\//, \"/\"),\n middlewares: subpath.middlewares\n });\n }\n continue;\n }\n\n if (typeof item === \"function\") {\n addPath({ router: this, method: \"use\", path: `${path}.*`, middlewares: [item as Middleware] });\n }\n }\n\n return this;\n }\n\n routes(): string[] {\n return this.paths.filter((path) => path.method === \"add\").map((path) => path.path);\n }\n\n async go(path: string, parentComponent?: Component, preventPushState = false): Promise<string | void> {\n if (!path) {\n throw new Error(\"router.url.required\");\n }\n\n let constructedPath = getPathWithoutLastSlash(`${this.pathPrefix}${path}`);\n const parts = constructedPath.split(\"?\", 2);\n this.url = constructedPath;\n this.query = parseQuery(parts[1]);\n\n const middlewares = searchMiddlewares(this as RouterInterface, parts[0].replace(/(.+)\\/$/, \"$1\").split(\"#\")[0]);\n let component = await searchComponent(this as RouterInterface, middlewares);\n\n if (component === false) {\n return;\n }\n\n if (!component) {\n throw new Error(`The url ${constructedPath} requested wasn't found`);\n }\n\n if (isComponent(parentComponent) || isVnodeComponent(parentComponent)) {\n const childComponent = isVnodeComponent(component) ? component : v(component as Component, {});\n if (isVnodeComponent(parentComponent)) {\n parentComponent.children.push(childComponent);\n component = parentComponent;\n } else {\n component = v(parentComponent, {}, childComponent) as VnodeComponentInterface;\n }\n }\n\n if (!isNodeJs && !preventPushState) {\n window.history.pushState(null, \"\", constructedPath);\n }\n\n if (this.container) {\n return mount(this.container, component);\n }\n }\n\n getOnClickHandler(url: string) {\n return (e: MouseEvent) => {\n if (typeof url === \"string\" && url.length > 0) {\n this.go(url);\n }\n e.preventDefault();\n };\n }\n}\n\nlet localRedirect: RedirectFunction;\n\nexport function redirect(url: string, parentComponent?: Component, preventPushState = false): string | void {\n if (!localRedirect) {\n throw new Error(\"router.redirect.not.found\");\n }\n return localRedirect(url, parentComponent, preventPushState);\n}\n\nexport function mountRouter(elementContainer: string | any, router: Router): void {\n router.container = elementContainer;\n localRedirect = router.go.bind(router);\n\n if (!isNodeJs) {\n function onPopStateGoToRoute(): void {\n let pathWithoutPrefix = getPathWithoutPrefix(document.location.pathname, router.pathPrefix);\n (router as unknown as Router).go(pathWithoutPrefix, undefined, true);\n }\n window.addEventListener(\"popstate\", onPopStateGoToRoute, false);\n onPopStateGoToRoute();\n }\n\n directive(\"route\", (url: string, vnode: VnodeWithDom, oldnode?: VnodeWithDom): void => {\n setAttribute(\"href\", url, vnode, oldnode);\n setAttribute(\"onclick\", router.getOnClickHandler(url), vnode, oldnode);\n });\n}\n"],
5
+ "mappings": ";AACA;AAAA,EAKE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAyDP,SAAS,KAAK,OAAY;AACxB,SAAO,MAAM,QAAQ,KAAK,IA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YAAY,kBAAgC,QAAsB;AAChF,SAAO,YAAY;AACnB,kBAAgB,OAAO,GAAG,KAAK,MAAM;AAErC,MAAI,CAAC,UAAU;AACb,QAAS,sBAAT,WAAqC;AACnC,UAAI,oBAAoB,qBAAqB,SAAS,SAAS,UAAU,OAAO,UAAU;AAC1F,MAAC,OAA6B,GAAG,mBAAmB,QAAW,IAAI;AAAA,IACrE;AACA,WAAO,iBAAiB,YAAY,qBAAqB,KAAK;AAC9D,wBAAoB;AAAA,EACtB;AAEA,YAAU,SAAS,CAAC,KAAa,OAAqB,YAAiC;AACrF,iBAAa,QAAQ,KAAK,OAAO,OAAO;AACxC,iBAAa,WAAW,OAAO,kBAAkB,GAAG,GAAG,OAAO,OAAO;AAAA,EACvE,CAAC;AACH;",
6
+ "names": []
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../lib/signal/index.ts"],
4
+ "sourcesContent": ["import { VnodeWithDom, current, onUnmount, updateVnode, v } from \"valyrian.js\";\n\ninterface GetterInterface {\n (): any;\n}\n\ninterface SetterInterface {\n (value: any): void;\n}\n\ninterface SubscribeInterface {\n (callback: Function): void;\n}\n\ninterface SubscriptionsInterface extends Array<Function> {}\n\nexport interface SignalInterface extends Array<any> {\n 0: GetterInterface;\n 1: SetterInterface;\n 2: SubscribeInterface;\n 3: SubscriptionsInterface;\n}\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport function Signal(initialValue): SignalInterface {\n // Create a copy of the current context object\n const { vnode, component } = { ...current };\n\n // Check if the context object has a vnode property\n if (vnode) {\n // Is first call\n if (!vnode.components) {\n // Set the components property to an empty array\n vnode.components = [];\n }\n\n // Check if the components array of the vnode object does not contain the component object\n if (vnode.components.indexOf(component) === -1) {\n // Set the calls property to -1\n vnode.signal_calls = -1;\n // Add the component to the components array\n vnode.components.push(component);\n\n // Check if the component object has a signals property\n if (!component.signals) {\n // Set the signals property of the component object to an empty array\n component.signals = [];\n // Add a function to the cleanup stack that removes the signals property from the component object\n onUnmount(() => Reflect.deleteProperty(component, \"signals\"));\n }\n }\n\n // Assign the signal variable to the signal stored at the index of the vnode object's calls property in the vnode's signals array\n let signal: SignalInterface = component.signals[++vnode.signal_calls];\n\n // If a signal has already been assigned to the signal variable, return it\n if (signal) {\n // Remove all subscriptions because we come from a new render\n signal[3].length = 0;\n\n // Return the signal\n return signal;\n }\n }\n\n // Declare a variable to store the current value of the Signal\n let value = initialValue;\n\n // Create an array to store functions that have subscribed to changes to the Signal's value\n const subscriptions: SubscriptionsInterface = [];\n\n // Define a function that allows other parts of the code to subscribe to changes to the Signal's value\n const subscribe = (callback) => {\n // Add the callback function to the subscriptions array if it is not already in the array\n if (subscriptions.indexOf(callback) === -1) {\n subscriptions.push(callback);\n }\n };\n\n // Set the vnodes to update when the Signal's value changes\n let vnodesToUpdate: Array<VnodeWithDom> = [];\n\n // This is the function that will be called when the Signal's value changes\n const updateVnodes = () => {\n // Create a copy of the vnodesToUpdate array and filter out any duplicate vnodes\n let vnodesToUpdateCopy = vnodesToUpdate.filter((vnode, index, self) => {\n return self.findIndex((v) => v.dom === vnode.dom) === index;\n });\n\n // Loop through the vnodesToUpdate array\n for (let i = 0, l = vnodesToUpdateCopy.length; i < l; i++) {\n const vnode2 = vnodesToUpdateCopy[i];\n // If it does, create a new vnode object based on the original vnode, its children, and its DOM and SVG properties\n let newVnode = v(vnode2.tag, vnode2.props, ...vnode2.initialChildren) as VnodeWithDom;\n newVnode.dom = vnode2.dom; // Set the new vnode object's DOM property to the old vnode object's DOM property\n newVnode.isSVG = vnode2.isSVG; // Set the new vnode object's isSVG property to the old vnode object's isSVG property\n\n // Update the vnode object\n updateVnode(newVnode, vnode2);\n }\n };\n\n // Define a function that returns the current value of the Signal\n function get() {\n // Get the current vnode from the context object\n const { vnode: vnode2 } = current;\n\n // If we have a current vnode, it means that a get function is being called from within a component\n // so we subscribe the vnode to be updated when the Signal's value changes\n if (vnode2 && vnodesToUpdate.indexOf(vnode2) === -1) {\n // We set the initialChildren to a copy of the vnode's children array\n // This is the case when the vnode is a component that has not been rendered yet and we need the initial children\n // because they could have the components that are using the Signal\n if (!vnode2.initialChildren) {\n vnode2.initialChildren = [...vnode2.children];\n }\n\n // Add the vnode to the vnodesToUpdate array\n vnodesToUpdate.push(vnode2);\n\n // Subscribe the updateVnodes function to the Signal\n subscribe(updateVnodes);\n }\n\n // Return the current value of the Signal\n return value;\n }\n\n // Define a function that allows the value of the Signal to be updated and notifies any subscribed functions of the change\n const set = (newValue) => {\n // If we have a current event on going, prevent the default action\n if (current.event) {\n current.event.preventDefault();\n }\n\n // Just return if the new value is the same as the current value\n if (newValue === value) {\n return;\n }\n\n // Update the value of the Signal\n value = newValue;\n\n // Call each subscribed function with the new value of the Signal as an argument\n for (let i = 0, l = subscriptions.length; i < l; i++) {\n subscriptions[i](value);\n }\n };\n\n // Assign the signal variable an array containing the get, set, and subscribe functions\n let signal: SignalInterface = [get, set, subscribe, subscriptions];\n\n // If the context object has a vnode property, add the signal to the vnode's signals array\n // and add the subscriptions array to the vnode's subscriptions array\n if (vnode) {\n component.signals.push(signal);\n }\n\n // Return the signal\n return signal;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAiE;AAwB1D,SAAS,OAAO,cAA+B;AAEpD,QAAM,EAAE,OAAO,UAAU,IAAI,EAAE,GAAG,wBAAQ;AAG1C,MAAI,OAAO;AAET,QAAI,CAAC,MAAM,YAAY;AAErB,YAAM,aAAa,CAAC;AAAA,IACtB;AAGA,QAAI,MAAM,WAAW,QAAQ,SAAS,MAAM,IAAI;AAE9C,YAAM,eAAe;AAErB,YAAM,WAAW,KAAK,SAAS;AAG/B,UAAI,CAAC,UAAU,SAAS;AAEtB,kBAAU,UAAU,CAAC;AAErB,uCAAU,MAAM,QAAQ,eAAe,WAAW,SAAS,CAAC;AAAA,MAC9D;AAAA,IACF;AAGA,QAAIA,UAA0B,UAAU,QAAQ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AG,KAAK;AACpD,oBAAc,CAAC,EAAE,KAAK;AAAA,IACxB;AAAA,EACF;AAGA,MAAI,SAA0B,CAAC,KAAK,KAAK,WAAW,aAAa;AAIjE,MAAI,OAAO;AACT,cAAU,QAAQ,KAAK,MAAM;AAAA,EAC/B;AAGA,SAAO;AACT;",
6
+ "names": ["signal", "vnode", "v"]
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../lib/signal/index.ts"],
4
+ "sourcesContent": ["import { VnodeWithDom, current, onUnmount, updateVnode, v } from \"valyrian.js\";\n\ninterface GetterInterface {\n (): any;\n}\n\ninterface SetterInterface {\n (value: any): void;\n}\n\ninterface SubscribeInterface {\n (callback: Function): void;\n}\n\ninterface SubscriptionsInterface extends Array<Function> {}\n\nexport interface SignalInterface extends Array<any> {\n 0: GetterInterface;\n 1: SetterInterface;\n 2: SubscribeInterface;\n 3: SubscriptionsInterface;\n}\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport function Signal(initialValue): SignalInterface {\n // Create a copy of the current context object\n const { vnode, component } = { ...current };\n\n // Check if the context object has a vnode property\n if (vnode) {\n // Is first call\n if (!vnode.components) {\n // Set the components property to an empty array\n vnode.components = [];\n }\n\n // Check if the components array of the vnode object does not contain the component object\n if (vnode.components.indexOf(component) === -1) {\n // Set the calls property to -1\n vnode.signal_calls = -1;\n // Add the component to the components array\n vnode.components.push(component);\n\n // Check if the component object has a signals property\n if (!component.signals) {\n // Set the signals property of the component object to an empty array\n component.signals = [];\n // Add a function to the cleanup stack that removes the signals property from the component object\n onUnmount(() => Reflect.deleteProperty(component, \"signals\"));\n }\n }\n\n // Assign the signal variable to the signal stored at the index of the vnode object's calls property in the vnode's signals array\n let signal: SignalInterface = component.signals[++vnode.signal_calls];\n\n // If a signal has already been assigned to the signal variable, return it\n if (signal) {\n // Remove all subscriptions because we come from a new render\n signal[3].length = 0;\n\n // Return the signal\n return signal;\n }\n }\n\n // Declare a variable to store the current value of the Signal\n let value = initialValue;\n\n // Create an array to store functions that have subscribed to changes to the Signal's value\n const subscriptions: SubscriptionsInterface = [];\n\n // Define a function that allows other parts of the code to subscribe to changes to the Signal's value\n const subscribe = (callback) => {\n // Add the callback function to the subscriptions array if it is not already in the array\n if (subscriptions.indexOf(callback) === -1) {\n subscriptions.push(callback);\n }\n };\n\n // Set the vnodes to update when the Signal's value changes\n let vnodesToUpdate: Array<VnodeWithDom> = [];\n\n // This is the function that will be called when the Signal's value changes\n const updateVnodes = () => {\n // Create a copy of the vnodesToUpdate array and filter out any duplicate vnodes\n let vnodesToUpdateCopy = vnodesToUpdate.filter((vnode, index, self) => {\n return self.findIndex((v) => v.dom === vnode.dom) === index;\n });\n\n // Loop through the vnodesToUpdate array\n for (let i = 0, l = vnodesToUpdateCopy.length; i < l; i++) {\n const vnode2 = vnodesToUpdateCopy[i];\n // If it does, create a new vnode object based on the original vnode, its children, and its DOM and SVG properties\n let newVnode = v(vnode2.tag, vnode2.props, ...vnode2.initialChildren) as VnodeWithDom;\n newVnode.dom = vnode2.dom; // Set the new vnode object's DOM property to the old vnode object's DOM property\n newVnode.isSVG = vnode2.isSVG; // Set the new vnode object's isSVG property to the old vnode object's isSVG property\n\n // Update the vnode object\n updateVnode(newVnode, vnode2);\n }\n };\n\n // Define a function that returns the current value of the Signal\n function get() {\n // Get the current vnode from the context object\n const { vnode: vnode2 } = current;\n\n // If we have a current vnode, it means that a get function is being called from within a component\n // so we subscribe the vnode to be updated when the Signal's value changes\n if (vnode2 && vnodesToUpdate.indexOf(vnode2) === -1) {\n // We set the initialChildren to a copy of the vnode's children array\n // This is the case when the vnode is a component that has not been rendered yet and we need the initial children\n // because they could have the components that are using the Signal\n if (!vnode2.initialChildren) {\n vnode2.initialChildren = [...vnode2.children];\n }\n\n // Add the vnode to the vnodesToUpdate array\n vnodesToUpdate.push(vnode2);\n\n // Subscribe the updateVnodes function to the Signal\n subscribe(updateVnodes);\n }\n\n // Return the current value of the Signal\n return value;\n }\n\n // Define a function that allows the value of the Signal to be updated and notifies any subscribed functions of the change\n const set = (newValue) => {\n // If we have a current event on going, prevent the default action\n if (current.event) {\n current.event.preventDefault();\n }\n\n // Just return if the new value is the same as the current value\n if (newValue === value) {\n return;\n }\n\n // Update the value of the Signal\n value = newValue;\n\n // Call each subscribed function with the new value of the Signal as an argument\n for (let i = 0, l = subscriptions.length; i < l; i++) {\n subscriptions[i](value);\n }\n };\n\n // Assign the signal variable an array containing the get, set, and subscribe functions\n let signal: SignalInterface = [get, set, subscribe, subscriptions];\n\n // If the context object has a vnode property, add the signal to the vnode's signals array\n // and add the subscriptions array to the vnode's subscriptions array\n if (vnode) {\n component.signals.push(signal);\n }\n\n // Return the signal\n return signal;\n}\n"],
5
+ "mappings": ";AAAA,SAAuB,SAAS,WAAW,aAAa,SAAS;AAwB1D,SAAS,OAAO,cAA+B;AAEpD,QAAM,EAAE,OAAO,UAAU,IAAI,EAAE,GAAG,QAAQ;AAG1C,MAAI,OAAO;AAET,QAAI,CAAC,MAAM,YAAY;AAErB,YAAM,aAAa,CAAC;AAAA,IACtB;AAGA,QAAI,MAAM,WAAW,QAAQ,SAAS,MAAM,IAAI;AAE9C,YAAM,eAAe;AAErB,YAAM,WAAW,KAAK,SAAS;AAG/B,UAAI,CAAC,UAAU,SAAS;AAEtB,kBAAU,UAAU,CAAC;AAErB,kBAAU,MAAM,QAAQ,eAAe,WAAW,SAAS,CAAC;AAAA,MAC9D;AAAA,IACF;AAGA,QAAIA,UAA0B,UAAU,QAAQ,EAAE,MAAM,YAAY;AAGpE,QAAIA,SAAQ;AAEV,MAAAA,QAAO,CAAC,EAAE,SAAS;AAGnB,aAAOA;AAAA,IACT;AAAA,EACF;AAGA,MAAI,QAAQ;AAGZ,QAAM,gBAAwC,CAAC;AAG/C,QAAM,YAAY,CAAC,aAAa;AAE9B,QAAI,cAAc,QAAQ,QAAQ,MAAM,IAAI;AAC1C,oBAAc,KAAK,QAAQ;AAAA,IAC7B;AAAA,EACF;AAGA,M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"sourcesContent": ["import { update } from \"valyrian.js\";\n\ninterface StoreOptions {\n state?: Record<string, unknown> | (() => Record<string, unknown>);\n getters?: Record<string, Function>;\n mutations?: Record<string, Function>;\n actions?: Record<string, Function>;\n}\n\ninterface StoreInstance {\n // eslint-disable-next-line no-unused-vars\n new (options: StoreOptions): StoreInstance;\n state: Record<string, any>;\n getters?: Record<string, any>;\n // eslint-disable-next-line no-unused-vars\n commit: (type: string, ...payload: any[]) => void;\n // eslint-disable-next-line no-unused-vars\n dispatch: (type: string, ...payload: any[]) => void;\n}\n\nfunction keyExists(typeOfKey: string, object: Record<string, unknown>, key: string) {\n if (key in object === false) {\n throw new Error(`The ${typeOfKey} \"${key}\" does not exists.`);\n }\n}\n\nfunction deepFreeze(obj: any) {\n if (typeof obj === \"object\" && obj !== null && !Object.isFrozen(obj)) {\n if (Array.isArray(obj)) {\n for (let i = 0, l = obj.length; i < l; i++) {\n deepFreeze(obj[i]);\n }\n } else {\n let props = Reflect.ownKeys(obj);\n for (let i = 0, l = props.length; i < l; i++) {\n deepFreeze(obj[props[i]]);\n }\n }\n Object.freeze(obj);\n }\n\n return obj;\n}\n\nlet updateTimeout: any;\nfunction delayedUpdate() {\n clearTimeout(updateTimeout);\n updateTimeout = setTimeout(update);\n}\n\nexport const Store = function Store(\n this: StoreInstance,\n { state = {}, getters = {}, actions = {}, mutations = {} }: StoreOptions = {}\n) {\n let frozen = true;\n\n function isUnfrozen() {\n if (frozen) {\n throw new Error(\"You need to commit a mutation to change the state\");\n }\n }\n\n let localState = typeof state === \"function\" ? state() : state;\n\n this.state = new Proxy(localState || {}, {\n get: (state, prop: string) => deepFreeze(state[prop]),\n set: (state, prop: string, value: any) => {\n isUnfrozen();\n state[prop] = value;\n return true;\n },\n deleteProperty: (state, prop: string) => {\n isUnfrozen();\n Reflect.deleteProperty(state, prop);\n return true;\n }\n });\n\n this.getters = new Proxy(getters, {\n get: (getters, getter: string) => {\n try {\n return getters[getter](this.state, this.getters);\n } catch (e) {\n // Getters should fail silently\n }\n }\n });\n\n this.commit = (mutation, ...args) => {\n keyExists(\"mutation\", mutations, mutation);\n frozen = false;\n mutations[mutation](this.state, ...args);\n frozen = true;\n delayedUpdate();\n };\n\n this.dispatch = (action, ...args) => {\n keyExists(\"action\", actions, action);\n return Promise.resolve(actions[action](this, ...args));\n };\n} as unknown as StoreInstance;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAuB;AAoBvB,SAAS,UAAU,WAAmB,QAAiC,KAAa;AAClF,MAAI,OAAO,WAAW,OAAO;AAC3B,UAAM,IAAI,MAAM,OAAO,SAAS,KAAK,GAAG,oBAAoB;AAAA,EAC9D;AACF;AAEA,SAAS,WAAW,KAAU;AAC5B,MAAI,OAAO,QAAQ,YAAY,QAAQ,QAAQ,CAAC,OAAO,SAAS,GAAG,GAAG;AACpE,QAAI,MAAM,QAAQ,GAAG,GAAG;AACtB,eAAS,IAAI,GAAG,IAAI,IAAI,QAAQ,IAAI,GAAG,KAAK;AAC1C,mBAAW,IAAI,CAAC,CAAC;AAAA,MACnB;AAAA,IACF,OAAO;AACL,UAAI,QAAQ,QAAQ,QAAQ,GAAG;AAC/B,eAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,IAAI,GAAG,KAAK;AAC5C,mBAAW,IAAI,MAAM,CAAC,CAAC,CAAC;AAAA,MAC1B;AAAA,IACF;AACA,WAAO,OAAO,GAAG;AAAA,EACnB;AAEA,SAAO;AACT;AAEA,IAAI;AACJ,SAAS,gBAAgB;AACvB,eAAa,aAAa;AAC1B,kBAAgB,WAAW,sBAAM;AACnC;AAEO,IAAM,QAAQ,SAASA,OAE5B,EAAE,QAAQ,CAAC,GAAG,UAAU,CAAC,GAAG,UAAU,CAAC,GAAG,YAAY,CAAC,EAAE,IAAkB,CAAC,GAC5E;AACA,MAAI,SAAS;AAEb,WAAS,aAAa;AACpB,QAAI,QAAQ;AACV,YAAM,IAAI,MAAM,mDAAmD;AAAA,IACrE;AAAA,EACF;AAEA,MAAI,aAAa,OAAO,UAAU,aAAa,MAAM,IAAI;AAEzD,OAAK,QAAQ,IAAI,MAAM,cAAc,CAAC,GAAG;AAAA,IACvC,KAAK,CAACC,QAAO,SAAiB,WAAWA,OAAM,IAAI,CAAC;AAAA,IACpD,KAAK,CAACA,QAAO,MAAc,UAAe;AACxC,iBAAW;AACX,MAAAA,OAAM,IAAI,IAAI;AACd,aAAO;AAAA,IACT;AAAA,IACA,gBAAgB,CAACA,QAAO,SAAiB;AACvC,iBAAW;AACX,cAAQ,eAAeA,QAAO,IAAI;AAClC,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AAED,OAAK,UAAU,IAAI,MAAM,SAAS;AAAA,IAChC,KAAK,CAACC,UAAS,WAAmB;AAChC,UAAI;AACF,eAAOA,SAAQ,MAAM,EAAE,KAAK,OAAO,KAAK,OAAO;AAAA,MACjD,SAAS,GAAG;AAAA,MAEZ;AAAA,IACF;AAAA,EACF,CAAC;AAED,OAAK,SAAS,CAAC,aAAa,SAAS;AACnC,cAAU,YAAY,WAAW,QAAQ;AACzC,aAAS;AACT,cAAU,QAAQ,EAAE,KAAK,OAAO,GAAG,IAAI;AACvC,aAAS;AACT,kBAAc;AAAA,EAChB;AAEA,OAAK,WAAW,CAAC,WAAW,SAAS;AACnC,cAAU,UAAU,SAAS,MAAM;AACnC,WAAO,QAAQ,QAAQ,QAAQ,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;AAAA,EACvD;AACF;",
6
+ "names": ["Store", "state", "getters"]
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../lib/store/index.ts"],
4
+ "sourcesContent": ["import { update } from \"valyrian.js\";\n\ninterface StoreOptions {\n state?: Record<string, unknown> | (() => Record<string, unknown>);\n getters?: Record<string, Function>;\n mutations?: Record<string, Function>;\n actions?: Record<string, Function>;\n}\n\ninterface StoreInstance {\n // eslint-disable-next-line no-unused-vars\n new (options: StoreOptions): StoreInstance;\n state: Record<string, any>;\n getters?: Record<string, any>;\n // eslint-disable-next-line no-unused-vars\n commit: (type: string, ...payload: any[]) => void;\n // eslint-disable-next-line no-unused-vars\n dispatch: (type: string, ...payload: any[]) => void;\n}\n\nfunction keyExists(typeOfKey: string, object: Record<string, unknown>, key: string) {\n if (key in object === false) {\n throw new Error(`The ${typeOfKey} \"${key}\" does not exists.`);\n }\n}\n\nfunction deepFreeze(obj: any) {\n if (typeof obj === \"object\" && obj !== null && !Object.isFrozen(obj)) {\n if (Array.isArray(obj)) {\n for (let i = 0, l = obj.length; i < l; i++) {\n deepFreeze(obj[i]);\n }\n } else {\n let props = Reflect.ownKeys(obj);\n for (let i = 0, l = props.length; i < l; i++) {\n deepFreeze(obj[props[i]]);\n }\n }\n Object.freeze(obj);\n }\n\n return obj;\n}\n\nlet updateTimeout: any;\nfunction delayedUpdate() {\n clearTimeout(updateTimeout);\n updateTimeout = setTimeout(update);\n}\n\nexport const Store = function Store(\n this: StoreInstance,\n { state = {}, getters = {}, actions = {}, mutations = {} }: StoreOptions = {}\n) {\n let frozen = true;\n\n function isUnfrozen() {\n if (frozen) {\n throw new Error(\"You need to commit a mutation to change the state\");\n }\n }\n\n let localState = typeof state === \"function\" ? state() : state;\n\n this.state = new Proxy(localState || {}, {\n get: (state, prop: string) => deepFreeze(state[prop]),\n set: (state, prop: string, value: any) => {\n isUnfrozen();\n state[prop] = value;\n return true;\n },\n deleteProperty: (state, prop: string) => {\n isUnfrozen();\n Reflect.deleteProperty(state, prop);\n return true;\n }\n });\n\n this.getters = new Proxy(getters, {\n get: (getters, getter: string) => {\n try {\n return getters[getter](this.state, this.getters);\n } catch (e) {\n // Getters should fail silently\n }\n }\n });\n\n this.commit = (mutation, ...args) => {\n keyExists(\"mutation\", mutations, mutation);\n frozen = false;\n mutations[mutation](this.state, ...args);\n frozen = true;\n delayedUpdate();\n };\n\n this.dispatch = (action, ...args) => {\n keyExists(\"action\", actions, action);\n return Promise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Ae;AACxC,iBAAW;AACX,MAAAA,OAAM,IAAI,IAAI;AACd,aAAO;AAAA,IACT;AAAA,IACA,gBAAgB,CAACA,QAAO,SAAiB;AACvC,iBAAW;AACX,cAAQ,eAAeA,QAAO,IAAI;AAClC,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AAED,OAAK,UAAU,IAAI,MAAM,SAAS;AAAA,IAChC,KAAK,CAACC,UAAS,WAAmB;AAChC,UAAI;AACF,eAAOA,SAAQ,MAAM,EAAE,KAAK,OAAO,KAAK,OAAO;AAAA,MACjD,SAAS,GAAG;AAAA,MAEZ;AAAA,IACF;AAAA,EACF,CAAC;AAED,OAAK,SAAS,CAAC,aAAa,SAAS;AACnC,cAAU,YAAY,WAAW,QAAQ;AACzC,aAAS;AACT,cAAU,QAAQ,EAAE,KAAK,OAAO,GAAG,IAAI;AACvC,aAAS;AACT,kBAAc;AAAA,EAChB;AAEA,OAAK,WAAW,CAAC,WAAW,SAAS;AACnC,cAAU,UAAU,SAAS,MAAM;AACnC,WAAO,QAAQ,QAAQ,QAAQ,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;AAAA,EACvD;AACF;",
6
+ "names": ["Store", "state", "getters"]
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../lib/sw/index.ts"],
4
+ "sourcesContent": ["import { isNodeJs } from \"valyrian.js\";\n\nexport async function registerSw(file = \"./sw.js\", options: RegistrationOptions = { scope: \"/\" }) {\n if (isNodeJs) {\n return;\n }\n await navigator.serviceWorker.register(file, options);\n return navigator.serviceWorker;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAyB;AAEzB,eAAsB,WAAW,OAAO,WAAW,UAA+B,EAAE,OAAO,IAAI,GAAG;AAChG,MAAI,0BAAU;AACZ;AAAA,EACF;AACA,QAAM,UAAU,cAAc,SAAS,MAAM,OAAO;AACpD,SAAO,UAAU;AACnB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../lib/sw/index.ts"],
4
+ "sourcesContent": ["import { isNodeJs } from \"valyrian.js\";\n\nexport async function registerSw(file = \"./sw.js\", options: RegistrationOptions = { scope: \"/\" }) {\n if (isNodeJs) {\n return;\n }\n await navigator.serviceWorker.register(file, options);\n return navigator.serviceWorker;\n}\n"],
5
+ "mappings": ";AAAA,SAAS,gBAAgB;AAEzB,eAAsB,WAAW,OAAO,WAAW,UAA+B,EAAE,OAAO,IAAI,GAAG;AAChG,MAAI,UAAU;AACZ;AAAA,EACF;AACA,QAAM,UAAU,cAAc,SAAS,MAAM,OAAO;AACpD,SAAO,UAAU;AACnB;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "valyrian.js",
3
- "version": "7.2.8",
3
+ "version": "7.2.9",
4
4
  "description": "Lightweight steel to forge PWAs. (Minimal Frontend Framework with server side rendering and other capabilities)",
5
5
  "repository": "git@github.com:Masquerade-Circus/valyrian.js.git",
6
6
  "author": "Masquerade <christian@masquerade-circus.net>",