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