ajo 0.1.6 → 0.1.7
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/component.cjs +1 -1
- package/dist/component.js +75 -78
- package/package.json +1 -1
- package/readme.md +2 -5
package/dist/component.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./jsx.cjs"),l=require("./util-f79f2bb8.cjs"),f=require("./html.cjs"),d=require("./dom.cjs");let p=0,m;const v=(n,{as:t}={})=>{var o;if(((o=n==null?void 0:n.constructor)==null?void 0:o.name)!=="GeneratorFunction")throw new TypeError("fn is not a generator function");const c=`host-${p++}`;return globalThis.document?(customElements.define(c,class extends x(t){*[Symbol.iterator](){for(;;)yield this.args}next(){var e;try{d.render((this[e=l.Iterator]??(this[e]=n.call(this,this.args))).next().value,this),typeof this[l.Ref]=="function"&&this[l.Ref](this)}catch(r){this.throw(r)}}throw(e){var r;for(let i=this;i;i=i.parentNode)if(typeof((r=i[l.Iterator])==null?void 0:r.throw)=="function")try{return d.render(i[l.Iterator].throw(e).value,i)}catch{continue}throw e}return(){var e;try{(e=this[l.Iterator])==null||e.return()}catch(r){this.throw(r)}finally{this[l.Iterator]=null}}},{extends:t}),({attrs:e={},args:r={},ref:i,...u})=>(w(e,r,u),a.h(t||c,l.assign(e,{is:t&&c,skip:!0,ref:h=>h&&l.assign(h,{[l.Ref]:s=>(s||h.return(),typeof i=="function"&&i(s)),args:r}).next()})))):({attrs:e={},args:r={},...i})=>{w(e,r,i);let u,h;try{const s=n.call(u={args:r,*[Symbol.iterator](){for(;;)yield r},next(){h=f.render(s.next().value)},throw(y){h=f.render(s.throw(y).value)},return(){s.return()}},r);u.next()}catch(s){u.throw(s)}finally{u.return()}return a.h(t||c,l.assign(e,{is:t&&c}),h)}},x=n=>{let t=(m??(m=new Map)).get(n);return t||(t=document.createElement(n).constructor,t===HTMLUnknownElement&&(t=HTMLElement),m.set(n,t)),t},w=(n,t,c)=>{for(const o in c)o.startsWith("arg:")?t[o.slice(4)]=c[o]:o==="children"?t[o]=c[o]:n[o]=c[o]};exports.component=v;
|
package/dist/component.js
CHANGED
|
@@ -1,89 +1,86 @@
|
|
|
1
|
-
import { h as
|
|
2
|
-
import { a, I as u, R as
|
|
1
|
+
import { h as m } from "./jsx.js";
|
|
2
|
+
import { a, I as u, R as f } from "./util-32b33d65.js";
|
|
3
3
|
import { render as w } from "./html.js";
|
|
4
|
-
import { render as
|
|
5
|
-
let
|
|
6
|
-
const
|
|
7
|
-
var
|
|
8
|
-
if (((
|
|
4
|
+
import { render as d } from "./dom.js";
|
|
5
|
+
let v = 0, y;
|
|
6
|
+
const k = (n, { as: t } = {}) => {
|
|
7
|
+
var o;
|
|
8
|
+
if (((o = n == null ? void 0 : n.constructor) == null ? void 0 : o.name) !== "GeneratorFunction")
|
|
9
9
|
throw new TypeError("fn is not a generator function");
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
args: e,
|
|
18
|
-
*[Symbol.iterator]() {
|
|
19
|
-
for (; ; )
|
|
20
|
-
yield e;
|
|
21
|
-
},
|
|
22
|
-
next() {
|
|
23
|
-
s = w(h.next().value);
|
|
24
|
-
},
|
|
25
|
-
throw(v) {
|
|
26
|
-
s = w(h.throw(v).value);
|
|
27
|
-
},
|
|
28
|
-
return() {
|
|
29
|
-
h.return();
|
|
30
|
-
}
|
|
31
|
-
}, e);
|
|
32
|
-
r.next();
|
|
33
|
-
} catch (h) {
|
|
34
|
-
r.throw(h);
|
|
35
|
-
} finally {
|
|
36
|
-
r.return();
|
|
10
|
+
const l = `host-${v++}`;
|
|
11
|
+
return globalThis.document ? (customElements.define(
|
|
12
|
+
l,
|
|
13
|
+
class extends E(t) {
|
|
14
|
+
*[Symbol.iterator]() {
|
|
15
|
+
for (; ; )
|
|
16
|
+
yield this.args;
|
|
37
17
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
next() {
|
|
46
|
-
var e;
|
|
47
|
-
try {
|
|
48
|
-
p((this[e = u] ?? (this[e] = n.call(this, this.args))).next().value, this), typeof this[m] == "function" && this[m](this);
|
|
49
|
-
} catch (l) {
|
|
50
|
-
this.throw(l);
|
|
18
|
+
next() {
|
|
19
|
+
var e;
|
|
20
|
+
try {
|
|
21
|
+
d((this[e = u] ?? (this[e] = n.call(this, this.args))).next().value, this), typeof this[f] == "function" && this[f](this);
|
|
22
|
+
} catch (r) {
|
|
23
|
+
this.throw(r);
|
|
24
|
+
}
|
|
51
25
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
throw e;
|
|
64
|
-
}
|
|
65
|
-
return() {
|
|
66
|
-
var e;
|
|
67
|
-
try {
|
|
68
|
-
(e = this[u]) == null || e.return();
|
|
69
|
-
} catch (l) {
|
|
70
|
-
this.throw(l);
|
|
71
|
-
} finally {
|
|
72
|
-
this[u] = null;
|
|
26
|
+
throw(e) {
|
|
27
|
+
var r;
|
|
28
|
+
for (let i = this; i; i = i.parentNode)
|
|
29
|
+
if (typeof ((r = i[u]) == null ? void 0 : r.throw) == "function")
|
|
30
|
+
try {
|
|
31
|
+
return d(i[u].throw(e).value, i);
|
|
32
|
+
} catch {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
throw e;
|
|
73
36
|
}
|
|
37
|
+
return() {
|
|
38
|
+
var e;
|
|
39
|
+
try {
|
|
40
|
+
(e = this[u]) == null || e.return();
|
|
41
|
+
} catch (r) {
|
|
42
|
+
this.throw(r);
|
|
43
|
+
} finally {
|
|
44
|
+
this[u] = null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
{ extends: t }
|
|
49
|
+
), ({ attrs: e = {}, args: r = {}, ref: i, ...s }) => (p(e, r, s), m(t || l, a(e, { is: t && l, skip: !0, ref: (h) => h && a(h, { [f]: (c) => (c || h.return(), typeof i == "function" && i(c)), args: r }).next() })))) : ({ attrs: e = {}, args: r = {}, ...i }) => {
|
|
50
|
+
p(e, r, i);
|
|
51
|
+
let s, h;
|
|
52
|
+
try {
|
|
53
|
+
const c = n.call(s = {
|
|
54
|
+
args: r,
|
|
55
|
+
*[Symbol.iterator]() {
|
|
56
|
+
for (; ; )
|
|
57
|
+
yield r;
|
|
58
|
+
},
|
|
59
|
+
next() {
|
|
60
|
+
h = w(c.next().value);
|
|
61
|
+
},
|
|
62
|
+
throw(x) {
|
|
63
|
+
h = w(c.throw(x).value);
|
|
64
|
+
},
|
|
65
|
+
return() {
|
|
66
|
+
c.return();
|
|
67
|
+
}
|
|
68
|
+
}, r);
|
|
69
|
+
s.next();
|
|
70
|
+
} catch (c) {
|
|
71
|
+
s.throw(c);
|
|
72
|
+
} finally {
|
|
73
|
+
s.return();
|
|
74
74
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
return customElements.define(o, i, { extends: t }), ({ attrs: c = {}, args: e = {}, ref: l, ...r }) => (x(c, e, r), d(t || o, a(c, { is: t && o, skip: !0, ref: (s) => a(s, { [m]: l, args: e }).next() })));
|
|
80
|
-
}, b = (n) => {
|
|
75
|
+
return m(t || l, a(e, { is: t && l }), h);
|
|
76
|
+
};
|
|
77
|
+
}, E = (n) => {
|
|
81
78
|
let t = (y ?? (y = /* @__PURE__ */ new Map())).get(n);
|
|
82
79
|
return t || (t = document.createElement(n).constructor, t === HTMLUnknownElement && (t = HTMLElement), y.set(n, t)), t;
|
|
83
|
-
},
|
|
84
|
-
for (const
|
|
85
|
-
|
|
80
|
+
}, p = (n, t, l) => {
|
|
81
|
+
for (const o in l)
|
|
82
|
+
o.startsWith("arg:") ? t[o.slice(4)] = l[o] : o === "children" ? t[o] = l[o] : n[o] = l[o];
|
|
86
83
|
};
|
|
87
84
|
export {
|
|
88
|
-
|
|
85
|
+
k as component
|
|
89
86
|
};
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -11,8 +11,7 @@ npm install ajo
|
|
|
11
11
|
|
|
12
12
|
```jsx
|
|
13
13
|
/** @jsx h */
|
|
14
|
-
import { h } from 'ajo'
|
|
15
|
-
import { render } from 'ajo/dom'
|
|
14
|
+
import { h, render } from 'ajo'
|
|
16
15
|
|
|
17
16
|
document.body.innerHTML = '<div>Hello World</div>'
|
|
18
17
|
|
|
@@ -34,9 +33,7 @@ render(<Greet name="World" />, document.body)
|
|
|
34
33
|
|
|
35
34
|
```jsx
|
|
36
35
|
/** @jsx h */
|
|
37
|
-
import { h } from 'ajo'
|
|
38
|
-
import { render } from 'ajo/dom'
|
|
39
|
-
import { component } from 'ajo/component'
|
|
36
|
+
import { h, render, component } from 'ajo'
|
|
40
37
|
|
|
41
38
|
const Counter = component(function* ({ init = 0 }) {
|
|
42
39
|
|