ddd-react 1.10.6 → 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 +78 -78
  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)
@@ -135,7 +135,7 @@ function D(e, t) {
135
135
  }
136
136
  let P = !1;
137
137
  const O = [];
138
- function d(e) {
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 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
  }
168
- function h(e, t, r = null, n = null) {
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 o = e.component;
185
- o && d(() => o.didMount());
185
+ o && h(() => o.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: o } = e;
202
202
  e.el = t, o?.forEach((i, s) => {
203
- h(i, t, r != null ? r + s : null, n);
203
+ d(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, 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);
207
+ const { tag: o, children: i } = e, l = o === "svg" || t instanceof SVGElement ? document.createElementNS("http://www.w3.org/2000/svg", o) : document.createElement(o);
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: 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);
217
+ const o = e.tag, { props: i } = C(e), s = new o(i, n);
218
218
  try {
219
219
  s.mount(t, r), e.component = s, e.el = s.firstElement || null;
220
220
  } catch {
@@ -234,7 +234,7 @@ function L(e, t, r) {
234
234
  function et(e, t) {
235
235
  const { children: r, container: n } = e;
236
236
  r?.forEach((o) => {
237
- h(o, n, null, t);
237
+ d(o, n, null, t);
238
238
  });
239
239
  }
240
240
  function j(e, t) {
@@ -246,9 +246,9 @@ function j(e, t) {
246
246
  props: { key: i }
247
247
  } = r, {
248
248
  tag: s,
249
- props: { key: u }
249
+ props: { key: l }
250
250
  } = n;
251
- return o === s && i === u;
251
+ return o === s && i === l;
252
252
  }
253
253
  if (e.type === c.COMPONENT) {
254
254
  const r = e, n = t, { tag: o } = r, { tag: i } = n;
@@ -260,7 +260,7 @@ function j(e, t) {
260
260
  }
261
261
  return !0;
262
262
  }
263
- function C(e, t) {
263
+ function A(e, t) {
264
264
  const r = Object.keys(e), n = Object.keys(t), o = [], i = [];
265
265
  for (const s of n)
266
266
  s in e ? e[s] !== t[s] && i.push(s) : o.push(s);
@@ -276,10 +276,10 @@ function rt(e) {
276
276
  function S(e) {
277
277
  return rt(e.trim());
278
278
  }
279
- function y(e, t, r, n = null) {
279
+ function g(e, t, r, n = null) {
280
280
  if (!j(e, t)) {
281
281
  const o = nt(r, e.el);
282
- return p(e), h(t, r, o, n), t;
282
+ return p(e), d(t, r, o, n), t;
283
283
  }
284
284
  switch (t.el = e.el, t.type) {
285
285
  case c.TEXT:
@@ -313,17 +313,17 @@ function st(e, t, r) {
313
313
  class: o,
314
314
  style: i,
315
315
  on: s,
316
- ...u
316
+ ...l
317
317
  } = e.props ?? {}, {
318
318
  class: a,
319
- style: l,
319
+ style: u,
320
320
  on: f,
321
- ...E
321
+ ...y
322
322
  } = t.props ?? {}, { listeners: v } = e;
323
- it(n, u, E), ct(n, o, a), ut(
323
+ it(n, l, y), ct(n, o, a), ut(
324
324
  n,
325
325
  i,
326
- l
326
+ u
327
327
  ), t.listeners = lt(
328
328
  n,
329
329
  v,
@@ -337,10 +337,10 @@ function it(e, t = {}, r = {}) {
337
337
  n !== o && (n && typeof n == "object" && "current" in n && (n.current = null), o && typeof o == "object" && "current" in o && (o.current = e));
338
338
  const i = { ...t }, s = { ...r };
339
339
  delete i.ref, delete s.ref;
340
- const { added: u, removed: a, updated: l } = C(i, s);
340
+ const { added: l, removed: a, updated: u } = A(i, s);
341
341
  for (const f of a)
342
342
  D(e, f);
343
- for (const f of u.concat(l))
343
+ for (const f of l.concat(u))
344
344
  w(e, f, s[f]);
345
345
  }
346
346
  function ct(e, t, r) {
@@ -351,66 +351,66 @@ function k(e = "") {
351
351
  return Array.isArray(e) ? e.filter(S) : String(e).split(/(\s+)/).filter(S);
352
352
  }
353
353
  function ut(e, t = {}, r = {}) {
354
- const { added: n, removed: o, updated: i } = C(t, r);
354
+ const { added: n, removed: o, updated: i } = A(t, r);
355
355
  for (const s of o)
356
356
  J(e, s);
357
357
  for (const s of n.concat(i))
358
358
  M(e, s, r[s]);
359
359
  }
360
360
  function lt(e, t = {}, r = {}, n = {}, o = null) {
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
+ const { removed: i, added: s, updated: l } = A(r, n);
362
+ for (const u of i.concat(l)) {
363
+ const f = t?.[u];
364
+ f && e.removeEventListener(u, f);
365
365
  }
366
366
  const a = {};
367
- for (const l of s.concat(u))
368
- a[l] = N(
369
- l,
370
- n[l],
367
+ for (const u of s.concat(l))
368
+ a[u] = N(
369
+ u,
370
+ n[u],
371
371
  e,
372
372
  o
373
373
  );
374
374
  return a;
375
375
  }
376
376
  function F(e, t, r) {
377
- const n = m(e), o = m(t), i = e.el, s = R(n, o, j), u = r?.offset ?? 0;
377
+ const n = m(e), o = m(t), i = e.el, s = R(n, o, j), l = r?.offset ?? 0;
378
378
  for (const a of s)
379
- if (a.op === g.NOOP) {
380
- const { originalIndex: l, index: f } = a;
381
- y(n[l], o[f], i, r);
379
+ if (a.op === E.NOOP) {
380
+ const { originalIndex: u, index: f } = a;
381
+ g(n[u], o[f], i, r);
382
382
  }
383
383
  for (const a of s)
384
384
  switch (a.op) {
385
- case g.MOVE: {
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));
385
+ case E.MOVE: {
386
+ const { from: u, index: f } = a, y = n[u].el, v = i.childNodes[f + l];
387
+ y && (i.insertBefore(y, v), g(n[u], o[f], i, r));
388
388
  break;
389
389
  }
390
- case g.REMOVE: {
391
- const { item: l } = a;
392
- p(l);
390
+ case E.REMOVE: {
391
+ const { item: u } = a;
392
+ p(u);
393
393
  break;
394
394
  }
395
- case g.ADD: {
396
- const { index: l, item: f } = a;
397
- h(f, i, l + u, r);
395
+ case E.ADD: {
396
+ const { index: u, item: f } = a;
397
+ d(f, i, u + l, r);
398
398
  break;
399
399
  }
400
400
  }
401
401
  }
402
402
  function at(e, t) {
403
- const { component: r } = e, { props: n } = A(t);
403
+ const { component: r } = e, { props: n } = C(t);
404
404
  r.updateProps(n), t.component = r, t.el = r.firstElement;
405
405
  }
406
406
  function ft(e, t, r) {
407
407
  if (e.container !== t.container) {
408
- p(e), h(t, document.body, null, r);
408
+ p(e), d(t, document.body, null, r);
409
409
  return;
410
410
  }
411
411
  F(e, t, r);
412
412
  }
413
- const ht = (e) => e.isProvider, dt = (e) => e.isConsumer;
413
+ const dt = (e) => e.isProvider, ht = (e) => e.isConsumer;
414
414
  class T {
415
415
  isMounted = !1;
416
416
  vdom = null;
@@ -437,7 +437,7 @@ class T {
437
437
  r !== -1 && (this.dependencies.splice(r, 1), t.subscribedProvider = null);
438
438
  }
439
439
  notify() {
440
- d(() => {
440
+ h(() => {
441
441
  this.dependencies.forEach(({ consumer: t }) => {
442
442
  t.isMounted && t.updateContext() && t.patch(t.props, t.state);
443
443
  });
@@ -475,7 +475,7 @@ class T {
475
475
  }
476
476
  updateProps(t) {
477
477
  const n = { ...this.getDefaultProps(), ...this.props, ...t }, o = this.props;
478
- this.props = n, !this.shouldComponentUpdate(o, n) && (ht(this) && this.notify(), this.patch(o, this.state));
478
+ this.props = n, !this.shouldComponentUpdate(o, n) && (dt(this) && this.notify(), this.patch(o, this.state));
479
479
  }
480
480
  setState(t) {
481
481
  const r = this.state;
@@ -487,24 +487,24 @@ class T {
487
487
  mount(t, r = null) {
488
488
  if (this.isMounted)
489
489
  throw new Error("Component is already mounted");
490
- dt(this) && !this.subscribedProvider && this.subscribeToProvider(), this.updateContext();
490
+ ht(this) && !this.subscribedProvider && this.subscribeToProvider(), this.updateContext();
491
491
  try {
492
- this.vdom = this.render(), this.hostEl = t, h(this.vdom, t, r, this), this.isMounted = !0;
492
+ this.vdom = this.render(), this.hostEl = t, d(this.vdom, t, r, this), this.isMounted = !0;
493
493
  } catch (n) {
494
494
  this.handleError(n, "mount");
495
495
  }
496
496
  }
497
497
  unmount() {
498
- this.isMounted && (d(() => this.willUnmount()), this.subscribedProvider && this.subscribedProvider.removeDependency({ consumer: this }), this.dependencies.forEach(({ consumer: t }) => {
498
+ this.isMounted && (h(() => this.willUnmount()), this.subscribedProvider && this.subscribedProvider.removeDependency({ consumer: this }), this.dependencies.forEach(({ consumer: t }) => {
499
499
  t.subscribedProvider = null;
500
- }), this.dependencies = [], this.vdom && p(this.vdom), d(() => this.didUnmount()), this.vdom = null, this.hostEl = null, this.isMounted = !1, this.error = null);
500
+ }), this.dependencies = [], this.vdom && p(this.vdom), h(() => this.didUnmount()), this.vdom = null, this.hostEl = null, this.isMounted = !1, this.error = null);
501
501
  }
502
502
  patch(t, r) {
503
503
  if (!(!this.isMounted || !this.hostEl || !this.vdom) && !this.error) {
504
- d(() => this.willUpdate(this.props, this.state));
504
+ h(() => this.willUpdate(this.props, this.state));
505
505
  try {
506
506
  const n = this.render();
507
- this.vdom = y(this.vdom, n, this.hostEl, this), d(() => this.didUpdate(t, r));
507
+ this.vdom = g(this.vdom, n, this.hostEl, this), h(() => this.didUpdate(t, r));
508
508
  } catch (n) {
509
509
  this.handleError(n, "patch");
510
510
  }
@@ -550,24 +550,24 @@ class T {
550
550
  const s = i.getDerivedStateFromError(t);
551
551
  n.state = { ...n.state, ...s };
552
552
  }
553
- if ((r === "patch" || n.isMounted) && (console.log("Calling componentDidCatch"), n.didCatch(t, {
554
- phase: r,
555
- failedComponent: this.constructor.name,
556
- componentStack: this.getComponentStack()
557
- })), n.hostEl) {
553
+ if (n.hostEl) {
558
554
  console.log("Rendering fallback UI");
559
555
  try {
560
556
  const s = n.render();
561
- if (s)
562
- if (n.vdom)
563
- console.log("Patching ErrorBoundary"), y(n.vdom, s, n.hostEl, n);
564
- else {
565
- console.log("Mounting ErrorBoundary fallback");
566
- const u = n.parent?.offset || 0;
567
- n.hostEl && n.hostEl.children.length > 0 && Array.from(n.hostEl.children).forEach((a) => {
568
- a.remove();
569
- }), h(s, n.hostEl, u, 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;
570
562
  }
563
+ h(() => {
564
+ n.didCatch(t, {
565
+ phase: r,
566
+ failedComponent: this.constructor.name,
567
+ componentStack: this.getComponentStack()
568
+ }), n.didMount();
569
+ });
570
+ }
571
571
  } catch (s) {
572
572
  console.error("Error during ErrorBoundary recovery:", s), n.parent && n.parent.handleError(s, r);
573
573
  }
@@ -580,14 +580,14 @@ class T {
580
580
  const i = o.getDerivedStateFromError(t);
581
581
  this.state = { ...this.state, ...i };
582
582
  }
583
- d(() => {
583
+ h(() => {
584
584
  if (this.didCatch(t, {
585
585
  phase: r,
586
586
  componentStack: this.getComponentStack()
587
587
  }), this.hostEl && this.isMounted)
588
588
  try {
589
589
  const i = this.render();
590
- i && y(this.vdom, i, this.hostEl, this);
590
+ i && g(this.vdom, i, this.hostEl, this);
591
591
  } catch (i) {
592
592
  console.error("Error during error recovery render:", i);
593
593
  }
@@ -618,7 +618,7 @@ function yt(e) {
618
618
  isProvider = !0;
619
619
  render() {
620
620
  let o = [];
621
- 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);
622
622
  }
623
623
  }
624
624
  class r extends T {
@@ -650,7 +650,7 @@ function yt(e) {
650
650
  function Et(e, t) {
651
651
  if (!t)
652
652
  throw new Error("Container element is not provided for rendering.");
653
- h(e, t);
653
+ d(e, t);
654
654
  }
655
655
  function gt(e = null) {
656
656
  return {
@@ -659,7 +659,7 @@ function gt(e = null) {
659
659
  }
660
660
  function vt(e, t) {
661
661
  const r = Array.isArray(e) ? e : [e];
662
- return U(r, t);
662
+ return B(r, t);
663
663
  }
664
664
  export {
665
665
  T as Component,
@@ -667,7 +667,7 @@ export {
667
667
  vt as createPortal,
668
668
  gt as createRef,
669
669
  Pt as h,
670
- B as hFragment,
670
+ U as hFragment,
671
671
  Ot as hString,
672
672
  Et as render
673
673
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ddd-react",
3
- "version": "1.10.6",
3
+ "version": "1.10.7",
4
4
  "scripts": {
5
5
  "test": "echo \"Error: no test specified\" && exit 1",
6
6
  "type-check": "tsc --noEmit",