olova 2.0.15 → 2.0.16

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.
Files changed (2) hide show
  1. package/dist/olova.js +1 -1
  2. package/package.json +1 -1
package/dist/olova.js CHANGED
@@ -1 +1 @@
1
- const e=Symbol("BATCH_UPDATES"),t=Symbol("SIGNAL_TYPE");class n{constructor(){this.globalSubs=new Set,this.propSubs=new Map,this.weakPropSubs=new WeakMap,this.dependencies=new WeakMap,this.batchMode=!1,this.pendingDeps=new Set}subscribe(e,t){if(!t)return;this.dependencies.has(t)||this.dependencies.set(t,new Set);const n=this.dependencies.get(t);if(!n.has(e)){if(n.add(e),!e)return void this.globalSubs.add(t);const r="object"==typeof e?this.weakPropSubs:this.propSubs;r.has(e)||r.set(e,new Set),r.get(e).add(t)}}notify(e,t=new Set){if(this.batchMode)return this.pendingDeps.add(e),t;if(e){const n=this.propSubs.get(e);if(n&&this.notifyDependentSubs(n,e,t),"object"==typeof e){const n=this.weakPropSubs.get(e);n&&this.notifyDependentSubs(n,e,t)}}return this.notifyDependentSubs(this.globalSubs,e,t),t}startBatch(){this.batchMode=!0,this.pendingDeps.clear()}endBatch(){this.batchMode=!1;const e=new Set;for(const t of this.pendingDeps)this.notify(t,e);return this.pendingDeps.clear(),e}notifyDependentSubs(e,t,n){for(const r of e)if(!n.has(r)){const e=this.dependencies.get(r);t&&e&&!e.has(t)||(r(),n.add(r))}}cleanup(e){if(e){this.propSubs.delete(e);for(const[t,n]of this.dependencies)n.delete(e),0===n.size&&this.dependencies.delete(t)}}}class r{constructor(){this.updates=new Map,this.priorities=new Map,this.timeouts=new Map,this.debounceTime=16}add(e,t,n=0,r=!1){if(r)return this.timeouts.has(e)&&clearTimeout(this.timeouts.get(e)),void this.timeouts.set(e,setTimeout((()=>{this.addImmediate(e,t,n),this.timeouts.delete(e)}),this.debounceTime));this.addImmediate(e,t,n)}addImmediate(e,t,n){if(this.updates.has(e)){const r=this.updates.get(e),o=this.priorities.get(e)||0;"object"==typeof r&&"object"==typeof t&&(t={...r,...t}),n=Math.max(o,n)}this.updates.set(e,t),this.priorities.set(e,n)}process(e){0!==this.updates.size&&(this.timeouts.size>0?Promise.all(Array.from(this.timeouts.values()).map((e=>new Promise((t=>{const n=setInterval((()=>{this.timeouts.has(e)||(clearInterval(n),t())}),0)}))))).then((()=>this.processImmediate(e))):this.processImmediate(e))}processImmediate(e){const t=[...this.updates.entries()].sort(((e,t)=>(this.priorities.get(t[0])||0)-(this.priorities.get(e[0])||0)));e.startBatch();const n=new Set;for(const[r,o]of t)"function"==typeof o&&o(),e.notify(r,n);e.endBatch(),this.updates.clear(),this.priorities.clear()}clear(){this.timeouts.forEach((e=>clearTimeout(e))),this.timeouts.clear(),this.updates.clear(),this.priorities.clear()}}const o=(o,i={})=>{const{equals:s=Object.is,immediate:a=!0,batched:c=!1,debounce:l=!1,throttle:u=0,persistence:d=!1,validate:f,transform:h,history:m=0,middleware:g=[],onError:y,computed:b}=i;let w=o;const S=new n,x=new r,T=m>0?new Array(m):null;let E=-1;const C={readCount:0,writeCount:0,lastUpdateTime:0,averageUpdateTime:0,totalUpdateTime:0},v=new Map;let N=!0;const M=d&&"string"==typeof d?d:`signal_${Math.random().toString(36).slice(2)}`;if(d)try{const e=localStorage.getItem(M);e&&(w=JSON.parse(e))}catch(e){A(e,"persistence_load")}const A=(e,t,n={})=>{const r={error:e,phase:t,value:w,timestamp:Date.now(),...n};y?y(r):console.error("Signal error:",r)},_=e=>{C.readCount++;const t=p();return t&&S.subscribe(e,t),b&&e&&b[e]?(!N&&v.has(e)||v.set(e,b[e](w)),v.get(e)):e?w[e]:w},D={undo:()=>{!T||E<0||(w=structuredClone(T[E]),E=(E-1+m)%m,S.notify())},reset:()=>{w=o,T&&T.fill(void 0),E=-1,v.clear(),N=!0,S.notify()},getMetrics:()=>({...C}),getHistory:()=>T?[...T]:null,subscribe:e=>S.subscribe(null,e),batch:_[e]};return Object.assign(_,D),_[t]=!0,_[e]=()=>(S.startBatch(),()=>{S.endBatch(),x.clear()}),[_,async(e,t,n=0)=>{const r=performance.now();C.writeCount++;try{let o=e;for(const e of g)o=await e(o,{prop:t,value:w,options:i});const a=(e=>{if(!h)return e;try{return h(e)}catch(t){return A(t,"transform"),e}})("function"==typeof o?o(t?w[t]:w):o);if(!(e=>{if(!f)return!0;try{return f(e)}catch(e){return A(e,"validation"),!1}})(a))return void A(new Error("Validation failed"),"validation",{newValue:a});if(!(t?!s(w[t],a):!s(w,a)))return;if(T&&(E=(E+1)%m,T[E]=structuredClone(w)),w=t?{...w,[t]:a}:a,N=!0,v.clear(),d)try{localStorage.setItem(M,JSON.stringify(w))}catch(e){A(e,"persistence_save")}c?(x.add(t,a,n,l),queueMicrotask((()=>{x.process(S)}))):S.notify(t);const u=performance.now()-r;C.lastUpdateTime=u,C.totalUpdateTime+=u,C.averageUpdateTime=C.totalUpdateTime/C.writeCount}catch(e){A(e,"write")}}]};function i(e,t=[],n={}){const{immediate:r=!0,batch:o=!0,debounce:i=0,throttle:s=0,priority:a=0,errorHandler:c}=n;let l=null,u=new Set,d=[],f=!1,p=0,m=null,g=0,y=0;const b={totalExecutionTime:0,averageExecutionTime:0,lastExecutionTime:0,maxExecutionTime:0},w=()=>{try{l&&l(),u.forEach((e=>{try{e()}catch(e){S(e,"cleanup function")}})),u.clear()}catch(e){S(e,"main cleanup")}},S=(e,n,r=0)=>{y++;const o={error:e,phase:n,executionCount:g,dependencies:[...t],timestamp:Date.now()};c?c(o):console.error("Effect error:",o),r<3&&setTimeout((()=>{x(r+1)}),1e3*Math.pow(2,r))},x=async(n=0)=>{if(f&&s>0)return;if(!r&&d.length===t.length&&!t.some(((e,t)=>{const n=d[t];return!Object.is(e,n)&&JSON.stringify(e)!==JSON.stringify(n)})))return;const o=performance.now();f=!0;try{w(),h=x;const n=await Promise.resolve(e());l=n||null;const r=performance.now()-o;b.totalExecutionTime+=r,b.lastExecutionTime=r,b.maxExecutionTime=Math.max(b.maxExecutionTime,r),b.averageExecutionTime=b.totalExecutionTime/++g,r>16&&console.warn(`Long running effect detected (${r.toFixed(2)}ms)`),d=[...t],p=Date.now(),y=0}catch(e){S(e,"execution",n)}finally{h=null,f=!1}},T=()=>{clearTimeout(m),m=setTimeout(x,i)},E={execute:()=>i>0?T():x(),cleanup:w,isRunning:()=>f,getMetrics:()=>({...b}),registerCleanup:e=>{if("function"!=typeof e)throw new Error("Cleanup must be a function");return u.add(e),()=>u.delete(e)},reset:()=>{w(),d=[],g=0,y=0,Object.keys(b).forEach((e=>b[e]=0))}};return r&&(o?queueMicrotask((()=>{i>0?T():x()})):i>0?T():x()),E}function s(e){const t=p();if(!t)throw new Error("onCleanup must be called within a reactive context");if(!t.cleanupFns)return e;t.cleanupFns.add(e)}function a(e,t=[],n={}){const[r,s]=o(void 0,n);let a=!1,c=[];return i((()=>{if(c.length>0&&t.length>0&&!t.some(((e,t)=>e!==c[t])))return;const o=e();a&&n.equals&&n.equals(r(),o)||(s(o),a=!0),c=[...t]}),t),r}function c(e,t={}){const{initialValue:n=null,cacheTime:r=5e3,retries:i=3,retryDelay:s=1e3,lazy:a=!1}=t,[c,l]=o(n),[u,d]=o(!1),[f,h]=o(null);let p=new Map,m=new Map,g=0;const y=e=>{e?(p.delete(e),m.has(e)&&(clearTimeout(m.get(e)),m.delete(e))):(p.clear(),m.forEach((e=>clearTimeout(e))),m.clear())},b=async t=>{const n=JSON.stringify(t);if(p.has(n))return p.get(n);d(!0),h(null),g=0;const o=async()=>{try{const o=await e(t);return l(o),p.set(n,o),r>0&&m.set(n,setTimeout((()=>y(n)),r)),o}catch(e){if(g<i)return g++,await new Promise((e=>setTimeout(e,s*g))),o();throw h(e),e}finally{d(!1)}};return o()};return a||b(),{data:c,loading:u,error:f,refetch:b,clearCache:y}}new Map;function l(e,n,...r){const o="http://www.w3.org/1999/xhtml",s=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","text","tspan","defs","use","mask","clipPath","pattern","filter","linearGradient","radialGradient","stop","animate","animateTransform","animateMotion","mpath","set","desc","metadata","title","foreignObject","switch","symbol","marker","view","image"]),c=new Set(["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"]);if("function"==typeof e)return e[t]?a((()=>e({...n,children:1===r.length?r[0]:r})),n.deps||Object.values(n)):e({...n,children:1===r.length?r[0]:r});if(e===u){const e=document.createDocumentFragment();return r.flat(1/0).forEach((t=>{const n=S(t);n&&e.appendChild(n)})),e}if("string"!=typeof e)throw new Error(`Invalid element type: ${e}`);let l=o;s.has(e.toLowerCase())?l="http://www.w3.org/2000/svg":e.startsWith("math")&&(l="http://www.w3.org/1998/Math/MathML");const d=l!==o?document.createElementNS(l,e):document.createElement(e);if(d._props=n,n)for(const[e,s]of Object.entries(n))if(null!=s){switch(e){case"ref":"function"==typeof s?(s(d),d._cleanup=()=>s(null)):s&&(s.current=d,d._cleanup=()=>s.current=null);continue;case"dangerouslySetInnerHTML":null!=s.__html&&(d.innerHTML=s.__html,r=[]);continue;case"style":"string"==typeof s?d.style.cssText=s:Object.entries(s).forEach((([e,t])=>{"number"!=typeof t||/^(z|opacity|flex|order|grid)/.test(e)||(t+="px"),d.style[e]=t}));continue;case"classList":Array.isArray(s)?d.classList.add(...s.filter(Boolean)):"object"==typeof s&&Object.entries(s).forEach((([e,t])=>{d.classList.toggle(e,Boolean(t))}));continue;case"className":case"class":d.setAttribute("class",s);continue;case"key":case"children":case"deps":continue}if(e.startsWith("on")){const t=e.slice(2).toLowerCase(),n=t.endsWith("capture"),r=n?t.slice(0,-7):t,o="function"==typeof s?s:new Function(s);d.addEventListener(r,o,n),d._cleanupFns||(d._cleanupFns=new Map),d._cleanupFns.set(r,(()=>{d.removeEventListener(r,o,n)}))}else if("function"==typeof s&&s[t]){const t=i((()=>{l!==o?null==s()||!1===s()?d.removeAttribute(e):d.setAttribute(e,!0===s()?"":s()):c.has(e)?d[e]=Boolean(s()):d[e]=s()}));d._cleanupFns||(d._cleanupFns=new Map),d._cleanupFns.set(`${e}_effect`,t)}else if(l!==o)!0===s?d.setAttribute(e,""):!1!==s&&d.setAttribute(e,s);else if(c.has(e))d[e]=Boolean(s);else try{d[e]=s}catch{d.setAttribute(e,s)}}const f=e=>{if(null==e)return;if(Array.isArray(e))return void e.flat(1/0).forEach(f);const t=S(e);t&&(t instanceof DocumentFragment||t instanceof Node?d.appendChild(t):d.appendChild(document.createTextNode(String(t))))};if(r.forEach(f),d._cleanupFns?.size){const e=()=>{d._cleanupFns.forEach((e=>e())),d._cleanupFns.clear()};d._cleanup=e}return d}const u=Symbol("Fragment");function d(t,n,r={}){const{hydrate:i=!1,onError:s=console.error,suspense:a=!0,beforeMount:c,afterMount:l}=r;if(!i)for(;n.firstChild;)n.removeChild(n.firstChild);const[u]=o(null),d=u[e]();let h=null;function p(e,t,n,r={}){if(t){for(;e.firstChild;)e.removeChild(e.firstChild);f(n,e,r.hydrate)}else f(n,e,r.hydrate)}function m(){try{let e=t();a&&e instanceof Promise?e.then((e=>{p(n,h,e,{hydrate:i}),h=e,l?.()})).catch(s):(p(n,h,e,{hydrate:i}),h=e,l?.())}catch(e){s(e)}}return c?.(),m(),d(),{update:m,cleanup:()=>{for(;n.firstChild;)n.removeChild(n.firstChild)}}}function f(e,t,n){if(!e)return;const r=Array.isArray(e)?e.flat(1/0):[e],o=Array.from(t.childNodes);let i=0;if(r.filter(Boolean).forEach((e=>{"string"==typeof e||"number"==typeof e?n&&o[i]?.nodeType===Node.TEXT_NODE?o[i].textContent=String(e):t.appendChild(document.createTextNode(String(e))):e instanceof Node?n&&o[i]?e.isEqualNode(o[i])||t.replaceChild(e,o[i]):t.appendChild(e):Array.isArray(e)?f(e,t,n):e&&"object"==typeof e&&t.appendChild(document.createTextNode(JSON.stringify(e))),i++})),!n)for(;i<o.length;)t.removeChild(o[i]),i++}let h=null;const p=()=>h;function m(e){const t=Symbol("context");new Map;return{Provider:({value:e,children:n})=>{const r=g(t);h=e;return h=r,n},Context:t,defaultValue:e}}function g(e){return h||e.defaultValue}function y({fallback:e,children:t}){try{return t}catch(t){return e(t)}}function b(e){let t=null,n=null;return function(r){if(!t)throw n||(n=e().then((e=>{t=e.default||e}))),n;return l(t,r)}}function w(e=null){return{current:e}}"undefined"!=typeof window?(window.h=l,window.Fragment=u):"undefined"!=typeof global&&(global.h=l,global.Fragment=u);export{o as setSignal,i as setEffect,a as setMemo,c as setResource,m as setContext,g as useContext,l as h,u as Fragment,d as render,y as ErrorBoundary,b as lazy,s as onCleanup,w as setRef};export default{h:l,Fragment:u};const S=e=>{if(null==e||!1===e||!0===e)return null;const n=()=>{const e=Math.random().toString(36).slice(2,8),t=document.createComment(`start:${e}`),n=document.createComment(`end:${e}`),r=document.createDocumentFragment();return r.appendChild(t),r.appendChild(n),{fragment:r,startNode:t,endNode:n}};if("function"==typeof e){const{fragment:r,startNode:o,endNode:s}=n();let a=null,c=null;return i((()=>{try{let n=(e[t],e());if(null!=n&&!1!==n&&!0!==n||(n=null),n===c)return;if(a){if(a.nodeType===Node.TEXT_NODE&&("string"==typeof n||"number"==typeof n)){const e=String(n);return a.textContent!==e&&(a.textContent=e),void(c=n)}if(a instanceof Element&&n instanceof Element&&a.tagName===n.tagName){const e=a.attributes,t=n.attributes;for(const t of e)n.hasAttribute(t.name)||a.removeAttribute(t.name);for(const e of t)a.getAttribute(e.name)!==e.value&&a.setAttribute(e.name,e.value);if(a.childNodes.length===n.childNodes.length){let e=!1;for(let t=0;t<a.childNodes.length;t++){const r=a.childNodes[t],o=n.childNodes[t];if(r.nodeType!==Node.TEXT_NODE||o.nodeType!==Node.TEXT_NODE){e=!0;break}r.textContent!==o.textContent&&(r.textContent=o.textContent)}if(!e)return void(c=n)}}}const r=s.parentNode,i=document.createDocumentFragment();if(null!=n){const e=x(n);e&&i.appendChild(e)}if(o.nextSibling!==s){let e=o.nextSibling;const t=[];for(;e&&e!==s;)t.push(e),e=e.nextSibling;t.forEach((e=>e.remove()))}i.firstChild?(r.insertBefore(i,s),a=o.nextSibling):a=null,c=n}catch(e){handleError(e,"processChild",{value:result})}})),r}if(Array.isArray(e)){const{fragment:t,startNode:r,endNode:o}=n();let s=[],a=new Map;return i((()=>{const t=e.flat(1/0).filter(Boolean);if(0===t.length){if(0===s.length)return;return E(r.nextSibling,o),s=[],void a.clear()}if(1===t.length&&1===s.length){if(t[0]===s[0])return;const e=S(t[0]);return e&&(E(r.nextSibling,o),r.parentNode.insertBefore(e,o)),void(s=t)}const n=new Map,i=new Map,c=document.createDocumentFragment();t.forEach(((e,t)=>{const r=T(e,t);n.set(r,{item:e,index:t})})),s.forEach(((e,t)=>{const n=T(e,t);i.set(n,{item:e,index:t,node:a.get(n)})}));let l=0;n.forEach((({item:e,index:t},n)=>{const r=i.get(n);if(r){const e=r.node;e&&(c.appendChild(e),a.set(n,e),r.index<l?function(e){e.dataset.reordered="true"}(e):l=r.index)}else{const t=S(e);t&&(c.appendChild(t),a.set(n,t))}})),E(r.nextSibling,o),r.parentNode.insertBefore(c,o),s=t}),[e]),t}return e instanceof Node?e:document.createTextNode(String(e))};const x=e=>{if(Array.isArray(e)){const t=document.createDocumentFragment();return e.forEach((e=>{const n=S(e);n&&t.appendChild(n)})),t}return e instanceof Node?e:document.createTextNode(String(e))};function T(e,t){return e?.key||`${typeof e}:${String(e)}:${t}`}function E(e,t){const n=[];let r=e;for(;r&&r!==t;)n.push(r),r=r.nextSibling;n.forEach((e=>e.remove()))}
1
+ const e=Symbol("BATCH_UPDATES"),t=Symbol("SIGNAL_TYPE");class n{constructor(){this.globalSubs=new Set,this.propSubs=new Map,this.weakPropSubs=new WeakMap,this.dependencies=new WeakMap,this.batchMode=!1,this.pendingDeps=new Set}subscribe(e,t){if(!t)return;this.dependencies.has(t)||this.dependencies.set(t,new Set);const n=this.dependencies.get(t);if(!n.has(e)){if(n.add(e),!e)return void this.globalSubs.add(t);const i="object"==typeof e?this.weakPropSubs:this.propSubs;i.has(e)||i.set(e,new Set),i.get(e).add(t)}}notify(e,t=new Set){if(this.batchMode)return this.pendingDeps.add(e),t;if(e){const n=this.propSubs.get(e);if(n&&this.notifyDependentSubs(n,e,t),"object"==typeof e){const n=this.weakPropSubs.get(e);n&&this.notifyDependentSubs(n,e,t)}}return this.notifyDependentSubs(this.globalSubs,e,t),t}startBatch(){this.batchMode=!0,this.pendingDeps.clear()}endBatch(){this.batchMode=!1;const e=new Set;for(const t of this.pendingDeps)this.notify(t,e);return this.pendingDeps.clear(),e}notifyDependentSubs(e,t,n){for(const i of e)if(!n.has(i)){const e=this.dependencies.get(i);t&&e&&!e.has(t)||(i(),n.add(i))}}cleanup(e){if(e){this.propSubs.delete(e);for(const[t,n]of this.dependencies)n.delete(e),0===n.size&&this.dependencies.delete(t)}}}class i{constructor(){this.updates=new Map,this.priorities=new Map,this.timeouts=new Map,this.debounceTime=16}add(e,t,n=0,i=!1){if(i)return this.timeouts.has(e)&&clearTimeout(this.timeouts.get(e)),void this.timeouts.set(e,setTimeout((()=>{this.addImmediate(e,t,n),this.timeouts.delete(e)}),this.debounceTime));this.addImmediate(e,t,n)}addImmediate(e,t,n){if(this.updates.has(e)){const i=this.updates.get(e),o=this.priorities.get(e)||0;"object"==typeof i&&"object"==typeof t&&(t={...i,...t}),n=Math.max(o,n)}this.updates.set(e,t),this.priorities.set(e,n)}process(e){0!==this.updates.size&&(this.timeouts.size>0?Promise.all(Array.from(this.timeouts.values()).map((e=>new Promise((t=>{const n=setInterval((()=>{this.timeouts.has(e)||(clearInterval(n),t())}),0)}))))).then((()=>this.processImmediate(e))):this.processImmediate(e))}processImmediate(e){const t=[...this.updates.entries()].sort(((e,t)=>(this.priorities.get(t[0])||0)-(this.priorities.get(e[0])||0)));e.startBatch();const n=new Set;for(const[i,o]of t)"function"==typeof o&&o(),e.notify(i,n);e.endBatch(),this.updates.clear(),this.priorities.clear()}clear(){this.timeouts.forEach((e=>clearTimeout(e))),this.timeouts.clear(),this.updates.clear(),this.priorities.clear()}}const o=(o,r={})=>{const{equals:s=Object.is,immediate:a=!0,batched:c=!1,debounce:l=!1}=r;let d=o;const u=new n,f=new i,h=e=>{const t=p();return t&&u.subscribe(e,t),e?d[e]:d};return h[e]=()=>(u.startBatch(),()=>{u.endBatch(),f.clear()}),h[t]=!0,[h,(e,t,n=0)=>{const i="function"==typeof e?e(t?d[t]:d):e;(t?!s(d[t],i):!s(d,i))&&(d=t?{...d,[t]:i}:i,c?(f.add(t,i,n,l),queueMicrotask((()=>{f.process(u)}))):u.notify(t))}]};function r(e,t={defer:!1}){let n=null,i=new Set,o=new Set;const r=()=>{n&&n(),o.forEach((e=>e())),o.clear(),i.clear(),h=r;try{n=e()||null}finally{h=null}};return t.defer||r(),r}function s(e){const t=p();if(!t)throw new Error("onCleanup must be called within a reactive context");if(!t.cleanupFns)return e;t.cleanupFns.add(e)}function a(e,t={}){const[n,i]=o(void 0,t);let s=!1,a=new Set;return r((()=>{a.clear();const o=e();s&&t.equals&&t.equals(n(),o)||(i(o),s=!0)})),n}function c(e,t={}){const{initialValue:n=null,cacheTime:i=5e3,retries:r=3,retryDelay:s=1e3,lazy:a=!1}=t,[c,l]=o(n),[d,u]=o(!1),[f,h]=o(null);let p=new Map,m=new Map,g=0;const y=e=>{e?(p.delete(e),m.has(e)&&(clearTimeout(m.get(e)),m.delete(e))):(p.clear(),m.forEach((e=>clearTimeout(e))),m.clear())},b=async t=>{const n=JSON.stringify(t);if(p.has(n))return p.get(n);u(!0),h(null),g=0;const o=async()=>{try{const o=await e(t);return l(o),p.set(n,o),i>0&&m.set(n,setTimeout((()=>y(n)),i)),o}catch(e){if(g<r)return g++,await new Promise((e=>setTimeout(e,s*g))),o();throw h(e),e}finally{u(!1)}};return o()};return a||b(),{data:c,loading:d,error:f,refetch:b,clearCache:y}}new Map;function l(e,n,...i){const o="http://www.w3.org/2000/svg",s=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","text","tspan","defs","use","mask","clipPath"]);if("function"==typeof e)return e({...n,children:i});if(e===d){const e=document.createDocumentFragment();return i.flat().forEach((t=>{const n=w(t);n&&e.appendChild(n)})),e}if("string"!=typeof e)throw new Error(`Invalid element type: ${e}`);const a=s.has(e.toLowerCase())||n&&n.xmlns===o,c=a?document.createElementNS(o,e):document.createElement(e);if(n)for(const[e,i]of Object.entries(n))if("ref"===e)"function"==typeof i?i(c):i&&(i.current=c);else if(e.startsWith("on")){const t=e.slice(2).toLowerCase();c.addEventListener(t,i)}else if("style"===e)"string"==typeof i?c.style.cssText=i:Object.assign(c.style,i);else if("classList"===e){if(Array.isArray(i))c.classList.add(...i.filter(Boolean));else if("object"==typeof i)for(const[e,t]of Object.entries(i))t?c.classList.add(e):c.classList.remove(e)}else"class"===e||"className"===e?c.setAttribute("class",i):["key"].includes(e)||("function"==typeof i&&i[t]?r((()=>{a?c.setAttribute(e,i()):c[e]=i()})):a?!0===i?c.setAttribute(e,""):!1!==i&&null!=i&&c.setAttribute(e,i):c[e]=i);return i.flat().forEach((e=>{if(null==e)return;const t=w(e);t&&(a&&t instanceof SVGElement||t instanceof Node?c.appendChild(t):c.appendChild(document.createTextNode(String(t))))})),c}const d=Symbol("Fragment");function u(t,n,i={}){const{hydrate:r=!1,onError:s=console.error,suspense:a=!0,beforeMount:c,afterMount:l}=i;if(!r)for(;n.firstChild;)n.removeChild(n.firstChild);const[d]=o(null),u=d[e]();c?.();try{let e=t();if(a&&e instanceof Promise)return void e.then((e=>{f(e,n,r),l?.()})).catch(s);f(e,n,r),l?.()}catch(t){s(t)}finally{u()}return()=>{for(;n.firstChild;)n.removeChild(n.firstChild)}}function f(e,t,n){if(!e)return;const i=Array.isArray(e)?e.flat(1/0):[e],o=Array.from(t.childNodes);let r=0;if(i.filter(Boolean).forEach((e=>{"string"==typeof e||"number"==typeof e?n&&o[r]?.nodeType===Node.TEXT_NODE?o[r].textContent=String(e):t.appendChild(document.createTextNode(String(e))):e instanceof Node?n&&o[r]?e.isEqualNode(o[r])||t.replaceChild(e,o[r]):t.appendChild(e):Array.isArray(e)?f(e,t,n):e&&"object"==typeof e&&t.appendChild(document.createTextNode(JSON.stringify(e))),r++})),!n)for(;r<o.length;)t.removeChild(o[r]),r++}let h=null;const p=()=>h;function m(e){const t=Symbol("context");return new Map,{Provider:({value:e,children:n})=>{const i=g(t);return h=e,h=i,n},Context:t,defaultValue:e}}function g(e){return h||e.defaultValue}function y({fallback:e,children:t}){try{return t}catch(t){return e(t)}}function b(e){let t=null,n=null;return function(i){if(!t)throw n||(n=e().then((e=>{t=e.default||e}))),n;return l(t,i)}}function S(e=null){return{current:e}}"undefined"!=typeof window?(window.h=l,window.Fragment=d):"undefined"!=typeof global&&(global.h=l,global.Fragment=d);export{o as setSignal,r as setEffect,a as setMemo,c as setResource,m as setContext,g as useContext,l as h,d as Fragment,u as render,y as ErrorBoundary,b as lazy,s as onCleanup,S as setRef};export default{h:l,Fragment:d};const w=e=>{if(null==e||!1===e||!0===e)return null;const n=()=>{const e=Math.random().toString(36).slice(2,8),t=document.createComment(`start:${e}`),n=document.createComment(`end:${e}`),i=document.createDocumentFragment();return i.appendChild(t),i.appendChild(n),{fragment:i,startNode:t,endNode:n}};if("function"==typeof e){const{fragment:i,startNode:o,endNode:s}=n();let a=null,c=null;return r((()=>{let n=(e[t],e());if(null!=n&&!1!==n&&!0!==n||(n=null),n===c)return;if(a){if(a.nodeType===Node.TEXT_NODE&&("string"==typeof n||"number"==typeof n)){const e=String(n);return a.textContent!==e&&(a.textContent=e),void(c=n)}if(a instanceof Element&&n instanceof Element&&a.tagName===n.tagName){const e=a.attributes,t=n.attributes;for(const t of e)n.hasAttribute(t.name)||a.removeAttribute(t.name);for(const e of t)a.getAttribute(e.name)!==e.value&&a.setAttribute(e.name,e.value);if(a.childNodes.length===n.childNodes.length){let e=!1;for(let t=0;t<a.childNodes.length;t++){const i=a.childNodes[t],o=n.childNodes[t];if(i.nodeType!==Node.TEXT_NODE||o.nodeType!==Node.TEXT_NODE){e=!0;break}i.textContent!==o.textContent&&(i.textContent=o.textContent)}if(!e)return void(c=n)}}}const i=s.parentNode,r=document.createDocumentFragment();if(null!=n){const e=N(n);e&&r.appendChild(e)}if(o.nextSibling!==s){let e=o.nextSibling;const t=[];for(;e&&e!==s;)t.push(e),e=e.nextSibling;t.forEach((e=>e.remove()))}r.firstChild?(i.insertBefore(r,s),a=o.nextSibling):a=null,c=n})),i}if(Array.isArray(e)){const{fragment:t,startNode:i,endNode:o}=n();let s=[],a=new Map;return r((()=>{const t=e.filter(Boolean);if(0===t.length){if(0===s.length)return;let e=i.nextSibling;const t=[];for(;e&&e!==o;)t.push(e),e=e.nextSibling;return t.forEach((e=>e.remove())),s=[],void a.clear()}if(s.length===t.length&&s.length<5){let e=!1;const n=[];let r=i.nextSibling;for(;r&&r!==o;)n.push(r),r=r.nextSibling;for(let i=0;i<t.length;i++){const o=s[i],r=t[i],a=n[i];if(o!==r){if(a.nodeType!==Node.TEXT_NODE||"string"!=typeof r&&"number"!=typeof r){e=!0;break}a.textContent=String(r)}}if(!e)return void(s=[...t])}const n=document.createDocumentFragment(),r=new Map;t.forEach(((e,t)=>{const i=e?.key||`${typeof e}:${String(e)}`;let o;a.has(i)?(o=a.get(i),a.delete(i)):o=w(e),o&&(r.set(i,o),n.appendChild(o))})),a.clear(),a=r;let c=i.nextSibling;const l=[];for(;c&&c!==o;)l.push(c),c=c.nextSibling;l.forEach((e=>e.remove())),o.parentNode.insertBefore(n,o),s=[...t]})),t}return e instanceof Node?e:document.createTextNode(String(e))},N=e=>{if(Array.isArray(e)){const t=document.createDocumentFragment();return e.forEach((e=>{const n=w(e);n&&t.appendChild(n)})),t}return e instanceof Node?e:document.createTextNode(String(e))};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "olova",
3
- "version": "2.0.15",
3
+ "version": "2.0.16",
4
4
  "description": "A lightweight JavaScript framework for building reactive applications.",
5
5
  "main": "dist/olova.js",
6
6
  "keywords": [