ajo 0.1.10 → 0.1.11

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/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const{isArray:w,prototype:{slice:k}}=Array,{assign:$,setPrototypeOf:x,hasOwn:T,keys:A}=Object,h=e=>typeof e!="string"&&typeof(e==null?void 0:e[Symbol.iterator])=="function",E=({children:e})=>e,C=function(e,n){const{length:i}=arguments;return(n??(n={})).nodeName=e,"children"in n||i<3||(n.children=i===3?arguments[2]:k.call(arguments,2)),n},d=(e,n)=>{let i=n.firstChild;for(e of m(e)){let t=i;if(typeof e=="string"){for(;t&&t.nodeType!=3;)t=t.nextSibling;t?t.data!=e&&(t.data=e):t=document.createTextNode(e)}else if(e instanceof Node)t=e;else{const{nodeName:o,key:c,skip:a,memo:f,ref:y,children:b}=e;for(;t&&!(t.localName===o&&(t.$key??(t.$key=c))==c);)t=t.nextSibling;if(t??(t=$(document.createElementNS(e.xmlns??o==="svg"?"http://www.w3.org/2000/svg":n.namespaceURI,o),{$key:c})),f==null||O(t.$memo,t.$memo=f)){const{$props:u}=t,g={},p={};for(const r in $({},u,e)){if(q.has(r))continue;if(r.startsWith("arg:")){p[r.slice(4)]=e[r];continue}const l=g[r]=e[r];l!==(u==null?void 0:u[r])&&(r.startsWith("set:")?t[r.slice(4)]=l:l==null||l===!1?t.removeAttribute(r):t.setAttribute(r,l===!0?"":l))}t.$props=g,a||d(b,t),typeof y=="function"&&(t.$ref=y)(t,p)}}t===i?i=i.nextSibling:I(n,t,i)}for(;i;){const t=i.nextSibling;i.nodeType===1&&v(i),n.removeChild(i),i=t}},m=function*(e,n={value:""},i=!0){for(e of h(e)?e:[e])if(!(e==null||typeof e=="boolean"))if(T(e,"nodeName")){const{value:t}=n,{nodeName:o}=e,c=typeof o;if(t&&(yield t,n.value=""),c==="function")if(o.constructor.name==="GeneratorFunction"){const{is:a=o.is??"div",ref:f}=e;e.nodeName=a,delete e.is,e.skip=!0,e.ref=F.bind(null,o,a,f),"children"in e&&(e["arg:children"]=e.children,delete e.children),yield e}else delete e.nodeName,yield*m(o(e),n,!1);else c==="string"&&(yield e)}else h(e)?yield*m(e,n,!1):n.value+=e;i&&n.value&&(yield n.value)},F=(e,n,i,t,o)=>{t&&(t.$gen??(t.$gen=(new U(t,n),e)),t.$ref=M.bind(null,t,i),t.$args=o,t.next())},M=(e,n,i,t)=>{i||e.return(),typeof n=="function"&&n(i,t)},O=(e,n)=>w(e)&&w(n)?e.some((i,t)=>i!==n[t]):e!==n,q=new Set("nodeName,key,skip,memo,ref,children".split(",")),I=(e,n,i)=>{if(n.contains(document.activeElement)){const t=n.nextSibling;for(;i&&i!=n;){const o=i.nextSibling;e.insertBefore(i,t),i=o}}else e.insertBefore(n,i)},v=e=>{for(const i of e.children)v(i);const{$ref:n}=e;typeof n=="function"&&n(null);for(const i of A(e))e[i]=null};class U{constructor(n,i){return x(n,x(this.constructor.prototype,j(n,i).prototype))}*[Symbol.iterator](){for(;;)yield this.$args}refresh(){B(this)}next(){try{d((this.$it??(this.$it=this.$gen.call(this,this.$args))).next().value,this),typeof this.$ref=="function"&&this.$ref(this)}catch(n){this.throw(n)}}throw(n){var i;for(let t=this;t;t=t.parentNode)if(typeof((i=t.$it)==null?void 0:i.throw)=="function")try{return d(t.$it.throw(n).value,t)}catch{}throw n}return(){var n;try{(n=this.$it)==null||n.return()}catch(i){this.throw(i)}finally{this.$it=null}}}let S,s,N;const j=(e,n)=>{let i=(S??(S=new Map)).get(n);return i||({constructor:i}=document.createElementNS(e.namespaceURI,n),S.set(n,i===HTMLUnknownElement?i=HTMLElement:i)),i},B=e=>{(s??(s=new Set)).has(e)&&s.delete(e);for(const n of s){if(n.contains(e))return;e.contains(n)&&s.delete(n)}s.add(e),N??(N=requestAnimationFrame(H))},H=()=>{for(const e of s)e.isConnected&&e.next();s.clear(),N=null};exports.Fragment=E;exports.h=C;exports.render=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const{isArray:p,prototype:{slice:k}}=Array,{keys:A,assign:w,hasOwn:O,setPrototypeOf:$,getPrototypeOf:h}=Object,x=e=>typeof e!="string"&&typeof(e==null?void 0:e[Symbol.iterator])=="function",C=({children:e})=>e,F=function(e,t){const{length:n}=arguments;return(t??(t={})).nodeName=e,"children"in t||n<3||(t.children=n===3?arguments[2]:k.call(arguments,2)),t},a=(e,t)=>{let n=t.firstChild;for(e of d(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 if(e instanceof Node)i=e;else{const{nodeName:o,key:c,skip:N,memo:m,ref:y,children:b}=e;for(;i&&!(i.localName===o&&(i.$key??(i.$key=c))==c);)i=i.nextSibling;if(i??(i=w(document.createElementNS(e.xmlns??o==="svg"?"http://www.w3.org/2000/svg":t.namespaceURI,o),{$key:c})),m==null||P(i.$memo,i.$memo=m)){const{$props:f}=i,g={};let u;for(const s in w({},f,e)){if(j.has(s))continue;if(s.startsWith("arg:")){(u??(u={}))[s.slice(4)]=e[s];continue}const l=g[s]=e[s];l!==(f==null?void 0:f[s])&&(s.startsWith("set:")?i[s.slice(4)]=l:l==null||l===!1?i.removeAttribute(s):i.setAttribute(s,l===!0?"":l))}u&&(i.$args=u),i.$props=g,N||a(b,i),typeof y=="function"&&(i.$ref=y)(i)}}i===n?n=n.nextSibling:B(t,i,n)}for(;n;){const i=n.nextSibling;n.nodeType===1&&S(n),t.removeChild(n),n=i}},d=function*(e,t={value:""},n=!0){for(e of x(e)?e:[e])if(!(e==null||typeof e=="boolean"))if(O(e,"nodeName")){const{value:i}=t,{nodeName:o}=e,c=typeof o;i&&(yield i,t.value=""),c==="function"?o.constructor.name==="GeneratorFunction"?(e.nodeName=o.is??"div",e.skip=!0,e.ref=T.bind(null,o,e.ref),"children"in e&&(e["arg:children"]=e.children,delete e.children),yield e):(delete e.nodeName,yield*d(o(e),t,!1)):c==="string"&&(yield e)}else x(e)?yield*d(e,t,!1):t.value+=e;n&&t.value&&(yield t.value)},T=(e,t,n)=>{n&&(n.$gen??(n.$gen=(new E(n),e)),n.$ref=q.bind(null,n,t),n.next())},q=(e,t,n)=>{n||e.return(),typeof t=="function"&&t(n)},P=(e,t)=>p(e)&&p(t)?e.some((n,i)=>n!==t[i]):e!==t,j=new Set("nodeName,key,skip,memo,ref,children".split(",")),B=(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)},S=e=>{for(const n of e.children)S(n);const{$ref:t}=e;typeof t=="function"&&t(null);for(const n of A(e))e[n]=null};class E{constructor(t){$(t,$(h(this),h(t)))}*[Symbol.iterator](){for(;;)yield this.$args??{}}refresh(){I(this)}next(){try{a((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 a(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}}}let r,v;const I=e=>{(r??(r=new Set)).has(e)&&r.delete(e);for(const t of r){if(t.contains(e))return;e.contains(t)&&r.delete(t)}r.add(e),v??(v=requestAnimationFrame(W))},W=()=>{for(const e of r)e.isConnected&&e.next();r.clear(),v=null};exports.Fragment=C;exports.h=F;exports.render=a;
package/dist/index.js CHANGED
@@ -1,136 +1,127 @@
1
- const { isArray: w, prototype: { slice: b } } = Array, { assign: $, setPrototypeOf: x, hasOwn: A, keys: E } = Object, h = (e) => typeof e != "string" && typeof (e == null ? void 0 : e[Symbol.iterator]) == "function", H = ({ children: e }) => e, L = function(e, n) {
2
- const { length: i } = arguments;
3
- return (n ?? (n = {})).nodeName = e, "children" in n || i < 3 || (n.children = i === 3 ? arguments[2] : b.call(arguments, 2)), n;
4
- }, m = (e, n) => {
5
- let i = n.firstChild;
1
+ const { isArray: p, prototype: { slice: b } } = Array, { keys: A, assign: w, hasOwn: C, setPrototypeOf: $, getPrototypeOf: x } = Object, h = (e) => typeof e != "string" && typeof (e == null ? void 0 : e[Symbol.iterator]) == "function", W = ({ children: e }) => e, j = 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] : b.call(arguments, 2)), t;
4
+ }, u = (e, t) => {
5
+ let n = t.firstChild;
6
6
  for (e of d(e)) {
7
- let t = i;
7
+ let i = n;
8
8
  if (typeof e == "string") {
9
- for (; t && t.nodeType != 3; )
10
- t = t.nextSibling;
11
- t ? t.data != e && (t.data = e) : t = document.createTextNode(e);
9
+ for (; i && i.nodeType != 3; )
10
+ i = i.nextSibling;
11
+ i ? i.data != e && (i.data = e) : i = document.createTextNode(e);
12
12
  } else if (e instanceof Node)
13
- t = e;
13
+ i = e;
14
14
  else {
15
- const { nodeName: o, key: c, skip: a, memo: f, ref: y, children: k } = e;
16
- for (; t && !(t.localName === o && (t.$key ?? (t.$key = c)) == c); )
17
- t = t.nextSibling;
18
- if (t ?? (t = $(document.createElementNS(e.xmlns ?? o === "svg" ? "http://www.w3.org/2000/svg" : n.namespaceURI, o), { $key: c })), f == null || q(t.$memo, t.$memo = f)) {
19
- const { $props: u } = t, g = {}, p = {};
20
- for (const s in $({}, u, e)) {
21
- if (F.has(s))
15
+ const { nodeName: o, key: c, skip: S, memo: m, ref: y, children: k } = e;
16
+ for (; i && !(i.localName === o && (i.$key ?? (i.$key = c)) == c); )
17
+ i = i.nextSibling;
18
+ if (i ?? (i = w(document.createElementNS(e.xmlns ?? o === "svg" ? "http://www.w3.org/2000/svg" : t.namespaceURI, o), { $key: c })), m == null || F(i.$memo, i.$memo = m)) {
19
+ const { $props: f } = i, g = {};
20
+ let a;
21
+ for (const s in w({}, f, e)) {
22
+ if (T.has(s))
22
23
  continue;
23
24
  if (s.startsWith("arg:")) {
24
- p[s.slice(4)] = e[s];
25
+ (a ?? (a = {}))[s.slice(4)] = e[s];
25
26
  continue;
26
27
  }
27
28
  const l = g[s] = e[s];
28
- l !== (u == null ? void 0 : u[s]) && (s.startsWith("set:") ? t[s.slice(4)] = l : l == null || l === !1 ? t.removeAttribute(s) : t.setAttribute(s, l === !0 ? "" : l));
29
+ l !== (f == null ? void 0 : f[s]) && (s.startsWith("set:") ? i[s.slice(4)] = l : l == null || l === !1 ? i.removeAttribute(s) : i.setAttribute(s, l === !0 ? "" : l));
29
30
  }
30
- t.$props = g, a || m(k, t), typeof y == "function" && (t.$ref = y)(t, p);
31
+ a && (i.$args = a), i.$props = g, S || u(k, i), typeof y == "function" && (i.$ref = y)(i);
31
32
  }
32
33
  }
33
- t === i ? i = i.nextSibling : I(n, t, i);
34
+ i === n ? n = n.nextSibling : B(t, i, n);
34
35
  }
35
- for (; i; ) {
36
- const t = i.nextSibling;
37
- i.nodeType === 1 && v(i), n.removeChild(i), i = t;
36
+ for (; n; ) {
37
+ const i = n.nextSibling;
38
+ n.nodeType === 1 && N(n), t.removeChild(n), n = i;
38
39
  }
39
- }, d = function* (e, n = { value: "" }, i = !0) {
40
+ }, d = function* (e, t = { value: "" }, n = !0) {
40
41
  for (e of h(e) ? e : [e])
41
42
  if (!(e == null || typeof e == "boolean"))
42
- if (A(e, "nodeName")) {
43
- const { value: t } = n, { nodeName: o } = e, c = typeof o;
44
- if (t && (yield t, n.value = ""), c === "function")
45
- if (o.constructor.name === "GeneratorFunction") {
46
- const { is: a = o.is ?? "div", ref: f } = e;
47
- e.nodeName = a, delete e.is, e.skip = !0, e.ref = T.bind(null, o, a, f), "children" in e && (e["arg:children"] = e.children, delete e.children), yield e;
48
- } else
49
- delete e.nodeName, yield* d(o(e), n, !1);
50
- else
51
- c === "string" && (yield e);
43
+ if (C(e, "nodeName")) {
44
+ const { value: i } = t, { nodeName: o } = e, c = typeof o;
45
+ i && (yield i, t.value = ""), c === "function" ? o.constructor.name === "GeneratorFunction" ? (e.nodeName = o.is ?? "div", e.skip = !0, e.ref = O.bind(null, o, e.ref), "children" in e && (e["arg:children"] = e.children, delete e.children), yield e) : (delete e.nodeName, yield* d(o(e), t, !1)) : c === "string" && (yield e);
52
46
  } else
53
- h(e) ? yield* d(e, n, !1) : n.value += e;
54
- i && n.value && (yield n.value);
55
- }, T = (e, n, i, t, o) => {
56
- t && (t.$gen ?? (t.$gen = (new M(t, n), e)), t.$ref = C.bind(null, t, i), t.$args = o, t.next());
57
- }, C = (e, n, i, t) => {
58
- i || e.return(), typeof n == "function" && n(i, t);
59
- }, q = (e, n) => w(e) && w(n) ? e.some((i, t) => i !== n[t]) : e !== n, F = new Set("nodeName,key,skip,memo,ref,children".split(",")), I = (e, n, i) => {
60
- if (n.contains(document.activeElement)) {
61
- const t = n.nextSibling;
62
- for (; i && i != n; ) {
63
- const o = i.nextSibling;
64
- e.insertBefore(i, t), i = o;
47
+ h(e) ? yield* d(e, t, !1) : t.value += e;
48
+ n && t.value && (yield t.value);
49
+ }, O = (e, t, n) => {
50
+ n && (n.$gen ?? (n.$gen = (new E(n), e)), n.$ref = q.bind(null, n, t), n.next());
51
+ }, q = (e, t, n) => {
52
+ n || e.return(), typeof t == "function" && t(n);
53
+ }, F = (e, t) => p(e) && p(t) ? e.some((n, i) => n !== t[i]) : e !== t, T = new Set("nodeName,key,skip,memo,ref,children".split(",")), B = (e, t, n) => {
54
+ if (t.contains(document.activeElement)) {
55
+ const i = t.nextSibling;
56
+ for (; n && n != t; ) {
57
+ const o = n.nextSibling;
58
+ e.insertBefore(n, i), n = o;
65
59
  }
66
60
  } else
67
- e.insertBefore(n, i);
68
- }, v = (e) => {
69
- for (const i of e.children)
70
- v(i);
71
- const { $ref: n } = e;
72
- typeof n == "function" && n(null);
73
- for (const i of E(e))
74
- e[i] = null;
61
+ e.insertBefore(t, n);
62
+ }, N = (e) => {
63
+ for (const n of e.children)
64
+ N(n);
65
+ const { $ref: t } = e;
66
+ typeof t == "function" && t(null);
67
+ for (const n of A(e))
68
+ e[n] = null;
75
69
  };
76
- class M {
77
- constructor(n, i) {
78
- return x(n, x(this.constructor.prototype, O(n, i).prototype));
70
+ class E {
71
+ constructor(t) {
72
+ $(t, $(x(this), x(t)));
79
73
  }
80
74
  *[Symbol.iterator]() {
81
75
  for (; ; )
82
- yield this.$args;
76
+ yield this.$args ?? {};
83
77
  }
84
78
  refresh() {
85
- U(this);
79
+ I(this);
86
80
  }
87
81
  next() {
88
82
  try {
89
- m((this.$it ?? (this.$it = this.$gen.call(this, this.$args))).next().value, this), typeof this.$ref == "function" && this.$ref(this);
90
- } catch (n) {
91
- this.throw(n);
83
+ u((this.$it ?? (this.$it = this.$gen.call(this, this.$args ?? {}))).next().value, this), typeof this.$ref == "function" && this.$ref(this);
84
+ } catch (t) {
85
+ this.throw(t);
92
86
  }
93
87
  }
94
- throw(n) {
95
- var i;
96
- for (let t = this; t; t = t.parentNode)
97
- if (typeof ((i = t.$it) == null ? void 0 : i.throw) == "function")
88
+ throw(t) {
89
+ var n;
90
+ for (let i = this; i; i = i.parentNode)
91
+ if (typeof ((n = i.$it) == null ? void 0 : n.throw) == "function")
98
92
  try {
99
- return m(t.$it.throw(n).value, t);
93
+ return u(i.$it.throw(t).value, i);
100
94
  } catch {
101
95
  }
102
- throw n;
96
+ throw t;
103
97
  }
104
98
  return() {
105
- var n;
99
+ var t;
106
100
  try {
107
- (n = this.$it) == null || n.return();
108
- } catch (i) {
109
- this.throw(i);
101
+ (t = this.$it) == null || t.return();
102
+ } catch (n) {
103
+ this.throw(n);
110
104
  } finally {
111
105
  this.$it = null;
112
106
  }
113
107
  }
114
108
  }
115
- let N, r, S;
116
- const O = (e, n) => {
117
- let i = (N ?? (N = /* @__PURE__ */ new Map())).get(n);
118
- return i || ({ constructor: i } = document.createElementNS(e.namespaceURI, n), N.set(n, i === HTMLUnknownElement ? i = HTMLElement : i)), i;
119
- }, U = (e) => {
109
+ let r, v;
110
+ const I = (e) => {
120
111
  (r ?? (r = /* @__PURE__ */ new Set())).has(e) && r.delete(e);
121
- for (const n of r) {
122
- if (n.contains(e))
112
+ for (const t of r) {
113
+ if (t.contains(e))
123
114
  return;
124
- e.contains(n) && r.delete(n);
115
+ e.contains(t) && r.delete(t);
125
116
  }
126
- r.add(e), S ?? (S = requestAnimationFrame(B));
127
- }, B = () => {
117
+ r.add(e), v ?? (v = requestAnimationFrame(P));
118
+ }, P = () => {
128
119
  for (const e of r)
129
120
  e.isConnected && e.next();
130
- r.clear(), S = null;
121
+ r.clear(), v = null;
131
122
  };
132
123
  export {
133
- H as Fragment,
134
- L as h,
135
- m as render
124
+ W as Fragment,
125
+ j as h,
126
+ u as render
136
127
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ajo",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
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
@@ -218,7 +218,7 @@ The `set:` prefix in Ajo allows you to directly set properties on DOM elements f
218
218
  ```jsx
219
219
  function* MyComponent() {
220
220
  const text = "Hello, Ajo!"
221
- yield <div set:textContent={text} skip></div>
221
+ while (true) yield <div set:textContent={text} skip></div>
222
222
  }
223
223
  ```
224
224
  > Here, `set:textContent` directly sets the `textContent` property of the `div`'s DOM node. `skip` is used to prevent Ajo from overriding the `div`'s children.
@@ -227,7 +227,7 @@ function* MyComponent() {
227
227
  ```jsx
228
228
  function* MyComponent() {
229
229
  const html = "<p>Hello, Ajo!</p>"
230
- yield <div set:innerHTML={html} skip></div>
230
+ while (true) yield <div set:innerHTML={html} skip></div>
231
231
  }
232
232
  ```
233
233
  > In this case, `set:innerHTML` is used to set the `innerHTML` property of the `div`'s DOM element. `skip` is used to prevent Ajo from overriding the `div`'s children.
@@ -236,7 +236,7 @@ function* MyComponent() {
236
236
  ```jsx
237
237
  function* MyComponent() {
238
238
  const handleClick = () => console.log('Clicked')
239
- yield <button set:onclick={handleClick}>Click Me</button>
239
+ while (true) yield <button set:onclick={handleClick}>Click Me</button>
240
240
  }
241
241
  ```
242
242
  > `set:onclick` assigns the `handleClick` function as the click event listener for the button.