ddd-react 1.10.1 → 1.10.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.
Files changed (2) hide show
  1. package/dist/index.mjs +90 -86
  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 E, 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 v, 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;
@@ -40,18 +40,18 @@ function m(e, t) {
40
40
  return !1;
41
41
  }
42
42
  function N(e, t, r, n = null) {
43
- function s(o) {
44
- const i = o;
45
- n ? t.call(n, i) : t(i);
43
+ function s(i) {
44
+ const o = i;
45
+ n ? t.call(n, o) : t(o);
46
46
  }
47
47
  return r.addEventListener(e, s), s;
48
48
  }
49
49
  function I(e = {}, t, r = null) {
50
50
  const n = {};
51
- return Object.entries(e).forEach(([s, o]) => {
51
+ return Object.entries(e).forEach(([s, i]) => {
52
52
  n[s] = N(
53
53
  s,
54
- o,
54
+ i,
55
55
  t,
56
56
  r
57
57
  );
@@ -114,11 +114,11 @@ function J(e, t) {
114
114
  }
115
115
  function K(e, t) {
116
116
  const { class: r, style: n, ...s } = t;
117
- r && W(e, r), n && Object.entries(n).forEach(([o, i]) => {
118
- M(e, o, i);
117
+ r && W(e, r), n && Object.entries(n).forEach(([i, o]) => {
118
+ M(e, i, o);
119
119
  });
120
- for (const [o, i] of Object.entries(s))
121
- w(e, o, i);
120
+ for (const [i, o] of Object.entries(s))
121
+ w(e, i, o);
122
122
  }
123
123
  function W(e, t) {
124
124
  if (e instanceof SVGElement) {
@@ -199,13 +199,13 @@ function z(e, t, r) {
199
199
  }
200
200
  function Q(e, t, r, n) {
201
201
  const { children: s } = e;
202
- e.el = t, s?.forEach((o, i) => {
203
- h(o, t, r != null ? r + i : null, n);
202
+ e.el = t, s?.forEach((i, o) => {
203
+ h(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: o } = 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, o?.forEach((f) => {
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
209
  h(f, a, null, n);
210
210
  }), L(a, t, r);
211
211
  }
@@ -214,8 +214,8 @@ function V(e, t, r) {
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: o } = A(e), i = new s(o, n);
218
- i.mount(t, r), e.component = i, e.el = i.firstElement || null;
217
+ const s = e.tag, { props: i } = A(e), o = new s(i, n);
218
+ o.mount(t, r), e.component = o, e.el = o.firstElement || null;
219
219
  }
220
220
  function L(e, t, r) {
221
221
  if (r == null) {
@@ -239,16 +239,16 @@ function j(e, t) {
239
239
  if (e.type === c.ELEMENT) {
240
240
  const r = e, n = t, {
241
241
  tag: s,
242
- props: { key: o }
242
+ props: { key: i }
243
243
  } = r, {
244
- tag: i,
244
+ tag: o,
245
245
  props: { key: a }
246
246
  } = n;
247
- return s === i && o === a;
247
+ return s === o && i === a;
248
248
  }
249
249
  if (e.type === c.COMPONENT) {
250
- const r = e, n = t, { tag: s } = r, { tag: o } = n;
251
- return s === o;
250
+ const r = e, n = t, { tag: s } = r, { tag: i } = n;
251
+ return s === i;
252
252
  }
253
253
  if (e.type === c.PORTAL) {
254
254
  const r = e, n = t;
@@ -257,22 +257,22 @@ function j(e, t) {
257
257
  return !0;
258
258
  }
259
259
  function S(e, t) {
260
- const r = Object.keys(e), n = Object.keys(t), s = [], o = [];
261
- for (const i of n)
262
- i in e ? e[i] !== t[i] && o.push(i) : s.push(i);
260
+ const r = Object.keys(e), n = Object.keys(t), s = [], i = [];
261
+ for (const o of n)
262
+ o in e ? e[o] !== t[o] && i.push(o) : s.push(o);
263
263
  return {
264
264
  added: s,
265
- removed: r.filter((i) => !(i in t)),
266
- updated: o
265
+ removed: r.filter((o) => !(o in t)),
266
+ updated: i
267
267
  };
268
268
  }
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
- function v(e, t, r, n = null) {
275
+ function y(e, t, r, n = null) {
276
276
  if (!j(e, t)) {
277
277
  const s = nt(r, e.el);
278
278
  return p(e), h(t, r, s, n), t;
@@ -307,23 +307,23 @@ function st(e, t) {
307
307
  function ot(e, t, r) {
308
308
  const n = e.el, {
309
309
  class: s,
310
- style: o,
311
- on: i,
310
+ style: i,
311
+ on: o,
312
312
  ...a
313
313
  } = e.props ?? {}, {
314
314
  class: f,
315
315
  style: u,
316
316
  on: l,
317
- ...y
317
+ ...E
318
318
  } = t.props ?? {}, { listeners: g } = e;
319
- it(n, a, y), ct(n, s, f), ut(
319
+ it(n, a, E), ct(n, s, f), ut(
320
320
  n,
321
- o,
321
+ i,
322
322
  u
323
323
  ), t.listeners = at(
324
324
  n,
325
325
  g,
326
- i ?? {},
326
+ o ?? {},
327
327
  l ?? {},
328
328
  r
329
329
  );
@@ -331,36 +331,36 @@ function ot(e, t, r) {
331
331
  function it(e, t = {}, r = {}) {
332
332
  const n = t.ref, s = r.ref;
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
- const o = { ...t }, i = { ...r };
335
- delete o.ref, delete i.ref;
336
- const { added: a, removed: f, updated: u } = S(o, i);
334
+ const i = { ...t }, o = { ...r };
335
+ delete i.ref, delete o.ref;
336
+ const { added: a, removed: f, updated: u } = S(i, o);
337
337
  for (const l of f)
338
338
  D(e, l);
339
339
  for (const l of a.concat(u))
340
- w(e, l, i[l]);
340
+ w(e, l, o[l]);
341
341
  }
342
342
  function ct(e, t, r) {
343
- const n = k(t), s = k(r), { added: o, removed: i } = F(n, s);
344
- i.length > 0 && e.classList.remove(...i), o.length > 0 && e.classList.add(...o);
343
+ const n = T(t), s = T(r), { added: i, removed: o } = x(n, s);
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
- const { added: n, removed: s, updated: o } = S(t, r);
351
- for (const i of s)
352
- J(e, i);
353
- for (const i of n.concat(o))
354
- M(e, i, r[i]);
350
+ const { added: n, removed: s, updated: i } = S(t, r);
351
+ for (const o of s)
352
+ J(e, o);
353
+ for (const o of n.concat(i))
354
+ M(e, o, r[o]);
355
355
  }
356
356
  function at(e, t = {}, r = {}, n = {}, s = null) {
357
- const { removed: o, added: i, updated: a } = S(r, n);
358
- for (const u of o.concat(a)) {
357
+ const { removed: i, added: o, updated: a } = S(r, n);
358
+ for (const u of i.concat(a)) {
359
359
  const l = t?.[u];
360
360
  l && e.removeEventListener(u, l);
361
361
  }
362
362
  const f = {};
363
- for (const u of i.concat(a))
363
+ for (const u of o.concat(a))
364
364
  f[u] = N(
365
365
  u,
366
366
  n[u],
@@ -370,27 +370,27 @@ function at(e, t = {}, r = {}, n = {}, s = null) {
370
370
  return f;
371
371
  }
372
372
  function R(e, t, r) {
373
- const n = b(e), s = b(t), o = e.el, i = x(n, s, j), a = r?.offset ?? 0;
374
- for (const f of i)
375
- if (f.op === E.NOOP) {
373
+ const n = m(e), s = m(t), i = e.el, o = F(n, s, j), a = r?.offset ?? 0;
374
+ for (const f of o)
375
+ if (f.op === v.NOOP) {
376
376
  const { originalIndex: u, index: l } = f;
377
- v(n[u], s[l], o, r);
377
+ y(n[u], s[l], i, r);
378
378
  }
379
- for (const f of i)
379
+ for (const f of o)
380
380
  switch (f.op) {
381
- case E.MOVE: {
382
- const { from: u, index: l } = f, y = n[u].el, g = o.childNodes[l + a];
383
- y && (o.insertBefore(y, g), v(n[u], s[l], o, r));
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));
384
384
  break;
385
385
  }
386
- case E.REMOVE: {
386
+ case v.REMOVE: {
387
387
  const { item: u } = f;
388
388
  p(u);
389
389
  break;
390
390
  }
391
- case E.ADD: {
391
+ case v.ADD: {
392
392
  const { index: u, item: l } = f;
393
- h(l, o, u + a, r);
393
+ h(l, i, u + a, r);
394
394
  break;
395
395
  }
396
396
  }
@@ -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];
@@ -500,7 +500,7 @@ class C {
500
500
  d(() => this.willUpdate(this.props, this.state));
501
501
  try {
502
502
  const n = this.render();
503
- this.vdom = v(this.vdom, n, this.hostEl, this), d(() => this.didUpdate(t, r));
503
+ this.vdom = y(this.vdom, n, this.hostEl, this), d(() => this.didUpdate(t, r));
504
504
  } catch (n) {
505
505
  this.handleError(n, "patch");
506
506
  }
@@ -536,12 +536,13 @@ 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 o = n.constructor;
542
- if (o.getDerivedStateFromError) {
543
- const i = o.getDerivedStateFromError(t);
544
- n.state = { ...n.state, ...i };
541
+ if (console.log("errorBoundary", n), n && n.isMounted) {
542
+ const i = n.constructor;
543
+ if (i.getDerivedStateFromError) {
544
+ const o = i.getDerivedStateFromError(t);
545
+ n.state = { ...n.state, ...o };
545
546
  }
546
547
  if (n.didCatch(t, {
547
548
  phase: r,
@@ -549,16 +550,19 @@ class C {
549
550
  componentStack: this.getComponentStack()
550
551
  }), n.hostEl && n.vdom)
551
552
  try {
552
- if (n.render())
553
+ const o = n.render();
554
+ if (o) {
555
+ y(n.vdom, o, n.hostEl, n);
553
556
  return;
554
- } catch (i) {
555
- console.error("Error during ErrorBoundary recovery:", i);
557
+ }
558
+ } catch (o) {
559
+ console.error("Error during ErrorBoundary recovery:", o);
556
560
  }
557
561
  }
558
562
  const s = this.constructor;
559
563
  if (s.getDerivedStateFromError) {
560
- const o = s.getDerivedStateFromError(t);
561
- this.state = { ...this.state, ...o };
564
+ const i = s.getDerivedStateFromError(t);
565
+ this.state = { ...this.state, ...i };
562
566
  }
563
567
  d(() => {
564
568
  if (this.didCatch(t, {
@@ -566,10 +570,10 @@ class C {
566
570
  componentStack: this.getComponentStack()
567
571
  }), this.hostEl && this.isMounted)
568
572
  try {
569
- const o = this.render();
570
- o && v(this.vdom, o, this.hostEl, this);
571
- } catch (o) {
572
- console.error("Error during error recovery render:", o);
573
+ const i = this.render();
574
+ i && y(this.vdom, i, this.hostEl, this);
575
+ } catch (i) {
576
+ console.error("Error during error recovery render:", i);
573
577
  }
574
578
  });
575
579
  }
@@ -590,18 +594,18 @@ class C {
590
594
  return null;
591
595
  }
592
596
  isErrorBoundary() {
593
- return this.constructor.getDerivedStateFromError !== void 0;
597
+ 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;
594
598
  }
595
599
  }
596
600
  function yt(e) {
597
- class t extends C {
601
+ class t extends k {
598
602
  isProvider = !0;
599
603
  render() {
600
604
  let s = [];
601
605
  return Array.isArray(this.props.children) ? s = this.props.children : this.props.children ? s = [this.props.children] : s = [], U(s);
602
606
  }
603
607
  }
604
- class r extends C {
608
+ class r extends k {
605
609
  static contextType = {
606
610
  Provider: t,
607
611
  defaultValue: e
@@ -642,7 +646,7 @@ function gt(e, t) {
642
646
  return B(r, t);
643
647
  }
644
648
  export {
645
- C as Component,
649
+ k as Component,
646
650
  yt as createContext,
647
651
  gt as createPortal,
648
652
  vt as createRef,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ddd-react",
3
- "version": "1.10.1",
3
+ "version": "1.10.3",
4
4
  "scripts": {
5
5
  "test": "echo \"Error: no test specified\" && exit 1",
6
6
  "type-check": "tsc --noEmit",