spikijs 1.1.36 → 1.1.38

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "spikijs",
3
3
  "license": "MIT",
4
- "version": "1.1.36",
4
+ "version": "1.1.38",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
package/spiki.d.ts CHANGED
@@ -42,28 +42,24 @@ export interface SpikiInstance {
42
42
  */
43
43
  destroy?(): void;
44
44
 
45
- /**
46
- * Allows dynamic properties (e.g. variables from s-for).
47
- */
48
- [key: string]: any;
49
45
  }
50
46
 
51
47
  /**
52
48
  * Helper type for the data factory function.
53
49
  * Ensures 'this' includes your data + Spiki internals.
54
50
  */
55
- export type ComponentFactory<T extends object = Record<string, any>> = (this: T & SpikiInstance) => T & ThisType<T & SpikiInstance>;
51
+ export type ComponentFactory<T> = () => T & ThisType<T & SpikiInstance>;
56
52
 
57
53
  export interface Spiki {
58
54
  /**
59
- * Registers a new component with one or more modules/factories.
55
+ * Registers a new component with a factory function.
60
56
  * @param name Name matching 's-data' in HTML.
61
57
  * @param factory Factory function returning state.
62
58
  */
63
- data<T extends object>(name: string, factory: ComponentFactory<T>): void;
59
+ data<T>(name: string, factory: ComponentFactory<T>): void;
64
60
 
65
61
  /**
66
- * Registers a new component with multiple modules/factories.
62
+ * Registers a new component with one or more modules/factories.
67
63
  * @param name Name matching 's-data' in HTML.
68
64
  * @param modules Factory functions or objects returning/containing state.
69
65
  */
package/spiki.esm.js CHANGED
@@ -193,9 +193,9 @@ var spiki = (() => {
193
193
  set: (target, key, val, receiver) => {
194
194
  var old = target[key];
195
195
  var isArr = Array.isArray(target);
196
- var hadKey = isArr ? Number(key) < target.length : Object.prototype.hasOwnProperty.call(target, key);
196
+ var hadKey = isArr ? (key === 'length' || Number(key) < target.length) : Object.prototype.hasOwnProperty.call(target, key);
197
197
 
198
- if (!hadKey) {
198
+ if (!isArr && !hadKey) {
199
199
  var proto = Object.getPrototypeOf(target);
200
200
  while (proto && proto !== Object.prototype) {
201
201
  var rawProto = proto._t || proto;
@@ -437,11 +437,7 @@ var spiki = (() => {
437
437
  for (var i = 0; i < len; i++) {
438
438
  var key = isArr ? i : keys[i];
439
439
  var item = isArr ? list[i] : list[key];
440
- var unique;
441
- if (item == null || typeof item !== 'object') unique = 'p_' + String(item);
442
- else if (keyPath) unique = 'k_' + evalPath(item, keyPath).val;
443
- else unique = 'i_' + String(key);
444
-
440
+ var unique = (keyPath ? evalPath(item, keyPath).val : null) ?? key;
445
441
  if (usedKeys[unique]) unique += '_' + i;
446
442
  var row = nodePool[unique];
447
443
  if (row) {
@@ -462,14 +458,14 @@ var spiki = (() => {
462
458
  nodePool[unique] = row;
463
459
  }
464
460
  if (row.nodes[0] === anchor) {
465
- if (frag.childNodes.length) end.parentNode.insertBefore(frag, anchor);
461
+ if (frag.childNodes.length && end.parentNode) end.parentNode.insertBefore(frag, anchor);
466
462
  anchor = row.nodes[row.nodes.length - 1].nextSibling;
467
463
  } else {
468
464
  for (var n = 0; n < row.nodes.length; n++) frag.appendChild(row.nodes[n]);
469
465
  }
470
466
  usedKeys[unique] = true;
471
467
  }
472
- if (frag.childNodes.length) end.parentNode.insertBefore(frag, anchor);
468
+ if (frag.childNodes.length && end.parentNode) end.parentNode.insertBefore(frag, anchor);
473
469
  for (var k in nodePool) if (!usedKeys[k]) {
474
470
  nodePool[k].cleanups.forEach(c => c());
475
471
  nodePool[k].nodes.forEach(n => n.remove());
package/spiki.esm.min.js CHANGED
@@ -1 +1 @@
1
- var spiki=(()=>{var e,t=Object.create(null),r=[],a=!1,n=null,o=!1,i=Promise.resolve(),l={blur:1,focus:1,scroll:1,load:1,error:1,mouseenter:1,mouseleave:1,toggle:1},s=e=>{e._q||(e._q=!0,r.push(e),a||(a=!0,i.then(()=>{var e=r;r=[],a=!1;for(var t=0;t<e.length;t++)e[t]._q=!1,e[t]()})))},c=(e,t)=>{var r,a=e;if("string"==typeof t)r=e?e[t]:void 0;else{for(var n=0,o=t.length;n<o-1&&a;)a=a[t[n++]];r=a?a[t[o-1]]:void 0}if(void 0===r){var i=Array.isArray(t)?t.join("."):t;console.warn("[spikijs] Property undefined: "+i)}return{ctx:a,val:r}},p={};["push","pop","shift","unshift","splice","sort","reverse"].forEach(e=>{p[e]=function(...t){o=!0;try{return Array.prototype[e].apply(this,t)}finally{o=!1,u(this,"length")}}});var f=(e,t)=>{if(n){var r=e._d||(Object.defineProperty(e,"_d",{value:Object.create(null),writable:!0}),e._d),a=r[t]||(r[t]=[]);-1===a.indexOf(n)&&(a.push(n),n.deps.push(a))}},u=(e,t)=>{if(!o&&e._d&&e._d[t])for(var r=e._d[t].slice(),a=0,i=r.length;a<i;a++){var l=r[a];l!==n&&(l.sched?l.sched(l):l())}},v=e=>{for(var t=e.deps.length;t--;){var r=e.deps[t],a=r.indexOf(e);-1!==a&&(r[a]=r[r.length-1],r.pop())}e.deps=[]},h=(e,t)=>{var r=()=>{v(r);var t=n;n=r;try{e()}finally{n=t}};return r.deps=[],r.sched=t,r(),()=>v(r)},d=e=>e&&"object"==typeof e&&!e._y&&!(e instanceof Node)&&!(e instanceof Date)&&!(e instanceof RegExp)&&!(e instanceof Map)&&!(e instanceof Set)&&!(e instanceof Promise),y=e=>{if(!d(e))return e;if(Object.prototype.hasOwnProperty.call(e,"_p"))return e._p;var t=new Proxy(e,{get:(e,t,r)=>{if("_y"===t)return r===e._p;if("_t"===t)return e;if("_d"===t)return e._d;if("_i"===t)return e._i;if("_c"===t)return e._c;if(Array.isArray(e)&&p.hasOwnProperty(t))return p[t];var a=Object.getOwnPropertyDescriptor(e,t);if(a&&a.get){var o=e._c||(Object.defineProperty(e,"_c",{value:Object.create(null)}),e._c),i=o[t];if(!i){var l=()=>{v(l);var t=n;n=l;try{i.d=!1,i.v=a.get.call(e._p)}finally{n=t}};l.deps=[],l.sched=()=>{i.d||(i.d=!0,u(e,t))},i=o[t]={r:l,d:!0,v:void 0}}return i.d&&i.r(),f(e,t),d(i.v)?y(i.v):i.v}Object.prototype.hasOwnProperty.call(e,t)&&f(e,Array.isArray(e)?"length":t);var s=Reflect.get(e,t,r);return d(s)?y(s):s},set:(e,t,r,a)=>{var n=e[t],i=Array.isArray(e),l=i?Number(t)<e.length:Object.prototype.hasOwnProperty.call(e,t);if(!l)for(var s=Object.getPrototypeOf(e);s&&s!==Object.prototype;){var c=s._t||s;if(Object.prototype.hasOwnProperty.call(c,t))return s[t]=r,!0;s=Object.getPrototypeOf(c)}var p=Reflect.set(e,t,r,a);return!o&&p&&(!l||r!==n||r&&"object"==typeof r)&&(u(e,t),i?u(e,"length"):l||u(e,"_k")),p},deleteProperty:(e,t)=>{var r=Object.prototype.hasOwnProperty.call(e,t),a=Reflect.deleteProperty(e,t);return a&&r&&(u(e,t),Array.isArray(e)?u(e,"length"):u(e,"_k")),a},ownKeys:e=>(f(e,"_k"),Reflect.ownKeys(e))});return Object.defineProperty(e,"_p",{value:t}),t};e=y({});var g=Object.create(null);g.text=(e,t)=>{t=null==t?"":t,e.textContent!==String(t)&&(e.textContent=t)},g.html=(e,t)=>{e.innerHTML!=t&&(e.innerHTML=null==t?"":t)},g.value=(e,t)=>{"checkbox"===e.type?e.checked=!!t:"radio"===e.type?e.checked=e.value==t:e.value!=t&&(e.value=null==t?"":t)},g.attr=(e,t,r)=>{if(null==t||!1===t)e.removeAttribute(r);else{var a=!0===t?"":String(t);e.getAttribute(r)!==a&&e.setAttribute(r,a)}},g.class=(e,t)=>{var r=e._n||"",a=Object.create(null);if(r.split(/\s+/).forEach(e=>e&&(a[e]=1)),"string"==typeof t)t.split(/\s+/).forEach(e=>e&&(a[e]=1));else if(t)for(var n in t)t[n]?a[n]=1:delete a[n];var o=Object.keys(a).join(" ");(e.getAttribute("class")||"")!==o&&e.setAttribute("class",o)};var b=(r,a)=>{if(r._m)return r._m;var n=r.getAttribute("s-data");if(t[n]){var o=t[n]();o.$refs={},o.$root=r,o.$store=e,o.$parent=a,a&&Object.setPrototypeOf(o,a);var i=y(o),p=[],u=Object.create(null),d=e=>{var t=e.target;if("input"!==e.type||!t._c)for(var a=r.parentNode,n=e.type;t&&t!==a&&!e.cancelBubble;){var o=t._h&&t._h[n];if(o){var l=t._s;if(!l||l.$root!==i.$root){t=t.parentNode;continue}for(var s=o.length;s--;){var p=o[s],f=p.p;if(p.model){var u="checkbox"===t.type?t.checked:t.value;if("number"===t.type||"range"===t.type)u=""===u?null:Number(u);else if("string"==typeof u){var v=u.trim();v&&v.length<16&&46!==v.charCodeAt(v.length-1)&&isFinite(v)&&(48===v.charCodeAt(0)&&1!==v.length&&46!==v.charCodeAt(1)||(u=Number(v)))}if("string"==typeof f)l&&(l[f]=u);else{for(var h=l,d=0,y=f.length-1;d<y&&h;)h=h[f[d++]];h&&(h[f[y]]=u)}}else{var g=c(l,f);"function"==typeof g.val&&(Object.defineProperty(e,"currentTarget",{configurable:!0,value:t}),g.val.call(g.ctx,e))}if(e.cancelBubble)break}}t=t.parentNode}},_=e=>{u[e]||(u[e]=!0,r.addEventListener(e,d,!!l[e]))},m=(e,t,a)=>{if(1===e.nodeType&&!e.hasAttribute("s-ignore"))if(e!==r&&e.hasAttribute("s-data")){var n=b(e,t);n&&a.push(n.unmount)}else{var o=e.getAttribute("s-if"),l=!o&&"TEMPLATE"===e.tagName&&e.getAttribute("s-for"),p=[];if(e.hasAttribute("class")&&!e._n&&(e._n=e.getAttribute("class")),o){var u=document.createTextNode(""),v=null,d=[];e.replaceWith(u);var O="!"===o[0],A=O?o.slice(1):o,j=-1===A.indexOf(".")?A:A.split(".");return a.push(()=>{for(var e=d.length;e--;)d[e]()}),a.push(h(()=>{var r=c(t,j).val;if(O&&(r=!r),r)v||((v=e.cloneNode(!0)).removeAttribute("s-if"),m(v,t,d),u.parentNode.insertBefore(v,u));else if(v){for(var a=d.length;a--;)d[a]();d=[],v.remove(),v=null}},s))}if(l){var x=l.indexOf(" in ");if(-1!==x){var P,N=l.slice(0,x).trim(),E=l.slice(x+4).trim(),k=N.replace(/[()]/g,"").split(","),w=k[0].trim(),C=k[1]?k[1].trim():null,S=-1===E.indexOf(".")?E:E.split("."),T=e.getAttribute("s-key"),L=T?-1===T.indexOf(".")?T:T.split("."):null,$=(u=document.createTextNode(""),Object.create(null));return e.replaceWith(u),a.push(()=>{for(var e in $)$[e].cleanups.forEach(e=>e())}),a.push(h(()=>{var r=c(t,S).val||[];"number"==typeof r&&(r=Array.from({length:Math.max(0,Math.floor(r))},(e,t)=>t+1)),Array.isArray(r)&&f(r,"length");var a=document.createDocumentFragment(),n=u.nextSibling;P=Object.create(null);for(var o=Array.isArray(r),i=o?r:Object.keys(r),l=o?r.length:i.length,s=0;s<l;s++){var p,v=o?s:i[s],h=o?r[s]:r[v];p=null==h||"object"!=typeof h?"p_"+String(h):L?"k_"+c(h,L).val:"i_"+String(v),P[p]&&(p+="_"+s);var d=$[p];if(d)d.scope[w]=h,C&&(d.scope[C]=v);else{var g=e.content.cloneNode(!0),b=Object.create(t);Object.defineProperty(b,"_i",{value:!0});var _=y(b);_[w]=h,C&&(_[C]=v);for(var O=Array.prototype.slice.call(g.childNodes),A=[],j=0;j<O.length;j++)m(O[j],_,A);d={nodes:Array.prototype.slice.call(g.childNodes),scope:_,cleanups:A},$[p]=d}if(d.nodes[0]===n)a.childNodes.length&&u.parentNode.insertBefore(a,n),n=d.nodes[d.nodes.length-1].nextSibling;else for(j=0;j<d.nodes.length;j++)a.appendChild(d.nodes[j]);P[p]=!0}for(var x in a.childNodes.length&&u.parentNode.insertBefore(a,n),$)P[x]||($[x].cleanups.forEach(e=>e()),$[x].nodes.forEach(e=>e.remove()),delete $[x])},s))}}if(e.hasAttributes())for(var M=e.attributes,R=M.length;R--;){var B=M[R],D=B.name,q=B.value;if(58===D.charCodeAt(0)){var F=D.slice(1),H=33===q.charCodeAt(0),K=H?q.slice(1):q;j=-1===K.indexOf(".")?K:K.split(".");p.push({type:"attr",name:F,path:j,neg:H})}else if(115===D.charCodeAt(0)&&45===D.charCodeAt(1)){let r=D.slice(2);if("data"===r)continue;let n=-1===q.indexOf(".")?q:q.split(".");if("init"===r||"destroy"===r)((r,n)=>{var o=c(t,n);"function"==typeof o.val&&("init"===r?s(()=>{var t=o.val.call(o.ctx,e);"function"==typeof t&&a.push(t)}):a.push(()=>o.val.call(o.ctx,e)))})(r,n);else if("effect"===r)a.push(h(()=>{var r=c(t,n);"function"==typeof r.val&&r.val.call(r.ctx,e)},s));else if("model"===r){p.push({type:"value",path:n}),e._s=t,e._h=e._h||{};var W="checkbox"===e.type||"radio"===e.type||"SELECT"===e.tagName?"change":"input";"input"===W&&(e.addEventListener("compositionstart",()=>e._c=!0),e.addEventListener("compositionend",()=>{e._c=!1,e.dispatchEvent(new Event("input",{bubbles:!0}))})),(e._h[W]=e._h[W]||[]).push({model:!0,p:n}),_(W)}else"ref"===r?i.$refs[q]=e:g[r]?p.push({type:r,path:n}):(e._s=t,e._h=e._h||{},(e._h[r]=e._h[r]||[]).unshift({p:n}),_(r))}}for(var z=e.firstChild;z;){var G=z.nextSibling;m(z,t,a),z=G}p.length&&a.push(h(()=>{for(var r=p.length;r--;){var a=p[r],n=c(t,a.path),o="function"==typeof n.val?n.val.call(n.ctx,e):n.val;"attr"===a.type?(a.neg&&(o=!o),"class"===a.name?g.class(e,o):g.attr(e,o,a.name)):g[a.type](e,o)}},s))}};m(r,i,p),i.init&&i.init();var O={unmount:()=>{i.destroy&&i.destroy.call(i);for(var e=p.length;e--;)p[e]();for(var t in u)r.removeEventListener(t,d,!!l[t]);if(i._c)for(var t in i._c)v(i._c[t].r);r._m=null}};return r._m=O,O}},_=e=>{if(!e||"object"!=typeof e||e instanceof Node||e instanceof Date||e instanceof RegExp)return e;var t=e._t||e;if(Array.isArray(t))return t.map(e=>_(e));var r={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&36!==a.charCodeAt(0)&&95!==a.charCodeAt(0)&&(r[a]=_(t[a]));return r};return{data:(e,...r)=>{t[e]=1===r.length?r[0]:()=>{for(var e={},t=0;t<r.length;t++)Object.defineProperties(e,Object.getOwnPropertyDescriptors(r[t]()));return e}},start:()=>{for(var e=document.querySelectorAll("[s-data]"),t=0;t<e.length;t++)b(e[t])},store:(t,r)=>{if(void 0===r)return e[t];e[t]=r;var a=e[t];return a&&"function"==typeof a.init&&a.init.call(a),a},raw:_,mount:e=>b(e),unmount:e=>{e&&e._m&&e._m.unmount()}}})();export default spiki;
1
+ var spiki=(()=>{var e,t=Object.create(null),r=[],a=!1,n=null,o=!1,l=Promise.resolve(),i={blur:1,focus:1,scroll:1,load:1,error:1,mouseenter:1,mouseleave:1,toggle:1},s=e=>{e._q||(e._q=!0,r.push(e),a||(a=!0,l.then(()=>{var e=r;r=[],a=!1;for(var t=0;t<e.length;t++)e[t]._q=!1,e[t]()})))},c=(e,t)=>{var r,a=e;if("string"==typeof t)r=e?e[t]:void 0;else{for(var n=0,o=t.length;n<o-1&&a;)a=a[t[n++]];r=a?a[t[o-1]]:void 0}if(void 0===r){var l=Array.isArray(t)?t.join("."):t;console.warn("[spikijs] Property undefined: "+l)}return{ctx:a,val:r}},p={};["push","pop","shift","unshift","splice","sort","reverse"].forEach(e=>{p[e]=function(...t){o=!0;try{return Array.prototype[e].apply(this,t)}finally{o=!1,u(this,"length")}}});var f=(e,t)=>{if(n){var r=e._d||(Object.defineProperty(e,"_d",{value:Object.create(null),writable:!0}),e._d),a=r[t]||(r[t]=[]);-1===a.indexOf(n)&&(a.push(n),n.deps.push(a))}},u=(e,t)=>{if(!o&&e._d&&e._d[t])for(var r=e._d[t].slice(),a=0,l=r.length;a<l;a++){var i=r[a];i!==n&&(i.sched?i.sched(i):i())}},v=e=>{for(var t=e.deps.length;t--;){var r=e.deps[t],a=r.indexOf(e);-1!==a&&(r[a]=r[r.length-1],r.pop())}e.deps=[]},d=(e,t)=>{var r=()=>{v(r);var t=n;n=r;try{e()}finally{n=t}};return r.deps=[],r.sched=t,r(),()=>v(r)},h=e=>e&&"object"==typeof e&&!e._y&&!(e instanceof Node)&&!(e instanceof Date)&&!(e instanceof RegExp)&&!(e instanceof Map)&&!(e instanceof Set)&&!(e instanceof Promise),y=e=>{if(!h(e))return e;if(Object.prototype.hasOwnProperty.call(e,"_p"))return e._p;var t=new Proxy(e,{get:(e,t,r)=>{if("_y"===t)return r===e._p;if("_t"===t)return e;if("_d"===t)return e._d;if("_i"===t)return e._i;if("_c"===t)return e._c;if(Array.isArray(e)&&p.hasOwnProperty(t))return p[t];var a=Object.getOwnPropertyDescriptor(e,t);if(a&&a.get){var o=e._c||(Object.defineProperty(e,"_c",{value:Object.create(null)}),e._c),l=o[t];if(!l){var i=()=>{v(i);var t=n;n=i;try{l.d=!1,l.v=a.get.call(e._p)}finally{n=t}};i.deps=[],i.sched=()=>{l.d||(l.d=!0,u(e,t))},l=o[t]={r:i,d:!0,v:void 0}}return l.d&&l.r(),f(e,t),h(l.v)?y(l.v):l.v}Object.prototype.hasOwnProperty.call(e,t)&&f(e,Array.isArray(e)?"length":t);var s=Reflect.get(e,t,r);return h(s)?y(s):s},set:(e,t,r,a)=>{var n=e[t],l=Array.isArray(e),i=l?"length"===t||Number(t)<e.length:Object.prototype.hasOwnProperty.call(e,t);if(!l&&!i)for(var s=Object.getPrototypeOf(e);s&&s!==Object.prototype;){var c=s._t||s;if(Object.prototype.hasOwnProperty.call(c,t))return s[t]=r,!0;s=Object.getPrototypeOf(c)}var p=Reflect.set(e,t,r,a);return!o&&p&&(!i||r!==n||r&&"object"==typeof r)&&(u(e,t),l?u(e,"length"):i||u(e,"_k")),p},deleteProperty:(e,t)=>{var r=Object.prototype.hasOwnProperty.call(e,t),a=Reflect.deleteProperty(e,t);return a&&r&&(u(e,t),Array.isArray(e)?u(e,"length"):u(e,"_k")),a},ownKeys:e=>(f(e,"_k"),Reflect.ownKeys(e))});return Object.defineProperty(e,"_p",{value:t}),t};e=y({});var g=Object.create(null);g.text=(e,t)=>{t=null==t?"":t,e.textContent!==String(t)&&(e.textContent=t)},g.html=(e,t)=>{e.innerHTML!=t&&(e.innerHTML=null==t?"":t)},g.value=(e,t)=>{"checkbox"===e.type?e.checked=!!t:"radio"===e.type?e.checked=e.value==t:e.value!=t&&(e.value=null==t?"":t)},g.attr=(e,t,r)=>{if(null==t||!1===t)e.removeAttribute(r);else{var a=!0===t?"":String(t);e.getAttribute(r)!==a&&e.setAttribute(r,a)}},g.class=(e,t)=>{var r=e._n||"",a=Object.create(null);if(r.split(/\s+/).forEach(e=>e&&(a[e]=1)),"string"==typeof t)t.split(/\s+/).forEach(e=>e&&(a[e]=1));else if(t)for(var n in t)t[n]?a[n]=1:delete a[n];var o=Object.keys(a).join(" ");(e.getAttribute("class")||"")!==o&&e.setAttribute("class",o)};var b=(r,a)=>{if(r._m)return r._m;var n=r.getAttribute("s-data");if(t[n]){var o=t[n]();o.$refs={},o.$root=r,o.$store=e,o.$parent=a,a&&Object.setPrototypeOf(o,a);var l=y(o),p=[],u=Object.create(null),h=e=>{var t=e.target;if("input"!==e.type||!t._c)for(var a=r.parentNode,n=e.type;t&&t!==a&&!e.cancelBubble;){var o=t._h&&t._h[n];if(o){var i=t._s;if(!i||i.$root!==l.$root){t=t.parentNode;continue}for(var s=o.length;s--;){var p=o[s],f=p.p;if(p.model){var u="checkbox"===t.type?t.checked:t.value;if("number"===t.type||"range"===t.type)u=""===u?null:Number(u);else if("string"==typeof u){var v=u.trim();v&&v.length<16&&46!==v.charCodeAt(v.length-1)&&isFinite(v)&&(48===v.charCodeAt(0)&&1!==v.length&&46!==v.charCodeAt(1)||(u=Number(v)))}if("string"==typeof f)i&&(i[f]=u);else{for(var d=i,h=0,y=f.length-1;h<y&&d;)d=d[f[h++]];d&&(d[f[y]]=u)}}else{var g=c(i,f);"function"==typeof g.val&&(Object.defineProperty(e,"currentTarget",{configurable:!0,value:t}),g.val.call(g.ctx,e))}if(e.cancelBubble)break}}t=t.parentNode}},_=e=>{u[e]||(u[e]=!0,r.addEventListener(e,h,!!i[e]))},m=(e,t,a)=>{if(1===e.nodeType&&!e.hasAttribute("s-ignore"))if(e!==r&&e.hasAttribute("s-data")){var n=b(e,t);n&&a.push(n.unmount)}else{var o=e.getAttribute("s-if"),i=!o&&"TEMPLATE"===e.tagName&&e.getAttribute("s-for"),p=[];if(e.hasAttribute("class")&&!e._n&&(e._n=e.getAttribute("class")),o){var u=document.createTextNode(""),v=null,h=[];e.replaceWith(u);var O="!"===o[0],A=O?o.slice(1):o,j=-1===A.indexOf(".")?A:A.split(".");return a.push(()=>{for(var e=h.length;e--;)h[e]()}),a.push(d(()=>{var r=c(t,j).val;if(O&&(r=!r),r)v||((v=e.cloneNode(!0)).removeAttribute("s-if"),m(v,t,h),u.parentNode.insertBefore(v,u));else if(v){for(var a=h.length;a--;)h[a]();h=[],v.remove(),v=null}},s))}if(i){var x=i.indexOf(" in ");if(-1!==x){var P,N=i.slice(0,x).trim(),E=i.slice(x+4).trim(),k=N.replace(/[()]/g,"").split(","),w=k[0].trim(),C=k[1]?k[1].trim():null,T=-1===E.indexOf(".")?E:E.split("."),L=e.getAttribute("s-key"),S=L?-1===L.indexOf(".")?L:L.split("."):null,$=(u=document.createTextNode(""),Object.create(null));return e.replaceWith(u),a.push(()=>{for(var e in $)$[e].cleanups.forEach(e=>e())}),a.push(d(()=>{var r=c(t,T).val||[];"number"==typeof r&&(r=Array.from({length:Math.max(0,Math.floor(r))},(e,t)=>t+1)),Array.isArray(r)&&f(r,"length");var a=document.createDocumentFragment(),n=u.nextSibling;P=Object.create(null);for(var o=Array.isArray(r),l=o?r:Object.keys(r),i=o?r.length:l.length,s=0;s<i;s++){var p=o?s:l[s],v=o?r[s]:r[p],d=(S?c(v,S).val:null)??p;P[d]&&(d+="_"+s);var h=$[d];if(h)h.scope[w]=v,C&&(h.scope[C]=p);else{var g=e.content.cloneNode(!0),b=Object.create(t);Object.defineProperty(b,"_i",{value:!0});var _=y(b);_[w]=v,C&&(_[C]=p);for(var O=Array.prototype.slice.call(g.childNodes),A=[],j=0;j<O.length;j++)m(O[j],_,A);h={nodes:Array.prototype.slice.call(g.childNodes),scope:_,cleanups:A},$[d]=h}if(h.nodes[0]===n)a.childNodes.length&&u.parentNode&&u.parentNode.insertBefore(a,n),n=h.nodes[h.nodes.length-1].nextSibling;else for(j=0;j<h.nodes.length;j++)a.appendChild(h.nodes[j]);P[d]=!0}for(var x in a.childNodes.length&&u.parentNode&&u.parentNode.insertBefore(a,n),$)P[x]||($[x].cleanups.forEach(e=>e()),$[x].nodes.forEach(e=>e.remove()),delete $[x])},s))}}if(e.hasAttributes())for(var M=e.attributes,R=M.length;R--;){var B=M[R],D=B.name,q=B.value;if(58===D.charCodeAt(0)){var F=D.slice(1),H=33===q.charCodeAt(0),K=H?q.slice(1):q;j=-1===K.indexOf(".")?K:K.split(".");p.push({type:"attr",name:F,path:j,neg:H})}else if(115===D.charCodeAt(0)&&45===D.charCodeAt(1)){let r=D.slice(2);if("data"===r)continue;let n=-1===q.indexOf(".")?q:q.split(".");if("init"===r||"destroy"===r)((r,n)=>{var o=c(t,n);"function"==typeof o.val&&("init"===r?s(()=>{var t=o.val.call(o.ctx,e);"function"==typeof t&&a.push(t)}):a.push(()=>o.val.call(o.ctx,e)))})(r,n);else if("effect"===r)a.push(d(()=>{var r=c(t,n);"function"==typeof r.val&&r.val.call(r.ctx,e)},s));else if("model"===r){p.push({type:"value",path:n}),e._s=t,e._h=e._h||{};var W="checkbox"===e.type||"radio"===e.type||"SELECT"===e.tagName?"change":"input";"input"===W&&(e.addEventListener("compositionstart",()=>e._c=!0),e.addEventListener("compositionend",()=>{e._c=!1,e.dispatchEvent(new Event("input",{bubbles:!0}))})),(e._h[W]=e._h[W]||[]).push({model:!0,p:n}),_(W)}else"ref"===r?l.$refs[q]=e:g[r]?p.push({type:r,path:n}):(e._s=t,e._h=e._h||{},(e._h[r]=e._h[r]||[]).unshift({p:n}),_(r))}}for(var z=e.firstChild;z;){var G=z.nextSibling;m(z,t,a),z=G}p.length&&a.push(d(()=>{for(var r=p.length;r--;){var a=p[r],n=c(t,a.path),o="function"==typeof n.val?n.val.call(n.ctx,e):n.val;"attr"===a.type?(a.neg&&(o=!o),"class"===a.name?g.class(e,o):g.attr(e,o,a.name)):g[a.type](e,o)}},s))}};m(r,l,p),l.init&&l.init();var O={unmount:()=>{l.destroy&&l.destroy.call(l);for(var e=p.length;e--;)p[e]();for(var t in u)r.removeEventListener(t,h,!!i[t]);if(l._c)for(var t in l._c)v(l._c[t].r);r._m=null}};return r._m=O,O}},_=e=>{if(!e||"object"!=typeof e||e instanceof Node||e instanceof Date||e instanceof RegExp)return e;var t=e._t||e;if(Array.isArray(t))return t.map(e=>_(e));var r={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&36!==a.charCodeAt(0)&&95!==a.charCodeAt(0)&&(r[a]=_(t[a]));return r};return{data:(e,...r)=>{t[e]=1===r.length?r[0]:()=>{for(var e={},t=0;t<r.length;t++)Object.defineProperties(e,Object.getOwnPropertyDescriptors(r[t]()));return e}},start:()=>{for(var e=document.querySelectorAll("[s-data]"),t=0;t<e.length;t++)b(e[t])},store:(t,r)=>{if(void 0===r)return e[t];e[t]=r;var a=e[t];return a&&"function"==typeof a.init&&a.init.call(a),a},raw:_,mount:e=>b(e),unmount:e=>{e&&e._m&&e._m.unmount()}}})();export default spiki;
package/spiki.js CHANGED
@@ -196,9 +196,9 @@ var spiki = (() => {
196
196
  set: (target, key, val, receiver) => {
197
197
  var old = target[key];
198
198
  var isArr = Array.isArray(target);
199
- var hadKey = isArr ? Number(key) < target.length : Object.prototype.hasOwnProperty.call(target, key);
199
+ var hadKey = isArr ? (key === 'length' || Number(key) < target.length) : Object.prototype.hasOwnProperty.call(target, key);
200
200
 
201
- if (!hadKey) {
201
+ if (!isArr && !hadKey) {
202
202
  var proto = Object.getPrototypeOf(target);
203
203
  while (proto && proto !== Object.prototype) {
204
204
  var rawProto = proto._t || proto;
@@ -440,11 +440,7 @@ var spiki = (() => {
440
440
  for (var i = 0; i < len; i++) {
441
441
  var key = isArr ? i : keys[i];
442
442
  var item = isArr ? list[i] : list[key];
443
- var unique;
444
- if (item == null || typeof item !== 'object') unique = 'p_' + String(item);
445
- else if (keyPath) unique = 'k_' + evalPath(item, keyPath).val;
446
- else unique = 'i_' + String(key);
447
-
443
+ var unique = (keyPath ? evalPath(item, keyPath).val : null) ?? key;
448
444
  if (usedKeys[unique]) unique += '_' + i;
449
445
  var row = nodePool[unique];
450
446
  if (row) {
@@ -465,14 +461,14 @@ var spiki = (() => {
465
461
  nodePool[unique] = row;
466
462
  }
467
463
  if (row.nodes[0] === anchor) {
468
- if (frag.childNodes.length) end.parentNode.insertBefore(frag, anchor);
464
+ if (frag.childNodes.length && end.parentNode) end.parentNode.insertBefore(frag, anchor);
469
465
  anchor = row.nodes[row.nodes.length - 1].nextSibling;
470
466
  } else {
471
467
  for (var n = 0; n < row.nodes.length; n++) frag.appendChild(row.nodes[n]);
472
468
  }
473
469
  usedKeys[unique] = true;
474
470
  }
475
- if (frag.childNodes.length) end.parentNode.insertBefore(frag, anchor);
471
+ if (frag.childNodes.length && end.parentNode) end.parentNode.insertBefore(frag, anchor);
476
472
  for (var k in nodePool) if (!usedKeys[k]) {
477
473
  nodePool[k].cleanups.forEach(c => c());
478
474
  nodePool[k].nodes.forEach(n => n.remove());
package/spiki.min.js CHANGED
@@ -1 +1 @@
1
- !function(){"use strict";var e=(()=>{var e,t=Object.create(null),r=[],a=!1,n=null,o=!1,i=Promise.resolve(),l={blur:1,focus:1,scroll:1,load:1,error:1,mouseenter:1,mouseleave:1,toggle:1},s=e=>{e._q||(e._q=!0,r.push(e),a||(a=!0,i.then(()=>{var e=r;r=[],a=!1;for(var t=0;t<e.length;t++)e[t]._q=!1,e[t]()})))},c=(e,t)=>{var r,a=e;if("string"==typeof t)r=e?e[t]:void 0;else{for(var n=0,o=t.length;n<o-1&&a;)a=a[t[n++]];r=a?a[t[o-1]]:void 0}if(void 0===r){var i=Array.isArray(t)?t.join("."):t;console.warn("[spikijs] Property undefined: "+i)}return{ctx:a,val:r}},f={};["push","pop","shift","unshift","splice","sort","reverse"].forEach(e=>{f[e]=function(...t){o=!0;try{return Array.prototype[e].apply(this,t)}finally{o=!1,u(this,"length")}}});var p=(e,t)=>{if(n){var r=e._d||(Object.defineProperty(e,"_d",{value:Object.create(null),writable:!0}),e._d),a=r[t]||(r[t]=[]);-1===a.indexOf(n)&&(a.push(n),n.deps.push(a))}},u=(e,t)=>{if(!o&&e._d&&e._d[t])for(var r=e._d[t].slice(),a=0,i=r.length;a<i;a++){var l=r[a];l!==n&&(l.sched?l.sched(l):l())}},v=e=>{for(var t=e.deps.length;t--;){var r=e.deps[t],a=r.indexOf(e);-1!==a&&(r[a]=r[r.length-1],r.pop())}e.deps=[]},h=(e,t)=>{var r=()=>{v(r);var t=n;n=r;try{e()}finally{n=t}};return r.deps=[],r.sched=t,r(),()=>v(r)},d=e=>e&&"object"==typeof e&&!e._y&&!(e instanceof Node)&&!(e instanceof Date)&&!(e instanceof RegExp)&&!(e instanceof Map)&&!(e instanceof Set)&&!(e instanceof Promise),y=e=>{if(!d(e))return e;if(Object.prototype.hasOwnProperty.call(e,"_p"))return e._p;var t=new Proxy(e,{get:(e,t,r)=>{if("_y"===t)return r===e._p;if("_t"===t)return e;if("_d"===t)return e._d;if("_i"===t)return e._i;if("_c"===t)return e._c;if(Array.isArray(e)&&f.hasOwnProperty(t))return f[t];var a=Object.getOwnPropertyDescriptor(e,t);if(a&&a.get){var o=e._c||(Object.defineProperty(e,"_c",{value:Object.create(null)}),e._c),i=o[t];if(!i){var l=()=>{v(l);var t=n;n=l;try{i.d=!1,i.v=a.get.call(e._p)}finally{n=t}};l.deps=[],l.sched=()=>{i.d||(i.d=!0,u(e,t))},i=o[t]={r:l,d:!0,v:void 0}}return i.d&&i.r(),p(e,t),d(i.v)?y(i.v):i.v}Object.prototype.hasOwnProperty.call(e,t)&&p(e,Array.isArray(e)?"length":t);var s=Reflect.get(e,t,r);return d(s)?y(s):s},set:(e,t,r,a)=>{var n=e[t],i=Array.isArray(e),l=i?Number(t)<e.length:Object.prototype.hasOwnProperty.call(e,t);if(!l)for(var s=Object.getPrototypeOf(e);s&&s!==Object.prototype;){var c=s._t||s;if(Object.prototype.hasOwnProperty.call(c,t))return s[t]=r,!0;s=Object.getPrototypeOf(c)}var f=Reflect.set(e,t,r,a);return!o&&f&&(!l||r!==n||r&&"object"==typeof r)&&(u(e,t),i?u(e,"length"):l||u(e,"_k")),f},deleteProperty:(e,t)=>{var r=Object.prototype.hasOwnProperty.call(e,t),a=Reflect.deleteProperty(e,t);return a&&r&&(u(e,t),Array.isArray(e)?u(e,"length"):u(e,"_k")),a},ownKeys:e=>(p(e,"_k"),Reflect.ownKeys(e))});return Object.defineProperty(e,"_p",{value:t}),t};e=y({});var g=Object.create(null);g.text=(e,t)=>{t=null==t?"":t,e.textContent!==String(t)&&(e.textContent=t)},g.html=(e,t)=>{e.innerHTML!=t&&(e.innerHTML=null==t?"":t)},g.value=(e,t)=>{"checkbox"===e.type?e.checked=!!t:"radio"===e.type?e.checked=e.value==t:e.value!=t&&(e.value=null==t?"":t)},g.attr=(e,t,r)=>{if(null==t||!1===t)e.removeAttribute(r);else{var a=!0===t?"":String(t);e.getAttribute(r)!==a&&e.setAttribute(r,a)}},g.class=(e,t)=>{var r=e._n||"",a=Object.create(null);if(r.split(/\s+/).forEach(e=>e&&(a[e]=1)),"string"==typeof t)t.split(/\s+/).forEach(e=>e&&(a[e]=1));else if(t)for(var n in t)t[n]?a[n]=1:delete a[n];var o=Object.keys(a).join(" ");(e.getAttribute("class")||"")!==o&&e.setAttribute("class",o)};var b=(r,a)=>{if(r._m)return r._m;var n=r.getAttribute("s-data");if(t[n]){var o=t[n]();o.$refs={},o.$root=r,o.$store=e,o.$parent=a,a&&Object.setPrototypeOf(o,a);var i=y(o),f=[],u=Object.create(null),d=e=>{var t=e.target;if("input"!==e.type||!t._c)for(var a=r.parentNode,n=e.type;t&&t!==a&&!e.cancelBubble;){var o=t._h&&t._h[n];if(o){var l=t._s;if(!l||l.$root!==i.$root){t=t.parentNode;continue}for(var s=o.length;s--;){var f=o[s],p=f.p;if(f.model){var u="checkbox"===t.type?t.checked:t.value;if("number"===t.type||"range"===t.type)u=""===u?null:Number(u);else if("string"==typeof u){var v=u.trim();v&&v.length<16&&46!==v.charCodeAt(v.length-1)&&isFinite(v)&&(48===v.charCodeAt(0)&&1!==v.length&&46!==v.charCodeAt(1)||(u=Number(v)))}if("string"==typeof p)l&&(l[p]=u);else{for(var h=l,d=0,y=p.length-1;d<y&&h;)h=h[p[d++]];h&&(h[p[y]]=u)}}else{var g=c(l,p);"function"==typeof g.val&&(Object.defineProperty(e,"currentTarget",{configurable:!0,value:t}),g.val.call(g.ctx,e))}if(e.cancelBubble)break}}t=t.parentNode}},_=e=>{u[e]||(u[e]=!0,r.addEventListener(e,d,!!l[e]))},m=(e,t,a)=>{if(1===e.nodeType&&!e.hasAttribute("s-ignore"))if(e!==r&&e.hasAttribute("s-data")){var n=b(e,t);n&&a.push(n.unmount)}else{var o=e.getAttribute("s-if"),l=!o&&"TEMPLATE"===e.tagName&&e.getAttribute("s-for"),f=[];if(e.hasAttribute("class")&&!e._n&&(e._n=e.getAttribute("class")),o){var u=document.createTextNode(""),v=null,d=[];e.replaceWith(u);var O="!"===o[0],A=O?o.slice(1):o,j=-1===A.indexOf(".")?A:A.split(".");return a.push(()=>{for(var e=d.length;e--;)d[e]()}),a.push(h(()=>{var r=c(t,j).val;if(O&&(r=!r),r)v||((v=e.cloneNode(!0)).removeAttribute("s-if"),m(v,t,d),u.parentNode.insertBefore(v,u));else if(v){for(var a=d.length;a--;)d[a]();d=[],v.remove(),v=null}},s))}if(l){var x=l.indexOf(" in ");if(-1!==x){var P,N=l.slice(0,x).trim(),w=l.slice(x+4).trim(),E=N.replace(/[()]/g,"").split(","),k=E[0].trim(),C=E[1]?E[1].trim():null,S=-1===w.indexOf(".")?w:w.split("."),T=e.getAttribute("s-key"),L=T?-1===T.indexOf(".")?T:T.split("."):null,$=(u=document.createTextNode(""),Object.create(null));return e.replaceWith(u),a.push(()=>{for(var e in $)$[e].cleanups.forEach(e=>e())}),a.push(h(()=>{var r=c(t,S).val||[];"number"==typeof r&&(r=Array.from({length:Math.max(0,Math.floor(r))},(e,t)=>t+1)),Array.isArray(r)&&p(r,"length");var a=document.createDocumentFragment(),n=u.nextSibling;P=Object.create(null);for(var o=Array.isArray(r),i=o?r:Object.keys(r),l=o?r.length:i.length,s=0;s<l;s++){var f,v=o?s:i[s],h=o?r[s]:r[v];f=null==h||"object"!=typeof h?"p_"+String(h):L?"k_"+c(h,L).val:"i_"+String(v),P[f]&&(f+="_"+s);var d=$[f];if(d)d.scope[k]=h,C&&(d.scope[C]=v);else{var g=e.content.cloneNode(!0),b=Object.create(t);Object.defineProperty(b,"_i",{value:!0});var _=y(b);_[k]=h,C&&(_[C]=v);for(var O=Array.prototype.slice.call(g.childNodes),A=[],j=0;j<O.length;j++)m(O[j],_,A);d={nodes:Array.prototype.slice.call(g.childNodes),scope:_,cleanups:A},$[f]=d}if(d.nodes[0]===n)a.childNodes.length&&u.parentNode.insertBefore(a,n),n=d.nodes[d.nodes.length-1].nextSibling;else for(j=0;j<d.nodes.length;j++)a.appendChild(d.nodes[j]);P[f]=!0}for(var x in a.childNodes.length&&u.parentNode.insertBefore(a,n),$)P[x]||($[x].cleanups.forEach(e=>e()),$[x].nodes.forEach(e=>e.remove()),delete $[x])},s))}}if(e.hasAttributes())for(var M=e.attributes,R=M.length;R--;){var B=M[R],D=B.name,q=B.value;if(58===D.charCodeAt(0)){var F=D.slice(1),H=33===q.charCodeAt(0),K=H?q.slice(1):q;j=-1===K.indexOf(".")?K:K.split(".");f.push({type:"attr",name:F,path:j,neg:H})}else if(115===D.charCodeAt(0)&&45===D.charCodeAt(1)){let r=D.slice(2);if("data"===r)continue;let n=-1===q.indexOf(".")?q:q.split(".");if("init"===r||"destroy"===r)((r,n)=>{var o=c(t,n);"function"==typeof o.val&&("init"===r?s(()=>{var t=o.val.call(o.ctx,e);"function"==typeof t&&a.push(t)}):a.push(()=>o.val.call(o.ctx,e)))})(r,n);else if("effect"===r)a.push(h(()=>{var r=c(t,n);"function"==typeof r.val&&r.val.call(r.ctx,e)},s));else if("model"===r){f.push({type:"value",path:n}),e._s=t,e._h=e._h||{};var W="checkbox"===e.type||"radio"===e.type||"SELECT"===e.tagName?"change":"input";"input"===W&&(e.addEventListener("compositionstart",()=>e._c=!0),e.addEventListener("compositionend",()=>{e._c=!1,e.dispatchEvent(new Event("input",{bubbles:!0}))})),(e._h[W]=e._h[W]||[]).push({model:!0,p:n}),_(W)}else"ref"===r?i.$refs[q]=e:g[r]?f.push({type:r,path:n}):(e._s=t,e._h=e._h||{},(e._h[r]=e._h[r]||[]).unshift({p:n}),_(r))}}for(var z=e.firstChild;z;){var G=z.nextSibling;m(z,t,a),z=G}f.length&&a.push(h(()=>{for(var r=f.length;r--;){var a=f[r],n=c(t,a.path),o="function"==typeof n.val?n.val.call(n.ctx,e):n.val;"attr"===a.type?(a.neg&&(o=!o),"class"===a.name?g.class(e,o):g.attr(e,o,a.name)):g[a.type](e,o)}},s))}};m(r,i,f),i.init&&i.init();var O={unmount:()=>{i.destroy&&i.destroy.call(i);for(var e=f.length;e--;)f[e]();for(var t in u)r.removeEventListener(t,d,!!l[t]);if(i._c)for(var t in i._c)v(i._c[t].r);r._m=null}};return r._m=O,O}},_=e=>{if(!e||"object"!=typeof e||e instanceof Node||e instanceof Date||e instanceof RegExp)return e;var t=e._t||e;if(Array.isArray(t))return t.map(e=>_(e));var r={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&36!==a.charCodeAt(0)&&95!==a.charCodeAt(0)&&(r[a]=_(t[a]));return r};return{data:(e,...r)=>{t[e]=1===r.length?r[0]:()=>{for(var e={},t=0;t<r.length;t++)Object.defineProperties(e,Object.getOwnPropertyDescriptors(r[t]()));return e}},start:()=>{for(var e=document.querySelectorAll("[s-data]"),t=0;t<e.length;t++)b(e[t])},store:(t,r)=>{if(void 0===r)return e[t];e[t]=r;var a=e[t];return a&&"function"==typeof a.init&&a.init.call(a),a},raw:_,mount:e=>b(e),unmount:e=>{e&&e._m&&e._m.unmount()}}})();window.spiki=e}();
1
+ !function(){"use strict";var e=(()=>{var e,t=Object.create(null),r=[],a=!1,n=null,o=!1,l=Promise.resolve(),i={blur:1,focus:1,scroll:1,load:1,error:1,mouseenter:1,mouseleave:1,toggle:1},s=e=>{e._q||(e._q=!0,r.push(e),a||(a=!0,l.then(()=>{var e=r;r=[],a=!1;for(var t=0;t<e.length;t++)e[t]._q=!1,e[t]()})))},c=(e,t)=>{var r,a=e;if("string"==typeof t)r=e?e[t]:void 0;else{for(var n=0,o=t.length;n<o-1&&a;)a=a[t[n++]];r=a?a[t[o-1]]:void 0}if(void 0===r){var l=Array.isArray(t)?t.join("."):t;console.warn("[spikijs] Property undefined: "+l)}return{ctx:a,val:r}},f={};["push","pop","shift","unshift","splice","sort","reverse"].forEach(e=>{f[e]=function(...t){o=!0;try{return Array.prototype[e].apply(this,t)}finally{o=!1,u(this,"length")}}});var p=(e,t)=>{if(n){var r=e._d||(Object.defineProperty(e,"_d",{value:Object.create(null),writable:!0}),e._d),a=r[t]||(r[t]=[]);-1===a.indexOf(n)&&(a.push(n),n.deps.push(a))}},u=(e,t)=>{if(!o&&e._d&&e._d[t])for(var r=e._d[t].slice(),a=0,l=r.length;a<l;a++){var i=r[a];i!==n&&(i.sched?i.sched(i):i())}},v=e=>{for(var t=e.deps.length;t--;){var r=e.deps[t],a=r.indexOf(e);-1!==a&&(r[a]=r[r.length-1],r.pop())}e.deps=[]},d=(e,t)=>{var r=()=>{v(r);var t=n;n=r;try{e()}finally{n=t}};return r.deps=[],r.sched=t,r(),()=>v(r)},h=e=>e&&"object"==typeof e&&!e._y&&!(e instanceof Node)&&!(e instanceof Date)&&!(e instanceof RegExp)&&!(e instanceof Map)&&!(e instanceof Set)&&!(e instanceof Promise),y=e=>{if(!h(e))return e;if(Object.prototype.hasOwnProperty.call(e,"_p"))return e._p;var t=new Proxy(e,{get:(e,t,r)=>{if("_y"===t)return r===e._p;if("_t"===t)return e;if("_d"===t)return e._d;if("_i"===t)return e._i;if("_c"===t)return e._c;if(Array.isArray(e)&&f.hasOwnProperty(t))return f[t];var a=Object.getOwnPropertyDescriptor(e,t);if(a&&a.get){var o=e._c||(Object.defineProperty(e,"_c",{value:Object.create(null)}),e._c),l=o[t];if(!l){var i=()=>{v(i);var t=n;n=i;try{l.d=!1,l.v=a.get.call(e._p)}finally{n=t}};i.deps=[],i.sched=()=>{l.d||(l.d=!0,u(e,t))},l=o[t]={r:i,d:!0,v:void 0}}return l.d&&l.r(),p(e,t),h(l.v)?y(l.v):l.v}Object.prototype.hasOwnProperty.call(e,t)&&p(e,Array.isArray(e)?"length":t);var s=Reflect.get(e,t,r);return h(s)?y(s):s},set:(e,t,r,a)=>{var n=e[t],l=Array.isArray(e),i=l?"length"===t||Number(t)<e.length:Object.prototype.hasOwnProperty.call(e,t);if(!l&&!i)for(var s=Object.getPrototypeOf(e);s&&s!==Object.prototype;){var c=s._t||s;if(Object.prototype.hasOwnProperty.call(c,t))return s[t]=r,!0;s=Object.getPrototypeOf(c)}var f=Reflect.set(e,t,r,a);return!o&&f&&(!i||r!==n||r&&"object"==typeof r)&&(u(e,t),l?u(e,"length"):i||u(e,"_k")),f},deleteProperty:(e,t)=>{var r=Object.prototype.hasOwnProperty.call(e,t),a=Reflect.deleteProperty(e,t);return a&&r&&(u(e,t),Array.isArray(e)?u(e,"length"):u(e,"_k")),a},ownKeys:e=>(p(e,"_k"),Reflect.ownKeys(e))});return Object.defineProperty(e,"_p",{value:t}),t};e=y({});var g=Object.create(null);g.text=(e,t)=>{t=null==t?"":t,e.textContent!==String(t)&&(e.textContent=t)},g.html=(e,t)=>{e.innerHTML!=t&&(e.innerHTML=null==t?"":t)},g.value=(e,t)=>{"checkbox"===e.type?e.checked=!!t:"radio"===e.type?e.checked=e.value==t:e.value!=t&&(e.value=null==t?"":t)},g.attr=(e,t,r)=>{if(null==t||!1===t)e.removeAttribute(r);else{var a=!0===t?"":String(t);e.getAttribute(r)!==a&&e.setAttribute(r,a)}},g.class=(e,t)=>{var r=e._n||"",a=Object.create(null);if(r.split(/\s+/).forEach(e=>e&&(a[e]=1)),"string"==typeof t)t.split(/\s+/).forEach(e=>e&&(a[e]=1));else if(t)for(var n in t)t[n]?a[n]=1:delete a[n];var o=Object.keys(a).join(" ");(e.getAttribute("class")||"")!==o&&e.setAttribute("class",o)};var b=(r,a)=>{if(r._m)return r._m;var n=r.getAttribute("s-data");if(t[n]){var o=t[n]();o.$refs={},o.$root=r,o.$store=e,o.$parent=a,a&&Object.setPrototypeOf(o,a);var l=y(o),f=[],u=Object.create(null),h=e=>{var t=e.target;if("input"!==e.type||!t._c)for(var a=r.parentNode,n=e.type;t&&t!==a&&!e.cancelBubble;){var o=t._h&&t._h[n];if(o){var i=t._s;if(!i||i.$root!==l.$root){t=t.parentNode;continue}for(var s=o.length;s--;){var f=o[s],p=f.p;if(f.model){var u="checkbox"===t.type?t.checked:t.value;if("number"===t.type||"range"===t.type)u=""===u?null:Number(u);else if("string"==typeof u){var v=u.trim();v&&v.length<16&&46!==v.charCodeAt(v.length-1)&&isFinite(v)&&(48===v.charCodeAt(0)&&1!==v.length&&46!==v.charCodeAt(1)||(u=Number(v)))}if("string"==typeof p)i&&(i[p]=u);else{for(var d=i,h=0,y=p.length-1;h<y&&d;)d=d[p[h++]];d&&(d[p[y]]=u)}}else{var g=c(i,p);"function"==typeof g.val&&(Object.defineProperty(e,"currentTarget",{configurable:!0,value:t}),g.val.call(g.ctx,e))}if(e.cancelBubble)break}}t=t.parentNode}},_=e=>{u[e]||(u[e]=!0,r.addEventListener(e,h,!!i[e]))},m=(e,t,a)=>{if(1===e.nodeType&&!e.hasAttribute("s-ignore"))if(e!==r&&e.hasAttribute("s-data")){var n=b(e,t);n&&a.push(n.unmount)}else{var o=e.getAttribute("s-if"),i=!o&&"TEMPLATE"===e.tagName&&e.getAttribute("s-for"),f=[];if(e.hasAttribute("class")&&!e._n&&(e._n=e.getAttribute("class")),o){var u=document.createTextNode(""),v=null,h=[];e.replaceWith(u);var O="!"===o[0],A=O?o.slice(1):o,j=-1===A.indexOf(".")?A:A.split(".");return a.push(()=>{for(var e=h.length;e--;)h[e]()}),a.push(d(()=>{var r=c(t,j).val;if(O&&(r=!r),r)v||((v=e.cloneNode(!0)).removeAttribute("s-if"),m(v,t,h),u.parentNode.insertBefore(v,u));else if(v){for(var a=h.length;a--;)h[a]();h=[],v.remove(),v=null}},s))}if(i){var x=i.indexOf(" in ");if(-1!==x){var P,N=i.slice(0,x).trim(),w=i.slice(x+4).trim(),E=N.replace(/[()]/g,"").split(","),k=E[0].trim(),C=E[1]?E[1].trim():null,T=-1===w.indexOf(".")?w:w.split("."),L=e.getAttribute("s-key"),S=L?-1===L.indexOf(".")?L:L.split("."):null,$=(u=document.createTextNode(""),Object.create(null));return e.replaceWith(u),a.push(()=>{for(var e in $)$[e].cleanups.forEach(e=>e())}),a.push(d(()=>{var r=c(t,T).val||[];"number"==typeof r&&(r=Array.from({length:Math.max(0,Math.floor(r))},(e,t)=>t+1)),Array.isArray(r)&&p(r,"length");var a=document.createDocumentFragment(),n=u.nextSibling;P=Object.create(null);for(var o=Array.isArray(r),l=o?r:Object.keys(r),i=o?r.length:l.length,s=0;s<i;s++){var f=o?s:l[s],v=o?r[s]:r[f],d=(S?c(v,S).val:null)??f;P[d]&&(d+="_"+s);var h=$[d];if(h)h.scope[k]=v,C&&(h.scope[C]=f);else{var g=e.content.cloneNode(!0),b=Object.create(t);Object.defineProperty(b,"_i",{value:!0});var _=y(b);_[k]=v,C&&(_[C]=f);for(var O=Array.prototype.slice.call(g.childNodes),A=[],j=0;j<O.length;j++)m(O[j],_,A);h={nodes:Array.prototype.slice.call(g.childNodes),scope:_,cleanups:A},$[d]=h}if(h.nodes[0]===n)a.childNodes.length&&u.parentNode&&u.parentNode.insertBefore(a,n),n=h.nodes[h.nodes.length-1].nextSibling;else for(j=0;j<h.nodes.length;j++)a.appendChild(h.nodes[j]);P[d]=!0}for(var x in a.childNodes.length&&u.parentNode&&u.parentNode.insertBefore(a,n),$)P[x]||($[x].cleanups.forEach(e=>e()),$[x].nodes.forEach(e=>e.remove()),delete $[x])},s))}}if(e.hasAttributes())for(var M=e.attributes,R=M.length;R--;){var B=M[R],D=B.name,q=B.value;if(58===D.charCodeAt(0)){var F=D.slice(1),H=33===q.charCodeAt(0),K=H?q.slice(1):q;j=-1===K.indexOf(".")?K:K.split(".");f.push({type:"attr",name:F,path:j,neg:H})}else if(115===D.charCodeAt(0)&&45===D.charCodeAt(1)){let r=D.slice(2);if("data"===r)continue;let n=-1===q.indexOf(".")?q:q.split(".");if("init"===r||"destroy"===r)((r,n)=>{var o=c(t,n);"function"==typeof o.val&&("init"===r?s(()=>{var t=o.val.call(o.ctx,e);"function"==typeof t&&a.push(t)}):a.push(()=>o.val.call(o.ctx,e)))})(r,n);else if("effect"===r)a.push(d(()=>{var r=c(t,n);"function"==typeof r.val&&r.val.call(r.ctx,e)},s));else if("model"===r){f.push({type:"value",path:n}),e._s=t,e._h=e._h||{};var W="checkbox"===e.type||"radio"===e.type||"SELECT"===e.tagName?"change":"input";"input"===W&&(e.addEventListener("compositionstart",()=>e._c=!0),e.addEventListener("compositionend",()=>{e._c=!1,e.dispatchEvent(new Event("input",{bubbles:!0}))})),(e._h[W]=e._h[W]||[]).push({model:!0,p:n}),_(W)}else"ref"===r?l.$refs[q]=e:g[r]?f.push({type:r,path:n}):(e._s=t,e._h=e._h||{},(e._h[r]=e._h[r]||[]).unshift({p:n}),_(r))}}for(var z=e.firstChild;z;){var G=z.nextSibling;m(z,t,a),z=G}f.length&&a.push(d(()=>{for(var r=f.length;r--;){var a=f[r],n=c(t,a.path),o="function"==typeof n.val?n.val.call(n.ctx,e):n.val;"attr"===a.type?(a.neg&&(o=!o),"class"===a.name?g.class(e,o):g.attr(e,o,a.name)):g[a.type](e,o)}},s))}};m(r,l,f),l.init&&l.init();var O={unmount:()=>{l.destroy&&l.destroy.call(l);for(var e=f.length;e--;)f[e]();for(var t in u)r.removeEventListener(t,h,!!i[t]);if(l._c)for(var t in l._c)v(l._c[t].r);r._m=null}};return r._m=O,O}},_=e=>{if(!e||"object"!=typeof e||e instanceof Node||e instanceof Date||e instanceof RegExp)return e;var t=e._t||e;if(Array.isArray(t))return t.map(e=>_(e));var r={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&36!==a.charCodeAt(0)&&95!==a.charCodeAt(0)&&(r[a]=_(t[a]));return r};return{data:(e,...r)=>{t[e]=1===r.length?r[0]:()=>{for(var e={},t=0;t<r.length;t++)Object.defineProperties(e,Object.getOwnPropertyDescriptors(r[t]()));return e}},start:()=>{for(var e=document.querySelectorAll("[s-data]"),t=0;t<e.length;t++)b(e[t])},store:(t,r)=>{if(void 0===r)return e[t];e[t]=r;var a=e[t];return a&&"function"==typeof a.init&&a.init.call(a),a},raw:_,mount:e=>b(e),unmount:e=>{e&&e._m&&e._m.unmount()}}})();window.spiki=e}();