ddd-react 1.7.2 → 1.8.0
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.d.ts +2 -0
- package/dist/index.mjs +259 -254
- package/dist/jsx-dev-runtime.d.ts +2 -1
- package/dist/jsx-runtime.d.ts +4 -1
- package/package.json +1 -1
- package/dist/jsx/jsx-dev-runtime.d.ts +0 -2
- package/dist/jsx/jsx-runtime.d.ts +0 -4
package/dist/component.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare abstract class Component<P = {}, S = {}, C = null> {
|
|
|
4
4
|
vdom: VDOMNode | null;
|
|
5
5
|
private hostEl;
|
|
6
6
|
parent: Component | null;
|
|
7
|
+
static defaultProps: any;
|
|
7
8
|
props: P & WithChildrenProps;
|
|
8
9
|
state: S;
|
|
9
10
|
context: C;
|
|
@@ -37,4 +38,5 @@ export declare abstract class Component<P = {}, S = {}, C = null> {
|
|
|
37
38
|
private patch;
|
|
38
39
|
private updateContext;
|
|
39
40
|
private subscribeToProvider;
|
|
41
|
+
getDefaultProps(): P;
|
|
40
42
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,157 +1,157 @@
|
|
|
1
1
|
import { D as c, e as v, a as x, A as E, b as U, h as F, c as I } from "./h-BbaMkkC7.mjs";
|
|
2
|
-
import { d as
|
|
3
|
-
function g(
|
|
4
|
-
if (
|
|
5
|
-
return
|
|
6
|
-
if (typeof
|
|
2
|
+
import { d as Ot, f as mt } from "./h-BbaMkkC7.mjs";
|
|
3
|
+
function g(e, t) {
|
|
4
|
+
if (e === null || t === null || e === void 0 || t === void 0)
|
|
5
|
+
return e === t;
|
|
6
|
+
if (typeof e != typeof t)
|
|
7
7
|
return !1;
|
|
8
|
-
if (Object.is(
|
|
8
|
+
if (Object.is(e, t))
|
|
9
9
|
return !0;
|
|
10
|
-
if (typeof
|
|
11
|
-
if (
|
|
10
|
+
if (typeof e == "object") {
|
|
11
|
+
if (e.constructor !== t.constructor)
|
|
12
12
|
return !1;
|
|
13
|
-
if (Array.isArray(
|
|
14
|
-
if (
|
|
13
|
+
if (Array.isArray(e)) {
|
|
14
|
+
if (e.length !== t.length)
|
|
15
15
|
return !1;
|
|
16
|
-
for (let n = 0; n <
|
|
17
|
-
if (!g(
|
|
16
|
+
for (let n = 0; n < e.length; ++n)
|
|
17
|
+
if (!g(e[n], t[n]))
|
|
18
18
|
return !1;
|
|
19
19
|
return !0;
|
|
20
20
|
}
|
|
21
|
-
if (
|
|
22
|
-
return
|
|
23
|
-
if (
|
|
24
|
-
return
|
|
25
|
-
if (
|
|
26
|
-
return
|
|
27
|
-
const r = Object.keys(
|
|
28
|
-
if (r.length !== Object.keys(
|
|
21
|
+
if (e.constructor === RegExp)
|
|
22
|
+
return e.source === t.source && e.flags === t.flags;
|
|
23
|
+
if (e.valueOf !== Object.prototype.valueOf)
|
|
24
|
+
return e.valueOf() === t.valueOf();
|
|
25
|
+
if (e.toString !== Object.prototype.toString)
|
|
26
|
+
return e.toString() === t.toString();
|
|
27
|
+
const r = Object.keys(e);
|
|
28
|
+
if (r.length !== Object.keys(t).length)
|
|
29
29
|
return !1;
|
|
30
30
|
for (let n = 0; n < r.length; ++n)
|
|
31
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
31
|
+
if (!Object.prototype.hasOwnProperty.call(t, r[n]))
|
|
32
32
|
return !1;
|
|
33
33
|
for (let n = 0; n < r.length; ++n) {
|
|
34
34
|
const s = r[n];
|
|
35
|
-
if (!(s === "_owner" &&
|
|
35
|
+
if (!(s === "_owner" && e.$$typeof) && !g(e[s], t[s]))
|
|
36
36
|
return !1;
|
|
37
37
|
}
|
|
38
38
|
return !0;
|
|
39
39
|
}
|
|
40
40
|
return !1;
|
|
41
41
|
}
|
|
42
|
-
function S(
|
|
42
|
+
function S(e, t, r, n = null) {
|
|
43
43
|
function s(i) {
|
|
44
44
|
const o = i;
|
|
45
|
-
n ?
|
|
45
|
+
n ? t.call(n, o) : t(o);
|
|
46
46
|
}
|
|
47
|
-
return r.addEventListener(
|
|
47
|
+
return r.addEventListener(e, s), s;
|
|
48
48
|
}
|
|
49
|
-
function $(
|
|
49
|
+
function $(e = {}, t, r = null) {
|
|
50
50
|
const n = {};
|
|
51
|
-
return Object.entries(
|
|
51
|
+
return Object.entries(e).forEach(([s, i]) => {
|
|
52
52
|
n[s] = S(
|
|
53
53
|
s,
|
|
54
54
|
i,
|
|
55
|
-
|
|
55
|
+
t,
|
|
56
56
|
r
|
|
57
57
|
);
|
|
58
58
|
}), n;
|
|
59
59
|
}
|
|
60
|
-
function q(
|
|
61
|
-
Object.entries(
|
|
62
|
-
|
|
60
|
+
function q(e = {}, t) {
|
|
61
|
+
Object.entries(e).forEach(([r, n]) => {
|
|
62
|
+
t.removeEventListener(r, n);
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
function h(
|
|
66
|
-
const { type:
|
|
67
|
-
switch (
|
|
65
|
+
function h(e) {
|
|
66
|
+
const { type: t } = e;
|
|
67
|
+
switch (t) {
|
|
68
68
|
case c.TEXT: {
|
|
69
|
-
G(
|
|
69
|
+
G(e);
|
|
70
70
|
break;
|
|
71
71
|
}
|
|
72
72
|
case c.ELEMENT: {
|
|
73
|
-
_(
|
|
73
|
+
_(e);
|
|
74
74
|
break;
|
|
75
75
|
}
|
|
76
76
|
case c.FRAGMENT: {
|
|
77
|
-
B(
|
|
77
|
+
B(e);
|
|
78
78
|
break;
|
|
79
79
|
}
|
|
80
80
|
case c.COMPONENT: {
|
|
81
|
-
|
|
81
|
+
e.component?.unmount();
|
|
82
82
|
break;
|
|
83
83
|
}
|
|
84
84
|
case c.PORTAL: {
|
|
85
|
-
X(
|
|
85
|
+
X(e);
|
|
86
86
|
break;
|
|
87
87
|
}
|
|
88
88
|
default:
|
|
89
|
-
throw new Error(`Can't destroy DOM of type: ${
|
|
89
|
+
throw new Error(`Can't destroy DOM of type: ${t}`);
|
|
90
90
|
}
|
|
91
|
-
delete
|
|
91
|
+
delete e.el;
|
|
92
92
|
}
|
|
93
|
-
function G(
|
|
94
|
-
const { el:
|
|
95
|
-
|
|
93
|
+
function G(e) {
|
|
94
|
+
const { el: t } = e;
|
|
95
|
+
t && t.remove();
|
|
96
96
|
}
|
|
97
|
-
function _(
|
|
98
|
-
const { el:
|
|
99
|
-
s?.ref && typeof s.ref == "object" && "current" in s.ref && (s.ref.current = null),
|
|
97
|
+
function _(e) {
|
|
98
|
+
const { el: t, children: r, listeners: n, props: s } = e;
|
|
99
|
+
s?.ref && typeof s.ref == "object" && "current" in s.ref && (s.ref.current = null), t && t.remove(), r && r.forEach(h), n && t && (q(n, t), delete e.listeners);
|
|
100
100
|
}
|
|
101
|
-
function B(
|
|
102
|
-
const { children:
|
|
103
|
-
|
|
101
|
+
function B(e) {
|
|
102
|
+
const { children: t } = e;
|
|
103
|
+
t && t.forEach(h);
|
|
104
104
|
}
|
|
105
|
-
function X(
|
|
106
|
-
const { children:
|
|
107
|
-
|
|
105
|
+
function X(e) {
|
|
106
|
+
const { children: t } = e;
|
|
107
|
+
t && t.forEach(h);
|
|
108
108
|
}
|
|
109
|
-
function C(
|
|
110
|
-
|
|
109
|
+
function C(e, t, r) {
|
|
110
|
+
e.style[t] = r.toString();
|
|
111
111
|
}
|
|
112
|
-
function J(
|
|
113
|
-
|
|
112
|
+
function J(e, t) {
|
|
113
|
+
e.style[t] = null;
|
|
114
114
|
}
|
|
115
|
-
function K(
|
|
116
|
-
const { class: r, style: n, ...s } =
|
|
117
|
-
r && W(
|
|
118
|
-
C(
|
|
115
|
+
function K(e, t) {
|
|
116
|
+
const { class: r, style: n, ...s } = t;
|
|
117
|
+
r && W(e, r), n && Object.entries(n).forEach(([i, o]) => {
|
|
118
|
+
C(e, i, o);
|
|
119
119
|
});
|
|
120
120
|
for (const [i, o] of Object.entries(s))
|
|
121
|
-
w(
|
|
121
|
+
w(e, i, o);
|
|
122
122
|
}
|
|
123
|
-
function W(
|
|
124
|
-
if (
|
|
125
|
-
|
|
123
|
+
function W(e, t) {
|
|
124
|
+
if (e instanceof SVGElement) {
|
|
125
|
+
e.removeAttribute("class"), typeof t == "string" ? e.setAttribute("class", t) : Array.isArray(t) && e.classList.add(...t);
|
|
126
126
|
return;
|
|
127
127
|
}
|
|
128
|
-
|
|
128
|
+
e.className = "", typeof t == "string" ? e.className = t : Array.isArray(t) && e.classList.add(...t);
|
|
129
129
|
}
|
|
130
|
-
function w(
|
|
131
|
-
r == null ? L(
|
|
130
|
+
function w(e, t, r) {
|
|
131
|
+
r == null ? L(e, t) : e.setAttribute(t, String(r));
|
|
132
132
|
}
|
|
133
|
-
function L(
|
|
134
|
-
t
|
|
133
|
+
function L(e, t) {
|
|
134
|
+
e[t] = null, e.removeAttribute(t);
|
|
135
135
|
}
|
|
136
136
|
let P = !1;
|
|
137
137
|
const O = [];
|
|
138
|
-
function d(
|
|
139
|
-
O.push(
|
|
138
|
+
function d(e) {
|
|
139
|
+
O.push(e), Y();
|
|
140
140
|
}
|
|
141
141
|
function Y() {
|
|
142
142
|
P || (P = !0, queueMicrotask(H));
|
|
143
143
|
}
|
|
144
144
|
function H() {
|
|
145
145
|
for (; O.length > 0; ) {
|
|
146
|
-
const
|
|
147
|
-
let
|
|
146
|
+
const e = O.shift();
|
|
147
|
+
let t;
|
|
148
148
|
try {
|
|
149
|
-
|
|
149
|
+
t = e();
|
|
150
150
|
} catch (r) {
|
|
151
151
|
console.error(`[scheduler]: ${r}`);
|
|
152
152
|
continue;
|
|
153
153
|
}
|
|
154
|
-
Promise.resolve(
|
|
154
|
+
Promise.resolve(t).then(
|
|
155
155
|
() => {
|
|
156
156
|
},
|
|
157
157
|
(r) => {
|
|
@@ -161,166 +161,166 @@ function H() {
|
|
|
161
161
|
}
|
|
162
162
|
P = !1;
|
|
163
163
|
}
|
|
164
|
-
function A(
|
|
165
|
-
const { on:
|
|
166
|
-
return delete r.key, { props: r, events:
|
|
164
|
+
function A(e) {
|
|
165
|
+
const { on: t = {}, ...r } = e.props;
|
|
166
|
+
return delete r.key, { props: r, events: t };
|
|
167
167
|
}
|
|
168
|
-
function p(
|
|
169
|
-
switch (
|
|
168
|
+
function p(e, t, r = null, n = null) {
|
|
169
|
+
switch (e.type) {
|
|
170
170
|
case c.TEXT: {
|
|
171
|
-
z(
|
|
171
|
+
z(e, t, r);
|
|
172
172
|
break;
|
|
173
173
|
}
|
|
174
174
|
case c.ELEMENT: {
|
|
175
|
-
Z(
|
|
175
|
+
Z(e, t, r, n);
|
|
176
176
|
break;
|
|
177
177
|
}
|
|
178
178
|
case c.FRAGMENT: {
|
|
179
|
-
Q(
|
|
179
|
+
Q(e, t, r, n);
|
|
180
180
|
break;
|
|
181
181
|
}
|
|
182
182
|
case c.COMPONENT: {
|
|
183
|
-
|
|
184
|
-
const s =
|
|
183
|
+
tt(e, t, r, n);
|
|
184
|
+
const s = e.component;
|
|
185
185
|
s && d(() => s.didMount());
|
|
186
186
|
break;
|
|
187
187
|
}
|
|
188
188
|
case c.PORTAL: {
|
|
189
|
-
|
|
189
|
+
et(e, n);
|
|
190
190
|
break;
|
|
191
191
|
}
|
|
192
192
|
default:
|
|
193
|
-
throw new Error(`Can't mount DOM of type: ${
|
|
193
|
+
throw new Error(`Can't mount DOM of type: ${e.type}`);
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
function z(
|
|
197
|
-
const { value: n } =
|
|
198
|
-
|
|
196
|
+
function z(e, t, r) {
|
|
197
|
+
const { value: n } = e, s = document.createTextNode(n);
|
|
198
|
+
e.el = s, j(s, t, r);
|
|
199
199
|
}
|
|
200
|
-
function Q(
|
|
201
|
-
const { children: s } =
|
|
202
|
-
|
|
203
|
-
p(i,
|
|
200
|
+
function Q(e, t, r, n) {
|
|
201
|
+
const { children: s } = e;
|
|
202
|
+
e.el = t, s?.forEach((i, o) => {
|
|
203
|
+
p(i, t, r != null ? r + o : null, n);
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
|
-
function Z(
|
|
207
|
-
const { tag: s, children: i } =
|
|
208
|
-
V(
|
|
209
|
-
p(l,
|
|
210
|
-
}), j(
|
|
206
|
+
function Z(e, t, r, n) {
|
|
207
|
+
const { tag: s, children: i } = e, f = s === "svg" || t instanceof SVGElement ? document.createElementNS("http://www.w3.org/2000/svg", s) : document.createElement(s);
|
|
208
|
+
V(f, e, n), e.el = f, i?.forEach((l) => {
|
|
209
|
+
p(l, f, null, n);
|
|
210
|
+
}), j(f, t, r);
|
|
211
211
|
}
|
|
212
|
-
function V(
|
|
213
|
-
const { props: n, events: s } = A(
|
|
214
|
-
n.ref && typeof n.ref == "object" && "current" in n.ref && (n.ref.current =
|
|
212
|
+
function V(e, t, r) {
|
|
213
|
+
const { props: n, events: s } = A(t);
|
|
214
|
+
n.ref && typeof n.ref == "object" && "current" in n.ref && (n.ref.current = e, delete n.ref), t.listeners = $(s, e, r), K(e, n);
|
|
215
215
|
}
|
|
216
|
-
function
|
|
217
|
-
const s =
|
|
218
|
-
o.mount(
|
|
216
|
+
function tt(e, t, r, n) {
|
|
217
|
+
const s = e.tag, { props: i } = A(e), o = new s(i, n);
|
|
218
|
+
o.mount(t, r), e.component = o, e.el = o.firstElement || null;
|
|
219
219
|
}
|
|
220
|
-
function j(
|
|
220
|
+
function j(e, t, r) {
|
|
221
221
|
if (r == null) {
|
|
222
|
-
|
|
222
|
+
t.append(e);
|
|
223
223
|
return;
|
|
224
224
|
}
|
|
225
225
|
if (r < 0)
|
|
226
226
|
throw new Error(`Index must be a positive integer, got ${r}`);
|
|
227
|
-
const n =
|
|
228
|
-
r >= n.length ?
|
|
227
|
+
const n = t.childNodes;
|
|
228
|
+
r >= n.length ? t.append(e) : t.insertBefore(e, n[r]);
|
|
229
229
|
}
|
|
230
|
-
function
|
|
231
|
-
const { children: r, container: n } =
|
|
230
|
+
function et(e, t) {
|
|
231
|
+
const { children: r, container: n } = e;
|
|
232
232
|
r?.forEach((s) => {
|
|
233
|
-
p(s, n, null,
|
|
233
|
+
p(s, n, null, t);
|
|
234
234
|
});
|
|
235
235
|
}
|
|
236
|
-
function D(
|
|
237
|
-
if (
|
|
236
|
+
function D(e, t) {
|
|
237
|
+
if (e.type !== t.type)
|
|
238
238
|
return !1;
|
|
239
|
-
if (
|
|
240
|
-
const r =
|
|
239
|
+
if (e.type === c.ELEMENT) {
|
|
240
|
+
const r = e, n = t, {
|
|
241
241
|
tag: s,
|
|
242
242
|
props: { key: i }
|
|
243
243
|
} = r, {
|
|
244
244
|
tag: o,
|
|
245
|
-
props: { key:
|
|
245
|
+
props: { key: f }
|
|
246
246
|
} = n;
|
|
247
|
-
return s === o && i ===
|
|
247
|
+
return s === o && i === f;
|
|
248
248
|
}
|
|
249
|
-
if (
|
|
250
|
-
const r =
|
|
249
|
+
if (e.type === c.COMPONENT) {
|
|
250
|
+
const r = e, n = t, { tag: s } = r, { tag: i } = n;
|
|
251
251
|
return s === i;
|
|
252
252
|
}
|
|
253
|
-
if (
|
|
254
|
-
const r =
|
|
253
|
+
if (e.type === c.PORTAL) {
|
|
254
|
+
const r = e, n = t;
|
|
255
255
|
return r.container === n.container;
|
|
256
256
|
}
|
|
257
257
|
return !0;
|
|
258
258
|
}
|
|
259
|
-
function T(
|
|
260
|
-
const r = Object.keys(
|
|
259
|
+
function T(e, t) {
|
|
260
|
+
const r = Object.keys(e), n = Object.keys(t), s = [], i = [];
|
|
261
261
|
for (const o of n)
|
|
262
|
-
o in
|
|
262
|
+
o in e ? e[o] !== t[o] && i.push(o) : s.push(o);
|
|
263
263
|
return {
|
|
264
264
|
added: s,
|
|
265
|
-
removed: r.filter((o) => !(o in
|
|
265
|
+
removed: r.filter((o) => !(o in t)),
|
|
266
266
|
updated: i
|
|
267
267
|
};
|
|
268
268
|
}
|
|
269
|
-
function
|
|
270
|
-
return
|
|
269
|
+
function rt(e) {
|
|
270
|
+
return e !== "";
|
|
271
271
|
}
|
|
272
|
-
function N(
|
|
273
|
-
return
|
|
272
|
+
function N(e) {
|
|
273
|
+
return rt(e.trim());
|
|
274
274
|
}
|
|
275
|
-
function m(
|
|
276
|
-
if (!D(
|
|
277
|
-
const s =
|
|
278
|
-
return h(
|
|
275
|
+
function m(e, t, r, n = null) {
|
|
276
|
+
if (!D(e, t)) {
|
|
277
|
+
const s = nt(r, e.el);
|
|
278
|
+
return h(e), p(t, r, s, n), t;
|
|
279
279
|
}
|
|
280
|
-
switch (
|
|
280
|
+
switch (t.el = e.el, t.type) {
|
|
281
281
|
case c.TEXT:
|
|
282
|
-
return
|
|
282
|
+
return st(e, t), t;
|
|
283
283
|
case c.ELEMENT: {
|
|
284
|
-
|
|
284
|
+
ot(e, t, n);
|
|
285
285
|
break;
|
|
286
286
|
}
|
|
287
287
|
case c.COMPONENT: {
|
|
288
|
-
|
|
288
|
+
lt(e, t);
|
|
289
289
|
break;
|
|
290
290
|
}
|
|
291
291
|
case c.PORTAL: {
|
|
292
|
-
|
|
292
|
+
at(e, t, n);
|
|
293
293
|
break;
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
|
-
return R(
|
|
296
|
+
return R(e, t, n), t;
|
|
297
297
|
}
|
|
298
|
-
function
|
|
299
|
-
if (!
|
|
300
|
-
const r = Array.from(
|
|
298
|
+
function nt(e, t) {
|
|
299
|
+
if (!t) return null;
|
|
300
|
+
const r = Array.from(e.childNodes).indexOf(t);
|
|
301
301
|
return r < 0 ? null : r;
|
|
302
302
|
}
|
|
303
|
-
function
|
|
304
|
-
const r =
|
|
303
|
+
function st(e, t) {
|
|
304
|
+
const r = e.el, { value: n } = e, { value: s } = t;
|
|
305
305
|
n !== s && r && (r.nodeValue = s);
|
|
306
306
|
}
|
|
307
|
-
function
|
|
308
|
-
const n =
|
|
307
|
+
function ot(e, t, r) {
|
|
308
|
+
const n = e.el, {
|
|
309
309
|
class: s,
|
|
310
310
|
style: i,
|
|
311
311
|
on: o,
|
|
312
|
-
...
|
|
313
|
-
} =
|
|
312
|
+
...f
|
|
313
|
+
} = e.props ?? {}, {
|
|
314
314
|
class: l,
|
|
315
|
-
style:
|
|
315
|
+
style: u,
|
|
316
316
|
on: a,
|
|
317
317
|
...y
|
|
318
|
-
} =
|
|
319
|
-
|
|
318
|
+
} = t.props ?? {}, { listeners: b } = e;
|
|
319
|
+
it(n, f, y), ct(n, s, l), ut(
|
|
320
320
|
n,
|
|
321
321
|
i,
|
|
322
|
-
|
|
323
|
-
),
|
|
322
|
+
u
|
|
323
|
+
), t.listeners = ft(
|
|
324
324
|
n,
|
|
325
325
|
b,
|
|
326
326
|
o ?? {},
|
|
@@ -328,90 +328,91 @@ function oe(t, e, r) {
|
|
|
328
328
|
r
|
|
329
329
|
);
|
|
330
330
|
}
|
|
331
|
-
function
|
|
332
|
-
const n =
|
|
333
|
-
n !== s && (n && typeof n == "object" && "current" in n && (n.current = null), s && typeof s == "object" && "current" in s && (s.current =
|
|
334
|
-
const i = { ...
|
|
331
|
+
function it(e, t = {}, r = {}) {
|
|
332
|
+
const n = t.ref, s = r.ref;
|
|
333
|
+
n !== s && (n && typeof n == "object" && "current" in n && (n.current = null), s && typeof s == "object" && "current" in s && (s.current = e));
|
|
334
|
+
const i = { ...t }, o = { ...r };
|
|
335
335
|
delete i.ref, delete o.ref;
|
|
336
|
-
const { added:
|
|
336
|
+
const { added: f, removed: l, updated: u } = T(i, o);
|
|
337
337
|
for (const a of l)
|
|
338
|
-
L(
|
|
339
|
-
for (const a of
|
|
340
|
-
w(
|
|
338
|
+
L(e, a);
|
|
339
|
+
for (const a of f.concat(u))
|
|
340
|
+
w(e, a, o[a]);
|
|
341
341
|
}
|
|
342
|
-
function
|
|
343
|
-
const n = M(
|
|
344
|
-
o.length > 0 &&
|
|
342
|
+
function ct(e, t, r) {
|
|
343
|
+
const n = M(t), s = M(r), { added: i, removed: o } = U(n, s);
|
|
344
|
+
o.length > 0 && e.classList.remove(...o), i.length > 0 && e.classList.add(...i);
|
|
345
345
|
}
|
|
346
|
-
function M(
|
|
347
|
-
return Array.isArray(
|
|
346
|
+
function M(e = "") {
|
|
347
|
+
return Array.isArray(e) ? e.filter(N) : String(e).split(/(\s+)/).filter(N);
|
|
348
348
|
}
|
|
349
|
-
function
|
|
350
|
-
const { added: n, removed: s, updated: i } = T(
|
|
349
|
+
function ut(e, t = {}, r = {}) {
|
|
350
|
+
const { added: n, removed: s, updated: i } = T(t, r);
|
|
351
351
|
for (const o of s)
|
|
352
|
-
J(
|
|
352
|
+
J(e, o);
|
|
353
353
|
for (const o of n.concat(i))
|
|
354
|
-
C(
|
|
354
|
+
C(e, o, r[o]);
|
|
355
355
|
}
|
|
356
|
-
function
|
|
357
|
-
const { removed: i, added: o, updated:
|
|
358
|
-
for (const
|
|
359
|
-
const a =
|
|
360
|
-
a &&
|
|
356
|
+
function ft(e, t = {}, r = {}, n = {}, s = null) {
|
|
357
|
+
const { removed: i, added: o, updated: f } = T(r, n);
|
|
358
|
+
for (const u of i.concat(f)) {
|
|
359
|
+
const a = t?.[u];
|
|
360
|
+
a && e.removeEventListener(u, a);
|
|
361
361
|
}
|
|
362
362
|
const l = {};
|
|
363
|
-
for (const
|
|
364
|
-
l[
|
|
365
|
-
|
|
366
|
-
n[
|
|
367
|
-
|
|
363
|
+
for (const u of o.concat(f))
|
|
364
|
+
l[u] = S(
|
|
365
|
+
u,
|
|
366
|
+
n[u],
|
|
367
|
+
e,
|
|
368
368
|
s
|
|
369
369
|
);
|
|
370
370
|
return l;
|
|
371
371
|
}
|
|
372
|
-
function R(
|
|
373
|
-
const n = v(
|
|
372
|
+
function R(e, t, r) {
|
|
373
|
+
const n = v(e), s = v(t), i = e.el, o = x(n, s, D), f = r?.offset ?? 0;
|
|
374
374
|
for (const l of o)
|
|
375
375
|
if (l.op === E.NOOP) {
|
|
376
|
-
const { originalIndex:
|
|
377
|
-
m(n[
|
|
376
|
+
const { originalIndex: u, index: a } = l;
|
|
377
|
+
m(n[u], s[a], i, r);
|
|
378
378
|
}
|
|
379
379
|
for (const l of o)
|
|
380
380
|
switch (l.op) {
|
|
381
381
|
case E.MOVE: {
|
|
382
|
-
const { from:
|
|
383
|
-
y && (i.insertBefore(y, b), m(n[
|
|
382
|
+
const { from: u, index: a } = l, y = n[u].el, b = i.childNodes[a + f];
|
|
383
|
+
y && (i.insertBefore(y, b), m(n[u], s[a], i, r));
|
|
384
384
|
break;
|
|
385
385
|
}
|
|
386
386
|
case E.REMOVE: {
|
|
387
|
-
const { item:
|
|
388
|
-
h(
|
|
387
|
+
const { item: u } = l;
|
|
388
|
+
h(u);
|
|
389
389
|
break;
|
|
390
390
|
}
|
|
391
391
|
case E.ADD: {
|
|
392
|
-
const { index:
|
|
393
|
-
p(a, i,
|
|
392
|
+
const { index: u, item: a } = l;
|
|
393
|
+
p(a, i, u + f, r);
|
|
394
394
|
break;
|
|
395
395
|
}
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
|
-
function
|
|
399
|
-
const { component: r } =
|
|
400
|
-
r.updateProps(n),
|
|
398
|
+
function lt(e, t) {
|
|
399
|
+
const { component: r } = e, { props: n } = A(t);
|
|
400
|
+
r.updateProps(n), t.component = r, t.el = r.firstElement;
|
|
401
401
|
}
|
|
402
|
-
function
|
|
403
|
-
if (
|
|
404
|
-
h(
|
|
402
|
+
function at(e, t, r) {
|
|
403
|
+
if (e.container !== t.container) {
|
|
404
|
+
h(e), p(t, document.body, null, r);
|
|
405
405
|
return;
|
|
406
406
|
}
|
|
407
|
-
R(
|
|
407
|
+
R(e, t, r);
|
|
408
408
|
}
|
|
409
|
-
const
|
|
409
|
+
const pt = (e) => e.isProvider, ht = (e) => e.isConsumer;
|
|
410
410
|
class k {
|
|
411
411
|
isMounted = !1;
|
|
412
412
|
vdom = null;
|
|
413
413
|
hostEl = null;
|
|
414
414
|
parent = null;
|
|
415
|
+
static defaultProps = {};
|
|
415
416
|
props;
|
|
416
417
|
state = {};
|
|
417
418
|
context = null;
|
|
@@ -419,30 +420,31 @@ class k {
|
|
|
419
420
|
subscribedProvider = null;
|
|
420
421
|
isProvider = !1;
|
|
421
422
|
isConsumer = !1;
|
|
422
|
-
constructor(
|
|
423
|
-
|
|
423
|
+
constructor(t = {}, r) {
|
|
424
|
+
const n = this.getDefaultProps();
|
|
425
|
+
this.props = { ...n, ...t }, this.parent = r;
|
|
424
426
|
}
|
|
425
|
-
addDependency({ consumer:
|
|
426
|
-
this.dependencies.some((r) => r.consumer ===
|
|
427
|
+
addDependency({ consumer: t }) {
|
|
428
|
+
this.dependencies.some((r) => r.consumer === t) || (this.dependencies.push({ consumer: t }), t.subscribedProvider = this);
|
|
427
429
|
}
|
|
428
|
-
removeDependency({ consumer:
|
|
429
|
-
const r = this.dependencies.findIndex((n) => n.consumer ===
|
|
430
|
-
r !== -1 && (this.dependencies.splice(r, 1),
|
|
430
|
+
removeDependency({ consumer: t }) {
|
|
431
|
+
const r = this.dependencies.findIndex((n) => n.consumer === t);
|
|
432
|
+
r !== -1 && (this.dependencies.splice(r, 1), t.subscribedProvider = null);
|
|
431
433
|
}
|
|
432
434
|
notify() {
|
|
433
435
|
d(() => {
|
|
434
|
-
this.dependencies.forEach(({ consumer:
|
|
435
|
-
|
|
436
|
+
this.dependencies.forEach(({ consumer: t }) => {
|
|
437
|
+
t.isMounted && t.updateContext() && t.patch(t.props, t.state);
|
|
436
438
|
});
|
|
437
439
|
});
|
|
438
440
|
}
|
|
439
441
|
didMount() {
|
|
440
442
|
return Promise.resolve();
|
|
441
443
|
}
|
|
442
|
-
willUpdate(
|
|
444
|
+
willUpdate(t, r) {
|
|
443
445
|
return Promise.resolve();
|
|
444
446
|
}
|
|
445
|
-
didUpdate(
|
|
447
|
+
didUpdate(t, r) {
|
|
446
448
|
return Promise.resolve();
|
|
447
449
|
}
|
|
448
450
|
willUnmount() {
|
|
@@ -452,7 +454,7 @@ class k {
|
|
|
452
454
|
return Promise.resolve();
|
|
453
455
|
}
|
|
454
456
|
get elements() {
|
|
455
|
-
return this.vdom == null ? [] : this.vdom.type === c.FRAGMENT ? v(this.vdom).flatMap((
|
|
457
|
+
return this.vdom == null ? [] : this.vdom.type === c.FRAGMENT ? v(this.vdom).flatMap((t) => t.type === c.COMPONENT && t.component ? t.component.elements : t.el ? [t.el] : []) : this.vdom.el ? [this.vdom.el] : [];
|
|
456
458
|
}
|
|
457
459
|
get firstElement() {
|
|
458
460
|
return this.elements[0];
|
|
@@ -460,65 +462,68 @@ class k {
|
|
|
460
462
|
get offset() {
|
|
461
463
|
return this.vdom?.type === c.FRAGMENT && this.hostEl && this.firstElement ? Array.from(this.hostEl.children).indexOf(this.firstElement) : 0;
|
|
462
464
|
}
|
|
463
|
-
updateProps(
|
|
464
|
-
const
|
|
465
|
-
this.props =
|
|
466
|
-
const
|
|
467
|
-
g(
|
|
465
|
+
updateProps(t) {
|
|
466
|
+
const n = { ...this.getDefaultProps(), ...this.props, ...t }, s = this.props;
|
|
467
|
+
this.props = n;
|
|
468
|
+
const i = this.updateContext();
|
|
469
|
+
g(s, n) && !i || (pt(this) && this.notify(), this.patch(s, this.state));
|
|
468
470
|
}
|
|
469
|
-
setState(
|
|
471
|
+
setState(t) {
|
|
470
472
|
const r = this.state;
|
|
471
|
-
typeof
|
|
473
|
+
typeof t == "function" ? this.state = {
|
|
472
474
|
...this.state,
|
|
473
|
-
...
|
|
474
|
-
} : this.state = { ...this.state, ...
|
|
475
|
+
...t(this.state, this.props)
|
|
476
|
+
} : this.state = { ...this.state, ...t }, this.patch(this.props, r);
|
|
475
477
|
}
|
|
476
|
-
mount(
|
|
478
|
+
mount(t, r = null) {
|
|
477
479
|
if (this.isMounted)
|
|
478
480
|
throw new Error("Component is already mounted");
|
|
479
|
-
|
|
481
|
+
ht(this) && !this.subscribedProvider && this.subscribeToProvider(), this.updateContext(), this.vdom = this.render(), p(this.vdom, t, r, this), this.hostEl = t, this.isMounted = !0;
|
|
480
482
|
}
|
|
481
483
|
unmount() {
|
|
482
|
-
this.isMounted && (d(() => this.willUnmount()), this.subscribedProvider && this.subscribedProvider.removeDependency({ consumer: this }), this.dependencies.forEach(({ consumer:
|
|
483
|
-
|
|
484
|
+
this.isMounted && (d(() => this.willUnmount()), this.subscribedProvider && this.subscribedProvider.removeDependency({ consumer: this }), this.dependencies.forEach(({ consumer: t }) => {
|
|
485
|
+
t.subscribedProvider = null;
|
|
484
486
|
}), this.dependencies = [], this.vdom && h(this.vdom), d(() => this.didUnmount()), this.vdom = null, this.hostEl = null, this.isMounted = !1);
|
|
485
487
|
}
|
|
486
|
-
patch(
|
|
488
|
+
patch(t, r) {
|
|
487
489
|
if (!this.isMounted || !this.hostEl || !this.vdom)
|
|
488
490
|
return;
|
|
489
491
|
d(() => this.willUpdate(this.props, this.state));
|
|
490
492
|
const n = this.render();
|
|
491
|
-
this.vdom = m(this.vdom, n, this.hostEl, this), d(() => this.didUpdate(
|
|
493
|
+
this.vdom = m(this.vdom, n, this.hostEl, this), d(() => this.didUpdate(t, r));
|
|
492
494
|
}
|
|
493
495
|
updateContext() {
|
|
494
|
-
const
|
|
496
|
+
const t = Object.getPrototypeOf(this).constructor.contextType;
|
|
495
497
|
let r = this.parent;
|
|
496
|
-
if (
|
|
498
|
+
if (t != null) {
|
|
497
499
|
for (; r; ) {
|
|
498
|
-
if (Object.getPrototypeOf(r).constructor ===
|
|
500
|
+
if (Object.getPrototypeOf(r).constructor === t.Provider)
|
|
499
501
|
return this.context = r.props.value, !0;
|
|
500
502
|
r = r.parent;
|
|
501
503
|
}
|
|
502
|
-
r == null && (this.context =
|
|
504
|
+
r == null && (this.context = t.defaultValue);
|
|
503
505
|
}
|
|
504
506
|
return !1;
|
|
505
507
|
}
|
|
506
508
|
subscribeToProvider() {
|
|
507
|
-
const
|
|
508
|
-
if (!
|
|
509
|
+
const t = Object.getPrototypeOf(this).constructor.contextType;
|
|
510
|
+
if (!t)
|
|
509
511
|
return;
|
|
510
512
|
let r = this.parent;
|
|
511
513
|
for (; r; ) {
|
|
512
|
-
if (Object.getPrototypeOf(r).constructor ===
|
|
514
|
+
if (Object.getPrototypeOf(r).constructor === t.Provider) {
|
|
513
515
|
r.addDependency({ consumer: this });
|
|
514
516
|
break;
|
|
515
517
|
}
|
|
516
518
|
r = r.parent;
|
|
517
519
|
}
|
|
518
520
|
}
|
|
521
|
+
getDefaultProps() {
|
|
522
|
+
return this.constructor.defaultProps || {};
|
|
523
|
+
}
|
|
519
524
|
}
|
|
520
|
-
function
|
|
521
|
-
class
|
|
525
|
+
function yt(e) {
|
|
526
|
+
class t extends k {
|
|
522
527
|
isProvider = !0;
|
|
523
528
|
render() {
|
|
524
529
|
let s = [];
|
|
@@ -527,8 +532,8 @@ function ye(t) {
|
|
|
527
532
|
}
|
|
528
533
|
class r extends k {
|
|
529
534
|
static contextType = {
|
|
530
|
-
Provider:
|
|
531
|
-
defaultValue:
|
|
535
|
+
Provider: t,
|
|
536
|
+
defaultValue: e
|
|
532
537
|
};
|
|
533
538
|
isConsumer = !0;
|
|
534
539
|
render() {
|
|
@@ -546,32 +551,32 @@ function ye(t) {
|
|
|
546
551
|
}
|
|
547
552
|
}
|
|
548
553
|
return {
|
|
549
|
-
Provider:
|
|
554
|
+
Provider: t,
|
|
550
555
|
Consumer: r,
|
|
551
|
-
defaultValue:
|
|
556
|
+
defaultValue: e
|
|
552
557
|
};
|
|
553
558
|
}
|
|
554
|
-
function
|
|
555
|
-
if (!
|
|
559
|
+
function Et(e, t) {
|
|
560
|
+
if (!t)
|
|
556
561
|
throw new Error("Container element is not provided for rendering.");
|
|
557
|
-
p(
|
|
562
|
+
p(e, t);
|
|
558
563
|
}
|
|
559
|
-
function
|
|
564
|
+
function bt(e = null) {
|
|
560
565
|
return {
|
|
561
|
-
current:
|
|
566
|
+
current: e
|
|
562
567
|
};
|
|
563
568
|
}
|
|
564
|
-
function
|
|
565
|
-
const r = Array.isArray(
|
|
566
|
-
return I(r,
|
|
569
|
+
function vt(e, t) {
|
|
570
|
+
const r = Array.isArray(e) ? e : [e];
|
|
571
|
+
return I(r, t);
|
|
567
572
|
}
|
|
568
573
|
export {
|
|
569
574
|
k as Component,
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
575
|
+
yt as createContext,
|
|
576
|
+
vt as createPortal,
|
|
577
|
+
bt as createRef,
|
|
578
|
+
Ot as h,
|
|
574
579
|
F as hFragment,
|
|
575
|
-
|
|
576
|
-
|
|
580
|
+
mt as hString,
|
|
581
|
+
Et as render
|
|
577
582
|
};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Fragment, jsx as jsxDEV } from './jsx-runtime';
|
|
2
|
+
export { Fragment, jsxDEV };
|
package/dist/jsx-runtime.d.ts
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import type { IProp, VDOMNode } from './types';
|
|
2
|
+
export declare const Fragment: unique symbol;
|
|
3
|
+
export type Child = VDOMNode | string | number | boolean | null | undefined;
|
|
4
|
+
export declare function jsx(tag: unknown, props?: IProp, ...children: Array<Child | Child[]>): VDOMNode;
|
package/package.json
CHANGED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { IProp, VDOMNode } from '../types';
|
|
2
|
-
export declare const Fragment: unique symbol;
|
|
3
|
-
export type Child = VDOMNode | string | number | boolean | null | undefined;
|
|
4
|
-
export declare function jsx(tag: unknown, props?: IProp, ...children: Array<Child | Child[]>): VDOMNode;
|