ajo 0.1.14 → 0.1.15
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 +1 -1
- package/dist/index.js +27 -29
- package/package.json +8 -8
- package/types.ts +74 -61
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=({children:e})=>e,A=function(e,t){const{length:i}=arguments;return(t??(t=C(null))).nodeName=e,"children"in t||i<3||(t.children=i===3?arguments[2]:O.call(arguments,2)),t},
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=({children:e})=>e,A=function(e,t){const{length:i}=arguments;return(t??(t=C(null))).nodeName=e,"children"in t||i<3||(t.children=i===3?arguments[2]:O.call(arguments,2)),t},d=(e,t)=>{let i=t.firstChild;for(e of h(e)){let n=i;if(typeof e=="string"){for(;n&&n.nodeType!=3;)n=n.nextSibling;n?n.data!=e&&(n.data=e):n=document.createTextNode(e)}else if(e instanceof Node)n=e;else{const{nodeName:o,key:a,skip:m,memo:r,ref:s,children:u}=e;for(;n&&!(n.localName===o&&(n.$key??(n.$key=a))==a);)n=n.nextSibling;if(n??(n=g(document.createElementNS(e.xmlns??o==="svg"?T:t.namespaceURI,o),{$key:a})),r==null||P(n.$memo,n.$memo=r)){const{$props:y}=n,w={};for(const l of p(g({},y,e))){if(q.has(l))continue;const f=w[l]=e[l];f!==(y==null?void 0:y[l])&&(l.startsWith("set:")?n[l.slice(4)]=f:f==null||f===!1?n.removeAttribute(l):n.setAttribute(l,f===!0?"":f))}n.$props=w,m||d(u,n),typeof s=="function"&&(n.$ref=s)(n)}}n===i?i=i.nextSibling:E(t,n,i)}for(;i;){const n=i.nextSibling;i.nodeType===1&&N(i),t.removeChild(i),i=n}},{isArray:$,prototype:{slice:O}}=Array,{create:C,keys:p,assign:g,hasOwn:F,setPrototypeOf:x,getPrototypeOf:v}=Object,T="http://www.w3.org/2000/svg",q=new Set("nodeName,key,skip,memo,ref,children".split(",")),S=e=>typeof e!="string"&&typeof(e==null?void 0:e[Symbol.iterator])=="function",P=(e,t)=>$(e)&&$(t)?e.some((i,n)=>i!==t[n]):e!==t,h=function*(e,t={value:""},i=!0){for(e of S(e)?e:[e])if(!(e==null||typeof e=="boolean"))if(F(e,"nodeName")){const{value:n}=t,{nodeName:o}=e,a=typeof o;if(n&&(yield n,t.value=""),a==="function")if(delete e.nodeName,o.constructor.name==="GeneratorFunction"){const m={},r=g({},o.attrs);for(const s of p(e)){const u=e[s];s.startsWith("attr:")&&(r[s.slice(5)]=u),s==="key"||s==="memo"?r[s]=u:m[s]=u}r.nodeName=o.is??"div",r.skip=!0,r.ref=j.bind(null,o,m),yield r}else yield*h(o(e),t,!1);else a==="string"&&(yield e)}else S(e)?yield*h(e,t,!1):t.value+=e;i&&t.value&&(yield t.value)},j=(e,t,i)=>{i&&(i.$gen??(i.$gen=(new W(i),e)),i.$ref=B.bind(null,i),i.$args=t,i.next())},B=(e,t)=>t??e.return(),E=(e,t,i)=>{if(t.contains(document.activeElement)){const n=t.nextSibling;for(;i&&i!=t;){const o=i.nextSibling;e.insertBefore(i,n),i=o}}else e.insertBefore(t,i)},N=e=>{for(const i of e.children)N(i);const{$ref:t}=e;typeof t=="function"&&t(null);for(const i of p(e))e[i]=null};let c,k;const I=()=>{for(const e of c)e.isConnected&&e.next();c.clear(),k=null};class W{constructor(t){x(t,x(v(this),v(t)))}*[Symbol.iterator](){for(;;)yield this.$args??{}}refresh(){(c??(c=new Set)).has(this)&&c.delete(this);for(const t of c){if(t.contains(this))return;this.contains(t)&&c.delete(t)}c.add(this),k??(k=requestAnimationFrame(I))}next(){try{d((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 i;for(let n=this;n;n=n.parentNode)if(typeof((i=n.$it)==null?void 0:i.throw)=="function")try{return d(n.$it.throw(t).value,n)}catch{}throw t}return(){var t;try{(t=this.$it)==null||t.return()}catch(i){this.throw(i)}finally{this.$it=null}}}exports.Fragment=b;exports.h=A;exports.render=d;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const W = ({ children: e }) => e, j = function(e, t) {
|
|
2
2
|
const { length: i } = arguments;
|
|
3
3
|
return (t ?? (t = A(null))).nodeName = e, "children" in t || i < 3 || (t.children = i === 3 ? arguments[2] : b.call(arguments, 2)), t;
|
|
4
4
|
}, d = (e, t) => {
|
|
@@ -16,14 +16,14 @@ const j = ({ children: e }) => e, z = function(e, t) {
|
|
|
16
16
|
for (; n && !(n.localName === o && (n.$key ?? (n.$key = a)) == a); )
|
|
17
17
|
n = n.nextSibling;
|
|
18
18
|
if (n ?? (n = g(document.createElementNS(e.xmlns ?? o === "svg" ? O : t.namespaceURI, o), { $key: a })), r == null || F(n.$memo, n.$memo = r)) {
|
|
19
|
-
const { $props: y } = n,
|
|
20
|
-
for (const
|
|
21
|
-
if (q.has(
|
|
19
|
+
const { $props: y } = n, w = {};
|
|
20
|
+
for (const l of h(g({}, y, e))) {
|
|
21
|
+
if (q.has(l))
|
|
22
22
|
continue;
|
|
23
|
-
const f =
|
|
24
|
-
f !== (y == null ? void 0 : y[
|
|
23
|
+
const f = w[l] = e[l];
|
|
24
|
+
f !== (y == null ? void 0 : y[l]) && (l.startsWith("set:") ? n[l.slice(4)] = f : f == null || f === !1 ? n.removeAttribute(l) : n.setAttribute(l, f === !0 ? "" : f));
|
|
25
25
|
}
|
|
26
|
-
n.$props =
|
|
26
|
+
n.$props = w, m || d(u, n), typeof s == "function" && (n.$ref = s)(n);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
n === i ? i = i.nextSibling : E(t, n, i);
|
|
@@ -32,7 +32,7 @@ const j = ({ children: e }) => e, z = function(e, t) {
|
|
|
32
32
|
const n = i.nextSibling;
|
|
33
33
|
i.nodeType === 1 && k(i), t.removeChild(i), i = n;
|
|
34
34
|
}
|
|
35
|
-
}, { isArray:
|
|
35
|
+
}, { isArray: $, prototype: { slice: b } } = Array, { create: A, keys: h, assign: g, hasOwn: C, setPrototypeOf: x, getPrototypeOf: v } = Object, O = "http://www.w3.org/2000/svg", q = new Set("nodeName,key,skip,memo,ref,children".split(",")), N = (e) => typeof e != "string" && typeof (e == null ? void 0 : e[Symbol.iterator]) == "function", F = (e, t) => $(e) && $(t) ? e.some((i, n) => i !== t[n]) : e !== t, p = function* (e, t = { value: "" }, i = !0) {
|
|
36
36
|
for (e of N(e) ? e : [e])
|
|
37
37
|
if (!(e == null || typeof e == "boolean"))
|
|
38
38
|
if (C(e, "nodeName")) {
|
|
@@ -40,7 +40,7 @@ const j = ({ children: e }) => e, z = function(e, t) {
|
|
|
40
40
|
if (n && (yield n, t.value = ""), a === "function")
|
|
41
41
|
if (delete e.nodeName, o.constructor.name === "GeneratorFunction") {
|
|
42
42
|
const m = {}, r = g({}, o.attrs);
|
|
43
|
-
for (const s of
|
|
43
|
+
for (const s of h(e)) {
|
|
44
44
|
const u = e[s];
|
|
45
45
|
s.startsWith("attr:") && (r[s.slice(5)] = u), s === "key" || s === "memo" ? r[s] = u : m[s] = u;
|
|
46
46
|
}
|
|
@@ -53,7 +53,7 @@ const j = ({ children: e }) => e, z = function(e, t) {
|
|
|
53
53
|
N(e) ? yield* p(e, t, !1) : t.value += e;
|
|
54
54
|
i && t.value && (yield t.value);
|
|
55
55
|
}, T = (e, t, i) => {
|
|
56
|
-
i && (i.$gen ?? (i.$gen = (new
|
|
56
|
+
i && (i.$gen ?? (i.$gen = (new P(i), e)), i.$ref = B.bind(null, i), i.$args = t, i.next());
|
|
57
57
|
}, B = (e, t) => t ?? e.return(), E = (e, t, i) => {
|
|
58
58
|
if (t.contains(document.activeElement)) {
|
|
59
59
|
const n = t.nextSibling;
|
|
@@ -68,10 +68,16 @@ const j = ({ children: e }) => e, z = function(e, t) {
|
|
|
68
68
|
k(i);
|
|
69
69
|
const { $ref: t } = e;
|
|
70
70
|
typeof t == "function" && t(null);
|
|
71
|
-
for (const i of
|
|
71
|
+
for (const i of h(e))
|
|
72
72
|
e[i] = null;
|
|
73
73
|
};
|
|
74
|
-
|
|
74
|
+
let c, S;
|
|
75
|
+
const I = () => {
|
|
76
|
+
for (const e of c)
|
|
77
|
+
e.isConnected && e.next();
|
|
78
|
+
c.clear(), S = null;
|
|
79
|
+
};
|
|
80
|
+
class P {
|
|
75
81
|
constructor(t) {
|
|
76
82
|
x(t, x(v(this), v(t)));
|
|
77
83
|
}
|
|
@@ -80,7 +86,13 @@ class I {
|
|
|
80
86
|
yield this.$args ?? {};
|
|
81
87
|
}
|
|
82
88
|
refresh() {
|
|
83
|
-
|
|
89
|
+
(c ?? (c = /* @__PURE__ */ new Set())).has(this) && c.delete(this);
|
|
90
|
+
for (const t of c) {
|
|
91
|
+
if (t.contains(this))
|
|
92
|
+
return;
|
|
93
|
+
this.contains(t) && c.delete(t);
|
|
94
|
+
}
|
|
95
|
+
c.add(this), S ?? (S = requestAnimationFrame(I));
|
|
84
96
|
}
|
|
85
97
|
next() {
|
|
86
98
|
try {
|
|
@@ -110,22 +122,8 @@ class I {
|
|
|
110
122
|
}
|
|
111
123
|
}
|
|
112
124
|
}
|
|
113
|
-
let l, S;
|
|
114
|
-
const P = (e) => {
|
|
115
|
-
(l ?? (l = /* @__PURE__ */ new Set())).has(e) && l.delete(e);
|
|
116
|
-
for (const t of l) {
|
|
117
|
-
if (t.contains(e))
|
|
118
|
-
return;
|
|
119
|
-
e.contains(t) && l.delete(t);
|
|
120
|
-
}
|
|
121
|
-
l.add(e), S ?? (S = requestAnimationFrame(W));
|
|
122
|
-
}, W = () => {
|
|
123
|
-
for (const e of l)
|
|
124
|
-
e.isConnected && e.next();
|
|
125
|
-
l.clear(), S = null;
|
|
126
|
-
};
|
|
127
125
|
export {
|
|
128
|
-
|
|
129
|
-
|
|
126
|
+
W as Fragment,
|
|
127
|
+
j as h,
|
|
130
128
|
d as render
|
|
131
129
|
};
|
package/package.json
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ajo",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"description": "ajo is a JavaScript view library for building user interfaces",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"module": "./dist/index.js",
|
|
7
|
-
"main": "./dist/index.cjs",
|
|
8
|
-
"types": "./types.ts",
|
|
9
6
|
"exports": {
|
|
10
7
|
".": {
|
|
11
8
|
"import": "./dist/index.js",
|
|
12
|
-
"require": "./dist/index.cjs"
|
|
9
|
+
"require": "./dist/index.cjs",
|
|
10
|
+
"types": "./types.ts"
|
|
13
11
|
},
|
|
14
12
|
"./html": {
|
|
15
13
|
"import": "./dist/html.js",
|
|
16
|
-
"require": "./dist/html.
|
|
14
|
+
"require": "./dist/html.cjs",
|
|
15
|
+
"types": "./types.ts"
|
|
17
16
|
}
|
|
18
17
|
},
|
|
19
18
|
"files": [
|
|
@@ -21,9 +20,10 @@
|
|
|
21
20
|
"types.ts"
|
|
22
21
|
],
|
|
23
22
|
"devDependencies": {
|
|
23
|
+
"@types/node": "^20.12.7",
|
|
24
24
|
"jsdom": "24.0.0",
|
|
25
|
-
"vite": "5.
|
|
26
|
-
"vitest": "1.
|
|
25
|
+
"vite": "5.2.8",
|
|
26
|
+
"vitest": "1.5.0"
|
|
27
27
|
},
|
|
28
28
|
"keywords": [
|
|
29
29
|
"ui",
|
package/types.ts
CHANGED
|
@@ -1,69 +1,82 @@
|
|
|
1
|
-
declare
|
|
2
|
-
|
|
3
|
-
interface VNode<TTag = Tag> extends Partial<AjoProps<ElementType<TTag>>> {
|
|
4
|
-
nodeName: TTag,
|
|
5
|
-
[key: string]: unknown,
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
type Child = null | undefined | boolean | bigint | number | string | symbol | Node | VNode | Iterable<Child>
|
|
9
|
-
|
|
10
|
-
type Tag = keyof (HTMLElementTagNameMap & SVGElementTagNameMap)
|
|
11
|
-
|
|
12
|
-
type ElementType<TTag> =
|
|
13
|
-
TTag extends keyof HTMLElementTagNameMap
|
|
14
|
-
? HTMLElementTagNameMap[TTag]
|
|
15
|
-
: TTag extends keyof SVGElementTagNameMap
|
|
16
|
-
? SVGElementTagNameMap[TTag]
|
|
17
|
-
: HTMLElement
|
|
18
|
-
|
|
19
|
-
type AjoProps<TElement> = {
|
|
20
|
-
key: unknown,
|
|
21
|
-
skip: boolean,
|
|
22
|
-
memo: unknown,
|
|
23
|
-
ref: (el: TElement | null) => void,
|
|
24
|
-
children: Child,
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
type SetProps<TTag> = {
|
|
28
|
-
[K in keyof ElementType<TTag> as `set:${Exclude<K, symbol>}`]: ElementType<TTag>[K]
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
type AttrProps<T> = {
|
|
32
|
-
[K in keyof T as `attr:${Exclude<K, symbol>}`]: T[K]
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
type Context<TArgs> = {
|
|
36
|
-
$args: TArgs
|
|
37
|
-
next: () => void
|
|
38
|
-
throw: (error?: unknown) => void
|
|
39
|
-
return: () => void
|
|
40
|
-
refresh: () => void
|
|
41
|
-
[Symbol.iterator]: () => Generator<TArgs, void, TArgs>
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
type Function<TArgs = {}> = (args: TArgs) => Child
|
|
45
|
-
|
|
46
|
-
type Component<TArgs = {}, TTag extends Tag = 'div'> = {
|
|
47
|
-
(this: ElementType<TTag> & Context<TArgs>, args: TArgs): Generator<Child, void, Child>
|
|
48
|
-
} & (TTag extends 'div' ? { is?: TTag } : { is: TTag })
|
|
49
|
-
}
|
|
1
|
+
declare module 'ajo' {
|
|
50
2
|
|
|
51
|
-
|
|
3
|
+
type Tag = keyof (HTMLElementTagNameMap & SVGElementTagNameMap)
|
|
4
|
+
|
|
5
|
+
type Props = Record<string, unknown>
|
|
6
|
+
|
|
7
|
+
type AjoNode<TTag = Tag> = { nodeName: TTag } & AjoProps<ElementType<TTag>> & Props
|
|
8
|
+
|
|
9
|
+
type Children =
|
|
10
|
+
| null
|
|
11
|
+
| undefined
|
|
12
|
+
| boolean
|
|
13
|
+
| bigint
|
|
14
|
+
| number
|
|
15
|
+
| string
|
|
16
|
+
| symbol
|
|
17
|
+
| Node
|
|
18
|
+
| AjoNode
|
|
19
|
+
| Iterable<Children>
|
|
20
|
+
|
|
21
|
+
type ElementType<TTag = Tag> = TTag extends keyof HTMLElementTagNameMap
|
|
22
|
+
? HTMLElementTagNameMap[TTag]
|
|
23
|
+
: TTag extends keyof SVGElementTagNameMap
|
|
24
|
+
? SVGElementTagNameMap[TTag]
|
|
25
|
+
: never
|
|
26
|
+
|
|
27
|
+
type AjoProps<TElement> = {
|
|
28
|
+
key: unknown
|
|
29
|
+
skip: boolean
|
|
30
|
+
memo: unknown
|
|
31
|
+
ref: (el: TElement | null) => void
|
|
32
|
+
} & ElementChildrenAttribute
|
|
33
|
+
|
|
34
|
+
type SetProps<TTag = Tag> = {
|
|
35
|
+
[K in keyof ElementType<TTag> as `set:${Exclude<K, symbol>}`]: ElementType<TTag>[K]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type AttrProps<TAttribute = Props> = {
|
|
39
|
+
[K in keyof TAttribute as `attr:${Exclude<K, symbol>}`]: TAttribute[K]
|
|
40
|
+
}
|
|
52
41
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
42
|
+
type Context<TArguments = Props> = {
|
|
43
|
+
$args: TArguments
|
|
44
|
+
next: () => void
|
|
45
|
+
throw: (value?: unknown) => void
|
|
46
|
+
return: () => void
|
|
47
|
+
refresh: () => void
|
|
48
|
+
[Symbol.iterator]: () => Generator<TArguments, unknown, unknown>
|
|
49
|
+
}
|
|
56
50
|
|
|
57
|
-
|
|
51
|
+
type Function<TArguments = Props> = (args: TArguments) => Children
|
|
52
|
+
|
|
53
|
+
type Component<TArguments = Props, TTag extends Tag = 'div'> = {
|
|
54
|
+
(this: ComponentElement<TArguments, TTag>, args: TArguments): Generator<Children, unknown, unknown>
|
|
55
|
+
} & (TTag extends 'div' ? { is?: TTag } : { is: TTag })
|
|
56
|
+
|
|
57
|
+
type ComponentElement<TArguments = Props, TTag = Tag> = Context<TArguments> & ElementType<TTag>
|
|
58
|
+
|
|
59
|
+
type IntrinsicElements = {
|
|
60
|
+
[TTag in Tag]: Partial<SetProps<TTag> & AjoProps<ElementType<TTag>>> & Props
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
type IntrinsicAttributes = Partial<Omit<AjoProps<ElementType<Tag>>, 'skip' | 'ref'>> & AttrProps
|
|
64
|
+
|
|
65
|
+
type ElementChildrenAttribute = { children: Children }
|
|
66
|
+
|
|
67
|
+
function Fragment({ children }: ElementChildrenAttribute): typeof children
|
|
68
|
+
function h<TProps = Props>(type: Tag | Function<TProps> | Component<TProps>, props?: TProps | null, ...children: Children[]): AjoNode<typeof type>
|
|
69
|
+
function render(h: Children, el: Element): void
|
|
58
70
|
}
|
|
59
71
|
|
|
60
|
-
declare namespace
|
|
61
|
-
|
|
62
|
-
|
|
72
|
+
declare namespace JSX {
|
|
73
|
+
type ElementChildrenAttribute = import('ajo').ElementChildrenAttribute
|
|
74
|
+
type IntrinsicElements = import('ajo').IntrinsicElements
|
|
75
|
+
type IntrinsicAttributes = import('ajo').IntrinsicAttributes
|
|
63
76
|
}
|
|
64
77
|
|
|
65
|
-
declare
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
78
|
+
declare namespace React {
|
|
79
|
+
const createElement: typeof import('ajo').h
|
|
80
|
+
const Fragment: typeof import('ajo').Fragment
|
|
81
|
+
type ReactNode = import('ajo').Children
|
|
69
82
|
}
|