@carbonorm/carbonreact 3.4.2 → 3.4.5
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/dist/api/hoc/getStatefulObjectWithWhere.d.ts +11 -0
- package/dist/api/hoc/watchInputElementChangeEvent.d.ts +2 -0
- package/dist/components/WebSocket/CarbonWebSocket.d.ts +8 -4
- package/dist/index.cjs.js +26 -10
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.esm.js +26 -12
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -3
- package/src/api/hoc/getStatefulObjectWithWhere.tsx +17 -0
- package/src/api/hoc/watchInputElementChangeEvent.tsx +24 -0
- package/src/components/WebSocket/CarbonWebSocket.tsx +22 -11
- package/src/index.ts +4 -0
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { default as CarbonReact } from "./CarbonReact";
|
|
5
5
|
export * from "./CarbonReact";
|
|
6
|
+
export { default as getStatefulObjectWithWhere } from "./api/hoc/getStatefulObjectWithWhere";
|
|
7
|
+
export * from "./api/hoc/getStatefulObjectWithWhere";
|
|
6
8
|
export * from "./api/hoc/useEffectOnce";
|
|
9
|
+
export { default as watchInputElementChangeEvent } from "./api/hoc/watchInputElementChangeEvent";
|
|
10
|
+
export * from "./api/hoc/watchInputElementChangeEvent";
|
|
7
11
|
export { default as Alert } from "./components/Alert/Alert";
|
|
8
12
|
export * from "./components/Alert/Alert";
|
|
9
13
|
export { default as AccessDenied } from "./components/Errors/AccessDenied";
|
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import react, { useRef, useState, useEffect, Component, lazy } from 'react';
|
|
2
|
-
import { toastOptions, clearCache, axiosInstance, isVerbose, checkAllRequestsComplete } from '@carbonorm/carbonnode';
|
|
2
|
+
import { toastOptions, clearCache, timeout, axiosInstance, isVerbose, checkAllRequestsComplete } from '@carbonorm/carbonnode';
|
|
3
3
|
import { useNavigate, BrowserRouter } from 'react-router-dom';
|
|
4
4
|
import { toast, ToastContainer } from 'react-toastify';
|
|
5
5
|
import OutsideClickHandler from 'react-outside-click-handler';
|
|
@@ -4047,7 +4047,7 @@ const useEffectOnce = (effect) => {
|
|
|
4047
4047
|
* @function connect
|
|
4048
4048
|
* This function establishes a connection with the websocket and also ensures constant reconnection if connection closes
|
|
4049
4049
|
**/
|
|
4050
|
-
function initiateWebsocket({ TABLES = undefined } = {}) {
|
|
4050
|
+
function initiateWebsocket({ TABLES = undefined, url = 'ws://localhost:8080/ws', timeoutSeconds = 250, heartbeatSeconds = 60 } = {}) {
|
|
4051
4051
|
const { websocket } = CarbonReact.instance.state;
|
|
4052
4052
|
if (!("WebSocket" in window)) {
|
|
4053
4053
|
// todo - store that this has been shown in the state
|
|
@@ -4061,13 +4061,13 @@ function initiateWebsocket({ TABLES = undefined } = {}) {
|
|
|
4061
4061
|
return;
|
|
4062
4062
|
}
|
|
4063
4063
|
let connectInterval;
|
|
4064
|
-
const connection = new WebSocket(
|
|
4065
|
-
console.log("Connecting websocket url",
|
|
4064
|
+
const connection = new WebSocket(url);
|
|
4065
|
+
console.log("Connecting websocket url", url);
|
|
4066
4066
|
CarbonReact.instance.setState({
|
|
4067
4067
|
websocket: connection
|
|
4068
4068
|
}, () => {
|
|
4069
4069
|
connection.onopen = () => {
|
|
4070
|
-
console.log('WebSocket Client Connected To :: ' +
|
|
4070
|
+
console.log('WebSocket Client Connected To :: ' + url);
|
|
4071
4071
|
clearTimeout(connectInterval); // clear Interval on open of websocket connection
|
|
4072
4072
|
function heartbeat() {
|
|
4073
4073
|
const { websocket } = CarbonReact.instance.state;
|
|
@@ -4076,7 +4076,7 @@ function initiateWebsocket({ TABLES = undefined } = {}) {
|
|
|
4076
4076
|
if (websocket.readyState !== 1)
|
|
4077
4077
|
return;
|
|
4078
4078
|
websocket.send("ping");
|
|
4079
|
-
setTimeout(heartbeat,
|
|
4079
|
+
setTimeout(heartbeat, heartbeatSeconds * 1000);
|
|
4080
4080
|
}
|
|
4081
4081
|
heartbeat();
|
|
4082
4082
|
};
|
|
@@ -4086,7 +4086,7 @@ function initiateWebsocket({ TABLES = undefined } = {}) {
|
|
|
4086
4086
|
websocketEvents: prevState.websocketEvents.concat(message),
|
|
4087
4087
|
websocketData: prevState.websocketData.concat(parsedData), // JSON.parse no good - base64?
|
|
4088
4088
|
}));
|
|
4089
|
-
console.
|
|
4089
|
+
console.info('todo - going to impl TABLES', TABLES);
|
|
4090
4090
|
/*if (undefined !== TABLES) {
|
|
4091
4091
|
|
|
4092
4092
|
TABLES.
|
|
@@ -4100,8 +4100,8 @@ function initiateWebsocket({ TABLES = undefined } = {}) {
|
|
|
4100
4100
|
let reason;
|
|
4101
4101
|
console.log(`Socket is closed.`, event.reason, event);
|
|
4102
4102
|
const retry = () => {
|
|
4103
|
-
const retrySeconds = Math.min(5000, (
|
|
4104
|
-
|
|
4103
|
+
const retrySeconds = Math.min(5000, (timeoutSeconds + timeoutSeconds) * 1000);
|
|
4104
|
+
timeoutSeconds = retrySeconds;
|
|
4105
4105
|
console.log(`WebSocket reconnect will be attempted in ${retrySeconds} second(s).`);
|
|
4106
4106
|
connectInterval = setTimeout(() => initiateWebsocket(), retrySeconds);
|
|
4107
4107
|
};
|
|
@@ -4160,9 +4160,9 @@ function initiateWebsocket({ TABLES = undefined } = {}) {
|
|
|
4160
4160
|
});
|
|
4161
4161
|
});
|
|
4162
4162
|
}
|
|
4163
|
-
function CarbonWebSocket () {
|
|
4163
|
+
function CarbonWebSocket (props) {
|
|
4164
4164
|
useEffectOnce(() => {
|
|
4165
|
-
initiateWebsocket();
|
|
4165
|
+
initiateWebsocket(props);
|
|
4166
4166
|
});
|
|
4167
4167
|
return null;
|
|
4168
4168
|
}
|
|
@@ -4240,6 +4240,20 @@ const CarbonReact = class extends Component {
|
|
|
4240
4240
|
}
|
|
4241
4241
|
};
|
|
4242
4242
|
|
|
4243
|
+
var getStatefulObjectWithWhere = ({ request }) => {
|
|
4244
|
+
};
|
|
4245
|
+
|
|
4246
|
+
function watchInputElementChangeEvent(event, cb, timeoutMs = 3000) {
|
|
4247
|
+
const target = event.target;
|
|
4248
|
+
const value = target.value;
|
|
4249
|
+
event.target.style.color = "orange";
|
|
4250
|
+
timeout(() => value === ((() => target.value)()), async () => {
|
|
4251
|
+
const callbackResult = await cb(event);
|
|
4252
|
+
console.log('User provided input callbackResult passed to WatchInputElementChangeEvent (will cause green or red) value (' + value + ')', callbackResult);
|
|
4253
|
+
target.style.color = false === callbackResult ? "red" : "green";
|
|
4254
|
+
}, timeoutMs);
|
|
4255
|
+
}
|
|
4256
|
+
|
|
4243
4257
|
function AccessDenied({ children }) {
|
|
4244
4258
|
return (jsxRuntime_1("div", { children: jsxRuntime_1("div", { className: classes.notfound, children: jsxRuntime_2("div", { className: classes.notfound_404, children: [jsxRuntime_1("h3", { children: "Oops! Access not granted" }), children, jsxRuntime_2("h1", { style: {
|
|
4245
4259
|
position: "absolute",
|
|
@@ -4638,5 +4652,5 @@ function useWindowDimensions() {
|
|
|
4638
4652
|
return windowDimensions;
|
|
4639
4653
|
}
|
|
4640
4654
|
|
|
4641
|
-
export { AccessDenied, Alert, BackendThrowable, C6, COLUMNS, CarbonReact, CarbonWebSocket, ErrorHttpCode, GlobalHistory, Loading, Nest, PageNotFound, Popup, TABLES, addAlert, addValidSQL$1 as addValidSQL, carbons, changed, comments, deleteRestfulObjectArrays, documentation, eUpdateInsertMethod, feature_group_references, features, getRootStyleValue, getStyles, globalNavigate, group_references, groups, hexToRgb, history_logs, initialCarbonReactState, initialRequiredCarbonORMState, initialRestfulObjectsState, initiateWebsocket, isEdgeBrowser, isJsonString, isProduction, location_references, locations, parseMultipleJson, photos, range, reports, ScrollIntoViewDirective as scrollIntoView, setCookies, setUrl, setupTests, toDataURL, updateRestfulObjectArrays, uploadImage, uploadImageChange, useEffectOnce, user_followers, user_groups, user_messages, user_sessions, user_tasks, users, ValidSQL as validSQL, useWindowDimensions as windowDimensions, wp_commentmeta, wp_comments, wp_links, wp_options, wp_postmeta, wp_posts, wp_term_relationships, wp_term_taxonomy, wp_termmeta, wp_terms, wp_usermeta, wp_users };
|
|
4655
|
+
export { AccessDenied, Alert, BackendThrowable, C6, COLUMNS, CarbonReact, CarbonWebSocket, ErrorHttpCode, GlobalHistory, Loading, Nest, PageNotFound, Popup, TABLES, addAlert, addValidSQL$1 as addValidSQL, carbons, changed, comments, deleteRestfulObjectArrays, documentation, eUpdateInsertMethod, feature_group_references, features, getRootStyleValue, getStatefulObjectWithWhere, getStyles, globalNavigate, group_references, groups, hexToRgb, history_logs, initialCarbonReactState, initialRequiredCarbonORMState, initialRestfulObjectsState, initiateWebsocket, isEdgeBrowser, isJsonString, isProduction, location_references, locations, parseMultipleJson, photos, range, reports, ScrollIntoViewDirective as scrollIntoView, setCookies, setUrl, setupTests, toDataURL, updateRestfulObjectArrays, uploadImage, uploadImageChange, useEffectOnce, user_followers, user_groups, user_messages, user_sessions, user_tasks, users, ValidSQL as validSQL, watchInputElementChangeEvent, useWindowDimensions as windowDimensions, wp_commentmeta, wp_comments, wp_links, wp_options, wp_postmeta, wp_posts, wp_term_relationships, wp_term_taxonomy, wp_termmeta, wp_terms, wp_usermeta, wp_users };
|
|
4642
4656
|
//# sourceMappingURL=index.esm.js.map
|