ajo 0.1.20 → 0.1.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/dist/html.cjs CHANGED
@@ -1 +1 @@
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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const{isArray:m,from:$}=Array,p="",{create:v,assign:g,entries:x,prototype:{hasOwnProperty:w},hasOwn:k=(e,t)=>w.call(e,t)}=Object,c=e=>$(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[l,i]of x(e))N.has(l)||l.startsWith("set:")||i==null||i===!1||(n+=i===!0?` ${l}`:` ${l}="${f(String(i))}"`);S.has(t)?yield`<${t}${n}>`:o?yield`<${t}${n}></${t}>`:(yield`<${t}${n}>`,typeof r=="string"&&r.startsWith(p)?yield r.slice(1):yield*d(r),yield`</${t}>`)}},u=function*(e,t={value:""},o=!0){for(e of m(e)?e:[e])if(!(e==null||typeof e=="boolean"))if(k(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=g({},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=O(n,l),yield i}else yield*u(n(e),t,!1);else yield e}else m(e)?yield*u(e,t,!1):t.value+=e;o&&t.value&&(yield t.value)},S=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(",")),f=e=>e.replace(/[&<>"']/g,t=>`&#${t.charCodeAt(0)};`);let s=null;const O=(e,t)=>{let o,r;try{const n=e.call(o={$args:t,$context:v((s==null?void 0: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 p+r},j=(e,t=Symbol())=>function(){const o=this??s;return o?arguments.length===0?t in o.$context?o.$context[t]:e:o.$context[t]=arguments[0]:e};exports.context=j;exports.html=d;exports.render=c;
package/dist/html.js CHANGED
@@ -1,64 +1,65 @@
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) {
1
+ const { isArray: d, from: $ } = Array, m = "", { create: v, assign: x, entries: g, prototype: { hasOwnProperty: w }, hasOwn: k = (e, t) => w.call(e, t) } = Object, y = (e) => $(p(e)).join(""), p = function* (e) {
2
2
  for (e of c(e))
3
- if (typeof e == "string") yield y(e);
3
+ if (typeof e == "string") yield f(e);
4
4
  else {
5
- const { nodeName: t, skip: o, children: r = "" } = e;
5
+ const { nodeName: t, skip: o, children: l = "" } = e;
6
6
  let n = "";
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}>`);
7
+ for (const [r, i] of g(e))
8
+ S.has(r) || r.startsWith("set:") || i == null || i === !1 || (n += i === !0 ? ` ${r}` : ` ${r}="${f(String(i))}"`);
9
+ N.has(t) ? yield `<${t}${n}>` : o ? yield `<${t}${n}></${t}>` : (yield `<${t}${n}>`, typeof l == "string" && l.startsWith(m) ? yield l.slice(1) : yield* p(l), 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 (N(e, "nodeName")) {
15
- const { value: r } = t, { nodeName: n } = e;
16
- if (r && (yield r, t.value = ""), typeof n == "function")
14
+ if (k(e, "nodeName")) {
15
+ const { value: l } = t, { nodeName: n } = e;
16
+ if (l && (yield l, t.value = ""), typeof n == "function")
17
17
  if (n.constructor.name === "GeneratorFunction") {
18
- const i = {}, s = v({}, n.attrs);
18
+ const r = {}, i = x({}, n.attrs);
19
19
  for (const a in e) {
20
20
  const u = e[a];
21
- a.startsWith("attr:") ? s[a.slice(5)] = u : i[a] = u;
21
+ a.startsWith("attr:") ? i[a.slice(5)] = u : r[a] = u;
22
22
  }
23
- s.nodeName = n.is ?? "div", s.children = A(n, i), yield s;
23
+ i.nodeName = n.is ?? "div", i.children = A(n, r), yield i;
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
- }, 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;
28
+ }, N = 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(",")), f = (e) => e.replace(/[&<>"']/g, (t) => `&#${t.charCodeAt(0)};`);
29
+ let s = null;
30
30
  const A = (e, t) => {
31
- let o, r;
31
+ let o, l;
32
32
  try {
33
33
  const n = e.call(o = {
34
34
  $args: t,
35
- $context: x((l == null ? void 0 : l.$context) ?? null),
35
+ $context: v((s == null ? void 0 : s.$context) ?? null),
36
36
  render() {
37
- l !== o && o.$next();
37
+ s !== o && o.next();
38
38
  },
39
- $next() {
40
- const i = l;
41
- l = o, r = $(n.next().value), l = i;
39
+ next() {
40
+ const r = s;
41
+ s = o, l = y(n.next().value), s = r;
42
42
  },
43
- $throw(i) {
44
- r = $(n.throw(i).value);
43
+ throw(r) {
44
+ l = y(n.throw(r).value);
45
45
  },
46
- $return() {
46
+ return() {
47
47
  n.return();
48
48
  }
49
49
  }, t);
50
- o.$next();
50
+ o.next();
51
51
  } catch (n) {
52
- o.$throw(n);
52
+ o.throw(n);
53
53
  } finally {
54
- o.$return();
54
+ o.return();
55
55
  }
56
- return f + 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;
56
+ return m + l;
57
+ }, O = (e, t = Symbol()) => function() {
58
+ const o = this ?? s;
59
+ return o ? arguments.length === 0 ? t in o.$context ? o.$context[t] : e : o.$context[t] = arguments[0] : e;
59
60
  };
60
61
  export {
61
62
  O as context,
62
- m as html,
63
- $ as render
63
+ p as html,
64
+ y as render
64
65
  };
package/dist/index.cjs CHANGED
@@ -1 +1 @@
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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=({children:t})=>t,N=function(t,n){return(n??(n=$(null))).nodeName=t,"children"in n||arguments.length<3||(n.children=arguments.length===3?arguments[2]:k.call(arguments,2)),n},d=(t,n)=>{let e=n.firstChild;for(t of h(t)){let o=e;if(typeof t=="string"){for(;o&&o.nodeType!=3;)o=o.nextSibling;o?o.data!=t&&(o.data=t):o=document.createTextNode(t)}else{const{nodeName:i,key:a,skip:c,memo:s,ref:f,children:w}=t;for(;o&&!(o.localName===i&&(o.$key??(o.$key=a))==a);)o=o.nextSibling;if(o??(o=m(document.createElementNS(t.xmlns??i==="svg"?O:n.namespaceURI,i),{$key:a})),s==null||F(o.$memo,o.$memo=s)){const{$props:y}=o,x={};for(const l of p(m({},y,t))){if(T.has(l))continue;const u=x[l]=t[l];u!==(y==null?void 0:y[l])&&(l.startsWith("set:")?o[l.slice(4)]=u:u==null||u===!1?o.removeAttribute(l):o.setAttribute(l,u===!0?"":u))}o.$props=x,c||d(w,o),typeof f=="function"&&(o.$ref=f)(o)}}o===e?e=e.nextSibling:C(n,o,e)}for(;e;){const o=e.nextSibling;e.nodeType===1&&v(e),n.removeChild(e),e=o}},{isArray:g,prototype:{slice:k}}=Array,{create:$,assign:m,keys:p,prototype:{hasOwnProperty:b},hasOwn:A=(t,n)=>b.call(t,n)}=Object,O="http://www.w3.org/2000/svg",T=new Set("nodeName,key,skip,memo,ref,children".split(",")),F=(t,n)=>g(t)&&g(n)?t.some((e,o)=>e!==n[o]):t!==n,h=function*(t,n={value:""},e=!0){for(t of g(t)?t:[t])if(!(t==null||typeof t=="boolean"))if(A(t,"nodeName")){const{value:o}=n,{nodeName:i}=t;if(o&&(yield o,n.value=""),typeof i=="function")if(i.constructor.name==="GeneratorFunction"){const a={},c=m({},i.attrs);for(const s of p(t)){const f=t[s];s.startsWith("attr:")?c[s.slice(5)]=f:s==="key"||s==="memo"?c[s]=f:a[s]=f}c.nodeName=i.is??"div",c.skip=!0,c.ref=j.bind(null,i,a),yield c}else yield*h(i(t),n,!1);else yield t}else g(t)?yield*h(t,n,!1):n.value+=t;e&&n.value&&(yield n.value)},j=(t,n,e)=>{if(!e)return;e.$generator??(e.$generator=(m(e,E),e.$context??(e.$context=$((r==null?void 0:r.$context)??null)),t));const{skip:o,ref:i,...a}=n;e.$ref=B.bind(null,i,e),m(e.$args??(e.$args={}),a),o||e.next()},B=(t,n,e)=>{typeof t=="function"&&t(e),e||n.return()},C=(t,n,e)=>{if(n.contains(document.activeElement)){const o=n.nextSibling;for(;e&&e!=n;){const i=e.nextSibling;t.insertBefore(e,o),e=i}}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 r=null;const E={render(){r!=null&&r.contains(this)||this.next()},next(){const t=r;r=this;try{d((this.$iterator??(this.$iterator=this.$generator.call(this,this.$args))).next().value,this),typeof this.$ref=="function"&&this.$ref(this)}catch(n){this.throw(n)}finally{r=t}},throw(t){var n;for(let e=this;e;e=e.parentNode)if(typeof((n=e.$iterator)==null?void 0:n.throw)=="function")try{return d(e.$iterator.throw(t).value,e)}catch{}throw t},return(){var t;try{(t=this.$iterator)==null||t.return()}catch(n){this.throw(n)}finally{this.$iterator=null}}},P=(t,n=Symbol())=>function(){const e=this??r;return e?arguments.length===0?n in e.$context?e.$context[n]:t:e.$context[n]=arguments[0]:t};exports.Fragment=S;exports.context=P;exports.h=N;exports.render=d;
package/dist/index.js CHANGED
@@ -1,24 +1,23 @@
1
1
  const F = ({ children: t }) => t, W = function(t, n) {
2
- const { length: e } = arguments;
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) => {
2
+ return (n ?? (n = h(null))).nodeName = t, "children" in n || arguments.length < 3 || (n.children = arguments.length === 3 ? arguments[2] : N.call(arguments, 2)), n;
3
+ }, g = (t, n) => {
5
4
  let e = n.firstChild;
6
- for (t of g(t)) {
5
+ for (t of x(t)) {
7
6
  let i = e;
8
7
  if (typeof t == "string") {
9
8
  for (; i && i.nodeType != 3; ) i = i.nextSibling;
10
9
  i ? i.data != t && (i.data = t) : i = document.createTextNode(t);
11
10
  } else {
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));
11
+ const { nodeName: o, key: a, skip: c, memo: s, ref: f, children: w } = t;
12
+ for (; i && !(i.localName === o && (i.$key ?? (i.$key = a)) == a); ) i = i.nextSibling;
13
+ if (i ?? (i = m(document.createElementNS(t.xmlns ?? o === "svg" ? b : n.namespaceURI, o), { $key: a })), s == null || O(i.$memo, i.$memo = s)) {
14
+ const { $props: y } = i, $ = {};
15
+ for (const l of p(m({}, y, t))) {
16
+ if (A.has(l)) continue;
17
+ const u = $[l] = t[l];
18
+ u !== (y == null ? void 0 : y[l]) && (l.startsWith("set:") ? i[l.slice(4)] = u : u == null || u === !1 ? i.removeAttribute(l) : i.setAttribute(l, u === !0 ? "" : u));
20
19
  }
21
- i.$props = x, c || d(w, i), typeof f == "function" && (i.$ref = f)(i);
20
+ i.$props = $, c || g(w, i), typeof f == "function" && (i.$ref = f)(i);
22
21
  }
23
22
  }
24
23
  i === e ? e = e.nextSibling : C(n, i, e);
@@ -27,29 +26,31 @@ const F = ({ children: t }) => t, W = function(t, n) {
27
26
  const i = e.nextSibling;
28
27
  e.nodeType === 1 && v(e), n.removeChild(e), e = i;
29
28
  }
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])
29
+ }, { isArray: d, 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) => d(t) && d(n) ? t.some((e, i) => e !== n[i]) : t !== n, x = function* (t, n = { value: "" }, e = !0) {
30
+ for (t of d(t) ? t : [t])
32
31
  if (!(t == null || typeof t == "boolean"))
33
32
  if (k(t, "nodeName")) {
34
33
  const { value: i } = n, { nodeName: o } = t;
35
34
  if (i && (yield i, n.value = ""), typeof o == "function")
36
35
  if (o.constructor.name === "GeneratorFunction") {
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;
36
+ const a = {}, c = m({}, o.attrs);
37
+ for (const s of p(t)) {
38
+ const f = t[s];
39
+ s.startsWith("attr:") ? c[s.slice(5)] = f : s === "key" || s === "memo" ? c[s] = f : a[s] = f;
41
40
  }
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);
41
+ c.nodeName = o.is ?? "div", c.skip = !0, c.ref = T.bind(null, o, a), yield c;
42
+ } else yield* x(o(t), n, !1);
44
43
  else yield t;
45
- } else y(t) ? yield* g(t, n, !1) : n.value += t;
44
+ } else d(t) ? yield* x(t, n, !1) : n.value += t;
46
45
  e && n.value && (yield n.value);
47
46
  }, T = (t, n, e) => {
48
47
  if (!e) return;
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) => {
48
+ e.$generator ?? (e.$generator = (m(e, E), e.$context ?? (e.$context = h((r == null ? void 0 : r.$context) ?? null)), t));
49
+ const { skip: i, ref: o, ...a } = n;
50
+ e.$ref = B.bind(null, o, e), m(e.$args ?? (e.$args = {}), a), i || e.next();
51
+ }, B = (t, n, e) => {
52
+ typeof t == "function" && t(e), e || n.return();
53
+ }, C = (t, n, e) => {
53
54
  if (n.contains(document.activeElement)) {
54
55
  const i = n.nextSibling;
55
56
  for (; e && e != n; ) {
@@ -62,46 +63,47 @@ const F = ({ children: t }) => t, W = function(t, n) {
62
63
  const { $ref: n } = t;
63
64
  typeof n == "function" && n(null);
64
65
  };
65
- let s = null;
66
+ let r = null;
66
67
  const E = {
67
68
  render() {
68
- s != null && s.contains(this) || this.$next();
69
+ r != null && r.contains(this) || this.next();
69
70
  },
70
- $next() {
71
- const t = s;
72
- s = this;
71
+ next() {
72
+ const t = r;
73
+ r = this;
73
74
  try {
74
- d((this.$it ?? (this.$it = this.$gen.call(this, this.$args))).next().value, this), typeof this.$ref == "function" && this.$ref(this);
75
+ g((this.$iterator ?? (this.$iterator = this.$generator.call(this, this.$args))).next().value, this), typeof this.$ref == "function" && this.$ref(this);
75
76
  } catch (n) {
76
- this.$throw(n);
77
+ this.throw(n);
77
78
  } finally {
78
- s = t;
79
+ r = t;
79
80
  }
80
81
  },
81
- $throw(t) {
82
+ throw(t) {
82
83
  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);
84
+ for (let e = this; e; e = e.parentNode) if (typeof ((n = e.$iterator) == null ? void 0 : n.throw) == "function") try {
85
+ return g(e.$iterator.throw(t).value, e);
85
86
  } catch {
86
87
  }
87
88
  throw t;
88
89
  },
89
- $return() {
90
+ return() {
90
91
  var t;
91
92
  try {
92
- (t = this.$it) == null || t.return();
93
+ (t = this.$iterator) == null || t.return();
93
94
  } catch (n) {
94
- this.$throw(n);
95
+ this.throw(n);
95
96
  } finally {
96
- this.$it = null;
97
+ this.$iterator = null;
97
98
  }
98
99
  }
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;
100
+ }, j = (t, n = Symbol()) => function() {
101
+ const e = this ?? r;
102
+ return e ? arguments.length === 0 ? n in e.$context ? e.$context[n] : t : e.$context[n] = arguments[0] : t;
101
103
  };
102
104
  export {
103
105
  F as Fragment,
104
106
  j as context,
105
107
  W as h,
106
- d as render
108
+ g as render
107
109
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ajo",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
4
4
  "description": "ajo is a JavaScript view library for building user interfaces",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
@@ -23,10 +23,10 @@
23
23
  "types.ts"
24
24
  ],
25
25
  "devDependencies": {
26
- "@types/node": "^20.14.10",
27
- "jsdom": "24.1.0",
28
- "vite": "5.3.3",
29
- "vitest": "2.0.1"
26
+ "@types/node": "^22.2.0",
27
+ "jsdom": "24.1.1",
28
+ "vite": "5.4.0",
29
+ "vitest": "2.0.5"
30
30
  },
31
31
  "keywords": [
32
32
  "ui",
package/readme.md CHANGED
@@ -264,14 +264,14 @@ const StatelessComponent = () => {
264
264
  // In a stateful component:
265
265
  function* StatefulComponent() {
266
266
  while (true) {
267
- const theme = ThemeContext(this)
267
+ const theme = ThemeContext()
268
268
  yield <div>Current theme: {theme}</div>
269
269
  }
270
270
  }
271
271
 
272
272
  // Setting context value:
273
273
  function* App() {
274
- ThemeContext(this, 'dark')
274
+ ThemeContext('dark')
275
275
  while (true) {
276
276
  yield (
277
277
  <>
@@ -313,9 +313,9 @@ Component methods:
313
313
  }
314
314
  ```
315
315
 
316
- - `this.$next()`: Advances the generator to the next yield point. It's automatically called by `this.render()` and is rarely used directly.
316
+ - `this.next()`: Advances the generator to the next yield point. It's automatically called by `this.render()` and is rarely used directly.
317
317
 
318
- - `this.$throw(error)`: Throws an error in the generator. Useful for error propagation and creating error boundaries. Ajo automatically calls this method when an error occurs during rendering.
318
+ - `this.throw(error)`: Throws an error in the generator. Useful for error propagation and creating error boundaries. Ajo automatically calls this method when an error occurs during rendering.
319
319
 
320
320
  ```javascript
321
321
  function* ErrorBoundary(props) {
@@ -329,14 +329,14 @@ Component methods:
329
329
  }
330
330
  ```
331
331
 
332
- - `this.$return()`: Completes the generator execution. It's automatically called by Ajo when a component is unmounted, but can be used manually to reset a component's state.
332
+ - `this.return()`: Completes the generator execution. It's automatically called by Ajo when a component is unmounted, but can be used manually to reset a component's state.
333
333
 
334
334
  ```javascript
335
335
  function* ResetableComponent() {
336
336
  let count = 0
337
337
  const reset = () => {
338
- this.$return() // Reset the generator
339
- this.render() // Re-render from the beginning
338
+ this.return() // Reset the generator
339
+ this.render() // Re-render from the beginning
340
340
  }
341
341
  while (true) {
342
342
  yield (
@@ -360,7 +360,7 @@ Component methods:
360
360
  }
361
361
  ```
362
362
 
363
- These methods provide powerful control over the component's lifecycle and state management, allowing for efficient and flexible UI updates. Note that `this.$throw()` and `this.$return()` are often called automatically by Ajo in response to errors or component unmounting, respectively, but can also be used manually when needed.
363
+ These methods provide powerful control over the component's lifecycle and state management, allowing for efficient and flexible UI updates. Note that `this.throw()` and `this.return()` are often called automatically by Ajo in response to errors or component unmounting, respectively, but can also be used manually when needed.
364
364
 
365
365
  ### `ajo/html` module
366
366
 
package/types.ts CHANGED
@@ -4,9 +4,9 @@ declare module 'ajo' {
4
4
 
5
5
  type Type = Tag | Function | Component
6
6
 
7
- type Props = Record<string, unknown>
7
+ type Attrs = Record<string, unknown>
8
8
 
9
- type VNode<TTag extends Type> = { nodeName: TTag } & TagProps<TTag>
9
+ type VNode<TTag extends Type> = { nodeName: TTag } & Attrs
10
10
 
11
11
  type Children = any
12
12
 
@@ -16,66 +16,56 @@ declare module 'ajo' {
16
16
  ? SVGElementTagNameMap[TTag]
17
17
  : never
18
18
 
19
- type AjoProps<TElement> = {
19
+ type AjoAttrs<TElement> = {
20
20
  key: unknown
21
21
  skip: boolean
22
22
  memo: unknown
23
23
  ref: (el: TElement | null) => void
24
24
  } & ElementChildrenAttribute
25
25
 
26
- type SetProps<TTag = Tag> = {
26
+ type PropSetter<TTag = Tag> = {
27
27
  [K in keyof ElementType<TTag> as `set:${Exclude<K, symbol>}`]: ElementType<TTag>[K]
28
28
  }
29
29
 
30
- type AttrProps<TAttribute = Props> = {
31
- [K in keyof TAttribute as `attr:${Exclude<K, symbol>}`]: TAttribute[K]
30
+ type AttrSetter = {
31
+ [key: `attr:${string}`]: unknown
32
32
  }
33
33
 
34
- type ComponentThis<TArguments = Props> = {
34
+ type Function<TArguments extends Attrs = Attrs> = (args: TArguments) => Children
35
+
36
+ type Component<TArguments extends Attrs = Attrs, TTag extends Tag = 'div'> = {
37
+ (this: ComponentElement<TArguments, TTag>, args: ComponentProps<TArguments, TTag>): Iterator<Children, unknown, unknown>
38
+ } & (TTag extends 'div' ? { is?: TTag } : { is: TTag })
39
+
40
+ type ComponentProps<TArguments extends Attrs = Attrs, TTag extends Tag = 'div'> =
41
+ Partial<PropSetter<TTag> & AjoAttrs<ComponentElement<TArguments, TTag>>> &
42
+ AttrSetter &
43
+ TArguments
44
+
45
+ type ComponentElement<TArguments extends Attrs = Attrs, TTag extends Tag = Tag> = ElementType<TTag> & {
35
46
  $args: TArguments,
36
47
  $context: { [key: symbol]: unknown },
37
48
  render: () => void,
38
- $next: () => void
39
- $throw: (value?: unknown) => void
40
- $return: () => void
49
+ next: () => void
50
+ throw: (value?: unknown) => void
51
+ return: () => void
41
52
  }
42
53
 
43
- type Function<TArguments = Props> = (args: TArguments) => Children
44
-
45
- type Component<TArguments = Props, TTag extends Tag = 'div'> = {
46
- (this: ElementType<TTag> & ComponentThis<TArguments>, args: TArguments): Iterator<Children, unknown, unknown>
47
- } & (TTag extends 'div' ? { is?: TTag } : { is: TTag })
48
-
49
- type Ref<TComponent> = TComponent extends Component<infer TArguments, infer TTag>
50
- ? Component<TArguments & { ref: (el: ThisParameterType<Ref<TComponent>> | null) => void }, TTag>
51
- : never
52
-
53
54
  type IntrinsicElements = {
54
- [TTag in Tag]: Partial<SetProps<TTag> & AjoProps<ElementType<TTag>>> & Props
55
+ [TTag in Tag]: Partial<PropSetter<TTag> & AjoAttrs<ElementType<TTag>>> & Attrs
55
56
  }
56
57
 
57
- type IntrinsicAttributes = Partial<Omit<AjoProps<ElementType<Tag>>, 'skip' | 'ref'>> & AttrProps
58
-
59
58
  type ElementChildrenAttribute = { children: Children }
60
59
 
61
- type TagProps<TTag extends Type> = TTag extends Tag
62
- ? IntrinsicElements[TTag] & IntrinsicAttributes
63
- : TTag extends Function<infer TArguments>
64
- ? TArguments
65
- : TTag extends Component<infer TArguments>
66
- ? TArguments
67
- : never
68
-
69
60
  function Fragment({ children }: ElementChildrenAttribute): typeof children
70
- function h<TTag extends Tag>(tag: TTag, props?: TagProps<TTag> | null, ...children: Array<unknown>): VNode<TTag>
61
+ function h<TTag extends Tag>(tag: TTag, props?: Attrs | null, ...children: Array<unknown>): VNode<TTag>
71
62
  function render(h: Children, el: Element): void
72
- function context<T>(fallback?: T): (el?: ThisParameterType<Component<unknown, Tag>>, value?: T) => T
63
+ function context<T>(fallback?: T): (value?: T) => T
73
64
  }
74
65
 
75
66
  declare namespace JSX {
76
67
  type ElementChildrenAttribute = import('ajo').ElementChildrenAttribute
77
68
  type IntrinsicElements = import('ajo').IntrinsicElements
78
- type IntrinsicAttributes = import('ajo').IntrinsicAttributes
79
69
  }
80
70
 
81
71
  declare namespace React {