ddd-react 1.10.5 → 1.10.6
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 +62 -58
- 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 d(e) {
|
|
139
139
|
O.push(e), Y();
|
|
140
140
|
}
|
|
141
141
|
function Y() {
|
|
@@ -165,7 +165,7 @@ function A(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 h(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 d(e, t, r = null, n = null) {
|
|
|
182
182
|
case c.COMPONENT: {
|
|
183
183
|
tt(e, t, r, n);
|
|
184
184
|
const o = e.component;
|
|
185
|
-
o &&
|
|
185
|
+
o && d(() => o.didMount());
|
|
186
186
|
break;
|
|
187
187
|
}
|
|
188
188
|
case c.PORTAL: {
|
|
@@ -200,14 +200,14 @@ function z(e, t, r) {
|
|
|
200
200
|
function Q(e, t, r, n) {
|
|
201
201
|
const { children: o } = e;
|
|
202
202
|
e.el = t, o?.forEach((i, s) => {
|
|
203
|
-
|
|
203
|
+
h(i, t, r != null ? r + s : null, n);
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
206
|
function Z(e, t, r, n) {
|
|
207
|
-
const { tag: o, children: i } = e,
|
|
208
|
-
V(
|
|
209
|
-
|
|
210
|
-
}), L(
|
|
207
|
+
const { tag: o, children: i } = e, u = o === "svg" || t instanceof SVGElement ? document.createElementNS("http://www.w3.org/2000/svg", o) : document.createElement(o);
|
|
208
|
+
V(u, e, n), e.el = u, i?.forEach((a) => {
|
|
209
|
+
h(a, u, null, n);
|
|
210
|
+
}), L(u, t, r);
|
|
211
211
|
}
|
|
212
212
|
function V(e, t, r) {
|
|
213
213
|
const { props: n, events: o } = A(t);
|
|
@@ -215,7 +215,11 @@ function V(e, t, r) {
|
|
|
215
215
|
}
|
|
216
216
|
function tt(e, t, r, n) {
|
|
217
217
|
const o = e.tag, { props: i } = A(e), s = new o(i, n);
|
|
218
|
-
|
|
218
|
+
try {
|
|
219
|
+
s.mount(t, r), e.component = s, e.el = s.firstElement || null;
|
|
220
|
+
} catch {
|
|
221
|
+
s.vdom && (e.component = s);
|
|
222
|
+
}
|
|
219
223
|
}
|
|
220
224
|
function L(e, t, r) {
|
|
221
225
|
if (r == null) {
|
|
@@ -230,7 +234,7 @@ function L(e, t, r) {
|
|
|
230
234
|
function et(e, t) {
|
|
231
235
|
const { children: r, container: n } = e;
|
|
232
236
|
r?.forEach((o) => {
|
|
233
|
-
|
|
237
|
+
h(o, n, null, t);
|
|
234
238
|
});
|
|
235
239
|
}
|
|
236
240
|
function j(e, t) {
|
|
@@ -242,9 +246,9 @@ function j(e, t) {
|
|
|
242
246
|
props: { key: i }
|
|
243
247
|
} = r, {
|
|
244
248
|
tag: s,
|
|
245
|
-
props: { key:
|
|
249
|
+
props: { key: u }
|
|
246
250
|
} = n;
|
|
247
|
-
return o === s && i ===
|
|
251
|
+
return o === s && i === u;
|
|
248
252
|
}
|
|
249
253
|
if (e.type === c.COMPONENT) {
|
|
250
254
|
const r = e, n = t, { tag: o } = r, { tag: i } = n;
|
|
@@ -272,10 +276,10 @@ function rt(e) {
|
|
|
272
276
|
function S(e) {
|
|
273
277
|
return rt(e.trim());
|
|
274
278
|
}
|
|
275
|
-
function
|
|
279
|
+
function y(e, t, r, n = null) {
|
|
276
280
|
if (!j(e, t)) {
|
|
277
281
|
const o = nt(r, e.el);
|
|
278
|
-
return p(e),
|
|
282
|
+
return p(e), h(t, r, o, n), t;
|
|
279
283
|
}
|
|
280
284
|
switch (t.el = e.el, t.type) {
|
|
281
285
|
case c.TEXT:
|
|
@@ -309,17 +313,17 @@ function st(e, t, r) {
|
|
|
309
313
|
class: o,
|
|
310
314
|
style: i,
|
|
311
315
|
on: s,
|
|
312
|
-
...
|
|
316
|
+
...u
|
|
313
317
|
} = e.props ?? {}, {
|
|
314
318
|
class: a,
|
|
315
|
-
style:
|
|
319
|
+
style: l,
|
|
316
320
|
on: f,
|
|
317
|
-
...
|
|
321
|
+
...E
|
|
318
322
|
} = t.props ?? {}, { listeners: v } = e;
|
|
319
|
-
it(n,
|
|
323
|
+
it(n, u, E), ct(n, o, a), ut(
|
|
320
324
|
n,
|
|
321
325
|
i,
|
|
322
|
-
|
|
326
|
+
l
|
|
323
327
|
), t.listeners = lt(
|
|
324
328
|
n,
|
|
325
329
|
v,
|
|
@@ -333,10 +337,10 @@ function it(e, t = {}, r = {}) {
|
|
|
333
337
|
n !== o && (n && typeof n == "object" && "current" in n && (n.current = null), o && typeof o == "object" && "current" in o && (o.current = e));
|
|
334
338
|
const i = { ...t }, s = { ...r };
|
|
335
339
|
delete i.ref, delete s.ref;
|
|
336
|
-
const { added:
|
|
340
|
+
const { added: u, removed: a, updated: l } = C(i, s);
|
|
337
341
|
for (const f of a)
|
|
338
342
|
D(e, f);
|
|
339
|
-
for (const f of
|
|
343
|
+
for (const f of u.concat(l))
|
|
340
344
|
w(e, f, s[f]);
|
|
341
345
|
}
|
|
342
346
|
function ct(e, t, r) {
|
|
@@ -354,43 +358,43 @@ function ut(e, t = {}, r = {}) {
|
|
|
354
358
|
M(e, s, r[s]);
|
|
355
359
|
}
|
|
356
360
|
function lt(e, t = {}, r = {}, n = {}, o = null) {
|
|
357
|
-
const { removed: i, added: s, updated:
|
|
358
|
-
for (const
|
|
359
|
-
const f = t?.[
|
|
360
|
-
f && e.removeEventListener(
|
|
361
|
+
const { removed: i, added: s, updated: u } = C(r, n);
|
|
362
|
+
for (const l of i.concat(u)) {
|
|
363
|
+
const f = t?.[l];
|
|
364
|
+
f && e.removeEventListener(l, f);
|
|
361
365
|
}
|
|
362
366
|
const a = {};
|
|
363
|
-
for (const
|
|
364
|
-
a[
|
|
365
|
-
|
|
366
|
-
n[
|
|
367
|
+
for (const l of s.concat(u))
|
|
368
|
+
a[l] = N(
|
|
369
|
+
l,
|
|
370
|
+
n[l],
|
|
367
371
|
e,
|
|
368
372
|
o
|
|
369
373
|
);
|
|
370
374
|
return a;
|
|
371
375
|
}
|
|
372
376
|
function F(e, t, r) {
|
|
373
|
-
const n = m(e), o = m(t), i = e.el, s = R(n, o, j),
|
|
377
|
+
const n = m(e), o = m(t), i = e.el, s = R(n, o, j), u = r?.offset ?? 0;
|
|
374
378
|
for (const a of s)
|
|
375
379
|
if (a.op === g.NOOP) {
|
|
376
|
-
const { originalIndex:
|
|
377
|
-
|
|
380
|
+
const { originalIndex: l, index: f } = a;
|
|
381
|
+
y(n[l], o[f], i, r);
|
|
378
382
|
}
|
|
379
383
|
for (const a of s)
|
|
380
384
|
switch (a.op) {
|
|
381
385
|
case g.MOVE: {
|
|
382
|
-
const { from:
|
|
383
|
-
|
|
386
|
+
const { from: l, index: f } = a, E = n[l].el, v = i.childNodes[f + u];
|
|
387
|
+
E && (i.insertBefore(E, v), y(n[l], o[f], i, r));
|
|
384
388
|
break;
|
|
385
389
|
}
|
|
386
390
|
case g.REMOVE: {
|
|
387
|
-
const { item:
|
|
388
|
-
p(
|
|
391
|
+
const { item: l } = a;
|
|
392
|
+
p(l);
|
|
389
393
|
break;
|
|
390
394
|
}
|
|
391
395
|
case g.ADD: {
|
|
392
|
-
const { index:
|
|
393
|
-
|
|
396
|
+
const { index: l, item: f } = a;
|
|
397
|
+
h(f, i, l + u, r);
|
|
394
398
|
break;
|
|
395
399
|
}
|
|
396
400
|
}
|
|
@@ -401,12 +405,12 @@ function at(e, t) {
|
|
|
401
405
|
}
|
|
402
406
|
function ft(e, t, r) {
|
|
403
407
|
if (e.container !== t.container) {
|
|
404
|
-
p(e),
|
|
408
|
+
p(e), h(t, document.body, null, r);
|
|
405
409
|
return;
|
|
406
410
|
}
|
|
407
411
|
F(e, t, r);
|
|
408
412
|
}
|
|
409
|
-
const
|
|
413
|
+
const ht = (e) => e.isProvider, dt = (e) => e.isConsumer;
|
|
410
414
|
class T {
|
|
411
415
|
isMounted = !1;
|
|
412
416
|
vdom = null;
|
|
@@ -433,7 +437,7 @@ class T {
|
|
|
433
437
|
r !== -1 && (this.dependencies.splice(r, 1), t.subscribedProvider = null);
|
|
434
438
|
}
|
|
435
439
|
notify() {
|
|
436
|
-
|
|
440
|
+
d(() => {
|
|
437
441
|
this.dependencies.forEach(({ consumer: t }) => {
|
|
438
442
|
t.isMounted && t.updateContext() && t.patch(t.props, t.state);
|
|
439
443
|
});
|
|
@@ -471,7 +475,7 @@ class T {
|
|
|
471
475
|
}
|
|
472
476
|
updateProps(t) {
|
|
473
477
|
const n = { ...this.getDefaultProps(), ...this.props, ...t }, o = this.props;
|
|
474
|
-
this.props = n, !this.shouldComponentUpdate(o, n) && (
|
|
478
|
+
this.props = n, !this.shouldComponentUpdate(o, n) && (ht(this) && this.notify(), this.patch(o, this.state));
|
|
475
479
|
}
|
|
476
480
|
setState(t) {
|
|
477
481
|
const r = this.state;
|
|
@@ -483,24 +487,24 @@ class T {
|
|
|
483
487
|
mount(t, r = null) {
|
|
484
488
|
if (this.isMounted)
|
|
485
489
|
throw new Error("Component is already mounted");
|
|
486
|
-
|
|
490
|
+
dt(this) && !this.subscribedProvider && this.subscribeToProvider(), this.updateContext();
|
|
487
491
|
try {
|
|
488
|
-
this.vdom = this.render(), this.hostEl = t,
|
|
492
|
+
this.vdom = this.render(), this.hostEl = t, h(this.vdom, t, r, this), this.isMounted = !0;
|
|
489
493
|
} catch (n) {
|
|
490
494
|
this.handleError(n, "mount");
|
|
491
495
|
}
|
|
492
496
|
}
|
|
493
497
|
unmount() {
|
|
494
|
-
this.isMounted && (
|
|
498
|
+
this.isMounted && (d(() => this.willUnmount()), this.subscribedProvider && this.subscribedProvider.removeDependency({ consumer: this }), this.dependencies.forEach(({ consumer: t }) => {
|
|
495
499
|
t.subscribedProvider = null;
|
|
496
|
-
}), this.dependencies = [], this.vdom && p(this.vdom),
|
|
500
|
+
}), this.dependencies = [], this.vdom && p(this.vdom), d(() => this.didUnmount()), this.vdom = null, this.hostEl = null, this.isMounted = !1, this.error = null);
|
|
497
501
|
}
|
|
498
502
|
patch(t, r) {
|
|
499
503
|
if (!(!this.isMounted || !this.hostEl || !this.vdom) && !this.error) {
|
|
500
|
-
|
|
504
|
+
d(() => this.willUpdate(this.props, this.state));
|
|
501
505
|
try {
|
|
502
506
|
const n = this.render();
|
|
503
|
-
this.vdom =
|
|
507
|
+
this.vdom = y(this.vdom, n, this.hostEl, this), d(() => this.didUpdate(t, r));
|
|
504
508
|
} catch (n) {
|
|
505
509
|
this.handleError(n, "patch");
|
|
506
510
|
}
|
|
@@ -556,13 +560,13 @@ class T {
|
|
|
556
560
|
const s = n.render();
|
|
557
561
|
if (s)
|
|
558
562
|
if (n.vdom)
|
|
559
|
-
console.log("Patching ErrorBoundary"),
|
|
563
|
+
console.log("Patching ErrorBoundary"), y(n.vdom, s, n.hostEl, n);
|
|
560
564
|
else {
|
|
561
565
|
console.log("Mounting ErrorBoundary fallback");
|
|
562
|
-
const
|
|
566
|
+
const u = n.parent?.offset || 0;
|
|
563
567
|
n.hostEl && n.hostEl.children.length > 0 && Array.from(n.hostEl.children).forEach((a) => {
|
|
564
568
|
a.remove();
|
|
565
|
-
}),
|
|
569
|
+
}), h(s, n.hostEl, u, n.parent), n.vdom = s, n.isMounted = !0;
|
|
566
570
|
}
|
|
567
571
|
} catch (s) {
|
|
568
572
|
console.error("Error during ErrorBoundary recovery:", s), n.parent && n.parent.handleError(s, r);
|
|
@@ -576,14 +580,14 @@ class T {
|
|
|
576
580
|
const i = o.getDerivedStateFromError(t);
|
|
577
581
|
this.state = { ...this.state, ...i };
|
|
578
582
|
}
|
|
579
|
-
|
|
583
|
+
d(() => {
|
|
580
584
|
if (this.didCatch(t, {
|
|
581
585
|
phase: r,
|
|
582
586
|
componentStack: this.getComponentStack()
|
|
583
587
|
}), this.hostEl && this.isMounted)
|
|
584
588
|
try {
|
|
585
589
|
const i = this.render();
|
|
586
|
-
i &&
|
|
590
|
+
i && y(this.vdom, i, this.hostEl, this);
|
|
587
591
|
} catch (i) {
|
|
588
592
|
console.error("Error during error recovery render:", i);
|
|
589
593
|
}
|
|
@@ -609,7 +613,7 @@ class T {
|
|
|
609
613
|
return console.log("isErrorBoundary"), console.log("this.constructor as typeof Component", this.constructor), console.log("(this.constructor as typeof Component).getDerivedStateFromError", this.constructor.getDerivedStateFromError), this.constructor.getDerivedStateFromError !== void 0;
|
|
610
614
|
}
|
|
611
615
|
}
|
|
612
|
-
function
|
|
616
|
+
function yt(e) {
|
|
613
617
|
class t extends T {
|
|
614
618
|
isProvider = !0;
|
|
615
619
|
render() {
|
|
@@ -643,10 +647,10 @@ function Et(e) {
|
|
|
643
647
|
defaultValue: e
|
|
644
648
|
};
|
|
645
649
|
}
|
|
646
|
-
function
|
|
650
|
+
function Et(e, t) {
|
|
647
651
|
if (!t)
|
|
648
652
|
throw new Error("Container element is not provided for rendering.");
|
|
649
|
-
|
|
653
|
+
h(e, t);
|
|
650
654
|
}
|
|
651
655
|
function gt(e = null) {
|
|
652
656
|
return {
|
|
@@ -659,11 +663,11 @@ function vt(e, t) {
|
|
|
659
663
|
}
|
|
660
664
|
export {
|
|
661
665
|
T as Component,
|
|
662
|
-
|
|
666
|
+
yt as createContext,
|
|
663
667
|
vt as createPortal,
|
|
664
668
|
gt as createRef,
|
|
665
669
|
Pt as h,
|
|
666
670
|
B as hFragment,
|
|
667
671
|
Ot as hString,
|
|
668
|
-
|
|
672
|
+
Et as render
|
|
669
673
|
};
|