rasengan 1.0.0-beta.2 → 1.0.0-beta.3
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/lib/cli/dirname.js +0 -1
- package/lib/cli/index.js +0 -1
- package/lib/config/index.d.ts +6 -0
- package/lib/config/index.js +9 -1
- package/lib/config/type.d.ts +1 -1
- package/lib/config/type.js +0 -1
- package/lib/core/components/index.js +0 -1
- package/lib/core/index.js +0 -1
- package/lib/core/interfaces.js +0 -1
- package/lib/core/types.js +0 -1
- package/lib/decorators/index.js +0 -1
- package/lib/decorators/route.js +0 -1
- package/lib/decorators/router.js +0 -1
- package/lib/decorators/types.js +0 -1
- package/lib/entries/entry-client.js +0 -1
- package/lib/entries/entry-server.js +0 -1
- package/lib/hooks/index.js +0 -1
- package/lib/index.js +0 -1
- package/lib/routing/components/index.js +0 -1
- package/lib/routing/index.js +0 -1
- package/lib/routing/interfaces.js +0 -1
- package/lib/routing/types.js +0 -1
- package/lib/routing/utils/index.js +0 -1
- package/lib/server/functions/vercel/api/index.js +0 -1
- package/lib/server/utils/createFetchRequest.js +0 -1
- package/lib/server/utils/getIp.js +0 -1
- package/lib/server/utils/handleError.js +0 -1
- package/lib/server/utils/index.js +0 -1
- package/lib/server/utils/log.js +0 -1
- package/package.json +3 -4
- package/tsconfig.lib.json +1 -1
- package/vite.config.ts +10 -1
- package/src/cli/dirname.ts +0 -7
- package/src/cli/index.ts +0 -134
- package/src/config/index.ts +0 -67
- package/src/config/type.ts +0 -76
- package/src/core/components/index.tsx +0 -95
- package/src/core/index.ts +0 -14
- package/src/core/interfaces.tsx +0 -129
- package/src/core/types.ts +0 -43
- package/src/decorators/index.ts +0 -2
- package/src/decorators/route.ts +0 -32
- package/src/decorators/router.ts +0 -30
- package/src/decorators/types.ts +0 -54
- package/src/entries/entry-client.tsx +0 -33
- package/src/entries/entry-server.tsx +0 -50
- package/src/hooks/index.ts +0 -0
- package/src/index.ts +0 -11
- package/src/routing/components/index.tsx +0 -125
- package/src/routing/index.ts +0 -23
- package/src/routing/interfaces.ts +0 -105
- package/src/routing/types.ts +0 -3
- package/src/routing/utils/index.tsx +0 -342
- package/src/server/functions/vercel/api/index.ts +0 -122
- package/src/server/functions/vercel/vercel.json +0 -12
- package/src/server/utils/createFetchRequest.ts +0 -40
- package/src/server/utils/getIp.ts +0 -37
- package/src/server/utils/handleError.ts +0 -36
- package/src/server/utils/index.ts +0 -15
- package/src/server/utils/log.ts +0 -115
- package/src/vite-env.d.ts +0 -1
package/lib/cli/dirname.js
CHANGED
package/lib/cli/index.js
CHANGED
package/lib/config/index.d.ts
CHANGED
|
@@ -31,6 +31,12 @@ export declare const defineConfig: (loadedConfig: AppConfig) => {
|
|
|
31
31
|
};
|
|
32
32
|
} | {
|
|
33
33
|
reactStrictMode: boolean;
|
|
34
|
+
vite: {
|
|
35
|
+
optimizeDeps: {
|
|
36
|
+
exclude: string[];
|
|
37
|
+
};
|
|
38
|
+
appType: string;
|
|
39
|
+
};
|
|
34
40
|
};
|
|
35
41
|
/**
|
|
36
42
|
* Function to adapt the path for dev and prod
|
package/lib/config/index.js
CHANGED
|
@@ -34,6 +34,15 @@ export const defineConfig = (loadedConfig) => {
|
|
|
34
34
|
console.error(error);
|
|
35
35
|
return {
|
|
36
36
|
reactStrictMode: true,
|
|
37
|
+
vite: {
|
|
38
|
+
optimizeDeps: {
|
|
39
|
+
exclude: [
|
|
40
|
+
"node:http",
|
|
41
|
+
"node-fetch",
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
appType: "custom",
|
|
45
|
+
}
|
|
37
46
|
};
|
|
38
47
|
}
|
|
39
48
|
};
|
|
@@ -54,4 +63,3 @@ export const adaptPath = (paths) => {
|
|
|
54
63
|
// If the path is a string
|
|
55
64
|
return `${prefix}${paths}`;
|
|
56
65
|
};
|
|
57
|
-
//# sourceMappingURL=index.js.map
|
package/lib/config/type.d.ts
CHANGED
package/lib/config/type.js
CHANGED
package/lib/core/index.js
CHANGED
package/lib/core/interfaces.js
CHANGED
package/lib/core/types.js
CHANGED
package/lib/decorators/index.js
CHANGED
package/lib/decorators/route.js
CHANGED
package/lib/decorators/router.js
CHANGED
package/lib/decorators/types.js
CHANGED
|
@@ -12,4 +12,3 @@ import * as pkg from "react-helmet-async";
|
|
|
12
12
|
// @ts-ignore
|
|
13
13
|
const { HelmetProvider } = pkg.default || pkg;
|
|
14
14
|
ReactDOM.hydrateRoot(document.getElementById("root"), config.reactStrictMode ? (_jsx(React.StrictMode, { children: _jsx(ErrorBoundary, { children: _jsx(HelmetProvider, { children: _jsx(App, { Component: Component }) }) }) })) : (_jsx(ErrorBoundary, { children: _jsx(HelmetProvider, { children: _jsx(App, { Component: Component }) }) })));
|
|
15
|
-
//# sourceMappingURL=entry-client.js.map
|
package/lib/hooks/index.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js
CHANGED
package/lib/routing/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { defineRouteLayout, defineRoutePage, defineRouter, } from "./utils/index.js";
|
|
2
2
|
export { RouterComponent } from "./interfaces.js";
|
|
3
3
|
export { Outlet, Link, useLocation, useNavigate, useParams, useSearchParams, useFetcher, useMatch, useRoutes, useResolvedPath, matchRoutes, generatePath, matchPath, createRoutesFromChildren, Navigate, } from "react-router-dom";
|
|
4
|
-
//# sourceMappingURL=index.js.map
|
package/lib/routing/types.js
CHANGED
package/lib/server/utils/log.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rasengan",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.0.0-beta.
|
|
4
|
+
"version": "1.0.0-beta.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"bin": {
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"url": "https://github.com/rasengan/rasengan.git",
|
|
20
20
|
"issues": "https://github.com/rasengan/rasengan/issues"
|
|
21
21
|
},
|
|
22
|
+
"homepage": "https://rasengan.dev",
|
|
22
23
|
"scripts": {
|
|
23
24
|
"dev": "node server",
|
|
24
25
|
"build": "npm run build:client && npm run build:server",
|
|
@@ -43,11 +44,10 @@
|
|
|
43
44
|
"keypress": "^0.2.1",
|
|
44
45
|
"node-fetch": "^3.3.2",
|
|
45
46
|
"ora": "^7.0.1",
|
|
46
|
-
"react-helmet": "^6.1.0",
|
|
47
47
|
"react-helmet-async": "^2.0.4",
|
|
48
48
|
"react-router-dom": "^6.20.1",
|
|
49
49
|
"sirv": "^2.0.3",
|
|
50
|
-
"vite": "^5.0.
|
|
50
|
+
"vite": "^5.0.12",
|
|
51
51
|
"vite-plugin-css": "^1.0.4"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
@@ -61,7 +61,6 @@
|
|
|
61
61
|
"@types/node": "^20.8.6",
|
|
62
62
|
"@types/react": "^18.2.28",
|
|
63
63
|
"@types/react-dom": "^18.2.13",
|
|
64
|
-
"@types/react-helmet": "^6.1.8",
|
|
65
64
|
"cross-env": "^7.0.3",
|
|
66
65
|
"typescript": "^5.2.2"
|
|
67
66
|
},
|
package/tsconfig.lib.json
CHANGED
package/vite.config.ts
CHANGED
|
@@ -5,14 +5,23 @@ import react from "@vitejs/plugin-react";
|
|
|
5
5
|
// @ts-ignore
|
|
6
6
|
import config from "./../../rasengan.config.js";
|
|
7
7
|
|
|
8
|
+
// Importing __dirname
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
import { fileURLToPath } from "url";
|
|
11
|
+
import path, { dirname } from "path";
|
|
12
|
+
|
|
8
13
|
// Extract vite config
|
|
9
14
|
const { vite } = config;
|
|
10
15
|
|
|
16
|
+
// Getting root path
|
|
17
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
18
|
+
const __pathToRoot = path.resolve(__dirname, "./../../");
|
|
19
|
+
|
|
11
20
|
export default defineConfig({
|
|
12
21
|
plugins: [react(), ...vite?.plugins],
|
|
13
22
|
|
|
14
23
|
// define index.html location
|
|
15
|
-
root:
|
|
24
|
+
root: __pathToRoot,
|
|
16
25
|
optimizeDeps: {
|
|
17
26
|
exclude: [
|
|
18
27
|
"node:http",
|
package/src/cli/dirname.ts
DELETED
package/src/cli/index.ts
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import chalk from "chalk";
|
|
3
|
-
import { Command } from "commander";
|
|
4
|
-
import __dirname from "./dirname.js";
|
|
5
|
-
import { execa } from "execa";
|
|
6
|
-
|
|
7
|
-
// Config
|
|
8
|
-
|
|
9
|
-
// @ts-ignore
|
|
10
|
-
import config from "../../../../rasengan.config.js";
|
|
11
|
-
|
|
12
|
-
const program = new Command();
|
|
13
|
-
|
|
14
|
-
program
|
|
15
|
-
.name(chalk.blue("rasengan"))
|
|
16
|
-
.version("1.0.0", "-v, --version", "Output the current version number");
|
|
17
|
-
|
|
18
|
-
// Handle the dev command
|
|
19
|
-
program
|
|
20
|
-
.command("dev")
|
|
21
|
-
.option("-p <port>")
|
|
22
|
-
.description("Start development server")
|
|
23
|
-
.action(async ({ p: port }: { p: number }) => {
|
|
24
|
-
const convertedPort = Number(port);
|
|
25
|
-
|
|
26
|
-
// Checking port
|
|
27
|
-
if (
|
|
28
|
-
port &&
|
|
29
|
-
(isNaN(convertedPort) || convertedPort < 0 || convertedPort > 65535)
|
|
30
|
-
) {
|
|
31
|
-
console.log("");
|
|
32
|
-
console.log(
|
|
33
|
-
chalk.red("Please provide a valid port number between 0-65535")
|
|
34
|
-
);
|
|
35
|
-
console.log("");
|
|
36
|
-
process.exit(1);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
execa("node", ["node_modules/rasengan/server"], {
|
|
40
|
-
stdio: "inherit",
|
|
41
|
-
env: {
|
|
42
|
-
...process.env,
|
|
43
|
-
PORT: convertedPort ? convertedPort.toString() : undefined,
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
// Handle the build command
|
|
49
|
-
program
|
|
50
|
-
.command("build")
|
|
51
|
-
.description("Build the project")
|
|
52
|
-
.action(() => {
|
|
53
|
-
// const childProcess = exec("npm --prefix node_modules/rasengan run build");
|
|
54
|
-
execa("npm", ["run", "build"], {
|
|
55
|
-
cwd: "node_modules/rasengan",
|
|
56
|
-
stdio: "inherit", // Pipe child process output to the parent process
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
// Handle the prebuild command
|
|
61
|
-
program
|
|
62
|
-
.command("prebuild")
|
|
63
|
-
.description("Prebuild the project")
|
|
64
|
-
.action(() => {
|
|
65
|
-
// Displaying the message
|
|
66
|
-
console.log("");
|
|
67
|
-
console.log(chalk.blue("Prebuilding your project..."));
|
|
68
|
-
console.log("");
|
|
69
|
-
|
|
70
|
-
// Checking the config file in order to know about hosting strategy
|
|
71
|
-
const { server } = config;
|
|
72
|
-
|
|
73
|
-
const hostingStrategy = server?.production?.hosting ?? "custom";
|
|
74
|
-
|
|
75
|
-
if (hostingStrategy === "vercel") {
|
|
76
|
-
// Displaying the message
|
|
77
|
-
console.log(
|
|
78
|
-
`Your project is configured to be hosted on ${chalk.bold.blue(
|
|
79
|
-
hostingStrategy
|
|
80
|
-
)}\n`
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
// Copying the api folder to the root directory
|
|
84
|
-
execa(
|
|
85
|
-
"cp",
|
|
86
|
-
["-r", "node_modules/rasengan/lib/server/functions/vercel/api", "."],
|
|
87
|
-
{
|
|
88
|
-
stdio: "inherit",
|
|
89
|
-
}
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
// Copying the vercel.json file to the root directory
|
|
93
|
-
execa(
|
|
94
|
-
"cp",
|
|
95
|
-
["node_modules/rasengan/src/server/functions/vercel/vercel.json", "."],
|
|
96
|
-
{
|
|
97
|
-
stdio: "inherit",
|
|
98
|
-
}
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
// Removing index.d.ts and index.js.map files from the api folder
|
|
102
|
-
execa("rm", ["api/index.d.ts", "api/index.js.map"], {
|
|
103
|
-
stdio: "inherit",
|
|
104
|
-
});
|
|
105
|
-
} else if (hostingStrategy === "netlify") {
|
|
106
|
-
// Copying the netlify.toml file to the root directory
|
|
107
|
-
// execa(
|
|
108
|
-
// "cp",
|
|
109
|
-
// ["node_modules/rasengan/src/server/functions/netlify/netlify.toml", "."],
|
|
110
|
-
// {
|
|
111
|
-
// stdio: "inherit",
|
|
112
|
-
// }
|
|
113
|
-
// );
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
// Handle the start command
|
|
118
|
-
program
|
|
119
|
-
.command("start")
|
|
120
|
-
.description("Start the project in production mode")
|
|
121
|
-
.action(async () => {
|
|
122
|
-
const childProcess = execa("npm", ["run", "preview"], {
|
|
123
|
-
cwd: "node_modules/rasengan",
|
|
124
|
-
stdio: "inherit", // Pipe child process output to the parent process
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
childProcess.on("close", (code) => {
|
|
128
|
-
if (code === 0) {
|
|
129
|
-
process.stdout.write("Project started Succesfully");
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
program.parse(process.argv);
|
package/src/config/index.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { type AppConfig } from "./type.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Function to define the config for the app
|
|
5
|
-
* It will be used by vite.config.ts and other files in other to configure the app
|
|
6
|
-
* @param {AppConfig} loadedConfig
|
|
7
|
-
*/
|
|
8
|
-
export const defineConfig = (loadedConfig: AppConfig) => {
|
|
9
|
-
const { reactStrictMode, server, vite } = loadedConfig;
|
|
10
|
-
|
|
11
|
-
try {
|
|
12
|
-
const config = {
|
|
13
|
-
reactStrictMode: reactStrictMode === undefined ? true : reactStrictMode,
|
|
14
|
-
server,
|
|
15
|
-
vite: {
|
|
16
|
-
plugins: vite?.plugins || [],
|
|
17
|
-
|
|
18
|
-
optimizeDeps: {
|
|
19
|
-
exclude: [
|
|
20
|
-
"node:http",
|
|
21
|
-
"node-fetch",
|
|
22
|
-
...(vite?.optimizeDeps?.exclude || []),
|
|
23
|
-
],
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
css: {
|
|
27
|
-
postcss: vite?.css?.postcss || undefined,
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
build: {
|
|
31
|
-
external: vite?.build?.external || [],
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
appType: "custom",
|
|
35
|
-
},
|
|
36
|
-
// More config options...
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
return config;
|
|
40
|
-
} catch (error) {
|
|
41
|
-
console.error(error);
|
|
42
|
-
return {
|
|
43
|
-
reactStrictMode: true,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Function to adapt the path for dev and prod
|
|
50
|
-
* @param {string | Array<string>} paths
|
|
51
|
-
*/
|
|
52
|
-
export const adaptPath = (paths: string | Array<string>) => {
|
|
53
|
-
// Check if we are in dev mode or prod
|
|
54
|
-
const isProduction = process.env.NODE_ENV === "production";
|
|
55
|
-
const prefix = isProduction ? "./../../" : "";
|
|
56
|
-
|
|
57
|
-
// Chech if the path is an array
|
|
58
|
-
const isArray = Array.isArray(paths);
|
|
59
|
-
|
|
60
|
-
// If the path is an array
|
|
61
|
-
if (isArray) {
|
|
62
|
-
return paths.map((path) => `${prefix}${path}`);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// If the path is a string
|
|
66
|
-
return `${prefix}${paths}`;
|
|
67
|
-
}
|
package/src/config/type.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
export type AppConfig = {
|
|
2
|
-
/**
|
|
3
|
-
* Enable strict mode
|
|
4
|
-
* @default true
|
|
5
|
-
*/
|
|
6
|
-
reactStrictMode?: boolean;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Configure server both in development and production
|
|
10
|
-
*/
|
|
11
|
-
server?: {
|
|
12
|
-
/**
|
|
13
|
-
* Configure server in development
|
|
14
|
-
*/
|
|
15
|
-
development?: {
|
|
16
|
-
/**
|
|
17
|
-
* Port to listen on
|
|
18
|
-
* @default 3000
|
|
19
|
-
*/
|
|
20
|
-
port?: number;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Configure server in production
|
|
25
|
-
*/
|
|
26
|
-
production?: {
|
|
27
|
-
/**
|
|
28
|
-
* Set the hosting strategy
|
|
29
|
-
* @default "custom"
|
|
30
|
-
*/
|
|
31
|
-
hosting?: HostingStrategy;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Configure Vite
|
|
37
|
-
*/
|
|
38
|
-
vite?: {
|
|
39
|
-
/**
|
|
40
|
-
* Configure Vite plugins
|
|
41
|
-
*/
|
|
42
|
-
plugins?: any[];
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Optimize dependencies
|
|
46
|
-
*/
|
|
47
|
-
optimizeDeps?: {
|
|
48
|
-
exclude?: string[];
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Configure css options
|
|
53
|
-
*/
|
|
54
|
-
css?: {
|
|
55
|
-
postcss?: {
|
|
56
|
-
plugins?: any[];
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Configure build options
|
|
62
|
-
*/
|
|
63
|
-
build?: {
|
|
64
|
-
/**
|
|
65
|
-
* Configure external dependencies
|
|
66
|
-
*/
|
|
67
|
-
external?: string[];
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
// More config options...
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Hosting strategy
|
|
75
|
-
*/
|
|
76
|
-
export type HostingStrategy = "vercel" | "netlify" | "heroku" | "custom";
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { ComponentProps, PageToRenderProps } from "../types.js";
|
|
3
|
-
import { getRouter } from "../../routing/utils/index.js";
|
|
4
|
-
import * as pkg from "react-helmet-async";
|
|
5
|
-
|
|
6
|
-
// @ts-ignore
|
|
7
|
-
const { Helmet } = pkg.default || pkg;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* App component that represent the entry point of the application
|
|
11
|
-
*/
|
|
12
|
-
export const Component = ({ router: AppRouter }: ComponentProps) => {
|
|
13
|
-
const Router = getRouter(AppRouter);
|
|
14
|
-
|
|
15
|
-
return <Router />;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Page component that defines title and description to a page
|
|
20
|
-
*/
|
|
21
|
-
export const PageToRender = ({ page, data }: PageToRenderProps) => {
|
|
22
|
-
// Get the page component
|
|
23
|
-
const Page = page.render;
|
|
24
|
-
|
|
25
|
-
// Get the page props
|
|
26
|
-
const props = data.props || {};
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<React.Fragment>
|
|
30
|
-
<Helmet>
|
|
31
|
-
<title>{page.title}</title>
|
|
32
|
-
<meta name="description" content={page.description} />
|
|
33
|
-
</Helmet>
|
|
34
|
-
|
|
35
|
-
<Page {...props} />
|
|
36
|
-
</React.Fragment>
|
|
37
|
-
);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Error fallback component that will be displayed if an error occurs
|
|
42
|
-
*/
|
|
43
|
-
export class ErrorBoundary extends React.Component {
|
|
44
|
-
state = { hasError: false, error: null, info: null };
|
|
45
|
-
|
|
46
|
-
componentDidCatch(error: any, info: any) {
|
|
47
|
-
this.setState({ hasError: true, error, info });
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
render() {
|
|
51
|
-
const { error, info } = this.state;
|
|
52
|
-
|
|
53
|
-
if (this.state.hasError) {
|
|
54
|
-
return <ErrorFallbackComponent error={error} info={info} />;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// @ts-ignore
|
|
58
|
-
return this.props.children
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Error fallback component that will be displayed if an error occurs
|
|
64
|
-
*/
|
|
65
|
-
const ErrorFallbackComponent = ({ error, info }: any) => {
|
|
66
|
-
console.log({ error, info });
|
|
67
|
-
return (
|
|
68
|
-
<div
|
|
69
|
-
style={{
|
|
70
|
-
width: "calc(100% - 80px)",
|
|
71
|
-
height: "calc(100vh - 80px)",
|
|
72
|
-
padding: "40px",
|
|
73
|
-
backgroundColor: "#fff",
|
|
74
|
-
}}
|
|
75
|
-
>
|
|
76
|
-
<div>
|
|
77
|
-
<h1 style={{ fontSize: "2rem" }}>Something went wrong</h1>
|
|
78
|
-
<p>{error.toString()}</p>
|
|
79
|
-
|
|
80
|
-
<div
|
|
81
|
-
style={{
|
|
82
|
-
width: "100%",
|
|
83
|
-
height: "auto",
|
|
84
|
-
borderRadius: 10,
|
|
85
|
-
padding: "20px",
|
|
86
|
-
marginTop: "10px",
|
|
87
|
-
backgroundColor: "#f0f0f0",
|
|
88
|
-
}}
|
|
89
|
-
>
|
|
90
|
-
<p>{info.componentStack}</p>
|
|
91
|
-
</div>
|
|
92
|
-
</div>
|
|
93
|
-
</div>
|
|
94
|
-
);
|
|
95
|
-
};
|
package/src/core/index.ts
DELETED