insite-subscriptions-react 2.3.0 → 2.3.3

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.
@@ -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,CAAC;AAGrC,KAAK,KAAK,GAAG,iCAAiC,GAAG,+BAA+B,GAAG,kCAAkC,CAAC;AAEtH,KAAK,KAAK,GAAG;IACZ,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,OAAO,EAAE,CAAC;IAClB,IAAI,CAAC,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;IAC/B,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC;IAC1D,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC,CAAC;AAEF,KAAK,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;AAOhC,qBAAa,qBAAsB,SAAQ,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC;gBACrD,KAAK,EAAE,KAAK;IAmBxB,KAAK,iBAGA;IAEL,KAAK;;sIAAC;IAEN,mBAAmB,qBAG0C;IAE7D,IAAI,QAAQ,YAEX;IAED,KAAK,CAAC,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE;IAIhD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B,SAAQ,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC;gBACrD,KAAK,EAAE,KAAK;IAmBxB,KAAK,iBAGA;IAEL,KAAK;;sIAAC;IAEN,mBAAmB,qBAG0C;IAE7D,IAAI,QAAQ,YAEX;IAED,KAAK,CAAC,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE;IAIhD,SAAS;IAIT,WAAW;IAKX,qBAAqB,6EAGqC;IAE1D,MAAM;IAKN,YAAY;IAMZ,iBAAiB;IAWjB,oBAAoB;IASpB,MAAM,CAAC,iCAAiC,CAAC,IAAI,EAAE,qBAAqB,EAAE,SAAS,EAAE,KAAK;IAYtF,MAAM,CAAC,sBAAsB,CAAC,IAAI,EAAE,qBAAqB;IAOzD,MAAM,CAAC,wBAAwB,CAAC,IAAI,EAAE,qBAAqB;IAO3D,MAAM,CAAC,YAAY;;MAEjB;IAEF,MAAM,CAAC,MAAM,6BAAuB;CAEpC"}
@@ -1,4 +1,5 @@
1
1
  import { Component } from "react";
2
+ import { noop } from "@nesvet/n";
2
3
  import { getSubscriptionSymbol, renewSymbol, subscribeSymbol, Subscription, SubscriptionArray, SubscriptionMap, SubscriptionObject, unsubscribeSymbol } from "insite-subscriptions-client";
3
4
  function isValueSubscriptionMap(props, value) {
4
5
  return props.map === true;
@@ -52,6 +53,7 @@ export class SubscriptionComponent extends Component {
52
53
  SubscriptionComponent.inconsistentHandleUpdate;
53
54
  }
54
55
  componentWillUnmount() {
56
+ this.handleUpdate = noop;
55
57
  this.unsubscribe();
56
58
  }
57
59
  static inconsistentShouldComponentUpdate(nextProps) {
@@ -63,12 +65,10 @@ export class SubscriptionComponent extends Component {
63
65
  return false;
64
66
  }
65
67
  static consistentHandleUpdate() {
66
- console.log("🔵 consistentHandleUpdate");
67
68
  this.props.onUpdate?.(this.value);
68
69
  this.forceUpdate();
69
70
  }
70
71
  static inconsistentHandleUpdate() {
71
- console.log("🔵 inconsistentHandleUpdate");
72
72
  this.props.onUpdate?.(this.value);
73
73
  this.setState({});
74
74
  }
@@ -22,11 +22,14 @@ export declare class SubscriptionGroupComponent extends Component<Props, State>
22
22
  redefine: (definitions: SubscriptionGroupUnparsedDefinition[]) => Promise<(import("insite-subscriptions-client/dist/SubscriptionGroup/SubscriptionGroupItem").SubscriptionGroupItem<import("insite-subscriptions-client").SubscriptionGroupSubscriptionType, import("insite-subscriptions-client").SubscriptionGroupDefinition<import("insite-subscriptions-client").SubscriptionGroupSubscriptionType>> | import("insite-subscriptions-client/dist/SubscriptionGroup/SubscriptionGroupItem").SubscriptionGroupItem<import("insite-subscriptions-client").SubscriptionGroupSubscriptionType, import("insite-subscriptions-client").SubscriptionGroupDefinition<import("insite-subscriptions-client").SubscriptionGroupSubscriptionType>>[])[]>;
23
23
  subscribe: () => void[];
24
24
  unsubscribe: () => (void | undefined)[];
25
- shouldComponentUpdate: ((nextProps: Props) => boolean) | undefined;
25
+ shouldComponentUpdate: typeof SubscriptionGroupComponent.inconsistentShouldComponentUpdate | undefined;
26
26
  render(): string | number | true | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null;
27
- handleUpdate: () => void;
27
+ handleUpdate(): void;
28
28
  componentDidMount(): void;
29
29
  componentWillUnmount(): void;
30
+ static inconsistentShouldComponentUpdate(this: SubscriptionGroupComponent, nextProps: Props): boolean;
31
+ static consistentHandleUpdate(this: SubscriptionGroupComponent): void;
32
+ static inconsistentHandleUpdate(this: SubscriptionGroupComponent): void;
30
33
  static bindTo: typeof Subscription.bindTo;
31
34
  }
32
35
  export {};
@@ -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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uB;CAEpC"}
@@ -27,7 +27,27 @@ export class SubscriptionGroupComponent extends Component {
27
27
  redefine = (definitions) => this.group.redefine(definitions);
28
28
  subscribe = () => this.group.subscribe();
29
29
  unsubscribe = () => this.group.unsubscribe();
30
- shouldComponentUpdate = this.props.consistent ? undefined : (nextProps) => {
30
+ shouldComponentUpdate = this.props.consistent ?
31
+ undefined :
32
+ SubscriptionGroupComponent.inconsistentShouldComponentUpdate;
33
+ render() {
34
+ return this.props.children?.(this.group.isLoaded, this.group.values) || null;
35
+ }
36
+ handleUpdate() {
37
+ this.props.onUpdate?.(this.group);
38
+ }
39
+ componentDidMount() {
40
+ this.subscribe();
41
+ this.handleUpdate =
42
+ this.props.consistent ?
43
+ SubscriptionGroupComponent.consistentHandleUpdate :
44
+ SubscriptionGroupComponent.inconsistentHandleUpdate;
45
+ }
46
+ componentWillUnmount() {
47
+ this.handleUpdate = noop;
48
+ this.unsubscribe();
49
+ }
50
+ static inconsistentShouldComponentUpdate(nextProps) {
31
51
  if (this.props.target !== nextProps.target || this.props.debounce !== nextProps.debounce)
32
52
  this.group.applyOptions({ target: nextProps.target, debounceLimit: nextProps.debounce });
33
53
  const definitionsSnapshot = JSON.stringify(nextProps.definitions);
@@ -36,26 +56,14 @@ export class SubscriptionGroupComponent extends Component {
36
56
  this.definitionsSnapshot = definitionsSnapshot;
37
57
  void this.redefine(nextProps.definitions);
38
58
  return false;
39
- };
40
- render() {
41
- return this.props.children?.(this.group.isLoaded, this.group.values) || null;
42
59
  }
43
- handleUpdate = () => this.props.onUpdate?.(this.group);
44
- componentDidMount() {
45
- this.subscribe();
46
- this.handleUpdate = this.props.consistent ? () => {
47
- console.log("🟣 consistentHandleUpdate");
48
- this.props.onUpdate?.(this.group);
49
- this.forceUpdate();
50
- } : () => {
51
- console.log("🟣 inconsistentHandleUpdate");
52
- this.props.onUpdate?.(this.group);
53
- this.setState({});
54
- };
60
+ static consistentHandleUpdate() {
61
+ this.props.onUpdate?.(this.group);
62
+ this.forceUpdate();
55
63
  }
56
- componentWillUnmount() {
57
- this.handleUpdate = noop;
58
- this.unsubscribe();
64
+ static inconsistentHandleUpdate() {
65
+ this.props.onUpdate?.(this.group);
66
+ this.setState({});
59
67
  }
60
68
  static bindTo = Subscription.bindTo;
61
69
  }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "insite-subscriptions-react",
3
- "version": "2.3.0",
3
+ "version": "2.3.3",
4
4
  "description": "inSite subscriptions React components",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
7
7
  "module": "./src/index.js",
8
- "packageManager": "bun@1.2.11",
8
+ "packageManager": "bun@1.2.18",
9
9
  "scripts": {
10
10
  "test": "echo \"Error: no test specified\" && exit 1",
11
11
  "build": "tsc -p ."
@@ -22,13 +22,13 @@
22
22
  "author": "Eugene Nesvetaev <dev@nesvet.dev> (https://nesvet.dev/)",
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
- "@nesvet/n": "^1.2.0",
26
- "insite-subscriptions-client": "^2.3.0",
25
+ "@nesvet/n": "^1.2.1",
26
+ "insite-subscriptions-client": "^2.3.3",
27
27
  "react": "~18.2.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@nesvet/eslint-config": "^2.1.1",
31
- "@types/react": "^18.3.20",
30
+ "@nesvet/eslint-config": "^2.1.2",
31
+ "@types/react": "^18.3.23",
32
32
  "typescript": "^5.8.3"
33
33
  }
34
34
  }
@@ -1,4 +1,5 @@
1
1
  import { Component, type ReactNode } from "react";
2
+ import { noop } from "@nesvet/n";
2
3
  import {
3
4
  getSubscriptionSymbol,
4
5
  renewSymbol,
@@ -113,6 +114,8 @@ export class SubscriptionComponent extends Component<Props, State> {
113
114
 
114
115
  componentWillUnmount() {
115
116
 
117
+ this.handleUpdate = noop;
118
+
116
119
  this.unsubscribe();
117
120
 
118
121
  }
@@ -132,8 +135,6 @@ export class SubscriptionComponent extends Component<Props, State> {
132
135
 
133
136
  static consistentHandleUpdate(this: SubscriptionComponent) {
134
137
 
135
- console.log("🔵 consistentHandleUpdate");
136
-
137
138
  this.props.onUpdate?.(this.value);
138
139
  this.forceUpdate();
139
140
 
@@ -141,8 +142,6 @@ export class SubscriptionComponent extends Component<Props, State> {
141
142
 
142
143
  static inconsistentHandleUpdate(this: SubscriptionComponent) {
143
144
 
144
- console.log("🔵 inconsistentHandleUpdate");
145
-
146
145
  this.props.onUpdate?.(this.value);
147
146
  this.setState({});
148
147
 
@@ -63,48 +63,31 @@ export class SubscriptionGroupComponent extends Component<Props, State> {
63
63
 
64
64
  unsubscribe = () => this.group.unsubscribe();
65
65
 
66
- shouldComponentUpdate = this.props.consistent ? undefined : (nextProps: Props) => {
67
- if (this.props.target !== nextProps.target || this.props.debounce !== nextProps.debounce)
68
- this.group.applyOptions({ target: nextProps.target, debounceLimit: nextProps.debounce });
69
-
70
- const definitionsSnapshot = JSON.stringify(nextProps.definitions);
71
-
72
- if (this.definitionsSnapshot === definitionsSnapshot)
73
- return true;
74
-
75
- this.definitionsSnapshot = definitionsSnapshot;
76
- void this.redefine(nextProps.definitions);
77
-
78
- return false;
79
-
80
- };
66
+
67
+ shouldComponentUpdate =
68
+ this.props.consistent ?
69
+ undefined :
70
+ SubscriptionGroupComponent.inconsistentShouldComponentUpdate;
81
71
 
82
72
  render() {
83
73
  return this.props.children?.(this.group.isLoaded, this.group.values) || null;
84
74
  }
85
75
 
86
76
 
87
- handleUpdate = () => this.props.onUpdate?.(this.group);
77
+ handleUpdate() {
78
+
79
+ this.props.onUpdate?.(this.group);
80
+
81
+ }
88
82
 
89
83
  componentDidMount() {
90
84
 
91
85
  this.subscribe();
92
86
 
93
- this.handleUpdate = this.props.consistent ? () => {
94
-
95
- console.log("🟣 consistentHandleUpdate");
96
-
97
- this.props.onUpdate?.(this.group);
98
- this.forceUpdate();
99
-
100
- } : () => {
101
-
102
- console.log("🟣 inconsistentHandleUpdate");
103
-
104
- this.props.onUpdate?.(this.group);
105
- this.setState({});
106
-
107
- };
87
+ this.handleUpdate =
88
+ this.props.consistent ?
89
+ SubscriptionGroupComponent.consistentHandleUpdate :
90
+ SubscriptionGroupComponent.inconsistentHandleUpdate;
108
91
 
109
92
  }
110
93
 
@@ -117,6 +100,35 @@ export class SubscriptionGroupComponent extends Component<Props, State> {
117
100
  }
118
101
 
119
102
 
103
+ static inconsistentShouldComponentUpdate(this: SubscriptionGroupComponent, nextProps: Props) {
104
+ if (this.props.target !== nextProps.target || this.props.debounce !== nextProps.debounce)
105
+ this.group.applyOptions({ target: nextProps.target, debounceLimit: nextProps.debounce });
106
+
107
+ const definitionsSnapshot = JSON.stringify(nextProps.definitions);
108
+
109
+ if (this.definitionsSnapshot === definitionsSnapshot)
110
+ return true;
111
+
112
+ this.definitionsSnapshot = definitionsSnapshot;
113
+ void this.redefine(nextProps.definitions);
114
+
115
+ return false;
116
+ }
117
+
118
+ static consistentHandleUpdate(this: SubscriptionGroupComponent) {
119
+
120
+ this.props.onUpdate?.(this.group);
121
+ this.forceUpdate();
122
+
123
+ }
124
+
125
+ static inconsistentHandleUpdate(this: SubscriptionGroupComponent) {
126
+
127
+ this.props.onUpdate?.(this.group);
128
+ this.setState({});
129
+
130
+ }
131
+
120
132
  static bindTo = Subscription.bindTo;
121
133
 
122
134
  }