dreaction-react 1.0.2 → 1.2.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/lib/hooks.d.ts.map +1 -1
- package/lib/hooks.js +6 -10
- package/package.json +3 -3
- package/src/hooks.ts +6 -10
package/lib/hooks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,wBAAgB,mBAAmB,YAelC;AAED;;GAEG;AACH,wBAAgB,kBAAkB;;;;
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,wBAAgB,mBAAmB,YAelC;AAED;;GAEG;AACH,wBAAgB,kBAAkB;;;;0BA6CH,MAAM;0BAON,MAAM;;;EA2CpC"}
|
package/lib/hooks.js
CHANGED
|
@@ -14,7 +14,7 @@ function useConnectionStatus() {
|
|
|
14
14
|
const [isConnected, setIsConnected] = (0, react_1.useState)(dreaction_1.dreaction.connected);
|
|
15
15
|
(0, react_1.useEffect)(() => {
|
|
16
16
|
const checkConnection = () => {
|
|
17
|
-
setIsConnected(dreaction_1.dreaction.
|
|
17
|
+
setIsConnected(dreaction_1.dreaction.isReady);
|
|
18
18
|
};
|
|
19
19
|
// Check connection status periodically
|
|
20
20
|
const interval = setInterval(checkConnection, 1000);
|
|
@@ -49,14 +49,7 @@ function useDReactionConfig() {
|
|
|
49
49
|
const shouldAutoConnect = window.localStorage.getItem(STORAGE_KEY_AUTO_CONNECT);
|
|
50
50
|
if (shouldAutoConnect === 'true' && !dreaction_1.dreaction.connected) {
|
|
51
51
|
hasAutoConnected.current = true;
|
|
52
|
-
|
|
53
|
-
dreaction_1.dreaction.configure({
|
|
54
|
-
host,
|
|
55
|
-
port,
|
|
56
|
-
secure: window.location.protocol === 'https:',
|
|
57
|
-
});
|
|
58
|
-
dreaction_1.dreaction.connect();
|
|
59
|
-
setIsConnected(true);
|
|
52
|
+
connect();
|
|
60
53
|
}
|
|
61
54
|
}
|
|
62
55
|
}, [host, port]);
|
|
@@ -84,9 +77,12 @@ function useDReactionConfig() {
|
|
|
84
77
|
dreaction_1.dreaction.configure({
|
|
85
78
|
host,
|
|
86
79
|
port,
|
|
80
|
+
secure: window.location.protocol === 'https:',
|
|
87
81
|
});
|
|
88
82
|
dreaction_1.dreaction.connect();
|
|
89
|
-
|
|
83
|
+
dreaction_1.dreaction.waitForConnect().then(() => {
|
|
84
|
+
setIsConnected(true);
|
|
85
|
+
});
|
|
90
86
|
// Save auto-connect preference
|
|
91
87
|
if (typeof window !== 'undefined' && window.localStorage) {
|
|
92
88
|
window.localStorage.setItem(STORAGE_KEY_AUTO_CONNECT, 'true');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dreaction-react",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "DReaction client for React web applications",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
},
|
|
26
26
|
"homepage": "https://github.com/moonrailgun/dreaction#readme",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"dreaction-
|
|
29
|
-
"dreaction-
|
|
28
|
+
"dreaction-client-core": "1.3.0",
|
|
29
|
+
"dreaction-protocol": "1.0.10"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/react": "^18.0.0",
|
package/src/hooks.ts
CHANGED
|
@@ -13,7 +13,7 @@ export function useConnectionStatus() {
|
|
|
13
13
|
|
|
14
14
|
useEffect(() => {
|
|
15
15
|
const checkConnection = () => {
|
|
16
|
-
setIsConnected(dreaction.
|
|
16
|
+
setIsConnected(dreaction.isReady);
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
// Check connection status periodically
|
|
@@ -57,14 +57,7 @@ export function useDReactionConfig() {
|
|
|
57
57
|
);
|
|
58
58
|
if (shouldAutoConnect === 'true' && !dreaction.connected) {
|
|
59
59
|
hasAutoConnected.current = true;
|
|
60
|
-
|
|
61
|
-
dreaction.configure({
|
|
62
|
-
host,
|
|
63
|
-
port,
|
|
64
|
-
secure: window.location.protocol === 'https:',
|
|
65
|
-
});
|
|
66
|
-
dreaction.connect();
|
|
67
|
-
setIsConnected(true);
|
|
60
|
+
connect();
|
|
68
61
|
}
|
|
69
62
|
}
|
|
70
63
|
}, [host, port]);
|
|
@@ -98,9 +91,12 @@ export function useDReactionConfig() {
|
|
|
98
91
|
dreaction.configure({
|
|
99
92
|
host,
|
|
100
93
|
port,
|
|
94
|
+
secure: window.location.protocol === 'https:',
|
|
101
95
|
});
|
|
102
96
|
dreaction.connect();
|
|
103
|
-
|
|
97
|
+
dreaction.waitForConnect().then(() => {
|
|
98
|
+
setIsConnected(true);
|
|
99
|
+
});
|
|
104
100
|
|
|
105
101
|
// Save auto-connect preference
|
|
106
102
|
if (typeof window !== 'undefined' && window.localStorage) {
|