@carbonorm/carbonreact 5.0.4 → 6.0.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/dist/components/Alert/Alert.d.ts +1 -1
- package/dist/components/Errors/BackendThrowable.d.ts +1 -1
- package/dist/components/WebSocket/CarbonWebSocket.d.ts +1 -1
- package/dist/{CarbonReact.d.ts → core/CarbonReact.d.ts} +4 -4
- package/dist/env/getEnv.d.ts +1 -0
- package/dist/env/isProduction.d.ts +2 -0
- package/dist/index.cjs +674 -786
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +5101 -5101
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +41 -44
- package/dist/index.esm.css +5101 -5101
- package/dist/index.esm.css.map +1 -1
- package/dist/index.esm.js +658 -769
- package/dist/index.esm.js.map +1 -1
- package/dist/{variables → schema}/C6.d.ts +1 -1
- package/dist/{hoc → state}/deleteRestfulObjectArrays.d.ts +2 -2
- package/dist/{hoc → state}/updateRestfulObjectArrays.d.ts +2 -2
- package/dist/{hoc → styles}/getStyles.d.ts +1 -1
- package/package.json +2 -2
- package/src/components/Alert/Alert.tsx +4 -5
- package/src/components/Errors/BackendThrowable.tsx +2 -2
- package/src/components/Loading/Loading.tsx +1 -2
- package/src/components/Popup/Popup.tsx +1 -2
- package/src/components/WebSocket/CarbonWebSocket.tsx +11 -3
- package/src/{CarbonReact.tsx → core/CarbonReact.tsx} +18 -24
- package/src/{hoc → dom}/isEdgeBrowser.tsx +4 -2
- package/src/{hoc → dom}/setCookies.tsx +1 -1
- package/src/env/getEnv.ts +29 -0
- package/src/env/isProduction.tsx +6 -0
- package/src/{hoc → hooks}/windowDimensions.tsx +9 -1
- package/src/index.ts +41 -44
- package/src/{variables → schema}/C6.tsx +1 -2
- package/src/{hoc → state}/deleteRestfulObjectArrays.tsx +2 -2
- package/src/{hoc → state}/updateRestfulObjectArrays.tsx +3 -3
- package/src/{hoc → styles}/getStyles.tsx +6 -2
- package/src/{hoc → testing}/setupTests.tsx +4 -1
- package/dist/components/Nest/Nest.d.ts +0 -49
- package/dist/hoc/setUrl.d.ts +0 -1
- package/dist/variables/isProduction.d.ts +0 -2
- package/src/components/Nest/Nest.tsx +0 -241
- package/src/hoc/setUrl.tsx +0 -38
- package/src/variables/isProduction.tsx +0 -5
- /package/dist/api/{hoc/getStatefulObjectWithWhere.d.ts → getStatefulObjectWithWhere.d.ts} +0 -0
- /package/dist/{hoc → dom}/isEdgeBrowser.d.ts +0 -0
- /package/dist/{hoc → dom}/scrollIntoView.d.ts +0 -0
- /package/dist/{hoc → dom}/setCookies.d.ts +0 -0
- /package/dist/{hoc → dom}/uploadImage.d.ts +0 -0
- /package/dist/{api/hoc → dom}/watchInputElementChangeEvent.d.ts +0 -0
- /package/dist/{api/hoc → hooks}/useEffectOnce.d.ts +0 -0
- /package/dist/{hoc → hooks}/windowDimensions.d.ts +0 -0
- /package/dist/{hoc → routing}/GlobalHistory.d.ts +0 -0
- /package/dist/{hoc → testing}/addValidSQL.d.ts +0 -0
- /package/dist/{hoc → testing}/setupTests.d.ts +0 -0
- /package/dist/{hoc → testing}/validSQL.d.ts +0 -0
- /package/dist/{hoc → types}/KeysMatching.d.ts +0 -0
- /package/dist/{hoc → types}/SubsetMatching.d.ts +0 -0
- /package/dist/{hoc → utils}/changed.d.ts +0 -0
- /package/dist/{hoc → utils}/hexToRgb.d.ts +0 -0
- /package/dist/{hoc → utils}/parseMultipleJson.d.ts +0 -0
- /package/src/api/{hoc/getStatefulObjectWithWhere.tsx → getStatefulObjectWithWhere.tsx} +0 -0
- /package/src/{hoc → dom}/scrollIntoView.tsx +0 -0
- /package/src/{hoc → dom}/uploadImage.tsx +0 -0
- /package/src/{api/hoc → dom}/watchInputElementChangeEvent.tsx +0 -0
- /package/src/{api/hoc → hooks}/useEffectOnce.tsx +0 -0
- /package/src/{hoc → routing}/GlobalHistory.tsx +0 -0
- /package/src/{variables → styles}/bootstrap.module.css +0 -0
- /package/src/{variables → styles}/bootstrap.module.css.d.ts +0 -0
- /package/src/{variables → styles}/bootstrap.module.css.json +0 -0
- /package/src/{variables → styles}/bootstrap.module.css.map +0 -0
- /package/src/{variables → styles}/bootstrap.module.scss +0 -0
- /package/src/{variables → styles}/bootstrap.module.scss.d.ts +0 -0
- /package/src/{hoc → testing}/addValidSQL.tsx +0 -0
- /package/src/{hoc → testing}/validSQL.tsx +0 -0
- /package/src/{hoc → types}/KeysMatching.ts +0 -0
- /package/src/{hoc → types}/SubsetMatching.ts +0 -0
- /package/src/{hoc → utils}/changed.tsx +0 -0
- /package/src/{hoc → utils}/hexToRgb.tsx +0 -0
- /package/src/{hoc → utils}/parseMultipleJson.tsx +0 -0
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import changed from "
|
|
2
|
-
import {GlobalHistory} from "
|
|
3
|
-
import hexToRgb from "hoc/hexToRgb";
|
|
1
|
+
import changed from "utils/changed";
|
|
2
|
+
import {GlobalHistory} from "routing/GlobalHistory";
|
|
4
3
|
import {Component, Context, createContext, ReactElement, ReactNode} from 'react';
|
|
5
4
|
import {ToastContainer} from 'react-toastify';
|
|
6
5
|
import 'react-toastify/dist/ReactToastify.css';
|
|
7
6
|
import BackendThrowable from 'components/Errors/BackendThrowable';
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import deleteRestfulObjectArrays, {iDeleteRestfulObjectArrays} from "./hoc/deleteRestfulObjectArrays";
|
|
7
|
+
import {initialRestfulObjectsState, iRestfulObjectArrayTypes} from "schema/C6";
|
|
8
|
+
import CarbonWebSocket, {iCarbonWebSocketProps} from "components/WebSocket/CarbonWebSocket";
|
|
9
|
+
import updateRestfulObjectArrays, {iUpdateRestfulObjectArrays} from "state/updateRestfulObjectArrays";
|
|
10
|
+
import deleteRestfulObjectArrays, {iDeleteRestfulObjectArrays} from "state/deleteRestfulObjectArrays";
|
|
13
11
|
import {BrowserRouter, HashRouter, MemoryRouter} from "react-router-dom";
|
|
14
12
|
|
|
15
13
|
export type tStatefulApiData<T extends { [key: string]: any } = {}> = T[] | undefined | null;
|
|
@@ -51,6 +49,8 @@ export enum eRouterType {
|
|
|
51
49
|
MemoryRouter,
|
|
52
50
|
}
|
|
53
51
|
|
|
52
|
+
const canUseDom = () => typeof window !== "undefined" && typeof document !== "undefined";
|
|
53
|
+
|
|
54
54
|
abstract class CarbonReact<P = {}, S extends iCarbonReactState = iCarbonReactState> extends Component<{
|
|
55
55
|
children?: ReactNode | ReactNode[],
|
|
56
56
|
instanceId?: string,
|
|
@@ -105,7 +105,7 @@ abstract class CarbonReact<P = {}, S extends iCarbonReactState = iCarbonReactSta
|
|
|
105
105
|
...rest
|
|
106
106
|
});
|
|
107
107
|
|
|
108
|
-
static lastLocation = window.location.pathname;
|
|
108
|
+
static lastLocation = typeof window === "undefined" ? "" : window.location.pathname;
|
|
109
109
|
|
|
110
110
|
static whyDidYouRender = true;
|
|
111
111
|
|
|
@@ -157,10 +157,10 @@ abstract class CarbonReact<P = {}, S extends iCarbonReactState = iCarbonReactSta
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
componentDidUpdate(_prevProps: Readonly<P>, _prevState: Readonly<S>, _snapshot?: any) {
|
|
160
|
-
if (CarbonReact.lastLocation !== location.pathname) {
|
|
160
|
+
if (typeof location !== "undefined" && CarbonReact.lastLocation !== location.pathname) {
|
|
161
161
|
CarbonReact.lastLocation = location.pathname;
|
|
162
162
|
const websocket = this.state.websocket;
|
|
163
|
-
if (websocket?.readyState === WebSocket.OPEN) {
|
|
163
|
+
if (typeof WebSocket !== "undefined" && websocket?.readyState === WebSocket.OPEN) {
|
|
164
164
|
websocket.send(location.pathname);
|
|
165
165
|
console.log(location.pathname);
|
|
166
166
|
}
|
|
@@ -168,7 +168,8 @@ abstract class CarbonReact<P = {}, S extends iCarbonReactState = iCarbonReactSta
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
reactRouterContext(children: ReactElement) {
|
|
171
|
-
|
|
171
|
+
const routerType = this.props.routerType ?? (canUseDom() ? eRouterType.BrowserRouter : eRouterType.MemoryRouter);
|
|
172
|
+
switch (routerType) {
|
|
172
173
|
case eRouterType.BrowserRouter:
|
|
173
174
|
return <BrowserRouter>{children}</BrowserRouter>
|
|
174
175
|
case eRouterType.MemoryRouter:
|
|
@@ -183,31 +184,24 @@ abstract class CarbonReact<P = {}, S extends iCarbonReactState = iCarbonReactSta
|
|
|
183
184
|
render(): ReactElement {
|
|
184
185
|
console.log('CarbonORM TSX RENDER');
|
|
185
186
|
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
console.log('%c color (' + colorHex + ')', 'color: ' + colorHex);
|
|
189
|
-
|
|
190
|
-
const nest = <Nest position={'fixed'} backgroundColor={''} color={hexToRgb(colorHex)} count={100}/>;
|
|
187
|
+
const canUseDomNow = canUseDom();
|
|
191
188
|
|
|
192
189
|
if (this.state.backendThrowable.length > 0) {
|
|
193
|
-
return
|
|
194
|
-
{nest}
|
|
195
|
-
<BackendThrowable instance={this}/>
|
|
196
|
-
</>;
|
|
190
|
+
return <BackendThrowable instance={this}/>;
|
|
197
191
|
}
|
|
198
192
|
|
|
199
193
|
this.context = createContext(this.state)
|
|
200
194
|
const Context = this.context.Provider;
|
|
201
195
|
|
|
202
196
|
return this.reactRouterContext(<>
|
|
203
|
-
<GlobalHistory/>
|
|
204
|
-
{this.props.websocket &&
|
|
197
|
+
{canUseDomNow && <GlobalHistory/>}
|
|
198
|
+
{canUseDomNow && this.props.websocket &&
|
|
205
199
|
<CarbonWebSocket<P, S> {...(false !== this.props.websocket ? this.props.websocket : {})}
|
|
206
200
|
instance={this}/>}
|
|
207
201
|
<Context value={this.state}>
|
|
208
202
|
{this.props.children}
|
|
209
203
|
</Context>
|
|
210
|
-
<ToastContainer/>
|
|
204
|
+
{canUseDomNow && <ToastContainer/>}
|
|
211
205
|
</>);
|
|
212
206
|
}
|
|
213
207
|
}
|
|
@@ -3,5 +3,7 @@
|
|
|
3
3
|
// Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) \
|
|
4
4
|
// Chrome/107.0.0.0 Safari/537.36 Edg/107.0.1418.26
|
|
5
5
|
|
|
6
|
-
const isEdgeBrowser = window
|
|
7
|
-
|
|
6
|
+
const isEdgeBrowser = typeof window !== "undefined"
|
|
7
|
+
&& typeof window.navigator !== "undefined"
|
|
8
|
+
&& window.navigator.userAgent.indexOf("Edg") > -1
|
|
9
|
+
export default isEdgeBrowser
|
|
@@ -11,7 +11,7 @@ export default function setCookies(cookies: string[], req: AxiosResponse | undef
|
|
|
11
11
|
.replace("HttpOnly", "")
|
|
12
12
|
.replace("secure", "");
|
|
13
13
|
|
|
14
|
-
if (document === undefined || document === null) {
|
|
14
|
+
if (typeof document === "undefined" || document === null) {
|
|
15
15
|
|
|
16
16
|
const getStackTrace = function () {
|
|
17
17
|
let obj: any = {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
function getProcessEnv(key: string): string | undefined {
|
|
2
|
+
// works in node + most polyfills
|
|
3
|
+
return typeof process !== "undefined" ? process.env?.[key] : undefined;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
function getViteEnv(key: string): string | undefined {
|
|
7
|
+
// IMPORTANT:
|
|
8
|
+
// this file must be ESM-compatible in any environment where it's executed
|
|
9
|
+
// because import.meta may not even parse in CJS contexts
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
return typeof import.meta !== "undefined" ? import.meta.env?.[key] : undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function getEnv<T = string>(key: string, fallback?: T): T {
|
|
15
|
+
// Prefer process.env in SSR/node (secrets, runtime config)
|
|
16
|
+
const proc = getProcessEnv(key);
|
|
17
|
+
if (proc !== undefined) return proc as T;
|
|
18
|
+
|
|
19
|
+
// Vite client / build-time vars
|
|
20
|
+
try {
|
|
21
|
+
const vite = getViteEnv(key);
|
|
22
|
+
if (vite !== undefined) return vite as T;
|
|
23
|
+
} catch {
|
|
24
|
+
// ignore
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (fallback !== undefined) return fallback;
|
|
28
|
+
throw new Error(`Missing required environment variable: ${key}`);
|
|
29
|
+
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { useState, useEffect } from 'react';
|
|
2
2
|
|
|
3
3
|
function getWindowDimensions() {
|
|
4
|
+
if (typeof window === "undefined") {
|
|
5
|
+
return { width: 0, height: 0 };
|
|
6
|
+
}
|
|
7
|
+
|
|
4
8
|
const { innerWidth: width, innerHeight: height } = window;
|
|
5
9
|
return {
|
|
6
10
|
width,
|
|
@@ -12,6 +16,10 @@ export default function useWindowDimensions() {
|
|
|
12
16
|
const [windowDimensions, setWindowDimensions] = useState(getWindowDimensions());
|
|
13
17
|
|
|
14
18
|
useEffect(() => {
|
|
19
|
+
if (typeof window === "undefined") {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
15
23
|
function handleResize() {
|
|
16
24
|
setWindowDimensions(getWindowDimensions());
|
|
17
25
|
}
|
|
@@ -21,4 +29,4 @@ export default function useWindowDimensions() {
|
|
|
21
29
|
}, []);
|
|
22
30
|
|
|
23
31
|
return windowDimensions;
|
|
24
|
-
}
|
|
32
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -2,13 +2,8 @@
|
|
|
2
2
|
* @file Automatically generated by barrelsby.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
export { default as
|
|
6
|
-
export * from "./
|
|
7
|
-
export { default as getStatefulObjectWithWhere } from "./api/hoc/getStatefulObjectWithWhere";
|
|
8
|
-
export * from "./api/hoc/getStatefulObjectWithWhere";
|
|
9
|
-
export * from "./api/hoc/useEffectOnce";
|
|
10
|
-
export { default as watchInputElementChangeEvent } from "./api/hoc/watchInputElementChangeEvent";
|
|
11
|
-
export * from "./api/hoc/watchInputElementChangeEvent";
|
|
5
|
+
export { default as getStatefulObjectWithWhere } from "./api/getStatefulObjectWithWhere";
|
|
6
|
+
export * from "./api/getStatefulObjectWithWhere";
|
|
12
7
|
export { default as Alert } from "./components/Alert/Alert";
|
|
13
8
|
export * from "./components/Alert/Alert";
|
|
14
9
|
export { default as AccessDenied } from "./components/Errors/AccessDenied";
|
|
@@ -21,46 +16,48 @@ export { default as PageNotFound } from "./components/Errors/PageNotFound";
|
|
|
21
16
|
export * from "./components/Errors/PageNotFound";
|
|
22
17
|
export { default as Loading } from "./components/Loading/Loading";
|
|
23
18
|
export * from "./components/Loading/Loading";
|
|
24
|
-
export { default as Nest } from "./components/Nest/Nest";
|
|
25
|
-
export * from "./components/Nest/Nest";
|
|
26
19
|
export { default as OutsideClickHandler } from "./components/OutsideClickHandler/OutsideClickHandler";
|
|
27
20
|
export * from "./components/OutsideClickHandler/OutsideClickHandler";
|
|
28
21
|
export { default as Popup } from "./components/Popup/Popup";
|
|
29
22
|
export * from "./components/Popup/Popup";
|
|
30
23
|
export { default as CarbonWebSocket } from "./components/WebSocket/CarbonWebSocket";
|
|
31
24
|
export * from "./components/WebSocket/CarbonWebSocket";
|
|
32
|
-
export
|
|
33
|
-
export * from "./
|
|
34
|
-
export
|
|
35
|
-
export
|
|
36
|
-
export
|
|
37
|
-
export
|
|
38
|
-
export
|
|
39
|
-
export
|
|
40
|
-
export
|
|
41
|
-
export
|
|
42
|
-
export
|
|
43
|
-
export
|
|
44
|
-
export * from "./
|
|
45
|
-
export { default as
|
|
46
|
-
export * from "./
|
|
47
|
-
export * from "./
|
|
48
|
-
export { default as
|
|
49
|
-
export * from "./
|
|
50
|
-
export
|
|
51
|
-
export * from "./
|
|
52
|
-
export { default as
|
|
53
|
-
export * from "./
|
|
54
|
-
export { default as
|
|
55
|
-
export * from "./
|
|
56
|
-
export { default as
|
|
57
|
-
export * from "./
|
|
58
|
-
export { default as
|
|
59
|
-
export * from "./
|
|
60
|
-
export { default as
|
|
61
|
-
export * from "./
|
|
62
|
-
export { default as
|
|
63
|
-
export * from "./
|
|
64
|
-
export * from "./
|
|
65
|
-
export
|
|
66
|
-
export
|
|
25
|
+
export { default as CarbonReact } from "./core/CarbonReact";
|
|
26
|
+
export * from "./core/CarbonReact";
|
|
27
|
+
export { default as isEdgeBrowser } from "./dom/isEdgeBrowser";
|
|
28
|
+
export * from "./dom/isEdgeBrowser";
|
|
29
|
+
export { default as scrollIntoView } from "./dom/scrollIntoView";
|
|
30
|
+
export * from "./dom/scrollIntoView";
|
|
31
|
+
export { default as setCookies } from "./dom/setCookies";
|
|
32
|
+
export * from "./dom/setCookies";
|
|
33
|
+
export { default as uploadImage } from "./dom/uploadImage";
|
|
34
|
+
export * from "./dom/uploadImage";
|
|
35
|
+
export { default as watchInputElementChangeEvent } from "./dom/watchInputElementChangeEvent";
|
|
36
|
+
export * from "./dom/watchInputElementChangeEvent";
|
|
37
|
+
export * from "./env/getEnv";
|
|
38
|
+
export { default as isProduction } from "./env/isProduction";
|
|
39
|
+
export * from "./env/isProduction";
|
|
40
|
+
export * from "./hooks/useEffectOnce";
|
|
41
|
+
export { default as windowDimensions } from "./hooks/windowDimensions";
|
|
42
|
+
export * from "./hooks/windowDimensions";
|
|
43
|
+
export * from "./routing/GlobalHistory";
|
|
44
|
+
export * from "./schema/C6";
|
|
45
|
+
export { default as deleteRestfulObjectArrays } from "./state/deleteRestfulObjectArrays";
|
|
46
|
+
export * from "./state/deleteRestfulObjectArrays";
|
|
47
|
+
export { default as updateRestfulObjectArrays } from "./state/updateRestfulObjectArrays";
|
|
48
|
+
export * from "./state/updateRestfulObjectArrays";
|
|
49
|
+
export { default as getStyles } from "./styles/getStyles";
|
|
50
|
+
export * from "./styles/getStyles";
|
|
51
|
+
export { default as addValidSQL } from "./testing/addValidSQL";
|
|
52
|
+
export * from "./testing/addValidSQL";
|
|
53
|
+
export { default as setupTests } from "./testing/setupTests";
|
|
54
|
+
export * from "./testing/setupTests";
|
|
55
|
+
export { default as validSQL } from "./testing/validSQL";
|
|
56
|
+
export * from "./testing/validSQL";
|
|
57
|
+
export * from "./types/KeysMatching";
|
|
58
|
+
export * from "./types/SubsetMatching";
|
|
59
|
+
export { default as changed } from "./utils/changed";
|
|
60
|
+
export * from "./utils/changed";
|
|
61
|
+
export { default as hexToRgb } from "./utils/hexToRgb";
|
|
62
|
+
export * from "./utils/hexToRgb";
|
|
63
|
+
export * from "./utils/parseMultipleJson";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { tStatefulApiData } from "CarbonReact";
|
|
1
|
+
import { tStatefulApiData } from "core/CarbonReact";
|
|
2
2
|
|
|
3
3
|
export interface stringMap {
|
|
4
4
|
[key: string]: string;
|
|
@@ -3301,4 +3301,3 @@ export const initialRestfulObjectsState: iRestfulObjectArrayTypes = {
|
|
|
3301
3301
|
|
|
3302
3302
|
export type tRestfulObjectArrayValues = iRestfulObjectArrayTypes[keyof iRestfulObjectArrayTypes];
|
|
3303
3303
|
|
|
3304
|
-
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import CarbonReact, { iCarbonReactState, tStatefulApiData } from "CarbonReact";
|
|
2
|
-
import { KeysMatching } from "
|
|
1
|
+
import CarbonReact, { iCarbonReactState, tStatefulApiData } from "core/CarbonReact";
|
|
2
|
+
import { KeysMatching } from "types/KeysMatching";
|
|
3
3
|
|
|
4
4
|
export interface iDeleteRestfulObjectArrays<
|
|
5
5
|
ObjectType extends {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import CarbonReact, { iCarbonReactState, tStatefulApiData } from "CarbonReact";
|
|
2
|
-
import { KeysMatching } from "
|
|
3
|
-
import { SubsetMatching } from "
|
|
1
|
+
import CarbonReact, { iCarbonReactState, tStatefulApiData } from "core/CarbonReact";
|
|
2
|
+
import { KeysMatching } from "types/KeysMatching";
|
|
3
|
+
import { SubsetMatching } from "types/SubsetMatching";
|
|
4
4
|
|
|
5
5
|
export enum eUpdateInsertMethod {
|
|
6
6
|
REPLACE,
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import classNames from "classnames";
|
|
2
|
-
import BootstrapStyle from "
|
|
2
|
+
import BootstrapStyle from "styles/bootstrap.module.css"
|
|
3
3
|
import Styles from "style.module.css"
|
|
4
4
|
|
|
5
5
|
export const getRootStyleValue = (property = '--dig_primary_color') : string => {
|
|
6
6
|
|
|
7
|
+
if (typeof document === "undefined" || typeof getComputedStyle === "undefined") {
|
|
8
|
+
return "";
|
|
9
|
+
}
|
|
10
|
+
|
|
7
11
|
return getComputedStyle(document.documentElement)
|
|
8
12
|
.getPropertyValue(property).trim();
|
|
9
13
|
|
|
@@ -41,4 +45,4 @@ export default function getStyles<iCSS extends {}>(overrides: iCSS = {} as iCSS)
|
|
|
41
45
|
|
|
42
46
|
return mergeStyles(dropStyles, overrides)
|
|
43
47
|
|
|
44
|
-
}
|
|
48
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {axiosInstance, checkAllRequestsComplete, isVerbose} from "@carbonorm/carbonnode";
|
|
2
|
-
import {
|
|
2
|
+
import {createRequire} from "module";
|
|
3
3
|
import ValidSQL, {validSQL} from "./validSQL";
|
|
4
4
|
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
6
|
+
|
|
5
7
|
export default function ({sqlDirectory = './logs/rest/', logsDirectory = './logs/tests/'}: {
|
|
6
8
|
sqlDirectory?: string,
|
|
7
9
|
logsDirectory?: string
|
|
@@ -9,6 +11,7 @@ export default function ({sqlDirectory = './logs/rest/', logsDirectory = './logs
|
|
|
9
11
|
|
|
10
12
|
const fs = require("fs");
|
|
11
13
|
const {inspect} = require("util");
|
|
14
|
+
const {waitFor} = require("@testing-library/react");
|
|
12
15
|
|
|
13
16
|
const originalWindowLocation = window.location.href
|
|
14
17
|
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
export declare const range: (n: any) => number[];
|
|
3
|
-
interface iTwoD {
|
|
4
|
-
max: number;
|
|
5
|
-
x: number | null;
|
|
6
|
-
y: number | null;
|
|
7
|
-
}
|
|
8
|
-
interface iTwoDAnimated extends iTwoD {
|
|
9
|
-
ya: number;
|
|
10
|
-
xa: number;
|
|
11
|
-
}
|
|
12
|
-
type NestProps = typeof Nest.defaultProps & {
|
|
13
|
-
children?: any;
|
|
14
|
-
position: "relative" | "-moz-initial" | "inherit" | "initial" | "revert" | "unset" | "-webkit-sticky" | "absolute" | "fixed" | "static" | "sticky";
|
|
15
|
-
};
|
|
16
|
-
export default class Nest extends React.Component<NestProps, {}> {
|
|
17
|
-
static defaultProps: {
|
|
18
|
-
backgroundColor: string;
|
|
19
|
-
display: string;
|
|
20
|
-
top: number;
|
|
21
|
-
left: number;
|
|
22
|
-
zIndex: number;
|
|
23
|
-
count: number;
|
|
24
|
-
opacity: number;
|
|
25
|
-
overflow: string;
|
|
26
|
-
color: string;
|
|
27
|
-
pointColor: string;
|
|
28
|
-
position: string;
|
|
29
|
-
};
|
|
30
|
-
canvas?: HTMLCanvasElement;
|
|
31
|
-
all: Array<iTwoDAnimated | iTwoD>;
|
|
32
|
-
points?: Array<iTwoDAnimated>;
|
|
33
|
-
current: iTwoD;
|
|
34
|
-
constructor(props: any);
|
|
35
|
-
canvasContext?: CanvasRenderingContext2D;
|
|
36
|
-
componentDidMount(): void;
|
|
37
|
-
randomPoints: () => {
|
|
38
|
-
x: number;
|
|
39
|
-
y: number;
|
|
40
|
-
xa: number;
|
|
41
|
-
ya: number;
|
|
42
|
-
max: number;
|
|
43
|
-
}[];
|
|
44
|
-
tid: number;
|
|
45
|
-
drawCanvas: () => void;
|
|
46
|
-
destroy(): void;
|
|
47
|
-
render(): import("react/jsx-runtime").JSX.Element;
|
|
48
|
-
}
|
|
49
|
-
export {};
|
package/dist/hoc/setUrl.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function setUrl(host?: string, https?: boolean): void;
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
import {toastOptions} from "@carbonorm/carbonnode";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import {toast} from "react-toastify";
|
|
4
|
-
|
|
5
|
-
export const range = n =>
|
|
6
|
-
new Array(n).fill(0).map((_, idx) => idx);
|
|
7
|
-
|
|
8
|
-
//export const canvasStyle = config =>
|
|
9
|
-
// `display:block;position:absolute;top:0;left:0;height:100%;width:100%;overflow:hidden;pointer-events:none;z-index:${config.zIndex};opacity:${config.opacity}`;
|
|
10
|
-
|
|
11
|
-
interface iTwoD {
|
|
12
|
-
max: number,
|
|
13
|
-
x: number | null,
|
|
14
|
-
y: number | null,
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface iTwoDAnimated extends iTwoD {
|
|
18
|
-
ya: number,
|
|
19
|
-
xa: number
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
type NestProps = typeof Nest.defaultProps & {
|
|
23
|
-
children?: any;
|
|
24
|
-
position: "relative" | "-moz-initial" | "inherit" | "initial" | "revert" | "unset" | "-webkit-sticky" | "absolute" | "fixed" | "static" | "sticky",
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// @link https://sites.google.com/site/webglbook/home/chapter-3
|
|
28
|
-
export default class Nest extends React.Component<NestProps, {
|
|
29
|
-
// updating react state will re-run the render method.
|
|
30
|
-
// this is un necessary overhead with canvas apps.
|
|
31
|
-
}> {
|
|
32
|
-
static defaultProps = {
|
|
33
|
-
backgroundColor: "white",
|
|
34
|
-
display:"block",
|
|
35
|
-
top: 0,
|
|
36
|
-
left: 0,
|
|
37
|
-
zIndex: -1,
|
|
38
|
-
count: 99,
|
|
39
|
-
opacity: 0.5,
|
|
40
|
-
overflow: "hidden",
|
|
41
|
-
color: '255,255,255',
|
|
42
|
-
pointColor: '255,0,0',
|
|
43
|
-
position: "relative"
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
canvas?: HTMLCanvasElement;
|
|
47
|
-
|
|
48
|
-
all: Array<iTwoDAnimated | iTwoD> = [];
|
|
49
|
-
|
|
50
|
-
points?: Array<iTwoDAnimated>;
|
|
51
|
-
|
|
52
|
-
current: iTwoD = {
|
|
53
|
-
x: 0, // current mouse x
|
|
54
|
-
y: 0, // current mouse y
|
|
55
|
-
max: 20000 // circle radius squared
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
constructor(props) {
|
|
59
|
-
super(props);
|
|
60
|
-
this.state ={}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
canvasContext ?: CanvasRenderingContext2D;
|
|
64
|
-
|
|
65
|
-
componentDidMount() {
|
|
66
|
-
|
|
67
|
-
this.canvas = document.getElementById('2d') as HTMLCanvasElement;
|
|
68
|
-
|
|
69
|
-
this.canvasContext = this.canvas.getContext('2d') || undefined;
|
|
70
|
-
|
|
71
|
-
if (undefined === this.canvasContext) {
|
|
72
|
-
|
|
73
|
-
toast.warn('Your browser does not support Canvas! Some features may not work as expected.', toastOptions)
|
|
74
|
-
|
|
75
|
-
return;
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
this.points = this.randomPoints();
|
|
80
|
-
|
|
81
|
-
this.all = this.all?.concat(this.points,
|
|
82
|
-
[this.current]
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
if (undefined === this.canvas) {
|
|
86
|
-
|
|
87
|
-
toast.error('Failed to load Canvas! Some features may not work as expected.', toastOptions)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
document.onmousemove = e => {
|
|
94
|
-
this.current.x = e.clientX; // - this.el.offsetLeft + document.scrollingElement.scrollLeft; // 当存在横向滚动条时,x坐标再往右移动滚动条拉动的距离
|
|
95
|
-
this.current.y = e.clientY; // - this.el.offsetTop + document.scrollingElement.scrollTop; // 当存在纵向滚动条时,y坐标再往下移动滚动条拉动的距离
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
this.canvas.onmouseout = () => {
|
|
99
|
-
this.current.x = null;
|
|
100
|
-
this.current.y = null;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
this.drawCanvas()
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
randomPoints = () => {
|
|
108
|
-
return range(this.props.count).map(() => ({
|
|
109
|
-
x: Math.random() * window.innerWidth,
|
|
110
|
-
y: Math.random() * window.innerHeight,
|
|
111
|
-
xa: 2 * Math.random() - 1, // 随机运动返现
|
|
112
|
-
ya: 2 * Math.random() - 1,
|
|
113
|
-
max: 6000 // Adhesion distance
|
|
114
|
-
}));
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
tid = 0;
|
|
119
|
-
|
|
120
|
-
drawCanvas = () => {
|
|
121
|
-
|
|
122
|
-
const context = this.canvasContext;
|
|
123
|
-
const width = window.innerWidth;
|
|
124
|
-
const height = window.innerHeight;
|
|
125
|
-
const current = this.current;
|
|
126
|
-
const points = this.points;
|
|
127
|
-
const all = this.all;
|
|
128
|
-
|
|
129
|
-
if (undefined === context
|
|
130
|
-
|| undefined === current
|
|
131
|
-
|| undefined === points
|
|
132
|
-
) {
|
|
133
|
-
alert('context, current, or points was undefined. quitting.')
|
|
134
|
-
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
context.clearRect(0, 0, width, height);
|
|
139
|
-
|
|
140
|
-
// random line and current position associative array
|
|
141
|
-
let e, i, d, x_dist, y_dist, dist; // temporary node
|
|
142
|
-
|
|
143
|
-
// Iterate through each point
|
|
144
|
-
points.forEach((r, idx) => {
|
|
145
|
-
|
|
146
|
-
r.x = r.x || 0;
|
|
147
|
-
|
|
148
|
-
r.y = r.y || 0;
|
|
149
|
-
|
|
150
|
-
r.x += r.xa;
|
|
151
|
-
|
|
152
|
-
r.y += r.ya; // move
|
|
153
|
-
|
|
154
|
-
r.xa *= r.x > width || r.x < 0 ? -1 : 1;
|
|
155
|
-
|
|
156
|
-
r.ya *= r.y > height || r.y < 0 ? -1 : 1; // Hit the boundary, bounce back
|
|
157
|
-
|
|
158
|
-
context.fillStyle = `rgba(${this.props.pointColor})`;
|
|
159
|
-
|
|
160
|
-
context.fillRect(r.x - 0.5, r.y - 0.5, 1, 1); // Draw a point with a width and height of 1
|
|
161
|
-
|
|
162
|
-
// start from next point
|
|
163
|
-
for (i = idx + 1; i < all.length; i++) {
|
|
164
|
-
|
|
165
|
-
e = all[i];
|
|
166
|
-
|
|
167
|
-
if (null !== e.x && null !== e.y) {
|
|
168
|
-
|
|
169
|
-
x_dist = r.x - e.x; // x-axis distance l
|
|
170
|
-
|
|
171
|
-
y_dist = r.y - e.y; // y-axis n
|
|
172
|
-
|
|
173
|
-
dist = x_dist * x_dist + y_dist * y_dist; // total distance, m
|
|
174
|
-
|
|
175
|
-
if (dist > e.max) {
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (e === current && dist >= e.max / 2) {
|
|
180
|
-
|
|
181
|
-
r.x -= 0.03 * x_dist;
|
|
182
|
-
|
|
183
|
-
r.y -= 0.03 * y_dist;
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
d = (e.max - dist) / e.max;
|
|
188
|
-
|
|
189
|
-
context.beginPath();
|
|
190
|
-
|
|
191
|
-
context.lineWidth = d / 2;
|
|
192
|
-
|
|
193
|
-
context.strokeStyle = `rgba(${this.props.color},${d + 0.2})`;
|
|
194
|
-
|
|
195
|
-
context.moveTo(r.x, r.y);
|
|
196
|
-
|
|
197
|
-
context.lineTo(e.x, e.y);
|
|
198
|
-
|
|
199
|
-
context.stroke();
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
requestAnimationFrame(this.drawCanvas);
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
destroy() {
|
|
212
|
-
|
|
213
|
-
cancelAnimationFrame(this.tid);
|
|
214
|
-
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
render() {
|
|
218
|
-
|
|
219
|
-
return (
|
|
220
|
-
<div>
|
|
221
|
-
{this.props.children}
|
|
222
|
-
<canvas
|
|
223
|
-
id={"2d"}
|
|
224
|
-
width={window.innerWidth}
|
|
225
|
-
height={window.innerHeight}
|
|
226
|
-
style={{
|
|
227
|
-
backgroundColor: this.props.backgroundColor,
|
|
228
|
-
display:this.props.display,
|
|
229
|
-
position: this.props.position,
|
|
230
|
-
top: this.props.top,
|
|
231
|
-
left: this.props.left,
|
|
232
|
-
overflow: this.props.overflow,
|
|
233
|
-
zIndex: this.props.zIndex,
|
|
234
|
-
opacity: this.props.opacity
|
|
235
|
-
}}/>
|
|
236
|
-
</div>
|
|
237
|
-
);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
}
|
|
241
|
-
|