ddd-react 1.3.9 → 1.3.10
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/component.d.ts +2 -0
- package/dist/index.mjs +10 -4
- package/package.json +1 -1
package/dist/component.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export declare abstract class Component<P = {}, S = ComponentState, ContextValue
|
|
|
11
11
|
consumer: Component;
|
|
12
12
|
}[];
|
|
13
13
|
subscribedProvider: Component | null;
|
|
14
|
+
isProvider: boolean;
|
|
15
|
+
isConsumer: boolean;
|
|
14
16
|
constructor(props: P, parentComponent: Component | null);
|
|
15
17
|
addDependency({ consumer }: {
|
|
16
18
|
consumer: Component;
|
package/dist/index.mjs
CHANGED
|
@@ -406,10 +406,10 @@ function pe(t, e, n) {
|
|
|
406
406
|
}
|
|
407
407
|
F(t, e, n);
|
|
408
408
|
}
|
|
409
|
-
const k = (t) => (console.log("isProvider"), console.log("component.constructor.name", t.constructor.name), t.
|
|
409
|
+
const k = (t) => (console.log("isProvider"), console.log("component.constructor.name", t.constructor.name), t.isProvider), C = (t) => (console.log("isConsumer"), console.log("component.constructor.name", t.constructor.name), t.isConsumer);
|
|
410
410
|
class S {
|
|
411
411
|
constructor(e = {}, 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.props = e, this.parent = 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 = e, this.parent = n;
|
|
413
413
|
}
|
|
414
414
|
addDependency({ consumer: e }) {
|
|
415
415
|
this.dependencies.some((n) => n.consumer === e) || (this.dependencies.push({ consumer: e }), e.subscribedProvider = this);
|
|
@@ -456,7 +456,7 @@ class S {
|
|
|
456
456
|
console.log("return");
|
|
457
457
|
return;
|
|
458
458
|
}
|
|
459
|
-
console.log("
|
|
459
|
+
console.log("isProvider(this.parent as Component)", k(this.parent)), k(this) && this.notify(), this.patch();
|
|
460
460
|
}
|
|
461
461
|
setState(e) {
|
|
462
462
|
typeof e == "function" ? this.state = {
|
|
@@ -467,7 +467,7 @@ class S {
|
|
|
467
467
|
mount(e, n = null) {
|
|
468
468
|
if (this.isMounted)
|
|
469
469
|
throw new Error("Component is already mounted");
|
|
470
|
-
console.log("this
|
|
470
|
+
console.log("this", this), console.log("isConsumer(this as Component)", C(this)), C(this) && !this.subscribedProvider && (console.log(" this.subscribeToProvider()"), this.subscribeToProvider()), this.updateContext(), this.vdom = this.render(), h(this.vdom, e, n, this), this.hostEl = e, this.isMounted = !0;
|
|
471
471
|
}
|
|
472
472
|
unmount() {
|
|
473
473
|
this.isMounted && (y(() => this.onWillUnmount()), this.subscribedProvider && this.subscribedProvider.removeDependency({ consumer: this }), this.dependencies.forEach(({ consumer: e }) => {
|
|
@@ -511,12 +511,18 @@ class S {
|
|
|
511
511
|
}
|
|
512
512
|
function ge(t) {
|
|
513
513
|
class e extends S {
|
|
514
|
+
constructor() {
|
|
515
|
+
super(...arguments), this.isProvider = !0;
|
|
516
|
+
}
|
|
514
517
|
render() {
|
|
515
518
|
let o = [];
|
|
516
519
|
return Array.isArray(this.props.children) ? o = this.props.children : this.props.children ? o = [this.props.children] : o = [], I(o);
|
|
517
520
|
}
|
|
518
521
|
}
|
|
519
522
|
const r = class r extends S {
|
|
523
|
+
constructor() {
|
|
524
|
+
super(...arguments), this.isConsumer = !0;
|
|
525
|
+
}
|
|
520
526
|
render() {
|
|
521
527
|
let o = this.props.children;
|
|
522
528
|
if (Array.isArray(o))
|