ddd-react 1.10.13 → 1.10.15

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 -99
  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 U, c as B } from "./h-BbaMkkC7.mjs";
1
+ import { D as u, 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
3
  function b(e, t) {
4
4
  if (e === null || t === null || e === void 0 || t === void 0)
@@ -65,23 +65,23 @@ function $(e = {}, t) {
65
65
  function p(e) {
66
66
  const { type: t } = e;
67
67
  switch (t) {
68
- case c.TEXT: {
68
+ case u.TEXT: {
69
69
  q(e);
70
70
  break;
71
71
  }
72
- case c.ELEMENT: {
72
+ case u.ELEMENT: {
73
73
  G(e);
74
74
  break;
75
75
  }
76
- case c.FRAGMENT: {
76
+ case u.FRAGMENT: {
77
77
  _(e);
78
78
  break;
79
79
  }
80
- case c.COMPONENT: {
80
+ case u.COMPONENT: {
81
81
  e.component?.unmount();
82
82
  break;
83
83
  }
84
- case c.PORTAL: {
84
+ case u.PORTAL: {
85
85
  X(e);
86
86
  break;
87
87
  }
@@ -161,31 +161,31 @@ function H() {
161
161
  }
162
162
  P = !1;
163
163
  }
164
- function C(e) {
164
+ function A(e) {
165
165
  const { on: t = {}, ...r } = e.props;
166
166
  return delete r.key, { props: r, events: t };
167
167
  }
168
168
  function d(e, t, r = null, n = null) {
169
169
  switch (e.type) {
170
- case c.TEXT: {
170
+ case u.TEXT: {
171
171
  z(e, t, r);
172
172
  break;
173
173
  }
174
- case c.ELEMENT: {
174
+ case u.ELEMENT: {
175
175
  Z(e, t, r, n);
176
176
  break;
177
177
  }
178
- case c.FRAGMENT: {
178
+ case u.FRAGMENT: {
179
179
  Q(e, t, r, n);
180
180
  break;
181
181
  }
182
- case c.COMPONENT: {
182
+ case u.COMPONENT: {
183
183
  tt(e, t, r, n);
184
184
  const s = e.component;
185
185
  s && h(() => s.didMount());
186
186
  break;
187
187
  }
188
- case c.PORTAL: {
188
+ case u.PORTAL: {
189
189
  et(e, n);
190
190
  break;
191
191
  }
@@ -195,7 +195,7 @@ function d(e, t, r = null, n = null) {
195
195
  }
196
196
  function z(e, t, r) {
197
197
  const { value: n } = e, s = document.createTextNode(n);
198
- e.el = s, L(s, t, r);
198
+ e.el = s, j(s, t, r);
199
199
  }
200
200
  function Q(e, t, r, n) {
201
201
  const { children: s } = e;
@@ -204,20 +204,20 @@ 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, 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
- d(a, l, null, n);
210
- }), L(l, t, r);
207
+ const { tag: s, children: i } = e, f = s === "svg" || t instanceof SVGElement ? document.createElementNS("http://www.w3.org/2000/svg", s) : document.createElement(s);
208
+ V(f, e, n), e.el = f, i?.forEach((a) => {
209
+ d(a, f, null, n);
210
+ }), j(f, t, r);
211
211
  }
212
212
  function V(e, t, r) {
213
- const { props: n, events: s } = C(t);
213
+ const { props: n, events: s } = A(t);
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: i } = C(e), o = new s(i, n);
217
+ const s = e.tag, { props: i } = A(e), o = new s(i, n);
218
218
  o.mount(t, r), e.component = o, e.el = o.firstElement || null;
219
219
  }
220
- function L(e, t, r) {
220
+ function j(e, t, r) {
221
221
  if (r == null) {
222
222
  t.append(e);
223
223
  return;
@@ -233,30 +233,30 @@ function et(e, t) {
233
233
  d(s, n, null, t);
234
234
  });
235
235
  }
236
- function j(e, t) {
236
+ function L(e, t) {
237
237
  if (e.type !== t.type)
238
238
  return !1;
239
- if (e.type === c.ELEMENT) {
239
+ if (e.type === u.ELEMENT) {
240
240
  const r = e, n = t, {
241
241
  tag: s,
242
242
  props: { key: i }
243
243
  } = r, {
244
244
  tag: o,
245
- props: { key: l }
245
+ props: { key: f }
246
246
  } = n;
247
- return s === o && i === l;
247
+ return s === o && i === f;
248
248
  }
249
- if (e.type === c.COMPONENT) {
249
+ if (e.type === u.COMPONENT) {
250
250
  const r = e, n = t, { tag: s } = r, { tag: i } = n;
251
251
  return s === i;
252
252
  }
253
- if (e.type === c.PORTAL) {
253
+ if (e.type === u.PORTAL) {
254
254
  const r = e, n = t;
255
255
  return r.container === n.container;
256
256
  }
257
257
  return !0;
258
258
  }
259
- function A(e, t) {
259
+ function S(e, t) {
260
260
  const r = Object.keys(e), n = Object.keys(t), s = [], i = [];
261
261
  for (const o of n)
262
262
  o in e ? e[o] !== t[o] && i.push(o) : s.push(o);
@@ -269,31 +269,31 @@ function A(e, t) {
269
269
  function rt(e) {
270
270
  return e !== "";
271
271
  }
272
- function S(e) {
272
+ function C(e) {
273
273
  return rt(e.trim());
274
274
  }
275
275
  function y(e, t, r, n = null) {
276
- if (!j(e, t)) {
276
+ if (!L(e, t)) {
277
277
  const s = nt(r, e.el);
278
278
  return p(e), d(t, r, s, n), t;
279
279
  }
280
280
  switch (t.el = e.el, t.type) {
281
- case c.TEXT:
281
+ case u.TEXT:
282
282
  return st(e, t), t;
283
- case c.ELEMENT: {
283
+ case u.ELEMENT: {
284
284
  ot(e, t, n);
285
285
  break;
286
286
  }
287
- case c.COMPONENT: {
288
- at(e, t);
287
+ case u.COMPONENT: {
288
+ ft(e, t);
289
289
  break;
290
290
  }
291
- case c.PORTAL: {
292
- ft(e, t, n);
291
+ case u.PORTAL: {
292
+ lt(e, t, n);
293
293
  break;
294
294
  }
295
295
  }
296
- return F(e, t, n), t;
296
+ return R(e, t, n), t;
297
297
  }
298
298
  function nt(e, t) {
299
299
  if (!t) return null;
@@ -309,22 +309,22 @@ function ot(e, t, r) {
309
309
  class: s,
310
310
  style: i,
311
311
  on: o,
312
- ...l
312
+ ...f
313
313
  } = e.props ?? {}, {
314
314
  class: a,
315
- style: u,
316
- on: f,
315
+ style: c,
316
+ on: l,
317
317
  ...E
318
- } = t.props ?? {}, { listeners: v } = e;
319
- it(n, l, E), ct(n, s, a), ut(
318
+ } = t.props ?? {}, { listeners: g } = e;
319
+ it(n, f, E), ct(n, s, a), ut(
320
320
  n,
321
321
  i,
322
- u
323
- ), t.listeners = lt(
322
+ c
323
+ ), t.listeners = at(
324
324
  n,
325
- v,
325
+ g,
326
326
  o ?? {},
327
- f ?? {},
327
+ l ?? {},
328
328
  r
329
329
  );
330
330
  }
@@ -333,78 +333,77 @@ 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: l, removed: a, updated: u } = A(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]);
336
+ const { added: f, removed: a, updated: c } = S(i, o);
337
+ for (const l of a)
338
+ D(e, l);
339
+ for (const l of f.concat(c))
340
+ w(e, l, o[l]);
341
341
  }
342
342
  function ct(e, t, r) {
343
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
346
  function T(e = "") {
347
- return Array.isArray(e) ? e.filter(S) : String(e).split(/(\s+)/).filter(S);
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: i } = A(t, r);
350
+ const { added: n, removed: s, updated: i } = S(t, r);
351
351
  for (const o of s)
352
352
  J(e, o);
353
353
  for (const o of n.concat(i))
354
354
  M(e, o, r[o]);
355
355
  }
356
- function lt(e, t = {}, r = {}, n = {}, s = null) {
357
- const { removed: i, added: o, updated: l } = A(r, n);
358
- for (const u of i.concat(l)) {
359
- const f = t?.[u];
360
- f && e.removeEventListener(u, f);
361
- }
362
- const a = {};
363
- for (const u of o.concat(l))
364
- a[u] = N(
365
- u,
366
- n[u],
356
+ function at(e, t = {}, r = {}, n = {}, s = null) {
357
+ const { removed: i, added: o, updated: f } = S(r, n), a = { ...t };
358
+ for (const c of i.concat(f)) {
359
+ const l = t?.[c];
360
+ l && (e.removeEventListener(c, l), delete a[c]);
361
+ }
362
+ for (const c of o.concat(f))
363
+ a[c] = N(
364
+ c,
365
+ n[c],
367
366
  e,
368
367
  s
369
368
  );
370
369
  return a;
371
370
  }
372
- function F(e, t, r) {
373
- const n = m(e), s = m(t), i = e.el, o = R(n, s, j), l = r?.offset ?? 0;
371
+ function R(e, t, r) {
372
+ const n = m(e), s = m(t), i = e.el, o = F(n, s, L), f = r?.offset ?? 0;
374
373
  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);
374
+ if (a.op === v.NOOP) {
375
+ const { originalIndex: c, index: l } = a;
376
+ y(n[c], s[l], i, r);
378
377
  }
379
378
  for (const a of o)
380
379
  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));
380
+ case v.MOVE: {
381
+ const { from: c, index: l } = a, E = n[c].el, g = i.childNodes[l + f];
382
+ E && (i.insertBefore(E, g), y(n[c], s[l], i, r));
384
383
  break;
385
384
  }
386
- case g.REMOVE: {
387
- const { item: u } = a;
388
- p(u);
385
+ case v.REMOVE: {
386
+ const { item: c } = a;
387
+ p(c);
389
388
  break;
390
389
  }
391
- case g.ADD: {
392
- const { index: u, item: f } = a;
393
- d(f, i, u + l, r);
390
+ case v.ADD: {
391
+ const { index: c, item: l } = a;
392
+ d(l, i, c + f, r);
394
393
  break;
395
394
  }
396
395
  }
397
396
  }
398
- function at(e, t) {
399
- const { component: r } = e, { props: n } = C(t);
397
+ function ft(e, t) {
398
+ const { component: r } = e, { props: n } = A(t);
400
399
  r.updateProps(n), t.component = r, t.el = r.firstElement;
401
400
  }
402
- function ft(e, t, r) {
401
+ function lt(e, t, r) {
403
402
  if (e.container !== t.container) {
404
403
  p(e), d(t, document.body, null, r);
405
404
  return;
406
405
  }
407
- F(e, t, r);
406
+ R(e, t, r);
408
407
  }
409
408
  const ht = (e) => e.isProvider, dt = (e) => e.isConsumer;
410
409
  class k {
@@ -461,13 +460,13 @@ class k {
461
460
  return b(t, r);
462
461
  }
463
462
  get elements() {
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] : [];
463
+ return this.vdom == null ? [] : this.vdom.type === u.FRAGMENT ? m(this.vdom).flatMap((t) => t.type === u.COMPONENT && t.component ? t.component.elements : t.el ? [t.el] : []) : this.vdom.el ? [this.vdom.el] : [];
465
464
  }
466
465
  get firstElement() {
467
466
  return this.elements[0];
468
467
  }
469
468
  get offset() {
470
- return this.vdom?.type === c.FRAGMENT && this.hostEl && this.firstElement ? Array.from(this.hostEl.children).indexOf(this.firstElement) : 0;
469
+ return this.vdom?.type === u.FRAGMENT && this.hostEl && this.firstElement ? Array.from(this.hostEl.children).indexOf(this.firstElement) : 0;
471
470
  }
472
471
  updateProps(t) {
473
472
  const n = { ...this.getDefaultProps(), ...this.props, ...t }, s = this.props;
@@ -496,7 +495,7 @@ class k {
496
495
  }), this.dependencies = [], this.vdom && p(this.vdom), h(() => this.didUnmount()), this.vdom = null, this.hostEl = null, this.isMounted = !1, this.error = null);
497
496
  }
498
497
  patch(t, r) {
499
- if (!(!this.isMounted || !this.hostEl || !this.vdom) && !this.error) {
498
+ if (!(!this.isMounted || !this.hostEl || !this.vdom)) {
500
499
  h(() => this.willUpdate(this.props, this.state));
501
500
  try {
502
501
  const n = this.render();
@@ -536,20 +535,14 @@ class k {
536
535
  return this.constructor.defaultProps || {};
537
536
  }
538
537
  handleError(t, r) {
539
- console.log("handleError");
540
538
  const n = this.findClosestErrorBoundary();
541
- if (console.log("errorBoundary", n), n) {
542
- console.log("Found error boundary");
539
+ if (n) {
543
540
  const i = n.constructor;
544
541
  if (i.getDerivedStateFromError) {
545
- console.log("Calling getDerivedStateFromError");
546
542
  const o = i.getDerivedStateFromError(t);
547
543
  n.state = { ...n.state, ...o };
548
544
  }
549
- for (; n.hostEl.firstChild; )
550
- n.hostEl.removeChild(n.hostEl.firstChild);
551
- if (n.hostEl && n.isMounted) {
552
- console.log("Rendering fallback UI");
545
+ if (n.hostEl && n.isMounted)
553
546
  try {
554
547
  const o = n.render();
555
548
  o && (n.vdom = y(n.vdom, o, n.hostEl, n), h(() => {
@@ -560,12 +553,10 @@ class k {
560
553
  });
561
554
  }));
562
555
  } catch (o) {
563
- console.error("Error during ErrorBoundary recovery:", o), n.parent && n.parent.handleError(o, r);
556
+ n.parent && n.parent.handleError(o, r);
564
557
  }
565
- }
566
558
  return;
567
559
  }
568
- console.log("No error boundary found, handling locally");
569
560
  const s = this.constructor;
570
561
  if (s.getDerivedStateFromError) {
571
562
  const i = s.getDerivedStateFromError(t);
@@ -643,20 +634,20 @@ function Et(e, t) {
643
634
  throw new Error("Container element is not provided for rendering.");
644
635
  d(e, t);
645
636
  }
646
- function gt(e = null) {
637
+ function vt(e = null) {
647
638
  return {
648
639
  current: e
649
640
  };
650
641
  }
651
- function vt(e, t) {
642
+ function gt(e, t) {
652
643
  const r = Array.isArray(e) ? e : [e];
653
644
  return B(r, t);
654
645
  }
655
646
  export {
656
647
  k as Component,
657
648
  yt as createContext,
658
- vt as createPortal,
659
- gt as createRef,
649
+ gt as createPortal,
650
+ vt as createRef,
660
651
  Pt as h,
661
652
  U as hFragment,
662
653
  Ot as hString,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ddd-react",
3
- "version": "1.10.13",
3
+ "version": "1.10.15",
4
4
  "scripts": {
5
5
  "test": "echo \"Error: no test specified\" && exit 1",
6
6
  "type-check": "tsc --noEmit",