ajo 0.1.19 → 0.1.20

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/dist/html.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const{create:p,assign:v,entries:g,hasOwn:x}=Object,{isArray:f,from:k}=Array,m="",c=e=>k(d(e)).join(""),d=function*(e){for(e of u(e))if(typeof e=="string")yield $(e);else{const{nodeName:t,skip:o,children:r=""}=e;let n="";for(const[l,i]of g(e))S.has(l)||l.startsWith("set:")||i==null||i===!1||(n+=i===!0?` ${l}`:` ${l}="${$(String(i))}"`);w.has(t)?yield`<${t}${n}>`:o?yield`<${t}${n}></${t}>`:(yield`<${t}${n}>`,typeof r=="string"&&r.startsWith(m)?yield r.slice(1):yield*d(r),yield`</${t}>`)}},u=function*(e,t={value:""},o=!0){for(e of f(e)?e:[e])if(!(e==null||typeof e=="boolean"))if(x(e,"nodeName")){const{value:r}=t,{nodeName:n}=e;if(r&&(yield r,t.value=""),typeof n=="function")if(n.constructor.name==="GeneratorFunction"){const l={},i=v({},n.attrs);for(const a in e){const y=e[a];a.startsWith("attr:")?i[a.slice(5)]=y:l[a]=y}i.nodeName=n.is??"div",i.children=N(n,l),yield i}else yield*u(n(e),t,!1);else yield e}else f(e)?yield*u(e,t,!1):t.value+=e;o&&t.value&&(yield t.value)},w=new Set("area,base,br,col,command,embed,hr,img,input,keygen,link,meta,param,source,track,wbr".split(",")),S=new Set("nodeName,key,skip,memo,ref,children".split(",")),$=e=>e.replace(/[&<>"']/g,t=>`&#${t.charCodeAt(0)};`);let s=null;const N=(e,t)=>{let o,r;try{const n=e.call(o={$args:t,$context:p(s?s.$context:null),render(){s!==o&&o.$next()},$next(){const l=s;s=o,r=c(n.next().value),s=l},$throw(l){r=c(n.throw(l).value)},$return(){n.return()}},t);o.$next()}catch(n){o.$throw(n)}finally{o.$return()}return m+r},b=(e,t=Symbol())=>function(o,r){return arguments.length===1?t in o.$context?o.$context[t]:e:o.$context[t]=r};exports.context=b;exports.html=d;exports.render=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const{isArray:$,from:p}=Array,m="",{create:g,assign:v,entries:x,prototype:{hasOwnProperty:w},hasOwn:S=(e,t)=>w.call(e,t)}=Object,c=e=>p(d(e)).join(""),d=function*(e){for(e of u(e))if(typeof e=="string")yield f(e);else{const{nodeName:t,skip:o,children:r=""}=e;let n="";for(const[i,s]of x(e))k.has(i)||i.startsWith("set:")||s==null||s===!1||(n+=s===!0?` ${i}`:` ${i}="${f(String(s))}"`);N.has(t)?yield`<${t}${n}>`:o?yield`<${t}${n}></${t}>`:(yield`<${t}${n}>`,typeof r=="string"&&r.startsWith(m)?yield r.slice(1):yield*d(r),yield`</${t}>`)}},u=function*(e,t={value:""},o=!0){for(e of $(e)?e:[e])if(!(e==null||typeof e=="boolean"))if(S(e,"nodeName")){const{value:r}=t,{nodeName:n}=e;if(r&&(yield r,t.value=""),typeof n=="function")if(n.constructor.name==="GeneratorFunction"){const i={},s=v({},n.attrs);for(const a in e){const y=e[a];a.startsWith("attr:")?s[a.slice(5)]=y:i[a]=y}s.nodeName=n.is??"div",s.children=O(n,i),yield s}else yield*u(n(e),t,!1);else yield e}else $(e)?yield*u(e,t,!1):t.value+=e;o&&t.value&&(yield t.value)},N=new Set("area,base,br,col,command,embed,hr,img,input,keygen,link,meta,param,source,track,wbr".split(",")),k=new Set("nodeName,key,skip,memo,ref,children".split(",")),f=e=>e.replace(/[&<>"']/g,t=>`&#${t.charCodeAt(0)};`);let l=null;const O=(e,t)=>{let o,r;try{const n=e.call(o={$args:t,$context:g((l==null?void 0:l.$context)??null),render(){l!==o&&o.$next()},$next(){const i=l;l=o,r=c(n.next().value),l=i},$throw(i){r=c(n.throw(i).value)},$return(){n.return()}},t);o.$next()}catch(n){o.$throw(n)}finally{o.$return()}return m+r},j=(e,t=Symbol())=>function(o,r){return arguments.length===0?l&&t in l.$context?l.$context[t]:e:arguments.length===1?t in o.$context?o.$context[t]:e:o.$context[t]=r};exports.context=j;exports.html=d;exports.render=c;
package/dist/html.js CHANGED
@@ -1,47 +1,47 @@
1
- const { create: p, assign: v, entries: x, hasOwn: g } = Object, { isArray: d, from: k } = Array, f = "", y = (e) => k(m(e)).join(""), m = function* (e) {
1
+ const { isArray: d, from: p } = Array, f = "", { create: x, assign: v, entries: g, prototype: { hasOwnProperty: w }, hasOwn: N = (e, t) => w.call(e, t) } = Object, $ = (e) => p(m(e)).join(""), m = function* (e) {
2
2
  for (e of c(e))
3
- if (typeof e == "string") yield $(e);
3
+ if (typeof e == "string") yield y(e);
4
4
  else {
5
5
  const { nodeName: t, skip: o, children: r = "" } = e;
6
6
  let n = "";
7
- for (const [i, l] of x(e))
8
- N.has(i) || i.startsWith("set:") || l == null || l === !1 || (n += l === !0 ? ` ${i}` : ` ${i}="${$(String(l))}"`);
9
- w.has(t) ? yield `<${t}${n}>` : o ? yield `<${t}${n}></${t}>` : (yield `<${t}${n}>`, typeof r == "string" && r.startsWith(f) ? yield r.slice(1) : yield* m(r), yield `</${t}>`);
7
+ for (const [i, s] of g(e))
8
+ S.has(i) || i.startsWith("set:") || s == null || s === !1 || (n += s === !0 ? ` ${i}` : ` ${i}="${y(String(s))}"`);
9
+ k.has(t) ? yield `<${t}${n}>` : o ? yield `<${t}${n}></${t}>` : (yield `<${t}${n}>`, typeof r == "string" && r.startsWith(f) ? yield r.slice(1) : yield* m(r), yield `</${t}>`);
10
10
  }
11
11
  }, c = function* (e, t = { value: "" }, o = !0) {
12
12
  for (e of d(e) ? e : [e])
13
13
  if (!(e == null || typeof e == "boolean"))
14
- if (g(e, "nodeName")) {
14
+ if (N(e, "nodeName")) {
15
15
  const { value: r } = t, { nodeName: n } = e;
16
16
  if (r && (yield r, t.value = ""), typeof n == "function")
17
17
  if (n.constructor.name === "GeneratorFunction") {
18
- const i = {}, l = v({}, n.attrs);
18
+ const i = {}, s = v({}, n.attrs);
19
19
  for (const a in e) {
20
20
  const u = e[a];
21
- a.startsWith("attr:") ? l[a.slice(5)] = u : i[a] = u;
21
+ a.startsWith("attr:") ? s[a.slice(5)] = u : i[a] = u;
22
22
  }
23
- l.nodeName = n.is ?? "div", l.children = S(n, i), yield l;
23
+ s.nodeName = n.is ?? "div", s.children = A(n, i), yield s;
24
24
  } else yield* c(n(e), t, !1);
25
25
  else yield e;
26
26
  } else d(e) ? yield* c(e, t, !1) : t.value += e;
27
27
  o && t.value && (yield t.value);
28
- }, w = new Set("area,base,br,col,command,embed,hr,img,input,keygen,link,meta,param,source,track,wbr".split(",")), N = new Set("nodeName,key,skip,memo,ref,children".split(",")), $ = (e) => e.replace(/[&<>"']/g, (t) => `&#${t.charCodeAt(0)};`);
29
- let s = null;
30
- const S = (e, t) => {
28
+ }, k = new Set("area,base,br,col,command,embed,hr,img,input,keygen,link,meta,param,source,track,wbr".split(",")), S = new Set("nodeName,key,skip,memo,ref,children".split(",")), y = (e) => e.replace(/[&<>"']/g, (t) => `&#${t.charCodeAt(0)};`);
29
+ let l = null;
30
+ const A = (e, t) => {
31
31
  let o, r;
32
32
  try {
33
33
  const n = e.call(o = {
34
34
  $args: t,
35
- $context: p(s ? s.$context : null),
35
+ $context: x((l == null ? void 0 : l.$context) ?? null),
36
36
  render() {
37
- s !== o && o.$next();
37
+ l !== o && o.$next();
38
38
  },
39
39
  $next() {
40
- const i = s;
41
- s = o, r = y(n.next().value), s = i;
40
+ const i = l;
41
+ l = o, r = $(n.next().value), l = i;
42
42
  },
43
43
  $throw(i) {
44
- r = y(n.throw(i).value);
44
+ r = $(n.throw(i).value);
45
45
  },
46
46
  $return() {
47
47
  n.return();
@@ -54,11 +54,11 @@ const S = (e, t) => {
54
54
  o.$return();
55
55
  }
56
56
  return f + r;
57
- }, A = (e, t = Symbol()) => function(o, r) {
58
- return arguments.length === 1 ? t in o.$context ? o.$context[t] : e : o.$context[t] = r;
57
+ }, O = (e, t = Symbol()) => function(o, r) {
58
+ return arguments.length === 0 ? l && t in l.$context ? l.$context[t] : e : arguments.length === 1 ? t in o.$context ? o.$context[t] : e : o.$context[t] = r;
59
59
  };
60
60
  export {
61
- A as context,
61
+ O as context,
62
62
  m as html,
63
- y as render
63
+ $ as render
64
64
  };
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=({children:n})=>n,k=function(n,t){const{length:e}=arguments;return(t??(t=v(null))).nodeName=n,"children"in t||e<3||(t.children=e===3?arguments[2]:O.call(arguments,2)),t},$=(n,t)=>{let e=t.firstChild;for(n of g(n)){let i=e;if(typeof n=="string"){for(;i&&i.nodeType!=3;)i=i.nextSibling;i?i.data!=n&&(i.data=n):i=document.createTextNode(n)}else{const{nodeName:o,key:a,skip:c,memo:r,ref:f,children:N}=n;for(;i&&!(i.localName===o&&(i.$key??(i.$key=a))==a);)i=i.nextSibling;if(i??(i=d(document.createElementNS(n.xmlns??o==="svg"?T:t.namespaceURI,o),{$key:a})),r==null||F(i.$memo,i.$memo=r)){const{$props:m}=i,x={};for(const l of w(d({},m,n))){if(C.has(l))continue;const u=x[l]=n[l];u!==(m==null?void 0:m[l])&&(l.startsWith("set:")?i[l.slice(4)]=u:u==null||u===!1?i.removeAttribute(l):i.setAttribute(l,u===!0?"":u))}i.$props=x,c||$(N,i),typeof f=="function"&&(i.$ref=f)(i)}}i===e?e=e.nextSibling:B(t,i,e)}for(;e;){const i=e.nextSibling;e.nodeType===1&&S(e),t.removeChild(e),e=i}},{isArray:y,prototype:{slice:O}}=Array,{create:v,keys:w,assign:d,hasOwn:A,setPrototypeOf:p,getPrototypeOf:h}=Object,T="http://www.w3.org/2000/svg",C=new Set("nodeName,key,skip,memo,ref,children".split(",")),F=(n,t)=>y(n)&&y(t)?n.some((e,i)=>e!==t[i]):n!==t,g=function*(n,t={value:""},e=!0){for(n of y(n)?n:[n])if(!(n==null||typeof n=="boolean"))if(A(n,"nodeName")){const{value:i}=t,{nodeName:o}=n;if(i&&(yield i,t.value=""),typeof o=="function")if(o.constructor.name==="GeneratorFunction"){const a={},c=d({},o.attrs);for(const r of w(n)){const f=n[r];r.startsWith("attr:")?c[r.slice(5)]=f:r==="key"||r==="memo"?c[r]=f:a[r]=f}c.nodeName=o.is??"div",c.skip=!0,c.ref=P.bind(null,o,a),yield c}else yield*g(o(n),t,!1);else yield n}else y(n)?yield*g(n,t,!1):t.value+=n;e&&t.value&&(yield t.value)},P=(n,t,e)=>{if(!e)return;e.$gen??(e.$gen=(new E(e),n)),e.$ref=j.bind(null,e);const{skip:i,...o}=t;d(e.$args??(e.$args={}),o),i||e.$next()},j=(n,t)=>t??n.$return(),B=(n,t,e)=>{if(t.contains(document.activeElement)){const i=t.nextSibling;for(;e&&e!=t;){const o=e.nextSibling;n.insertBefore(e,i),e=o}}else n.insertBefore(t,e)},S=n=>{for(const e of n.children)S(e);const{$ref:t}=n;typeof t=="function"&&t(null)};let s=null;class E{constructor(t){p(t,p(h(this),h(t))),t.$context=v((s==null?void 0:s.$context)??null)}render(){s!=null&&s.contains(this)||this.$next()}$next(){const t=s;s=this;try{$((this.$it??(this.$it=this.$gen.call(this,this.$args))).next().value,this),typeof this.$ref=="function"&&this.$ref(this)}catch(e){this.$throw(e)}finally{s=t}}$throw(t){var e;for(let i=this;i;i=i.parentNode)if(typeof((e=i.$it)==null?void 0:e.throw)=="function")try{return $(i.$it.throw(t).value,i)}catch{}throw t}$return(){var t;try{(t=this.$it)==null||t.return()}catch(e){this.$throw(e)}finally{this.$it=null}}}const W=(n,t=Symbol())=>function(e,i){const{length:o}=arguments;return o===0?s&&t in s.$context?s.$context[t]:n:o===1?t in e.$context?e.$context[t]:n:e.$context[t]=i};exports.Fragment=b;exports.context=W;exports.h=k;exports.render=$;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=({children:t})=>t,N=function(t,n){const{length:e}=arguments;return(n??(n=h(null))).nodeName=t,"children"in n||e<3||(n.children=e===3?arguments[2]:b.call(arguments,2)),n},d=(t,n)=>{let e=n.firstChild;for(t of g(t)){let i=e;if(typeof t=="string"){for(;i&&i.nodeType!=3;)i=i.nextSibling;i?i.data!=t&&(i.data=t):i=document.createTextNode(t)}else{const{nodeName:o,key:l,skip:c,memo:r,ref:f,children:w}=t;for(;i&&!(i.localName===o&&(i.$key??(i.$key=l))==l);)i=i.nextSibling;if(i??(i=m(document.createElementNS(t.xmlns??o==="svg"?O:n.namespaceURI,o),{$key:l})),r==null||F(i.$memo,i.$memo=r)){const{$props:$}=i,x={};for(const a of p(m({},$,t))){if(T.has(a))continue;const u=x[a]=t[a];u!==($==null?void 0:$[a])&&(a.startsWith("set:")?i[a.slice(4)]=u:u==null||u===!1?i.removeAttribute(a):i.setAttribute(a,u===!0?"":u))}i.$props=x,c||d(w,i),typeof f=="function"&&(i.$ref=f)(i)}}i===e?e=e.nextSibling:C(n,i,e)}for(;e;){const i=e.nextSibling;e.nodeType===1&&v(e),n.removeChild(e),e=i}},{isArray:y,prototype:{slice:b}}=Array,{create:h,assign:m,keys:p,prototype:{hasOwnProperty:k},hasOwn:A=(t,n)=>k.call(t,n)}=Object,O="http://www.w3.org/2000/svg",T=new Set("nodeName,key,skip,memo,ref,children".split(",")),F=(t,n)=>y(t)&&y(n)?t.some((e,i)=>e!==n[i]):t!==n,g=function*(t,n={value:""},e=!0){for(t of y(t)?t:[t])if(!(t==null||typeof t=="boolean"))if(A(t,"nodeName")){const{value:i}=n,{nodeName:o}=t;if(i&&(yield i,n.value=""),typeof o=="function")if(o.constructor.name==="GeneratorFunction"){const l={},c=m({},o.attrs);for(const r of p(t)){const f=t[r];r.startsWith("attr:")?c[r.slice(5)]=f:r==="key"||r==="memo"?c[r]=f:l[r]=f}c.nodeName=o.is??"div",c.skip=!0,c.ref=j.bind(null,o,l),yield c}else yield*g(o(t),n,!1);else yield t}else y(t)?yield*g(t,n,!1):n.value+=t;e&&n.value&&(yield n.value)},j=(t,n,e)=>{if(!e)return;e.$gen??(e.$gen=(m(e,E),e.$context??(e.$context=h((s==null?void 0:s.$context)??null)),t)),e.$ref=B.bind(null,e);const{skip:i,...o}=n;m(e.$args??(e.$args={}),o),i||e.$next()},B=(t,n)=>n??t.$return(),C=(t,n,e)=>{if(n.contains(document.activeElement)){const i=n.nextSibling;for(;e&&e!=n;){const o=e.nextSibling;t.insertBefore(e,i),e=o}}else t.insertBefore(n,e)},v=t=>{for(const e of t.children)v(e);const{$ref:n}=t;typeof n=="function"&&n(null)};let s=null;const E={render(){s!=null&&s.contains(this)||this.$next()},$next(){const t=s;s=this;try{d((this.$it??(this.$it=this.$gen.call(this,this.$args))).next().value,this),typeof this.$ref=="function"&&this.$ref(this)}catch(n){this.$throw(n)}finally{s=t}},$throw(t){var n;for(let e=this;e;e=e.parentNode)if(typeof((n=e.$it)==null?void 0:n.throw)=="function")try{return d(e.$it.throw(t).value,e)}catch{}throw t},$return(){var t;try{(t=this.$it)==null||t.return()}catch(n){this.$throw(n)}finally{this.$it=null}}},P=(t,n=Symbol())=>function(e,i){return arguments.length===0?s&&n in s.$context?s.$context[n]:t:arguments.length===1?n in e.$context?e.$context[n]:t:e.$context[n]=i};exports.Fragment=S;exports.context=P;exports.h=N;exports.render=d;
package/dist/index.js CHANGED
@@ -1,111 +1,106 @@
1
- const P = ({ children: n }) => n, W = function(n, t) {
1
+ const F = ({ children: t }) => t, W = function(t, n) {
2
2
  const { length: e } = arguments;
3
- return (t ?? (t = v(null))).nodeName = n, "children" in t || e < 3 || (t.children = e === 3 ? arguments[2] : k.call(arguments, 2)), t;
4
- }, d = (n, t) => {
5
- let e = t.firstChild;
6
- for (n of g(n)) {
3
+ return (n ?? (n = h(null))).nodeName = t, "children" in n || e < 3 || (n.children = e === 3 ? arguments[2] : N.call(arguments, 2)), n;
4
+ }, d = (t, n) => {
5
+ let e = n.firstChild;
6
+ for (t of g(t)) {
7
7
  let i = e;
8
- if (typeof n == "string") {
8
+ if (typeof t == "string") {
9
9
  for (; i && i.nodeType != 3; ) i = i.nextSibling;
10
- i ? i.data != n && (i.data = n) : i = document.createTextNode(n);
10
+ i ? i.data != t && (i.data = t) : i = document.createTextNode(t);
11
11
  } else {
12
- const { nodeName: o, key: a, skip: c, memo: r, ref: f, children: S } = n;
13
- for (; i && !(i.localName === o && (i.$key ?? (i.$key = a)) == a); ) i = i.nextSibling;
14
- if (i ?? (i = y(document.createElementNS(n.xmlns ?? o === "svg" ? A : t.namespaceURI, o), { $key: a })), r == null || C(i.$memo, i.$memo = r)) {
15
- const { $props: m } = i, x = {};
16
- for (const l of w(y({}, m, n))) {
17
- if (O.has(l)) continue;
18
- const u = x[l] = n[l];
19
- u !== (m == null ? void 0 : m[l]) && (l.startsWith("set:") ? i[l.slice(4)] = u : u == null || u === !1 ? i.removeAttribute(l) : i.setAttribute(l, u === !0 ? "" : u));
12
+ const { nodeName: o, key: l, skip: c, memo: r, ref: f, children: w } = t;
13
+ for (; i && !(i.localName === o && (i.$key ?? (i.$key = l)) == l); ) i = i.nextSibling;
14
+ if (i ?? (i = m(document.createElementNS(t.xmlns ?? o === "svg" ? b : n.namespaceURI, o), { $key: l })), r == null || O(i.$memo, i.$memo = r)) {
15
+ const { $props: $ } = i, x = {};
16
+ for (const a of p(m({}, $, t))) {
17
+ if (A.has(a)) continue;
18
+ const u = x[a] = t[a];
19
+ u !== ($ == null ? void 0 : $[a]) && (a.startsWith("set:") ? i[a.slice(4)] = u : u == null || u === !1 ? i.removeAttribute(a) : i.setAttribute(a, u === !0 ? "" : u));
20
20
  }
21
- i.$props = x, c || d(S, i), typeof f == "function" && (i.$ref = f)(i);
21
+ i.$props = x, c || d(w, i), typeof f == "function" && (i.$ref = f)(i);
22
22
  }
23
23
  }
24
- i === e ? e = e.nextSibling : E(t, i, e);
24
+ i === e ? e = e.nextSibling : C(n, i, e);
25
25
  }
26
26
  for (; e; ) {
27
27
  const i = e.nextSibling;
28
- e.nodeType === 1 && N(e), t.removeChild(e), e = i;
28
+ e.nodeType === 1 && v(e), n.removeChild(e), e = i;
29
29
  }
30
- }, { isArray: $, prototype: { slice: k } } = Array, { create: v, keys: w, assign: y, hasOwn: b, setPrototypeOf: p, getPrototypeOf: h } = Object, A = "http://www.w3.org/2000/svg", O = new Set("nodeName,key,skip,memo,ref,children".split(",")), C = (n, t) => $(n) && $(t) ? n.some((e, i) => e !== t[i]) : n !== t, g = function* (n, t = { value: "" }, e = !0) {
31
- for (n of $(n) ? n : [n])
32
- if (!(n == null || typeof n == "boolean"))
33
- if (b(n, "nodeName")) {
34
- const { value: i } = t, { nodeName: o } = n;
35
- if (i && (yield i, t.value = ""), typeof o == "function")
30
+ }, { isArray: y, prototype: { slice: N } } = Array, { create: h, assign: m, keys: p, prototype: { hasOwnProperty: S }, hasOwn: k = (t, n) => S.call(t, n) } = Object, b = "http://www.w3.org/2000/svg", A = new Set("nodeName,key,skip,memo,ref,children".split(",")), O = (t, n) => y(t) && y(n) ? t.some((e, i) => e !== n[i]) : t !== n, g = function* (t, n = { value: "" }, e = !0) {
31
+ for (t of y(t) ? t : [t])
32
+ if (!(t == null || typeof t == "boolean"))
33
+ if (k(t, "nodeName")) {
34
+ const { value: i } = n, { nodeName: o } = t;
35
+ if (i && (yield i, n.value = ""), typeof o == "function")
36
36
  if (o.constructor.name === "GeneratorFunction") {
37
- const a = {}, c = y({}, o.attrs);
38
- for (const r of w(n)) {
39
- const f = n[r];
40
- r.startsWith("attr:") ? c[r.slice(5)] = f : r === "key" || r === "memo" ? c[r] = f : a[r] = f;
37
+ const l = {}, c = m({}, o.attrs);
38
+ for (const r of p(t)) {
39
+ const f = t[r];
40
+ r.startsWith("attr:") ? c[r.slice(5)] = f : r === "key" || r === "memo" ? c[r] = f : l[r] = f;
41
41
  }
42
- c.nodeName = o.is ?? "div", c.skip = !0, c.ref = T.bind(null, o, a), yield c;
43
- } else yield* g(o(n), t, !1);
44
- else yield n;
45
- } else $(n) ? yield* g(n, t, !1) : t.value += n;
46
- e && t.value && (yield t.value);
47
- }, T = (n, t, e) => {
42
+ c.nodeName = o.is ?? "div", c.skip = !0, c.ref = T.bind(null, o, l), yield c;
43
+ } else yield* g(o(t), n, !1);
44
+ else yield t;
45
+ } else y(t) ? yield* g(t, n, !1) : n.value += t;
46
+ e && n.value && (yield n.value);
47
+ }, T = (t, n, e) => {
48
48
  if (!e) return;
49
- e.$gen ?? (e.$gen = (new F(e), n)), e.$ref = B.bind(null, e);
50
- const { skip: i, ...o } = t;
51
- y(e.$args ?? (e.$args = {}), o), i || e.$next();
52
- }, B = (n, t) => t ?? n.$return(), E = (n, t, e) => {
53
- if (t.contains(document.activeElement)) {
54
- const i = t.nextSibling;
55
- for (; e && e != t; ) {
49
+ e.$gen ?? (e.$gen = (m(e, E), e.$context ?? (e.$context = h((s == null ? void 0 : s.$context) ?? null)), t)), e.$ref = B.bind(null, e);
50
+ const { skip: i, ...o } = n;
51
+ m(e.$args ?? (e.$args = {}), o), i || e.$next();
52
+ }, B = (t, n) => n ?? t.$return(), C = (t, n, e) => {
53
+ if (n.contains(document.activeElement)) {
54
+ const i = n.nextSibling;
55
+ for (; e && e != n; ) {
56
56
  const o = e.nextSibling;
57
- n.insertBefore(e, i), e = o;
57
+ t.insertBefore(e, i), e = o;
58
58
  }
59
- } else n.insertBefore(t, e);
60
- }, N = (n) => {
61
- for (const e of n.children) N(e);
62
- const { $ref: t } = n;
63
- typeof t == "function" && t(null);
59
+ } else t.insertBefore(n, e);
60
+ }, v = (t) => {
61
+ for (const e of t.children) v(e);
62
+ const { $ref: n } = t;
63
+ typeof n == "function" && n(null);
64
64
  };
65
65
  let s = null;
66
- class F {
67
- constructor(t) {
68
- p(t, p(h(this), h(t))), t.$context = v((s == null ? void 0 : s.$context) ?? null);
69
- }
66
+ const E = {
70
67
  render() {
71
68
  s != null && s.contains(this) || this.$next();
72
- }
69
+ },
73
70
  $next() {
74
71
  const t = s;
75
72
  s = this;
76
73
  try {
77
74
  d((this.$it ?? (this.$it = this.$gen.call(this, this.$args))).next().value, this), typeof this.$ref == "function" && this.$ref(this);
78
- } catch (e) {
79
- this.$throw(e);
75
+ } catch (n) {
76
+ this.$throw(n);
80
77
  } finally {
81
78
  s = t;
82
79
  }
83
- }
80
+ },
84
81
  $throw(t) {
85
- var e;
86
- for (let i = this; i; i = i.parentNode) if (typeof ((e = i.$it) == null ? void 0 : e.throw) == "function") try {
87
- return d(i.$it.throw(t).value, i);
82
+ var n;
83
+ for (let e = this; e; e = e.parentNode) if (typeof ((n = e.$it) == null ? void 0 : n.throw) == "function") try {
84
+ return d(e.$it.throw(t).value, e);
88
85
  } catch {
89
86
  }
90
87
  throw t;
91
- }
88
+ },
92
89
  $return() {
93
90
  var t;
94
91
  try {
95
92
  (t = this.$it) == null || t.return();
96
- } catch (e) {
97
- this.$throw(e);
93
+ } catch (n) {
94
+ this.$throw(n);
98
95
  } finally {
99
96
  this.$it = null;
100
97
  }
101
98
  }
102
- }
103
- const j = (n, t = Symbol()) => function(e, i) {
104
- const { length: o } = arguments;
105
- return o === 0 ? s && t in s.$context ? s.$context[t] : n : o === 1 ? t in e.$context ? e.$context[t] : n : e.$context[t] = i;
99
+ }, j = (t, n = Symbol()) => function(e, i) {
100
+ return arguments.length === 0 ? s && n in s.$context ? s.$context[n] : t : arguments.length === 1 ? n in e.$context ? e.$context[n] : t : e.$context[n] = i;
106
101
  };
107
102
  export {
108
- P as Fragment,
103
+ F as Fragment,
109
104
  j as context,
110
105
  W as h,
111
106
  d as render
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ajo",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "ajo is a JavaScript view library for building user interfaces",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
package/readme.md CHANGED
@@ -51,7 +51,7 @@ function* Counter() {
51
51
  yield (
52
52
  <>
53
53
  <p>Count: {count}</p>
54
- <button onClick={increment}>Increment</button>
54
+ <button set:onclick={increment}>Increment</button>
55
55
  </>
56
56
  )
57
57
  }
package/types.ts CHANGED
@@ -6,7 +6,7 @@ declare module 'ajo' {
6
6
 
7
7
  type Props = Record<string, unknown>
8
8
 
9
- type AjoNode<TTag extends Type> = { nodeName: TTag } & TagProps<TTag>
9
+ type VNode<TTag extends Type> = { nodeName: TTag } & TagProps<TTag>
10
10
 
11
11
  type Children = any
12
12
 
@@ -31,7 +31,7 @@ declare module 'ajo' {
31
31
  [K in keyof TAttribute as `attr:${Exclude<K, symbol>}`]: TAttribute[K]
32
32
  }
33
33
 
34
- type Context<TArguments = Props> = {
34
+ type ComponentThis<TArguments = Props> = {
35
35
  $args: TArguments,
36
36
  $context: { [key: symbol]: unknown },
37
37
  render: () => void,
@@ -43,7 +43,7 @@ declare module 'ajo' {
43
43
  type Function<TArguments = Props> = (args: TArguments) => Children
44
44
 
45
45
  type Component<TArguments = Props, TTag extends Tag = 'div'> = {
46
- (this: ElementType<TTag> & Context<TArguments>, args: TArguments): Iterator<Children, unknown, unknown>
46
+ (this: ElementType<TTag> & ComponentThis<TArguments>, args: TArguments): Iterator<Children, unknown, unknown>
47
47
  } & (TTag extends 'div' ? { is?: TTag } : { is: TTag })
48
48
 
49
49
  type Ref<TComponent> = TComponent extends Component<infer TArguments, infer TTag>
@@ -67,9 +67,9 @@ declare module 'ajo' {
67
67
  : never
68
68
 
69
69
  function Fragment({ children }: ElementChildrenAttribute): typeof children
70
- function h<TTag extends Tag>(tag: TTag, props?: TagProps<TTag> | null, ...children: Array<unknown>): AjoNode<TTag>
70
+ function h<TTag extends Tag>(tag: TTag, props?: TagProps<TTag> | null, ...children: Array<unknown>): VNode<TTag>
71
71
  function render(h: Children, el: Element): void
72
- function context<T>(fallback?: T): { (el: ThisParameterType<Component<unknown, Tag>>, value?: T): T }
72
+ function context<T>(fallback?: T): (el?: ThisParameterType<Component<unknown, Tag>>, value?: T) => T
73
73
  }
74
74
 
75
75
  declare namespace JSX {