ajo 0.0.19 → 0.0.21

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/index.cjs CHANGED
@@ -33,10 +33,12 @@ __export(ajo_exports, {
33
33
  stx: () => stx
34
34
  });
35
35
  module.exports = __toCommonJS(ajo_exports);
36
- const Fragment = ({ children }) => children, For = ({ is, each, by, children, ref, ...props }) => h(is ?? "div", {
36
+ const Fragment = ({ children }) => children, For = ({ is, key, block, each, by, children, ref, ...props }) => h(is ?? "div", {
37
37
  ...props,
38
+ key,
39
+ block,
38
40
  skip: true,
39
- ref: (host) => iterate(host, each, by, children, ref)
41
+ ref: iterate.bind(null, each, by, children, ref)
40
42
  }), h = (nodeName, props, ...children) => {
41
43
  const { length } = children;
42
44
  children = length == 0 ? null : length == 1 ? children[0] : children;
@@ -66,14 +68,16 @@ const Fragment = ({ children }) => children, For = ({ is, each, by, children, re
66
68
  }
67
69
  while (child) {
68
70
  const next = child.nextSibling;
69
- host.removeChild(child);
71
+ dispose(host.removeChild(child));
70
72
  child = next;
71
73
  }
72
- }, component = (setup) => ({ is, props, ref, ...params }) => h(is ?? setup.is ?? "div", {
74
+ }, component = (setup) => ({ is, props, key, block, ref, ...params }) => h(is ?? setup.is ?? "div", {
73
75
  ...setup.props,
74
76
  ...props,
77
+ key,
78
+ block,
75
79
  skip: true,
76
- ref: (host) => run(host, setup, params, ref)
80
+ ref: run.bind(null, setup, params, ref)
77
81
  }), refresh = (host) => {
78
82
  try {
79
83
  render((host.$render ??= host.$setup(host))(host.$params), host);
@@ -92,21 +96,16 @@ const Fragment = ({ children }) => children, For = ({ is, each, by, children, re
92
96
  throw error;
93
97
  }, cleanup = (host, fn) => isFunction(fn) && (host.$cleanups ??= /* @__PURE__ */ new Set()).add(fn), clx = (o) => keys(o).filter((k) => o[k]).join(" ") || null, stx = (o) => entries(o).map((t) => t.join(":")).join(";") || null, keb = (o) => keys(o).reduce((r, k) => (r[k.replace(search, replace).toLowerCase()] = o[k], r), {});
94
98
  const { isArray, from } = Array, { keys, entries } = Object, isFunction = (v) => typeof v == "function", noop = () => {
95
- }, on = (host, type, v) => {
96
- let fn, map2;
97
- if (fn = (map2 = host.$on ??= {})[type]) {
98
- host.removeEventListener(type, fn, fn.options), map2[type] = null;
99
- }
100
- if (typeof (fn = (v = isArray(v) ? v : [v])[0]) == "function") {
101
- host.addEventListener(type, fn = map2[type] = fn.bind(null, v[1]), fn.options = v[2]);
102
- }
103
99
  }, map = (list) => list.reduce(set, /* @__PURE__ */ new Map()), set = (m, v, i) => (m.set(v, i), m), some = (a, b) => isArray(a) && isArray(b) ? a.some((v, i) => v !== b[i]) : a !== b, reduce = (v) => from(v).reduce(assign, {}), assign = (v, { name, value }) => (v[name] = value, v), create = (ns, name, key) => {
104
100
  const node = ns ? document.createElementNS(ns, name) : document.createElement(name);
105
101
  return node.$key = key, node;
106
102
  }, proxy = { firstChild: null, insertBefore: (node) => proxy.firstChild ??= node }, handler = {
107
103
  get(target, key) {
108
- const value = key == "nextSibling" ? null : target[key];
104
+ const value = key == "nextSibling" ? null : Reflect.get(target, key);
109
105
  return isFunction(value) ? value.bind(target) : value;
106
+ },
107
+ set(target, key, value) {
108
+ return Reflect.set(target, key, value);
110
109
  }
111
110
  }, search = /([a-z0-9])([A-Z])/g, replace = "$1-$2", normalize = function* (h2, buffer = { t: "" }, root = true) {
112
111
  let t;
@@ -125,9 +124,7 @@ const { isArray, from } = Array, { keys, entries } = Object, isFunction = (v) =>
125
124
  const prev = host.$props ??= host.hasAttributes() ? reduce(host.attributes) : {};
126
125
  for (const name in { ...prev, ...host.$props = props }) {
127
126
  let value = props[name];
128
- if (name.startsWith("on:")) {
129
- some(value, prev[name]) && on(host, name.slice(3), value);
130
- } else if (value !== prev[name])
127
+ if (value !== prev[name])
131
128
  if (name.startsWith("set:"))
132
129
  host[name.slice(4)] = value;
133
130
  else if (value == null || value === false)
@@ -145,17 +142,20 @@ const { isArray, from } = Array, { keys, entries } = Object, isFunction = (v) =>
145
142
  }
146
143
  } else
147
144
  host.insertBefore(node, child);
148
- }, iterate = (host, each, by, fn, ref) => {
145
+ }, iterate = (each, by, fn, ref, host) => {
149
146
  each = isArray(each) ? each : [];
150
147
  by = isFunction(by) ? by : (v) => v;
151
148
  fn = isFunction(fn) ? fn : noop;
152
- const map2 = host.$for ??= /* @__PURE__ */ new Map(), del = (node) => map2.delete(node.$by), clr = each !== host.$each, len = (host.$each = each).length, a = from(host.childNodes), b = new Array(len);
149
+ const map2 = host.$for ??= /* @__PURE__ */ new Map(), del = (node) => {
150
+ map2.delete(node.$by);
151
+ dispose(node);
152
+ }, clr = each !== host.$each, len = (host.$each = each).length, a = from(host.childNodes), b = new Array(len);
153
153
  clr && map2.clear();
154
154
  for (let child, index = 0; index < len; index++) {
155
155
  const item = each[index], key = by(item, index);
156
156
  child = clr ? a[index] : map2.get(key);
157
157
  proxy.firstChild = child ? new Proxy(child, handler) : null;
158
- render(fn(item), proxy);
158
+ render(fn(item, index), proxy);
159
159
  child ??= proxy.firstChild;
160
160
  proxy.firstChild = null;
161
161
  map2.set(child.$by = key, b[index] = child);
@@ -166,8 +166,7 @@ const { isArray, from } = Array, { keys, entries } = Object, isFunction = (v) =>
166
166
  const aLen = a.length, bLen = b.length;
167
167
  let aIndex = 0, bIndex = 0, aValue, bValue, aMap, bMap, i;
168
168
  while (aIndex !== aLen || bIndex !== bLen) {
169
- aValue = a[aIndex];
170
- bValue = b[bIndex];
169
+ aValue = a[aIndex], bValue = b[bIndex];
171
170
  if (aValue === null)
172
171
  aIndex++;
173
172
  else if (bLen <= bIndex)
@@ -177,8 +176,7 @@ const { isArray, from } = Array, { keys, entries } = Object, isFunction = (v) =>
177
176
  else if (aValue === bValue)
178
177
  aIndex++, bIndex++;
179
178
  else {
180
- aMap ??= map(a);
181
- bMap ??= map(b);
179
+ aMap ??= map(a), bMap ??= map(b);
182
180
  if (bMap.get(aValue) == null)
183
181
  aIndex++, dispose2(host.removeChild(aValue));
184
182
  else {
@@ -191,22 +189,19 @@ const { isArray, from } = Array, { keys, entries } = Object, isFunction = (v) =>
191
189
  }
192
190
  }
193
191
  }
194
- }, run = (host, setup, params, ref) => {
195
- host.$setup ??= (host.addEventListener("DOMNodeRemovedFromDocument", dispose), isFunction(setup) ? setup : noop);
192
+ }, run = (setup, params, ref, host) => {
193
+ host.$setup ??= isFunction(setup) ? setup : noop;
196
194
  host.$params = { ...setup.params, ...params };
197
195
  refresh(host);
198
196
  isFunction(ref) && ref(host);
199
- }, dispose = ({ target }) => {
200
- (globalThis.queueMicrotask ?? ((v) => v()))(() => {
201
- if (document.contains(target))
202
- return;
203
- if ("$cleanups" in target) {
204
- try {
205
- for (const fn of target.$cleanups)
206
- fn(target);
207
- } finally {
208
- target.$cleanups.clear();
209
- }
197
+ }, dispose = (host) => {
198
+ if (host.nodeType != 1)
199
+ return;
200
+ for (const child of host.children)
201
+ dispose(child);
202
+ if ("$cleanups" in host)
203
+ for (const fn of host.$cleanups) {
204
+ host.$cleanups.delete(fn);
205
+ fn(host);
210
206
  }
211
- });
212
207
  };
package/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  export const
2
2
  Fragment = ({ children }) => children,
3
3
 
4
- For = ({ is, each, by, children, ref, ...props }) => h(is ?? 'div', {
5
- ...props, skip: true, ref: host => iterate(host, each, by, children, ref)
4
+ For = ({ is, key, block, each, by, children, ref, ...props }) => h(is ?? 'div', {
5
+ ...props, key, block, skip: true, ref: iterate.bind(null, each, by, children, ref)
6
6
  }),
7
7
 
8
8
  h = (nodeName, props, ...children) => {
@@ -45,13 +45,13 @@ export const
45
45
 
46
46
  while (child) {
47
47
  const next = child.nextSibling
48
- host.removeChild(child)
48
+ dispose(host.removeChild(child))
49
49
  child = next
50
50
  }
51
51
  },
52
52
 
53
- component = setup => ({ is, props, ref, ...params }) => h(is ?? setup.is ?? 'div', {
54
- ...setup.props, ...props, skip: true, ref: host => run(host, setup, params, ref)
53
+ component = setup => ({ is, props, key, block, ref, ...params }) => h(is ?? setup.is ?? 'div', {
54
+ ...setup.props, ...props, key, block, skip: true, ref: run.bind(null, setup, params, ref)
55
55
  }),
56
56
 
57
57
  refresh = host => {
@@ -87,18 +87,7 @@ export const
87
87
  const
88
88
  { isArray, from } = Array, { keys, entries } = Object,
89
89
 
90
- isFunction = v => typeof v == 'function', noop = () => { }, on = (host, type, v) => {
91
-
92
- let fn, map
93
-
94
- if (fn = (map = host.$on ??= {})[type]) {
95
- host.removeEventListener(type, fn, fn.options), map[type] = null
96
- }
97
-
98
- if (typeof (fn = (v = isArray(v) ? v : [v])[0]) == 'function') {
99
- host.addEventListener(type, fn = map[type] = fn.bind(null, v[1]), fn.options = v[2])
100
- }
101
- },
90
+ isFunction = v => typeof v == 'function', noop = () => { },
102
91
 
103
92
  map = list => list.reduce(set, new Map), set = (m, v, i) => (m.set(v, i), m),
104
93
 
@@ -108,14 +97,17 @@ const
108
97
 
109
98
  create = (ns, name, key) => {
110
99
  const node = ns ? document.createElementNS(ns, name) : document.createElement(name)
111
- return node.$key = key, node
100
+ return ((node.$key = key), node)
112
101
  },
113
102
 
114
103
  proxy = { firstChild: null, insertBefore: node => proxy.firstChild ??= node }, handler = {
115
104
  get(target, key) {
116
- const value = key == 'nextSibling' ? null : target[key]
105
+ const value = key == 'nextSibling' ? null : Reflect.get(target, key)
117
106
  return isFunction(value) ? value.bind(target) : value
118
107
  },
108
+ set(target, key, value) {
109
+ return Reflect.set(target, key, value)
110
+ }
119
111
  },
120
112
 
121
113
  search = /([a-z0-9])([A-Z])/g, replace = '$1-$2',
@@ -142,9 +134,7 @@ const
142
134
 
143
135
  let value = props[name]
144
136
 
145
- if (name.startsWith('on:')) {
146
- some(value, prev[name]) && on(host, name.slice(3), value)
147
- } else if (value !== prev[name])
137
+ if (value !== prev[name])
148
138
  if (name.startsWith('set:')) host[name.slice(4)] = value
149
139
  else if (value == null || value === false) host.removeAttribute(name)
150
140
  else host.setAttribute(name, value === true ? '' : value)
@@ -165,7 +155,7 @@ const
165
155
  } else host.insertBefore(node, child)
166
156
  },
167
157
 
168
- iterate = (host, each, by, fn, ref) => {
158
+ iterate = (each, by, fn, ref, host) => {
169
159
 
170
160
  each = isArray(each) ? each : []
171
161
  by = isFunction(by) ? by : v => v
@@ -173,7 +163,10 @@ const
173
163
 
174
164
  const
175
165
  map = host.$for ??= new Map,
176
- del = node => map.delete(node.$by),
166
+ del = node => {
167
+ map.delete(node.$by)
168
+ dispose(node)
169
+ },
177
170
  clr = each !== host.$each,
178
171
  len = (host.$each = each).length,
179
172
  a = from(host.childNodes),
@@ -188,7 +181,7 @@ const
188
181
  child = (clr ? a[index] : map.get(key))
189
182
 
190
183
  proxy.firstChild = child ? new Proxy(child, handler) : null
191
- render(fn(item), proxy)
184
+ render(fn(item, index), proxy)
192
185
 
193
186
  child ??= proxy.firstChild
194
187
  proxy.firstChild = null
@@ -208,8 +201,7 @@ const
208
201
 
209
202
  while (aIndex !== aLen || bIndex !== bLen) {
210
203
 
211
- aValue = a[aIndex]
212
- bValue = b[bIndex]
204
+ aValue = a[aIndex], bValue = b[bIndex]
213
205
 
214
206
  if (aValue === null) aIndex++
215
207
  else if (bLen <= bIndex) aIndex++, dispose(host.removeChild(aValue))
@@ -217,8 +209,7 @@ const
217
209
  else if (aValue === bValue) aIndex++, bIndex++
218
210
  else {
219
211
 
220
- aMap ??= map(a)
221
- bMap ??= map(b)
212
+ aMap ??= map(a), bMap ??= map(b)
222
213
 
223
214
  if (bMap.get(aValue) == null) aIndex++, dispose(host.removeChild(aValue))
224
215
  else {
@@ -234,25 +225,20 @@ const
234
225
  }
235
226
  },
236
227
 
237
- run = (host, setup, params, ref) => {
228
+ run = (setup, params, ref, host) => {
238
229
 
239
- host.$setup ??= (host.addEventListener('DOMNodeRemovedFromDocument', dispose), isFunction(setup) ? setup : noop)
230
+ host.$setup ??= isFunction(setup) ? setup : noop
240
231
  host.$params = { ...setup.params, ...params }
241
232
 
242
233
  refresh(host)
243
234
  isFunction(ref) && ref(host)
244
235
  },
245
236
 
246
- dispose = ({ target }) => {
247
- (globalThis.queueMicrotask ?? (v => v()))(() => {
248
- if (document.contains(target)) return
249
-
250
- if ('$cleanups' in target) {
251
- try {
252
- for (const fn of target.$cleanups) fn(target)
253
- } finally {
254
- target.$cleanups.clear()
255
- }
256
- }
257
- })
237
+ dispose = host => {
238
+ if (host.nodeType != 1) return
239
+ for (const child of host.children) dispose(child)
240
+ if ('$cleanups' in host) for (const fn of host.$cleanups) {
241
+ host.$cleanups.delete(fn)
242
+ fn(host)
243
+ }
258
244
  }
package/index.min.js CHANGED
@@ -1 +1 @@
1
- var ajo=(()=>{var x=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var F=(e,n)=>{for(var i in n)x(e,i,{get:n[i],enumerable:!0})},T=(e,n,i,l)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of j(n))!B.call(e,r)&&r!==i&&x(e,r,{get:()=>n[r],enumerable:!(l=L(n,r))||l.enumerable});return e};var z=e=>T(x({},"__esModule",{value:!0}),e);var ae={};F(ae,{For:()=>I,Fragment:()=>D,cleanup:()=>P,clx:()=>R,component:()=>O,consume:()=>W,h:()=>b,intercept:()=>q,keb:()=>G,propagate:()=>k,provide:()=>V,refresh:()=>S,render:()=>g,stx:()=>Z});const D=({children:e})=>e,I=({is:e,each:n,by:i,children:l,ref:r,...o})=>b(e??"div",{...o,skip:!0,ref:t=>ie(t,n,i,l,r)}),b=(e,n,...i)=>{const{length:l}=i;return i=l==0?null:l==1?i[0]:i,{children:i,...n,nodeName:e}},g=(e,n,i)=>{let l=n.firstChild;for(e of y(e)){let r=l;if(e instanceof Node)r=e;else if(typeof e=="string"){for(;r&&r.nodeType!=3;)r=r.nextSibling;r?r.data!=e&&(r.data=e):r=document.createTextNode(e)}else{const{xmlns:o=i,nodeName:t,key:s,block:c,skip:f,children:p,ref:a,...d}=e;for(;r&&!(r.localName==t&&(r.$key??=s)==s);)r=r.nextSibling;r??=X(o,t,s),(c==null||E(r.$deps,r.$deps=c))&&(ee(d,r),f||g(p,r,o),u(a)&&a(r))}r==l?l=l.nextSibling:ne(n,r,l)}for(;l;){const r=l.nextSibling;n.removeChild(l),l=r}},O=e=>({is:n,props:i,ref:l,...r})=>b(n??e.is??"div",{...e.props,...i,skip:!0,ref:o=>re(o,e,r,l)}),S=e=>{try{g((e.$render??=e.$setup(e))(e.$params),e)}catch(n){k(e,n)}},V=(e,n,i)=>(e.$provisions??=new Map).set(n,i),W=(e,n,i)=>{for(let l;e;e=e.parentNode)if((l=e.$provisions)&&l.has(n))return l.get(n);return i},q=(e,n)=>u(n)&&(e.$interceptor=n),k=(e,n)=>{for(let i;e;e=e.parentNode)if(u(i=e.$interceptor))return g(i(n),e);throw n},P=(e,n)=>u(n)&&(e.$cleanups??=new Set).add(n),R=e=>M(e).filter(n=>e[n]).join(" ")||null,Z=e=>H(e).map(n=>n.join(":")).join(";")||null,G=e=>M(e).reduce((n,i)=>(n[i.replace(_,h).toLowerCase()]=e[i],n),{}),{isArray:m,from:A}=Array,{keys:M,entries:H}=Object,u=e=>typeof e=="function",w=()=>{},J=(e,n,i)=>{let l,r;(l=(r=e.$on??={})[n])&&(e.removeEventListener(n,l,l.options),r[n]=null),typeof(l=(i=m(i)?i:[i])[0])=="function"&&e.addEventListener(n,l=r[n]=l.bind(null,i[1]),l.options=i[2])},C=e=>e.reduce(K,new Map),K=(e,n,i)=>(e.set(n,i),e),E=(e,n)=>m(e)&&m(n)?e.some((i,l)=>i!==n[l]):e!==n,Q=e=>A(e).reduce(U,{}),U=(e,{name:n,value:i})=>(e[n]=i,e),X=(e,n,i)=>{const l=e?document.createElementNS(e,n):document.createElement(n);return l.$key=i,l},$={firstChild:null,insertBefore:e=>$.firstChild??=e},Y={get(e,n){const i=n=="nextSibling"?null:e[n];return u(i)?i.bind(e):i}},_=/([a-z0-9])([A-Z])/g,h="$1-$2",y=function*(e,n={t:""},i=!0){let l;for(e of m(e)?e:[e])e==null||typeof e=="boolean"||(typeof e.nodeName=="string"?((l=n.t)&&(n.t="",yield l),yield e):u(e.nodeName)?yield*y(e.nodeName(e),n,!1):m(e)?yield*y(e,n,!1):n.t+=e);i&&(l=n.t)&&(yield l)},ee=(e,n)=>{const i=n.$props??=n.hasAttributes()?Q(n.attributes):{};for(const l in{...i,...n.$props=e}){let r=e[l];l.startsWith("on:")?E(r,i[l])&&J(n,l.slice(3),r):r!==i[l]&&(l.startsWith("set:")?n[l.slice(4)]=r:r==null||r===!1?n.removeAttribute(l):n.setAttribute(l,r===!0?"":r))}},ne=(e,n,i)=>{if(n.contains?.(document.activeElement)){const l=n.nextSibling;for(;i&&i!=n;){const r=i.nextSibling;e.insertBefore(i,l),i=r}}else e.insertBefore(n,i)},ie=(e,n,i,l,r)=>{n=m(n)?n:[],i=u(i)?i:a=>a,l=u(l)?l:w;const o=e.$for??=new Map,t=a=>o.delete(a.$by),s=n!==e.$each,c=(e.$each=n).length,f=A(e.childNodes),p=new Array(c);s&&o.clear();for(let a,d=0;d<c;d++){const v=n[d],N=i(v,d);a=s?f[d]:o.get(N),$.firstChild=a?new Proxy(a,Y):null,g(l(v),$),a??=$.firstChild,$.firstChild=null,o.set(a.$by=N,p[d]=a)}le(e,f,p,t),u(r)&&r(e)},le=(e,n,i,l=w)=>{const r=n.length,o=i.length;let t=0,s=0,c,f,p,a,d;for(;t!==r||s!==o;)c=n[t],f=i[s],c===null?t++:o<=s?(t++,l(e.removeChild(c))):r<=t?(s++,e.appendChild(f)):c===f?(t++,s++):(p??=C(n),a??=C(i),a.get(c)==null?(t++,l(e.removeChild(c))):(e.insertBefore(f,c),s++,(d=p.get(f))!=null&&(d>t+1&&t++,n[d]=null)))},re=(e,n,i,l)=>{e.$setup??=(e.addEventListener("DOMNodeRemovedFromDocument",te),u(n)?n:w),e.$params={...n.params,...i},S(e),u(l)&&l(e)},te=({target:e})=>{(globalThis.queueMicrotask??(n=>n()))(()=>{if(!document.contains(e)&&"$cleanups"in e)try{for(const n of e.$cleanups)n(e)}finally{e.$cleanups.clear()}})};return z(ae);})();
1
+ var ajo=(()=>{var x=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var L=(e,n)=>{for(var l in n)x(e,l,{get:n[l],enumerable:!0})},T=(e,n,l,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of E(n))!F.call(e,t)&&t!==l&&x(e,t,{get:()=>n[t],enumerable:!(i=B(n,t))||i.enumerable});return e};var z=e=>T(x({},"__esModule",{value:!0}),e);var re={};L(re,{For:()=>R,Fragment:()=>I,cleanup:()=>Z,clx:()=>q,component:()=>V,consume:()=>P,h:()=>b,intercept:()=>W,keb:()=>G,propagate:()=>A,provide:()=>O,refresh:()=>k,render:()=>g,stx:()=>D});const I=({children:e})=>e,R=({is:e,key:n,block:l,each:i,by:t,children:s,ref:r,...o})=>b(e??"div",{...o,key:n,block:l,skip:!0,ref:le.bind(null,i,t,s,r)}),b=(e,n,...l)=>{const{length:i}=l;return l=i==0?null:i==1?l[0]:l,{children:l,...n,nodeName:e}},g=(e,n,l)=>{let i=n.firstChild;for(e of y(e)){let t=i;if(e instanceof Node)t=e;else if(typeof e=="string"){for(;t&&t.nodeType!=3;)t=t.nextSibling;t?t.data!=e&&(t.data=e):t=document.createTextNode(e)}else{const{xmlns:s=l,nodeName:r,key:o,block:c,skip:f,children:u,ref:a,...d}=e;for(;t&&!(t.localName==r&&(t.$key??=o)==o);)t=t.nextSibling;t??=X(s,r,o),(c==null||K(t.$deps,t.$deps=c))&&(ee(d,t),f||g(u,t,s),p(a)&&a(t))}t==i?i=i.nextSibling:ne(n,t,i)}for(;i;){const t=i.nextSibling;v(n.removeChild(i)),i=t}},V=e=>({is:n,props:l,key:i,block:t,ref:s,...r})=>b(n??e.is??"div",{...e.props,...l,key:i,block:t,skip:!0,ref:te.bind(null,e,r,s)}),k=e=>{try{g((e.$render??=e.$setup(e))(e.$params),e)}catch(n){A(e,n)}},O=(e,n,l)=>(e.$provisions??=new Map).set(n,l),P=(e,n,l)=>{for(let i;e;e=e.parentNode)if((i=e.$provisions)&&i.has(n))return i.get(n);return l},W=(e,n)=>p(n)&&(e.$interceptor=n),A=(e,n)=>{for(let l;e;e=e.parentNode)if(p(l=e.$interceptor))return g(l(n),e);throw n},Z=(e,n)=>p(n)&&(e.$cleanups??=new Set).add(n),q=e=>j(e).filter(n=>e[n]).join(" ")||null,D=e=>H(e).map(n=>n.join(":")).join(";")||null,G=e=>j(e).reduce((n,l)=>(n[l.replace(_,h).toLowerCase()]=e[l],n),{}),{isArray:$,from:M}=Array,{keys:j,entries:H}=Object,p=e=>typeof e=="function",w=()=>{},S=e=>e.reduce(J,new Map),J=(e,n,l)=>(e.set(n,l),e),K=(e,n)=>$(e)&&$(n)?e.some((l,i)=>l!==n[i]):e!==n,Q=e=>M(e).reduce(U,{}),U=(e,{name:n,value:l})=>(e[n]=l,e),X=(e,n,l)=>{const i=e?document.createElementNS(e,n):document.createElement(n);return i.$key=l,i},m={firstChild:null,insertBefore:e=>m.firstChild??=e},Y={get(e,n){const l=n=="nextSibling"?null:Reflect.get(e,n);return p(l)?l.bind(e):l},set(e,n,l){return Reflect.set(e,n,l)}},_=/([a-z0-9])([A-Z])/g,h="$1-$2",y=function*(e,n={t:""},l=!0){let i;for(e of $(e)?e:[e])e==null||typeof e=="boolean"||(typeof e.nodeName=="string"?((i=n.t)&&(n.t="",yield i),yield e):p(e.nodeName)?yield*y(e.nodeName(e),n,!1):$(e)?yield*y(e,n,!1):n.t+=e);l&&(i=n.t)&&(yield i)},ee=(e,n)=>{const l=n.$props??=n.hasAttributes()?Q(n.attributes):{};for(const i in{...l,...n.$props=e}){let t=e[i];t!==l[i]&&(i.startsWith("set:")?n[i.slice(4)]=t:t==null||t===!1?n.removeAttribute(i):n.setAttribute(i,t===!0?"":t))}},ne=(e,n,l)=>{if(n.contains?.(document.activeElement)){const i=n.nextSibling;for(;l&&l!=n;){const t=l.nextSibling;e.insertBefore(l,i),l=t}}else e.insertBefore(n,l)},le=(e,n,l,i,t)=>{e=$(e)?e:[],n=p(n)?n:a=>a,l=p(l)?l:w;const s=t.$for??=new Map,r=a=>{s.delete(a.$by),v(a)},o=e!==t.$each,c=(t.$each=e).length,f=M(t.childNodes),u=new Array(c);o&&s.clear();for(let a,d=0;d<c;d++){const C=e[d],N=n(C,d);a=o?f[d]:s.get(N),m.firstChild=a?new Proxy(a,Y):null,g(l(C,d),m),a??=m.firstChild,m.firstChild=null,s.set(a.$by=N,u[d]=a)}ie(t,f,u,r),p(i)&&i(t)},ie=(e,n,l,i=w)=>{const t=n.length,s=l.length;let r=0,o=0,c,f,u,a,d;for(;r!==t||o!==s;)c=n[r],f=l[o],c===null?r++:s<=o?(r++,i(e.removeChild(c))):t<=r?(o++,e.appendChild(f)):c===f?(r++,o++):(u??=S(n),a??=S(l),a.get(c)==null?(r++,i(e.removeChild(c))):(e.insertBefore(f,c),o++,(d=u.get(f))!=null&&(d>r+1&&r++,n[d]=null)))},te=(e,n,l,i)=>{i.$setup??=p(e)?e:w,i.$params={...e.params,...n},k(i),p(l)&&l(i)},v=e=>{if(e.nodeType==1){for(const n of e.children)v(n);if("$cleanups"in e)for(const n of e.$cleanups)e.$cleanups.delete(n),n(e)}};return z(re);})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ajo",
3
- "version": "0.0.19",
3
+ "version": "0.0.21",
4
4
  "description": "ajo is a JavaScript view library for building user interfaces",
5
5
  "type": "module",
6
6
  "module": "index.js",
@@ -38,7 +38,7 @@
38
38
  "homepage": "https://github.com/cristianfalcone/ajo#readme",
39
39
  "devDependencies": {
40
40
  "backdom": "^0.0.8",
41
- "esbuild": "^0.15.7",
41
+ "esbuild": "^0.15.9",
42
42
  "uvu": "^0.5.6"
43
43
  }
44
44
  }