ajo 0.1.25 → 0.1.26

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 a=require("./context.cjs"),b=new Set(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),S=new Set(["key","skip","memo","ref"]),w=new Set(["nodeName","children"]),$=Symbol.for("ajo.args"),g=e=>e.replace(/[&<>"']/g,r=>`&#${r.charCodeAt(0)};`),u=()=>{},v=e=>[...y(e)].join(""),y=function*(e,{alloc:r=u,push:n=u,placeholder:t=u}={}){for(e of f(e,{alloc:r,push:n,placeholder:t}))typeof e=="string"?yield g(e):yield*x(e,{alloc:r,push:n,placeholder:t})},x=function*(e,r){const{nodeName:n,children:t}=e;let l="";for(const i in e)w.has(i)||i.startsWith("set:")||e[i]==null||e[i]===!1||(e[i]===!0?l+=` ${i}`:l+=` ${i}="${g(String(e[i]))}"`);b.has(n)?yield`<${n}${l}>`:(yield`<${n}${l}>`,t!=null&&(yield*y(t,r)),yield`</${n}>`)},f=function*(e,r){if(e==null)return;const n=typeof e;if(n!="boolean")if(n=="string")yield e;else if(n=="number"||n=="bigint")yield String(e);else if(Symbol.iterator in e)for(e of e)yield*f(e,r);else"nodeName"in e?typeof e.nodeName=="function"?yield*A(e,r):yield o(e,r):yield String(e)},A=function*({nodeName:e,fallback:r=e.fallback,...n},t){const l=e.constructor.name;e.src?yield j(e.src,n,t):l=="GeneratorFunction"?yield G(e,n,t):l=="AsyncGeneratorFunction"?yield C(e,r,n,t):(n=e(n),typeof(n==null?void 0:n.then)=="function"?yield O(r,n,t):yield*f(n,t))},j=(e,r,n)=>{const t=n.alloc();return n.push({id:t,src:e,h:o(r,n),done:!0}),n.placeholder(t)},G=(e,r,n)=>{var p,m;const t={...e.attrs},l={...e.args};for(const c in r)c.startsWith("attr:")?t[c.slice(5)]=r[c]:S.has(c)||c.startsWith("set:")?t[c]=r[c]:l[c]=r[c];const i={[a.Context]:Object.create(((p=a.current())==null?void 0:p[a.Context])??null),[$]:l,render:u,next:u,return:u,throw:c=>{throw c}},s=e.call(i,l),d=a.current();a.current(i);try{const c=[...f(s.next().value,n)];return{...t,nodeName:e.is??"div",children:c.length==1?c[0]:c}}finally{(m=s.return)==null||m.call(s),a.current(d)}},C=(e,r,n,t)=>{const l=t.alloc();return Promise.resolve().then(async()=>{var s;const i=e(n);t={...t,alloc:(d=l)=>t.alloc(d)};try{for(n=await i.next();!n.done;)t.push({id:l,h:o(n.value,t),done:!1}),n=await i.next();t.push({id:l,h:o(n.value,t),done:!0})}catch(d){t.push({id:l,h:o(d,t),done:!0})}finally{(s=i.return)==null||s.call(i)}}),t.placeholder(l,r)},O=(e,r,n)=>{const t=n.alloc();return r.then(l=>n.push({id:t,h:o(l,{...n,alloc:(i=t)=>n.alloc(i)}),done:!0})),n.placeholder(t,e)},o=({key:e,skip:r,memo:n,ref:t,...l},i)=>{if("children"in l){const s=[...f(l.children,i)];s.length?l.children=s.length==1?s[0]:s:delete l.children}return l};exports.html=y;exports.render=v;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./context.cjs"),m=new Set(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),g=new Set(["key","skip","memo","ref"]),b=new Set(["nodeName","children"]),S=Symbol.for("ajo.args"),y=e=>e.replace(/[&<>"']/g,r=>`&#${r.charCodeAt(0)};`),u=()=>{},w=e=>[...f(e)].join(""),f=function*(e,{alloc:r=u,push:t=u,placeholder:n=u}={}){for(e of d(e,{alloc:r,push:t,placeholder:n}))typeof e=="string"?yield y(e):yield*$(e,{alloc:r,push:t,placeholder:n})},$=function*(e,r){const{nodeName:t,children:n}=e;let l="";for(const i in e)b.has(i)||i.startsWith("set:")||e[i]==null||e[i]===!1||(e[i]===!0?l+=` ${i}`:l+=` ${i}="${y(String(e[i]))}"`);m.has(t)?yield`<${t}${l}>`:(yield`<${t}${l}>`,n!=null&&(yield*f(n,r)),yield`</${t}>`)},d=function*(e,r){if(e==null)return;const t=typeof e;if(t!="boolean")if(t=="string")yield e;else if(t=="number"||t=="bigint")yield String(e);else if(Symbol.iterator in e)for(e of e)yield*d(e,r);else"nodeName"in e?typeof e.nodeName=="function"?yield*v(e,r):yield o(e,r):yield String(e)},v=function*({nodeName:e,fallback:r=e.fallback,...t},n){const l=e.constructor.name;e.src?yield x(e.src,t,n):l=="GeneratorFunction"?yield A(e,t,n):l=="AsyncGeneratorFunction"?yield j(e,r,t,n):(t=e(t),typeof t?.then=="function"?yield G(r,t,n):yield*d(t,n))},x=(e,r,t)=>{const n=t.alloc();return t.push({id:n,src:e,h:o(r,t),done:!0}),t.placeholder(n)},A=(e,r,t)=>{const n={...e.attrs},l={...e.args};for(const c in r)c.startsWith("attr:")?n[c.slice(5)]=r[c]:g.has(c)||c.startsWith("set:")?n[c]=r[c]:l[c]=r[c];const i={[a.Context]:Object.create(a.current()?.[a.Context]??null),[S]:l,next:u,return:u,throw:c=>{throw c}},s=e.call(i,l),p=a.current();a.current(i);try{const c=[...d(s.next().value,t)];return{...n,nodeName:e.is??"div",children:c.length==1?c[0]:c}}finally{s.return?.(),a.current(p)}},j=(e,r,t,n)=>{const l=n.alloc();return Promise.resolve().then(async()=>{const i=e(t);n={...n,alloc:(s=l)=>n.alloc(s)};try{for(t=await i.next();!t.done;)n.push({id:l,h:o(t.value,n),done:!1}),t=await i.next();n.push({id:l,h:o(t.value,n),done:!0})}catch(s){n.push({id:l,h:o(s,n),done:!0})}finally{i.return?.()}}),n.placeholder(l,r)},G=(e,r,t)=>{const n=t.alloc();return r.then(l=>t.push({id:n,h:o(l,{...t,alloc:(i=n)=>t.alloc(i)}),done:!0})),t.placeholder(n,e)},o=({key:e,skip:r,memo:t,ref:n,...l},i)=>{if("children"in l){const s=[...d(l.children,i)];s.length?l.children=s.length==1?s[0]:s:delete l.children}return l};exports.html=f;exports.render=w;
package/dist/html.js CHANGED
@@ -1,77 +1,74 @@
1
- import { Context as m, current as f } from "./context.js";
2
- const w = /* @__PURE__ */ new Set(["area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]), S = /* @__PURE__ */ new Set(["key", "skip", "memo", "ref"]), $ = /* @__PURE__ */ new Set(["nodeName", "children"]), v = Symbol.for("ajo.args"), g = (e) => e.replace(/[&<>"']/g, (r) => `&#${r.charCodeAt(0)};`), a = () => {
3
- }, O = (e) => [...b(e)].join(""), b = function* (e, { alloc: r = a, push: n = a, placeholder: t = a } = {}) {
4
- for (e of u(e, { alloc: r, push: n, placeholder: t }))
5
- typeof e == "string" ? yield g(e) : yield* x(e, { alloc: r, push: n, placeholder: t });
6
- }, x = function* (e, r) {
7
- const { nodeName: n, children: t } = e;
8
- let l = "";
9
- for (const i in e)
10
- $.has(i) || i.startsWith("set:") || e[i] == null || e[i] === !1 || (e[i] === !0 ? l += ` ${i}` : l += ` ${i}="${g(String(e[i]))}"`);
11
- w.has(n) ? yield `<${n}${l}>` : (yield `<${n}${l}>`, t != null && (yield* b(t, r)), yield `</${n}>`);
1
+ import { Context as f, current as d } from "./context.js";
2
+ const g = /* @__PURE__ */ new Set(["area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]), b = /* @__PURE__ */ new Set(["key", "skip", "memo", "ref"]), w = /* @__PURE__ */ new Set(["nodeName", "children"]), S = Symbol.for("ajo.args"), y = (e) => e.replace(/[&<>"']/g, (r) => `&#${r.charCodeAt(0)};`), o = () => {
3
+ }, C = (e) => [...p(e)].join(""), p = function* (e, { alloc: r = o, push: t = o, placeholder: n = o } = {}) {
4
+ for (e of u(e, { alloc: r, push: t, placeholder: n }))
5
+ typeof e == "string" ? yield y(e) : yield* $(e, { alloc: r, push: t, placeholder: n });
6
+ }, $ = function* (e, r) {
7
+ const { nodeName: t, children: n } = e;
8
+ let i = "";
9
+ for (const l in e)
10
+ w.has(l) || l.startsWith("set:") || e[l] == null || e[l] === !1 || (e[l] === !0 ? i += ` ${l}` : i += ` ${l}="${y(String(e[l]))}"`);
11
+ g.has(t) ? yield `<${t}${i}>` : (yield `<${t}${i}>`, n != null && (yield* p(n, r)), yield `</${t}>`);
12
12
  }, u = function* (e, r) {
13
13
  if (e == null) return;
14
- const n = typeof e;
15
- if (n != "boolean")
16
- if (n == "string") yield e;
17
- else if (n == "number" || n == "bigint") yield String(e);
14
+ const t = typeof e;
15
+ if (t != "boolean")
16
+ if (t == "string") yield e;
17
+ else if (t == "number" || t == "bigint") yield String(e);
18
18
  else if (Symbol.iterator in e) for (e of e) yield* u(e, r);
19
- else "nodeName" in e ? typeof e.nodeName == "function" ? yield* A(e, r) : yield o(e, r) : yield String(e);
20
- }, A = function* ({ nodeName: e, fallback: r = e.fallback, ...n }, t) {
21
- const l = e.constructor.name;
22
- e.src ? yield G(e.src, n, t) : l == "GeneratorFunction" ? yield j(e, n, t) : l == "AsyncGeneratorFunction" ? yield W(e, r, n, t) : (n = e(n), typeof (n == null ? void 0 : n.then) == "function" ? yield C(r, n, t) : yield* u(n, t));
23
- }, G = (e, r, n) => {
24
- const t = n.alloc();
25
- return n.push({ id: t, src: e, h: o(r, n), done: !0 }), n.placeholder(t);
26
- }, j = (e, r, n) => {
27
- var y, p;
28
- const t = { ...e.attrs }, l = { ...e.args };
19
+ else "nodeName" in e ? typeof e.nodeName == "function" ? yield* v(e, r) : yield a(e, r) : yield String(e);
20
+ }, v = function* ({ nodeName: e, fallback: r = e.fallback, ...t }, n) {
21
+ const i = e.constructor.name;
22
+ e.src ? yield x(e.src, t, n) : i == "GeneratorFunction" ? yield A(e, t, n) : i == "AsyncGeneratorFunction" ? yield G(e, r, t, n) : (t = e(t), typeof t?.then == "function" ? yield j(r, t, n) : yield* u(t, n));
23
+ }, x = (e, r, t) => {
24
+ const n = t.alloc();
25
+ return t.push({ id: n, src: e, h: a(r, t), done: !0 }), t.placeholder(n);
26
+ }, A = (e, r, t) => {
27
+ const n = { ...e.attrs }, i = { ...e.args };
29
28
  for (const c in r)
30
- c.startsWith("attr:") ? t[c.slice(5)] = r[c] : S.has(c) || c.startsWith("set:") ? t[c] = r[c] : l[c] = r[c];
31
- const i = {
32
- [m]: Object.create(((y = f()) == null ? void 0 : y[m]) ?? null),
33
- [v]: l,
34
- render: a,
35
- next: a,
36
- return: a,
29
+ c.startsWith("attr:") ? n[c.slice(5)] = r[c] : b.has(c) || c.startsWith("set:") ? n[c] = r[c] : i[c] = r[c];
30
+ const l = {
31
+ [f]: Object.create(d()?.[f] ?? null),
32
+ [S]: i,
33
+ next: o,
34
+ return: o,
37
35
  throw: (c) => {
38
36
  throw c;
39
37
  }
40
- }, s = e.call(i, l), d = f();
41
- f(i);
38
+ }, s = e.call(l, i), m = d();
39
+ d(l);
42
40
  try {
43
- const c = [...u(s.next().value, n)];
44
- return { ...t, nodeName: e.is ?? "div", children: c.length == 1 ? c[0] : c };
41
+ const c = [...u(s.next().value, t)];
42
+ return { ...n, nodeName: e.is ?? "div", children: c.length == 1 ? c[0] : c };
45
43
  } finally {
46
- (p = s.return) == null || p.call(s), f(d);
44
+ s.return?.(), d(m);
47
45
  }
48
- }, W = (e, r, n, t) => {
49
- const l = t.alloc();
46
+ }, G = (e, r, t, n) => {
47
+ const i = n.alloc();
50
48
  return Promise.resolve().then(async () => {
51
- var s;
52
- const i = e(n);
53
- t = { ...t, alloc: (d = l) => t.alloc(d) };
49
+ const l = e(t);
50
+ n = { ...n, alloc: (s = i) => n.alloc(s) };
54
51
  try {
55
- for (n = await i.next(); !n.done; )
56
- t.push({ id: l, h: o(n.value, t), done: !1 }), n = await i.next();
57
- t.push({ id: l, h: o(n.value, t), done: !0 });
58
- } catch (d) {
59
- t.push({ id: l, h: o(d, t), done: !0 });
52
+ for (t = await l.next(); !t.done; )
53
+ n.push({ id: i, h: a(t.value, n), done: !1 }), t = await l.next();
54
+ n.push({ id: i, h: a(t.value, n), done: !0 });
55
+ } catch (s) {
56
+ n.push({ id: i, h: a(s, n), done: !0 });
60
57
  } finally {
61
- (s = i.return) == null || s.call(i);
58
+ l.return?.();
62
59
  }
63
- }), t.placeholder(l, r);
64
- }, C = (e, r, n) => {
65
- const t = n.alloc();
66
- return r.then((l) => n.push({ id: t, h: o(l, { ...n, alloc: (i = t) => n.alloc(i) }), done: !0 })), n.placeholder(t, e);
67
- }, o = ({ key: e, skip: r, memo: n, ref: t, ...l }, i) => {
68
- if ("children" in l) {
69
- const s = [...u(l.children, i)];
70
- s.length ? l.children = s.length == 1 ? s[0] : s : delete l.children;
60
+ }), n.placeholder(i, r);
61
+ }, j = (e, r, t) => {
62
+ const n = t.alloc();
63
+ return r.then((i) => t.push({ id: n, h: a(i, { ...t, alloc: (l = n) => t.alloc(l) }), done: !0 })), t.placeholder(n, e);
64
+ }, a = ({ key: e, skip: r, memo: t, ref: n, ...i }, l) => {
65
+ if ("children" in i) {
66
+ const s = [...u(i.children, l)];
67
+ s.length ? i.children = s.length == 1 ? s[0] : s : delete i.children;
71
68
  }
72
- return l;
69
+ return i;
73
70
  };
74
71
  export {
75
- b as html,
76
- O as render
72
+ p as html,
73
+ C as render
77
74
  };
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./context.cjs"),u=Symbol.for("ajo.keyed"),b=Symbol.for("ajo.key"),j=Symbol.for("ajo.memo"),m=Symbol.for("ajo.ref"),v=Symbol.for("ajo.cache"),f=Symbol.for("ajo.generator"),o=Symbol.for("ajo.iterator"),l=Symbol.for("ajo.args"),p=t=>t.children,A=(t,r,...n)=>((r??(r={})).nodeName=t,!("children"in r)&&n.length&&(r.children=n.length==1?n[0]:n),r),y=(t,r)=>{let n=r.firstChild;for(t of S(t)){const e=O(t,r,n);n==null?g(r,e):e==n?n=n.nextSibling:g(r,e,e==n.nextSibling?n=C(r,n):n)}for(;n;){const e=n.nextSibling;r.removeChild(n),n=e}},C=(t,r)=>{const n=r.nextSibling;return g(t,r),n.nextSibling},S=function*(t){if(t==null)return;const r=typeof t;if(r!="boolean")if(r=="string")yield t;else if(r=="number"||r=="bigint")yield String(t);else if(Symbol.iterator in t)for(t of t)yield*S(t);else"nodeName"in t?typeof t.nodeName=="function"?yield*E(t):yield t:yield String(t)},E=function*({nodeName:t,...r}){t.constructor.name=="GeneratorFunction"?yield N(t,r):yield*S(t(r))},N=function(t,r){const n={...t.attrs},e={...t.args};for(const i in r)i.startsWith("attr:")?n[i.slice(5)]=r[i]:i=="key"||i=="memo"||i.startsWith("set:")?n[i]=r[i]:e[i]=r[i];return{...n,nodeName:t.is??"div",skip:!0,ref:B.bind(null,t,e)}},O=(t,r,n)=>typeof t=="string"?M(t,n):T(t,r,n),M=(t,r)=>{for(;r&&r.nodeType!=3;)r=r.nextSibling;return r?r.data!=t&&(r.data=t):r=document.createTextNode(t),r},T=({nodeName:t,children:r,key:n,skip:e,memo:i,ref:w,...h},a,s)=>{for(n!=null&&(s=(a[u]??(a[u]=new Map)).get(n)??s);s&&s.localName!=t;)s=s.nextSibling;return s??(s=document.createElementNS(h.xmlns??a.namespaceURI,t)),n!=s[b]&&(s[b]!=null&&x(s),a[u].set(s[b]=n,s)),(i==null||F(s[j],s[j]=i))&&(k(s[v]??W(s),s[v]=h,s),e||y(r,s),typeof w=="function"&&(s[m]=w)(s)),s},k=(t,r,n)=>{for(const e in{...t,...r})t[e]!==r[e]&&(e.startsWith("set:")?n[e.slice(4)]=r[e]:r[e]==null||r[e]===!1?n.removeAttribute(e):n.setAttribute(e,r[e]===!0?"":r[e]))},F=(t,r)=>Array.isArray(t)&&Array.isArray(r)?t.some((n,e)=>n!==r[e]):t!==r,W=t=>Array.from(t.attributes).reduce((r,n)=>(r[n.name]=n.value,r),{}),g=(t,r,n)=>{if(!r.contains(document.activeElement))return t.insertBefore(r,n);const e=r.nextSibling;for(;n&&n!=r;){const i=n.nextSibling;t.insertBefore(n,e),n=i}},x=t=>{var r,n;for(const e of t.children)x(e);(r=t[u])==null||r.clear(),t[f]&&(t[f]=null),(n=t[m])==null||n.call(t,null)},B=(t,{skip:r,ref:n,...e},i)=>{i&&(i[f]??(i[f]=(R(i),t)),i[m]=q.bind(null,n,i),Object.assign(i[l]??(i[l]={}),e),r||i.next())},R=t=>{var r;Object.assign(t,L),t[c.Context]=Object.create(((r=c.current())==null?void 0:r[c.Context])??null)},q=(t,r,n)=>{typeof t=="function"&&t(n),n||r.return()},L={render(){var t;(t=c.current())!=null&&t.contains(this)||this.next()},next(){var r;const t=c.current();c.current(this);try{const{value:n,done:e}=(this[o]??(this[o]=this[f].call(this,this[l]))).next();y(n,this),(r=this[m])==null||r.call(this,this),e&&this.return()}catch(n){this.throw(n)}finally{c.current(t)}},throw(t){var r;for(let n=this;n;n=n.parentNode)if(typeof((r=n[o])==null?void 0:r.throw)=="function")try{return y(n[o].throw(t).value,n)}catch(e){t=new Error(e instanceof Error?e.message:e,{cause:t})}throw t},return(){var t;try{(t=this[o])==null||t.return()}catch(r){this.throw(r)}finally{this[o]=null}}};"MutationObserver"in globalThis&&new MutationObserver(t=>t.forEach(r=>r.removedNodes.forEach(n=>n.isConnected||n.nodeType==1&&x(n)))).observe(document,{childList:!0,subtree:!0});exports.Fragment=p;exports.h=A;exports.render=y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./context.cjs"),a=Symbol.for("ajo.keyed"),l=Symbol.for("ajo.key"),p=Symbol.for("ajo.memo"),u=Symbol.for("ajo.ref"),w=Symbol.for("ajo.cache"),g=Symbol.for("ajo.generator"),c=Symbol.for("ajo.iterator"),m=Symbol.for("ajo.render"),b=Symbol.for("ajo.args"),A=e=>e.children,v=(e,t,...r)=>((t??={}).nodeName=e,!("children"in t)&&r.length&&(t.children=r.length==1?r[0]:r),t),f=(e,t)=>{let r=t.firstChild;for(e of S(e)){const n=k(e,t,r);r==null?t.appendChild(n):n==r?r=n.nextSibling:n==r.nextSibling?(t.appendChild(r),r=n.nextSibling):M(t,n,r)}for(;r;){const n=r.nextSibling;r.nodeType==1&&j(t,r),t.removeChild(r),r=n}},S=function*(e){if(e==null)return;const t=typeof e;if(t!="boolean")if(t=="string")yield e;else if(t=="number"||t=="bigint")yield String(e);else if(Symbol.iterator in e)for(e of e)yield*S(e);else"nodeName"in e?typeof e.nodeName=="function"?yield*C(e):yield e:yield String(e)},C=function*({nodeName:e,...t}){e.constructor.name=="GeneratorFunction"?yield N(e,t):yield*S(e(t))},N=function(e,t){const r={...e.attrs},n={...e.args};for(const i in t)i.startsWith("attr:")?r[i.slice(5)]=t[i]:i=="key"||i=="memo"||i.startsWith("set:")?r[i]=t[i]:n[i]=t[i];return{...r,nodeName:e.is??"div",skip:!0,ref:R.bind(null,e,n)}},k=(e,t,r)=>typeof e=="string"?E(e,r):O(e,t,r),E=(e,t)=>{for(;t&&t.nodeType!=3;)t=t.nextSibling;return t?t.data!=e&&(t.data=e):t=document.createTextNode(e),t},O=({nodeName:e,children:t,key:r,skip:n,memo:i,ref:x,...h},y,s)=>{for(r!=null&&(s=(y[a]??=new Map).get(r)??(s?.[l]==null?s:null));s&&s.localName!=e;)s=s.nextSibling;return s??=document.createElementNS(h.xmlns??y.namespaceURI,e),r!=s[l]&&y[a].set(s[l]=r,s),(i==null||F(s[p],s[p]=i))&&(T(s[w]??G(s),s[w]=h,s),n||f(t,s),typeof x=="function"&&(s[u]=x)(s)),s},T=(e,t,r)=>{for(const n in{...e,...t})e[n]!==t[n]&&(n.startsWith("set:")?r[n.slice(4)]=t[n]:t[n]==null||t[n]===!1?r.removeAttribute(n):r.setAttribute(n,t[n]===!0?"":t[n]))},F=(e,t)=>Array.isArray(e)&&Array.isArray(t)?e.some((r,n)=>r!==t[n]):e!==t,G=e=>Array.from(e.attributes).reduce((t,r)=>(t[r.name]=r.value,t),{}),M=(e,t,r)=>{if(t.contains(document.activeElement)){const n=t.nextSibling;for(;r&&r!=t;){const i=r.nextSibling;e.insertBefore(r,n),r=i}}else e.insertBefore(t,r)},j=(e,t)=>{for(const r of t.children)j(t,r);e[a]?.delete(t[l]),t[a]?.clear(),t[u]?.(null),t[g]&&=null},R=(e,{skip:t,ref:r,...n},i)=>{i&&(i[g]??=(W(i),e),i[u]=B.bind(null,r,i),Object.assign(i[b]??={},n),t||i[m]())},W=e=>{Object.assign(e,I),e[o.Context]=Object.create(o.current()?.[o.Context]??null)},B=(e,t,r)=>{typeof e=="function"&&e(r),r||t.return()},I={[m](){const e=o.current();o.current(this);try{const{value:t,done:r}=(this[c]??=this[g].call(this,this[b])).next();f(t,this),this[u]?.(this),r&&this.return()}catch(t){this.throw(t)}finally{o.current(e)}},next(e){if(typeof e=="function")try{e.call(this,this[b])}catch(t){this.throw(t)}o.current()?.contains(this)||this[m]()},throw(e){for(let t=this;t;t=t.parentNode)if(typeof t[c]?.throw=="function")try{return f(t[c].throw(e).value,t)}catch(r){e=new Error(r instanceof Error?r.message:r,{cause:e})}throw e},return(){try{this[c]?.return()}catch(e){this.throw(e)}finally{this[c]=null}}};exports.Fragment=A;exports.h=v;exports.render=f;
package/dist/index.js CHANGED
@@ -1,102 +1,96 @@
1
- import { Context as j, current as a } from "./context.js";
2
- const u = Symbol.for("ajo.keyed"), y = Symbol.for("ajo.key"), p = Symbol.for("ajo.memo"), m = Symbol.for("ajo.ref"), v = Symbol.for("ajo.cache"), c = Symbol.for("ajo.generator"), o = Symbol.for("ajo.iterator"), l = Symbol.for("ajo.args"), q = (t) => t.children, z = (t, r, ...n) => ((r ?? (r = {})).nodeName = t, !("children" in r) && n.length && (r.children = n.length == 1 ? n[0] : n), r), b = (t, r) => {
3
- let n = r.firstChild;
4
- for (t of x(t)) {
5
- const i = C(t, r, n);
6
- n == null ? g(r, i) : i == n ? n = n.nextSibling : g(r, i, i == n.nextSibling ? n = A(r, n) : n);
1
+ import { Context as p, current as c } from "./context.js";
2
+ const a = Symbol.for("ajo.keyed"), l = Symbol.for("ajo.key"), w = Symbol.for("ajo.memo"), f = Symbol.for("ajo.ref"), j = Symbol.for("ajo.cache"), g = Symbol.for("ajo.generator"), o = Symbol.for("ajo.iterator"), y = Symbol.for("ajo.render"), m = Symbol.for("ajo.args"), M = (e) => e.children, U = (e, t, ...r) => ((t ??= {}).nodeName = e, !("children" in t) && r.length && (t.children = r.length == 1 ? r[0] : r), t), b = (e, t) => {
3
+ let r = t.firstChild;
4
+ for (e of S(e)) {
5
+ const i = N(e, t, r);
6
+ r == null ? t.appendChild(i) : i == r ? r = i.nextSibling : i == r.nextSibling ? (t.appendChild(r), r = i.nextSibling) : T(t, i, r);
7
7
  }
8
- for (; n; ) {
9
- const i = n.nextSibling;
10
- r.removeChild(n), n = i;
8
+ for (; r; ) {
9
+ const i = r.nextSibling;
10
+ r.nodeType == 1 && A(t, r), t.removeChild(r), r = i;
11
11
  }
12
- }, A = (t, r) => {
13
- const n = r.nextSibling;
14
- return g(t, r), n.nextSibling;
15
- }, x = function* (t) {
16
- if (t == null) return;
17
- const r = typeof t;
18
- if (r != "boolean")
19
- if (r == "string") yield t;
20
- else if (r == "number" || r == "bigint") yield String(t);
21
- else if (Symbol.iterator in t) for (t of t) yield* x(t);
22
- else "nodeName" in t ? typeof t.nodeName == "function" ? yield* E(t) : yield t : yield String(t);
23
- }, E = function* ({ nodeName: t, ...r }) {
24
- t.constructor.name == "GeneratorFunction" ? yield N(t, r) : yield* x(t(r));
25
- }, N = function(t, r) {
26
- const n = { ...t.attrs }, i = { ...t.args };
27
- for (const e in r)
28
- e.startsWith("attr:") ? n[e.slice(5)] = r[e] : e == "key" || e == "memo" || e.startsWith("set:") ? n[e] = r[e] : i[e] = r[e];
29
- return { ...n, nodeName: t.is ?? "div", skip: !0, ref: B.bind(null, t, i) };
30
- }, C = (t, r, n) => typeof t == "string" ? O(t, n) : k(t, r, n), O = (t, r) => {
31
- for (; r && r.nodeType != 3; ) r = r.nextSibling;
32
- return r ? r.data != t && (r.data = t) : r = document.createTextNode(t), r;
33
- }, k = ({ nodeName: t, children: r, key: n, skip: i, memo: e, ref: w, ...h }, f, s) => {
34
- for (n != null && (s = (f[u] ?? (f[u] = /* @__PURE__ */ new Map())).get(n) ?? s); s && s.localName != t; ) s = s.nextSibling;
35
- return s ?? (s = document.createElementNS(h.xmlns ?? f.namespaceURI, t)), n != s[y] && (s[y] != null && S(s), f[u].set(s[y] = n, s)), (e == null || T(s[p], s[p] = e)) && (M(s[v] ?? W(s), s[v] = h, s), i || b(r, s), typeof w == "function" && (s[m] = w)(s)), s;
36
- }, M = (t, r, n) => {
37
- for (const i in { ...t, ...r })
38
- t[i] !== r[i] && (i.startsWith("set:") ? n[i.slice(4)] = r[i] : r[i] == null || r[i] === !1 ? n.removeAttribute(i) : n.setAttribute(i, r[i] === !0 ? "" : r[i]));
39
- }, T = (t, r) => Array.isArray(t) && Array.isArray(r) ? t.some((n, i) => n !== r[i]) : t !== r, W = (t) => Array.from(t.attributes).reduce((r, n) => (r[n.name] = n.value, r), {}), g = (t, r, n) => {
40
- if (!r.contains(document.activeElement)) return t.insertBefore(r, n);
41
- const i = r.nextSibling;
42
- for (; n && n != r; ) {
43
- const e = n.nextSibling;
44
- t.insertBefore(n, i), n = e;
45
- }
46
- }, S = (t) => {
47
- var r, n;
48
- for (const i of t.children) S(i);
49
- (r = t[u]) == null || r.clear(), t[c] && (t[c] = null), (n = t[m]) == null || n.call(t, null);
50
- }, B = (t, { skip: r, ref: n, ...i }, e) => {
51
- e && (e[c] ?? (e[c] = (F(e), t)), e[m] = R.bind(null, n, e), Object.assign(e[l] ?? (e[l] = {}), i), r || e.next());
52
- }, F = (t) => {
53
- var r;
54
- Object.assign(t, L), t[j] = Object.create(((r = a()) == null ? void 0 : r[j]) ?? null);
55
- }, R = (t, r, n) => {
56
- typeof t == "function" && t(n), n || r.return();
57
- }, L = {
58
- render() {
59
- var t;
60
- (t = a()) != null && t.contains(this) || this.next();
61
- },
62
- next() {
63
- var r;
64
- const t = a();
65
- a(this);
12
+ }, S = function* (e) {
13
+ if (e == null) return;
14
+ const t = typeof e;
15
+ if (t != "boolean")
16
+ if (t == "string") yield e;
17
+ else if (t == "number" || t == "bigint") yield String(e);
18
+ else if (Symbol.iterator in e) for (e of e) yield* S(e);
19
+ else "nodeName" in e ? typeof e.nodeName == "function" ? yield* v(e) : yield e : yield String(e);
20
+ }, v = function* ({ nodeName: e, ...t }) {
21
+ e.constructor.name == "GeneratorFunction" ? yield C(e, t) : yield* S(e(t));
22
+ }, C = function(e, t) {
23
+ const r = { ...e.attrs }, i = { ...e.args };
24
+ for (const n in t)
25
+ n.startsWith("attr:") ? r[n.slice(5)] = t[n] : n == "key" || n == "memo" || n.startsWith("set:") ? r[n] = t[n] : i[n] = t[n];
26
+ return { ...r, nodeName: e.is ?? "div", skip: !0, ref: W.bind(null, e, i) };
27
+ }, N = (e, t, r) => typeof e == "string" ? k(e, r) : E(e, t, r), k = (e, t) => {
28
+ for (; t && t.nodeType != 3; ) t = t.nextSibling;
29
+ return t ? t.data != e && (t.data = e) : t = document.createTextNode(e), t;
30
+ }, E = ({ nodeName: e, children: t, key: r, skip: i, memo: n, ref: x, ...h }, u, s) => {
31
+ for (r != null && (s = (u[a] ??= /* @__PURE__ */ new Map()).get(r) ?? (s?.[l] == null ? s : null)); s && s.localName != e; ) s = s.nextSibling;
32
+ return s ??= document.createElementNS(h.xmlns ?? u.namespaceURI, e), r != s[l] && u[a].set(s[l] = r, s), (n == null || O(s[w], s[w] = n)) && (G(s[j] ?? R(s), s[j] = h, s), i || b(t, s), typeof x == "function" && (s[f] = x)(s)), s;
33
+ }, G = (e, t, r) => {
34
+ for (const i in { ...e, ...t })
35
+ e[i] !== t[i] && (i.startsWith("set:") ? r[i.slice(4)] = t[i] : t[i] == null || t[i] === !1 ? r.removeAttribute(i) : r.setAttribute(i, t[i] === !0 ? "" : t[i]));
36
+ }, O = (e, t) => Array.isArray(e) && Array.isArray(t) ? e.some((r, i) => r !== t[i]) : e !== t, R = (e) => Array.from(e.attributes).reduce((t, r) => (t[r.name] = r.value, t), {}), T = (e, t, r) => {
37
+ if (t.contains(document.activeElement)) {
38
+ const i = t.nextSibling;
39
+ for (; r && r != t; ) {
40
+ const n = r.nextSibling;
41
+ e.insertBefore(r, i), r = n;
42
+ }
43
+ } else e.insertBefore(t, r);
44
+ }, A = (e, t) => {
45
+ for (const r of t.children) A(t, r);
46
+ e[a]?.delete(t[l]), t[a]?.clear(), t[f]?.(null), t[g] &&= null;
47
+ }, W = (e, { skip: t, ref: r, ...i }, n) => {
48
+ n && (n[g] ??= (B(n), e), n[f] = F.bind(null, r, n), Object.assign(n[m] ??= {}, i), t || n[y]());
49
+ }, B = (e) => {
50
+ Object.assign(e, I), e[p] = Object.create(c()?.[p] ?? null);
51
+ }, F = (e, t, r) => {
52
+ typeof e == "function" && e(r), r || t.return();
53
+ }, I = {
54
+ [y]() {
55
+ const e = c();
56
+ c(this);
66
57
  try {
67
- const { value: n, done: i } = (this[o] ?? (this[o] = this[c].call(this, this[l]))).next();
68
- b(n, this), (r = this[m]) == null || r.call(this, this), i && this.return();
69
- } catch (n) {
70
- this.throw(n);
58
+ const { value: t, done: r } = (this[o] ??= this[g].call(this, this[m])).next();
59
+ b(t, this), this[f]?.(this), r && this.return();
60
+ } catch (t) {
61
+ this.throw(t);
71
62
  } finally {
72
- a(t);
63
+ c(e);
73
64
  }
74
65
  },
75
- throw(t) {
76
- var r;
77
- for (let n = this; n; n = n.parentNode) if (typeof ((r = n[o]) == null ? void 0 : r.throw) == "function") try {
78
- return b(n[o].throw(t).value, n);
79
- } catch (i) {
80
- t = new Error(i instanceof Error ? i.message : i, { cause: t });
66
+ next(e) {
67
+ if (typeof e == "function") try {
68
+ e.call(this, this[m]);
69
+ } catch (t) {
70
+ this.throw(t);
81
71
  }
82
- throw t;
72
+ c()?.contains(this) || this[y]();
73
+ },
74
+ throw(e) {
75
+ for (let t = this; t; t = t.parentNode) if (typeof t[o]?.throw == "function") try {
76
+ return b(t[o].throw(e).value, t);
77
+ } catch (r) {
78
+ e = new Error(r instanceof Error ? r.message : r, { cause: e });
79
+ }
80
+ throw e;
83
81
  },
84
82
  return() {
85
- var t;
86
83
  try {
87
- (t = this[o]) == null || t.return();
88
- } catch (r) {
89
- this.throw(r);
84
+ this[o]?.return();
85
+ } catch (e) {
86
+ this.throw(e);
90
87
  } finally {
91
88
  this[o] = null;
92
89
  }
93
90
  }
94
91
  };
95
- "MutationObserver" in globalThis && new MutationObserver(
96
- (t) => t.forEach((r) => r.removedNodes.forEach((n) => n.isConnected || n.nodeType == 1 && S(n)))
97
- ).observe(document, { childList: !0, subtree: !0 });
98
92
  export {
99
- q as Fragment,
100
- z as h,
93
+ M as Fragment,
94
+ U as h,
101
95
  b as render
102
96
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ajo",
3
- "version": "0.1.25",
3
+ "version": "0.1.26",
4
4
  "description": "ajo is a JavaScript view library for building user interfaces",
5
5
  "type": "module",
6
6
  "types": "./types.ts",
@@ -33,11 +33,11 @@
33
33
  "types.ts"
34
34
  ],
35
35
  "devDependencies": {
36
- "@types/node": "24.0.0",
36
+ "@types/node": "24.3.0",
37
37
  "happy-dom": "18.0.1",
38
- "vite": "6.3.5",
38
+ "vite": "7.1.4",
39
39
  "vite-tsconfig-paths": "5.1.4",
40
- "vitest": "3.2.3"
40
+ "vitest": "3.2.4"
41
41
  },
42
42
  "keywords": [
43
43
  "ui",
package/readme.md CHANGED
@@ -13,15 +13,335 @@
13
13
  </a>
14
14
  </div>
15
15
 
16
- Ajo is a lightweight and efficient JavaScript library for building dynamic user interfaces. It combines the best ideas from Incremental DOM and Crank.js to offer a unique approach to UI development.
16
+ A modern JavaScript library for building user interfaces with generator-based state management, efficient DOM updates, and streaming server-side rendering.
17
17
 
18
- ## Key Features
18
+ ## Features
19
19
 
20
- - Efficient in-place DOM updates
21
- - Generator-based state management
22
- - JSX syntax support
23
- - Lightweight design
24
- - Server-Side Rendering (SSR) support
20
+ - **Generator-Based Components**: Use JavaScript generator functions (`function*`) for stateful components with built-in lifecycle management
21
+ - **Efficient DOM Updates**: In-place DOM reconciliation minimizes DOM manipulation and maximizes performance
22
+ - **Declarative JSX**: Write components using familiar JSX syntax with full TypeScript support
23
+ - **Performance Optimization**: Built-in `memo` attribute for fine-grained performance optimization
24
+ - **Context API**: Share state across component trees without prop drilling
25
+ - **Server-Side Rendering**: Complete SSR solution with streaming and hydration support
26
+ - **Islands Architecture**: Selective hydration for maximum performance with minimal client-side JavaScript
27
+
28
+ ## Quick Start
29
+
30
+ Install Ajo using your preferred package manager:
31
+
32
+ ```bash
33
+ npm install ajo
34
+ ```
35
+
36
+ Create your first component:
37
+
38
+ ```javascript
39
+ import { render } from 'ajo';
40
+
41
+ // Stateless component
42
+ const Greeting = ({ name }) => <p>Hello, {name}!</p>
43
+
44
+ // Stateful component
45
+ function* Counter() {
46
+ let count = 0
47
+
48
+ const increment = () => this.next(() => count++)
49
+
50
+ while (true) {
51
+ yield (
52
+ <button set:onclick={increment}>
53
+ Count: {count}
54
+ </button>
55
+ );
56
+ }
57
+ }
58
+
59
+ // Render to DOM
60
+ render(<Counter />, document.body)
61
+ ```
62
+
63
+ ## Core Concepts
64
+
65
+ ### Component Types
66
+
67
+ **Stateless Components** are pure functions:
68
+ ```javascript
69
+ const UserCard = ({ user }) => (
70
+ <div class="user-card">
71
+ <h3>{user.name}</h3>
72
+ <p>{user.email}</p>
73
+ </div>
74
+ );
75
+ ```
76
+
77
+ **Stateful Components** use generator functions with automatic wrapper elements:
78
+ ```javascript
79
+ function* TodoList() {
80
+ let todos = []
81
+
82
+ const addTodo = (text) => {
83
+ this.next(() => todos.push({ id: Date.now(), text }))
84
+ };
85
+
86
+ while (true) {
87
+ yield (
88
+ <>
89
+ <input set:onkeydown={(e) => {
90
+ if (e.key === 'Enter') addTodo(e.target.value);
91
+ }} />
92
+ <ul>
93
+ {todos.map(todo => (
94
+ <li key={todo.id}>{todo.text}</li>
95
+ ))}
96
+ </ul>
97
+ </>
98
+ );
99
+ }
100
+ }
101
+ ```
102
+
103
+ ### State Management Pattern
104
+
105
+ The generator structure provides a natural mental model:
106
+ - **Before the loop**: Persistent state, handlers, and utilities
107
+ - **Inside the loop**: Re-executed on each render for derived values
108
+
109
+ ```javascript
110
+ function* ShoppingCart(args) {
111
+ // Persistent state (like useState)
112
+ let items = []
113
+
114
+ // Persistent handlers (like useCallback)
115
+ const addItem = (product) => {
116
+ this.next(() => items.push(product))
117
+ };
118
+
119
+ // Main render loop
120
+ while (true) {
121
+ // Derived values computed fresh each render
122
+ const total = items.reduce((sum, item) => sum + item.price, 0)
123
+ const itemCount = items.length
124
+
125
+ yield (
126
+ <>
127
+ <h2>Cart ({itemCount} items)</h2>
128
+ <p>Total: ${total}</p>
129
+ {/* ... */}
130
+ </>
131
+ );
132
+ }
133
+ }
134
+ ```
135
+
136
+ ### Special Attributes
137
+
138
+ - **`key`**: List reconciliation
139
+ - **`ref`**: DOM element access
140
+ - **`memo`**: Performance optimization
141
+ - **`skip`**: Third-party DOM management
142
+ - **`set:`**: Direct property setting
143
+ - **`attr:`**: Force HTML attributes
144
+
145
+ ```javascript
146
+ function* MapComponent(args) {
147
+ let mapRef = null
148
+
149
+ while (true) {
150
+ yield (
151
+ <div
152
+ ref={el => {
153
+ if (el && !mapRef) {
154
+ mapRef = el
155
+ // Third-party map library controls this DOM
156
+ new GoogleMap(el, args.config)
157
+ }
158
+ }}
159
+ skip={true}
160
+ >
161
+ {/* Google Maps API manages these elements */}
162
+ <div class="map-controls"></div>
163
+ <div class="map-markers"></div>
164
+ </div>
165
+ );
166
+ }
167
+ }
168
+ ```
169
+
170
+ ## Server-Side Rendering
171
+
172
+ ### Static SSR
173
+ ```javascript
174
+ import { render } from 'ajo/html'
175
+
176
+ const html = render(<App />)
177
+ ```
178
+
179
+ ### Streaming SSR
180
+ ```javascript
181
+ import { stream } from 'ajo/stream';
182
+
183
+ for await (const chunk of stream(<App />)) {
184
+ response.write(chunk);
185
+ }
186
+ ```
187
+
188
+ ## Best Practices
189
+
190
+ 1. **Use fragments in stateful components** to avoid unnecessary DOM nesting
191
+ 2. **Don't destructure props in function signatures** - use `args` parameter or destructure inside the render loop
192
+ 3. **Leverage the generator structure** for natural state and lifecycle management
193
+ 4. **Use TypeScript** for enhanced developer experience
194
+
195
+ ## API Reference
196
+
197
+ ### Core Module (`ajo`)
198
+
199
+ #### `render(children: Children, container: Element): void`
200
+ Renders JSX into a DOM container element.
201
+
202
+ ```javascript
203
+ import { render } from 'ajo';
204
+
205
+ render(<App />, document.getElementById('root'));
206
+ ```
207
+
208
+ #### `h(type: Type, props?: Props, ...children: Children[]): VNode`
209
+ JSX factory function (rarely used directly).
210
+
211
+ #### `Fragment({ children }: { children: Children }): Children`
212
+ JSX fragment component for rendering multiple elements without a wrapper.
213
+
214
+ ```javascript
215
+ const List = () => (
216
+ <>
217
+ <li>Item 1</li>
218
+ <li>Item 2</li>
219
+ </>
220
+ );
221
+ ```
222
+
223
+ ### Stateful Component Instance Methods
224
+
225
+ Stateful components have access to several instance methods through `this`:
226
+
227
+ #### `this.next(callback?: (args: ComponentArgs) => void): void`
228
+ Triggers a re-render of the component by advancing to the next yield point. Optionally accepts a callback function that receives the component's current props/args as the first parameter.
229
+
230
+ ```javascript
231
+ function* Counter(args) {
232
+ let count = 0;
233
+
234
+ const increment = () => {
235
+ // Simple re-render
236
+ this.next(() => count++);
237
+ };
238
+
239
+ const incrementByStep = () => {
240
+ // Access current props in callback
241
+ this.next(({ step }) => count += step);
242
+ };
243
+
244
+ // ... rest of component
245
+ }
246
+ ```
247
+
248
+ #### `this.throw(error: unknown): void`
249
+ Throws an error that can be caught by parent error boundaries.
250
+
251
+ #### `this.return(): void`
252
+ Terminates the generator and triggers cleanup (rarely used directly).
253
+
254
+ ### Context Module (`ajo/context`)
255
+
256
+ #### `context<T>(fallback?: T): ContextFunction<T>`
257
+ Creates a context for sharing data across component trees.
258
+
259
+ ```javascript
260
+ import { context } from 'ajo/context';
261
+
262
+ const ThemeContext = context('light');
263
+
264
+ // Set value
265
+ ThemeContext('dark');
266
+
267
+ // Get value
268
+ const theme = ThemeContext(); // 'dark'
269
+ ```
270
+
271
+ ### HTML Module (`ajo/html`)
272
+
273
+ #### `render(children: Children): string`
274
+ Renders JSX to an HTML string for static site generation.
275
+
276
+ ```javascript
277
+ import { render } from 'ajo/html';
278
+
279
+ const html = render(<HomePage title="Welcome" />);
280
+ ```
281
+
282
+ #### `html(children: Children, hooks?: Hooks): IterableIterator<string>`
283
+ Low-level HTML streaming function with custom hooks.
284
+
285
+ ### Stream Module (`ajo/stream`)
286
+
287
+ #### `stream(children: Children): AsyncIterableIterator<string>`
288
+ Renders components to an async stream for progressive SSR.
289
+
290
+ ```javascript
291
+ import { stream } from 'ajo/stream';
292
+
293
+ for await (const chunk of stream(<App />)) {
294
+ response.write(chunk);
295
+ }
296
+ ```
297
+
298
+ #### `hydrate(patch: Patch): Promise<void>`
299
+ Client-side function for applying streamed patches during hydration.
300
+
301
+ ```javascript
302
+ import { hydrate } from 'ajo/stream';
303
+
304
+ window.$stream = { push: hydrate };
305
+ ```
306
+
307
+ ### TypeScript Support
308
+
309
+ ```typescript
310
+ // Component types
311
+ type Stateless<Props = {}> = (props: Props) => Children;
312
+ type Stateful<Props = {}, Tag = 'div'> = {
313
+ (this: StatefulElement<Tag>, props: Props): Iterator<Children>;
314
+ is?: Tag;
315
+ attrs?: Record<string, unknown>;
316
+ args?: Partial<Props>;
317
+ };
318
+
319
+ // Stateful component instance
320
+ type StatefulElement<Tag> = HTMLElement & {
321
+ next: (callback?: (args: ComponentArgs) => void) => void;
322
+ throw: (error: unknown) => void;
323
+ return: () => void;
324
+ };
325
+
326
+ // Element types
327
+ type Children = unknown;
328
+ type VNode<Type, Props> = Props & {
329
+ nodeName: Type;
330
+ children?: Children;
331
+ };
332
+
333
+ // Special attributes
334
+ type SpecialAttributes = {
335
+ key?: unknown;
336
+ ref?: (element: Element | null) => void;
337
+ memo?: unknown[];
338
+ skip?: boolean;
339
+ };
340
+ ```
341
+
342
+ ## Documentation
343
+
344
+ For comprehensive guides, advanced patterns, and detailed examples, see [documentation.md](./documentation.md).
25
345
 
26
346
  ## License
27
347
 
package/types.ts CHANGED
@@ -39,17 +39,16 @@ declare module 'ajo' {
39
39
  type Stateless<TArguments extends Props = {}> = (args: TArguments) => Children
40
40
 
41
41
  type Stateful<TArguments extends Props = {}, TTag extends Tag = 'div'> = {
42
- (this: StatefulElement<TTag>, args: StatefulProps<TArguments, TTag>): Iterator<Children>
42
+ (this: StatefulElement<TArguments, TTag>, args: StatefulProps<TArguments, TTag>): Iterator<Children>
43
43
  } & (TTag extends 'div' ? { is?: TTag } : { is: TTag }) & { attrs?: Partial<PropSetter<TTag>> & Props, args?: Partial<TArguments> }
44
44
 
45
45
  type StatefulProps<TArguments, TTag> =
46
- Partial<SpecialProps<StatefulElement<TTag>> & PropSetter<TTag>> &
46
+ Partial<SpecialProps<StatefulElement<TArguments, TTag>> & PropSetter<TTag>> &
47
47
  AttrSetter &
48
48
  TArguments
49
49
 
50
- type StatefulElement<TTag> = ElementType<TTag> & {
51
- render: () => void,
52
- next: () => void,
50
+ type StatefulElement<TArguments, TTag> = ElementType<TTag> & {
51
+ next: (fn?: (this: StatefulElement<TArguments, TTag>, args: StatefulProps<TArguments, TTag>) => void) => void,
53
52
  throw: (value?: unknown) => void,
54
53
  return: () => void,
55
54
  }