ddd-react 1.3.0 → 1.3.1

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.
package/dist/index.d.ts CHANGED
@@ -6,7 +6,5 @@ import { createRef } from './ref';
6
6
  import type { Ref } from './ref';
7
7
  import type { ComponentType } from './types/types';
8
8
  import { createPortal } from './portal';
9
- import { jsx } from "./jsx/jsx-runtime";
10
- import { jsxDEV } from "./jsx/jsx-dev-runtime";
11
9
  export type { ComponentType, Ref };
12
- export { Component, createContext, createRef, h, hFragment, hString, render, createPortal, jsx, jsxDEV };
10
+ export { Component, createContext, createRef, h, hFragment, hString, render, createPortal };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- function O(e, t) {
1
+ function v(e, t) {
2
2
  if (e === null || t === null || e === void 0 || t === void 0)
3
3
  return e === t;
4
4
  if (typeof e != typeof t)
@@ -12,7 +12,7 @@ function O(e, t) {
12
12
  if (e.length !== t.length)
13
13
  return !1;
14
14
  for (let r = 0; r < e.length; ++r)
15
- if (!O(e[r], t[r]))
15
+ if (!v(e[r], t[r]))
16
16
  return !1;
17
17
  return !0;
18
18
  }
@@ -30,7 +30,7 @@ function O(e, t) {
30
30
  return !1;
31
31
  for (let r = 0; r < n.length; ++r) {
32
32
  const s = n[r];
33
- if (!(s === "_owner" && e.$$typeof) && !O(e[s], t[s]))
33
+ if (!(s === "_owner" && e.$$typeof) && !v(e[s], t[s]))
34
34
  return !1;
35
35
  }
36
36
  return !0;
@@ -38,24 +38,24 @@ function O(e, t) {
38
38
  return !1;
39
39
  }
40
40
  function R(e, t, n, r = null) {
41
- function s(o) {
42
- const i = o;
43
- r ? t.call(r, i) : t(i);
41
+ function s(i) {
42
+ const o = i;
43
+ r ? t.call(r, o) : t(o);
44
44
  }
45
45
  return n.addEventListener(e, s), s;
46
46
  }
47
- function W(e = {}, t, n = null) {
47
+ function F(e = {}, t, n = null) {
48
48
  const r = {};
49
- return Object.entries(e).forEach(([s, o]) => {
49
+ return Object.entries(e).forEach(([s, i]) => {
50
50
  r[s] = R(
51
51
  s,
52
- o,
52
+ i,
53
53
  t,
54
54
  n
55
55
  );
56
56
  }), r;
57
57
  }
58
- function $(e = {}, t) {
58
+ function G(e = {}, t) {
59
59
  Object.entries(e).forEach(([n, r]) => {
60
60
  t.removeEventListener(n, r);
61
61
  });
@@ -65,7 +65,7 @@ const h = {
65
65
  REMOVE: "remove",
66
66
  MOVE: "move",
67
67
  NOOP: "noop"
68
- }, f = {
68
+ }, c = {
69
69
  TEXT: "text",
70
70
  ELEMENT: "element",
71
71
  FRAGMENT: "fragment",
@@ -75,24 +75,24 @@ const h = {
75
75
  function d(e) {
76
76
  const { type: t } = e;
77
77
  switch (t) {
78
- case f.TEXT: {
79
- B(e);
78
+ case c.TEXT: {
79
+ q(e);
80
80
  break;
81
81
  }
82
- case f.ELEMENT: {
83
- X(e);
82
+ case c.ELEMENT: {
83
+ U(e);
84
84
  break;
85
85
  }
86
- case f.FRAGMENT: {
87
- _(e);
86
+ case c.FRAGMENT: {
87
+ $(e);
88
88
  break;
89
89
  }
90
- case f.COMPONENT: {
90
+ case c.COMPONENT: {
91
91
  e.component?.unmount();
92
92
  break;
93
93
  }
94
- case f.PORTAL: {
95
- z(e);
94
+ case c.PORTAL: {
95
+ W(e);
96
96
  break;
97
97
  }
98
98
  default:
@@ -100,32 +100,32 @@ function d(e) {
100
100
  }
101
101
  delete e.el;
102
102
  }
103
- function B(e) {
103
+ function q(e) {
104
104
  const { el: t } = e;
105
105
  t && t.remove();
106
106
  }
107
- function X(e) {
107
+ function U(e) {
108
108
  const { el: t, children: n, listeners: r, props: s } = e;
109
- s?.ref && typeof s.ref == "object" && "current" in s.ref && (s.ref.current = null), t && t.remove(), n && n.forEach(d), r && t && ($(r, t), delete e.listeners);
109
+ s?.ref && typeof s.ref == "object" && "current" in s.ref && (s.ref.current = null), t && t.remove(), n && n.forEach(d), r && t && (G(r, t), delete e.listeners);
110
110
  }
111
- function _(e) {
111
+ function $(e) {
112
112
  const { children: t } = e;
113
113
  t && t.forEach(d);
114
114
  }
115
- function z(e) {
115
+ function W(e) {
116
116
  const { children: t } = e;
117
117
  t && t.forEach(d);
118
118
  }
119
- function T(e) {
119
+ function N(e) {
120
120
  return e.filter((t) => t != null);
121
121
  }
122
- function J(e, t) {
122
+ function X(e, t) {
123
123
  return {
124
124
  added: t.filter((n) => !e.includes(n)),
125
125
  removed: e.filter((n) => !t.includes(n))
126
126
  };
127
127
  }
128
- class K {
128
+ class _ {
129
129
  #t = [];
130
130
  #e = [];
131
131
  #n;
@@ -146,7 +146,7 @@ class K {
146
146
  return !1;
147
147
  const r = this.#t[t];
148
148
  return n.findIndex(
149
- (o) => this.#n(r, o)
149
+ (i) => this.#n(r, i)
150
150
  ) === -1;
151
151
  }
152
152
  findIndexFrom(t, n) {
@@ -195,115 +195,115 @@ class K {
195
195
  from: r,
196
196
  index: n,
197
197
  item: this.#t[r]
198
- }, [o] = this.#t.splice(r, 1);
199
- this.#t.splice(n, 0, o);
200
- const [i] = this.#e.splice(r, 1);
201
- return this.#e.splice(n, 0, i), s;
198
+ }, [i] = this.#t.splice(r, 1);
199
+ this.#t.splice(n, 0, i);
200
+ const [o] = this.#e.splice(r, 1);
201
+ return this.#e.splice(n, 0, o), s;
202
202
  }
203
203
  get length() {
204
204
  return this.#t.length;
205
205
  }
206
206
  }
207
- function Y(e, t, n = (r, s) => r === s) {
208
- const r = [], s = new K(e, n);
209
- for (let o = 0; o < t.length; o++) {
210
- if (s.isRemoval(o, t)) {
211
- r.push(s.removeItem(o)), o--;
207
+ function B(e, t, n = (r, s) => r === s) {
208
+ const r = [], s = new _(e, n);
209
+ for (let i = 0; i < t.length; i++) {
210
+ if (s.isRemoval(i, t)) {
211
+ r.push(s.removeItem(i)), i--;
212
212
  continue;
213
213
  }
214
- if (s.isNoop(o, t)) {
215
- r.push(s.noopItem(o));
214
+ if (s.isNoop(i, t)) {
215
+ r.push(s.noopItem(i));
216
216
  continue;
217
217
  }
218
- const i = t[o];
219
- if (s.isAddition(i, o)) {
220
- r.push(s.addItem(i, o));
218
+ const o = t[i];
219
+ if (s.isAddition(o, i)) {
220
+ r.push(s.addItem(o, i));
221
221
  continue;
222
222
  }
223
- r.push(s.moveItem(i, o));
223
+ r.push(s.moveItem(o, i));
224
224
  }
225
225
  return r.push(...s.removeItemsAfter(t.length)), r;
226
226
  }
227
- function w(e, t = {}, n = []) {
228
- const r = typeof e == "string" ? f.ELEMENT : f.COMPONENT;
227
+ function mt(e, t = {}, n = []) {
228
+ const r = typeof e == "string" ? c.ELEMENT : c.COMPONENT;
229
229
  return {
230
230
  tag: e,
231
231
  props: t,
232
232
  type: r,
233
- children: A(T(n))
233
+ children: T(N(n))
234
234
  };
235
235
  }
236
- function S(e) {
236
+ function J(e) {
237
237
  return {
238
- type: f.TEXT,
238
+ type: c.TEXT,
239
239
  value: e,
240
240
  props: {}
241
241
  };
242
242
  }
243
- function D(e) {
243
+ function K(e) {
244
244
  return {
245
- type: f.FRAGMENT,
246
- children: A(T(e)),
245
+ type: c.FRAGMENT,
246
+ children: T(N(e)),
247
247
  props: {}
248
248
  };
249
249
  }
250
- function H(e, t) {
250
+ function Y(e, t) {
251
251
  return {
252
- type: f.PORTAL,
253
- children: A(T(e)),
252
+ type: c.PORTAL,
253
+ children: T(N(e)),
254
254
  props: {},
255
255
  container: t
256
256
  };
257
257
  }
258
- function A(e) {
259
- return e.map((t) => typeof t == "string" ? S(t) : t);
258
+ function T(e) {
259
+ return e.map((t) => typeof t == "string" ? J(t) : t);
260
260
  }
261
- function y(e) {
261
+ function g(e) {
262
262
  if (!e.children)
263
263
  return [];
264
264
  const t = [];
265
265
  for (const n of e.children)
266
- n.type === f.FRAGMENT ? t.push(...y(n)) : t.push(n);
266
+ n.type === c.FRAGMENT ? t.push(...g(n)) : t.push(n);
267
267
  return t;
268
268
  }
269
- function x(e, t, n) {
269
+ function S(e, t, n) {
270
270
  e.style[t] = n.toString();
271
271
  }
272
- function Q(e, t) {
272
+ function H(e, t) {
273
273
  e.style[t] = null;
274
274
  }
275
- function Z(e, t) {
275
+ function z(e, t) {
276
276
  const { class: n, style: r, ...s } = t;
277
- n && V(e, n), r && Object.entries(r).forEach(([o, i]) => {
278
- x(e, o, i);
277
+ n && Q(e, n), r && Object.entries(r).forEach(([i, o]) => {
278
+ S(e, i, o);
279
279
  });
280
- for (const [o, i] of Object.entries(s))
281
- F(e, o, i);
280
+ for (const [i, o] of Object.entries(s))
281
+ C(e, i, o);
282
282
  }
283
- function V(e, t) {
283
+ function Q(e, t) {
284
284
  if (e instanceof SVGElement) {
285
285
  e.removeAttribute("class"), typeof t == "string" ? e.setAttribute("class", t) : Array.isArray(t) && e.classList.add(...t);
286
286
  return;
287
287
  }
288
288
  e.className = "", typeof t == "string" ? e.className = t : Array.isArray(t) && e.classList.add(...t);
289
289
  }
290
- function F(e, t, n) {
291
- n == null ? k(e, t) : e.setAttribute(t, String(n));
290
+ function C(e, t, n) {
291
+ n == null ? w(e, t) : e.setAttribute(t, String(n));
292
292
  }
293
- function k(e, t) {
293
+ function w(e, t) {
294
294
  e[t] = null, e.removeAttribute(t);
295
295
  }
296
- let v = !1;
297
- const N = [];
298
- function E(e) {
299
- N.push(e), tt();
296
+ let b = !1;
297
+ const O = [];
298
+ function y(e) {
299
+ O.push(e), Z();
300
300
  }
301
- function tt() {
302
- v || (v = !0, queueMicrotask(et));
301
+ function Z() {
302
+ b || (b = !0, queueMicrotask(V));
303
303
  }
304
- function et() {
305
- for (; N.length > 0; ) {
306
- const e = N.shift();
304
+ function V() {
305
+ for (; O.length > 0; ) {
306
+ const e = O.shift();
307
307
  let t;
308
308
  try {
309
309
  t = e();
@@ -319,65 +319,65 @@ function et() {
319
319
  }
320
320
  );
321
321
  }
322
- v = !1;
322
+ b = !1;
323
323
  }
324
- function M(e) {
324
+ function A(e) {
325
325
  const { on: t = {}, ...n } = e.props;
326
326
  return delete n.key, { props: n, events: t };
327
327
  }
328
328
  function p(e, t, n = null, r = null) {
329
329
  switch (e.type) {
330
- case f.TEXT: {
331
- nt(e, t, n);
330
+ case c.TEXT: {
331
+ tt(e, t, n);
332
332
  break;
333
333
  }
334
- case f.ELEMENT: {
335
- st(e, t, n, r);
334
+ case c.ELEMENT: {
335
+ nt(e, t, n, r);
336
336
  break;
337
337
  }
338
- case f.FRAGMENT: {
339
- rt(e, t, n, r);
338
+ case c.FRAGMENT: {
339
+ et(e, t, n, r);
340
340
  break;
341
341
  }
342
- case f.COMPONENT: {
343
- ot(e, t, n, r);
342
+ case c.COMPONENT: {
343
+ st(e, t, n, r);
344
344
  const s = e.component;
345
- s && E(() => s.onMount());
345
+ s && y(() => s.onMount());
346
346
  break;
347
347
  }
348
- case f.PORTAL: {
349
- ct(e, r);
348
+ case c.PORTAL: {
349
+ it(e, r);
350
350
  break;
351
351
  }
352
352
  default:
353
353
  throw new Error(`Can't mount DOM of type: ${e.type}`);
354
354
  }
355
355
  }
356
- function nt(e, t, n) {
356
+ function tt(e, t, n) {
357
357
  const { value: r } = e, s = document.createTextNode(r);
358
- e.el = s, U(s, t, n);
358
+ e.el = s, j(s, t, n);
359
359
  }
360
- function rt(e, t, n, r) {
360
+ function et(e, t, n, r) {
361
361
  const { children: s } = e;
362
- e.el = t, s?.forEach((o, i) => {
363
- p(o, t, n != null ? n + i : null, r);
362
+ e.el = t, s?.forEach((i, o) => {
363
+ p(i, t, n != null ? n + o : null, r);
364
364
  });
365
365
  }
366
- function st(e, t, n, r) {
367
- const { tag: s, children: o } = e, c = s === "svg" || t instanceof SVGElement ? document.createElementNS("http://www.w3.org/2000/svg", s) : document.createElement(s);
368
- it(c, e, r), e.el = c, o?.forEach((l) => {
369
- p(l, c, null, r);
370
- }), U(c, t, n);
366
+ function nt(e, t, n, r) {
367
+ const { tag: s, children: i } = e, f = s === "svg" || t instanceof SVGElement ? document.createElementNS("http://www.w3.org/2000/svg", s) : document.createElement(s);
368
+ rt(f, e, r), e.el = f, i?.forEach((l) => {
369
+ p(l, f, null, r);
370
+ }), j(f, t, n);
371
371
  }
372
- function it(e, t, n) {
373
- const { props: r, events: s } = M(t);
374
- r.ref && typeof r.ref == "object" && "current" in r.ref && (r.ref.current = e, delete r.ref), t.listeners = W(s, e, n), Z(e, r);
372
+ function rt(e, t, n) {
373
+ const { props: r, events: s } = A(t);
374
+ r.ref && typeof r.ref == "object" && "current" in r.ref && (r.ref.current = e, delete r.ref), t.listeners = F(s, e, n), z(e, r);
375
375
  }
376
- function ot(e, t, n, r) {
377
- const s = e.tag, { props: o } = M(e), i = new s(o, r);
378
- i.mount(t, n), e.component = i, e.el = i.firstElement || null;
376
+ function st(e, t, n, r) {
377
+ const s = e.tag, { props: i } = A(e), o = new s(i, r);
378
+ o.mount(t, n), e.component = o, e.el = o.firstElement || null;
379
379
  }
380
- function U(e, t, n) {
380
+ function j(e, t, n) {
381
381
  if (n == null) {
382
382
  t.append(e);
383
383
  return;
@@ -387,75 +387,75 @@ function U(e, t, n) {
387
387
  const r = t.childNodes;
388
388
  n >= r.length ? t.append(e) : t.insertBefore(e, r[n]);
389
389
  }
390
- function ct(e, t) {
390
+ function it(e, t) {
391
391
  const { children: n, container: r } = e;
392
392
  n?.forEach((s) => {
393
393
  p(s, r, null, t);
394
394
  });
395
395
  }
396
- function G(e, t) {
396
+ function D(e, t) {
397
397
  if (e.type !== t.type)
398
398
  return !1;
399
- if (e.type === f.ELEMENT) {
399
+ if (e.type === c.ELEMENT) {
400
400
  const n = e, r = t, {
401
401
  tag: s,
402
- props: { key: o }
402
+ props: { key: i }
403
403
  } = n, {
404
- tag: i,
405
- props: { key: c }
404
+ tag: o,
405
+ props: { key: f }
406
406
  } = r;
407
- return s === i && o === c;
407
+ return s === o && i === f;
408
408
  }
409
- if (e.type === f.COMPONENT) {
410
- const n = e, r = t, { tag: s } = n, { tag: o } = r;
411
- return s === o;
409
+ if (e.type === c.COMPONENT) {
410
+ const n = e, r = t, { tag: s } = n, { tag: i } = r;
411
+ return s === i;
412
412
  }
413
- if (e.type === f.PORTAL) {
413
+ if (e.type === c.PORTAL) {
414
414
  const n = e, r = t;
415
415
  return n.container === r.container;
416
416
  }
417
417
  return !0;
418
418
  }
419
- function I(e, t) {
420
- const n = Object.keys(e), r = Object.keys(t), s = [], o = [];
421
- for (const i of r)
422
- i in e ? e[i] !== t[i] && o.push(i) : s.push(i);
419
+ function M(e, t) {
420
+ const n = Object.keys(e), r = Object.keys(t), s = [], i = [];
421
+ for (const o of r)
422
+ o in e ? e[o] !== t[o] && i.push(o) : s.push(o);
423
423
  return {
424
424
  added: s,
425
- removed: n.filter((i) => !(i in t)),
426
- updated: o
425
+ removed: n.filter((o) => !(o in t)),
426
+ updated: i
427
427
  };
428
428
  }
429
- function ft(e) {
429
+ function ot(e) {
430
430
  return e !== "";
431
431
  }
432
- function C(e) {
433
- return ft(e.trim());
432
+ function k(e) {
433
+ return ot(e.trim());
434
434
  }
435
435
  function P(e, t, n, r = null) {
436
- if (!G(e, t)) {
437
- const s = lt(n, e.el);
436
+ if (!D(e, t)) {
437
+ const s = ct(n, e.el);
438
438
  return d(e), p(t, n, s, r), t;
439
439
  }
440
440
  switch (t.el = e.el, t.type) {
441
- case f.TEXT:
441
+ case c.TEXT:
442
442
  return ut(e, t), t;
443
- case f.ELEMENT: {
444
- at(e, t, r);
443
+ case c.ELEMENT: {
444
+ ft(e, t, r);
445
445
  break;
446
446
  }
447
- case f.COMPONENT: {
448
- Et(e, t);
447
+ case c.COMPONENT: {
448
+ dt(e, t);
449
449
  break;
450
450
  }
451
- case f.PORTAL: {
452
- yt(e, t, r);
451
+ case c.PORTAL: {
452
+ Et(e, t, r);
453
453
  break;
454
454
  }
455
455
  }
456
- return q(e, t, r), t;
456
+ return x(e, t, r), t;
457
457
  }
458
- function lt(e, t) {
458
+ function ct(e, t) {
459
459
  if (!t) return null;
460
460
  const n = Array.from(e.childNodes).indexOf(t);
461
461
  return n < 0 ? null : n;
@@ -464,63 +464,63 @@ function ut(e, t) {
464
464
  const n = e.el, { value: r } = e, { value: s } = t;
465
465
  r !== s && n && (n.nodeValue = s);
466
466
  }
467
- function at(e, t, n) {
467
+ function ft(e, t, n) {
468
468
  const r = e.el, {
469
469
  class: s,
470
- style: o,
471
- on: i,
472
- ...c
470
+ style: i,
471
+ on: o,
472
+ ...f
473
473
  } = e.props ?? {}, {
474
474
  class: l,
475
475
  style: u,
476
476
  on: a,
477
- ...m
478
- } = t.props ?? {}, { listeners: b } = e;
479
- ht(r, c, m), pt(r, s, l), dt(
477
+ ...E
478
+ } = t.props ?? {}, { listeners: m } = e;
479
+ lt(r, f, E), at(r, s, l), ht(
480
480
  r,
481
- o,
481
+ i,
482
482
  u
483
- ), t.listeners = mt(
483
+ ), t.listeners = pt(
484
484
  r,
485
- b,
486
- i ?? {},
485
+ m,
486
+ o ?? {},
487
487
  a ?? {},
488
488
  n
489
489
  );
490
490
  }
491
- function ht(e, t = {}, n = {}) {
491
+ function lt(e, t = {}, n = {}) {
492
492
  const r = t.ref, s = n.ref;
493
493
  r !== s && (r && typeof r == "object" && "current" in r && (r.current = null), s && typeof s == "object" && "current" in s && (s.current = e));
494
- const o = { ...t }, i = { ...n };
495
- delete o.ref, delete i.ref;
496
- const { added: c, removed: l, updated: u } = I(o, i);
494
+ const i = { ...t }, o = { ...n };
495
+ delete i.ref, delete o.ref;
496
+ const { added: f, removed: l, updated: u } = M(i, o);
497
497
  for (const a of l)
498
- k(e, a);
499
- for (const a of c.concat(u))
500
- F(e, a, i[a]);
501
- }
502
- function pt(e, t, n) {
503
- const r = L(t), s = L(n), { added: o, removed: i } = J(r, s);
504
- i.length > 0 && e.classList.remove(...i), o.length > 0 && e.classList.add(...o);
505
- }
506
- function L(e = "") {
507
- return Array.isArray(e) ? e.filter(C) : String(e).split(/(\s+)/).filter(C);
508
- }
509
- function dt(e, t = {}, n = {}) {
510
- const { added: r, removed: s, updated: o } = I(t, n);
511
- for (const i of s)
512
- Q(e, i);
513
- for (const i of r.concat(o))
514
- x(e, i, n[i]);
515
- }
516
- function mt(e, t = {}, n = {}, r = {}, s = null) {
517
- const { removed: o, added: i, updated: c } = I(n, r);
518
- for (const u of o.concat(c)) {
498
+ w(e, a);
499
+ for (const a of f.concat(u))
500
+ C(e, a, o[a]);
501
+ }
502
+ function at(e, t, n) {
503
+ const r = I(t), s = I(n), { added: i, removed: o } = X(r, s);
504
+ o.length > 0 && e.classList.remove(...o), i.length > 0 && e.classList.add(...i);
505
+ }
506
+ function I(e = "") {
507
+ return Array.isArray(e) ? e.filter(k) : String(e).split(/(\s+)/).filter(k);
508
+ }
509
+ function ht(e, t = {}, n = {}) {
510
+ const { added: r, removed: s, updated: i } = M(t, n);
511
+ for (const o of s)
512
+ H(e, o);
513
+ for (const o of r.concat(i))
514
+ S(e, o, n[o]);
515
+ }
516
+ function pt(e, t = {}, n = {}, r = {}, s = null) {
517
+ const { removed: i, added: o, updated: f } = M(n, r);
518
+ for (const u of i.concat(f)) {
519
519
  const a = t?.[u];
520
520
  a && e.removeEventListener(u, a);
521
521
  }
522
522
  const l = {};
523
- for (const u of i.concat(c))
523
+ for (const u of o.concat(f))
524
524
  l[u] = R(
525
525
  u,
526
526
  r[u],
@@ -529,18 +529,18 @@ function mt(e, t = {}, n = {}, r = {}, s = null) {
529
529
  );
530
530
  return l;
531
531
  }
532
- function q(e, t, n) {
533
- const r = y(e), s = y(t), o = e.el, i = Y(r, s, G), c = n?.offset ?? 0;
534
- for (const l of i)
532
+ function x(e, t, n) {
533
+ const r = g(e), s = g(t), i = e.el, o = B(r, s, D), f = n?.offset ?? 0;
534
+ for (const l of o)
535
535
  if (l.op === h.NOOP) {
536
536
  const { originalIndex: u, index: a } = l;
537
- P(r[u], s[a], o, n);
537
+ P(r[u], s[a], i, n);
538
538
  }
539
- for (const l of i)
539
+ for (const l of o)
540
540
  switch (l.op) {
541
541
  case h.MOVE: {
542
- const { from: u, index: a } = l, m = r[u].el, b = o.childNodes[a + c];
543
- m && (o.insertBefore(m, b), P(r[u], s[a], o, n));
542
+ const { from: u, index: a } = l, E = r[u].el, m = i.childNodes[a + f];
543
+ E && (i.insertBefore(E, m), P(r[u], s[a], i, n));
544
544
  break;
545
545
  }
546
546
  case h.REMOVE: {
@@ -550,24 +550,24 @@ function q(e, t, n) {
550
550
  }
551
551
  case h.ADD: {
552
552
  const { index: u, item: a } = l;
553
- p(a, o, u + c, n);
553
+ p(a, i, u + f, n);
554
554
  break;
555
555
  }
556
556
  }
557
557
  }
558
- function Et(e, t) {
559
- const { component: n } = e, { props: r } = M(t);
558
+ function dt(e, t) {
559
+ const { component: n } = e, { props: r } = A(t);
560
560
  n.updateProps(r), t.component = n, t.el = n.firstElement;
561
561
  }
562
- function yt(e, t, n) {
562
+ function Et(e, t, n) {
563
563
  if (e.container !== t.container) {
564
564
  d(e), p(t, document.body, null, n);
565
565
  return;
566
566
  }
567
- q(e, t, n);
567
+ x(e, t, n);
568
568
  }
569
- const bt = (e) => e.constructor.name.includes("Provider"), gt = (e) => e.constructor.name.includes("Consumer");
570
- class j {
569
+ const yt = (e) => e.constructor.name.includes("Provider"), gt = (e) => e.constructor.name.includes("Consumer");
570
+ class L {
571
571
  constructor(t = {}, n) {
572
572
  this.isMounted = !1, this.vdom = null, this.hostEl = null, this.parent = null, this.state = {}, this.context = null, this.dependencies = [], this.subscribedProvider = null, this.props = t, this.parent = n;
573
573
  }
@@ -596,19 +596,19 @@ class j {
596
596
  return Promise.resolve();
597
597
  }
598
598
  get elements() {
599
- return this.vdom == null ? [] : this.vdom.type === f.FRAGMENT ? y(this.vdom).flatMap((t) => t.type === f.COMPONENT && t.component ? t.component.elements : t.el ? [t.el] : []) : this.vdom.el ? [this.vdom.el] : [];
599
+ return this.vdom == null ? [] : this.vdom.type === c.FRAGMENT ? g(this.vdom).flatMap((t) => t.type === c.COMPONENT && t.component ? t.component.elements : t.el ? [t.el] : []) : this.vdom.el ? [this.vdom.el] : [];
600
600
  }
601
601
  get firstElement() {
602
602
  return this.elements[0];
603
603
  }
604
604
  get offset() {
605
- return this.vdom?.type === f.FRAGMENT && this.hostEl && this.firstElement ? Array.from(this.hostEl.children).indexOf(this.firstElement) : 0;
605
+ return this.vdom?.type === c.FRAGMENT && this.hostEl && this.firstElement ? Array.from(this.hostEl.children).indexOf(this.firstElement) : 0;
606
606
  }
607
607
  updateProps(t) {
608
608
  const n = { ...this.props, ...t }, r = this.props;
609
609
  this.props = n;
610
610
  let s = this.updateContext();
611
- O(r, n) && !s || (bt(this) && this.notify(), this.patch());
611
+ v(r, n) && !s || (yt(this) && this.notify(), this.patch());
612
612
  }
613
613
  setState(t) {
614
614
  typeof t == "function" ? this.state = {
@@ -622,15 +622,15 @@ class j {
622
622
  gt(this) && !this.subscribedProvider && this.subscribeToProvider(), this.updateContext(), this.vdom = this.render(), p(this.vdom, t, n, this), this.hostEl = t, this.isMounted = !0;
623
623
  }
624
624
  unmount() {
625
- this.isMounted && (E(() => this.onWillUnmount()), this.subscribedProvider && this.subscribedProvider.removeDependency({ consumer: this }), this.dependencies.forEach(({ consumer: t }) => {
625
+ this.isMounted && (y(() => this.onWillUnmount()), this.subscribedProvider && this.subscribedProvider.removeDependency({ consumer: this }), this.dependencies.forEach(({ consumer: t }) => {
626
626
  t.subscribedProvider = null;
627
- }), this.dependencies = [], this.vdom && d(this.vdom), E(() => this.onUnmount()), this.vdom = null, this.hostEl = null, this.isMounted = !1);
627
+ }), this.dependencies = [], this.vdom && d(this.vdom), y(() => this.onUnmount()), this.vdom = null, this.hostEl = null, this.isMounted = !1);
628
628
  }
629
629
  patch() {
630
630
  if (!this.isMounted || !this.hostEl || !this.vdom)
631
631
  return;
632
632
  const t = this.render();
633
- this.vdom = P(this.vdom, t, this.hostEl, this), E(() => this.onUpdate());
633
+ this.vdom = P(this.vdom, t, this.hostEl, this), y(() => this.onUpdate());
634
634
  }
635
635
  updateContext() {
636
636
  const t = Object.getPrototypeOf(this).constructor.contextType;
@@ -660,25 +660,25 @@ class j {
660
660
  }
661
661
  }
662
662
  function vt(e) {
663
- class t extends j {
663
+ class t extends L {
664
664
  render() {
665
- let o = [];
666
- return Array.isArray(this.props.children) ? o = this.props.children : this.props.children ? o = [this.props.children] : o = [], D(o);
665
+ let i = [];
666
+ return Array.isArray(this.props.children) ? i = this.props.children : this.props.children ? i = [this.props.children] : i = [], K(i);
667
667
  }
668
668
  }
669
- const r = class r extends j {
669
+ const r = class r extends L {
670
670
  render() {
671
- let o = this.props.children;
672
- if (Array.isArray(o))
673
- if (o.length === 1 && typeof o[0] == "function")
674
- o = o[0];
671
+ let i = this.props.children;
672
+ if (Array.isArray(i))
673
+ if (i.length === 1 && typeof i[0] == "function")
674
+ i = i[0];
675
675
  else
676
676
  throw new Error(
677
677
  "Consumer: expected single function child, got array"
678
678
  );
679
- if (typeof o != "function")
679
+ if (typeof i != "function")
680
680
  throw new Error("Consumer: children is not a function");
681
- return o(this.context);
681
+ return i(this.context);
682
682
  }
683
683
  };
684
684
  r.contextType = {
@@ -692,62 +692,27 @@ function vt(e) {
692
692
  defaultValue: e
693
693
  };
694
694
  }
695
- function Nt(e, t) {
695
+ function bt(e, t) {
696
696
  if (!t)
697
697
  throw new Error("Container element is not provided for rendering.");
698
698
  p(e, t);
699
699
  }
700
- function Pt(e = null) {
700
+ function Ot(e = null) {
701
701
  return {
702
702
  current: e
703
703
  };
704
704
  }
705
- function Tt(e, t) {
705
+ function Pt(e, t) {
706
706
  const n = Array.isArray(e) ? e : [e];
707
- return H(n, t);
708
- }
709
- const Ot = /* @__PURE__ */ Symbol("Fragment");
710
- function g(e) {
711
- return e == null || e === !1 ? null : typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? S(String(e)) : e;
712
- }
713
- function At(e, t, ...n) {
714
- if (e === Ot) {
715
- const i = n.flat().map(g).filter((c) => c != null);
716
- return D(i);
717
- }
718
- let r = {}, s = {};
719
- if (t && Object.entries(t).forEach(([i, c]) => {
720
- if (i.startsWith("on") && typeof c == "function") {
721
- const l = i.slice(2).toLowerCase();
722
- r[l] = c;
723
- } else i === "ref" ? s.ref = c : i === "className" ? s.class = c : i === "style" && typeof c == "object" ? s.style = c : i === "colorInterpolationFilters" ? s["color-interpolation-filters"] = c : i === "viewbox" ? s.viewBox = c : i !== "children" && i !== "key" && (s[i] = c);
724
- }), typeof e == "function")
725
- try {
726
- return e({ ...s, on: r });
727
- } catch {
728
- }
729
- if (typeof e == "function" || typeof e == "object" && e != null && "render" in e) {
730
- const i = { ...t ?? {} };
731
- return n.length > 0 && (i.children = n.flat().map(g).filter((c) => c != null)), w(e, i);
732
- }
733
- r = {}, s = {}, t && Object.entries(t).forEach(([i, c]) => {
734
- if (i.startsWith("on") && typeof c == "function") {
735
- const l = i.slice(2).toLowerCase();
736
- r[l] = c;
737
- } else i === "ref" ? s.ref = c : i === "className" ? s.class = c : i === "style" && typeof c == "object" ? s.style = c : i === "colorInterpolationFilters" ? s["color-interpolation-filters"] = c : i === "filterUnits" ? s.filterUnits = c : i === "clipPath" ? s["clip-path"] = c : i === "floodOpacity" ? s["flood-opacity"] = c : i === "stdDeviation" ? s.stdDeviation = c : i === "viewbox" ? s.viewBox = c : i !== "children" && i !== "key" && (s[i] = c);
738
- });
739
- const o = n.flat().map(g).filter((i) => i != null);
740
- return w(e, { ...s, on: r }, o);
707
+ return Y(n, t);
741
708
  }
742
709
  export {
743
- j as Component,
710
+ L as Component,
744
711
  vt as createContext,
745
- Tt as createPortal,
746
- Pt as createRef,
747
- w as h,
748
- D as hFragment,
749
- S as hString,
750
- At as jsx,
751
- At as jsxDEV,
752
- Nt as render
712
+ Pt as createPortal,
713
+ Ot as createRef,
714
+ mt as h,
715
+ K as hFragment,
716
+ J as hString,
717
+ bt as render
753
718
  };
@@ -0,0 +1,2 @@
1
+ export { jsx } from './jsx/jsx-runtime';
2
+ export { jsxDEV } from './jsx/jsx-dev-runtime';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ddd-react",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "scripts": {
5
5
  "test": "echo \"Error: no test specified\" && exit 1",
6
6
  "type-check": "tsc --noEmit",