rasengan 1.0.0-beta.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/LICENSE +21 -0
- package/lib/cli/dirname.d.ts +2 -0
- package/lib/cli/dirname.js +6 -0
- package/lib/cli/dirname.js.map +1 -0
- package/lib/cli/index.d.ts +2 -0
- package/lib/cli/index.js +101 -0
- package/lib/cli/index.js.map +1 -0
- package/lib/config/index.d.ts +39 -0
- package/lib/config/index.js +57 -0
- package/lib/config/index.js.map +1 -0
- package/lib/config/type.d.ts +68 -0
- package/lib/config/type.js +2 -0
- package/lib/config/type.js.map +1 -0
- package/lib/core/components/index.d.ts +26 -0
- package/lib/core/components/index.js +72 -0
- package/lib/core/components/index.js.map +1 -0
- package/lib/core/index.d.ts +2 -0
- package/lib/core/index.js +2 -0
- package/lib/core/index.js.map +1 -0
- package/lib/core/interfaces.d.ts +76 -0
- package/lib/core/interfaces.js +91 -0
- package/lib/core/interfaces.js.map +1 -0
- package/lib/core/types.d.ts +45 -0
- package/lib/core/types.js +2 -0
- package/lib/core/types.js.map +1 -0
- package/lib/decorators/index.d.ts +2 -0
- package/lib/decorators/index.js +3 -0
- package/lib/decorators/index.js.map +1 -0
- package/lib/decorators/route.d.ts +7 -0
- package/lib/decorators/route.js +25 -0
- package/lib/decorators/route.js.map +1 -0
- package/lib/decorators/router.d.ts +7 -0
- package/lib/decorators/router.js +24 -0
- package/lib/decorators/router.js.map +1 -0
- package/lib/decorators/types.d.ts +47 -0
- package/lib/decorators/types.js +2 -0
- package/lib/decorators/types.js.map +1 -0
- package/lib/entries/entry-client.d.ts +1 -0
- package/lib/entries/entry-client.js +15 -0
- package/lib/entries/entry-client.js.map +1 -0
- package/lib/entries/entry-server.d.ts +6 -0
- package/lib/entries/entry-server.js +20 -0
- package/lib/entries/entry-server.js.map +1 -0
- package/lib/hooks/index.d.ts +0 -0
- package/lib/hooks/index.js +1 -0
- package/lib/hooks/index.js.map +1 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +10 -0
- package/lib/index.js.map +1 -0
- package/lib/routing/components/index.d.ts +32 -0
- package/lib/routing/components/index.js +69 -0
- package/lib/routing/components/index.js.map +1 -0
- package/lib/routing/index.d.ts +3 -0
- package/lib/routing/index.js +4 -0
- package/lib/routing/index.js.map +1 -0
- package/lib/routing/interfaces.d.ts +67 -0
- package/lib/routing/interfaces.js +88 -0
- package/lib/routing/interfaces.js.map +1 -0
- package/lib/routing/types.d.ts +4 -0
- package/lib/routing/types.js +2 -0
- package/lib/routing/types.js.map +1 -0
- package/lib/routing/utils/index.d.ts +40 -0
- package/lib/routing/utils/index.js +256 -0
- package/lib/routing/utils/index.js.map +1 -0
- package/lib/server/functions/vercel/api/index.d.ts +2 -0
- package/lib/server/functions/vercel/api/index.js +91 -0
- package/lib/server/functions/vercel/api/index.js.map +1 -0
- package/lib/server/functions/vercel/vercel.json +12 -0
- package/lib/server/utils/createFetchRequest.d.ts +5 -0
- package/lib/server/utils/createFetchRequest.js +34 -0
- package/lib/server/utils/createFetchRequest.js.map +1 -0
- package/lib/server/utils/getIp.d.ts +1 -0
- package/lib/server/utils/getIp.js +30 -0
- package/lib/server/utils/getIp.js.map +1 -0
- package/lib/server/utils/handleError.d.ts +2 -0
- package/lib/server/utils/handleError.js +28 -0
- package/lib/server/utils/handleError.js.map +1 -0
- package/lib/server/utils/index.d.ts +5 -0
- package/lib/server/utils/index.js +8 -0
- package/lib/server/utils/index.js.map +1 -0
- package/lib/server/utils/log.d.ts +6 -0
- package/lib/server/utils/log.js +69 -0
- package/lib/server/utils/log.js.map +1 -0
- package/package.json +75 -0
- package/server.js +229 -0
- package/src/cli/dirname.ts +7 -0
- package/src/cli/index.ts +134 -0
- package/src/config/index.ts +67 -0
- package/src/config/type.ts +76 -0
- package/src/core/components/index.tsx +111 -0
- package/src/core/index.ts +14 -0
- package/src/core/interfaces.tsx +129 -0
- package/src/core/types.ts +43 -0
- package/src/decorators/index.ts +2 -0
- package/src/decorators/route.ts +32 -0
- package/src/decorators/router.ts +30 -0
- package/src/decorators/types.ts +54 -0
- package/src/entries/entry-client.tsx +33 -0
- package/src/entries/entry-server.tsx +50 -0
- package/src/hooks/index.ts +0 -0
- package/src/index.ts +11 -0
- package/src/routing/components/index.tsx +125 -0
- package/src/routing/index.ts +23 -0
- package/src/routing/interfaces.ts +105 -0
- package/src/routing/types.ts +3 -0
- package/src/routing/utils/index.tsx +342 -0
- package/src/server/functions/vercel/api/index.ts +122 -0
- package/src/server/functions/vercel/vercel.json +12 -0
- package/src/server/utils/createFetchRequest.ts +40 -0
- package/src/server/utils/getIp.ts +37 -0
- package/src/server/utils/handleError.ts +36 -0
- package/src/server/utils/index.ts +15 -0
- package/src/server/utils/log.ts +115 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.json +30 -0
- package/tsconfig.lib.json +41 -0
- package/tsconfig.node.json +11 -0
- package/vite.config.ts +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-Present Dilane Kombou
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dirname.js","sourceRoot":"","sources":["../../src/cli/dirname.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC,eAAe,SAAS,CAAC"}
|
package/lib/cli/index.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
import { execa } from "execa";
|
|
5
|
+
// Config
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
import config from "../../../../rasengan.config.js";
|
|
8
|
+
const program = new Command();
|
|
9
|
+
program
|
|
10
|
+
.name(chalk.blue("rasengan"))
|
|
11
|
+
.version("1.0.0", "-v, --version", "Output the current version number");
|
|
12
|
+
// Handle the dev command
|
|
13
|
+
program
|
|
14
|
+
.command("dev")
|
|
15
|
+
.option("-p <port>")
|
|
16
|
+
.description("Start development server")
|
|
17
|
+
.action(async ({ p: port }) => {
|
|
18
|
+
const convertedPort = Number(port);
|
|
19
|
+
// Checking port
|
|
20
|
+
if (port &&
|
|
21
|
+
(isNaN(convertedPort) || convertedPort < 0 || convertedPort > 65535)) {
|
|
22
|
+
console.log("");
|
|
23
|
+
console.log(chalk.red("Please provide a valid port number between 0-65535"));
|
|
24
|
+
console.log("");
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
execa("node", ["node_modules/rasengan/server"], {
|
|
28
|
+
stdio: "inherit",
|
|
29
|
+
env: {
|
|
30
|
+
...process.env,
|
|
31
|
+
PORT: convertedPort ? convertedPort.toString() : undefined,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
// Handle the build command
|
|
36
|
+
program
|
|
37
|
+
.command("build")
|
|
38
|
+
.description("Build the project")
|
|
39
|
+
.action(() => {
|
|
40
|
+
// const childProcess = exec("npm --prefix node_modules/rasengan run build");
|
|
41
|
+
execa("npm", ["run", "build"], {
|
|
42
|
+
cwd: "node_modules/rasengan",
|
|
43
|
+
stdio: "inherit", // Pipe child process output to the parent process
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
// Handle the prebuild command
|
|
47
|
+
program
|
|
48
|
+
.command("prebuild")
|
|
49
|
+
.description("Prebuild the project")
|
|
50
|
+
.action(() => {
|
|
51
|
+
// Displaying the message
|
|
52
|
+
console.log("");
|
|
53
|
+
console.log(chalk.blue("Prebuilding your project..."));
|
|
54
|
+
console.log("");
|
|
55
|
+
// Checking the config file in order to know about hosting strategy
|
|
56
|
+
const { server } = config;
|
|
57
|
+
const hostingStrategy = server?.production?.hosting ?? "custom";
|
|
58
|
+
if (hostingStrategy === "vercel") {
|
|
59
|
+
// Displaying the message
|
|
60
|
+
console.log(`Your project is configured to be hosted on ${chalk.bold.blue(hostingStrategy)}\n`);
|
|
61
|
+
// Copying the api folder to the root directory
|
|
62
|
+
execa("cp", ["-r", "node_modules/rasengan/lib/server/functions/vercel/api", "."], {
|
|
63
|
+
stdio: "inherit",
|
|
64
|
+
});
|
|
65
|
+
// Copying the vercel.json file to the root directory
|
|
66
|
+
execa("cp", ["node_modules/rasengan/src/server/functions/vercel/vercel.json", "."], {
|
|
67
|
+
stdio: "inherit",
|
|
68
|
+
});
|
|
69
|
+
// Removing index.d.ts and index.js.map files from the api folder
|
|
70
|
+
execa("rm", ["api/index.d.ts", "api/index.js.map"], {
|
|
71
|
+
stdio: "inherit",
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
else if (hostingStrategy === "netlify") {
|
|
75
|
+
// Copying the netlify.toml file to the root directory
|
|
76
|
+
// execa(
|
|
77
|
+
// "cp",
|
|
78
|
+
// ["node_modules/rasengan/src/server/functions/netlify/netlify.toml", "."],
|
|
79
|
+
// {
|
|
80
|
+
// stdio: "inherit",
|
|
81
|
+
// }
|
|
82
|
+
// );
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
// Handle the start command
|
|
86
|
+
program
|
|
87
|
+
.command("start")
|
|
88
|
+
.description("Start the project in production mode")
|
|
89
|
+
.action(async () => {
|
|
90
|
+
const childProcess = execa("npm", ["run", "preview"], {
|
|
91
|
+
cwd: "node_modules/rasengan",
|
|
92
|
+
stdio: "inherit", // Pipe child process output to the parent process
|
|
93
|
+
});
|
|
94
|
+
childProcess.on("close", (code) => {
|
|
95
|
+
if (code === 0) {
|
|
96
|
+
process.stdout.write("Project started Succesfully");
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
program.parse(process.argv);
|
|
101
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B,SAAS;AAET,aAAa;AACb,OAAO,MAAM,MAAM,gCAAgC,CAAC;AAEpD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC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OAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,sCAAsC,CAAC;KACnD,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,MAAM,YAAY,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE;QACpD,GAAG,EAAE,uBAAuB;QAC5B,KAAK,EAAE,SAAS,EAAE,kDAAkD;KACrE,CAAC,CAAC;IAEH,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;QAChC,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;YACf,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACtD,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type AppConfig } from "./type.js";
|
|
2
|
+
/**
|
|
3
|
+
* Function to define the config for the app
|
|
4
|
+
* It will be used by vite.config.ts and other files in other to configure the app
|
|
5
|
+
* @param {AppConfig} loadedConfig
|
|
6
|
+
*/
|
|
7
|
+
export declare const defineConfig: (loadedConfig: AppConfig) => {
|
|
8
|
+
reactStrictMode: boolean;
|
|
9
|
+
server: {
|
|
10
|
+
development?: {
|
|
11
|
+
port?: number;
|
|
12
|
+
};
|
|
13
|
+
production?: {
|
|
14
|
+
hosting?: import("./type.js").HostingStrategy;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
vite: {
|
|
18
|
+
plugins: any[];
|
|
19
|
+
optimizeDeps: {
|
|
20
|
+
exclude: string[];
|
|
21
|
+
};
|
|
22
|
+
css: {
|
|
23
|
+
postcss: {
|
|
24
|
+
plugins?: any[];
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
build: {
|
|
28
|
+
external: string[];
|
|
29
|
+
};
|
|
30
|
+
appType: string;
|
|
31
|
+
};
|
|
32
|
+
} | {
|
|
33
|
+
reactStrictMode: boolean;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Function to adapt the path for dev and prod
|
|
37
|
+
* @param {string | Array<string>} paths
|
|
38
|
+
*/
|
|
39
|
+
export declare const adaptPath: (paths: string | Array<string>) => string | string[];
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function to define the config for the app
|
|
3
|
+
* It will be used by vite.config.ts and other files in other to configure the app
|
|
4
|
+
* @param {AppConfig} loadedConfig
|
|
5
|
+
*/
|
|
6
|
+
export const defineConfig = (loadedConfig) => {
|
|
7
|
+
const { reactStrictMode, server, vite } = loadedConfig;
|
|
8
|
+
try {
|
|
9
|
+
const config = {
|
|
10
|
+
reactStrictMode: reactStrictMode === undefined ? true : reactStrictMode,
|
|
11
|
+
server,
|
|
12
|
+
vite: {
|
|
13
|
+
plugins: vite?.plugins || [],
|
|
14
|
+
optimizeDeps: {
|
|
15
|
+
exclude: [
|
|
16
|
+
"node:http",
|
|
17
|
+
"node-fetch",
|
|
18
|
+
...(vite?.optimizeDeps?.exclude || []),
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
css: {
|
|
22
|
+
postcss: vite?.css?.postcss || undefined,
|
|
23
|
+
},
|
|
24
|
+
build: {
|
|
25
|
+
external: vite?.build?.external || [],
|
|
26
|
+
},
|
|
27
|
+
appType: "custom",
|
|
28
|
+
},
|
|
29
|
+
// More config options...
|
|
30
|
+
};
|
|
31
|
+
return config;
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
console.error(error);
|
|
35
|
+
return {
|
|
36
|
+
reactStrictMode: true,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Function to adapt the path for dev and prod
|
|
42
|
+
* @param {string | Array<string>} paths
|
|
43
|
+
*/
|
|
44
|
+
export const adaptPath = (paths) => {
|
|
45
|
+
// Check if we are in dev mode or prod
|
|
46
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
47
|
+
const prefix = isProduction ? "./../../" : "";
|
|
48
|
+
// Chech if the path is an array
|
|
49
|
+
const isArray = Array.isArray(paths);
|
|
50
|
+
// If the path is an array
|
|
51
|
+
if (isArray) {
|
|
52
|
+
return paths.map((path) => `${prefix}${path}`);
|
|
53
|
+
}
|
|
54
|
+
// If the path is a string
|
|
55
|
+
return `${prefix}${paths}`;
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,YAAuB,EAAE,EAAE;IACtD,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,YAAY,CAAC;IAEvD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG;YACb,eAAe,EAAE,eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe;YACvE,MAAM;YACN,IAAI,EAAE;gBACJ,OAAO,EAAE,IAAI,EAAE,OAAO,IAAI,EAAE;gBAE5B,YAAY,EAAE;oBACZ,OAAO,EAAE;wBACP,WAAW;wBACX,YAAY;wBACZ,GAAG,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,IAAI,EAAE,CAAC;qBACvC;iBACF;gBAED,GAAG,EAAE;oBACH,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,IAAI,SAAS;iBACzC;gBAED,KAAK,EAAE;oBACL,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,IAAI,EAAE;iBACtC;gBAED,OAAO,EAAE,QAAQ;aAClB;YACD,yBAAyB;SAC1B,CAAC;QAEF,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrB,OAAO;YACL,eAAe,EAAE,IAAI;SACtB,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAA6B,EAAE,EAAE;IACzD,sCAAsC;IACtC,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC;IAC3D,MAAM,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;IAE9C,gCAAgC;IAChC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAErC,0BAA0B;IAC1B,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,MAAM,GAAG,IAAI,EAAE,CAAC,CAAC;IACjD,CAAC;IAED,0BAA0B;IAC1B,OAAO,GAAG,MAAM,GAAG,KAAK,EAAE,CAAC;AAC7B,CAAC,CAAA"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export type AppConfig = {
|
|
2
|
+
/**
|
|
3
|
+
* Enable strict mode
|
|
4
|
+
* @default true
|
|
5
|
+
*/
|
|
6
|
+
reactStrictMode?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Configure server both in development and production
|
|
9
|
+
*/
|
|
10
|
+
server?: {
|
|
11
|
+
/**
|
|
12
|
+
* Configure server in development
|
|
13
|
+
*/
|
|
14
|
+
development?: {
|
|
15
|
+
/**
|
|
16
|
+
* Port to listen on
|
|
17
|
+
* @default 3000
|
|
18
|
+
*/
|
|
19
|
+
port?: number;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Configure server in production
|
|
23
|
+
*/
|
|
24
|
+
production?: {
|
|
25
|
+
/**
|
|
26
|
+
* Set the hosting strategy
|
|
27
|
+
* @default "custom"
|
|
28
|
+
*/
|
|
29
|
+
hosting?: HostingStrategy;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Configure Vite
|
|
34
|
+
*/
|
|
35
|
+
vite?: {
|
|
36
|
+
/**
|
|
37
|
+
* Configure Vite plugins
|
|
38
|
+
*/
|
|
39
|
+
plugins?: any[];
|
|
40
|
+
/**
|
|
41
|
+
* Optimize dependencies
|
|
42
|
+
*/
|
|
43
|
+
optimizeDeps?: {
|
|
44
|
+
exclude?: string[];
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Configure css options
|
|
48
|
+
*/
|
|
49
|
+
css?: {
|
|
50
|
+
postcss?: {
|
|
51
|
+
plugins?: any[];
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Configure build options
|
|
56
|
+
*/
|
|
57
|
+
build?: {
|
|
58
|
+
/**
|
|
59
|
+
* Configure external dependencies
|
|
60
|
+
*/
|
|
61
|
+
external?: string[];
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Hosting strategy
|
|
67
|
+
*/
|
|
68
|
+
export type HostingStrategy = "vercel" | "netlify" | "heroku" | "custom";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/config/type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ComponentProps, PageToRenderProps } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* App component that represent the entry point of the application
|
|
5
|
+
*/
|
|
6
|
+
export declare const Component: ({ router: AppRouter }: ComponentProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
/**
|
|
8
|
+
* Page component that defines title and description to a page
|
|
9
|
+
*/
|
|
10
|
+
export declare const PageToRender: ({ page, data }: PageToRenderProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
/**
|
|
12
|
+
* Error fallback component that will be displayed if an error occurs
|
|
13
|
+
*/
|
|
14
|
+
export declare class ErrorBoundary extends React.Component {
|
|
15
|
+
state: {
|
|
16
|
+
hasError: boolean;
|
|
17
|
+
error: any;
|
|
18
|
+
info: any;
|
|
19
|
+
};
|
|
20
|
+
componentDidCatch(error: any, info: any): void;
|
|
21
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Error fallback component that will be displayed if an error occurs during a routing
|
|
25
|
+
*/
|
|
26
|
+
export declare const RouteErrorBoundary: ({ children }: any) => any;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { getRouter } from "../../routing/utils/index.js";
|
|
4
|
+
import * as pkg from "react-helmet-async";
|
|
5
|
+
import { useRouteError } from "react-router-dom";
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
const { Helmet } = pkg.default || pkg;
|
|
8
|
+
/**
|
|
9
|
+
* App component that represent the entry point of the application
|
|
10
|
+
*/
|
|
11
|
+
export const Component = ({ router: AppRouter }) => {
|
|
12
|
+
const Router = getRouter(AppRouter);
|
|
13
|
+
return _jsx(Router, {});
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Page component that defines title and description to a page
|
|
17
|
+
*/
|
|
18
|
+
export const PageToRender = ({ page, data }) => {
|
|
19
|
+
// Get the page component
|
|
20
|
+
const Page = page.render;
|
|
21
|
+
// Get the page props
|
|
22
|
+
const props = data.props || {};
|
|
23
|
+
return (_jsxs(React.Fragment, { children: [_jsxs(Helmet, { children: [_jsx("title", { children: page.title }), _jsx("meta", { name: "description", content: page.description })] }), _jsx(Page, { ...props })] }));
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Error fallback component that will be displayed if an error occurs
|
|
27
|
+
*/
|
|
28
|
+
export class ErrorBoundary extends React.Component {
|
|
29
|
+
state = { hasError: false, error: null, info: null };
|
|
30
|
+
componentDidCatch(error, info) {
|
|
31
|
+
this.setState({ hasError: true, error, info });
|
|
32
|
+
}
|
|
33
|
+
render() {
|
|
34
|
+
const { error, info } = this.state;
|
|
35
|
+
if (this.state.hasError) {
|
|
36
|
+
return _jsx(ErrorFallbackComponent, { error: error, info: info });
|
|
37
|
+
}
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
return _jsx(RouteErrorBoundary, { children: this.props.children });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Error fallback component that will be displayed if an error occurs during a routing
|
|
44
|
+
*/
|
|
45
|
+
export const RouteErrorBoundary = ({ children }) => {
|
|
46
|
+
const error = useRouteError();
|
|
47
|
+
console.log({ error });
|
|
48
|
+
if (error) {
|
|
49
|
+
return _jsx(ErrorFallbackComponent, { error: error, info: null });
|
|
50
|
+
}
|
|
51
|
+
return children;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Error fallback component that will be displayed if an error occurs
|
|
55
|
+
*/
|
|
56
|
+
const ErrorFallbackComponent = ({ error, info }) => {
|
|
57
|
+
console.log({ error, info });
|
|
58
|
+
return (_jsx("div", { style: {
|
|
59
|
+
width: "calc(100% - 80px)",
|
|
60
|
+
height: "calc(100vh - 80px)",
|
|
61
|
+
padding: "40px",
|
|
62
|
+
backgroundColor: "#fff",
|
|
63
|
+
}, children: _jsxs("div", { children: [_jsx("h1", { style: { fontSize: "2rem" }, children: "Something went wrong" }), _jsx("p", { children: error.toString() }), _jsx("div", { style: {
|
|
64
|
+
width: "100%",
|
|
65
|
+
height: "auto",
|
|
66
|
+
borderRadius: 10,
|
|
67
|
+
padding: "20px",
|
|
68
|
+
marginTop: "10px",
|
|
69
|
+
backgroundColor: "#f0f0f0",
|
|
70
|
+
}, children: _jsx("p", { children: info.componentStack }) })] }) }));
|
|
71
|
+
};
|
|
72
|
+
//# s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,qCAA2B,EAC1D,sBAAI,KAAK,CAAC,QAAQ,EAAE,GAAK,EAEzB,cACE,KAAK,EAAE;wBACL,KAAK,EAAE,MAAM;wBACb,MAAM,EAAE,MAAM;wBACd,YAAY,EAAE,EAAE;wBAChB,OAAO,EAAE,MAAM;wBACf,SAAS,EAAE,MAAM;wBACjB,eAAe,EAAE,SAAS;qBAC3B,YAED,sBAAI,IAAI,CAAC,cAAc,GAAK,GACxB,IACF,GACF,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EACf,aAAa,EACb,aAAa,GACd,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { LoaderOptions, LoaderResponse, ReactComponentProps } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Layout component interface that defines the base structure of a Layout and a Page too.
|
|
5
|
+
*/
|
|
6
|
+
export interface ILayoutComponent {
|
|
7
|
+
/**
|
|
8
|
+
* Fonction Component that return a JSX Element for a UI
|
|
9
|
+
*/
|
|
10
|
+
render: React.FC<ReactComponentProps>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Layout component that represents a layout
|
|
14
|
+
*/
|
|
15
|
+
export declare abstract class LayoutComponent implements ILayoutComponent {
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* Page path
|
|
19
|
+
*/
|
|
20
|
+
protected _path: string;
|
|
21
|
+
/**
|
|
22
|
+
* Render method which is a React component
|
|
23
|
+
* @param props - props for the component
|
|
24
|
+
*/
|
|
25
|
+
abstract render(props?: ReactComponentProps): React.ReactNode;
|
|
26
|
+
/**
|
|
27
|
+
* Get page path
|
|
28
|
+
*/
|
|
29
|
+
get path(): string;
|
|
30
|
+
/**
|
|
31
|
+
* Set page path
|
|
32
|
+
*/
|
|
33
|
+
set path(path: string);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Default Layout
|
|
37
|
+
*/
|
|
38
|
+
export declare class DefaultLayout extends LayoutComponent {
|
|
39
|
+
constructor();
|
|
40
|
+
render(): React.ReactNode;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Page component that extends LayoutComponent and represents a page
|
|
44
|
+
*/
|
|
45
|
+
export declare abstract class PageComponent extends LayoutComponent {
|
|
46
|
+
/**
|
|
47
|
+
* Page title
|
|
48
|
+
*/
|
|
49
|
+
protected _title: string;
|
|
50
|
+
/**
|
|
51
|
+
* Page description
|
|
52
|
+
*/
|
|
53
|
+
protected _description: string;
|
|
54
|
+
/**
|
|
55
|
+
* Get page title
|
|
56
|
+
*/
|
|
57
|
+
get title(): string;
|
|
58
|
+
/**
|
|
59
|
+
* Get page description
|
|
60
|
+
*/
|
|
61
|
+
get description(): string;
|
|
62
|
+
/**
|
|
63
|
+
* Set page title
|
|
64
|
+
*/
|
|
65
|
+
set title(title: string);
|
|
66
|
+
/**
|
|
67
|
+
* Set page description
|
|
68
|
+
*/
|
|
69
|
+
set description(description: string);
|
|
70
|
+
/**
|
|
71
|
+
* Loader method that will be called during a routing on the server side
|
|
72
|
+
* in order to get data for the page from the server
|
|
73
|
+
* @returns Promise<any>
|
|
74
|
+
*/
|
|
75
|
+
loader(_options: LoaderOptions): Promise<LoaderResponse>;
|
|
76
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Outlet } from "react-router-dom";
|
|
4
|
+
/**
|
|
5
|
+
* Layout component that represents a layout
|
|
6
|
+
*/
|
|
7
|
+
export class LayoutComponent {
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* Page path
|
|
11
|
+
*/
|
|
12
|
+
_path;
|
|
13
|
+
// Getters
|
|
14
|
+
/**
|
|
15
|
+
* Get page path
|
|
16
|
+
*/
|
|
17
|
+
get path() {
|
|
18
|
+
return this._path;
|
|
19
|
+
}
|
|
20
|
+
// Setters
|
|
21
|
+
/**
|
|
22
|
+
* Set page path
|
|
23
|
+
*/
|
|
24
|
+
set path(path) {
|
|
25
|
+
this._path = path;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Default Layout
|
|
30
|
+
*/
|
|
31
|
+
export class DefaultLayout extends LayoutComponent {
|
|
32
|
+
constructor() {
|
|
33
|
+
super();
|
|
34
|
+
this._path = "/";
|
|
35
|
+
}
|
|
36
|
+
render() {
|
|
37
|
+
return (_jsx(React.Fragment, { children: _jsx(Outlet, {}) }));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Page component that extends LayoutComponent and represents a page
|
|
42
|
+
*/
|
|
43
|
+
export class PageComponent extends LayoutComponent {
|
|
44
|
+
/**
|
|
45
|
+
* Page title
|
|
46
|
+
*/
|
|
47
|
+
_title;
|
|
48
|
+
/**
|
|
49
|
+
* Page description
|
|
50
|
+
*/
|
|
51
|
+
_description;
|
|
52
|
+
// Getters
|
|
53
|
+
/**
|
|
54
|
+
* Get page title
|
|
55
|
+
*/
|
|
56
|
+
get title() {
|
|
57
|
+
return this._title;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Get page description
|
|
61
|
+
*/
|
|
62
|
+
get description() {
|
|
63
|
+
return this._description;
|
|
64
|
+
}
|
|
65
|
+
// Setters
|
|
66
|
+
/**
|
|
67
|
+
* Set page title
|
|
68
|
+
*/
|
|
69
|
+
set title(title) {
|
|
70
|
+
this._title = title;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Set page description
|
|
74
|
+
*/
|
|
75
|
+
set description(description) {
|
|
76
|
+
this._description = description;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Loader method that will be called during a routing on the server side
|
|
80
|
+
* in order to get data for the page from the server
|
|
81
|
+
* @returns Promise<any>
|
|
82
|
+
*/
|
|
83
|
+
async loader(_options) {
|
|
84
|
+
return new Promise((resolve) => {
|
|
85
|
+
resolve({
|
|
86
|
+
props: {},
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=interfaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/core/interfaces.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAY1C;;GAEG;AACH,MAAM,OAAgB,eAAe;IACnC;;;OAGG;IACO,KAAK,CAAU;IAQzB,UAAU;IAEV;;OAEG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,UAAU;IAEV;;OAEG;IACH,IAAI,IAAI,CAAC,IAAY;QACnB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,eAAe;IAChD;QACE,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;IACnB,CAAC;IAED,MAAM;QACJ,OAAO,CACL,KAAC,KAAK,CAAC,QAAQ,cACb,KAAC,MAAM,KAAG,GACK,CAClB,CAAC;IACJ,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAgB,aAAc,SAAQ,eAAe;IACzD;;OAEG;IACO,MAAM,CAAU;IAE1B;;OAEG;IACO,YAAY,CAAU;IAEhC,UAAU;IAEV;;OAEG;IACH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,UAAU;IAEV;;OAEG;IACH,IAAI,KAAK,CAAC,KAAa;QACrB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,IAAI,WAAW,CAAC,WAAmB;QACjC,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CACV,QAAuB;QAEvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,OAAO,CAAC;gBACN,KAAK,EAAE,EAAE;aACV,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { RouterComponent } from "../routing/interfaces.js";
|
|
3
|
+
import { PageComponent } from "./interfaces.js";
|
|
4
|
+
/**
|
|
5
|
+
* Props for App component
|
|
6
|
+
*/
|
|
7
|
+
export type AppProps = {
|
|
8
|
+
Component: React.FC<{
|
|
9
|
+
router: any;
|
|
10
|
+
}>;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Props for the base Component that takes the app router
|
|
14
|
+
*/
|
|
15
|
+
export type ComponentProps = {
|
|
16
|
+
router: RouterComponent;
|
|
17
|
+
};
|
|
18
|
+
export type PageToRenderProps = {
|
|
19
|
+
page: PageComponent;
|
|
20
|
+
data: LoaderResponse;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Props for component react components
|
|
24
|
+
*/
|
|
25
|
+
export type ReactComponentProps = {
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Options for the loader function that loads data for a page from the server
|
|
30
|
+
*/
|
|
31
|
+
export type LoaderOptions = {
|
|
32
|
+
params: {
|
|
33
|
+
[key: string]: any;
|
|
34
|
+
};
|
|
35
|
+
request: Request;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Data returned from the loader function
|
|
39
|
+
*/
|
|
40
|
+
export type LoaderResponse = {
|
|
41
|
+
props?: {
|
|
42
|
+
[key: string]: any;
|
|
43
|
+
};
|
|
44
|
+
redirect?: string;
|
|
45
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":""}
|