@rpcbase/client 0.57.0 → 0.59.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/base_url.js +4 -4
- package/hashState.js +10 -3
- package/package.json +1 -1
package/base_url.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/* @flow */
|
|
2
2
|
import axios from "axios"
|
|
3
3
|
|
|
4
|
-
import {SERVER_PORT,
|
|
4
|
+
import {SERVER_PORT, APP_DOMAIN} from "env"
|
|
5
5
|
|
|
6
6
|
const protocol = (typeof window !== "undefined" && window?.location?.protocol) || "http:"
|
|
7
7
|
|
|
8
8
|
// there is no SERVER_PORT in production, as we use the default port and we are behind the gateway
|
|
9
9
|
// we assume we specify the port only when localhost or 127.0.0.1
|
|
10
|
-
const is_local = ["localhost", "127.0.0.1"].includes(
|
|
10
|
+
const is_local = ["localhost", "127.0.0.1"].includes(APP_DOMAIN)
|
|
11
11
|
|
|
12
|
-
const BASE_URL = is_local ? `${protocol}//${
|
|
12
|
+
const BASE_URL = is_local ? `${protocol}//${APP_DOMAIN}:${SERVER_PORT}` : `https://${APP_DOMAIN}`
|
|
13
13
|
|
|
14
|
-
console.log("
|
|
14
|
+
console.log("APP_DOMAIN", APP_DOMAIN, BASE_URL)
|
|
15
15
|
|
|
16
16
|
export default BASE_URL
|
package/hashState.js
CHANGED
|
@@ -5,8 +5,8 @@ import _isNil from "lodash/isNil"
|
|
|
5
5
|
import _omitBy from "lodash/omitBy"
|
|
6
6
|
import isEqual from "fast-deep-equal"
|
|
7
7
|
|
|
8
|
-
import {PAGE_NAVIGATION} from "config/events"
|
|
9
8
|
|
|
9
|
+
const PAGE_NAVIGATION_EVENT = "RB_PAGE_NAVIGATION"
|
|
10
10
|
|
|
11
11
|
const EMPTY_STATE_TOKEN = "N4XyA" // lz-string encoded empty state ''
|
|
12
12
|
|
|
@@ -91,9 +91,9 @@ export const HashStateProvider = ({children}) => {
|
|
|
91
91
|
setHashState(newState)
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
document.body.addEventListener(
|
|
94
|
+
document.body.addEventListener(PAGE_NAVIGATION_EVENT, onChange)
|
|
95
95
|
|
|
96
|
-
return () => document.body.removeEventListener(
|
|
96
|
+
return () => document.body.removeEventListener(PAGE_NAVIGATION_EVENT, onChange)
|
|
97
97
|
}, [hashState, setHashState])
|
|
98
98
|
|
|
99
99
|
useEffect(() => {
|
|
@@ -139,3 +139,10 @@ export const HashStateProvider = ({children}) => {
|
|
|
139
139
|
</HashContext.Provider>
|
|
140
140
|
)
|
|
141
141
|
}
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
export const hashStateMiddleware = (context, next) => {
|
|
145
|
+
next()
|
|
146
|
+
const ev = new CustomEvent(PAGE_NAVIGATION_EVENT, {detail: {context}})
|
|
147
|
+
document.body.dispatchEvent(ev)
|
|
148
|
+
}
|