ddd-react 1.10.12 → 1.10.13
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 +61 -59
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -135,7 +135,7 @@ function D(e, t) {
|
|
|
135
135
|
}
|
|
136
136
|
let P = !1;
|
|
137
137
|
const O = [];
|
|
138
|
-
function
|
|
138
|
+
function h(e) {
|
|
139
139
|
O.push(e), Y();
|
|
140
140
|
}
|
|
141
141
|
function Y() {
|
|
@@ -161,11 +161,11 @@ function H() {
|
|
|
161
161
|
}
|
|
162
162
|
P = !1;
|
|
163
163
|
}
|
|
164
|
-
function
|
|
164
|
+
function C(e) {
|
|
165
165
|
const { on: t = {}, ...r } = e.props;
|
|
166
166
|
return delete r.key, { props: r, events: t };
|
|
167
167
|
}
|
|
168
|
-
function
|
|
168
|
+
function d(e, t, r = null, n = null) {
|
|
169
169
|
switch (e.type) {
|
|
170
170
|
case c.TEXT: {
|
|
171
171
|
z(e, t, r);
|
|
@@ -182,7 +182,7 @@ function h(e, t, r = null, n = null) {
|
|
|
182
182
|
case c.COMPONENT: {
|
|
183
183
|
tt(e, t, r, n);
|
|
184
184
|
const s = e.component;
|
|
185
|
-
s &&
|
|
185
|
+
s && h(() => s.didMount());
|
|
186
186
|
break;
|
|
187
187
|
}
|
|
188
188
|
case c.PORTAL: {
|
|
@@ -200,21 +200,21 @@ function z(e, t, r) {
|
|
|
200
200
|
function Q(e, t, r, n) {
|
|
201
201
|
const { children: s } = e;
|
|
202
202
|
e.el = t, s?.forEach((i, o) => {
|
|
203
|
-
|
|
203
|
+
d(i, t, r != null ? r + o : null, n);
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
206
|
function Z(e, t, r, n) {
|
|
207
|
-
const { tag: s, children: i } = e,
|
|
208
|
-
V(
|
|
209
|
-
|
|
210
|
-
}), L(
|
|
207
|
+
const { tag: s, children: i } = e, l = s === "svg" || t instanceof SVGElement ? document.createElementNS("http://www.w3.org/2000/svg", s) : document.createElement(s);
|
|
208
|
+
V(l, e, n), e.el = l, i?.forEach((a) => {
|
|
209
|
+
d(a, l, null, n);
|
|
210
|
+
}), L(l, t, r);
|
|
211
211
|
}
|
|
212
212
|
function V(e, t, r) {
|
|
213
|
-
const { props: n, events: s } =
|
|
213
|
+
const { props: n, events: s } = C(t);
|
|
214
214
|
n.ref && typeof n.ref == "object" && "current" in n.ref && (n.ref.current = e, delete n.ref), t.listeners = I(s, e, r), K(e, n);
|
|
215
215
|
}
|
|
216
216
|
function tt(e, t, r, n) {
|
|
217
|
-
const s = e.tag, { props: i } =
|
|
217
|
+
const s = e.tag, { props: i } = C(e), o = new s(i, n);
|
|
218
218
|
o.mount(t, r), e.component = o, e.el = o.firstElement || null;
|
|
219
219
|
}
|
|
220
220
|
function L(e, t, r) {
|
|
@@ -230,7 +230,7 @@ function L(e, t, r) {
|
|
|
230
230
|
function et(e, t) {
|
|
231
231
|
const { children: r, container: n } = e;
|
|
232
232
|
r?.forEach((s) => {
|
|
233
|
-
|
|
233
|
+
d(s, n, null, t);
|
|
234
234
|
});
|
|
235
235
|
}
|
|
236
236
|
function j(e, t) {
|
|
@@ -242,9 +242,9 @@ function j(e, t) {
|
|
|
242
242
|
props: { key: i }
|
|
243
243
|
} = r, {
|
|
244
244
|
tag: o,
|
|
245
|
-
props: { key:
|
|
245
|
+
props: { key: l }
|
|
246
246
|
} = n;
|
|
247
|
-
return s === o && i ===
|
|
247
|
+
return s === o && i === l;
|
|
248
248
|
}
|
|
249
249
|
if (e.type === c.COMPONENT) {
|
|
250
250
|
const r = e, n = t, { tag: s } = r, { tag: i } = n;
|
|
@@ -256,7 +256,7 @@ function j(e, t) {
|
|
|
256
256
|
}
|
|
257
257
|
return !0;
|
|
258
258
|
}
|
|
259
|
-
function
|
|
259
|
+
function A(e, t) {
|
|
260
260
|
const r = Object.keys(e), n = Object.keys(t), s = [], i = [];
|
|
261
261
|
for (const o of n)
|
|
262
262
|
o in e ? e[o] !== t[o] && i.push(o) : s.push(o);
|
|
@@ -269,13 +269,13 @@ function S(e, t) {
|
|
|
269
269
|
function rt(e) {
|
|
270
270
|
return e !== "";
|
|
271
271
|
}
|
|
272
|
-
function
|
|
272
|
+
function S(e) {
|
|
273
273
|
return rt(e.trim());
|
|
274
274
|
}
|
|
275
275
|
function y(e, t, r, n = null) {
|
|
276
276
|
if (!j(e, t)) {
|
|
277
277
|
const s = nt(r, e.el);
|
|
278
|
-
return p(e),
|
|
278
|
+
return p(e), d(t, r, s, n), t;
|
|
279
279
|
}
|
|
280
280
|
switch (t.el = e.el, t.type) {
|
|
281
281
|
case c.TEXT:
|
|
@@ -285,7 +285,7 @@ function y(e, t, r, n = null) {
|
|
|
285
285
|
break;
|
|
286
286
|
}
|
|
287
287
|
case c.COMPONENT: {
|
|
288
|
-
|
|
288
|
+
at(e, t);
|
|
289
289
|
break;
|
|
290
290
|
}
|
|
291
291
|
case c.PORTAL: {
|
|
@@ -309,18 +309,18 @@ function ot(e, t, r) {
|
|
|
309
309
|
class: s,
|
|
310
310
|
style: i,
|
|
311
311
|
on: o,
|
|
312
|
-
...
|
|
312
|
+
...l
|
|
313
313
|
} = e.props ?? {}, {
|
|
314
|
-
class:
|
|
314
|
+
class: a,
|
|
315
315
|
style: u,
|
|
316
316
|
on: f,
|
|
317
317
|
...E
|
|
318
318
|
} = t.props ?? {}, { listeners: v } = e;
|
|
319
|
-
it(n,
|
|
319
|
+
it(n, l, E), ct(n, s, a), ut(
|
|
320
320
|
n,
|
|
321
321
|
i,
|
|
322
322
|
u
|
|
323
|
-
), t.listeners =
|
|
323
|
+
), t.listeners = lt(
|
|
324
324
|
n,
|
|
325
325
|
v,
|
|
326
326
|
o ?? {},
|
|
@@ -333,10 +333,10 @@ function it(e, t = {}, r = {}) {
|
|
|
333
333
|
n !== s && (n && typeof n == "object" && "current" in n && (n.current = null), s && typeof s == "object" && "current" in s && (s.current = e));
|
|
334
334
|
const i = { ...t }, o = { ...r };
|
|
335
335
|
delete i.ref, delete o.ref;
|
|
336
|
-
const { added:
|
|
337
|
-
for (const f of
|
|
336
|
+
const { added: l, removed: a, updated: u } = A(i, o);
|
|
337
|
+
for (const f of a)
|
|
338
338
|
D(e, f);
|
|
339
|
-
for (const f of
|
|
339
|
+
for (const f of l.concat(u))
|
|
340
340
|
w(e, f, o[f]);
|
|
341
341
|
}
|
|
342
342
|
function ct(e, t, r) {
|
|
@@ -344,69 +344,69 @@ function ct(e, t, r) {
|
|
|
344
344
|
o.length > 0 && e.classList.remove(...o), i.length > 0 && e.classList.add(...i);
|
|
345
345
|
}
|
|
346
346
|
function T(e = "") {
|
|
347
|
-
return Array.isArray(e) ? e.filter(
|
|
347
|
+
return Array.isArray(e) ? e.filter(S) : String(e).split(/(\s+)/).filter(S);
|
|
348
348
|
}
|
|
349
349
|
function ut(e, t = {}, r = {}) {
|
|
350
|
-
const { added: n, removed: s, updated: i } =
|
|
350
|
+
const { added: n, removed: s, updated: i } = A(t, r);
|
|
351
351
|
for (const o of s)
|
|
352
352
|
J(e, o);
|
|
353
353
|
for (const o of n.concat(i))
|
|
354
354
|
M(e, o, r[o]);
|
|
355
355
|
}
|
|
356
|
-
function
|
|
357
|
-
const { removed: i, added: o, updated:
|
|
358
|
-
for (const u of i.concat(
|
|
356
|
+
function lt(e, t = {}, r = {}, n = {}, s = null) {
|
|
357
|
+
const { removed: i, added: o, updated: l } = A(r, n);
|
|
358
|
+
for (const u of i.concat(l)) {
|
|
359
359
|
const f = t?.[u];
|
|
360
360
|
f && e.removeEventListener(u, f);
|
|
361
361
|
}
|
|
362
|
-
const
|
|
363
|
-
for (const u of o.concat(
|
|
364
|
-
|
|
362
|
+
const a = {};
|
|
363
|
+
for (const u of o.concat(l))
|
|
364
|
+
a[u] = N(
|
|
365
365
|
u,
|
|
366
366
|
n[u],
|
|
367
367
|
e,
|
|
368
368
|
s
|
|
369
369
|
);
|
|
370
|
-
return
|
|
370
|
+
return a;
|
|
371
371
|
}
|
|
372
372
|
function F(e, t, r) {
|
|
373
|
-
const n = m(e), s = m(t), i = e.el, o = R(n, s, j),
|
|
374
|
-
for (const
|
|
375
|
-
if (
|
|
376
|
-
const { originalIndex: u, index: f } =
|
|
373
|
+
const n = m(e), s = m(t), i = e.el, o = R(n, s, j), l = r?.offset ?? 0;
|
|
374
|
+
for (const a of o)
|
|
375
|
+
if (a.op === g.NOOP) {
|
|
376
|
+
const { originalIndex: u, index: f } = a;
|
|
377
377
|
y(n[u], s[f], i, r);
|
|
378
378
|
}
|
|
379
|
-
for (const
|
|
380
|
-
switch (
|
|
379
|
+
for (const a of o)
|
|
380
|
+
switch (a.op) {
|
|
381
381
|
case g.MOVE: {
|
|
382
|
-
const { from: u, index: f } =
|
|
382
|
+
const { from: u, index: f } = a, E = n[u].el, v = i.childNodes[f + l];
|
|
383
383
|
E && (i.insertBefore(E, v), y(n[u], s[f], i, r));
|
|
384
384
|
break;
|
|
385
385
|
}
|
|
386
386
|
case g.REMOVE: {
|
|
387
|
-
const { item: u } =
|
|
387
|
+
const { item: u } = a;
|
|
388
388
|
p(u);
|
|
389
389
|
break;
|
|
390
390
|
}
|
|
391
391
|
case g.ADD: {
|
|
392
|
-
const { index: u, item: f } =
|
|
393
|
-
|
|
392
|
+
const { index: u, item: f } = a;
|
|
393
|
+
d(f, i, u + l, r);
|
|
394
394
|
break;
|
|
395
395
|
}
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
|
-
function
|
|
399
|
-
const { component: r } = e, { props: n } =
|
|
398
|
+
function at(e, t) {
|
|
399
|
+
const { component: r } = e, { props: n } = C(t);
|
|
400
400
|
r.updateProps(n), t.component = r, t.el = r.firstElement;
|
|
401
401
|
}
|
|
402
402
|
function ft(e, t, r) {
|
|
403
403
|
if (e.container !== t.container) {
|
|
404
|
-
p(e),
|
|
404
|
+
p(e), d(t, document.body, null, r);
|
|
405
405
|
return;
|
|
406
406
|
}
|
|
407
407
|
F(e, t, r);
|
|
408
408
|
}
|
|
409
|
-
const
|
|
409
|
+
const ht = (e) => e.isProvider, dt = (e) => e.isConsumer;
|
|
410
410
|
class k {
|
|
411
411
|
isMounted = !1;
|
|
412
412
|
vdom = null;
|
|
@@ -433,7 +433,7 @@ class k {
|
|
|
433
433
|
r !== -1 && (this.dependencies.splice(r, 1), t.subscribedProvider = null);
|
|
434
434
|
}
|
|
435
435
|
notify() {
|
|
436
|
-
|
|
436
|
+
h(() => {
|
|
437
437
|
this.dependencies.forEach(({ consumer: t }) => {
|
|
438
438
|
t.isMounted && t.updateContext() && t.patch(t.props, t.state);
|
|
439
439
|
});
|
|
@@ -471,7 +471,7 @@ class k {
|
|
|
471
471
|
}
|
|
472
472
|
updateProps(t) {
|
|
473
473
|
const n = { ...this.getDefaultProps(), ...this.props, ...t }, s = this.props;
|
|
474
|
-
this.props = n, !this.shouldComponentUpdate(s, n) && (
|
|
474
|
+
this.props = n, !this.shouldComponentUpdate(s, n) && (ht(this) && this.notify(), this.patch(s, this.state));
|
|
475
475
|
}
|
|
476
476
|
setState(t) {
|
|
477
477
|
const r = this.state;
|
|
@@ -483,24 +483,24 @@ class k {
|
|
|
483
483
|
mount(t, r = null) {
|
|
484
484
|
if (this.isMounted)
|
|
485
485
|
throw new Error("Component is already mounted");
|
|
486
|
-
|
|
486
|
+
dt(this) && !this.subscribedProvider && this.subscribeToProvider(), this.updateContext();
|
|
487
487
|
try {
|
|
488
|
-
this.vdom = this.render(), this.hostEl = t, this.isMounted = !0,
|
|
488
|
+
this.vdom = this.render(), this.hostEl = t, this.isMounted = !0, d(this.vdom, t, r, this);
|
|
489
489
|
} catch (n) {
|
|
490
490
|
this.handleError(n, "mount");
|
|
491
491
|
}
|
|
492
492
|
}
|
|
493
493
|
unmount() {
|
|
494
|
-
this.isMounted && (
|
|
494
|
+
this.isMounted && (h(() => this.willUnmount()), this.subscribedProvider && this.subscribedProvider.removeDependency({ consumer: this }), this.dependencies.forEach(({ consumer: t }) => {
|
|
495
495
|
t.subscribedProvider = null;
|
|
496
|
-
}), this.dependencies = [], this.vdom && p(this.vdom),
|
|
496
|
+
}), this.dependencies = [], this.vdom && p(this.vdom), h(() => this.didUnmount()), this.vdom = null, this.hostEl = null, this.isMounted = !1, this.error = null);
|
|
497
497
|
}
|
|
498
498
|
patch(t, r) {
|
|
499
499
|
if (!(!this.isMounted || !this.hostEl || !this.vdom) && !this.error) {
|
|
500
|
-
|
|
500
|
+
h(() => this.willUpdate(this.props, this.state));
|
|
501
501
|
try {
|
|
502
502
|
const n = this.render();
|
|
503
|
-
this.vdom = y(this.vdom, n, this.hostEl, this),
|
|
503
|
+
this.vdom = y(this.vdom, n, this.hostEl, this), h(() => this.didUpdate(t, r));
|
|
504
504
|
} catch (n) {
|
|
505
505
|
this.handleError(n, "patch");
|
|
506
506
|
}
|
|
@@ -546,11 +546,13 @@ class k {
|
|
|
546
546
|
const o = i.getDerivedStateFromError(t);
|
|
547
547
|
n.state = { ...n.state, ...o };
|
|
548
548
|
}
|
|
549
|
+
for (; n.hostEl.firstChild; )
|
|
550
|
+
n.hostEl.removeChild(n.hostEl.firstChild);
|
|
549
551
|
if (n.hostEl && n.isMounted) {
|
|
550
552
|
console.log("Rendering fallback UI");
|
|
551
553
|
try {
|
|
552
554
|
const o = n.render();
|
|
553
|
-
o && (n.vdom = y(n.vdom, o, n.hostEl, n),
|
|
555
|
+
o && (n.vdom = y(n.vdom, o, n.hostEl, n), h(() => {
|
|
554
556
|
n.didCatch(t, {
|
|
555
557
|
phase: r,
|
|
556
558
|
failedComponent: this.constructor.name,
|
|
@@ -569,7 +571,7 @@ class k {
|
|
|
569
571
|
const i = s.getDerivedStateFromError(t);
|
|
570
572
|
this.state = { ...this.state, ...i };
|
|
571
573
|
}
|
|
572
|
-
|
|
574
|
+
h(() => {
|
|
573
575
|
if (this.didCatch(t, {
|
|
574
576
|
phase: r,
|
|
575
577
|
componentStack: this.getComponentStack()
|
|
@@ -639,7 +641,7 @@ function yt(e) {
|
|
|
639
641
|
function Et(e, t) {
|
|
640
642
|
if (!t)
|
|
641
643
|
throw new Error("Container element is not provided for rendering.");
|
|
642
|
-
|
|
644
|
+
d(e, t);
|
|
643
645
|
}
|
|
644
646
|
function gt(e = null) {
|
|
645
647
|
return {
|