rasengan 1.0.0-beta.6 → 1.0.0-beta.60
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/CHANGELOG.md +19 -0
- package/README.md +36 -0
- package/bin.js +13 -0
- package/lib/esm/cli/index.js +40 -0
- package/lib/esm/client.js +2 -0
- package/lib/esm/core/config/index.js +3 -0
- package/lib/esm/core/config/type.js +6 -0
- package/lib/esm/core/config/utils/define-config.js +80 -0
- package/lib/esm/core/config/utils/load-modules.js +78 -0
- package/lib/esm/core/config/utils/path.js +16 -0
- package/lib/esm/core/config/vite/defaults.js +93 -0
- package/lib/esm/core/dynamic/index.js +21 -0
- package/lib/esm/core/index.js +2 -0
- package/lib/esm/core/middlewares/index.js +1 -0
- package/lib/esm/core/middlewares/logger.js +6 -0
- package/lib/esm/core/plugins/index.js +167 -0
- package/lib/esm/core/utils/log.js +9 -0
- package/lib/esm/entries/client/render.js +28 -0
- package/lib/esm/entries/server/entry.server.js +30 -0
- package/lib/esm/entries/server/index.js +31 -0
- package/lib/esm/index.js +5 -0
- package/lib/esm/plugin.js +2 -0
- package/lib/esm/routing/components/index.js +104 -0
- package/lib/esm/routing/components/template.js +64 -0
- package/lib/esm/routing/index.js +5 -0
- package/lib/{routing → esm/routing}/interfaces.js +19 -2
- package/lib/esm/routing/utils/define-router.js +78 -0
- package/lib/esm/routing/utils/define-routes-group.js +44 -0
- package/lib/esm/routing/utils/generate-metadata.js +83 -0
- package/lib/esm/routing/utils/generate-routes.js +301 -0
- package/lib/esm/routing/utils/index.js +4 -0
- package/lib/esm/scripts/build-command.js +17 -0
- package/lib/esm/scripts/generate-package-json.js +23 -0
- package/lib/esm/scripts/utils/check-os.js +7 -0
- package/lib/esm/scripts/utils/copy.js +16 -0
- package/lib/esm/server/build/index.js +11 -0
- package/lib/esm/server/build/manifest.js +91 -0
- package/lib/esm/server/build/rendering.js +18 -0
- package/lib/esm/server/dev/handlers.js +125 -0
- package/lib/esm/server/dev/server.js +174 -0
- package/lib/esm/server/dev/utils.js +192 -0
- package/lib/esm/server/node/index.js +69 -0
- package/lib/esm/server/node/rendering.js +44 -0
- package/lib/esm/server/node/stream.js +129 -0
- package/lib/esm/server/node/utils.js +91 -0
- package/lib/esm/server/runtime/mode.js +14 -0
- package/lib/esm/server/runtime/utils.js +5 -0
- package/lib/esm/server/virtual/index.js +8 -0
- package/lib/esm/server.js +4 -0
- package/lib/tsconfig.esm.tsbuildinfo +1 -0
- package/lib/tsconfig.types.tsbuildinfo +1 -0
- package/lib/types/client.d.ts +2 -0
- package/lib/types/core/config/index.d.ts +3 -0
- package/lib/types/core/config/type.d.ts +66 -0
- package/lib/types/core/config/utils/define-config.d.ts +7 -0
- package/lib/types/core/config/utils/load-modules.d.ts +19 -0
- package/lib/types/core/config/utils/path.d.ts +7 -0
- package/lib/types/core/config/vite/defaults.d.ts +3 -0
- package/lib/types/core/dynamic/index.d.ts +13 -0
- package/lib/types/core/index.d.ts +1 -0
- package/lib/types/core/middlewares/index.d.ts +1 -0
- package/lib/types/core/middlewares/logger.d.ts +2 -0
- package/lib/types/core/plugins/index.d.ts +18 -0
- package/lib/types/core/types.d.ts +15 -0
- package/lib/types/core/utils/log.d.ts +2 -0
- package/lib/types/entries/client/render.d.ts +5 -0
- package/lib/types/entries/server/entry.server.d.ts +20 -0
- package/lib/types/entries/server/index.d.ts +14 -0
- package/lib/types/index.d.ts +6 -0
- package/lib/types/plugin.d.ts +3 -0
- package/lib/types/routing/components/index.d.ts +22 -0
- package/lib/types/routing/components/template.d.ts +41 -0
- package/lib/types/routing/index.d.ts +6 -0
- package/lib/{routing → types/routing}/interfaces.d.ts +18 -6
- package/lib/types/routing/types.d.ts +213 -0
- package/lib/types/routing/utils/define-router.d.ts +8 -0
- package/lib/types/routing/utils/define-routes-group.d.ts +7 -0
- package/lib/types/routing/utils/generate-metadata.d.ts +7 -0
- package/lib/types/routing/utils/generate-routes.d.ts +13 -0
- package/lib/types/routing/utils/index.d.ts +4 -0
- package/lib/types/scripts/utils/check-os.d.ts +1 -0
- package/lib/types/scripts/utils/copy.d.ts +1 -0
- package/lib/types/server/build/index.d.ts +13 -0
- package/lib/types/server/build/manifest.d.ts +27 -0
- package/lib/types/server/build/rendering.d.ts +7 -0
- package/lib/types/server/dev/handlers.d.ts +27 -0
- package/lib/types/server/dev/server.d.ts +1 -0
- package/lib/types/server/dev/utils.d.ts +39 -0
- package/lib/types/server/node/index.d.ts +9 -0
- package/lib/types/server/node/rendering.d.ts +9 -0
- package/lib/types/server/node/stream.d.ts +7 -0
- package/lib/types/server/node/utils.d.ts +18 -0
- package/lib/types/server/runtime/mode.d.ts +9 -0
- package/lib/types/server/runtime/utils.d.ts +4 -0
- package/lib/types/server/virtual/index.d.ts +5 -0
- package/lib/types/server.d.ts +4 -0
- package/package.json +97 -47
- package/{tsconfig.json → tsconfig.base.json} +6 -16
- package/tsconfig.esm.json +8 -0
- package/tsconfig.types.json +10 -0
- package/types/client.d.ts +71 -0
- package/vite.config.ts +28 -65
- package/lib/cli/dirname.d.ts +0 -2
- package/lib/cli/dirname.js +0 -5
- package/lib/cli/index.d.ts +0 -2
- package/lib/cli/index.js +0 -99
- package/lib/config/index.d.ts +0 -58
- package/lib/config/index.js +0 -106
- package/lib/config/type.d.ts +0 -85
- package/lib/core/components/index.d.ts +0 -22
- package/lib/core/components/index.js +0 -67
- package/lib/core/index.d.ts +0 -2
- package/lib/core/index.js +0 -1
- package/lib/core/interfaces.d.ts +0 -93
- package/lib/core/interfaces.js +0 -114
- package/lib/core/types.d.ts +0 -45
- package/lib/decorators/index.d.ts +0 -2
- package/lib/decorators/index.js +0 -2
- package/lib/decorators/route.d.ts +0 -8
- package/lib/decorators/route.js +0 -20
- package/lib/decorators/router.d.ts +0 -8
- package/lib/decorators/router.js +0 -34
- package/lib/decorators/types.d.ts +0 -52
- package/lib/entries/entry-client.js +0 -14
- package/lib/entries/entry-server.d.ts +0 -6
- package/lib/entries/entry-server.js +0 -21
- package/lib/hooks/index.d.ts +0 -0
- package/lib/hooks/index.js +0 -0
- package/lib/index.d.ts +0 -6
- package/lib/index.js +0 -9
- package/lib/routing/components/index.d.ts +0 -38
- package/lib/routing/components/index.js +0 -81
- package/lib/routing/index.d.ts +0 -5
- package/lib/routing/index.js +0 -5
- package/lib/routing/types.d.ts +0 -9
- package/lib/routing/utils/index.d.ts +0 -38
- package/lib/routing/utils/index.js +0 -252
- package/lib/server/functions/vercel/_rasengan/server/index.d.ts +0 -2
- package/lib/server/functions/vercel/_rasengan/server/index.js +0 -91
- package/lib/server/functions/vercel/api/index.d.ts +0 -2
- package/lib/server/functions/vercel/api/index.js +0 -91
- package/lib/server/functions/vercel/vercel.json +0 -16
- package/lib/server/utils/createFetchRequest.d.ts +0 -5
- package/lib/server/utils/createFetchRequest.js +0 -33
- package/lib/server/utils/getIp.d.ts +0 -1
- package/lib/server/utils/getIp.js +0 -29
- package/lib/server/utils/handleError.d.ts +0 -2
- package/lib/server/utils/handleError.js +0 -27
- package/lib/server/utils/index.d.ts +0 -5
- package/lib/server/utils/index.js +0 -7
- package/lib/server/utils/log.d.ts +0 -7
- package/lib/server/utils/log.js +0 -74
- package/server.js +0 -238
- package/tsconfig.lib.json +0 -41
- package/tsconfig.node.json +0 -11
- package/types/image.d.ts +0 -44
- package/types/style.d.ts +0 -4
- /package/lib/{core → esm/core}/types.js +0 -0
- /package/lib/{decorators → esm/routing}/types.js +0 -0
- /package/lib/{config/type.js → types/cli/index.d.ts} +0 -0
- /package/lib/{entries/entry-client.d.ts → types/scripts/build-command.d.ts} +0 -0
- /package/lib/{routing/types.js → types/scripts/generate-package-json.d.ts} +0 -0
|
@@ -1,35 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"baseUrl": ".",
|
|
4
|
-
"target": "ES2020",
|
|
5
3
|
"useDefineForClassFields": true,
|
|
6
4
|
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
7
|
-
"module": "ESNext",
|
|
8
5
|
"skipLibCheck": true,
|
|
6
|
+
"experimentalDecorators": true,
|
|
7
|
+
"composite": true,
|
|
9
8
|
|
|
10
9
|
/* Bundler mode */
|
|
10
|
+
"module": "ESNext",
|
|
11
|
+
"allowSyntheticDefaultImports": true,
|
|
11
12
|
"moduleResolution": "bundler",
|
|
12
13
|
"allowImportingTsExtensions": true,
|
|
13
14
|
"resolveJsonModule": true,
|
|
14
15
|
"isolatedModules": true,
|
|
15
16
|
"noEmit": true,
|
|
16
|
-
"jsx": "react-jsx",
|
|
17
|
-
"composite": true,
|
|
18
17
|
|
|
19
18
|
/* Linting */
|
|
20
19
|
"strict": true,
|
|
21
20
|
"noUnusedLocals": true,
|
|
22
21
|
"noUnusedParameters": true,
|
|
23
|
-
"noFallthroughCasesInSwitch": true
|
|
24
|
-
|
|
25
|
-
/* Plugins */
|
|
26
|
-
"plugins": [{ "name": "typescript-plugin-css-modules" }],
|
|
27
|
-
|
|
28
|
-
"paths": {
|
|
29
|
-
"@/*": ["src/*"]
|
|
30
|
-
}
|
|
22
|
+
"noFallthroughCasesInSwitch": true
|
|
31
23
|
},
|
|
32
|
-
"include": ["
|
|
33
|
-
|
|
34
|
-
"references": [{ "path": "./tsconfig.node.json" }]
|
|
24
|
+
"include": ["vite.config.ts", "types/client.d.ts"]
|
|
35
25
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
/// <reference types="../lib/types/index.d.ts" />
|
|
3
|
+
|
|
4
|
+
// Markdown files
|
|
5
|
+
|
|
6
|
+
declare module '*.mdx' {
|
|
7
|
+
import { type MDXPageComponent } from '../lib/esm/index.js';
|
|
8
|
+
|
|
9
|
+
let MDXComponent: MDXPageComponent;
|
|
10
|
+
|
|
11
|
+
export default MDXComponent;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare module '*.md' {
|
|
15
|
+
import { type MDXPageComponent } from '../lib/esm/index.js';
|
|
16
|
+
|
|
17
|
+
let MDXComponent: MDXPageComponent;
|
|
18
|
+
|
|
19
|
+
export default MDXComponent;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// ?raw files
|
|
23
|
+
|
|
24
|
+
declare module '*.js?raw' {
|
|
25
|
+
const value: string;
|
|
26
|
+
export default value;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Virtual modules
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* virtual-entry-server.d.ts
|
|
33
|
+
**/
|
|
34
|
+
declare module 'virtual:entry-server' {
|
|
35
|
+
import { type Response } from 'express';
|
|
36
|
+
import { redirect, StaticHandlerContext } from 'react-router';
|
|
37
|
+
import {
|
|
38
|
+
Metadata,
|
|
39
|
+
MetadataWithoutTitleAndDescription,
|
|
40
|
+
} from '../lib/esm/index.js';
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Render the app to a stream
|
|
44
|
+
* @param router
|
|
45
|
+
* @param res
|
|
46
|
+
* @param options
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
49
|
+
export async function render(
|
|
50
|
+
router: any,
|
|
51
|
+
res: Response,
|
|
52
|
+
options: {
|
|
53
|
+
context: StaticHandlerContext;
|
|
54
|
+
metadata: {
|
|
55
|
+
page: Metadata;
|
|
56
|
+
layout: MetadataWithoutTitleAndDescription;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
): Promise<unknown>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// declare module "virtual:rasengan-config" {
|
|
63
|
+
// import { type ProductionAppConfig } from "../lib/esm/core/config/types.js";
|
|
64
|
+
|
|
65
|
+
// export const __RASENGAN_CONFIG__: ProductionAppConfig;
|
|
66
|
+
// }
|
|
67
|
+
|
|
68
|
+
interface Window {
|
|
69
|
+
__staticRouterHydrationData: any;
|
|
70
|
+
__RASENGAN_SPA_MODE__: boolean;
|
|
71
|
+
}
|
package/vite.config.ts
CHANGED
|
@@ -1,66 +1,29 @@
|
|
|
1
|
-
import { defineConfig } from
|
|
2
|
-
import react from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
build: {
|
|
30
|
-
sourcemap: true,
|
|
31
|
-
rollupOptions: {
|
|
32
|
-
external: vite?.build?.external,
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
ssr: {
|
|
37
|
-
// Ignore CSS files
|
|
38
|
-
noExternal: [/\.css$/],
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
css: {
|
|
42
|
-
modules: {
|
|
43
|
-
localsConvention: "camelCaseOnly",
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
postcss: vite?.css?.postcss,
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
// Aliases
|
|
50
|
-
resolve: {
|
|
51
|
-
alias: vite?.resolve?.alias.map(
|
|
52
|
-
(alias: { find: string; replacement: string }) => ({
|
|
53
|
-
find: alias.find,
|
|
54
|
-
replacement: path.join(__pathToRoot, alias.replacement),
|
|
55
|
-
})
|
|
56
|
-
),
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
// Cache directory
|
|
60
|
-
cacheDir: ".rasengan/",
|
|
61
|
-
|
|
62
|
-
// Environment variable prefix
|
|
63
|
-
envPrefix: "RASENGAN_",
|
|
64
|
-
|
|
65
|
-
appType: vite.appType,
|
|
1
|
+
import { defineConfig, UserConfig } from 'vite';
|
|
2
|
+
import react from '@vitejs/plugin-react';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import {
|
|
5
|
+
loadModuleSSR,
|
|
6
|
+
getDirname,
|
|
7
|
+
} from './lib/esm/core/config/utils/load-modules.js';
|
|
8
|
+
import { plugins } from './lib/esm/core/plugins/index.js';
|
|
9
|
+
import { createDefaultViteConfig } from './lib/esm/core/config/vite/defaults.js';
|
|
10
|
+
|
|
11
|
+
export default defineConfig(async ({ mode }): Promise<UserConfig> => {
|
|
12
|
+
const rootPath = process.cwd();
|
|
13
|
+
const __dirname = await getDirname(import.meta.url);
|
|
14
|
+
|
|
15
|
+
// Load Rasengan config
|
|
16
|
+
const configPath = join(`${rootPath}/rasengan.config.js`);
|
|
17
|
+
const configHandler = await (await loadModuleSSR(configPath)).default;
|
|
18
|
+
|
|
19
|
+
const config = await configHandler();
|
|
20
|
+
|
|
21
|
+
// Get base config
|
|
22
|
+
const baseConfig = createDefaultViteConfig(rootPath, __dirname, mode, config);
|
|
23
|
+
|
|
24
|
+
// Merge with user plugins
|
|
25
|
+
return {
|
|
26
|
+
...baseConfig,
|
|
27
|
+
plugins: [react(), ...plugins, ...(config.vite?.plugins || [])],
|
|
28
|
+
};
|
|
66
29
|
});
|
package/lib/cli/dirname.d.ts
DELETED
package/lib/cli/dirname.js
DELETED
package/lib/cli/index.d.ts
DELETED
package/lib/cli/index.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
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
|
-
execa("npm", ["run", "build"], {
|
|
41
|
-
cwd: "node_modules/rasengan",
|
|
42
|
-
stdio: "inherit", // Pipe child process output to the parent process
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
// Handle the prebuild command
|
|
46
|
-
program
|
|
47
|
-
.command("prepare")
|
|
48
|
-
.description("Prepare the project")
|
|
49
|
-
.action(() => {
|
|
50
|
-
// Displaying the message
|
|
51
|
-
console.log("");
|
|
52
|
-
console.log(chalk.blue("Preparing your project for production..."));
|
|
53
|
-
console.log("");
|
|
54
|
-
// Checking the config file in order to know about hosting strategy
|
|
55
|
-
const { server } = config;
|
|
56
|
-
const hostingStrategy = server?.production?.hosting ?? "custom";
|
|
57
|
-
if (hostingStrategy === "vercel") {
|
|
58
|
-
// Displaying the message
|
|
59
|
-
console.log(`Your project is configured to be hosted on ${chalk.bold.blue(hostingStrategy)}\n`);
|
|
60
|
-
// Copying the api folder to the root directory
|
|
61
|
-
execa("cp", ["-r", "node_modules/rasengan/lib/server/functions/vercel/api", "."], {
|
|
62
|
-
stdio: "inherit",
|
|
63
|
-
});
|
|
64
|
-
// Copying the vercel.json file to the root directory
|
|
65
|
-
execa("cp", ["node_modules/rasengan/lib/server/functions/vercel/vercel.json", "."], {
|
|
66
|
-
stdio: "inherit",
|
|
67
|
-
});
|
|
68
|
-
// Removing index.d.ts and index.js.map files from the api folder
|
|
69
|
-
execa("rm", ["api/index.d.ts"], {
|
|
70
|
-
stdio: "inherit",
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
else if (hostingStrategy === "netlify") {
|
|
74
|
-
// Copying the netlify.toml file to the root directory
|
|
75
|
-
// execa(
|
|
76
|
-
// "cp",
|
|
77
|
-
// ["node_modules/rasengan/src/server/functions/netlify/netlify.toml", "."],
|
|
78
|
-
// {
|
|
79
|
-
// stdio: "inherit",
|
|
80
|
-
// }
|
|
81
|
-
// );
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
// Handle the start command
|
|
85
|
-
program
|
|
86
|
-
.command("start")
|
|
87
|
-
.description("Start the project in production mode")
|
|
88
|
-
.action(async () => {
|
|
89
|
-
const childProcess = execa("npm", ["run", "preview"], {
|
|
90
|
-
cwd: "node_modules/rasengan",
|
|
91
|
-
stdio: "inherit", // Pipe child process output to the parent process
|
|
92
|
-
});
|
|
93
|
-
childProcess.on("close", (code) => {
|
|
94
|
-
if (code === 0) {
|
|
95
|
-
process.stdout.write("Project started Succesfully");
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
program.parse(process.argv);
|
package/lib/config/index.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
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
|
-
open: boolean;
|
|
13
|
-
};
|
|
14
|
-
production: {
|
|
15
|
-
hosting: import("./type.js").HostingStrategy;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
vite: {
|
|
19
|
-
plugins: any[];
|
|
20
|
-
optimizeDeps: {
|
|
21
|
-
exclude: string[];
|
|
22
|
-
};
|
|
23
|
-
css: {
|
|
24
|
-
postcss: {
|
|
25
|
-
plugins?: any[];
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
build: {
|
|
29
|
-
external: string[];
|
|
30
|
-
};
|
|
31
|
-
resolve: {
|
|
32
|
-
alias: {
|
|
33
|
-
find: string;
|
|
34
|
-
replacement: string;
|
|
35
|
-
}[];
|
|
36
|
-
};
|
|
37
|
-
appType: string;
|
|
38
|
-
};
|
|
39
|
-
} | {
|
|
40
|
-
reactStrictMode: boolean;
|
|
41
|
-
vite: {
|
|
42
|
-
optimizeDeps: {
|
|
43
|
-
exclude: string[];
|
|
44
|
-
};
|
|
45
|
-
appType: string;
|
|
46
|
-
resolve: {
|
|
47
|
-
alias: {
|
|
48
|
-
find: string;
|
|
49
|
-
replacement: string;
|
|
50
|
-
}[];
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* Function to adapt the path for dev and prod
|
|
56
|
-
* @param {string | Array<string>} paths
|
|
57
|
-
*/
|
|
58
|
-
export declare const adaptPath: (paths: string | Array<string>) => string | string[];
|
package/lib/config/index.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
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
|
-
// Define default values for vite config coming from loadedConfig.vite
|
|
9
|
-
const defaultViteConfig = {
|
|
10
|
-
plugins: vite?.plugins || [],
|
|
11
|
-
optimizeDeps: {
|
|
12
|
-
exclude: vite?.optimizeDeps?.exclude || [],
|
|
13
|
-
},
|
|
14
|
-
css: {
|
|
15
|
-
postcss: vite?.css?.postcss || undefined,
|
|
16
|
-
},
|
|
17
|
-
build: {
|
|
18
|
-
external: vite?.build?.external || [],
|
|
19
|
-
},
|
|
20
|
-
resolve: {
|
|
21
|
-
alias: vite?.resolve?.alias || [],
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
// Define default values for server config coming from loadedConfig.server
|
|
25
|
-
const defaultServerConfig = {
|
|
26
|
-
development: {
|
|
27
|
-
port: server?.development?.port || undefined,
|
|
28
|
-
open: server?.development?.open || false,
|
|
29
|
-
},
|
|
30
|
-
production: {
|
|
31
|
-
hosting: server?.production?.hosting || "custom",
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
try {
|
|
35
|
-
const config = {
|
|
36
|
-
reactStrictMode: reactStrictMode === undefined ? true : reactStrictMode,
|
|
37
|
-
server: defaultServerConfig,
|
|
38
|
-
vite: {
|
|
39
|
-
plugins: defaultViteConfig.plugins,
|
|
40
|
-
optimizeDeps: {
|
|
41
|
-
exclude: [
|
|
42
|
-
"node:http",
|
|
43
|
-
"node-fetch",
|
|
44
|
-
...defaultViteConfig.optimizeDeps.exclude,
|
|
45
|
-
],
|
|
46
|
-
},
|
|
47
|
-
css: {
|
|
48
|
-
postcss: defaultViteConfig.css.postcss,
|
|
49
|
-
},
|
|
50
|
-
build: {
|
|
51
|
-
external: defaultViteConfig.build.external,
|
|
52
|
-
},
|
|
53
|
-
resolve: {
|
|
54
|
-
// concat two arrays
|
|
55
|
-
alias: [
|
|
56
|
-
{
|
|
57
|
-
find: "@/",
|
|
58
|
-
replacement: "src/",
|
|
59
|
-
},
|
|
60
|
-
...defaultViteConfig.resolve.alias,
|
|
61
|
-
],
|
|
62
|
-
},
|
|
63
|
-
appType: "custom",
|
|
64
|
-
},
|
|
65
|
-
// More config options...
|
|
66
|
-
};
|
|
67
|
-
return config;
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
console.error(error);
|
|
71
|
-
return {
|
|
72
|
-
reactStrictMode: true,
|
|
73
|
-
vite: {
|
|
74
|
-
optimizeDeps: {
|
|
75
|
-
exclude: ["node:http", "node-fetch"],
|
|
76
|
-
},
|
|
77
|
-
appType: "custom",
|
|
78
|
-
resolve: {
|
|
79
|
-
alias: [
|
|
80
|
-
{
|
|
81
|
-
find: "@/",
|
|
82
|
-
replacement: "src/",
|
|
83
|
-
},
|
|
84
|
-
],
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* Function to adapt the path for dev and prod
|
|
92
|
-
* @param {string | Array<string>} paths
|
|
93
|
-
*/
|
|
94
|
-
export const adaptPath = (paths) => {
|
|
95
|
-
// Check if we are in dev mode or prod
|
|
96
|
-
const isProduction = process.env.NODE_ENV === "production";
|
|
97
|
-
const prefix = isProduction ? "./../../" : "";
|
|
98
|
-
// Chech if the path is an array
|
|
99
|
-
const isArray = Array.isArray(paths);
|
|
100
|
-
// If the path is an array
|
|
101
|
-
if (isArray) {
|
|
102
|
-
return paths.map((path) => `${prefix}${path}`);
|
|
103
|
-
}
|
|
104
|
-
// If the path is a string
|
|
105
|
-
return `${prefix}${paths}`;
|
|
106
|
-
};
|
package/lib/config/type.d.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
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 5320
|
|
18
|
-
*/
|
|
19
|
-
port?: number;
|
|
20
|
-
/**
|
|
21
|
-
* Automatically open browser
|
|
22
|
-
* @default false
|
|
23
|
-
*/
|
|
24
|
-
open?: boolean;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Configure server in production
|
|
28
|
-
*/
|
|
29
|
-
production?: {
|
|
30
|
-
/**
|
|
31
|
-
* Set the hosting strategy
|
|
32
|
-
* @default "custom"
|
|
33
|
-
*/
|
|
34
|
-
hosting?: HostingStrategy;
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Configure Vite
|
|
39
|
-
*/
|
|
40
|
-
vite?: {
|
|
41
|
-
/**
|
|
42
|
-
* Configure Vite plugins
|
|
43
|
-
*/
|
|
44
|
-
plugins?: any[];
|
|
45
|
-
/**
|
|
46
|
-
* Optimize dependencies
|
|
47
|
-
*/
|
|
48
|
-
optimizeDeps?: {
|
|
49
|
-
exclude?: string[];
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* Configure css options
|
|
53
|
-
*/
|
|
54
|
-
css?: {
|
|
55
|
-
postcss?: {
|
|
56
|
-
plugins?: any[];
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* Configure build options
|
|
61
|
-
*/
|
|
62
|
-
build?: {
|
|
63
|
-
/**
|
|
64
|
-
* Configure external dependencies
|
|
65
|
-
*/
|
|
66
|
-
external?: string[];
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* Configure resolve options
|
|
70
|
-
*/
|
|
71
|
-
resolve?: {
|
|
72
|
-
/**
|
|
73
|
-
* Configure aliases
|
|
74
|
-
*/
|
|
75
|
-
alias?: Array<{
|
|
76
|
-
find: string;
|
|
77
|
-
replacement: string;
|
|
78
|
-
}>;
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
/**
|
|
83
|
-
* Hosting strategy
|
|
84
|
-
*/
|
|
85
|
-
export type HostingStrategy = "vercel" | "custom";
|
|
@@ -1,22 +0,0 @@
|
|
|
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, children, }: ComponentProps) => string | number | true | Iterable<React.ReactNode> | 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(): any;
|
|
22
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { generateMetadata, getRouter } from "../../routing/utils/index.js";
|
|
4
|
-
import * as pkg from "react-helmet-async";
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
const { Helmet } = pkg.default || pkg;
|
|
7
|
-
/**
|
|
8
|
-
* App component that represent the entry point of the application
|
|
9
|
-
*/
|
|
10
|
-
export const Component = ({ router: AppRouter, children = undefined, }) => {
|
|
11
|
-
// Return children if they exist
|
|
12
|
-
if (children)
|
|
13
|
-
return children;
|
|
14
|
-
// Otherwise, get the router and return it
|
|
15
|
-
const Router = getRouter(AppRouter);
|
|
16
|
-
return _jsx(Router, {});
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Page component that defines title and description to a page
|
|
20
|
-
*/
|
|
21
|
-
export const PageToRender = ({ page, data }) => {
|
|
22
|
-
// Get the page component
|
|
23
|
-
const Page = page.render;
|
|
24
|
-
// Get the page props
|
|
25
|
-
const props = data.props || {};
|
|
26
|
-
// Generate meta tags
|
|
27
|
-
const metaTags = React.useMemo(() => {
|
|
28
|
-
return generateMetadata(page.metadata);
|
|
29
|
-
}, []);
|
|
30
|
-
return (_jsxs(React.Fragment, { children: [_jsxs(Helmet, { children: [metaTags.map((meta) => meta), _jsx("meta", { name: "description", content: page.description }), _jsx("title", { children: page.title })] }), _jsx(Page, { ...props })] }));
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Error fallback component that will be displayed if an error occurs
|
|
34
|
-
*/
|
|
35
|
-
export class ErrorBoundary extends React.Component {
|
|
36
|
-
state = { hasError: false, error: null, info: null };
|
|
37
|
-
componentDidCatch(error, info) {
|
|
38
|
-
this.setState({ hasError: true, error, info });
|
|
39
|
-
}
|
|
40
|
-
render() {
|
|
41
|
-
const { error, info } = this.state;
|
|
42
|
-
if (this.state.hasError) {
|
|
43
|
-
return _jsx(ErrorFallbackComponent, { error: error, info: info });
|
|
44
|
-
}
|
|
45
|
-
// @ts-ignore
|
|
46
|
-
return this.props.children;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Error fallback component that will be displayed if an error occurs
|
|
51
|
-
*/
|
|
52
|
-
const ErrorFallbackComponent = ({ error, info }) => {
|
|
53
|
-
console.log({ error, info });
|
|
54
|
-
return (_jsx("div", { style: {
|
|
55
|
-
width: "calc(100% - 80px)",
|
|
56
|
-
height: "calc(100vh - 80px)",
|
|
57
|
-
padding: "40px",
|
|
58
|
-
backgroundColor: "#fff",
|
|
59
|
-
}, children: _jsxs("div", { children: [_jsx("h1", { style: { fontSize: "2rem" }, children: "Something went wrong" }), _jsx("p", { children: error.toString() }), _jsx("div", { style: {
|
|
60
|
-
width: "100%",
|
|
61
|
-
height: "auto",
|
|
62
|
-
borderRadius: 10,
|
|
63
|
-
padding: "20px",
|
|
64
|
-
marginTop: "10px",
|
|
65
|
-
backgroundColor: "#f0f0f0",
|
|
66
|
-
}, children: _jsx("p", { children: info.componentStack }) })] }) }));
|
|
67
|
-
};
|
package/lib/core/index.d.ts
DELETED