ddd-react 1.5.0 → 1.6.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.
@@ -10,7 +10,9 @@ export declare abstract class Component<P = {}, S = ComponentState, ContextValue
10
10
  dependencies: {
11
11
  consumer: Component;
12
12
  }[];
13
- subscribedProvider: Component | null;
13
+ subscribedProvider: Component<{
14
+ value: ContextValueType;
15
+ }> | null;
14
16
  isProvider: boolean;
15
17
  isConsumer: boolean;
16
18
  constructor(props: P, parentComponent: Component | null);
package/dist/index.mjs CHANGED
@@ -13,8 +13,8 @@ function g(e, t) {
13
13
  if (Array.isArray(e)) {
14
14
  if (e.length !== t.length)
15
15
  return !1;
16
- for (let r = 0; r < e.length; ++r)
17
- if (!g(e[r], t[r]))
16
+ for (let n = 0; n < e.length; ++n)
17
+ if (!g(e[n], t[n]))
18
18
  return !1;
19
19
  return !0;
20
20
  }
@@ -24,14 +24,14 @@ function g(e, t) {
24
24
  return e.valueOf() === t.valueOf();
25
25
  if (e.toString !== Object.prototype.toString)
26
26
  return e.toString() === t.toString();
27
- const n = Object.keys(e);
28
- if (n.length !== Object.keys(t).length)
27
+ const r = Object.keys(e);
28
+ if (r.length !== Object.keys(t).length)
29
29
  return !1;
30
- for (let r = 0; r < n.length; ++r)
31
- if (!Object.prototype.hasOwnProperty.call(t, n[r]))
30
+ for (let n = 0; n < r.length; ++n)
31
+ if (!Object.prototype.hasOwnProperty.call(t, r[n]))
32
32
  return !1;
33
- for (let r = 0; r < n.length; ++r) {
34
- const s = n[r];
33
+ for (let n = 0; n < r.length; ++n) {
34
+ const s = r[n];
35
35
  if (!(s === "_owner" && e.$$typeof) && !g(e[s], t[s]))
36
36
  return !1;
37
37
  }
@@ -39,27 +39,27 @@ function g(e, t) {
39
39
  }
40
40
  return !1;
41
41
  }
42
- function S(e, t, n, r = null) {
43
- function s(o) {
44
- const i = o;
45
- r ? t.call(r, i) : t(i);
42
+ function S(e, t, r, n = null) {
43
+ function s(i) {
44
+ const o = i;
45
+ n ? t.call(n, o) : t(o);
46
46
  }
47
- return n.addEventListener(e, s), s;
47
+ return r.addEventListener(e, s), s;
48
48
  }
49
- function $(e = {}, t, n = null) {
50
- const r = {};
51
- return Object.entries(e).forEach(([s, o]) => {
52
- r[s] = S(
49
+ function $(e = {}, t, r = null) {
50
+ const n = {};
51
+ return Object.entries(e).forEach(([s, i]) => {
52
+ n[s] = S(
53
53
  s,
54
- o,
54
+ i,
55
55
  t,
56
- n
56
+ r
57
57
  );
58
- }), r;
58
+ }), n;
59
59
  }
60
60
  function q(e = {}, t) {
61
- Object.entries(e).forEach(([n, r]) => {
62
- t.removeEventListener(n, r);
61
+ Object.entries(e).forEach(([r, n]) => {
62
+ t.removeEventListener(r, n);
63
63
  });
64
64
  }
65
65
  function p(e) {
@@ -95,8 +95,8 @@ function G(e) {
95
95
  t && t.remove();
96
96
  }
97
97
  function W(e) {
98
- const { el: t, children: n, listeners: r, props: s } = e;
99
- s?.ref && typeof s.ref == "object" && "current" in s.ref && (s.ref.current = null), t && t.remove(), n && n.forEach(p), r && t && (q(r, t), delete e.listeners);
98
+ const { el: t, children: r, listeners: n, props: s } = e;
99
+ s?.ref && typeof s.ref == "object" && "current" in s.ref && (s.ref.current = null), t && t.remove(), r && r.forEach(p), n && t && (q(n, t), delete e.listeners);
100
100
  }
101
101
  function B(e) {
102
102
  const { children: t } = e;
@@ -106,19 +106,19 @@ function X(e) {
106
106
  const { children: t } = e;
107
107
  t && t.forEach(p);
108
108
  }
109
- function C(e, t, n) {
110
- e.style[t] = n.toString();
109
+ function C(e, t, r) {
110
+ e.style[t] = r.toString();
111
111
  }
112
112
  function _(e, t) {
113
113
  e.style[t] = null;
114
114
  }
115
115
  function J(e, t) {
116
- const { class: n, style: r, ...s } = t;
117
- n && K(e, n), r && Object.entries(r).forEach(([o, i]) => {
118
- C(e, o, i);
116
+ const { class: r, style: n, ...s } = t;
117
+ r && K(e, r), n && Object.entries(n).forEach(([i, o]) => {
118
+ C(e, i, o);
119
119
  });
120
- for (const [o, i] of Object.entries(s))
121
- L(e, o, i);
120
+ for (const [i, o] of Object.entries(s))
121
+ L(e, i, o);
122
122
  }
123
123
  function K(e, t) {
124
124
  if (e instanceof SVGElement) {
@@ -127,15 +127,15 @@ function K(e, t) {
127
127
  }
128
128
  e.className = "", typeof t == "string" ? e.className = t : Array.isArray(t) && e.classList.add(...t);
129
129
  }
130
- function L(e, t, n) {
131
- n == null ? w(e, t) : e.setAttribute(t, String(n));
130
+ function L(e, t, r) {
131
+ r == null ? w(e, t) : e.setAttribute(t, String(r));
132
132
  }
133
133
  function w(e, t) {
134
134
  e[t] = null, e.removeAttribute(t);
135
135
  }
136
136
  let P = !1;
137
137
  const O = [];
138
- function E(e) {
138
+ function b(e) {
139
139
  O.push(e), Y();
140
140
  }
141
141
  function Y() {
@@ -147,276 +147,276 @@ function H() {
147
147
  let t;
148
148
  try {
149
149
  t = e();
150
- } catch (n) {
151
- console.error(`[scheduler]: ${n}`);
150
+ } catch (r) {
151
+ console.error(`[scheduler]: ${r}`);
152
152
  continue;
153
153
  }
154
154
  Promise.resolve(t).then(
155
155
  () => {
156
156
  },
157
- (n) => {
158
- console.error(`[scheduler]: ${n}`);
157
+ (r) => {
158
+ console.error(`[scheduler]: ${r}`);
159
159
  }
160
160
  );
161
161
  }
162
162
  P = !1;
163
163
  }
164
164
  function A(e) {
165
- const { on: t = {}, ...n } = e.props;
166
- return delete n.key, { props: n, events: t };
165
+ const { on: t = {}, ...r } = e.props;
166
+ return delete r.key, { props: r, events: t };
167
167
  }
168
- function h(e, t, n = null, r = null) {
168
+ function h(e, t, r = null, n = null) {
169
169
  switch (e.type) {
170
170
  case c.TEXT: {
171
- z(e, t, n);
171
+ z(e, t, r);
172
172
  break;
173
173
  }
174
174
  case c.ELEMENT: {
175
- Z(e, t, n, r);
175
+ Z(e, t, r, n);
176
176
  break;
177
177
  }
178
178
  case c.FRAGMENT: {
179
- Q(e, t, n, r);
179
+ Q(e, t, r, n);
180
180
  break;
181
181
  }
182
182
  case c.COMPONENT: {
183
- tt(e, t, n, r);
183
+ tt(e, t, r, n);
184
184
  const s = e.component;
185
- s && E(() => s.onMount());
185
+ s && b(() => s.onMount());
186
186
  break;
187
187
  }
188
188
  case c.PORTAL: {
189
- et(e, r);
189
+ et(e, n);
190
190
  break;
191
191
  }
192
192
  default:
193
193
  throw new Error(`Can't mount DOM of type: ${e.type}`);
194
194
  }
195
195
  }
196
- function z(e, t, n) {
197
- const { value: r } = e, s = document.createTextNode(r);
198
- e.el = s, j(s, t, n);
196
+ function z(e, t, r) {
197
+ const { value: n } = e, s = document.createTextNode(n);
198
+ e.el = s, j(s, t, r);
199
199
  }
200
- function Q(e, t, n, r) {
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, n != null ? n + i : null, r);
202
+ e.el = t, s?.forEach((i, o) => {
203
+ h(i, t, r != null ? r + o : null, n);
204
204
  });
205
205
  }
206
- function Z(e, t, n, r) {
207
- const { tag: s, children: o } = e, f = s === "svg" || t instanceof SVGElement ? document.createElementNS("http://www.w3.org/2000/svg", s) : document.createElement(s);
208
- V(f, e, r), e.el = f, o?.forEach((l) => {
209
- h(l, f, null, r);
210
- }), j(f, t, n);
206
+ function Z(e, t, r, n) {
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
+ h(a, f, null, n);
210
+ }), j(f, t, r);
211
211
  }
212
- function V(e, t, n) {
213
- const { props: r, events: s } = A(t);
214
- r.ref && typeof r.ref == "object" && "current" in r.ref && (r.ref.current = e, delete r.ref), t.listeners = $(s, e, n), J(e, r);
212
+ function V(e, t, r) {
213
+ const { props: n, events: s } = A(t);
214
+ n.ref && typeof n.ref == "object" && "current" in n.ref && (n.ref.current = e, delete n.ref), t.listeners = $(s, e, r), J(e, n);
215
215
  }
216
- function tt(e, t, n, r) {
217
- const s = e.tag, { props: o } = A(e), i = new s(o, r);
218
- i.mount(t, n), e.component = i, e.el = i.firstElement || null;
216
+ function tt(e, t, r, n) {
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
- function j(e, t, n) {
221
- if (n == null) {
220
+ function j(e, t, r) {
221
+ if (r == null) {
222
222
  t.append(e);
223
223
  return;
224
224
  }
225
- if (n < 0)
226
- throw new Error(`Index must be a positive integer, got ${n}`);
227
- const r = t.childNodes;
228
- n >= r.length ? t.append(e) : t.insertBefore(e, r[n]);
225
+ if (r < 0)
226
+ throw new Error(`Index must be a positive integer, got ${r}`);
227
+ const n = t.childNodes;
228
+ r >= n.length ? t.append(e) : t.insertBefore(e, n[r]);
229
229
  }
230
230
  function et(e, t) {
231
- const { children: n, container: r } = e;
232
- n?.forEach((s) => {
233
- h(s, r, null, t);
231
+ const { children: r, container: n } = e;
232
+ r?.forEach((s) => {
233
+ h(s, n, null, t);
234
234
  });
235
235
  }
236
236
  function D(e, t) {
237
237
  if (e.type !== t.type)
238
238
  return !1;
239
239
  if (e.type === c.ELEMENT) {
240
- const n = e, r = t, {
240
+ const r = e, n = t, {
241
241
  tag: s,
242
- props: { key: o }
243
- } = n, {
244
- tag: i,
242
+ props: { key: i }
243
+ } = r, {
244
+ tag: o,
245
245
  props: { key: f }
246
- } = r;
247
- return s === i && o === f;
246
+ } = n;
247
+ return s === o && i === f;
248
248
  }
249
249
  if (e.type === c.COMPONENT) {
250
- const n = e, r = t, { tag: s } = n, { tag: o } = r;
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
- const n = e, r = t;
255
- return n.container === r.container;
254
+ const r = e, n = t;
255
+ return r.container === n.container;
256
256
  }
257
257
  return !0;
258
258
  }
259
259
  function T(e, t) {
260
- const n = Object.keys(e), r = Object.keys(t), s = [], o = [];
261
- for (const i of r)
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: n.filter((i) => !(i in t)),
266
- updated: o
265
+ removed: r.filter((o) => !(o in t)),
266
+ updated: i
267
267
  };
268
268
  }
269
- function nt(e) {
269
+ function rt(e) {
270
270
  return e !== "";
271
271
  }
272
272
  function N(e) {
273
- return nt(e.trim());
273
+ return rt(e.trim());
274
274
  }
275
- function m(e, t, n, r = null) {
275
+ function m(e, t, r, n = null) {
276
276
  if (!D(e, t)) {
277
- const s = rt(n, e.el);
278
- return p(e), h(t, n, s, r), t;
277
+ const s = nt(r, e.el);
278
+ return p(e), h(t, r, s, n), t;
279
279
  }
280
280
  switch (t.el = e.el, t.type) {
281
281
  case c.TEXT:
282
282
  return st(e, t), t;
283
283
  case c.ELEMENT: {
284
- ot(e, t, r);
284
+ it(e, t, n);
285
285
  break;
286
286
  }
287
287
  case c.COMPONENT: {
288
- lt(e, t);
288
+ at(e, t);
289
289
  break;
290
290
  }
291
291
  case c.PORTAL: {
292
- at(e, t, r);
292
+ lt(e, t, n);
293
293
  break;
294
294
  }
295
295
  }
296
- return R(e, t, r), t;
296
+ return R(e, t, n), t;
297
297
  }
298
- function rt(e, t) {
298
+ function nt(e, t) {
299
299
  if (!t) return null;
300
- const n = Array.from(e.childNodes).indexOf(t);
301
- return n < 0 ? null : n;
300
+ const r = Array.from(e.childNodes).indexOf(t);
301
+ return r < 0 ? null : r;
302
302
  }
303
303
  function st(e, t) {
304
- const n = e.el, { value: r } = e, { value: s } = t;
305
- r !== s && n && (n.nodeValue = s);
304
+ const r = e.el, { value: n } = e, { value: s } = t;
305
+ n !== s && r && (r.nodeValue = s);
306
306
  }
307
- function ot(e, t, n) {
308
- const r = e.el, {
307
+ function it(e, t, r) {
308
+ const n = e.el, {
309
309
  class: s,
310
- style: o,
311
- on: i,
310
+ style: i,
311
+ on: o,
312
312
  ...f
313
313
  } = e.props ?? {}, {
314
- class: l,
314
+ class: a,
315
315
  style: u,
316
- on: a,
316
+ on: l,
317
317
  ...d
318
- } = t.props ?? {}, { listeners: b } = e;
319
- it(r, f, d), ct(r, s, l), ut(
320
- r,
321
- o,
318
+ } = t.props ?? {}, { listeners: E } = e;
319
+ ot(n, f, d), ct(n, s, a), ut(
320
+ n,
321
+ i,
322
322
  u
323
323
  ), t.listeners = ft(
324
- r,
325
- b,
326
- i ?? {},
327
- a ?? {},
328
- n
324
+ n,
325
+ E,
326
+ o ?? {},
327
+ l ?? {},
328
+ r
329
329
  );
330
330
  }
331
- function it(e, t = {}, n = {}) {
332
- const r = t.ref, s = n.ref;
333
- r !== s && (r && typeof r == "object" && "current" in r && (r.current = null), s && typeof s == "object" && "current" in s && (s.current = e));
334
- const o = { ...t }, i = { ...n };
335
- delete o.ref, delete i.ref;
336
- const { added: f, removed: l, updated: u } = T(o, i);
337
- for (const a of l)
338
- w(e, a);
339
- for (const a of f.concat(u))
340
- L(e, a, i[a]);
341
- }
342
- function ct(e, t, n) {
343
- const r = M(t), s = M(n), { added: o, removed: i } = F(r, s);
344
- i.length > 0 && e.classList.remove(...i), o.length > 0 && e.classList.add(...o);
331
+ function ot(e, t = {}, r = {}) {
332
+ const n = t.ref, s = r.ref;
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 i = { ...t }, o = { ...r };
335
+ delete i.ref, delete o.ref;
336
+ const { added: f, removed: a, updated: u } = T(i, o);
337
+ for (const l of a)
338
+ w(e, l);
339
+ for (const l of f.concat(u))
340
+ L(e, l, o[l]);
341
+ }
342
+ function ct(e, t, r) {
343
+ const n = M(t), s = M(r), { added: i, removed: o } = F(n, s);
344
+ o.length > 0 && e.classList.remove(...o), i.length > 0 && e.classList.add(...i);
345
345
  }
346
346
  function M(e = "") {
347
347
  return Array.isArray(e) ? e.filter(N) : String(e).split(/(\s+)/).filter(N);
348
348
  }
349
- function ut(e, t = {}, n = {}) {
350
- const { added: r, removed: s, updated: o } = T(t, n);
351
- for (const i of s)
352
- _(e, i);
353
- for (const i of r.concat(o))
354
- C(e, i, n[i]);
355
- }
356
- function ft(e, t = {}, n = {}, r = {}, s = null) {
357
- const { removed: o, added: i, updated: f } = T(n, r);
358
- for (const u of o.concat(f)) {
359
- const a = t?.[u];
360
- a && e.removeEventListener(u, a);
361
- }
362
- const l = {};
363
- for (const u of i.concat(f))
364
- l[u] = S(
349
+ function ut(e, t = {}, r = {}) {
350
+ const { added: n, removed: s, updated: i } = T(t, r);
351
+ for (const o of s)
352
+ _(e, o);
353
+ for (const o of n.concat(i))
354
+ C(e, o, r[o]);
355
+ }
356
+ function ft(e, t = {}, r = {}, n = {}, s = null) {
357
+ const { removed: i, added: o, updated: f } = T(r, n);
358
+ for (const u of i.concat(f)) {
359
+ const l = t?.[u];
360
+ l && e.removeEventListener(u, l);
361
+ }
362
+ const a = {};
363
+ for (const u of o.concat(f))
364
+ a[u] = S(
365
365
  u,
366
- r[u],
366
+ n[u],
367
367
  e,
368
368
  s
369
369
  );
370
- return l;
371
- }
372
- function R(e, t, n) {
373
- const r = v(e), s = v(t), o = e.el, i = x(r, s, D), f = n?.offset ?? 0;
374
- for (const l of i)
375
- if (l.op === y.NOOP) {
376
- const { originalIndex: u, index: a } = l;
377
- m(r[u], s[a], o, n);
370
+ return a;
371
+ }
372
+ function R(e, t, r) {
373
+ const n = v(e), s = v(t), i = e.el, o = x(n, s, D), f = r?.offset ?? 0;
374
+ for (const a of o)
375
+ if (a.op === y.NOOP) {
376
+ const { originalIndex: u, index: l } = a;
377
+ m(n[u], s[l], i, r);
378
378
  }
379
- for (const l of i)
380
- switch (l.op) {
379
+ for (const a of o)
380
+ switch (a.op) {
381
381
  case y.MOVE: {
382
- const { from: u, index: a } = l, d = r[u].el, b = o.childNodes[a + f];
383
- d && (o.insertBefore(d, b), m(r[u], s[a], o, n));
382
+ const { from: u, index: l } = a, d = n[u].el, E = i.childNodes[l + f];
383
+ d && (i.insertBefore(d, E), m(n[u], s[l], i, r));
384
384
  break;
385
385
  }
386
386
  case y.REMOVE: {
387
- const { item: u } = l;
387
+ const { item: u } = a;
388
388
  p(u);
389
389
  break;
390
390
  }
391
391
  case y.ADD: {
392
- const { index: u, item: a } = l;
393
- h(a, o, u + f, n);
392
+ const { index: u, item: l } = a;
393
+ h(l, i, u + f, r);
394
394
  break;
395
395
  }
396
396
  }
397
397
  }
398
- function lt(e, t) {
399
- const { component: n } = e, { props: r } = A(t);
400
- n.updateProps(r), t.component = n, t.el = n.firstElement;
398
+ function at(e, t) {
399
+ const { component: r } = e, { props: n } = A(t);
400
+ r.updateProps(n), t.component = r, t.el = r.firstElement;
401
401
  }
402
- function at(e, t, n) {
402
+ function lt(e, t, r) {
403
403
  if (e.container !== t.container) {
404
- p(e), h(t, document.body, null, n);
404
+ p(e), h(t, document.body, null, r);
405
405
  return;
406
406
  }
407
- R(e, t, n);
407
+ R(e, t, r);
408
408
  }
409
409
  const ht = (e) => e.isProvider, pt = (e) => e.isConsumer;
410
410
  class k {
411
- constructor(t = {}, n) {
412
- this.isMounted = !1, this.vdom = null, this.hostEl = null, this.parent = null, this.state = {}, this.context = null, this.dependencies = [], this.subscribedProvider = null, this.isProvider = !1, this.isConsumer = !1, this.props = t, this.parent = n;
411
+ constructor(t = {}, r) {
412
+ this.isMounted = !1, this.vdom = null, this.hostEl = null, this.parent = null, this.state = {}, this.context = null, this.dependencies = [], this.subscribedProvider = null, this.isProvider = !1, this.isConsumer = !1, this.props = t, this.parent = r;
413
413
  }
414
414
  addDependency({ consumer: t }) {
415
- this.dependencies.some((n) => n.consumer === t) || (this.dependencies.push({ consumer: t }), t.subscribedProvider = this);
415
+ this.dependencies.some((r) => r.consumer === t) || (this.dependencies.push({ consumer: t }), t.subscribedProvider = this);
416
416
  }
417
417
  removeDependency({ consumer: t }) {
418
- const n = this.dependencies.findIndex((r) => r.consumer === t);
419
- n !== -1 && (this.dependencies.splice(n, 1), t.subscribedProvider = null);
418
+ const r = this.dependencies.findIndex((n) => n.consumer === t);
419
+ r !== -1 && (this.dependencies.splice(r, 1), t.subscribedProvider = null);
420
420
  }
421
421
  notify() {
422
422
  this.dependencies.forEach(({ consumer: t }) => {
@@ -429,7 +429,7 @@ class k {
429
429
  onUnmount() {
430
430
  return Promise.resolve();
431
431
  }
432
- onUpdate(t, n) {
432
+ onUpdate(t, r) {
433
433
  return Promise.resolve();
434
434
  }
435
435
  onWillUnmount() {
@@ -445,44 +445,40 @@ class k {
445
445
  return this.vdom?.type === c.FRAGMENT && this.hostEl && this.firstElement ? Array.from(this.hostEl.children).indexOf(this.firstElement) : 0;
446
446
  }
447
447
  updateProps(t) {
448
- const n = { ...this.props, ...t }, r = this.props;
449
- this.props = n;
448
+ const r = { ...this.props, ...t }, n = this.props;
449
+ this.props = r;
450
450
  let s = this.updateContext();
451
- g(r, n) && !s || (ht(this) && this.notify(), this.patch(r, this.state));
451
+ g(n, r) && !s || (ht(this) && this.notify(), this.patch(n, this.state));
452
452
  }
453
453
  setState(t) {
454
- let n = this.state;
454
+ let r = this.state;
455
455
  typeof t == "function" ? this.state = {
456
456
  ...this.state,
457
457
  ...t(this.state, this.props)
458
- } : this.state = { ...this.state, ...t }, this.patch(this.props, n);
458
+ } : this.state = { ...this.state, ...t }, this.patch(this.props, r);
459
459
  }
460
- mount(t, n = null) {
460
+ mount(t, r = null) {
461
461
  if (this.isMounted)
462
462
  throw new Error("Component is already mounted");
463
- pt(this) && !this.subscribedProvider && this.subscribeToProvider(), this.updateContext(), this.vdom = this.render(), h(this.vdom, t, n, this), this.hostEl = t, this.isMounted = !0;
463
+ pt(this) && !this.subscribedProvider && this.subscribeToProvider(), this.updateContext(), this.vdom = this.render(), h(this.vdom, t, r, this), this.hostEl = t, this.isMounted = !0;
464
464
  }
465
465
  unmount() {
466
- this.isMounted && (E(() => this.onWillUnmount()), this.subscribedProvider && this.subscribedProvider.removeDependency({ consumer: this }), this.dependencies.forEach(({ consumer: t }) => {
466
+ this.isMounted && (b(() => this.onWillUnmount()), this.subscribedProvider && this.subscribedProvider.removeDependency({ consumer: this }), this.dependencies.forEach(({ consumer: t }) => {
467
467
  t.subscribedProvider = null;
468
- }), this.dependencies = [], this.vdom && p(this.vdom), E(() => this.onUnmount()), this.vdom = null, this.hostEl = null, this.isMounted = !1);
468
+ }), this.dependencies = [], this.vdom && p(this.vdom), b(() => this.onUnmount()), this.vdom = null, this.hostEl = null, this.isMounted = !1);
469
469
  }
470
- patch(t, n) {
470
+ patch(t, r) {
471
471
  if (!this.isMounted || !this.hostEl || !this.vdom)
472
472
  return;
473
- const r = this.render();
474
- this.vdom = m(this.vdom, r, this.hostEl, this), E(() => this.onUpdate(t, n));
473
+ const n = this.render();
474
+ this.vdom = m(this.vdom, n, this.hostEl, this), b(() => this.onUpdate(t, r));
475
475
  }
476
476
  updateContext() {
477
477
  const t = Object.getPrototypeOf(this).constructor.contextType;
478
- let n = this.parent;
479
- if (t != null) {
480
- for (; n; ) {
481
- if (Object.getPrototypeOf(n).constructor === t.Provider)
482
- return this.context = n.props.value, !0;
483
- n = n.parent;
484
- }
485
- n == null && (this.context = t.defaultValue);
478
+ if (t !== null) {
479
+ if (this.subscribedProvider)
480
+ return this.context = this.subscribedProvider.props.value, !0;
481
+ this.context = t.defaultValue;
486
482
  }
487
483
  return !1;
488
484
  }
@@ -490,13 +486,13 @@ class k {
490
486
  const t = Object.getPrototypeOf(this).constructor.contextType;
491
487
  if (!t)
492
488
  return;
493
- let n = this.parent;
494
- for (; n; ) {
495
- if (Object.getPrototypeOf(n).constructor === t.Provider) {
496
- n.addDependency({ consumer: this });
489
+ let r = this.parent;
490
+ for (; r; ) {
491
+ if (Object.getPrototypeOf(r).constructor === t.Provider) {
492
+ r.addDependency({ consumer: this });
497
493
  break;
498
494
  }
499
- n = n.parent;
495
+ r = r.parent;
500
496
  }
501
497
  }
502
498
  }
@@ -506,60 +502,60 @@ function yt(e) {
506
502
  super(...arguments), this.isProvider = !0;
507
503
  }
508
504
  render() {
509
- let o = [];
510
- return Array.isArray(this.props.children) ? o = this.props.children : this.props.children ? o = [this.props.children] : o = [], U(o);
505
+ let i = [];
506
+ return Array.isArray(this.props.children) ? i = this.props.children : this.props.children ? i = [this.props.children] : i = [], U(i);
511
507
  }
512
508
  }
513
- const r = class r extends k {
509
+ const n = class n extends k {
514
510
  constructor() {
515
511
  super(...arguments), this.isConsumer = !0;
516
512
  }
517
513
  render() {
518
- let o = this.props.children;
519
- if (Array.isArray(o))
520
- if (o.length === 1 && typeof o[0] == "function")
521
- o = o[0];
514
+ let i = this.props.children;
515
+ if (Array.isArray(i))
516
+ if (i.length === 1 && typeof i[0] == "function")
517
+ i = i[0];
522
518
  else
523
519
  throw new Error(
524
520
  "Consumer: expected single function child, got array"
525
521
  );
526
- if (typeof o != "function")
522
+ if (typeof i != "function")
527
523
  throw new Error("Consumer: children is not a function");
528
- return o(this.context);
524
+ return i(this.context);
529
525
  }
530
526
  };
531
- r.contextType = {
527
+ n.contextType = {
532
528
  Provider: t,
533
529
  defaultValue: e
534
530
  };
535
- let n = r;
531
+ let r = n;
536
532
  return {
537
533
  Provider: t,
538
- Consumer: n,
534
+ Consumer: r,
539
535
  defaultValue: e
540
536
  };
541
537
  }
542
- function Et(e, t) {
538
+ function bt(e, t) {
543
539
  if (!t)
544
540
  throw new Error("Container element is not provided for rendering.");
545
541
  h(e, t);
546
542
  }
547
- function bt(e = null) {
543
+ function Et(e = null) {
548
544
  return {
549
545
  current: e
550
546
  };
551
547
  }
552
548
  function vt(e, t) {
553
- const n = Array.isArray(e) ? e : [e];
554
- return I(n, t);
549
+ const r = Array.isArray(e) ? e : [e];
550
+ return I(r, t);
555
551
  }
556
552
  export {
557
553
  k as Component,
558
554
  yt as createContext,
559
555
  vt as createPortal,
560
- bt as createRef,
556
+ Et as createRef,
561
557
  Ot as h,
562
558
  U as hFragment,
563
559
  mt as hString,
564
- Et as render
560
+ bt as render
565
561
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ddd-react",
3
- "version": "1.5.0",
3
+ "version": "1.6.1",
4
4
  "scripts": {
5
5
  "test": "echo \"Error: no test specified\" && exit 1",
6
6
  "type-check": "tsc --noEmit",