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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./jsx.cjs"),o=require("./util-f79f2bb8.cjs"),f=require("./html.cjs"),m=require("./dom.cjs");let v=0,w;const x=(n,{as:t}={})=>{var a;if(((a=n==null?void 0:n.constructor)==null?void 0:a.name)!=="GeneratorFunction")throw new TypeError("fn is not a generator function");const i=`host-${v++}`;if(!globalThis.document)return({attrs:s={},args:e={},...c})=>{y(s,e,c);let r,u;try{const h=n.call(r={args:e,*[Symbol.iterator](){for(;;)yield e},next(){u=f.render(h.next().value)},throw(p){u=f.render(h.throw(p).value)},return(){h.return()}},e);r.next()}catch(h){r.throw(h)}finally{r.return()}return d.h(t||i,o.assign(s,{is:t&&i}),u)};class l extends b(t){*[Symbol.iterator](){for(;;)yield this.args}next(){var e;try{m.render((this[e=o.Iterator]??(this[e]=n.call(this,this.args))).next().value,this),typeof this[o.Ref]=="function"&&this[o.Ref](this)}catch(c){this.throw(c)}}throw(e){var c;for(let r=this;r;r=r.parentNode)if(typeof((c=r[o.Iterator])==null?void 0:c.throw)=="function")try{m.render(r[o.Iterator].throw(e).value,r);return}catch{continue}throw e}return(){var e;try{(e=this[o.Iterator])==null||e.return()}catch(c){this.throw(c)}finally{this[o.Iterator]=null}}disconnectedCallback(){this.return()}}return customElements.define(i,l,{extends:t}),({attrs:s={},args:e={},ref:c,...r})=>(y(s,e,r),d.h(t||i,o.assign(s,{is:t&&i,skip:!0,ref:u=>o.assign(u,{[o.Ref]:c,args:e}).next()})))},b=n=>{let t=(w??(w=new Map)).get(n);return t||(t=document.createElement(n).constructor,t===HTMLUnknownElement&&(t=HTMLElement),w.set(n,t)),t},y=(n,t,i)=>{for(const l in i)l.startsWith("arg:")?t[l.slice(4)]=i[l]:l==="children"?t[l]=i[l]:n[l]=i[l]};exports.component=x;
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 d } from "./jsx.js";
2
- import { a, I as u, R as m } from "./util-32b33d65.js";
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 p } from "./dom.js";
5
- let E = 0, y;
6
- const C = (n, { as: t } = {}) => {
7
- var f;
8
- if (((f = n == null ? void 0 : n.constructor) == null ? void 0 : f.name) !== "GeneratorFunction")
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 o = `host-${E++}`;
11
- if (!globalThis.document)
12
- return ({ attrs: c = {}, args: e = {}, ...l }) => {
13
- x(c, e, l);
14
- let r, s;
15
- try {
16
- const h = n.call(r = {
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
- return d(t || o, a(c, { is: t && o }), s);
39
- };
40
- class i extends b(t) {
41
- *[Symbol.iterator]() {
42
- for (; ; )
43
- yield this.args;
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
- throw(e) {
54
- var l;
55
- for (let r = this; r; r = r.parentNode)
56
- if (typeof ((l = r[u]) == null ? void 0 : l.throw) == "function")
57
- try {
58
- p(r[u].throw(e).value, r);
59
- return;
60
- } catch {
61
- continue;
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
- disconnectedCallback() {
76
- this.return();
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
- }, x = (n, t, o) => {
84
- for (const i in o)
85
- i.startsWith("arg:") ? t[i.slice(4)] = o[i] : i === "children" ? t[i] = o[i] : n[i] = o[i];
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
- C as component
85
+ k as component
89
86
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ajo",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
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
@@ -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