@carbonorm/carbonreact 5.0.4 → 6.0.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.
Files changed (79) hide show
  1. package/dist/components/Alert/Alert.d.ts +1 -1
  2. package/dist/components/Errors/BackendThrowable.d.ts +1 -1
  3. package/dist/components/WebSocket/CarbonWebSocket.d.ts +1 -1
  4. package/dist/{CarbonReact.d.ts → core/CarbonReact.d.ts} +4 -4
  5. package/dist/env/getEnv.d.ts +1 -0
  6. package/dist/env/isProduction.d.ts +2 -0
  7. package/dist/index.cjs +690 -782
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.css +5101 -5101
  10. package/dist/index.css.map +1 -1
  11. package/dist/index.d.ts +41 -44
  12. package/dist/index.esm.css +5101 -5101
  13. package/dist/index.esm.css.map +1 -1
  14. package/dist/index.esm.js +674 -765
  15. package/dist/index.esm.js.map +1 -1
  16. package/dist/{variables → schema}/C6.d.ts +1 -1
  17. package/dist/{hoc → state}/deleteRestfulObjectArrays.d.ts +2 -2
  18. package/dist/{hoc → state}/updateRestfulObjectArrays.d.ts +2 -2
  19. package/dist/{hoc → styles}/getStyles.d.ts +1 -1
  20. package/package.json +2 -2
  21. package/src/components/Alert/Alert.tsx +4 -5
  22. package/src/components/Errors/BackendThrowable.tsx +2 -2
  23. package/src/components/Loading/Loading.tsx +1 -2
  24. package/src/components/Popup/Popup.tsx +1 -2
  25. package/src/components/WebSocket/CarbonWebSocket.tsx +11 -3
  26. package/src/{CarbonReact.tsx → core/CarbonReact.tsx} +18 -24
  27. package/src/{hoc → dom}/isEdgeBrowser.tsx +4 -2
  28. package/src/{hoc → dom}/setCookies.tsx +1 -1
  29. package/src/env/getEnv.ts +29 -0
  30. package/src/env/isProduction.tsx +6 -0
  31. package/src/{hoc → hooks}/windowDimensions.tsx +9 -1
  32. package/src/index.ts +41 -44
  33. package/src/{variables → schema}/C6.tsx +1 -2
  34. package/src/{hoc → state}/deleteRestfulObjectArrays.tsx +2 -2
  35. package/src/{hoc → state}/updateRestfulObjectArrays.tsx +3 -3
  36. package/src/{hoc → styles}/getStyles.tsx +6 -2
  37. package/src/{hoc → testing}/setupTests.tsx +34 -8
  38. package/dist/components/Nest/Nest.d.ts +0 -49
  39. package/dist/hoc/setUrl.d.ts +0 -1
  40. package/dist/variables/isProduction.d.ts +0 -2
  41. package/src/components/Nest/Nest.tsx +0 -241
  42. package/src/hoc/setUrl.tsx +0 -38
  43. package/src/variables/isProduction.tsx +0 -5
  44. /package/dist/api/{hoc/getStatefulObjectWithWhere.d.ts → getStatefulObjectWithWhere.d.ts} +0 -0
  45. /package/dist/{hoc → dom}/isEdgeBrowser.d.ts +0 -0
  46. /package/dist/{hoc → dom}/scrollIntoView.d.ts +0 -0
  47. /package/dist/{hoc → dom}/setCookies.d.ts +0 -0
  48. /package/dist/{hoc → dom}/uploadImage.d.ts +0 -0
  49. /package/dist/{api/hoc → dom}/watchInputElementChangeEvent.d.ts +0 -0
  50. /package/dist/{api/hoc → hooks}/useEffectOnce.d.ts +0 -0
  51. /package/dist/{hoc → hooks}/windowDimensions.d.ts +0 -0
  52. /package/dist/{hoc → routing}/GlobalHistory.d.ts +0 -0
  53. /package/dist/{hoc → testing}/addValidSQL.d.ts +0 -0
  54. /package/dist/{hoc → testing}/setupTests.d.ts +0 -0
  55. /package/dist/{hoc → testing}/validSQL.d.ts +0 -0
  56. /package/dist/{hoc → types}/KeysMatching.d.ts +0 -0
  57. /package/dist/{hoc → types}/SubsetMatching.d.ts +0 -0
  58. /package/dist/{hoc → utils}/changed.d.ts +0 -0
  59. /package/dist/{hoc → utils}/hexToRgb.d.ts +0 -0
  60. /package/dist/{hoc → utils}/parseMultipleJson.d.ts +0 -0
  61. /package/src/api/{hoc/getStatefulObjectWithWhere.tsx → getStatefulObjectWithWhere.tsx} +0 -0
  62. /package/src/{hoc → dom}/scrollIntoView.tsx +0 -0
  63. /package/src/{hoc → dom}/uploadImage.tsx +0 -0
  64. /package/src/{api/hoc → dom}/watchInputElementChangeEvent.tsx +0 -0
  65. /package/src/{api/hoc → hooks}/useEffectOnce.tsx +0 -0
  66. /package/src/{hoc → routing}/GlobalHistory.tsx +0 -0
  67. /package/src/{variables → styles}/bootstrap.module.css +0 -0
  68. /package/src/{variables → styles}/bootstrap.module.css.d.ts +0 -0
  69. /package/src/{variables → styles}/bootstrap.module.css.json +0 -0
  70. /package/src/{variables → styles}/bootstrap.module.css.map +0 -0
  71. /package/src/{variables → styles}/bootstrap.module.scss +0 -0
  72. /package/src/{variables → styles}/bootstrap.module.scss.d.ts +0 -0
  73. /package/src/{hoc → testing}/addValidSQL.tsx +0 -0
  74. /package/src/{hoc → testing}/validSQL.tsx +0 -0
  75. /package/src/{hoc → types}/KeysMatching.ts +0 -0
  76. /package/src/{hoc → types}/SubsetMatching.ts +0 -0
  77. /package/src/{hoc → utils}/changed.tsx +0 -0
  78. /package/src/{hoc → utils}/hexToRgb.tsx +0 -0
  79. /package/src/{hoc → utils}/parseMultipleJson.tsx +0 -0
@@ -1,15 +1,13 @@
1
- import changed from "hoc/changed";
2
- import {GlobalHistory} from "hoc/GlobalHistory";
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 Nest from 'components/Nest/Nest';
9
- import {initialRestfulObjectsState, iRestfulObjectArrayTypes} from "variables/C6";
10
- import CarbonWebSocket, {iCarbonWebSocketProps} from "./components/WebSocket/CarbonWebSocket";
11
- import updateRestfulObjectArrays, {iUpdateRestfulObjectArrays} from "./hoc/updateRestfulObjectArrays";
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
- switch (this.props.routerType ?? eRouterType.BrowserRouter) {
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 colorHex = '#' + Math.random().toString(16).slice(-6);
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.navigator.userAgent.indexOf("Edg") > -1
7
- export default isEdgeBrowser
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
+ }
@@ -0,0 +1,6 @@
1
+ import {getEnv} from "./getEnv";
2
+
3
+ // @ts-ignore
4
+ const isProduction = () => getEnv("NODE_ENV", "") === "production"
5
+
6
+ export default isProduction
@@ -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 CarbonReact } from "./CarbonReact";
6
- export * from "./CarbonReact";
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 * from "./hoc/GlobalHistory";
33
- export * from "./hoc/KeysMatching";
34
- export * from "./hoc/SubsetMatching";
35
- export { default as addValidSQL } from "./hoc/addValidSQL";
36
- export * from "./hoc/addValidSQL";
37
- export { default as changed } from "./hoc/changed";
38
- export * from "./hoc/changed";
39
- export { default as deleteRestfulObjectArrays } from "./hoc/deleteRestfulObjectArrays";
40
- export * from "./hoc/deleteRestfulObjectArrays";
41
- export { default as getStyles } from "./hoc/getStyles";
42
- export * from "./hoc/getStyles";
43
- export { default as hexToRgb } from "./hoc/hexToRgb";
44
- export * from "./hoc/hexToRgb";
45
- export { default as isEdgeBrowser } from "./hoc/isEdgeBrowser";
46
- export * from "./hoc/isEdgeBrowser";
47
- export * from "./hoc/parseMultipleJson";
48
- export { default as scrollIntoView } from "./hoc/scrollIntoView";
49
- export * from "./hoc/scrollIntoView";
50
- export { default as setCookies } from "./hoc/setCookies";
51
- export * from "./hoc/setCookies";
52
- export { default as setUrl } from "./hoc/setUrl";
53
- export * from "./hoc/setUrl";
54
- export { default as setupTests } from "./hoc/setupTests";
55
- export * from "./hoc/setupTests";
56
- export { default as updateRestfulObjectArrays } from "./hoc/updateRestfulObjectArrays";
57
- export * from "./hoc/updateRestfulObjectArrays";
58
- export { default as uploadImage } from "./hoc/uploadImage";
59
- export * from "./hoc/uploadImage";
60
- export { default as validSQL } from "./hoc/validSQL";
61
- export * from "./hoc/validSQL";
62
- export { default as windowDimensions } from "./hoc/windowDimensions";
63
- export * from "./hoc/windowDimensions";
64
- export * from "./variables/C6";
65
- export { default as isProduction } from "./variables/isProduction";
66
- export * from "./variables/isProduction";
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 "./KeysMatching";
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 "./KeysMatching";
3
- import { SubsetMatching } from "./SubsetMatching";
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 "variables/bootstrap.module.css"
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,14 +1,34 @@
1
1
  import {axiosInstance, checkAllRequestsComplete, isVerbose} from "@carbonorm/carbonnode";
2
- import {waitFor} from "@testing-library/react";
3
2
  import ValidSQL, {validSQL} from "./validSQL";
4
3
 
4
+ const nodeModulePromise = typeof process !== "undefined" && process.versions?.node
5
+ ? Promise.all([
6
+ import("node:fs"),
7
+ import("node:util"),
8
+ import("@testing-library/react"),
9
+ ])
10
+ : null;
11
+
12
+ const getNodeModules = async () => {
13
+ if (!nodeModulePromise) {
14
+ throw new Error("setupTests requires a Node runtime.");
15
+ }
16
+
17
+ const [fsModule, utilModule, testingLib] = await nodeModulePromise;
18
+ return {
19
+ fs: fsModule,
20
+ inspect: utilModule.inspect,
21
+ waitFor: testingLib.waitFor,
22
+ };
23
+ };
24
+
5
25
  export default function ({sqlDirectory = './logs/rest/', logsDirectory = './logs/tests/'}: {
6
26
  sqlDirectory?: string,
7
27
  logsDirectory?: string
8
28
  } = {}) {
9
-
10
- const fs = require("fs");
11
- const {inspect} = require("util");
29
+ if (!nodeModulePromise) {
30
+ throw new Error("setupTests requires a Node runtime.");
31
+ }
12
32
 
13
33
  const originalWindowLocation = window.location.href
14
34
 
@@ -36,10 +56,14 @@ export default function ({sqlDirectory = './logs/rest/', logsDirectory = './logs
36
56
  })
37
57
 
38
58
  // @link https://stackoverflow.com/questions/13542667/create-directory-when-writing-to-file-in-node-js
39
- const asyncFileLogging = async (...args) => fs.writeFileSync(
40
- logsFile(),
41
- '\n' + inspect(args.length === 1 ? args.pop() : args, false, 10, true),
42
- {flag: "a+"});
59
+ const asyncFileLogging = async (...args) => {
60
+ const {fs, inspect} = await getNodeModules();
61
+ fs.writeFileSync(
62
+ logsFile(),
63
+ '\n' + inspect(args.length === 1 ? args.pop() : args, false, 10, true),
64
+ {flag: "a+"}
65
+ );
66
+ };
43
67
 
44
68
  global.console = {
45
69
  ...console,
@@ -61,6 +85,8 @@ export default function ({sqlDirectory = './logs/rest/', logsDirectory = './logs
61
85
 
62
86
  afterEach(async () => {
63
87
 
88
+ const {waitFor, fs} = await getNodeModules();
89
+
64
90
  await waitFor(async () => {
65
91
 
66
92
  expect(checkAllRequestsComplete()).toEqual(true);
@@ -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 {};
@@ -1 +0,0 @@
1
- export default function setUrl(host?: string, https?: boolean): void;
@@ -1,2 +0,0 @@
1
- declare const isProduction: boolean;
2
- export default isProduction;