ddd-react 1.10.6 → 1.10.8

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