defuss 1.2.4 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/dist/index-B8vV328V.cjs +2 -0
- package/dist/index-B8vV328V.cjs.map +1 -0
- package/dist/index-BDxEyjzN.mjs +2 -0
- package/dist/index-BDxEyjzN.mjs.map +1 -0
- package/dist/{index-BILpZg_l.d.ts → index-aOQf6G9I.d.ts} +104 -31
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +182 -5
- package/dist/index.d.ts +182 -5
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/dist/render/client.cjs +1 -1
- package/dist/render/client.cjs.map +1 -1
- package/dist/render/client.d.cts +4 -3
- package/dist/render/client.d.ts +4 -3
- package/dist/render/client.mjs +1 -1
- package/dist/render/client.mjs.map +1 -1
- package/dist/render/index.cjs +1 -1
- package/dist/render/index.cjs.map +1 -1
- package/dist/render/index.d.cts +1 -1
- package/dist/render/index.d.ts +1 -1
- package/dist/render/index.mjs +1 -1
- package/dist/render/index.mjs.map +1 -1
- package/dist/render/server.cjs +1 -1
- package/dist/render/server.cjs.map +1 -1
- package/dist/render/server.d.cts +2 -2
- package/dist/render/server.d.ts +2 -2
- package/dist/render/server.mjs +1 -1
- package/dist/render/server.mjs.map +1 -1
- package/package.json +11 -8
package/LICENSE
CHANGED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var M=Object.defineProperty;var c=(n,s)=>M(n,"name",{value:s,configurable:!0});const m=/(.*)\[(\d+)\]/,I=/^\d+$/,l=c(n=>n.split(".").flatMap(s=>{const e=s.match(m);return e?[...l(e[1]),Number(e[2])]:s}),"getAllKeysFromPath"),g=c((n,s,e)=>{s in n||(n[s]=I.test(String(e))?[]:{})},"ensureKey"),A=c((n,s)=>l(s).reduce((r,t)=>r?.[t],n),"getByPath"),h=c((n,s,e)=>{const r=l(s),t=r[0],o=Array.isArray(n)?[...n]:{...n};return r.length===1?(e===void 0?Array.isArray(o)?o.splice(Number(t),1):delete o[t]:o[t]=e,o):(g(o,t,r[1]),o[t]=h(o[t],r.slice(1).join("."),e),o)},"setByPath"),E="class",T="xlink",L="xmlns",C="ref",p={[L]:"http://www.w3.org/2000/xmlns/",[T]:"http://www.w3.org/1999/xlink",svg:"http://www.w3.org/2000/svg"},N=c(n=>n&&typeof n=="object"&&!n.attributes&&!n.type&&!n.children,"isJSXComment"),b=c(n=>n.filter(s=>!N(s)),"filterComments"),x=c(n=>({type:"p",attributes:{},children:[`FATAL ERROR: ${n?.message||n}`]}),"createInPlaceErrorMessageVNode"),d=c((n,s,e)=>{s={...s},typeof e<"u"&&(s.key=e);let r=(s?.children?[].concat(s.children):[]).filter(Boolean);if(delete s?.children,r=b([].concat.apply([],r)),n==="fragment")return b(r);if(typeof n=="function"&&n.constructor.name!=="AsyncFunction")try{return n({children:r,...s})}catch(t){return typeof t=="string"?t=`[JsxError] in ${n.name}: ${t}`:t instanceof Error&&(t.message=`[JsxError] in ${n.name}: ${t.message}`),x(t)}return{type:n,attributes:s,children:r}},"jsx"),R=c((n,s)=>{if(!n||typeof s!="function")throw new Error("Invalid arguments. Ensure domNode and onUnmount are valid.");const e=n.parentNode;if(!e)throw new Error("The provided domNode does not have a parentNode.");const r=new MutationObserver(t=>{for(const o of t)if(o.removedNodes.length>0){for(const i of o.removedNodes)if(i===n){s(),r.disconnect();return}}});r.observe(e,{childList:!0})},"observeUnmount"),S=c(n=>{typeof n?.$onMount=="function"&&(n.$onMount(),n.$onMount=null),typeof n?.$onUnmount=="function"&&R(n,n.$onUnmount)},"handleLifecycleEventsForOnMount"),y=c(n=>{const s={hasElNamespace:c(e=>e.namespaceURI===p.svg,"hasElNamespace"),hasSvgNamespace:c((e,r)=>s.hasElNamespace(e)&&r!=="STYLE"&&r!=="SCRIPT","hasSvgNamespace"),createElementOrElements:c((e,r)=>Array.isArray(e)?s.createChildElements(e,r):typeof e<"u"?s.createElement(e,r):s.createTextNode("",r),"createElementOrElements"),createElement:c((e,r)=>{let t;try{e.constructor.name==="AsyncFunction"?t=n.createElement("div"):typeof e.type=="function"?(t=n.createElement("div"),t.innerText=`FATAL ERROR: ${e.type._error}`):e.type.toUpperCase()==="SVG"||r&&s.hasSvgNamespace(r,e.type.toUpperCase())?t=n.createElementNS(p.svg,e.type):t=n.createElement(e.type),e.attributes&&(s.setAttributes(e,t),e.attributes.dangerouslySetInnerHTML&&(t.innerHTML=e.attributes.dangerouslySetInnerHTML.__html)),e.children&&s.createChildElements(e.children,t),r&&(r.appendChild(t),S(t))}catch(o){throw console.error("Fatal error! Error happend while rendering the VDOM!",o,e),o}return t},"createElement"),createTextNode:c((e,r)=>{const t=n.createTextNode(e.toString());return r&&r.appendChild(t),t},"createTextNode"),createChildElements:c((e,r)=>{const t=[];for(let o=0;o<e.length;o++){const i=e[o];i===null||typeof i!="object"&&typeof i!="function"?t.push(s.createTextNode((typeof i>"u"||i===null?"":i).toString(),r)):t.push(s.createElement(i,r))}return t},"createChildElements"),setAttribute:c((e,r,t,o)=>{if(typeof r>"u"||e==="dangerouslySetInnerHTML")return;if(e===C&&typeof r!="function"){r.current=t;return}if(e.startsWith("on")&&typeof r=="function"){let f=e.substring(2).toLowerCase();const a=f.indexOf("capture"),u=a>-1;f==="mount"&&(t.$onMount=r),f==="unmount"&&(t.$onUnmount=r),u&&(f=f.substring(0,a)),t.addEventListener(f,r,u);return}e==="className"&&(e=E),e===E&&Array.isArray(r)&&(r=r.join(" "));const i=e.match(/[A-Z]/)?.index;if(s.hasElNamespace(t)&&i){const f=e.substring(0,i).toLowerCase(),a=e.substring(i,e.length).toLowerCase(),u=p[f]||null;t.setAttributeNS(u,f===T||f==="xmlns"?`${f}:${a}`:e,r)}else if(e==="style"&&typeof r!="string"){const f=Object.keys(r);for(let a=0;a<f.length;a++)t.style[f[a]]=r[f[a]]}else typeof r=="boolean"?t[e]=r:t.setAttribute(e,r)},"setAttribute"),setAttributes:c((e,r)=>{const t=Object.keys(e.attributes);for(let o=0;o<t.length;o++)s.setAttribute(t[o],e.attributes[t[o]],r,e)},"setAttributes")};return s},"getRenderer"),$=c((n,s,e)=>{const r=s.el||s;let t;return typeof n=="string"?t=y(e.window.document).createTextNode(n,r):t=y(e.window.document).createElementOrElements(n,r),t},"renderIsomorphic"),_=c(n=>n.children,"Fragment"),U=d,F=c((n,s,e,r,t,o)=>{let i;try{i=d(n,s,e)}catch(f){console.error("JSX error:",f,"in",t,"component",o)}return i},"jsxDEV"),w=c(n=>{let s=n;const e=[],r=c((t,o)=>{e.forEach(i=>i(s,t,o))},"notify");return{get value(){return s},get(t){return t?A(s,t):s},set(t,o){const i=s;if(o===void 0)i!==t&&(s=t,r(i));else{const f=h(s,t,o);i!==f&&(s=f,r(i,t))}},subscribe(t){return e.push(t),()=>{const o=e.indexOf(t);o>=0&&e.splice(o,1)}}}},"createStore"),B=c(n=>n&&typeof n=="object"&&"current"in n,"isRef");function O(n,s){const e=w(s),r={current:null,store:e,get state(){return e.value},set state(t){e.set(t)},update:c(t=>{e.set(t)},"update"),subscribe:c(t=>e.subscribe(t),"subscribe")};return typeof n=="function"&&r.subscribe(n),r}c(O,"createRef"),exports.Fragment=_,exports.createInPlaceErrorMessageVNode=x,exports.createRef=O,exports.createStore=w,exports.ensureKey=g,exports.getAllKeysFromPath=l,exports.getByPath=A,exports.getRenderer=y,exports.handleLifecycleEventsForOnMount=S,exports.isRef=B,exports.jsx=d,exports.jsxDEV=F,exports.jsxs=U,exports.observeUnmount=R,exports.renderIsomorphic=$,exports.setByPath=h;
|
|
2
|
+
//# sourceMappingURL=index-B8vV328V.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-B8vV328V.cjs","sources":["../src/common/path.ts","../src/render/isomorph.ts","../src/store/store.ts","../src/render/ref.ts"],"sourcesContent":["const ARRAY_INDEX = /(.*)\\[(\\d+)\\]/;\nconst IS_NUMBER = /^\\d+$/;\n\nexport const getAllKeysFromPath = (path: string): Array<string | number> =>\n path.split('.').flatMap(key => {\n const match = key.match(ARRAY_INDEX);\n return match ? [...getAllKeysFromPath(match[1]), Number(match[2])] : key;\n });\n\nexport const ensureKey = (\n obj: Record<string, any>,\n key: string | number,\n nextKey?: string | number\n): void => {\n if (!(key in obj)) {\n obj[key] = IS_NUMBER.test(String(nextKey)) ? [] : {};\n }\n};\n\nexport const getByPath = (obj: any, path: string): any => {\n const keys = getAllKeysFromPath(path);\n return keys.reduce((result, key) => (result == null ? undefined : result[key]), obj);\n};\n\nexport const setByPath = (obj: any, path: string, value: any): any => {\n const keys = getAllKeysFromPath(path);\n const key = keys[0];\n const newObj = Array.isArray(obj) ? [...obj] : { ...obj };\n\n if (keys.length === 1) {\n if (value === undefined) {\n Array.isArray(newObj) ? newObj.splice(Number(key), 1) : delete newObj[key];\n } else {\n newObj[key] = value;\n }\n return newObj;\n }\n\n ensureKey(newObj, key, keys[1]);\n newObj[key] = setByPath(newObj[key], keys.slice(1).join('.'), value);\n return newObj;\n};\n","import type { Dequery } from '@/dequery/dequery.js'\nimport type { VNodeChild, VNodeChildren, VNode, VNodeType, VNodeAttributes, DomAbstractionImpl, Globals } from '@/render/types.js'\n\nconst CLASS_ATTRIBUTE_NAME = 'class'\nconst XLINK_ATTRIBUTE_NAME = 'xlink'\nconst XMLNS_ATTRIBUTE_NAME = 'xmlns'\nconst REF_ATTRIBUTE_NAME = 'ref'\n\nconst nsMap = {\n [XMLNS_ATTRIBUTE_NAME]: 'http://www.w3.org/2000/xmlns/',\n [XLINK_ATTRIBUTE_NAME]: 'http://www.w3.org/1999/xlink',\n svg: 'http://www.w3.org/2000/svg',\n}\n\n// If a JSX comment is written, it looks like: { /* this */ }\n// Therefore, it turns into: {}, which is detected here\nconst isJSXComment = (node: VNode): boolean =>\n /* v8 ignore next */\n node && typeof node === 'object' && !node.attributes && !node.type && !node.children\n\n// Filters comments and undefines like: ['a', 'b', false, {}] to: ['a', 'b', false]\nconst filterComments = (children: Array<VNode> | Array<VNodeChild>) =>\n children.filter((child: VNodeChild) => !isJSXComment(child as VNode))\n\nexport const createInPlaceErrorMessageVNode = (error: unknown) => ({\n type: 'p',\n attributes: {},\n children: [`FATAL ERROR: ${(error as Error)?.message || error}`]\n})\n\nexport const jsx = (\n type: VNodeType | Function | any,\n attributes: (JSX.HTMLAttributes & JSX.SVGAttributes & Record<string, any>) | null,\n key?: string\n): Array<VNode> | VNode => {\n\n // clone attributes as well\n attributes = { ...attributes }\n\n if (typeof key !== \"undefined\") {\n /* key passed for instance-based lifecycle event listener registration */\n attributes.key = key;\n }\n\n // extract children from attributes and ensure it's always an array\n let children: Array<VNodeChild> = (attributes?.children ? [].concat(attributes.children) : []).filter(Boolean);\n delete attributes?.children;\n\n children = filterComments(\n // Implementation to flatten virtual node children structures like:\n // [<p>1</p>, [<p>2</p>,<p>3</p>]] to: [<p>1</p>,<p>2</p>,<p>3</p>]\n ([] as Array<VNodeChildren>).concat.apply([], children as any) as Array<VNodeChildren>,\n )\n\n // effectively unwrap by directly returning the children\n if (type === 'fragment') {\n return filterComments(children) as Array<VNode>;\n }\n\n // it's a component, divide and conquer children\n // in case of async functions, we just pass them through\n if (typeof type === 'function' && type.constructor.name !== 'AsyncFunction') {\n\n try {\n return type({\n children,\n ...attributes,\n })\n } catch (error) {\n\n if (typeof error === \"string\") {\n error = `[JsxError] in ${type.name}: ${error}`;\n } else if (error instanceof Error) {\n error.message = `[JsxError] in ${type.name}: ${error.message}`;\n }\n\n // render the error in place\n return createInPlaceErrorMessageVNode(error)\n }\n }\n\n return {\n type,\n attributes,\n children,\n };\n}\n\nexport const observeUnmount = (domNode: Node, onUnmount: () => void): void => {\n if (!domNode || typeof onUnmount !== 'function') {\n throw new Error('Invalid arguments. Ensure domNode and onUnmount are valid.');\n }\n\n const parentNode = domNode.parentNode;\n if (!parentNode) {\n throw new Error('The provided domNode does not have a parentNode.');\n }\n\n const observer = new MutationObserver((mutationsList) => {\n for (const mutation of mutationsList) {\n if (mutation.removedNodes.length > 0) {\n for (const removedNode of mutation.removedNodes) {\n if (removedNode === domNode) {\n onUnmount();\n observer.disconnect(); // Stop observing after unmount\n return;\n }\n }\n }\n }\n });\n\n // Observe the parentNode for child removals\n observer.observe(parentNode, { childList: true });\n}\n\n/** lifecycle event attachment has been implemented separately, because it is also required to run when partially updating the DOM */\nexport const handleLifecycleEventsForOnMount = (newEl: HTMLElement) => {\n\n // check for a lifecycle \"onMount\" hook and call it\n if (typeof (newEl as any)?.$onMount === 'function') {\n ; (newEl as any).$onMount!()\n // remove the hook after it's been called\n ; (newEl as any).$onMount = null;\n }\n\n // optionally check for a element lifecycle \"onUnmount\" and hook it up\n if (typeof (newEl as any)?.$onUnmount === 'function') {\n // register the unmount observer (MutationObserver)\n observeUnmount(newEl as HTMLElement, (newEl as any).$onUnmount!);\n }\n}\n\nexport const getRenderer = (document: Document): DomAbstractionImpl => {\n // DOM abstraction layer for manipulation\n const renderer = {\n hasElNamespace: (domElement: Element | Document): boolean => (domElement as Element).namespaceURI === nsMap.svg,\n\n hasSvgNamespace: (parentElement: Element | Document, type: string): boolean =>\n renderer.hasElNamespace(parentElement) && type !== 'STYLE' && type !== 'SCRIPT',\n\n createElementOrElements: (\n virtualNode: VNode | undefined | Array<VNode | undefined | string>,\n parentDomElement?: Element | Document,\n ): Array<Element | Text | undefined> | Element | Text | undefined => {\n if (Array.isArray(virtualNode)) {\n return renderer.createChildElements(virtualNode, parentDomElement)\n }\n if (typeof virtualNode !== 'undefined') {\n return renderer.createElement(virtualNode, parentDomElement)\n }\n // undefined virtualNode -> e.g. when a tsx variable is used in markup which is undefined\n return renderer.createTextNode('', parentDomElement)\n },\n\n createElement: (virtualNode: VNode, parentDomElement?: Element | Document): Element | undefined => {\n let newEl: Element | undefined = undefined;\n\n try {\n // if a synchronous function is still a function, VDOM has obviously not resolved, probably an \n // Error occurred while generating the VDOM (in JSX runtime)\n if (\n virtualNode.constructor.name === 'AsyncFunction'\n ) {\n newEl = document.createElement('div')\n } else if (typeof virtualNode.type === 'function') {\n newEl = document.createElement('div')\n ; (newEl as HTMLElement).innerText = `FATAL ERROR: ${virtualNode.type._error}`\n } else if ( // SVG support\n virtualNode.type.toUpperCase() === 'SVG' ||\n (parentDomElement && renderer.hasSvgNamespace(parentDomElement, virtualNode.type.toUpperCase()))\n ) { // SVG support\n newEl = document.createElementNS(nsMap.svg, virtualNode.type as string)\n } else {\n newEl = document.createElement(virtualNode.type as string)\n }\n\n if (virtualNode.attributes) {\n renderer.setAttributes(virtualNode, newEl as Element)\n\n // Apply dangerouslySetInnerHTML if provided\n if (virtualNode.attributes.dangerouslySetInnerHTML) {\n // TODO: FIX me\n newEl.innerHTML = virtualNode.attributes.dangerouslySetInnerHTML.__html;\n }\n }\n\n if (virtualNode.children) {\n renderer.createChildElements(virtualNode.children, newEl as Element)\n }\n\n if (parentDomElement) {\n parentDomElement.appendChild(newEl)\n handleLifecycleEventsForOnMount(newEl as HTMLElement)\n }\n } catch (e) {\n console.error('Fatal error! Error happend while rendering the VDOM!', e, virtualNode);\n throw e;\n }\n return newEl as Element\n },\n\n createTextNode: (text: string, domElement?: Element | Document): Text => {\n const node = document.createTextNode(text.toString())\n\n if (domElement) {\n domElement.appendChild(node)\n }\n return node\n },\n\n createChildElements: (\n virtualChildren: VNodeChildren,\n domElement?: Element | Document,\n ): Array<Element | Text | undefined> => {\n const children: Array<Element | Text | undefined> = []\n\n for (let i = 0; i < virtualChildren.length; i++) {\n const virtualChild = virtualChildren[i]\n if (virtualChild === null || (typeof virtualChild !== 'object' && typeof virtualChild !== 'function')) {\n children.push(\n renderer.createTextNode(\n (typeof virtualChild === 'undefined' || virtualChild === null ? '' : virtualChild!).toString(),\n domElement,\n ),\n )\n } else {\n children.push(renderer.createElement(virtualChild as VNode, domElement))\n }\n }\n return children\n },\n\n setAttribute: (name: string, value: any, domElement: Element, virtualNode: VNode<VNodeAttributes>) => {\n // attributes not set (undefined) are ignored; use null value to reset an attributes state\n if (typeof value === 'undefined') return // if not set, ignore\n\n // TODO: use DANGROUSLY_SET_INNER_HTML_ATTRIBUTE here\n if (name === 'dangerouslySetInnerHTML') return; // special case, handled elsewhere\n\n // save ref as { current: DOMElement } in ref object\n // allows for ref={someRef}\n if (name === REF_ATTRIBUTE_NAME && typeof value !== 'function') {\n value.current = domElement // update ref\n return; // but do not render the ref as a string [object Object] into the DOM\n }\n\n if (name.startsWith('on') && typeof value === 'function') {\n\n let eventName = name.substring(2).toLowerCase()\n const capturePos = eventName.indexOf('capture')\n const doCapture = capturePos > -1\n\n if (eventName === 'mount') {\n ; (domElement as any).$onMount = value // DOM event lifecycle hook\n }\n\n if (eventName === 'unmount') {\n ; (domElement as any).$onUnmount = value // DOM event lifecycle hook\n }\n\n // onClickCapture={...} support\n if (doCapture) {\n eventName = eventName.substring(0, capturePos)\n }\n domElement.addEventListener(eventName, value, doCapture)\n return\n }\n\n // transforms className=\"...\" -> class=\"...\"\n // allows for React JSX to work seamlessly\n if (name === 'className') {\n name = CLASS_ATTRIBUTE_NAME\n }\n\n // transforms class={['a', 'b']} into class=\"a b\"\n if (name === CLASS_ATTRIBUTE_NAME && Array.isArray(value)) {\n value = value.join(' ')\n }\n\n // SVG support\n const nsEndIndex = name.match(/[A-Z]/)?.index\n if (renderer.hasElNamespace(domElement) && nsEndIndex) {\n const ns = name.substring(0, nsEndIndex).toLowerCase()\n const attrName = name.substring(nsEndIndex, name.length).toLowerCase()\n const namespace = nsMap[ns as keyof typeof nsMap] || null\n domElement.setAttributeNS(\n namespace,\n ns === XLINK_ATTRIBUTE_NAME || ns === 'xmlns' ? `${ns}:${attrName}` : name,\n value,\n )\n } else if (name === 'style' && typeof value !== 'string') {\n const propNames = Object.keys(value)\n\n // allows for style={{ margin: 10 }} etc.\n for (let i = 0; i < propNames.length; i++) {\n ; (domElement as HTMLElement).style[propNames[i] as any] = value[propNames[i]]\n }\n } else if (typeof value === 'boolean') {\n // for cases like <button checked={false} />\n ; (domElement as any)[name] = value\n } else {\n // for any other case\n domElement.setAttribute(name, value)\n }\n },\n\n setAttributes: (virtualNode: VNode<VNodeAttributes>, domElement: Element) => {\n const attrNames = Object.keys(virtualNode.attributes!)\n for (let i = 0; i < attrNames.length; i++) {\n renderer.setAttribute(attrNames[i], virtualNode.attributes![attrNames[i]], domElement, virtualNode)\n }\n },\n }\n return renderer\n}\n\nexport const renderIsomorphic = (\n virtualNode: VNode | undefined | string | Array<VNode | undefined | string>,\n parentDomElement: Element | Document | Dequery | undefined,\n globals: Globals,\n): Array<Element | Text | undefined> | Element | Text | undefined => {\n\n const parentEl = (parentDomElement as Dequery).el as Element || parentDomElement\n let renderResult: Array<Element | Text | undefined> | Element | Text | undefined\n\n if (typeof virtualNode === 'string') {\n renderResult = getRenderer(globals.window.document).createTextNode(virtualNode, parentEl)\n } else {\n renderResult = getRenderer(globals.window.document).createElementOrElements(virtualNode, parentEl)\n }\n return renderResult;\n}\n\n// --- JSX standard (necessary exports for jsx-runtime)\nexport const Fragment = (props: VNode) => props.children\nexport const jsxs = jsx\nexport const jsxDEV = (\n type: VNodeType | Function | any,\n attributes: (JSX.HTMLAttributes & JSX.SVGAttributes & Record<string, any>) | null,\n key?: string,\n allChildrenAreStatic?: boolean,\n sourceInfo?: string,\n selfReference?: any,\n): Array<VNode> | VNode => {\n let renderResult: Array<VNode> | VNode;\n try {\n renderResult = jsx(type, attributes, key);\n } catch (error) {\n console.error(\"JSX error:\", error, 'in', sourceInfo, 'component', selfReference);\n }\n return renderResult!;\n}\n\nexport default {\n jsx,\n Fragment,\n renderIsomorphic,\n getRenderer,\n\n // implementing the full standard\n // https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md\n jsxs,\n jsxDEV,\n};","import { getByPath, setByPath } from '@/common/index.js';\n\nexport type Listener<T> = (newValue: T, oldValue?: T, changedKey?: string) => void;\n\nexport interface Store<T> {\n value: T;\n get: <D=T>(path?: string) => D;\n set: <D=T>(pathOrValue: string | D, value?: D) => void;\n subscribe: (listener: Listener<T>) => () => void;\n}\n\nexport const createStore = <T>(initialValue: T): Store<T> => {\n let value: T = initialValue; // internal state\n const listeners: Array<Listener<T>> = [];\n\n const notify = (oldValue: T, changedKey?: string) => {\n listeners.forEach(listener => listener(value, oldValue, changedKey));\n };\n\n return {\n // allow reading value but prevent external mutation\n get value() {\n return value; \n },\n\n get(path?: string) {\n return path ? getByPath(value, path) : value;\n },\n\n set(pathOrValue: string | any, newValue?: any) {\n const oldValue = value;\n\n if (newValue === undefined) {\n // replace entire store value\n if (oldValue !== pathOrValue) {\n value = pathOrValue;\n notify(oldValue);\n }\n } else {\n // update a specific path\n const updatedValue = setByPath(value, pathOrValue, newValue);\n if (oldValue !== updatedValue) {\n value = updatedValue;\n notify(oldValue, pathOrValue);\n }\n }\n },\n\n subscribe(listener) {\n listeners.push(listener);\n return () => {\n const index = listeners.indexOf(listener);\n if (index >= 0) listeners.splice(index, 1);\n };\n },\n };\n};\n","import type { Ref, RefUpdateFn } from '@/render/types.js';\nimport { createStore } from '@/store/store.js';\n\nexport const isRef = (obj: any): obj is Ref<Element> =>\n obj && typeof obj === \"object\" && \"current\" in obj;\n\nexport function createRef<ST = any, NT extends Node | Element | Text | null = HTMLElement>(refUpdateFn?: RefUpdateFn<ST>, defaultState?: ST): Ref<NT, ST> {\n\n const stateStore = createStore<ST>(defaultState as ST);\n \n const ref: Ref<NT, ST> = { \n current: null as NT,\n store: stateStore,\n get state() {\n return stateStore.value;\n },\n set state(value: ST) {\n stateStore.set(value);\n },\n update: (state: ST) => {\n stateStore.set(state);\n },\n subscribe: (refUpdateFn: RefUpdateFn<ST>) => stateStore.subscribe(refUpdateFn),\n }\n\n if (typeof refUpdateFn === 'function') {\n ref.subscribe(refUpdateFn);\n }\n return ref;\n}"],"names":[],"mappings":";;AACA,MAAM,WAAW,GAAG,eAAe;AACnC,MAAM,SAAS,GAAG,OAAO;AACb,MAAC,kBAAkB,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC,KAA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G,WAAW,CAAC,YAAY,CAAC;AAC9C,EAAE,MAAM,GAAG,GAAG;AACd,IAAI,OAAO,EAAE,IAAI;AACjB,IAAI,KAAK,EAAE,UAAU;AACrB,IAAI,IAAI,KAAK,GAAG;AAChB,MAAM,OAAO,UAAU,CAAC,KAAK;AAC7B,KAAK;AACL,IAAI,IAAI,KAAK,CAAC,KAAK,EAAE;AACrB,MAAM,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC;AAC3B,KAAK;AACL,IAAI,MAAM,EAAE,CAAC,KAAK,KAAK;AACvB,MAAM,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC;AAC3B,KAAK;AACL,IAAI,SAAS,EAAE,CAAC,YAAY,KAAK,UAAU,CAAC,SAAS,CAAC,YAAY;AAClE,GAAG;AACH,EAAE,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE;AACzC,IAAI,GAAG,CAAC,SAAS,CAAC,WAAW,CAAC;AAC9B;AACA,EAAE,OAAO,GAAG;AACZ;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var M=Object.defineProperty;var c=(n,s)=>M(n,"name",{value:s,configurable:!0});const C=/(.*)\[(\d+)\]/,I=/^\d+$/,l=c(n=>n.split(".").flatMap(s=>{const e=s.match(C);return e?[...l(e[1]),Number(e[2])]:s}),"getAllKeysFromPath"),g=c((n,s,e)=>{s in n||(n[s]=I.test(String(e))?[]:{})},"ensureKey"),A=c((n,s)=>l(s).reduce((r,t)=>r?.[t],n),"getByPath"),p=c((n,s,e)=>{const r=l(s),t=r[0],o=Array.isArray(n)?[...n]:{...n};return r.length===1?(e===void 0?Array.isArray(o)?o.splice(Number(t),1):delete o[t]:o[t]=e,o):(g(o,t,r[1]),o[t]=p(o[t],r.slice(1).join("."),e),o)},"setByPath"),T="class",b="xlink",L="xmlns",$="ref",h={[L]:"http://www.w3.org/2000/xmlns/",[b]:"http://www.w3.org/1999/xlink",svg:"http://www.w3.org/2000/svg"},N=c(n=>n&&typeof n=="object"&&!n.attributes&&!n.type&&!n.children,"isJSXComment"),E=c(n=>n.filter(s=>!N(s)),"filterComments"),w=c(n=>({type:"p",attributes:{},children:[`FATAL ERROR: ${n?.message||n}`]}),"createInPlaceErrorMessageVNode"),d=c((n,s,e)=>{s={...s},typeof e<"u"&&(s.key=e);let r=(s?.children?[].concat(s.children):[]).filter(Boolean);if(delete s?.children,r=E([].concat.apply([],r)),n==="fragment")return E(r);if(typeof n=="function"&&n.constructor.name!=="AsyncFunction")try{return n({children:r,...s})}catch(t){return typeof t=="string"?t=`[JsxError] in ${n.name}: ${t}`:t instanceof Error&&(t.message=`[JsxError] in ${n.name}: ${t.message}`),w(t)}return{type:n,attributes:s,children:r}},"jsx"),x=c((n,s)=>{if(!n||typeof s!="function")throw new Error("Invalid arguments. Ensure domNode and onUnmount are valid.");const e=n.parentNode;if(!e)throw new Error("The provided domNode does not have a parentNode.");const r=new MutationObserver(t=>{for(const o of t)if(o.removedNodes.length>0){for(const i of o.removedNodes)if(i===n){s(),r.disconnect();return}}});r.observe(e,{childList:!0})},"observeUnmount"),S=c(n=>{typeof n?.$onMount=="function"&&(n.$onMount(),n.$onMount=null),typeof n?.$onUnmount=="function"&&x(n,n.$onUnmount)},"handleLifecycleEventsForOnMount"),y=c(n=>{const s={hasElNamespace:c(e=>e.namespaceURI===h.svg,"hasElNamespace"),hasSvgNamespace:c((e,r)=>s.hasElNamespace(e)&&r!=="STYLE"&&r!=="SCRIPT","hasSvgNamespace"),createElementOrElements:c((e,r)=>Array.isArray(e)?s.createChildElements(e,r):typeof e<"u"?s.createElement(e,r):s.createTextNode("",r),"createElementOrElements"),createElement:c((e,r)=>{let t;try{e.constructor.name==="AsyncFunction"?t=n.createElement("div"):typeof e.type=="function"?(t=n.createElement("div"),t.innerText=`FATAL ERROR: ${e.type._error}`):e.type.toUpperCase()==="SVG"||r&&s.hasSvgNamespace(r,e.type.toUpperCase())?t=n.createElementNS(h.svg,e.type):t=n.createElement(e.type),e.attributes&&(s.setAttributes(e,t),e.attributes.dangerouslySetInnerHTML&&(t.innerHTML=e.attributes.dangerouslySetInnerHTML.__html)),e.children&&s.createChildElements(e.children,t),r&&(r.appendChild(t),S(t))}catch(o){throw console.error("Fatal error! Error happend while rendering the VDOM!",o,e),o}return t},"createElement"),createTextNode:c((e,r)=>{const t=n.createTextNode(e.toString());return r&&r.appendChild(t),t},"createTextNode"),createChildElements:c((e,r)=>{const t=[];for(let o=0;o<e.length;o++){const i=e[o];i===null||typeof i!="object"&&typeof i!="function"?t.push(s.createTextNode((typeof i>"u"||i===null?"":i).toString(),r)):t.push(s.createElement(i,r))}return t},"createChildElements"),setAttribute:c((e,r,t,o)=>{if(typeof r>"u"||e==="dangerouslySetInnerHTML")return;if(e===$&&typeof r!="function"){r.current=t;return}if(e.startsWith("on")&&typeof r=="function"){let f=e.substring(2).toLowerCase();const a=f.indexOf("capture"),u=a>-1;f==="mount"&&(t.$onMount=r),f==="unmount"&&(t.$onUnmount=r),u&&(f=f.substring(0,a)),t.addEventListener(f,r,u);return}e==="className"&&(e=T),e===T&&Array.isArray(r)&&(r=r.join(" "));const i=e.match(/[A-Z]/)?.index;if(s.hasElNamespace(t)&&i){const f=e.substring(0,i).toLowerCase(),a=e.substring(i,e.length).toLowerCase(),u=h[f]||null;t.setAttributeNS(u,f===b||f==="xmlns"?`${f}:${a}`:e,r)}else if(e==="style"&&typeof r!="string"){const f=Object.keys(r);for(let a=0;a<f.length;a++)t.style[f[a]]=r[f[a]]}else typeof r=="boolean"?t[e]=r:t.setAttribute(e,r)},"setAttribute"),setAttributes:c((e,r)=>{const t=Object.keys(e.attributes);for(let o=0;o<t.length;o++)s.setAttribute(t[o],e.attributes[t[o]],r,e)},"setAttributes")};return s},"getRenderer"),m=c((n,s,e)=>{const r=s.el||s;let t;return typeof n=="string"?t=y(e.window.document).createTextNode(n,r):t=y(e.window.document).createElementOrElements(n,r),t},"renderIsomorphic"),_=c(n=>n.children,"Fragment"),U=d,F=c((n,s,e,r,t,o)=>{let i;try{i=d(n,s,e)}catch(f){console.error("JSX error:",f,"in",t,"component",o)}return i},"jsxDEV"),R=c(n=>{let s=n;const e=[],r=c((t,o)=>{e.forEach(i=>i(s,t,o))},"notify");return{get value(){return s},get(t){return t?A(s,t):s},set(t,o){const i=s;if(o===void 0)i!==t&&(s=t,r(i));else{const f=p(s,t,o);i!==f&&(s=f,r(i,t))}},subscribe(t){return e.push(t),()=>{const o=e.indexOf(t);o>=0&&e.splice(o,1)}}}},"createStore"),O=c(n=>n&&typeof n=="object"&&"current"in n,"isRef");function B(n,s){const e=R(s),r={current:null,store:e,get state(){return e.value},set state(t){e.set(t)},update:c(t=>{e.set(t)},"update"),subscribe:c(t=>e.subscribe(t),"subscribe")};return typeof n=="function"&&r.subscribe(n),r}c(B,"createRef");export{_ as F,U as a,F as b,w as c,B as d,R as e,l as f,y as g,S as h,O as i,d as j,g as k,A as l,x as o,m as r,p as s};
|
|
2
|
+
//# sourceMappingURL=index-BDxEyjzN.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BDxEyjzN.mjs","sources":["../src/common/path.ts","../src/render/isomorph.ts","../src/store/store.ts","../src/render/ref.ts"],"sourcesContent":["const ARRAY_INDEX = /(.*)\\[(\\d+)\\]/;\nconst IS_NUMBER = /^\\d+$/;\n\nexport const getAllKeysFromPath = (path: string): Array<string | number> =>\n path.split('.').flatMap(key => {\n const match = key.match(ARRAY_INDEX);\n return match ? [...getAllKeysFromPath(match[1]), Number(match[2])] : key;\n });\n\nexport const ensureKey = (\n obj: Record<string, any>,\n key: string | number,\n nextKey?: string | number\n): void => {\n if (!(key in obj)) {\n obj[key] = IS_NUMBER.test(String(nextKey)) ? [] : {};\n }\n};\n\nexport const getByPath = (obj: any, path: string): any => {\n const keys = getAllKeysFromPath(path);\n return keys.reduce((result, key) => (result == null ? undefined : result[key]), obj);\n};\n\nexport const setByPath = (obj: any, path: string, value: any): any => {\n const keys = getAllKeysFromPath(path);\n const key = keys[0];\n const newObj = Array.isArray(obj) ? [...obj] : { ...obj };\n\n if (keys.length === 1) {\n if (value === undefined) {\n Array.isArray(newObj) ? newObj.splice(Number(key), 1) : delete newObj[key];\n } else {\n newObj[key] = value;\n }\n return newObj;\n }\n\n ensureKey(newObj, key, keys[1]);\n newObj[key] = setByPath(newObj[key], keys.slice(1).join('.'), value);\n return newObj;\n};\n","import type { Dequery } from '@/dequery/dequery.js'\nimport type { VNodeChild, VNodeChildren, VNode, VNodeType, VNodeAttributes, DomAbstractionImpl, Globals } from '@/render/types.js'\n\nconst CLASS_ATTRIBUTE_NAME = 'class'\nconst XLINK_ATTRIBUTE_NAME = 'xlink'\nconst XMLNS_ATTRIBUTE_NAME = 'xmlns'\nconst REF_ATTRIBUTE_NAME = 'ref'\n\nconst nsMap = {\n [XMLNS_ATTRIBUTE_NAME]: 'http://www.w3.org/2000/xmlns/',\n [XLINK_ATTRIBUTE_NAME]: 'http://www.w3.org/1999/xlink',\n svg: 'http://www.w3.org/2000/svg',\n}\n\n// If a JSX comment is written, it looks like: { /* this */ }\n// Therefore, it turns into: {}, which is detected here\nconst isJSXComment = (node: VNode): boolean =>\n /* v8 ignore next */\n node && typeof node === 'object' && !node.attributes && !node.type && !node.children\n\n// Filters comments and undefines like: ['a', 'b', false, {}] to: ['a', 'b', false]\nconst filterComments = (children: Array<VNode> | Array<VNodeChild>) =>\n children.filter((child: VNodeChild) => !isJSXComment(child as VNode))\n\nexport const createInPlaceErrorMessageVNode = (error: unknown) => ({\n type: 'p',\n attributes: {},\n children: [`FATAL ERROR: ${(error as Error)?.message || error}`]\n})\n\nexport const jsx = (\n type: VNodeType | Function | any,\n attributes: (JSX.HTMLAttributes & JSX.SVGAttributes & Record<string, any>) | null,\n key?: string\n): Array<VNode> | VNode => {\n\n // clone attributes as well\n attributes = { ...attributes }\n\n if (typeof key !== \"undefined\") {\n /* key passed for instance-based lifecycle event listener registration */\n attributes.key = key;\n }\n\n // extract children from attributes and ensure it's always an array\n let children: Array<VNodeChild> = (attributes?.children ? [].concat(attributes.children) : []).filter(Boolean);\n delete attributes?.children;\n\n children = filterComments(\n // Implementation to flatten virtual node children structures like:\n // [<p>1</p>, [<p>2</p>,<p>3</p>]] to: [<p>1</p>,<p>2</p>,<p>3</p>]\n ([] as Array<VNodeChildren>).concat.apply([], children as any) as Array<VNodeChildren>,\n )\n\n // effectively unwrap by directly returning the children\n if (type === 'fragment') {\n return filterComments(children) as Array<VNode>;\n }\n\n // it's a component, divide and conquer children\n // in case of async functions, we just pass them through\n if (typeof type === 'function' && type.constructor.name !== 'AsyncFunction') {\n\n try {\n return type({\n children,\n ...attributes,\n })\n } catch (error) {\n\n if (typeof error === \"string\") {\n error = `[JsxError] in ${type.name}: ${error}`;\n } else if (error instanceof Error) {\n error.message = `[JsxError] in ${type.name}: ${error.message}`;\n }\n\n // render the error in place\n return createInPlaceErrorMessageVNode(error)\n }\n }\n\n return {\n type,\n attributes,\n children,\n };\n}\n\nexport const observeUnmount = (domNode: Node, onUnmount: () => void): void => {\n if (!domNode || typeof onUnmount !== 'function') {\n throw new Error('Invalid arguments. Ensure domNode and onUnmount are valid.');\n }\n\n const parentNode = domNode.parentNode;\n if (!parentNode) {\n throw new Error('The provided domNode does not have a parentNode.');\n }\n\n const observer = new MutationObserver((mutationsList) => {\n for (const mutation of mutationsList) {\n if (mutation.removedNodes.length > 0) {\n for (const removedNode of mutation.removedNodes) {\n if (removedNode === domNode) {\n onUnmount();\n observer.disconnect(); // Stop observing after unmount\n return;\n }\n }\n }\n }\n });\n\n // Observe the parentNode for child removals\n observer.observe(parentNode, { childList: true });\n}\n\n/** lifecycle event attachment has been implemented separately, because it is also required to run when partially updating the DOM */\nexport const handleLifecycleEventsForOnMount = (newEl: HTMLElement) => {\n\n // check for a lifecycle \"onMount\" hook and call it\n if (typeof (newEl as any)?.$onMount === 'function') {\n ; (newEl as any).$onMount!()\n // remove the hook after it's been called\n ; (newEl as any).$onMount = null;\n }\n\n // optionally check for a element lifecycle \"onUnmount\" and hook it up\n if (typeof (newEl as any)?.$onUnmount === 'function') {\n // register the unmount observer (MutationObserver)\n observeUnmount(newEl as HTMLElement, (newEl as any).$onUnmount!);\n }\n}\n\nexport const getRenderer = (document: Document): DomAbstractionImpl => {\n // DOM abstraction layer for manipulation\n const renderer = {\n hasElNamespace: (domElement: Element | Document): boolean => (domElement as Element).namespaceURI === nsMap.svg,\n\n hasSvgNamespace: (parentElement: Element | Document, type: string): boolean =>\n renderer.hasElNamespace(parentElement) && type !== 'STYLE' && type !== 'SCRIPT',\n\n createElementOrElements: (\n virtualNode: VNode | undefined | Array<VNode | undefined | string>,\n parentDomElement?: Element | Document,\n ): Array<Element | Text | undefined> | Element | Text | undefined => {\n if (Array.isArray(virtualNode)) {\n return renderer.createChildElements(virtualNode, parentDomElement)\n }\n if (typeof virtualNode !== 'undefined') {\n return renderer.createElement(virtualNode, parentDomElement)\n }\n // undefined virtualNode -> e.g. when a tsx variable is used in markup which is undefined\n return renderer.createTextNode('', parentDomElement)\n },\n\n createElement: (virtualNode: VNode, parentDomElement?: Element | Document): Element | undefined => {\n let newEl: Element | undefined = undefined;\n\n try {\n // if a synchronous function is still a function, VDOM has obviously not resolved, probably an \n // Error occurred while generating the VDOM (in JSX runtime)\n if (\n virtualNode.constructor.name === 'AsyncFunction'\n ) {\n newEl = document.createElement('div')\n } else if (typeof virtualNode.type === 'function') {\n newEl = document.createElement('div')\n ; (newEl as HTMLElement).innerText = `FATAL ERROR: ${virtualNode.type._error}`\n } else if ( // SVG support\n virtualNode.type.toUpperCase() === 'SVG' ||\n (parentDomElement && renderer.hasSvgNamespace(parentDomElement, virtualNode.type.toUpperCase()))\n ) { // SVG support\n newEl = document.createElementNS(nsMap.svg, virtualNode.type as string)\n } else {\n newEl = document.createElement(virtualNode.type as string)\n }\n\n if (virtualNode.attributes) {\n renderer.setAttributes(virtualNode, newEl as Element)\n\n // Apply dangerouslySetInnerHTML if provided\n if (virtualNode.attributes.dangerouslySetInnerHTML) {\n // TODO: FIX me\n newEl.innerHTML = virtualNode.attributes.dangerouslySetInnerHTML.__html;\n }\n }\n\n if (virtualNode.children) {\n renderer.createChildElements(virtualNode.children, newEl as Element)\n }\n\n if (parentDomElement) {\n parentDomElement.appendChild(newEl)\n handleLifecycleEventsForOnMount(newEl as HTMLElement)\n }\n } catch (e) {\n console.error('Fatal error! Error happend while rendering the VDOM!', e, virtualNode);\n throw e;\n }\n return newEl as Element\n },\n\n createTextNode: (text: string, domElement?: Element | Document): Text => {\n const node = document.createTextNode(text.toString())\n\n if (domElement) {\n domElement.appendChild(node)\n }\n return node\n },\n\n createChildElements: (\n virtualChildren: VNodeChildren,\n domElement?: Element | Document,\n ): Array<Element | Text | undefined> => {\n const children: Array<Element | Text | undefined> = []\n\n for (let i = 0; i < virtualChildren.length; i++) {\n const virtualChild = virtualChildren[i]\n if (virtualChild === null || (typeof virtualChild !== 'object' && typeof virtualChild !== 'function')) {\n children.push(\n renderer.createTextNode(\n (typeof virtualChild === 'undefined' || virtualChild === null ? '' : virtualChild!).toString(),\n domElement,\n ),\n )\n } else {\n children.push(renderer.createElement(virtualChild as VNode, domElement))\n }\n }\n return children\n },\n\n setAttribute: (name: string, value: any, domElement: Element, virtualNode: VNode<VNodeAttributes>) => {\n // attributes not set (undefined) are ignored; use null value to reset an attributes state\n if (typeof value === 'undefined') return // if not set, ignore\n\n // TODO: use DANGROUSLY_SET_INNER_HTML_ATTRIBUTE here\n if (name === 'dangerouslySetInnerHTML') return; // special case, handled elsewhere\n\n // save ref as { current: DOMElement } in ref object\n // allows for ref={someRef}\n if (name === REF_ATTRIBUTE_NAME && typeof value !== 'function') {\n value.current = domElement // update ref\n return; // but do not render the ref as a string [object Object] into the DOM\n }\n\n if (name.startsWith('on') && typeof value === 'function') {\n\n let eventName = name.substring(2).toLowerCase()\n const capturePos = eventName.indexOf('capture')\n const doCapture = capturePos > -1\n\n if (eventName === 'mount') {\n ; (domElement as any).$onMount = value // DOM event lifecycle hook\n }\n\n if (eventName === 'unmount') {\n ; (domElement as any).$onUnmount = value // DOM event lifecycle hook\n }\n\n // onClickCapture={...} support\n if (doCapture) {\n eventName = eventName.substring(0, capturePos)\n }\n domElement.addEventListener(eventName, value, doCapture)\n return\n }\n\n // transforms className=\"...\" -> class=\"...\"\n // allows for React JSX to work seamlessly\n if (name === 'className') {\n name = CLASS_ATTRIBUTE_NAME\n }\n\n // transforms class={['a', 'b']} into class=\"a b\"\n if (name === CLASS_ATTRIBUTE_NAME && Array.isArray(value)) {\n value = value.join(' ')\n }\n\n // SVG support\n const nsEndIndex = name.match(/[A-Z]/)?.index\n if (renderer.hasElNamespace(domElement) && nsEndIndex) {\n const ns = name.substring(0, nsEndIndex).toLowerCase()\n const attrName = name.substring(nsEndIndex, name.length).toLowerCase()\n const namespace = nsMap[ns as keyof typeof nsMap] || null\n domElement.setAttributeNS(\n namespace,\n ns === XLINK_ATTRIBUTE_NAME || ns === 'xmlns' ? `${ns}:${attrName}` : name,\n value,\n )\n } else if (name === 'style' && typeof value !== 'string') {\n const propNames = Object.keys(value)\n\n // allows for style={{ margin: 10 }} etc.\n for (let i = 0; i < propNames.length; i++) {\n ; (domElement as HTMLElement).style[propNames[i] as any] = value[propNames[i]]\n }\n } else if (typeof value === 'boolean') {\n // for cases like <button checked={false} />\n ; (domElement as any)[name] = value\n } else {\n // for any other case\n domElement.setAttribute(name, value)\n }\n },\n\n setAttributes: (virtualNode: VNode<VNodeAttributes>, domElement: Element) => {\n const attrNames = Object.keys(virtualNode.attributes!)\n for (let i = 0; i < attrNames.length; i++) {\n renderer.setAttribute(attrNames[i], virtualNode.attributes![attrNames[i]], domElement, virtualNode)\n }\n },\n }\n return renderer\n}\n\nexport const renderIsomorphic = (\n virtualNode: VNode | undefined | string | Array<VNode | undefined | string>,\n parentDomElement: Element | Document | Dequery | undefined,\n globals: Globals,\n): Array<Element | Text | undefined> | Element | Text | undefined => {\n\n const parentEl = (parentDomElement as Dequery).el as Element || parentDomElement\n let renderResult: Array<Element | Text | undefined> | Element | Text | undefined\n\n if (typeof virtualNode === 'string') {\n renderResult = getRenderer(globals.window.document).createTextNode(virtualNode, parentEl)\n } else {\n renderResult = getRenderer(globals.window.document).createElementOrElements(virtualNode, parentEl)\n }\n return renderResult;\n}\n\n// --- JSX standard (necessary exports for jsx-runtime)\nexport const Fragment = (props: VNode) => props.children\nexport const jsxs = jsx\nexport const jsxDEV = (\n type: VNodeType | Function | any,\n attributes: (JSX.HTMLAttributes & JSX.SVGAttributes & Record<string, any>) | null,\n key?: string,\n allChildrenAreStatic?: boolean,\n sourceInfo?: string,\n selfReference?: any,\n): Array<VNode> | VNode => {\n let renderResult: Array<VNode> | VNode;\n try {\n renderResult = jsx(type, attributes, key);\n } catch (error) {\n console.error(\"JSX error:\", error, 'in', sourceInfo, 'component', selfReference);\n }\n return renderResult!;\n}\n\nexport default {\n jsx,\n Fragment,\n renderIsomorphic,\n getRenderer,\n\n // implementing the full standard\n // https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md\n jsxs,\n jsxDEV,\n};","import { getByPath, setByPath } from '@/common/index.js';\n\nexport type Listener<T> = (newValue: T, oldValue?: T, changedKey?: string) => void;\n\nexport interface Store<T> {\n value: T;\n get: <D=T>(path?: string) => D;\n set: <D=T>(pathOrValue: string | D, value?: D) => void;\n subscribe: (listener: Listener<T>) => () => void;\n}\n\nexport const createStore = <T>(initialValue: T): Store<T> => {\n let value: T = initialValue; // internal state\n const listeners: Array<Listener<T>> = [];\n\n const notify = (oldValue: T, changedKey?: string) => {\n listeners.forEach(listener => listener(value, oldValue, changedKey));\n };\n\n return {\n // allow reading value but prevent external mutation\n get value() {\n return value; \n },\n\n get(path?: string) {\n return path ? getByPath(value, path) : value;\n },\n\n set(pathOrValue: string | any, newValue?: any) {\n const oldValue = value;\n\n if (newValue === undefined) {\n // replace entire store value\n if (oldValue !== pathOrValue) {\n value = pathOrValue;\n notify(oldValue);\n }\n } else {\n // update a specific path\n const updatedValue = setByPath(value, pathOrValue, newValue);\n if (oldValue !== updatedValue) {\n value = updatedValue;\n notify(oldValue, pathOrValue);\n }\n }\n },\n\n subscribe(listener) {\n listeners.push(listener);\n return () => {\n const index = listeners.indexOf(listener);\n if (index >= 0) listeners.splice(index, 1);\n };\n },\n };\n};\n","import type { Ref, RefUpdateFn } from '@/render/types.js';\nimport { createStore } from '@/store/store.js';\n\nexport const isRef = (obj: any): obj is Ref<Element> =>\n obj && typeof obj === \"object\" && \"current\" in obj;\n\nexport function createRef<ST = any, NT extends Node | Element | Text | null = HTMLElement>(refUpdateFn?: RefUpdateFn<ST>, defaultState?: ST): Ref<NT, ST> {\n\n const stateStore = createStore<ST>(defaultState as ST);\n \n const ref: Ref<NT, ST> = { \n current: null as NT,\n store: stateStore,\n get state() {\n return stateStore.value;\n },\n set state(value: ST) {\n stateStore.set(value);\n },\n update: (state: ST) => {\n stateStore.set(state);\n },\n subscribe: (refUpdateFn: RefUpdateFn<ST>) => stateStore.subscribe(refUpdateFn),\n }\n\n if (typeof refUpdateFn === 'function') {\n ref.subscribe(refUpdateFn);\n }\n return ref;\n}"],"names":[],"mappings":"AACA,MAAM,WAAW,GAAG,eAAe;AACnC,MAAM,SAAS,GAAG,OAAO;AACb,MAAC,kBAAkB,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,KAAK;AAC7E,EAAE,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC;AACtC,EAAE,OAAO,KAAK,GAAG,CAAC,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG;AAC1E,CAAC;AACW,MAAC,SAAS,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,KAAK;AAChD,EAAE,IAAI,EAAE,GAAG,IAAI,GAAG,CAAC,EAAE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AI,SAAS,EAAE,CAAC,YAAY,KAAK,UAAU,CAAC,SAAS,CAAC,YAAY;AAClE,GAAG;AACH,EAAE,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE;AACzC,IAAI,GAAG,CAAC,SAAS,CAAC,WAAW,CAAC;AAC9B;AACA,EAAE,OAAO,GAAG;AACZ;;;;"}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import * as CSS from 'csstype';
|
|
2
2
|
|
|
3
|
+
type Listener<T> = (newValue: T, oldValue?: T, changedKey?: string) => void;
|
|
4
|
+
interface Store<T> {
|
|
5
|
+
value: T;
|
|
6
|
+
get: <D = T>(path?: string) => D;
|
|
7
|
+
set: <D = T>(pathOrValue: string | D, value?: D) => void;
|
|
8
|
+
subscribe: (listener: Listener<T>) => () => void;
|
|
9
|
+
}
|
|
10
|
+
declare const createStore: <T>(initialValue: T) => Store<T>;
|
|
11
|
+
|
|
3
12
|
type Globals = Window & typeof globalThis;
|
|
4
13
|
interface CSSProperties extends CSS.Properties<string | number> {
|
|
5
14
|
}
|
|
@@ -121,26 +130,28 @@ interface KeyFrameProperties {
|
|
|
121
130
|
'99%'?: Partial<CSSProperties>;
|
|
122
131
|
'100%'?: Partial<CSSProperties>;
|
|
123
132
|
}
|
|
124
|
-
type
|
|
125
|
-
interface Ref {
|
|
126
|
-
current
|
|
127
|
-
|
|
128
|
-
|
|
133
|
+
type RefUpdateFn<D> = (state: D) => void;
|
|
134
|
+
interface Ref<NT = null | Node | Element | Text, ST = any> {
|
|
135
|
+
current: NT;
|
|
136
|
+
store?: Store<ST>;
|
|
137
|
+
state?: ST;
|
|
138
|
+
update: RefUpdateFn<ST>;
|
|
139
|
+
subscribe: (refUpdateFn: RefUpdateFn<ST>) => () => void;
|
|
129
140
|
}
|
|
130
|
-
type VRef = (el: Element) => void;
|
|
131
141
|
interface VAttributes {
|
|
132
|
-
ref?: Ref
|
|
142
|
+
ref?: Ref;
|
|
133
143
|
key?: string;
|
|
134
144
|
}
|
|
135
145
|
interface VNodeAttributes extends VAttributes {
|
|
136
146
|
[attributeName: string]: any;
|
|
147
|
+
key?: string;
|
|
137
148
|
}
|
|
138
149
|
interface VNode<A = VNodeAttributes> {
|
|
139
|
-
type
|
|
140
|
-
attributes
|
|
150
|
+
type?: VNodeType;
|
|
151
|
+
attributes?: A;
|
|
141
152
|
children?: VNodeChildren;
|
|
142
153
|
}
|
|
143
|
-
type VNodeType = string | any;
|
|
154
|
+
type VNodeType = string | Function | any;
|
|
144
155
|
type VNodeKey = string | number | any;
|
|
145
156
|
type VNodeRefObject<T> = {
|
|
146
157
|
current?: T | null;
|
|
@@ -157,8 +168,8 @@ interface DomAbstractionImpl {
|
|
|
157
168
|
createElement(virtualNode: VNode | undefined, parentDomElement?: Element | Document): Element | undefined;
|
|
158
169
|
createTextNode(text: string, parentDomElement?: Element | Document): Text;
|
|
159
170
|
createChildElements(virtualChildren: VNodeChildren, parentDomElement?: Element): Array<Element | Text | undefined>;
|
|
160
|
-
setAttribute(name: string, value: any, parentDomElement: Element,
|
|
161
|
-
setAttributes(attributes:
|
|
171
|
+
setAttribute(name: string, value: any, parentDomElement: Element, attributes: VNodeAttributes): void;
|
|
172
|
+
setAttributes(attributes: VNode<VNodeAttributes>, parentDomElement: Element): void;
|
|
162
173
|
}
|
|
163
174
|
declare global {
|
|
164
175
|
namespace JSX {
|
|
@@ -421,10 +432,12 @@ declare global {
|
|
|
421
432
|
type WheelEventHandler = EventHandler<WheelEvent>;
|
|
422
433
|
type AnimationEventHandler = EventHandler<AnimationEvent>;
|
|
423
434
|
type TransitionEventHandler = EventHandler<TransitionEvent>;
|
|
435
|
+
type ProgressEventHandler = EventHandler<ProgressEvent>;
|
|
424
436
|
type GenericEventHandler = EventHandler<Event>;
|
|
425
437
|
type PointerEventHandler = EventHandler<PointerEvent>;
|
|
426
438
|
interface DOMAttributeEventHandlersLowerCase {
|
|
427
439
|
onmount?: Function;
|
|
440
|
+
onunmount?: Function;
|
|
428
441
|
onload?: GenericEventHandler;
|
|
429
442
|
onloadcapture?: GenericEventHandler;
|
|
430
443
|
onerror?: GenericEventHandler;
|
|
@@ -487,8 +500,8 @@ declare global {
|
|
|
487
500
|
onplaycapture?: GenericEventHandler;
|
|
488
501
|
onplaying?: GenericEventHandler;
|
|
489
502
|
onplayingcapture?: GenericEventHandler;
|
|
490
|
-
onprogress?:
|
|
491
|
-
onprogresscapture?:
|
|
503
|
+
onprogress?: ProgressEventHandler;
|
|
504
|
+
onprogresscapture?: ProgressEventHandler;
|
|
492
505
|
onratechange?: GenericEventHandler;
|
|
493
506
|
onratechangecapture?: GenericEventHandler;
|
|
494
507
|
onseeked?: GenericEventHandler;
|
|
@@ -585,8 +598,9 @@ declare global {
|
|
|
585
598
|
ontransitionendcapture?: TransitionEventHandler;
|
|
586
599
|
}
|
|
587
600
|
interface DOMAttributes extends VAttributes, DOMAttributeEventHandlersLowerCase {
|
|
588
|
-
ref?: Ref
|
|
601
|
+
ref?: Ref;
|
|
589
602
|
onMount?: Function;
|
|
603
|
+
onUnmount?: Function;
|
|
590
604
|
onLoad?: GenericEventHandler;
|
|
591
605
|
onLoadCapture?: GenericEventHandler;
|
|
592
606
|
onError?: GenericEventHandler;
|
|
@@ -747,7 +761,8 @@ declare global {
|
|
|
747
761
|
onTransitionEndCapture?: TransitionEventHandler;
|
|
748
762
|
}
|
|
749
763
|
interface HTMLAttributesLowerCase {
|
|
750
|
-
|
|
764
|
+
ref?: Ref;
|
|
765
|
+
dangerouslysetinnerhtml?: {
|
|
751
766
|
__html: string;
|
|
752
767
|
};
|
|
753
768
|
accept?: string;
|
|
@@ -890,7 +905,7 @@ declare global {
|
|
|
890
905
|
itemref?: string;
|
|
891
906
|
}
|
|
892
907
|
interface HTMLAttributes extends HTMLAttributesLowerCase, DOMAttributes {
|
|
893
|
-
ref?: Ref
|
|
908
|
+
ref?: Ref;
|
|
894
909
|
dangerouslySetInnerHTML?: {
|
|
895
910
|
__html: string;
|
|
896
911
|
};
|
|
@@ -1204,34 +1219,92 @@ declare global {
|
|
|
1204
1219
|
interface Props {
|
|
1205
1220
|
children?: VNodeChildren;
|
|
1206
1221
|
ref?: Ref;
|
|
1222
|
+
key?: string;
|
|
1223
|
+
onError?: (error: unknown) => void;
|
|
1207
1224
|
}
|
|
1208
1225
|
type RenderNodeInput = VNode | string | undefined;
|
|
1209
1226
|
type RenderInput = RenderNodeInput | Array<RenderNodeInput>;
|
|
1210
1227
|
type RenderResultNode = Element | Text | undefined;
|
|
1211
1228
|
type RenderResult<T = RenderInput> = T extends Array<RenderNodeInput> ? Array<RenderResultNode> : RenderResultNode;
|
|
1212
1229
|
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1230
|
+
type NodeType = Node | Text | Element | Document | DocumentFragment;
|
|
1231
|
+
type FormFieldValue = string | Date | File | boolean | number;
|
|
1232
|
+
interface FormKeyValues {
|
|
1233
|
+
[keyOrPath: string]: FormFieldValue;
|
|
1234
|
+
}
|
|
1235
|
+
interface DequeryOptions {
|
|
1236
|
+
maxWaitMs: number;
|
|
1237
|
+
}
|
|
1238
|
+
declare const defaultConfig: DequeryOptions;
|
|
1239
|
+
declare const dequery: (selectorRefOrEl: Node | Element | Text | Ref<Node | Element | Text, any> | string, options?: DequeryOptions) => Dequery;
|
|
1240
|
+
declare class Dequery {
|
|
1241
|
+
options: DequeryOptions;
|
|
1242
|
+
elements: Array<NodeType>;
|
|
1243
|
+
constructor(options?: DequeryOptions, elements?: Array<NodeType>);
|
|
1244
|
+
get el(): NodeType;
|
|
1245
|
+
tap(cb: (el: NodeType | Array<NodeType>) => void): Dequery;
|
|
1246
|
+
query(selector: string): Dequery;
|
|
1247
|
+
first(): Dequery;
|
|
1248
|
+
last(): Dequery;
|
|
1249
|
+
next(): Dequery;
|
|
1250
|
+
eq(idx: number): Dequery;
|
|
1251
|
+
prev(): Dequery;
|
|
1252
|
+
each(cb: (el: NodeType, idx: number) => void): Dequery;
|
|
1253
|
+
find(selector: string): Dequery;
|
|
1254
|
+
parent(): Dequery;
|
|
1255
|
+
children(): Dequery;
|
|
1256
|
+
closest(selector: string): Dequery;
|
|
1257
|
+
filter(selector: string): Dequery;
|
|
1258
|
+
attr(name: string): string | null;
|
|
1259
|
+
attr(name: string, value: string): Dequery;
|
|
1217
1260
|
empty(): Dequery;
|
|
1218
|
-
html(
|
|
1219
|
-
|
|
1261
|
+
html(newInnerHtml?: string): Dequery;
|
|
1262
|
+
jsx(newJsxPartialDom: RenderInput): Dequery;
|
|
1263
|
+
text(text?: string): Dequery;
|
|
1220
1264
|
remove(): Dequery;
|
|
1221
|
-
|
|
1265
|
+
replaceWithJsx(vdomOrNode: RenderInput | NodeType): Dequery;
|
|
1266
|
+
append(content: string | NodeType): Dequery;
|
|
1267
|
+
on(eventName: string, handler: EventListener): Dequery;
|
|
1268
|
+
off(eventName: string, handler: EventListener): Dequery;
|
|
1269
|
+
css(cssProps: string): string | undefined;
|
|
1270
|
+
css(cssProps: CSSProperties): Dequery;
|
|
1271
|
+
css(cssProps: string, value: string): Dequery;
|
|
1222
1272
|
addClass(className: Array<string> | string): Dequery;
|
|
1223
1273
|
removeClass(className: Array<string> | string): Dequery;
|
|
1224
|
-
hasClass(className: string):
|
|
1274
|
+
hasClass(className: string): Dequery;
|
|
1225
1275
|
toggleClass(className: string): Dequery;
|
|
1226
|
-
|
|
1227
|
-
|
|
1276
|
+
animateClass(className: string, duration: number): Dequery;
|
|
1277
|
+
click(): Dequery;
|
|
1278
|
+
focus(): Dequery;
|
|
1279
|
+
blur(): Dequery;
|
|
1280
|
+
val(value: string | boolean): Dequery;
|
|
1281
|
+
val(): string | undefined;
|
|
1282
|
+
map<T = any>(cb: (el: NodeType, idx: number) => any): Array<T>;
|
|
1283
|
+
prop<K extends keyof HTMLElement>(name: K, value: HTMLElement[K]): Dequery;
|
|
1284
|
+
prop<K extends keyof HTMLElement>(name: K): HTMLElement[K];
|
|
1285
|
+
data(name: string): string | undefined;
|
|
1286
|
+
data(name: string, value: string): Dequery;
|
|
1287
|
+
form(): FormKeyValues;
|
|
1288
|
+
form(formData: FormKeyValues): Dequery;
|
|
1228
1289
|
}
|
|
1290
|
+
declare const $: (selectorRefOrEl: Node | Element | Text | Ref<Node | Element | Text, any> | string, options?: DequeryOptions) => Dequery;
|
|
1229
1291
|
|
|
1230
|
-
declare const
|
|
1292
|
+
declare const createInPlaceErrorMessageVNode: (error: unknown) => {
|
|
1293
|
+
type: string;
|
|
1294
|
+
attributes: {};
|
|
1295
|
+
children: string[];
|
|
1296
|
+
};
|
|
1297
|
+
declare const jsx: (type: VNodeType | Function | any, attributes: (JSX.HTMLAttributes & JSX.SVGAttributes & Record<string, any>) | null, key?: string) => Array<VNode> | VNode;
|
|
1298
|
+
declare const observeUnmount: (domNode: Node, onUnmount: () => void) => void;
|
|
1299
|
+
/** lifecycle event attachment has been implemented separately, because it is also required to run when partially updating the DOM */
|
|
1300
|
+
declare const handleLifecycleEventsForOnMount: (newEl: HTMLElement) => void;
|
|
1231
1301
|
declare const getRenderer: (document: Document) => DomAbstractionImpl;
|
|
1232
1302
|
declare const renderIsomorphic: (virtualNode: VNode | undefined | string | Array<VNode | undefined | string>, parentDomElement: Element | Document | Dequery | undefined, globals: Globals) => Array<Element | Text | undefined> | Element | Text | undefined;
|
|
1233
1303
|
declare const Fragment: (props: VNode) => VNodeChildren | undefined;
|
|
1234
|
-
declare const jsxs: (type: VNodeType | Function | any, attributes: (JSX.HTMLAttributes & JSX.SVGAttributes & Record<string, any>) | null) => Array<VNode> | VNode;
|
|
1235
|
-
declare const jsxDEV: (type: VNodeType | Function | any, attributes: (JSX.HTMLAttributes & JSX.SVGAttributes & Record<string, any>) | null) => Array<VNode> | VNode;
|
|
1304
|
+
declare const jsxs: (type: VNodeType | Function | any, attributes: (JSX.HTMLAttributes & JSX.SVGAttributes & Record<string, any>) | null, key?: string) => Array<VNode> | VNode;
|
|
1305
|
+
declare const jsxDEV: (type: VNodeType | Function | any, attributes: (JSX.HTMLAttributes & JSX.SVGAttributes & Record<string, any>) | null, key?: string, allChildrenAreStatic?: boolean, sourceInfo?: string, selfReference?: any) => Array<VNode> | VNode;
|
|
1306
|
+
|
|
1307
|
+
declare const isRef: (obj: any) => obj is Ref<Element>;
|
|
1308
|
+
declare function createRef<ST = any, NT extends Node | Element | Text | null = HTMLElement>(refUpdateFn?: RefUpdateFn<ST>, defaultState?: ST): Ref<NT, ST>;
|
|
1236
1309
|
|
|
1237
|
-
export { type CSSProperties as C,
|
|
1310
|
+
export { $, createRef as A, type FormFieldValue as B, type CSSProperties as C, Dequery as D, type FormKeyValues as E, type FontFaceProperties as F, type Globals as G, type DequeryOptions as H, defaultConfig as I, dequery as J, type KeyFrameProperties as K, type Listener as L, createStore as M, type NodeType as N, type Props as P, type RenderInput as R, type Store as S, type VAttributes as V, type RenderResult as a, type RefUpdateFn as b, type Ref as c, type VNodeAttributes as d, type VNode as e, type VNodeType as f, type VNodeKey as g, type VNodeRefObject as h, type VNodeRefCallback as i, type VNodeRef as j, type VNodeChild as k, type VNodeChildren as l, type Children as m, type DomAbstractionImpl as n, type RenderNodeInput as o, type RenderResultNode as p, createInPlaceErrorMessageVNode as q, jsx as r, observeUnmount as s, handleLifecycleEventsForOnMount as t, getRenderer as u, renderIsomorphic as v, Fragment as w, jsxs as x, jsxDEV as y, isRef as z };
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
"use strict";var l=Object.defineProperty;var n=(t,e)=>l(t,"name",{value:e,configurable:!0});var o=require("./render/index.cjs");const g=n((t,e)=>{t.classList.contains(e)||t.classList.add(e)},"addSingleClass"),f=n((t,e)=>r=>{if(Array.isArray(r))for(let s=0;s<r.length;s++)g(t,r[s]);else g(t,r);return e},"addClass"),u=n((t,e)=>{t.classList.contains(e)&&t.classList.remove(e)},"removeSingleClass"),h=n((t,e)=>r=>{if(Array.isArray(r))for(let s=0;s<r.length;s++)u(t,r[s]);else u(t,r);return e},"removeClass"),p=n((t,e)=>r=>(t.classList.toggle(r),e),"toggleClass"),m=n(t=>e=>t.classList.contains(e),"hasClass"),v=n((t,e)=>(r,s)=>typeof s>"u"?t.getAttribute(r):(t.setAttribute(r,s),e),"attr"),w=n((t,e)=>r=>{const s=t.type==="checkbox";return typeof r>"u"?s?t.checked:t.value:(s?t.checked=r:t.value=r,e)},"val"),d=n((t,e)=>()=>(t.innerHTML="",e),"empty"),y=n((t,e)=>r=>(typeof r=="string"?t.innerHTML=r:(d(t,e)(),t.appendChild(o.renderIsomorphic(r,t,globalThis))),e),"html"),C=n((t,e)=>r=>(t.textContent=r,e),"text"),S=n((t,e)=>()=>(t.parentNode&&t.parentNode.removeChild(t),e),"remove"),x=n(t=>e=>{let r=e;return e instanceof Node||(r=o.renderIsomorphic(e,t,globalThis)),t.parentNode&&t.parentNode.replaceChild(r,t),r},"replaceWith"),I=n((t,e)=>(r,s)=>(t.removeEventListener(r,s),e),"off"),b=n((t,e)=>(r,s)=>(t.addEventListener(r,s),e),"on"),A=n(t=>{let e={},r=t?.current||t;return typeof t=="string"&&(r=document.querySelector(t)),e={el:r,attr:v(r,e),val:w(r,e),empty:d(r,e),html:y(r,e),text:C(r,e),remove:S(r,e),replaceWith:x(r),addClass:f(r,e),removeClass:h(r,e),toggleClass:p(r,e),hasClass:m(r),on:b(r,e),off:I(r,e)},e},"$"),L=n(()=>{const t=new Map;return{clear:n(()=>{t.clear()},"clear"),getItem:n(e=>t.get(String(e))??null,"getItem"),removeItem:n(e=>{t.delete(String(e))},"removeItem"),setItem:n((e,r)=>{t.set(String(e),r)},"setItem")}},"newInMemoryGenericStorageBackend"),j=L();class i{static{n(this,"WebStorageProvider")}storage;constructor(e){this.storage=e||j}get(e,r,s){const a=this.storage.getItem(e);if(a===null)return r;let c=JSON.parse(a);return s&&(c=s(e,c)),c}set(e,r,s){s&&(r=s(e,r)),this.storage.setItem(e,JSON.stringify(r))}remove(e){this.storage.removeItem(e)}removeAll(){this.storage.clear()}get backendApi(){return this.storage}}const E=n((t,e)=>{switch(t){case"session":return new i(window.sessionStorage);case"local":return new i(window.localStorage)}return new i},"getPersistenceProvider$1"),P=n((t,e)=>new i,"getPersistenceProvider"),k=n(()=>typeof window>"u"||typeof window.document>"u","isServer"),V=n((t="local",e)=>k()?P():E(t),"cache");exports.Fragment=o.Fragment,exports.getRenderer=o.getRenderer,exports.jsx=o.jsx,exports.jsxDEV=o.jsxDEV,exports.jsxs=o.jsxs,exports.renderIsomorphic=o.renderIsomorphic,exports.$=A,exports.cache=V;
|
|
1
|
+
"use strict";var I=Object.defineProperty;var o=(t,e)=>I(t,"name",{value:e,configurable:!0});var h=require("./index-B8vV328V.cjs");const H=!0,C=o((t,e)=>{if(t===e)return!0;if(t.nodeType!==e.nodeType)return!1;if(t.nodeType===Node.ELEMENT_NODE){const r=t,s=e;if(r.tagName!==s.tagName)return!1;const n=r.attributes,i=s.attributes;if(n.length!==i.length)return!1;for(let c=0;c<n.length;c++){const l=n[c],u=s.getAttribute(l.name);if(l.value!==u)return!1}}return!(t.nodeType===Node.TEXT_NODE&&t.textContent!==e.textContent)},"areDomNodesEqual"),v=o((t,e)=>{if(!C(t,e)){t.parentNode?.replaceChild(e.cloneNode(!0),t);return}if(t.nodeType===Node.ELEMENT_NODE){const r=t.childNodes,s=e.childNodes,n=Math.max(r.length,s.length);for(let i=0;i<n;i++){const c=r[i],l=s[i];c&&l?v(c,l):l&&!c?t.appendChild(l.cloneNode(!0)):c&&!l&&t.removeChild(c)}}},"updateNode"),T=o((t,e)=>{const s=new DOMParser().parseFromString(e,"text/html"),n=Array.from(s.body.children);if(n.length===0){console.warn("No root elements found in the new HTML.");return}for(let i=0;i<n.length;i++){const c=n[i],l=t.children[i];l?v(l,c):t.appendChild(c.cloneNode(!0))}for(;t.children.length>n.length;)t.removeChild(t.lastChild)},"updateDom");function A(t){if(t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="object"&&"type"in t)return t}o(A,"toValidChild");function N(t,e){if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return t.nodeType===Node.TEXT_NODE;if(e&&typeof e=="object"){if(t.nodeType!==Node.ELEMENT_NODE)return!1;const r=t.tagName.toLowerCase(),s=e.type.toLowerCase();return r===s}return!1}o(N,"areNodeAndChildMatching");function B(t,e,r){const s=h.getRenderer(r.window.document);if(typeof e=="string"||typeof e=="number"||typeof e=="boolean"){const n=String(e);t.nodeValue!==n&&(t.nodeValue=n);return}if(t.nodeType===Node.ELEMENT_NODE&&e&&typeof e=="object"){const n=t,i=Array.from(n.attributes);for(const c of i){const{name:l}=c;!Object.prototype.hasOwnProperty.call(e.attributes,l)&&l!=="style"&&n.removeAttribute(l)}if(s.setAttributes(e,n),e.attributes?.dangerouslySetInnerHTML){n.innerHTML=e.attributes.dangerouslySetInnerHTML.__html;return}if(e.children)b(n,e.children,r);else for(;n.firstChild;)n.removeChild(n.firstChild)}}o(B,"patchDomInPlace");function _(t,e){const r=h.getRenderer(e.window.document);if(t==null)return;if(typeof t=="string"||typeof t=="number"||typeof t=="boolean")return e.window.document.createTextNode(String(t));let s=r.createElementOrElements(t);return s&&!Array.isArray(s)&&(s=[s]),s}o(_,"createDomFromChild");function b(t,e,r){console.log("updateDomWithVdom",e,t);let s=[];if(Array.isArray(e))s=e.map(A).filter(l=>l!==void 0);else if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")s=[e];else if(e){const l=A(e);l!==void 0&&(s=[l])}console.log("new children to render!",s);const n=s.map(l=>_(l,r)),i=Array.from(t.childNodes),c=Math.max(i.length,n.length);for(let l=0;l<c;l++){const u=i[l],f=n[l],p=s[l];if(u&&f!==void 0)if(Array.isArray(f))if(f.length===0)t.removeChild(u);else{const m=f[0];t.replaceChild(m,u),typeof m<"u"&&h.handleLifecycleEventsForOnMount(m);for(let d=1;d<f.length;d++)f[d]&&(t.insertBefore(f[d],m.nextSibling),typeof f[d]<"u"&&(console.log("inserBefore!"),h.handleLifecycleEventsForOnMount(f[d])))}else f&&(p&&N(u,p)?B(u,p,r):(t.replaceChild(f,u),h.handleLifecycleEventsForOnMount(f)));else!u&&f!==void 0?Array.isArray(f)?f.forEach(m=>{const d=m&&t.appendChild(m);return d&&h.handleLifecycleEventsForOnMount(m),d}):f&&(t.appendChild(f),h.handleLifecycleEventsForOnMount(f)):u&&f===void 0&&t.removeChild(u)}}o(b,"updateDomWithVdom");function j(t,e,r){for(;t.firstChild;)t.removeChild(t.firstChild);const n=h.getRenderer(r.window.document).createElementOrElements(e);if(Array.isArray(n))for(const i of n)i&&t.appendChild(i);else n&&t.appendChild(n)}o(j,"replaceDomWithVdom");const a=o(t=>{if(t instanceof HTMLElement)return t;let e="Expected an HTMLElement, but found: ";throw t?.nodeName?e+=t.nodeName:e+=t,new Error(e)},"elementGuard"),g={maxWaitMs:1e3},L=o((t,e=g)=>{if(!t)throw console.error("dequery: selector, ref, or element is required. Got nothing."),new Error("dequery: selector, ref, or element is required. Got nothing.");const r=new x({...g,...e});return typeof t=="string"?r.query(t):h.isRef(t)?r.elements=[t.current]:t.nodeType===Node.ELEMENT_NODE&&(r.elements=[t]),a(r.el),r},"dequery");class x{static{o(this,"Dequery")}constructor(e=g,r=[]){this.options=e,this.elements=r,this.options={...g,...e},this.elements=[]}get el(){return this.elements[0]}tap(e){return e(this.elements),this}query(e){return console.log("querying",e),this.elements=Array.from(document.querySelectorAll(e)),this}first(){return this.elements=[this.el],this}last(){const e=this.elements;return this.elements=[e[e.length-1]],this}next(){return this.elements=this.elements.map(e=>a(e).nextElementSibling).filter(Boolean),this}eq(e){return this.elements=[this.elements[e]],this}prev(){return this.elements=this.elements.map(e=>a(e).previousElementSibling).filter(Boolean),this}each(e){return this.elements.forEach(e),this}find(e){return this.elements=this.elements.flatMap(r=>Array.from(a(r).querySelectorAll(e))),this}parent(){return this.elements=this.elements.map(e=>e.parentElement).filter(Boolean),this}children(){return this.elements=this.elements.flatMap(e=>Array.from(a(e).children)),this}closest(e){return this.elements=this.elements.map(r=>a(r).closest(e)).filter(Boolean),this}filter(e){return this.elements=this.elements.filter(r=>a(r).matches(e)),this}attr(e,r){return r!==void 0?(this.elements.forEach(s=>a(s).setAttribute(e,r)),this):a(this.el)?.getAttribute(e)??null}empty(){return this.elements.forEach(e=>{a(e).innerHTML=""}),this}html(e){return e&&this.elements.forEach(r=>{T(a(r),e)}),this}jsx(e){return this.elements.forEach(r=>{b(a(r),e,globalThis)}),this}text(e){return e&&this.elements.forEach(r=>{a(r).textContent=e}),this}remove(){return this.elements.forEach(e=>a(e).remove()),this}replaceWithJsx(e){return this.elements.forEach(r=>{const s=e instanceof Node?e:h.renderIsomorphic(e,a(r),globalThis);r.parentNode?.replaceChild(s.cloneNode(!0),r)}),this}append(e){return this.elements.forEach(r=>{typeof e=="string"?a(r).innerHTML+=e:r.appendChild(e)}),this}on(e,r){return this.elements.forEach(s=>s.addEventListener(e,r)),this}off(e,r){return this.elements.forEach(s=>s.removeEventListener(e,r)),this}css(e,r){return!r&&typeof e=="string"?a(this.el)?.style.getPropertyValue(e):!r&&typeof e=="object"?(this.elements.forEach(s=>{for(const n in e)a(s).style.setProperty(n,e[n])}),this):typeof r=="string"&&typeof e=="string"?(this.elements.forEach(s=>{a(s).style.setProperty(e,r)}),this):this}addClass(e){const r=Array.isArray(e)?e:[e];return this.elements.forEach(s=>a(s).classList.add(...r)),this}removeClass(e){const r=Array.isArray(e)?e:[e];return this.elements.forEach(s=>a(s).classList.remove(...r)),this}hasClass(e){const r=this.elements.every(s=>a(s).classList.contains(e));return console.log(`Has class "${e}":`,r),this}toggleClass(e){return this.elements.forEach(r=>a(r).classList.toggle(e)),this}animateClass(e,r){return this.elements.forEach(s=>{a(s).classList.add(e),setTimeout(()=>a(s).classList.remove(e),r)}),this}click(){return this.elements.forEach(e=>a(e).click()),this}focus(){return this.elements.forEach(e=>a(e).focus()),this}blur(){return this.elements.forEach(e=>a(e).blur()),this}val(e){return typeof e<"u"?(this.elements.forEach(r=>{r instanceof HTMLInputElement&&(r.value=String(e))}),this):a(this.el)?.value}map(e){return this.elements.map(e)}prop(e,r){return typeof r<"u"?(this.elements.forEach(s=>{a(s)[e]=r}),this):a(this.el)[e]}data(e,r){return typeof r<"u"?(this.elements.forEach(s=>{a(s).dataset[e]=r}),this):a(this.el)?.dataset[e]}form(e){if(e)return Object.entries(e).forEach(([s,n])=>{this.elements.forEach(i=>{i instanceof HTMLInputElement&&(i.value=n)})}),this;const r={};return this.elements.forEach(s=>{s instanceof HTMLInputElement&&(r[s.name]=s.value)}),r}}const R=L,F=o(()=>{const t=new Map;return{clear:o(()=>{t.clear()},"clear"),getItem:o(e=>t.get(String(e))??null,"getItem"),removeItem:o(e=>{t.delete(String(e))},"removeItem"),setItem:o((e,r)=>{t.set(String(e),r)},"setItem")}},"newInMemoryGenericStorageBackend"),O=F();class E{static{o(this,"WebStorageProvider")}storage;constructor(e){this.storage=e||O}get(e,r,s){const n=this.storage.getItem(e);if(n===null)return r;let i=JSON.parse(n);return s&&(i=s(e,i)),i}set(e,r,s){s&&(r=s(e,r)),this.storage.setItem(e,JSON.stringify(r))}remove(e){this.storage.removeItem(e)}removeAll(){this.storage.clear()}get backendApi(){return this.storage}}const k=o((t,e)=>{switch(t){case"session":return new E(window.sessionStorage);case"local":return new E(window.localStorage)}return new E},"getPersistenceProvider$1"),V=o((t,e)=>new E,"getPersistenceProvider"),W=o(()=>typeof window>"u"||typeof window.document>"u","isServer"),$=o((t="local",e)=>W()?V():k(t),"webstorage"),G=/{([^}]*)}/g,J=o((t,e)=>t.replace(G,(r,s)=>e[s]||`{${s}}`),"interpolate"),S=o(()=>{const t=h.createStore({});let e="en";const r=[];return{language:e,changeLanguage(s){e=s,r.forEach(n=>n(s))},t(s,n={}){const i=t.get(`${e}.${s}`)||s;return typeof i!="string"?i:J(i,n)},load(s,n){t.set(s,{...t.get(s),...n})},subscribe(s){return r.push(s),()=>{const n=r.indexOf(s);n>=0&&r.splice(n,1)}}}},"createI18n"),w=S(),U=o(({path:t,replacements:e,tag:r,...s})=>{const n={};return w.subscribe(()=>{const i=w.t(t,e);console.log("new val",i)}),{tag:r||"span",attributes:{ref:n,...s},children:w.t(t,e)}},"Trans");class y{static{o(this,"Headers")}map;constructor(e={}){this.map=new Map,e instanceof y?e.forEach((r,s)=>this.map.set(s,r)):Object.entries(e).forEach(([r,s])=>this.map.set(r.toLowerCase(),s))}append(e,r){this.map.set(e.toLowerCase(),r)}get(e){return this.map.get(e.toLowerCase())||null}has(e){return this.map.has(e.toLowerCase())}forEach(e){this.map.forEach((r,s)=>e(r,s))}}class M extends EventTarget{static{o(this,"ProgressSignal")}_progress;constructor(){super(),this._progress={loaded:0,total:0}}get progress(){return this._progress}dispatchProgress(e){this._progress={loaded:e.loaded,total:e.total},this.dispatchEvent(new ProgressEvent("progress",{loaded:e.loaded,total:e.total}))}}class K{static{o(this,"ProgressController")}signal;constructor(){this.signal=new M}}function P(t){return t?t instanceof FormData||t instanceof Blob||t instanceof URLSearchParams||t instanceof ArrayBuffer||ArrayBuffer.isView(t)||typeof t=="string"?t:typeof t=="object"?JSON.stringify(t):String(t):null}o(P,"serializeBody");function q(t){const e=new y;return t.split(`\r
|
|
2
|
+
`).forEach(r=>{const[s,...n]=r.split(": ");s&&e.append(s,n.join(": "))}),e}o(q,"parseHeaders");async function D(t,e={}){return!e.progressSignal&&typeof globalThis.fetch=="function"?D(t,e):new Promise((r,s)=>{const n=new XMLHttpRequest,i=(e.method||"GET").toUpperCase(),c=P(e.body||null),l=e.progressSignal,u=e.signal;if(u){const f=o(()=>{n.abort(),s(new DOMException("The operation was aborted.","AbortError"))},"abortHandler");u.addEventListener("abort",f,{once:!0})}n.open(i,t.toString(),!0),e.credentials==="include"?n.withCredentials=!0:e.credentials==="omit"&&(n.withCredentials=!1),e.headers instanceof y?e.headers.forEach((f,p)=>n.setRequestHeader(p,f)):e.headers&&Object.entries(e.headers).forEach(([f,p])=>{n.setRequestHeader(f,p)}),l&&(n.upload&&(n.upload.onprogress=f=>l.dispatchProgress(f)),n.onprogress=f=>l.dispatchProgress(f)),n.onload=()=>{const f={ok:n.status>=200&&n.status<300,status:n.status,statusText:n.statusText,headers:q(n.getAllResponseHeaders()),url:n.responseURL,text:o(()=>Promise.resolve(n.responseText),"text"),json:o(()=>Promise.resolve(JSON.parse(n.responseText)),"json"),blob:o(()=>Promise.resolve(new Blob([n.response])),"blob")};r(f)},n.onerror=()=>s(new TypeError("Network request failed")),n.ontimeout=()=>s(new TypeError("Network request timed out")),n.onabort=()=>s(new DOMException("The operation was aborted.","AbortError")),n.send(c)})}o(D,"fetch"),exports.Fragment=h.Fragment,exports.createInPlaceErrorMessageVNode=h.createInPlaceErrorMessageVNode,exports.createRef=h.createRef,exports.createStore=h.createStore,exports.ensureKey=h.ensureKey,exports.getAllKeysFromPath=h.getAllKeysFromPath,exports.getByPath=h.getByPath,exports.getRenderer=h.getRenderer,exports.handleLifecycleEventsForOnMount=h.handleLifecycleEventsForOnMount,exports.isRef=h.isRef,exports.jsx=h.jsx,exports.jsxDEV=h.jsxDEV,exports.jsxs=h.jsxs,exports.observeUnmount=h.observeUnmount,exports.renderIsomorphic=h.renderIsomorphic,exports.setByPath=h.setByPath,exports.$=R,exports.Dequery=x,exports.Headers=y,exports.ProgressController=K,exports.ProgressSignal=M,exports.Trans=U,exports.areDomNodesEqual=C,exports.createI18n=S,exports.defaultConfig=g,exports.dequery=L,exports.fetch=D,exports.i18n=w,exports.inDevMode=H,exports.parseHeaders=q,exports.replaceDomWithVdom=j,exports.serializeBody=P,exports.updateDom=T,exports.updateDomWithVdom=b,exports.webstorage=$;
|
|
2
3
|
//# sourceMappingURL=index.cjs.map
|