insite-subscriptions-react 2.2.3 → 2.3.0
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/Subscription.d.ts +5 -2
- package/dist/Subscription.d.ts.map +1 -1
- package/dist/Subscription.js +28 -16
- package/dist/SubscriptionGroup.d.ts.map +1 -1
- package/dist/SubscriptionGroup.js +3 -1
- package/package.json +32 -32
- package/src/Subscription.tsx +43 -24
- package/src/SubscriptionGroup.tsx +5 -1
package/dist/Subscription.d.ts
CHANGED
|
@@ -24,11 +24,14 @@ export declare class SubscriptionComponent extends Component<Props, State> {
|
|
|
24
24
|
renew(publicationName: string, params: unknown[]): void;
|
|
25
25
|
subscribe(): void;
|
|
26
26
|
unsubscribe(): void;
|
|
27
|
-
shouldComponentUpdate:
|
|
27
|
+
shouldComponentUpdate: typeof SubscriptionComponent.inconsistentShouldComponentUpdate | undefined;
|
|
28
28
|
render(): string | number | true | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null;
|
|
29
|
-
handleUpdate
|
|
29
|
+
handleUpdate(): void;
|
|
30
30
|
componentDidMount(): void;
|
|
31
31
|
componentWillUnmount(): void;
|
|
32
|
+
static inconsistentShouldComponentUpdate(this: SubscriptionComponent, nextProps: Props): boolean;
|
|
33
|
+
static consistentHandleUpdate(this: SubscriptionComponent): void;
|
|
34
|
+
static inconsistentHandleUpdate(this: SubscriptionComponent): void;
|
|
32
35
|
static defaultProps: {
|
|
33
36
|
params: never[];
|
|
34
37
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Subscription.d.ts","sourceRoot":"","sources":["../src/Subscription.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAIN,YAAY,EAEZ,iCAAiC,EACjC,eAAe,EACf,+BAA+B,EAE/B,kCAAkC,EAElC,MAAM,6BAA6B,C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
|
36
36
|
return this.value[unsubscribeSymbol]();
|
|
37
37
|
}
|
|
38
|
-
shouldComponentUpdate = this.props.consistent ?
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return true;
|
|
42
|
-
this.publicationSnapshot = publicationSnapshot;
|
|
43
|
-
this.renew(nextProps.publication, nextProps.params);
|
|
44
|
-
return false;
|
|
45
|
-
};
|
|
38
|
+
shouldComponentUpdate = this.props.consistent ?
|
|
39
|
+
undefined :
|
|
40
|
+
SubscriptionComponent.inconsistentShouldComponentUpdate;
|
|
46
41
|
render() {
|
|
47
42
|
return this.props.children?.(this.isActive, this.value) || null;
|
|
48
43
|
}
|
|
49
|
-
handleUpdate
|
|
44
|
+
handleUpdate() {
|
|
45
|
+
this.props.onUpdate?.(this.value);
|
|
46
|
+
}
|
|
50
47
|
componentDidMount() {
|
|
51
48
|
this.subscribe();
|
|
52
|
-
this.handleUpdate =
|
|
53
|
-
this.props.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
this.props.onUpdate?.(this.value);
|
|
57
|
-
this.setState({});
|
|
58
|
-
};
|
|
49
|
+
this.handleUpdate =
|
|
50
|
+
this.props.consistent ?
|
|
51
|
+
SubscriptionComponent.consistentHandleUpdate :
|
|
52
|
+
SubscriptionComponent.inconsistentHandleUpdate;
|
|
59
53
|
}
|
|
60
54
|
componentWillUnmount() {
|
|
61
55
|
this.unsubscribe();
|
|
62
56
|
}
|
|
57
|
+
static inconsistentShouldComponentUpdate(nextProps) {
|
|
58
|
+
const publicationSnapshot = JSON.stringify(nextProps.params) + nextProps.publication;
|
|
59
|
+
if (this.publicationSnapshot === publicationSnapshot)
|
|
60
|
+
return true;
|
|
61
|
+
this.publicationSnapshot = publicationSnapshot;
|
|
62
|
+
this.renew(nextProps.publication, nextProps.params);
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
static consistentHandleUpdate() {
|
|
66
|
+
console.log("🔵 consistentHandleUpdate");
|
|
67
|
+
this.props.onUpdate?.(this.value);
|
|
68
|
+
this.forceUpdate();
|
|
69
|
+
}
|
|
70
|
+
static inconsistentHandleUpdate() {
|
|
71
|
+
console.log("🔵 inconsistentHandleUpdate");
|
|
72
|
+
this.props.onUpdate?.(this.value);
|
|
73
|
+
this.setState({});
|
|
74
|
+
}
|
|
63
75
|
static defaultProps = {
|
|
64
76
|
params: []
|
|
65
77
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubscriptionGroup.d.ts","sourceRoot":"","sources":["../src/SubscriptionGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EACN,YAAY,EACZ,iBAAiB,EACjB,KAAK,wBAAwB,EAC7B,KAAK,mCAAmC,EACxC,MAAM,6BAA6B,CAAC;AAGrC,KAAK,uBAAuB,GAAG,GAAG,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAE3D,KAAK,KAAK,GAAG;IACZ,WAAW,EAAE,mCAAmC,EAAE,CAAC;IACnD,MAAM,EAAE,wBAAwB,CAAC,QAAQ,CAAC,CAAC;IAC3C,QAAQ,EAAE,wBAAwB,CAAC,UAAU,CAAC,CAAC;IAC/C,SAAS,EAAE,CAAC,MAAM,EAAE,uBAAuB,KAAK,IAAI,CAAC;IACrD,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,uBAAuB,KAAK,SAAS,CAAC;IAC5E,QAAQ,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;CAC7C,CAAC;AAEF,KAAK,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;AAGhC,qBAAa,0BAA2B,SAAQ,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC;gBAC1D,KAAK,EAAE,KAAK;IAexB,KAAK,2DAAC;IAEN,KAAK,iBAA0C;IAE/C,mBAAmB,qBAA8E;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AEjG,IAAI,QAAQ,YAEX;IAED,IAAI,QAAQ,YAEX;IAED,IAAI,MAAM,gCAET;IAED,QAAQ,GAAI,aAAa,mCAAmC,EAAE,kpBAAsC;IAEpG,SAAS,eAAgC;IAEzC,WAAW,6BAAkC;IAE7C,qBAAqB,eAAmD,KAAK,0BAc3E;IAEF,MAAM;IAKN,YAAY,aAA2C;IAEvD,iBAAiB;IAsBjB,oBAAoB;IASpB,MAAM,CAAC,MAAM,6BAAuB;CAEpC"}
|
|
@@ -34,7 +34,7 @@ export class SubscriptionGroupComponent extends Component {
|
|
|
34
34
|
if (this.definitionsSnapshot === definitionsSnapshot)
|
|
35
35
|
return true;
|
|
36
36
|
this.definitionsSnapshot = definitionsSnapshot;
|
|
37
|
-
this.redefine(nextProps.definitions);
|
|
37
|
+
void this.redefine(nextProps.definitions);
|
|
38
38
|
return false;
|
|
39
39
|
};
|
|
40
40
|
render() {
|
|
@@ -44,9 +44,11 @@ export class SubscriptionGroupComponent extends Component {
|
|
|
44
44
|
componentDidMount() {
|
|
45
45
|
this.subscribe();
|
|
46
46
|
this.handleUpdate = this.props.consistent ? () => {
|
|
47
|
+
console.log("🟣 consistentHandleUpdate");
|
|
47
48
|
this.props.onUpdate?.(this.group);
|
|
48
49
|
this.forceUpdate();
|
|
49
50
|
} : () => {
|
|
51
|
+
console.log("🟣 inconsistentHandleUpdate");
|
|
50
52
|
this.props.onUpdate?.(this.group);
|
|
51
53
|
this.setState({});
|
|
52
54
|
};
|
package/package.json
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
2
|
+
"name": "insite-subscriptions-react",
|
|
3
|
+
"version": "2.3.0",
|
|
4
|
+
"description": "inSite subscriptions React components",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./src/index.js",
|
|
7
|
+
"module": "./src/index.js",
|
|
8
|
+
"packageManager": "bun@1.2.11",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
11
|
+
"build": "tsc -p ."
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/nesvet/insite-subscriptions-react.git"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"insite",
|
|
19
|
+
"subscriptions",
|
|
20
|
+
"react"
|
|
21
|
+
],
|
|
22
|
+
"author": "Eugene Nesvetaev <dev@nesvet.dev> (https://nesvet.dev/)",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@nesvet/n": "^1.2.0",
|
|
26
|
+
"insite-subscriptions-client": "^2.3.0",
|
|
27
|
+
"react": "~18.2.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@nesvet/eslint-config": "^2.1.1",
|
|
31
|
+
"@types/react": "^18.3.20",
|
|
32
|
+
"typescript": "^5.8.3"
|
|
33
|
+
}
|
|
34
34
|
}
|
package/src/Subscription.tsx
CHANGED
|
@@ -84,41 +84,30 @@ export class SubscriptionComponent extends Component<Props, State> {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
|
|
87
|
-
shouldComponentUpdate =
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return true;
|
|
92
|
-
|
|
93
|
-
this.publicationSnapshot = publicationSnapshot;
|
|
94
|
-
this.renew(nextProps.publication, nextProps.params);
|
|
95
|
-
|
|
96
|
-
return false;
|
|
97
|
-
|
|
98
|
-
};
|
|
87
|
+
shouldComponentUpdate =
|
|
88
|
+
this.props.consistent ?
|
|
89
|
+
undefined :
|
|
90
|
+
SubscriptionComponent.inconsistentShouldComponentUpdate;
|
|
99
91
|
|
|
100
92
|
render() {
|
|
101
93
|
return this.props.children?.(this.isActive, this.value) || null;
|
|
102
94
|
}
|
|
103
95
|
|
|
104
96
|
|
|
105
|
-
handleUpdate
|
|
97
|
+
handleUpdate() {
|
|
98
|
+
|
|
99
|
+
this.props.onUpdate?.(this.value);
|
|
100
|
+
|
|
101
|
+
}
|
|
106
102
|
|
|
107
103
|
componentDidMount() {
|
|
108
104
|
|
|
109
105
|
this.subscribe();
|
|
110
106
|
|
|
111
|
-
this.handleUpdate =
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
} : () => {
|
|
117
|
-
|
|
118
|
-
this.props.onUpdate?.(this.value);
|
|
119
|
-
this.setState({});
|
|
120
|
-
|
|
121
|
-
};
|
|
107
|
+
this.handleUpdate =
|
|
108
|
+
this.props.consistent ?
|
|
109
|
+
SubscriptionComponent.consistentHandleUpdate :
|
|
110
|
+
SubscriptionComponent.inconsistentHandleUpdate;
|
|
122
111
|
|
|
123
112
|
}
|
|
124
113
|
|
|
@@ -129,6 +118,36 @@ export class SubscriptionComponent extends Component<Props, State> {
|
|
|
129
118
|
}
|
|
130
119
|
|
|
131
120
|
|
|
121
|
+
static inconsistentShouldComponentUpdate(this: SubscriptionComponent, nextProps: Props) {
|
|
122
|
+
const publicationSnapshot = JSON.stringify(nextProps.params) + nextProps.publication;
|
|
123
|
+
|
|
124
|
+
if (this.publicationSnapshot === publicationSnapshot)
|
|
125
|
+
return true;
|
|
126
|
+
|
|
127
|
+
this.publicationSnapshot = publicationSnapshot;
|
|
128
|
+
this.renew(nextProps.publication, nextProps.params);
|
|
129
|
+
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
static consistentHandleUpdate(this: SubscriptionComponent) {
|
|
134
|
+
|
|
135
|
+
console.log("🔵 consistentHandleUpdate");
|
|
136
|
+
|
|
137
|
+
this.props.onUpdate?.(this.value);
|
|
138
|
+
this.forceUpdate();
|
|
139
|
+
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
static inconsistentHandleUpdate(this: SubscriptionComponent) {
|
|
143
|
+
|
|
144
|
+
console.log("🔵 inconsistentHandleUpdate");
|
|
145
|
+
|
|
146
|
+
this.props.onUpdate?.(this.value);
|
|
147
|
+
this.setState({});
|
|
148
|
+
|
|
149
|
+
}
|
|
150
|
+
|
|
132
151
|
static defaultProps = {
|
|
133
152
|
params: []
|
|
134
153
|
};
|
|
@@ -73,7 +73,7 @@ export class SubscriptionGroupComponent extends Component<Props, State> {
|
|
|
73
73
|
return true;
|
|
74
74
|
|
|
75
75
|
this.definitionsSnapshot = definitionsSnapshot;
|
|
76
|
-
this.redefine(nextProps.definitions);
|
|
76
|
+
void this.redefine(nextProps.definitions);
|
|
77
77
|
|
|
78
78
|
return false;
|
|
79
79
|
|
|
@@ -92,11 +92,15 @@ export class SubscriptionGroupComponent extends Component<Props, State> {
|
|
|
92
92
|
|
|
93
93
|
this.handleUpdate = this.props.consistent ? () => {
|
|
94
94
|
|
|
95
|
+
console.log("🟣 consistentHandleUpdate");
|
|
96
|
+
|
|
95
97
|
this.props.onUpdate?.(this.group);
|
|
96
98
|
this.forceUpdate();
|
|
97
99
|
|
|
98
100
|
} : () => {
|
|
99
101
|
|
|
102
|
+
console.log("🟣 inconsistentHandleUpdate");
|
|
103
|
+
|
|
100
104
|
this.props.onUpdate?.(this.group);
|
|
101
105
|
this.setState({});
|
|
102
106
|
|