dreaction-react 1.0.1 → 1.1.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 -9
- package/package.json +3 -4
- package/src/hooks.ts +6 -9
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,13 +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
|
-
});
|
|
57
|
-
dreaction_1.dreaction.connect();
|
|
58
|
-
setIsConnected(true);
|
|
52
|
+
connect();
|
|
59
53
|
}
|
|
60
54
|
}
|
|
61
55
|
}, [host, port]);
|
|
@@ -83,9 +77,12 @@ function useDReactionConfig() {
|
|
|
83
77
|
dreaction_1.dreaction.configure({
|
|
84
78
|
host,
|
|
85
79
|
port,
|
|
80
|
+
secure: window.location.protocol === 'https:',
|
|
86
81
|
});
|
|
87
82
|
dreaction_1.dreaction.connect();
|
|
88
|
-
|
|
83
|
+
dreaction_1.dreaction.waitForConnect().then(() => {
|
|
84
|
+
setIsConnected(true);
|
|
85
|
+
});
|
|
89
86
|
// Save auto-connect preference
|
|
90
87
|
if (typeof window !== 'undefined' && window.localStorage) {
|
|
91
88
|
window.localStorage.setItem(STORAGE_KEY_AUTO_CONNECT, 'true');
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dreaction-react",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "DReaction client for React web applications",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"files": [
|
|
8
8
|
"lib",
|
|
9
|
-
"src"
|
|
10
|
-
"README.md"
|
|
9
|
+
"src"
|
|
11
10
|
],
|
|
12
11
|
"keywords": [
|
|
13
12
|
"dreaction",
|
|
@@ -26,7 +25,7 @@
|
|
|
26
25
|
},
|
|
27
26
|
"homepage": "https://github.com/moonrailgun/dreaction#readme",
|
|
28
27
|
"dependencies": {
|
|
29
|
-
"dreaction-client-core": "1.2.
|
|
28
|
+
"dreaction-client-core": "1.2.1",
|
|
30
29
|
"dreaction-protocol": "1.0.8"
|
|
31
30
|
},
|
|
32
31
|
"devDependencies": {
|
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,13 +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
|
-
});
|
|
65
|
-
dreaction.connect();
|
|
66
|
-
setIsConnected(true);
|
|
60
|
+
connect();
|
|
67
61
|
}
|
|
68
62
|
}
|
|
69
63
|
}, [host, port]);
|
|
@@ -97,9 +91,12 @@ export function useDReactionConfig() {
|
|
|
97
91
|
dreaction.configure({
|
|
98
92
|
host,
|
|
99
93
|
port,
|
|
94
|
+
secure: window.location.protocol === 'https:',
|
|
100
95
|
});
|
|
101
96
|
dreaction.connect();
|
|
102
|
-
|
|
97
|
+
dreaction.waitForConnect().then(() => {
|
|
98
|
+
setIsConnected(true);
|
|
99
|
+
});
|
|
103
100
|
|
|
104
101
|
// Save auto-connect preference
|
|
105
102
|
if (typeof window !== 'undefined' && window.localStorage) {
|