ddd-react 1.10.5 → 1.10.7

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.
Files changed (2) hide show
  1. package/dist/index.mjs +44 -40
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { D as c, e as m, a as R, A as g, b as x, h as B, c as U } from "./h-BbaMkkC7.mjs";
1
+ import { D as c, e as m, a as R, A as E, b as x, h as U, c as B } from "./h-BbaMkkC7.mjs";
2
2
  import { d as Pt, f as Ot } from "./h-BbaMkkC7.mjs";
3
3
  function b(e, t) {
4
4
  if (e === null || t === null || e === void 0 || t === void 0)
@@ -161,7 +161,7 @@ function H() {
161
161
  }
162
162
  P = !1;
163
163
  }
164
- function A(e) {
164
+ function C(e) {
165
165
  const { on: t = {}, ...r } = e.props;
166
166
  return delete r.key, { props: r, events: t };
167
167
  }
@@ -210,12 +210,16 @@ function Z(e, t, r, n) {
210
210
  }), L(l, t, r);
211
211
  }
212
212
  function V(e, t, r) {
213
- const { props: n, events: o } = A(t);
213
+ const { props: n, events: o } = C(t);
214
214
  n.ref && typeof n.ref == "object" && "current" in n.ref && (n.ref.current = e, delete n.ref), t.listeners = I(o, e, r), K(e, n);
215
215
  }
216
216
  function tt(e, t, r, n) {
217
- const o = e.tag, { props: i } = A(e), s = new o(i, n);
218
- s.mount(t, r), e.component = s, e.el = s.firstElement || null;
217
+ const o = e.tag, { props: i } = C(e), s = new o(i, n);
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) {
@@ -256,7 +260,7 @@ function j(e, t) {
256
260
  }
257
261
  return !0;
258
262
  }
259
- function C(e, t) {
263
+ function A(e, t) {
260
264
  const r = Object.keys(e), n = Object.keys(t), o = [], i = [];
261
265
  for (const s of n)
262
266
  s in e ? e[s] !== t[s] && i.push(s) : o.push(s);
@@ -272,7 +276,7 @@ function rt(e) {
272
276
  function S(e) {
273
277
  return rt(e.trim());
274
278
  }
275
- function E(e, t, r, n = null) {
279
+ function g(e, t, r, n = null) {
276
280
  if (!j(e, t)) {
277
281
  const o = nt(r, e.el);
278
282
  return p(e), d(t, r, o, n), t;
@@ -333,7 +337,7 @@ 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: l, removed: a, updated: u } = C(i, s);
340
+ const { added: l, removed: a, updated: u } = A(i, s);
337
341
  for (const f of a)
338
342
  D(e, f);
339
343
  for (const f of l.concat(u))
@@ -347,14 +351,14 @@ function k(e = "") {
347
351
  return Array.isArray(e) ? e.filter(S) : String(e).split(/(\s+)/).filter(S);
348
352
  }
349
353
  function ut(e, t = {}, r = {}) {
350
- const { added: n, removed: o, updated: i } = C(t, r);
354
+ const { added: n, removed: o, updated: i } = A(t, r);
351
355
  for (const s of o)
352
356
  J(e, s);
353
357
  for (const s of n.concat(i))
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: l } = C(r, n);
361
+ const { removed: i, added: s, updated: l } = A(r, n);
358
362
  for (const u of i.concat(l)) {
359
363
  const f = t?.[u];
360
364
  f && e.removeEventListener(u, f);
@@ -372,23 +376,23 @@ function lt(e, t = {}, r = {}, n = {}, o = null) {
372
376
  function F(e, t, r) {
373
377
  const n = m(e), o = m(t), i = e.el, s = R(n, o, j), l = r?.offset ?? 0;
374
378
  for (const a of s)
375
- if (a.op === g.NOOP) {
379
+ if (a.op === E.NOOP) {
376
380
  const { originalIndex: u, index: f } = a;
377
- E(n[u], o[f], i, r);
381
+ g(n[u], o[f], i, r);
378
382
  }
379
383
  for (const a of s)
380
384
  switch (a.op) {
381
- case g.MOVE: {
385
+ case E.MOVE: {
382
386
  const { from: u, index: f } = a, y = n[u].el, v = i.childNodes[f + l];
383
- y && (i.insertBefore(y, v), E(n[u], o[f], i, r));
387
+ y && (i.insertBefore(y, v), g(n[u], o[f], i, r));
384
388
  break;
385
389
  }
386
- case g.REMOVE: {
390
+ case E.REMOVE: {
387
391
  const { item: u } = a;
388
392
  p(u);
389
393
  break;
390
394
  }
391
- case g.ADD: {
395
+ case E.ADD: {
392
396
  const { index: u, item: f } = a;
393
397
  d(f, i, u + l, r);
394
398
  break;
@@ -396,7 +400,7 @@ function F(e, t, r) {
396
400
  }
397
401
  }
398
402
  function at(e, t) {
399
- const { component: r } = e, { props: n } = A(t);
403
+ const { component: r } = e, { props: n } = C(t);
400
404
  r.updateProps(n), t.component = r, t.el = r.firstElement;
401
405
  }
402
406
  function ft(e, t, r) {
@@ -500,7 +504,7 @@ class T {
500
504
  h(() => this.willUpdate(this.props, this.state));
501
505
  try {
502
506
  const n = this.render();
503
- this.vdom = E(this.vdom, n, this.hostEl, this), h(() => this.didUpdate(t, r));
507
+ this.vdom = g(this.vdom, n, this.hostEl, this), h(() => this.didUpdate(t, r));
504
508
  } catch (n) {
505
509
  this.handleError(n, "patch");
506
510
  }
@@ -546,24 +550,24 @@ class T {
546
550
  const s = i.getDerivedStateFromError(t);
547
551
  n.state = { ...n.state, ...s };
548
552
  }
549
- if ((r === "patch" || n.isMounted) && (console.log("Calling componentDidCatch"), n.didCatch(t, {
550
- phase: r,
551
- failedComponent: this.constructor.name,
552
- componentStack: this.getComponentStack()
553
- })), n.hostEl) {
553
+ if (n.hostEl) {
554
554
  console.log("Rendering fallback UI");
555
555
  try {
556
556
  const s = n.render();
557
- if (s)
558
- if (n.vdom)
559
- console.log("Patching ErrorBoundary"), E(n.vdom, s, n.hostEl, n);
560
- else {
561
- console.log("Mounting ErrorBoundary fallback");
562
- const l = n.parent?.offset || 0;
563
- n.hostEl && n.hostEl.children.length > 0 && Array.from(n.hostEl.children).forEach((a) => {
564
- a.remove();
565
- }), d(s, n.hostEl, l, n.parent), n.vdom = s, n.isMounted = !0;
557
+ if (s && !n.vdom) {
558
+ if (n.isMounted = !0, !n.vdom) {
559
+ for (console.log("Mounting ErrorBoundary fallback (first time)"); n.hostEl.firstChild; )
560
+ n.hostEl.removeChild(n.hostEl.firstChild);
561
+ d(s, n.hostEl, null, n.parent), n.vdom = s;
566
562
  }
563
+ h(() => {
564
+ n.didCatch(t, {
565
+ phase: r,
566
+ failedComponent: this.constructor.name,
567
+ componentStack: this.getComponentStack()
568
+ }), n.didMount();
569
+ });
570
+ }
567
571
  } catch (s) {
568
572
  console.error("Error during ErrorBoundary recovery:", s), n.parent && n.parent.handleError(s, r);
569
573
  }
@@ -583,7 +587,7 @@ class T {
583
587
  }), this.hostEl && this.isMounted)
584
588
  try {
585
589
  const i = this.render();
586
- i && E(this.vdom, i, this.hostEl, this);
590
+ i && g(this.vdom, i, this.hostEl, this);
587
591
  } catch (i) {
588
592
  console.error("Error during error recovery render:", i);
589
593
  }
@@ -609,12 +613,12 @@ 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 Et(e) {
616
+ function yt(e) {
613
617
  class t extends T {
614
618
  isProvider = !0;
615
619
  render() {
616
620
  let o = [];
617
- return Array.isArray(this.props.children) ? o = this.props.children : this.props.children ? o = [this.props.children] : o = [], B(o);
621
+ return Array.isArray(this.props.children) ? o = this.props.children : this.props.children ? o = [this.props.children] : o = [], U(o);
618
622
  }
619
623
  }
620
624
  class r extends T {
@@ -643,7 +647,7 @@ function Et(e) {
643
647
  defaultValue: e
644
648
  };
645
649
  }
646
- function yt(e, t) {
650
+ function Et(e, t) {
647
651
  if (!t)
648
652
  throw new Error("Container element is not provided for rendering.");
649
653
  d(e, t);
@@ -655,15 +659,15 @@ function gt(e = null) {
655
659
  }
656
660
  function vt(e, t) {
657
661
  const r = Array.isArray(e) ? e : [e];
658
- return U(r, t);
662
+ return B(r, t);
659
663
  }
660
664
  export {
661
665
  T as Component,
662
- Et as createContext,
666
+ yt as createContext,
663
667
  vt as createPortal,
664
668
  gt as createRef,
665
669
  Pt as h,
666
- B as hFragment,
670
+ U as hFragment,
667
671
  Ot as hString,
668
- yt as render
672
+ Et as render
669
673
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ddd-react",
3
- "version": "1.10.5",
3
+ "version": "1.10.7",
4
4
  "scripts": {
5
5
  "test": "echo \"Error: no test specified\" && exit 1",
6
6
  "type-check": "tsc --noEmit",