ajo 0.1.24 → 0.1.25

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 f=require("./context.cjs"),$=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"]),S=new Set(["nodeName","children",...g]),b=Symbol.for("ajo.args"),d=e=>e.replace(/[&<>"']/g,i=>`&#${i.charCodeAt(0)};`),o=()=>{},A=e=>[...w(e)].join(""),w=function*(e,{alloc:i=()=>"",placeholder:r=o,push:t=o}={}){yield*y(a(e,{alloc:i,placeholder:r,push:t}))},a=(e,i)=>{const r=typeof e;if(!(e==null||r==="boolean")){if(r==="string"||r==="number")return String(e);if(Array.isArray(e)){const t=[];for(e of e.flat(1/0)){const n=a(e,i);n!=null&&t.push(n)}return t.length===1?t[0]:t}if("nodeName"in e){if(typeof e.nodeName=="function")return v(e,i);const t={nodeName:e.nodeName};for(const n in e)!S.has(n)&&!n.startsWith("set:")&&(t[n]=e[n]);return"children"in e&&(t.children=a(e.children,i)),t}return String(e)}},v=({nodeName:e,fallback:i=e.fallback,...r},t)=>{if(e.src){const c=t.alloc();return t.push({id:c,src:e.src,h:r,done:!0}),t.placeholder(c,i)}const n=e.constructor.name;if(n==="GeneratorFunction")return x(e,r,t);if(n==="AsyncGeneratorFunction")return j(e,i,r,t);if(r=e(r),r instanceof Promise){if(t.push===o)return i;const c=t.alloc();return r.then(s=>t.push({id:c,h:a(s,{...t,alloc:(u=c)=>t.alloc(u)}),done:!0})),t.placeholder(c,i)}return a(r,t)},x=(e,i,r)=>{var p,m;const t={...e.attrs},n={...e.args};for(const l in i)l.startsWith("attr:")?t[l.slice(5)]=i[l]:g.has(l)||l.startsWith("set:")?t[l]=i[l]:n[l]=i[l];const c={[f.Context]:Object.assign(Object.create(null),(p=f.current())==null?void 0:p[f.Context]),[b]:n,render:o,next:o,return:o,throw:l=>{throw l}},s=e.call(c,n),u=f.current();f.current(c);try{return{...t,nodeName:e.is??"div",children:a(s.next().value,r)}}finally{(m=s.return)==null||m.call(s),f.current(u)}},j=(e,i,r,t)=>{if(t.push===o)return i;const n=t.alloc();return Promise.resolve().then(async()=>{var s;const c=e(r);t={...t,alloc:(u=n)=>t.alloc(u)};try{for(r=await c.next();!r.done;)t.push({id:n,h:a(r.value,t),done:!1}),r=await c.next();t.push({id:n,h:a(r.value,t),done:!0})}catch(u){t.push({id:n,h:a(u,t),done:!0})}finally{(s=c.return)==null||s.call(c)}}),t.placeholder(n,i)},y=function*(e){if(typeof e=="string")yield d(e);else if(Array.isArray(e))for(e of e)yield*y(e);else if("nodeName"in e){const{nodeName:i,children:r}=e;let t="";for(const n in e)S.has(n)||n.startsWith("set:")||e[n]==null||e[n]===!1||(e[n]===!0?t+=` ${n}`:t+=` ${n}="${d(String(e[n]))}"`);$.has(i)?yield`<${i}${t}>`:(yield`<${i}${t}>`,r!=null&&(yield*y(r)),yield`</${i}>`)}else yield d(String(e))};exports.html=w;exports.render=A;
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;
package/dist/html.js CHANGED
@@ -1,91 +1,77 @@
1
- import { Context as g, current as f } from "./context.js";
2
- const $ = /* @__PURE__ */ new Set(["area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]), w = /* @__PURE__ */ new Set(["key", "skip", "memo", "ref"]), S = /* @__PURE__ */ new Set(["nodeName", "children", ...w]), A = Symbol.for("ajo.args"), d = (e) => e.replace(/[&<>"']/g, (i) => `&#${i.charCodeAt(0)};`), o = () => {
3
- }, W = (e) => [...b(e)].join(""), b = function* (e, { alloc: i = () => "", placeholder: r = o, push: n = o } = {}) {
4
- yield* y(a(e, { alloc: i, placeholder: r, push: n }));
5
- }, a = (e, i) => {
6
- const r = typeof e;
7
- if (!(e == null || r === "boolean")) {
8
- if (r === "string" || r === "number") return String(e);
9
- if (Array.isArray(e)) {
10
- const n = [];
11
- for (e of e.flat(1 / 0)) {
12
- const t = a(e, i);
13
- t != null && n.push(t);
14
- }
15
- return n.length === 1 ? n[0] : n;
16
- }
17
- if ("nodeName" in e) {
18
- if (typeof e.nodeName == "function") return v(e, i);
19
- const n = { nodeName: e.nodeName };
20
- for (const t in e) !S.has(t) && !t.startsWith("set:") && (n[t] = e[t]);
21
- return "children" in e && (n.children = a(e.children, i)), n;
22
- }
23
- return String(e);
24
- }
25
- }, v = ({ nodeName: e, fallback: i = e.fallback, ...r }, n) => {
26
- if (e.src) {
27
- const c = n.alloc();
28
- return n.push({ id: c, src: e.src, h: r, done: !0 }), n.placeholder(c, i);
29
- }
30
- const t = e.constructor.name;
31
- if (t === "GeneratorFunction") return x(e, r, n);
32
- if (t === "AsyncGeneratorFunction") return j(e, i, r, n);
33
- if (r = e(r), r instanceof Promise) {
34
- if (n.push === o) return i;
35
- const c = n.alloc();
36
- return r.then((s) => n.push({ id: c, h: a(s, { ...n, alloc: (u = c) => n.alloc(u) }), done: !0 })), n.placeholder(c, i);
37
- }
38
- return a(r, n);
39
- }, x = (e, i, r) => {
40
- var p, m;
41
- const n = { ...e.attrs }, t = { ...e.args };
42
- for (const l in i)
43
- l.startsWith("attr:") ? n[l.slice(5)] = i[l] : w.has(l) || l.startsWith("set:") ? n[l] = i[l] : t[l] = i[l];
44
- const c = {
45
- [g]: Object.assign(/* @__PURE__ */ Object.create(null), (p = f()) == null ? void 0 : p[g]),
46
- [A]: t,
47
- render: o,
48
- next: o,
49
- return: o,
50
- throw: (l) => {
51
- throw l;
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}>`);
12
+ }, u = function* (e, r) {
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);
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 };
29
+ 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,
37
+ throw: (c) => {
38
+ throw c;
52
39
  }
53
- }, s = e.call(c, t), u = f();
54
- f(c);
40
+ }, s = e.call(i, l), d = f();
41
+ f(i);
55
42
  try {
56
- return { ...n, nodeName: e.is ?? "div", children: a(s.next().value, r) };
43
+ const c = [...u(s.next().value, n)];
44
+ return { ...t, nodeName: e.is ?? "div", children: c.length == 1 ? c[0] : c };
57
45
  } finally {
58
- (m = s.return) == null || m.call(s), f(u);
46
+ (p = s.return) == null || p.call(s), f(d);
59
47
  }
60
- }, j = (e, i, r, n) => {
61
- if (n.push === o) return i;
62
- const t = n.alloc();
48
+ }, W = (e, r, n, t) => {
49
+ const l = t.alloc();
63
50
  return Promise.resolve().then(async () => {
64
51
  var s;
65
- const c = e(r);
66
- n = { ...n, alloc: (u = t) => n.alloc(u) };
52
+ const i = e(n);
53
+ t = { ...t, alloc: (d = l) => t.alloc(d) };
67
54
  try {
68
- for (r = await c.next(); !r.done; )
69
- n.push({ id: t, h: a(r.value, n), done: !1 }), r = await c.next();
70
- n.push({ id: t, h: a(r.value, n), done: !0 });
71
- } catch (u) {
72
- n.push({ id: t, h: a(u, n), done: !0 });
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 });
73
60
  } finally {
74
- (s = c.return) == null || s.call(c);
61
+ (s = i.return) == null || s.call(i);
75
62
  }
76
- }), n.placeholder(t, i);
77
- }, y = function* (e) {
78
- if (typeof e == "string") yield d(e);
79
- else if (Array.isArray(e)) for (e of e) yield* y(e);
80
- else if ("nodeName" in e) {
81
- const { nodeName: i, children: r } = e;
82
- let n = "";
83
- for (const t in e)
84
- S.has(t) || t.startsWith("set:") || e[t] == null || e[t] === !1 || (e[t] === !0 ? n += ` ${t}` : n += ` ${t}="${d(String(e[t]))}"`);
85
- $.has(i) ? yield `<${i}${n}>` : (yield `<${i}${n}>`, r != null && (yield* y(r)), yield `</${i}>`);
86
- } else yield d(String(e));
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;
71
+ }
72
+ return l;
87
73
  };
88
74
  export {
89
75
  b as html,
90
- W as render
76
+ O as render
91
77
  };
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./context.cjs"),f=Symbol.for("ajo.keyed"),b=Symbol.for("ajo.key"),j=Symbol.for("ajo.memo"),m=Symbol.for("ajo.ref"),v=Symbol.for("ajo.cache"),u=Symbol.for("ajo.generator"),o=Symbol.for("ajo.iterator"),l=Symbol.for("ajo.args"),p=t=>t.children,A=(t,r,...e)=>((r??(r={})).nodeName=t,!("children"in r)&&e.length&&(r.children=e.length==1?e[0]:e),r),y=(t,r)=>{let e=r.firstChild;for(t of x(t)){const n=O(t,r,e);e==null?g(r,n):n==e?e=e.nextSibling:g(r,n,n==e.nextSibling?e=C(r,e):e)}for(;e;){const n=e.nextSibling;r.removeChild(e),e=n}},C=(t,r)=>{const e=r.nextSibling;return g(t,r),e.nextSibling},x=function*(t){const r=typeof t;if(!(t==null||r=="boolean"))if(r==="string"||r==="number")yield String(t);else if(Array.isArray(t))for(t of t)yield*x(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*x(t(r))},N=function(t,r){const e={...t.attrs},n={...t.args};for(const i in r)i.startsWith("attr:")?e[i.slice(5)]=r[i]:i=="key"||i=="memo"||i.startsWith("set:")?e[i]=r[i]:n[i]=r[i];return{...e,nodeName:t.is??"div",skip:!0,ref:B.bind(null,t,n)}},O=(t,r,e)=>typeof t=="string"?M(t,e):T(t,r,e),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:e,skip:n,memo:i,ref:w,...h},a,s)=>{if(e!=null)s=(a[f]??(a[f]=new Map)).get(e)??s;else for(;s&&s.localName!=t;)s=s.nextSibling;return s??(s=document.createElementNS(h.xmlns??a.namespaceURI,t)),e!=null&&s[b]!=e&&(s[b]!=null&&S(s),a[f].set(s[b]=e,s)),(i==null||F(s[j],s[j]=i))&&(k(s[v]??W(s),s[v]=h,s),n||y(r,s),typeof w=="function"&&(s[m]=w)(s)),s},k=(t,r,e)=>{for(const n in{...t,...r})t[n]!==r[n]&&(n.startsWith("set:")?e[n.slice(4)]=r[n]:r[n]==null||r[n]===!1?e.removeAttribute(n):e.setAttribute(n,r[n]===!0?"":r[n]))},F=(t,r)=>Array.isArray(t)&&Array.isArray(r)?t.some((e,n)=>e!==r[n]):t!==r,W=t=>Array.from(t.attributes).reduce((r,e)=>(r[e.name]=e.value,r),{}),g=(t,r,e)=>{if(!r.contains(document.activeElement))return t.insertBefore(r,e);const n=r.nextSibling;for(;e&&e!=r;){const i=e.nextSibling;t.insertBefore(e,n),e=i}},S=t=>{var r,e;for(const n of t.children)S(n);(r=t[f])==null||r.clear(),(e=t[m])==null||e.call(t,null)},B=(t,{skip:r,ref:e,...n},i)=>{i&&(i[u]??(i[u]=(R(i),t)),i[m]=q.bind(null,e,i),Object.assign(i[l]??(i[l]={}),n),r||i.next())},R=t=>{var r;Object.assign(t,G),t[c.Context]=Object.create(((r=c.current())==null?void 0:r[c.Context])??null)},q=(t,r,e)=>{typeof t=="function"&&t(e),e||r.return()},G={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:e,done:n}=(this[o]??(this[o]=this[u].call(this,this[l]))).next();y(e,this),(r=this[m])==null||r.call(this,this),n&&this.return()}catch(e){this.throw(e)}finally{c.current(t)}},throw(t){var r;for(let e=this;e;e=e.parentNode)if(typeof((r=e[o])==null?void 0:r.throw)=="function")try{return y(e[o].throw(t).value,e)}catch(n){t=new Error(n instanceof Error?n.message:n,{cause:t})}throw t},return(){var t;try{(t=this[o])==null||t.return()}catch(r){this.throw(r)}finally{this[o]=null}}};new MutationObserver(t=>t.forEach(r=>r.removedNodes.forEach(e=>e.isConnected||e.nodeType==1&&S(e)))).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 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;
package/dist/index.js CHANGED
@@ -1,82 +1,83 @@
1
- import { Context as j, current as f } from "./context.js";
2
- const a = Symbol.for("ajo.keyed"), y = Symbol.for("ajo.key"), p = Symbol.for("ajo.memo"), m = Symbol.for("ajo.ref"), v = Symbol.for("ajo.cache"), u = Symbol.for("ajo.generator"), o = Symbol.for("ajo.iterator"), l = Symbol.for("ajo.args"), U = (t) => t.children, q = (t, r, ...n) => ((r ?? (r = {})).nodeName = t, !("children" in r) && n.length && (r.children = n.length == 1 ? n[0] : n), r), b = (t, r) => {
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
3
  let n = r.firstChild;
4
4
  for (t of x(t)) {
5
- const e = C(t, r, n);
6
- n == null ? g(r, e) : e == n ? n = n.nextSibling : g(r, e, e == n.nextSibling ? n = A(r, n) : n);
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);
7
7
  }
8
8
  for (; n; ) {
9
- const e = n.nextSibling;
10
- r.removeChild(n), n = e;
9
+ const i = n.nextSibling;
10
+ r.removeChild(n), n = i;
11
11
  }
12
12
  }, A = (t, r) => {
13
13
  const n = r.nextSibling;
14
14
  return g(t, r), n.nextSibling;
15
15
  }, x = function* (t) {
16
+ if (t == null) return;
16
17
  const r = typeof t;
17
- if (!(t == null || r == "boolean"))
18
- if (r === "string" || r === "number") yield String(t);
19
- else if (Array.isArray(t)) for (t of t) yield* x(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);
20
22
  else "nodeName" in t ? typeof t.nodeName == "function" ? yield* E(t) : yield t : yield String(t);
21
23
  }, E = function* ({ nodeName: t, ...r }) {
22
24
  t.constructor.name == "GeneratorFunction" ? yield N(t, r) : yield* x(t(r));
23
25
  }, N = function(t, r) {
24
- const n = { ...t.attrs }, e = { ...t.args };
25
- for (const i in r)
26
- i.startsWith("attr:") ? n[i.slice(5)] = r[i] : i == "key" || i == "memo" || i.startsWith("set:") ? n[i] = r[i] : e[i] = r[i];
27
- return { ...n, nodeName: t.is ?? "div", skip: !0, ref: B.bind(null, t, e) };
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) };
28
30
  }, C = (t, r, n) => typeof t == "string" ? O(t, n) : k(t, r, n), O = (t, r) => {
29
31
  for (; r && r.nodeType != 3; ) r = r.nextSibling;
30
32
  return r ? r.data != t && (r.data = t) : r = document.createTextNode(t), r;
31
- }, k = ({ nodeName: t, children: r, key: n, skip: e, memo: i, ref: w, ...h }, c, s) => {
32
- if (n != null) s = (c[a] ?? (c[a] = /* @__PURE__ */ new Map())).get(n) ?? s;
33
- else for (; s && s.localName != t; ) s = s.nextSibling;
34
- return s ?? (s = document.createElementNS(h.xmlns ?? c.namespaceURI, t)), n != null && s[y] != n && (s[y] != null && S(s), c[a].set(s[y] = n, s)), (i == null || T(s[p], s[p] = i)) && (M(s[v] ?? W(s), s[v] = h, s), e || b(r, s), typeof w == "function" && (s[m] = w)(s)), s;
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;
35
36
  }, M = (t, r, n) => {
36
- for (const e in { ...t, ...r })
37
- 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]));
38
- }, T = (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) => {
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) => {
39
40
  if (!r.contains(document.activeElement)) return t.insertBefore(r, n);
40
- const e = r.nextSibling;
41
+ const i = r.nextSibling;
41
42
  for (; n && n != r; ) {
42
- const i = n.nextSibling;
43
- t.insertBefore(n, e), n = i;
43
+ const e = n.nextSibling;
44
+ t.insertBefore(n, i), n = e;
44
45
  }
45
46
  }, S = (t) => {
46
47
  var r, n;
47
- for (const e of t.children) S(e);
48
- (r = t[a]) == null || r.clear(), (n = t[m]) == null || n.call(t, null);
49
- }, B = (t, { skip: r, ref: n, ...e }, i) => {
50
- i && (i[u] ?? (i[u] = (F(i), t)), i[m] = R.bind(null, n, i), Object.assign(i[l] ?? (i[l] = {}), e), r || i.next());
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());
51
52
  }, F = (t) => {
52
53
  var r;
53
- Object.assign(t, G), t[j] = Object.create(((r = f()) == null ? void 0 : r[j]) ?? null);
54
+ Object.assign(t, L), t[j] = Object.create(((r = a()) == null ? void 0 : r[j]) ?? null);
54
55
  }, R = (t, r, n) => {
55
56
  typeof t == "function" && t(n), n || r.return();
56
- }, G = {
57
+ }, L = {
57
58
  render() {
58
59
  var t;
59
- (t = f()) != null && t.contains(this) || this.next();
60
+ (t = a()) != null && t.contains(this) || this.next();
60
61
  },
61
62
  next() {
62
63
  var r;
63
- const t = f();
64
- f(this);
64
+ const t = a();
65
+ a(this);
65
66
  try {
66
- const { value: n, done: e } = (this[o] ?? (this[o] = this[u].call(this, this[l]))).next();
67
- b(n, this), (r = this[m]) == null || r.call(this, this), e && this.return();
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();
68
69
  } catch (n) {
69
70
  this.throw(n);
70
71
  } finally {
71
- f(t);
72
+ a(t);
72
73
  }
73
74
  },
74
75
  throw(t) {
75
76
  var r;
76
77
  for (let n = this; n; n = n.parentNode) if (typeof ((r = n[o]) == null ? void 0 : r.throw) == "function") try {
77
78
  return b(n[o].throw(t).value, n);
78
- } catch (e) {
79
- t = new Error(e instanceof Error ? e.message : e, { cause: t });
79
+ } catch (i) {
80
+ t = new Error(i instanceof Error ? i.message : i, { cause: t });
80
81
  }
81
82
  throw t;
82
83
  },
@@ -91,11 +92,11 @@ const a = Symbol.for("ajo.keyed"), y = Symbol.for("ajo.key"), p = Symbol.for("aj
91
92
  }
92
93
  }
93
94
  };
94
- new MutationObserver(
95
+ "MutationObserver" in globalThis && new MutationObserver(
95
96
  (t) => t.forEach((r) => r.removedNodes.forEach((n) => n.isConnected || n.nodeType == 1 && S(n)))
96
97
  ).observe(document, { childList: !0, subtree: !0 });
97
98
  export {
98
- U as Fragment,
99
- q as h,
99
+ q as Fragment,
100
+ z as h,
100
101
  b as render
101
102
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ajo",
3
- "version": "0.1.24",
3
+ "version": "0.1.25",
4
4
  "description": "ajo is a JavaScript view library for building user interfaces",
5
5
  "type": "module",
6
6
  "types": "./types.ts",
package/types.ts CHANGED
@@ -73,9 +73,9 @@ declare module 'ajo/html' {
73
73
 
74
74
  type Patch = {
75
75
  id: string,
76
- h?: import('ajo').Children,
76
+ h: import('ajo').Children,
77
77
  src?: string,
78
- done?: boolean,
78
+ done: boolean,
79
79
  }
80
80
 
81
81
  type Hooks = {