arc-ux 0.0.14 → 0.1.1
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/package.json +3 -2
- package/src/ArcUX.js +5 -0
- package/src/FrameworkComponents/App.jsx +41 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arc-ux",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "A purely functional router for independently evaluating a path against a list of routes",
|
|
5
5
|
"main": "src/ArcUX.js",
|
|
6
6
|
"type": "module",
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"react": ">=18 <20",
|
|
34
34
|
"react-dom": ">=18 <20",
|
|
35
|
-
"styled-components": ">=6 <7"
|
|
35
|
+
"styled-components": ">=6 <7",
|
|
36
|
+
"cross-fetch": "^4.1.0"
|
|
36
37
|
},
|
|
37
38
|
"dependencies": {
|
|
38
39
|
"arc-lib": "^9.2.0"
|
package/src/ArcUX.js
CHANGED
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import withArcUX from "../withArcUX.js";
|
|
3
3
|
import ModalLayer from "./ModalLayer.jsx";
|
|
4
4
|
import { Log } from "arc-lib";
|
|
5
|
+
import fetch from "cross-fetch";
|
|
5
6
|
|
|
6
7
|
class App extends React.Component {
|
|
7
8
|
#routeListener;
|
|
@@ -22,6 +23,46 @@ class App extends React.Component {
|
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
async componentDidMount() {
|
|
26
|
+
if(window.app.environment === 'development'){
|
|
27
|
+
window.app.ArcUX = this.props.ArcUX;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if(window?.app?.version) {
|
|
31
|
+
let timeout = 1000*60*5;
|
|
32
|
+
if(window.app.environment === 'development'){
|
|
33
|
+
timeout = 1000*30; //Thirty seconds
|
|
34
|
+
}
|
|
35
|
+
setInterval(async () => {
|
|
36
|
+
let failures = 0;
|
|
37
|
+
try{
|
|
38
|
+
let response;
|
|
39
|
+
const rawResponse = await fetch(`/version`, {
|
|
40
|
+
method: "GET",
|
|
41
|
+
mode: "cors",
|
|
42
|
+
headers: {},
|
|
43
|
+
credentials: 'include'
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
status = rawResponse.status;
|
|
47
|
+
response = await rawResponse.text();
|
|
48
|
+
|
|
49
|
+
try{
|
|
50
|
+
response = JSON.parse(response);
|
|
51
|
+
} catch (e) {
|
|
52
|
+
Log.catch(e);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if(rawResponse?.status === 200 && response.version !== window.app.version){
|
|
56
|
+
Log.dRed("There is a version mismatch.", [window.app.version, response.version]);
|
|
57
|
+
this.props.ArcUX.emit('version', [window.app.version, response.version]);
|
|
58
|
+
}
|
|
59
|
+
} catch (e){
|
|
60
|
+
failures++;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
}, timeout);
|
|
64
|
+
}
|
|
65
|
+
|
|
25
66
|
const initialRoute = this.props.ArcUX.getKeyVal('route');
|
|
26
67
|
|
|
27
68
|
window.onpopstate = (_event) => {
|