ddd-react 1.10.2 → 1.10.4

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 +91 -84
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { D as c, e as b, a as x, A as v, b as F, h as U, c as B } from "./h-BbaMkkC7.mjs";
1
+ import { D as c, e as m, a as F, A as g, 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
- function m(e, t) {
3
+ function b(e, t) {
4
4
  if (e === null || t === null || e === void 0 || t === void 0)
5
5
  return e === t;
6
6
  if (typeof e != typeof t)
@@ -14,7 +14,7 @@ function m(e, t) {
14
14
  if (e.length !== t.length)
15
15
  return !1;
16
16
  for (let n = 0; n < e.length; ++n)
17
- if (!m(e[n], t[n]))
17
+ if (!b(e[n], t[n]))
18
18
  return !1;
19
19
  return !0;
20
20
  }
@@ -32,7 +32,7 @@ function m(e, t) {
32
32
  return !1;
33
33
  for (let n = 0; n < r.length; ++n) {
34
34
  const s = r[n];
35
- if (!(s === "_owner" && e.$$typeof) && !m(e[s], t[s]))
35
+ if (!(s === "_owner" && e.$$typeof) && !b(e[s], t[s]))
36
36
  return !1;
37
37
  }
38
38
  return !0;
@@ -204,10 +204,10 @@ function Q(e, t, r, n) {
204
204
  });
205
205
  }
206
206
  function Z(e, t, r, n) {
207
- const { tag: s, children: i } = e, a = s === "svg" || t instanceof SVGElement ? document.createElementNS("http://www.w3.org/2000/svg", s) : document.createElement(s);
208
- V(a, e, n), e.el = a, i?.forEach((f) => {
209
- h(f, a, null, n);
210
- }), L(a, t, r);
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
+ h(a, l, null, n);
210
+ }), L(l, t, r);
211
211
  }
212
212
  function V(e, t, r) {
213
213
  const { props: n, events: s } = A(t);
@@ -242,9 +242,9 @@ function j(e, t) {
242
242
  props: { key: i }
243
243
  } = r, {
244
244
  tag: o,
245
- props: { key: a }
245
+ props: { key: l }
246
246
  } = n;
247
- return s === o && i === a;
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;
@@ -269,7 +269,7 @@ function S(e, t) {
269
269
  function rt(e) {
270
270
  return e !== "";
271
271
  }
272
- function T(e) {
272
+ function C(e) {
273
273
  return rt(e.trim());
274
274
  }
275
275
  function y(e, t, r, n = null) {
@@ -285,11 +285,11 @@ function y(e, t, r, n = null) {
285
285
  break;
286
286
  }
287
287
  case c.COMPONENT: {
288
- ft(e, t);
288
+ at(e, t);
289
289
  break;
290
290
  }
291
291
  case c.PORTAL: {
292
- lt(e, t, n);
292
+ ft(e, t, n);
293
293
  break;
294
294
  }
295
295
  }
@@ -309,22 +309,22 @@ function ot(e, t, r) {
309
309
  class: s,
310
310
  style: i,
311
311
  on: o,
312
- ...a
312
+ ...l
313
313
  } = e.props ?? {}, {
314
- class: f,
314
+ class: a,
315
315
  style: u,
316
- on: l,
316
+ on: f,
317
317
  ...E
318
- } = t.props ?? {}, { listeners: g } = e;
319
- it(n, a, E), ct(n, s, f), ut(
318
+ } = t.props ?? {}, { listeners: v } = e;
319
+ it(n, l, E), ct(n, s, a), ut(
320
320
  n,
321
321
  i,
322
322
  u
323
- ), t.listeners = at(
323
+ ), t.listeners = lt(
324
324
  n,
325
- g,
325
+ v,
326
326
  o ?? {},
327
- l ?? {},
327
+ f ?? {},
328
328
  r
329
329
  );
330
330
  }
@@ -333,18 +333,18 @@ 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: a, removed: f, updated: u } = S(i, o);
337
- for (const l of f)
338
- D(e, l);
339
- for (const l of a.concat(u))
340
- w(e, l, o[l]);
336
+ const { added: l, removed: a, updated: u } = S(i, o);
337
+ for (const f of a)
338
+ D(e, f);
339
+ for (const f of l.concat(u))
340
+ w(e, f, o[f]);
341
341
  }
342
342
  function ct(e, t, r) {
343
- const n = k(t), s = k(r), { added: i, removed: o } = F(n, s);
343
+ const n = T(t), s = T(r), { added: i, removed: o } = x(n, s);
344
344
  o.length > 0 && e.classList.remove(...o), i.length > 0 && e.classList.add(...i);
345
345
  }
346
- function k(e = "") {
347
- return Array.isArray(e) ? e.filter(T) : String(e).split(/(\s+)/).filter(T);
346
+ function T(e = "") {
347
+ return Array.isArray(e) ? e.filter(C) : String(e).split(/(\s+)/).filter(C);
348
348
  }
349
349
  function ut(e, t = {}, r = {}) {
350
350
  const { added: n, removed: s, updated: i } = S(t, r);
@@ -353,53 +353,53 @@ function ut(e, t = {}, r = {}) {
353
353
  for (const o of n.concat(i))
354
354
  M(e, o, r[o]);
355
355
  }
356
- function at(e, t = {}, r = {}, n = {}, s = null) {
357
- const { removed: i, added: o, updated: a } = S(r, n);
358
- for (const u of i.concat(a)) {
359
- const l = t?.[u];
360
- l && e.removeEventListener(u, l);
356
+ function lt(e, t = {}, r = {}, n = {}, s = null) {
357
+ const { removed: i, added: o, updated: l } = S(r, n);
358
+ for (const u of i.concat(l)) {
359
+ const f = t?.[u];
360
+ f && e.removeEventListener(u, f);
361
361
  }
362
- const f = {};
363
- for (const u of o.concat(a))
364
- f[u] = N(
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 f;
370
+ return a;
371
371
  }
372
372
  function R(e, t, r) {
373
- const n = b(e), s = b(t), i = e.el, o = x(n, s, j), a = r?.offset ?? 0;
374
- for (const f of o)
375
- if (f.op === v.NOOP) {
376
- const { originalIndex: u, index: l } = f;
377
- y(n[u], s[l], i, r);
373
+ const n = m(e), s = m(t), i = e.el, o = F(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
+ y(n[u], s[f], i, r);
378
378
  }
379
- for (const f of o)
380
- switch (f.op) {
381
- case v.MOVE: {
382
- const { from: u, index: l } = f, E = n[u].el, g = i.childNodes[l + a];
383
- E && (i.insertBefore(E, g), y(n[u], s[l], i, r));
379
+ for (const a of o)
380
+ switch (a.op) {
381
+ case g.MOVE: {
382
+ const { from: u, index: f } = a, E = n[u].el, v = i.childNodes[f + l];
383
+ E && (i.insertBefore(E, v), y(n[u], s[f], i, r));
384
384
  break;
385
385
  }
386
- case v.REMOVE: {
387
- const { item: u } = f;
386
+ case g.REMOVE: {
387
+ const { item: u } = a;
388
388
  p(u);
389
389
  break;
390
390
  }
391
- case v.ADD: {
392
- const { index: u, item: l } = f;
393
- h(l, i, u + a, r);
391
+ case g.ADD: {
392
+ const { index: u, item: f } = a;
393
+ h(f, i, u + l, r);
394
394
  break;
395
395
  }
396
396
  }
397
397
  }
398
- function ft(e, t) {
398
+ function at(e, t) {
399
399
  const { component: r } = e, { props: n } = A(t);
400
400
  r.updateProps(n), t.component = r, t.el = r.firstElement;
401
401
  }
402
- function lt(e, t, r) {
402
+ function ft(e, t, r) {
403
403
  if (e.container !== t.container) {
404
404
  p(e), h(t, document.body, null, r);
405
405
  return;
@@ -407,7 +407,7 @@ function lt(e, t, r) {
407
407
  R(e, t, r);
408
408
  }
409
409
  const ht = (e) => e.isProvider, dt = (e) => e.isConsumer;
410
- class C {
410
+ class k {
411
411
  isMounted = !1;
412
412
  vdom = null;
413
413
  hostEl = null;
@@ -458,10 +458,10 @@ class C {
458
458
  return console.error("Uncaught error:", t, r), this.error = t, Promise.resolve();
459
459
  }
460
460
  shouldComponentUpdate(t, r) {
461
- return m(t, r);
461
+ return b(t, r);
462
462
  }
463
463
  get elements() {
464
- return this.vdom == null ? [] : this.vdom.type === c.FRAGMENT ? b(this.vdom).flatMap((t) => t.type === c.COMPONENT && t.component ? t.component.elements : t.el ? [t.el] : []) : this.vdom.el ? [this.vdom.el] : [];
464
+ return this.vdom == null ? [] : this.vdom.type === c.FRAGMENT ? m(this.vdom).flatMap((t) => t.type === c.COMPONENT && t.component ? t.component.elements : t.el ? [t.el] : []) : this.vdom.el ? [this.vdom.el] : [];
465
465
  }
466
466
  get firstElement() {
467
467
  return this.elements[0];
@@ -536,28 +536,35 @@ class C {
536
536
  return this.constructor.defaultProps || {};
537
537
  }
538
538
  handleError(t, r) {
539
+ console.log("handleError");
539
540
  const n = this.findClosestErrorBoundary();
540
- if (n && n.isMounted) {
541
- const i = n.constructor;
542
- if (i.getDerivedStateFromError) {
543
- const o = i.getDerivedStateFromError(t);
544
- n.state = { ...n.state, ...o };
545
- }
546
- if (n.didCatch(t, {
547
- phase: r,
548
- failedComponent: this.constructor.name,
549
- componentStack: this.getComponentStack()
550
- }), n.hostEl && n.vdom)
551
- try {
552
- const o = n.render();
553
- if (o) {
554
- y(n.vdom, o, n.hostEl, n);
555
- return;
541
+ if (console.log("errorBoundary", n), console.log(1), n) {
542
+ if (console.log(2), n.isMounted) {
543
+ console.log(3);
544
+ const i = n.constructor;
545
+ if (i.getDerivedStateFromError) {
546
+ console.log(4);
547
+ const o = i.getDerivedStateFromError(t);
548
+ n.state = { ...n.state, ...o };
549
+ }
550
+ if (n.didCatch(t, {
551
+ phase: r,
552
+ failedComponent: this.constructor.name,
553
+ componentStack: this.getComponentStack()
554
+ }), n.hostEl && n.vdom) {
555
+ console.log(5);
556
+ try {
557
+ console.log(6);
558
+ const o = n.render();
559
+ o && (console.log(7), y(n.vdom, o, n.hostEl, n));
560
+ } catch (o) {
561
+ console.log(8), console.error("Error during ErrorBoundary recovery:", o);
556
562
  }
557
- } catch (o) {
558
- console.error("Error during ErrorBoundary recovery:", o);
559
563
  }
564
+ }
565
+ return;
560
566
  }
567
+ console.log(9);
561
568
  const s = this.constructor;
562
569
  if (s.getDerivedStateFromError) {
563
570
  const i = s.getDerivedStateFromError(t);
@@ -593,18 +600,18 @@ class C {
593
600
  return null;
594
601
  }
595
602
  isErrorBoundary() {
596
- return this.constructor.getDerivedStateFromError !== void 0;
603
+ 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;
597
604
  }
598
605
  }
599
606
  function yt(e) {
600
- class t extends C {
607
+ class t extends k {
601
608
  isProvider = !0;
602
609
  render() {
603
610
  let s = [];
604
611
  return Array.isArray(this.props.children) ? s = this.props.children : this.props.children ? s = [this.props.children] : s = [], U(s);
605
612
  }
606
613
  }
607
- class r extends C {
614
+ class r extends k {
608
615
  static contextType = {
609
616
  Provider: t,
610
617
  defaultValue: e
@@ -635,20 +642,20 @@ function Et(e, t) {
635
642
  throw new Error("Container element is not provided for rendering.");
636
643
  h(e, t);
637
644
  }
638
- function vt(e = null) {
645
+ function gt(e = null) {
639
646
  return {
640
647
  current: e
641
648
  };
642
649
  }
643
- function gt(e, t) {
650
+ function vt(e, t) {
644
651
  const r = Array.isArray(e) ? e : [e];
645
652
  return B(r, t);
646
653
  }
647
654
  export {
648
- C as Component,
655
+ k as Component,
649
656
  yt as createContext,
650
- gt as createPortal,
651
- vt as createRef,
657
+ vt as createPortal,
658
+ gt as createRef,
652
659
  Pt as h,
653
660
  U as hFragment,
654
661
  Ot as hString,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ddd-react",
3
- "version": "1.10.2",
3
+ "version": "1.10.4",
4
4
  "scripts": {
5
5
  "test": "echo \"Error: no test specified\" && exit 1",
6
6
  "type-check": "tsc --noEmit",