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