ajo 0.1.16 → 0.1.18

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{assign:$,entries:f,hasOwn:p}=Object,{isArray:u}=Array,a=e=>[...d(e)].join(""),d=function*(e){for(e of c(e))if(typeof e=="string")yield m(e);else{const{nodeName:t,skip:r,children:l=""}=e;let n="";for(const[i,o]of f(e))g.has(i)||i.startsWith("set:")||o==null||o===!1||(n+=o===!0?`${n} ${i}`:`${n} ${i}="${m(String(o))}"`);v.has(t)?yield`<${t}${n}>`:r?yield`<${t}${n}></${t}>`:typeof l=="string"?yield`<${t}${n}>${l}</${t}>`:(yield`<${t}${n}>`,yield*d(l),yield`</${t}>`)}},c=function*(e,t={value:""},r=!0){for(e of u(e)?e:[e])if(!(e==null||typeof e=="boolean"))if(p(e,"nodeName")){const{value:l}=t,{nodeName:n}=e;if(l&&(yield l,t.value=""),typeof n=="function")if(delete e.nodeName,n.constructor.name==="GeneratorFunction"){const i={},o=$({},n.attrs);for(const s in e){const y=e[s];s.startsWith("attr:")?o[s.slice(5)]=y:i[s]=y}o.nodeName=n.is??"div",o.children=k(n,i),yield o}else delete e.nodeName,yield*c(n(e),t,!1);else yield e}else u(e)?yield*c(e,t,!1):t.value+=e;r&&t.value&&(yield t.value)},v=new Set("area,base,br,col,command,embed,hr,img,input,keygen,link,meta,param,source,track,wbr".split(",")),g=new Set("nodeName,key,skip,memo,ref,children".split(",")),m=e=>e.replace(/[&<>"']/g,t=>`&#${t.charCodeAt(0)};`),k=(e,t)=>{let r,l;try{const n=e.call(r={$args:t,*[Symbol.iterator](){for(;;)yield t},$next(){l=a(n.next().value)},$throw(i){l=a(n.throw(i).value)},$return(){n.return()}},t);r.$next()}catch(n){r.$throw(n)}finally{r.$return()}return l};exports.html=d;exports.render=a;
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;
package/dist/html.js CHANGED
@@ -1,57 +1,64 @@
1
- const { assign: f, entries: m, hasOwn: p } = Object, { isArray: d } = Array, y = (e) => [...$(e)].join(""), $ = function* (e) {
2
- for (e of a(e))
3
- if (typeof e == "string") yield u(e);
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) {
2
+ for (e of c(e))
3
+ if (typeof e == "string") yield $(e);
4
4
  else {
5
- const { nodeName: t, skip: r, children: l = "" } = e;
5
+ const { nodeName: t, skip: o, children: r = "" } = e;
6
6
  let n = "";
7
- for (const [i, o] of m(e))
8
- k.has(i) || i.startsWith("set:") || o == null || o === !1 || (n += o === !0 ? `${n} ${i}` : `${n} ${i}="${u(String(o))}"`);
9
- v.has(t) ? yield `<${t}${n}>` : r ? yield `<${t}${n}></${t}>` : typeof l == "string" ? yield `<${t}${n}>${l}</${t}>` : (yield `<${t}${n}>`, yield* $(l), yield `</${t}>`);
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}>`);
10
10
  }
11
- }, a = function* (e, t = { value: "" }, r = !0) {
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 (p(e, "nodeName")) {
15
- const { value: l } = t, { nodeName: n } = e;
16
- if (l && (yield l, t.value = ""), typeof n == "function")
17
- if (delete e.nodeName, n.constructor.name === "GeneratorFunction") {
18
- const i = {}, o = f({}, n.attrs);
19
- for (const s in e) {
20
- const c = e[s];
21
- s.startsWith("attr:") ? o[s.slice(5)] = c : i[s] = c;
14
+ if (g(e, "nodeName")) {
15
+ const { value: r } = t, { nodeName: n } = e;
16
+ if (r && (yield r, t.value = ""), typeof n == "function")
17
+ if (n.constructor.name === "GeneratorFunction") {
18
+ const i = {}, l = v({}, n.attrs);
19
+ for (const a in e) {
20
+ const u = e[a];
21
+ a.startsWith("attr:") ? l[a.slice(5)] = u : i[a] = u;
22
22
  }
23
- o.nodeName = n.is ?? "div", o.children = w(n, i), yield o;
24
- } else delete e.nodeName, yield* a(n(e), t, !1);
23
+ l.nodeName = n.is ?? "div", l.children = S(n, i), yield l;
24
+ } else yield* c(n(e), t, !1);
25
25
  else yield e;
26
- } else d(e) ? yield* a(e, t, !1) : t.value += e;
27
- r && t.value && (yield t.value);
28
- }, v = 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(",")), u = (e) => e.replace(/[&<>"']/g, (t) => `&#${t.charCodeAt(0)};`), w = (e, t) => {
29
- let r, l;
26
+ } else d(e) ? yield* c(e, t, !1) : t.value += e;
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) => {
31
+ let o, r;
30
32
  try {
31
- const n = e.call(r = {
33
+ const n = e.call(o = {
32
34
  $args: t,
33
- *[Symbol.iterator]() {
34
- for (; ; ) yield t;
35
+ $context: p(s ? s.$context : null),
36
+ render() {
37
+ s !== o && o.$next();
35
38
  },
36
39
  $next() {
37
- l = y(n.next().value);
40
+ const i = s;
41
+ s = o, r = y(n.next().value), s = i;
38
42
  },
39
43
  $throw(i) {
40
- l = y(n.throw(i).value);
44
+ r = y(n.throw(i).value);
41
45
  },
42
46
  $return() {
43
47
  n.return();
44
48
  }
45
49
  }, t);
46
- r.$next();
50
+ o.$next();
47
51
  } catch (n) {
48
- r.$throw(n);
52
+ o.$throw(n);
49
53
  } finally {
50
- r.$return();
54
+ o.$return();
51
55
  }
52
- return l;
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;
53
59
  };
54
60
  export {
55
- $ as html,
61
+ A as context,
62
+ m as html,
56
63
  y as render
57
64
  };
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=({children:e})=>e,k=function(e,t){const{length:n}=arguments;return(t??(t={})).nodeName=e,"children"in t||n<3||(t.children=n===3?arguments[2]:S.call(arguments,2)),t},m=(e,t)=>{let n=t.firstChild;for(e of g(e)){let i=n;if(typeof e=="string"){for(;i&&i.nodeType!=3;)i=i.nextSibling;i?i.data!=e&&(i.data=e):i=document.createTextNode(e)}else{const{nodeName:o,key:a,skip:r,memo:s,ref:l,children:x}=e;for(;i&&!(i.localName===o&&(i.$key??(i.$key=a))==a);)i=i.nextSibling;if(i??(i=d(document.createElementNS(e.xmlns??o==="svg"?O:t.namespaceURI,o),{$key:a})),s==null||T(i.$memo,i.$memo=s)){const{$props:u}=i,$={};for(const c of w(d({},u,e))){if(A.has(c))continue;const f=$[c]=e[c];f!==(u==null?void 0:u[c])&&(c.startsWith("set:")?i[c.slice(4)]=f:f==null||f===!1?i.removeAttribute(c):i.setAttribute(c,f===!0?"":f))}i.$props=$,r||m(x,i),typeof l=="function"&&(i.$ref=l)(i)}}i===n?n=n.nextSibling:P(t,i,n)}for(;n;){const i=n.nextSibling;n.nodeType===1&&h(n),t.removeChild(n),n=i}},{isArray:y,prototype:{slice:S}}=Array,{keys:w,assign:d,hasOwn:b,setPrototypeOf:p,getPrototypeOf:v}=Object,O="http://www.w3.org/2000/svg",A=new Set("nodeName,key,skip,memo,ref,children".split(",")),T=(e,t)=>y(e)&&y(t)?e.some((n,i)=>n!==t[i]):e!==t,g=function*(e,t={value:""},n=!0){for(e of y(e)?e:[e])if(!(e==null||typeof e=="boolean"))if(b(e,"nodeName")){const{value:i}=t,{nodeName:o}=e;if(i&&(yield i,t.value=""),typeof o=="function")if(delete e.nodeName,o.constructor.name==="GeneratorFunction"){const a={},r=d({},o.attrs);for(const s of w(e)){const l=e[s];s.startsWith("attr:")?r[s.slice(5)]=l:s==="key"||s==="memo"?r[s]=l:a[s]=l}r.nodeName=o.is??"div",r.skip=!0,r.ref=C.bind(null,o,a),yield r}else yield*g(o(e),t,!1);else yield e}else y(e)?yield*g(e,t,!1):t.value+=e;n&&t.value&&(yield t.value)},C=(e,t,n)=>{n&&(n.$gen??(n.$gen=(new j(n),e)),n.$ref=F.bind(null,n),d(n.$args??(n.$args={}),t),n.$next())},F=(e,t)=>t??e.$return(),P=(e,t,n)=>{if(t.contains(document.activeElement)){const i=t.nextSibling;for(;n&&n!=t;){const o=n.nextSibling;e.insertBefore(n,i),n=o}}else e.insertBefore(t,n)},h=e=>{for(const n of e.children)h(n);const{$ref:t}=e;typeof t=="function"&&t(null)};class j{constructor(t){p(t,p(v(this),v(t)))}$next(){try{m((this.$it??(this.$it=this.$gen.call(this,this.$args))).next().value,this),typeof this.$ref=="function"&&this.$ref(this)}catch(t){this.$throw(t)}}$throw(t){var n;for(let i=this;i;i=i.parentNode)if(typeof((n=i.$it)==null?void 0:n.throw)=="function")try{return m(i.$it.throw(t).value,i)}catch{}throw t}$return(){var t;try{(t=this.$it)==null||t.return()}catch(n){this.$throw(n)}finally{this.$it=null}}}exports.Fragment=N;exports.h=k;exports.render=m;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=({children:i})=>i,b=function(i,e){const{length:t}=arguments;return(e??(e=v(null))).nodeName=i,"children"in e||t<3||(e.children=t===3?arguments[2]:O.call(arguments,2)),e},y=(i,e)=>{let t=e.firstChild;for(i of g(i)){let n=t;if(typeof i=="string"){for(;n&&n.nodeType!=3;)n=n.nextSibling;n?n.data!=i&&(n.data=i):n=document.createTextNode(i)}else{const{nodeName:o,key:a,skip:c,memo:s,ref:f,children:N}=i;for(;n&&!(n.localName===o&&(n.$key??(n.$key=a))==a);)n=n.nextSibling;if(n??(n=d(document.createElementNS(i.xmlns??o==="svg"?T:e.namespaceURI,o),{$key:a})),s==null||F(n.$memo,n.$memo=s)){const{$props:m}=n,x={};for(const l of w(d({},m,i))){if(C.has(l))continue;const u=x[l]=i[l];u!==(m==null?void 0:m[l])&&(l.startsWith("set:")?n[l.slice(4)]=u:u==null||u===!1?n.removeAttribute(l):n.setAttribute(l,u===!0?"":u))}n.$props=x,c||y(N,n),typeof f=="function"&&(n.$ref=f)(n)}}n===t?t=t.nextSibling:B(e,n,t)}for(;t;){const n=t.nextSibling;t.nodeType===1&&S(t),e.removeChild(t),t=n}},{isArray:$,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=(i,e)=>$(i)&&$(e)?i.some((t,n)=>t!==e[n]):i!==e,g=function*(i,e={value:""},t=!0){for(i of $(i)?i:[i])if(!(i==null||typeof i=="boolean"))if(A(i,"nodeName")){const{value:n}=e,{nodeName:o}=i;if(n&&(yield n,e.value=""),typeof o=="function")if(o.constructor.name==="GeneratorFunction"){const a={},c=d({},o.attrs);for(const s of w(i)){const f=i[s];s.startsWith("attr:")?c[s.slice(5)]=f:s==="key"||s==="memo"?c[s]=f:a[s]=f}c.nodeName=o.is??"div",c.skip=!0,c.ref=P.bind(null,o,a),yield c}else yield*g(o(i),e,!1);else yield i}else $(i)?yield*g(i,e,!1):e.value+=i;t&&e.value&&(yield e.value)},P=(i,e,t)=>{if(!t)return;t.$gen??(t.$gen=(new E(t),i)),t.$ref=j.bind(null,t);const{skip:n,...o}=e;d(t.$args??(t.$args={}),o),n||t.$next()},j=(i,e)=>e??i.$return(),B=(i,e,t)=>{if(e.contains(document.activeElement)){const n=e.nextSibling;for(;t&&t!=e;){const o=t.nextSibling;i.insertBefore(t,n),t=o}}else i.insertBefore(e,t)},S=i=>{for(const t of i.children)S(t);const{$ref:e}=i;typeof e=="function"&&e(null)};let r=null;class E{constructor(e){p(e,p(h(this),h(e))),e.$context=v((r==null?void 0:r.$context)??null)}render(){r!=null&&r.contains(this)||this.$next()}$next(){const e=r;r=this;try{y((this.$it??(this.$it=this.$gen.call(this,this.$args))).next().value,this),typeof this.$ref=="function"&&this.$ref(this)}catch(t){this.$throw(t)}finally{r=e}}$throw(e){var t;for(let n=this;n;n=n.parentNode)if(typeof((t=n.$it)==null?void 0:t.throw)=="function")try{return y(n.$it.throw(e).value,n)}catch{}throw e}$return(){var e;try{(e=this.$it)==null||e.return()}catch(t){this.$throw(t)}finally{this.$it=null}}}const W=(i,e=Symbol())=>function(t,n){return arguments.length===1?e in t.$context?t.$context[e]:i:t.$context[e]=n};exports.Fragment=k;exports.context=W;exports.h=b;exports.render=y;
package/dist/index.js CHANGED
@@ -1,96 +1,111 @@
1
- const E = ({ children: e }) => e, F = function(e, t) {
2
- const { length: n } = arguments;
3
- return (t ?? (t = {})).nodeName = e, "children" in t || n < 3 || (t.children = n === 3 ? arguments[2] : N.call(arguments, 2)), t;
4
- }, d = (e, t) => {
5
- let n = t.firstChild;
6
- for (e of $(e)) {
7
- let i = n;
8
- if (typeof e == "string") {
9
- for (; i && i.nodeType != 3; ) i = i.nextSibling;
10
- i ? i.data != e && (i.data = e) : i = document.createTextNode(e);
1
+ const P = ({ children: i }) => i, W = function(i, e) {
2
+ const { length: t } = arguments;
3
+ return (e ?? (e = v(null))).nodeName = i, "children" in e || t < 3 || (e.children = t === 3 ? arguments[2] : S.call(arguments, 2)), e;
4
+ }, d = (i, e) => {
5
+ let t = e.firstChild;
6
+ for (i of g(i)) {
7
+ let n = t;
8
+ if (typeof i == "string") {
9
+ for (; n && n.nodeType != 3; ) n = n.nextSibling;
10
+ n ? n.data != i && (n.data = i) : n = document.createTextNode(i);
11
11
  } else {
12
- const { nodeName: o, key: a, skip: r, memo: s, ref: l, children: h } = e;
13
- for (; i && !(i.localName === o && (i.$key ?? (i.$key = a)) == a); ) i = i.nextSibling;
14
- if (i ?? (i = y(document.createElementNS(e.xmlns ?? o === "svg" ? S : t.namespaceURI, o), { $key: a })), s == null || A(i.$memo, i.$memo = s)) {
15
- const { $props: u } = i, g = {};
16
- for (const c of w(y({}, u, e))) {
17
- if (b.has(c)) continue;
18
- const f = g[c] = e[c];
19
- f !== (u == null ? void 0 : u[c]) && (c.startsWith("set:") ? i[c.slice(4)] = f : f == null || f === !1 ? i.removeAttribute(c) : i.setAttribute(c, f === !0 ? "" : f));
12
+ const { nodeName: o, key: a, skip: c, memo: s, ref: f, children: k } = i;
13
+ for (; n && !(n.localName === o && (n.$key ?? (n.$key = a)) == a); ) n = n.nextSibling;
14
+ if (n ?? (n = $(document.createElementNS(i.xmlns ?? o === "svg" ? A : e.namespaceURI, o), { $key: a })), s == null || C(n.$memo, n.$memo = s)) {
15
+ const { $props: m } = n, x = {};
16
+ for (const l of w($({}, m, i))) {
17
+ if (O.has(l)) continue;
18
+ const u = x[l] = i[l];
19
+ u !== (m == null ? void 0 : m[l]) && (l.startsWith("set:") ? n[l.slice(4)] = u : u == null || u === !1 ? n.removeAttribute(l) : n.setAttribute(l, u === !0 ? "" : u));
20
20
  }
21
- i.$props = g, r || d(h, i), typeof l == "function" && (i.$ref = l)(i);
21
+ n.$props = x, c || d(k, n), typeof f == "function" && (n.$ref = f)(n);
22
22
  }
23
23
  }
24
- i === n ? n = n.nextSibling : T(t, i, n);
24
+ n === t ? t = t.nextSibling : E(e, n, t);
25
25
  }
26
- for (; n; ) {
27
- const i = n.nextSibling;
28
- n.nodeType === 1 && x(n), t.removeChild(n), n = i;
26
+ for (; t; ) {
27
+ const n = t.nextSibling;
28
+ t.nodeType === 1 && N(t), e.removeChild(t), t = n;
29
29
  }
30
- }, { isArray: m, prototype: { slice: N } } = Array, { keys: w, assign: y, hasOwn: k, setPrototypeOf: p, getPrototypeOf: v } = Object, S = "http://www.w3.org/2000/svg", b = new Set("nodeName,key,skip,memo,ref,children".split(",")), A = (e, t) => m(e) && m(t) ? e.some((n, i) => n !== t[i]) : e !== t, $ = function* (e, t = { value: "" }, n = !0) {
31
- for (e of m(e) ? e : [e])
32
- if (!(e == null || typeof e == "boolean"))
33
- if (k(e, "nodeName")) {
34
- const { value: i } = t, { nodeName: o } = e;
35
- if (i && (yield i, t.value = ""), typeof o == "function")
36
- if (delete e.nodeName, o.constructor.name === "GeneratorFunction") {
37
- const a = {}, r = y({}, o.attrs);
38
- for (const s of w(e)) {
39
- const l = e[s];
40
- s.startsWith("attr:") ? r[s.slice(5)] = l : s === "key" || s === "memo" ? r[s] = l : a[s] = l;
30
+ }, { isArray: y, prototype: { slice: S } } = Array, { create: v, keys: w, assign: $, 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 = (i, e) => y(i) && y(e) ? i.some((t, n) => t !== e[n]) : i !== e, g = function* (i, e = { value: "" }, t = !0) {
31
+ for (i of y(i) ? i : [i])
32
+ if (!(i == null || typeof i == "boolean"))
33
+ if (b(i, "nodeName")) {
34
+ const { value: n } = e, { nodeName: o } = i;
35
+ if (n && (yield n, e.value = ""), typeof o == "function")
36
+ if (o.constructor.name === "GeneratorFunction") {
37
+ const a = {}, c = $({}, o.attrs);
38
+ for (const s of w(i)) {
39
+ const f = i[s];
40
+ s.startsWith("attr:") ? c[s.slice(5)] = f : s === "key" || s === "memo" ? c[s] = f : a[s] = f;
41
41
  }
42
- r.nodeName = o.is ?? "div", r.skip = !0, r.ref = O.bind(null, o, a), yield r;
43
- } else yield* $(o(e), t, !1);
44
- else yield e;
45
- } else m(e) ? yield* $(e, t, !1) : t.value += e;
46
- n && t.value && (yield t.value);
47
- }, O = (e, t, n) => {
48
- n && (n.$gen ?? (n.$gen = (new B(n), e)), n.$ref = C.bind(null, n), y(n.$args ?? (n.$args = {}), t), n.$next());
49
- }, C = (e, t) => t ?? e.$return(), T = (e, t, n) => {
50
- if (t.contains(document.activeElement)) {
51
- const i = t.nextSibling;
52
- for (; n && n != t; ) {
53
- const o = n.nextSibling;
54
- e.insertBefore(n, i), n = o;
42
+ c.nodeName = o.is ?? "div", c.skip = !0, c.ref = T.bind(null, o, a), yield c;
43
+ } else yield* g(o(i), e, !1);
44
+ else yield i;
45
+ } else y(i) ? yield* g(i, e, !1) : e.value += i;
46
+ t && e.value && (yield e.value);
47
+ }, T = (i, e, t) => {
48
+ if (!t) return;
49
+ t.$gen ?? (t.$gen = (new F(t), i)), t.$ref = B.bind(null, t);
50
+ const { skip: n, ...o } = e;
51
+ $(t.$args ?? (t.$args = {}), o), n || t.$next();
52
+ }, B = (i, e) => e ?? i.$return(), E = (i, e, t) => {
53
+ if (e.contains(document.activeElement)) {
54
+ const n = e.nextSibling;
55
+ for (; t && t != e; ) {
56
+ const o = t.nextSibling;
57
+ i.insertBefore(t, n), t = o;
55
58
  }
56
- } else e.insertBefore(t, n);
57
- }, x = (e) => {
58
- for (const n of e.children) x(n);
59
- const { $ref: t } = e;
60
- typeof t == "function" && t(null);
59
+ } else i.insertBefore(e, t);
60
+ }, N = (i) => {
61
+ for (const t of i.children) N(t);
62
+ const { $ref: e } = i;
63
+ typeof e == "function" && e(null);
61
64
  };
62
- class B {
63
- constructor(t) {
64
- p(t, p(v(this), v(t)));
65
+ let r = null;
66
+ class F {
67
+ constructor(e) {
68
+ p(e, p(h(this), h(e))), e.$context = v((r == null ? void 0 : r.$context) ?? null);
69
+ }
70
+ render() {
71
+ r != null && r.contains(this) || this.$next();
65
72
  }
66
73
  $next() {
74
+ const e = r;
75
+ r = this;
67
76
  try {
68
77
  d((this.$it ?? (this.$it = this.$gen.call(this, this.$args))).next().value, this), typeof this.$ref == "function" && this.$ref(this);
69
78
  } catch (t) {
70
79
  this.$throw(t);
80
+ } finally {
81
+ r = e;
71
82
  }
72
83
  }
73
- $throw(t) {
74
- var n;
75
- for (let i = this; i; i = i.parentNode) if (typeof ((n = i.$it) == null ? void 0 : n.throw) == "function") try {
76
- return d(i.$it.throw(t).value, i);
84
+ $throw(e) {
85
+ var t;
86
+ for (let n = this; n; n = n.parentNode) if (typeof ((t = n.$it) == null ? void 0 : t.throw) == "function") try {
87
+ return d(n.$it.throw(e).value, n);
77
88
  } catch {
78
89
  }
79
- throw t;
90
+ throw e;
80
91
  }
81
92
  $return() {
82
- var t;
93
+ var e;
83
94
  try {
84
- (t = this.$it) == null || t.return();
85
- } catch (n) {
86
- this.$throw(n);
95
+ (e = this.$it) == null || e.return();
96
+ } catch (t) {
97
+ this.$throw(t);
87
98
  } finally {
88
99
  this.$it = null;
89
100
  }
90
101
  }
91
102
  }
103
+ const j = (i, e = Symbol()) => function(t, n) {
104
+ return arguments.length === 1 ? e in t.$context ? t.$context[e] : i : t.$context[e] = n;
105
+ };
92
106
  export {
93
- E as Fragment,
94
- F as h,
107
+ P as Fragment,
108
+ j as context,
109
+ W as h,
95
110
  d as render
96
111
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ajo",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
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
@@ -68,7 +68,7 @@ function* Counter() {
68
68
 
69
69
  const handleClick = () => {
70
70
  count++
71
- this.$next()
71
+ this.render()
72
72
  }
73
73
 
74
74
  while (true) yield (
@@ -264,7 +264,7 @@ function* ChatComponent(props) {
264
264
 
265
265
  message = event.target.value
266
266
 
267
- this.$next()
267
+ this.render()
268
268
  }
269
269
 
270
270
  const send = () => {
@@ -275,13 +275,13 @@ function* ChatComponent(props) {
275
275
 
276
276
  message = ''
277
277
 
278
- this.$next()
278
+ this.render()
279
279
  }
280
280
  }
281
281
 
282
282
  const handleConnectionOpen = () => {
283
283
  connected = true
284
- this.$next()
284
+ this.render()
285
285
  }
286
286
 
287
287
  const handleConnectionError = error => {
@@ -549,7 +549,7 @@ function* MultiStepForm({ initialData }) {
549
549
  currentStep++
550
550
 
551
551
  // Re-render with the next step
552
- this.$next()
552
+ this.render()
553
553
  }
554
554
 
555
555
  const handleRestart = () => {
@@ -558,7 +558,7 @@ function* MultiStepForm({ initialData }) {
558
558
  this.$return()
559
559
 
560
560
  // Re-render the component in its initial state
561
- this.$next()
561
+ this.render()
562
562
  }
563
563
 
564
564
  while (true) {
package/types.ts CHANGED
@@ -32,11 +32,12 @@ declare module 'ajo' {
32
32
  }
33
33
 
34
34
  type Context<TArguments = Props> = {
35
- $args: TArguments
35
+ $args: TArguments,
36
+ $context: { [key: symbol]: unknown },
37
+ render: () => void,
36
38
  $next: () => void
37
39
  $throw: (value?: unknown) => void
38
40
  $return: () => void
39
- [Symbol.iterator]: () => Iterator<TArguments, unknown, unknown>
40
41
  }
41
42
 
42
43
  type Function<TArguments = Props> = (args: TArguments) => Children
@@ -68,6 +69,7 @@ declare module 'ajo' {
68
69
  function Fragment({ children }: ElementChildrenAttribute): typeof children
69
70
  function h<TTag extends Tag>(tag: TTag, props?: TagProps<TTag> | null, ...children: Array<unknown>): AjoNode<TTag>
70
71
  function render(h: Children, el: Element): void
72
+ function context<T>(fallback?: T): { (el: ThisParameterType<Component<unknown, Tag>>, value?: T): T }
71
73
  }
72
74
 
73
75
  declare namespace JSX {