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.
Files changed (61) hide show
  1. package/lib/cli/dirname.js +0 -1
  2. package/lib/cli/index.js +0 -1
  3. package/lib/config/index.d.ts +6 -0
  4. package/lib/config/index.js +9 -1
  5. package/lib/config/type.d.ts +1 -1
  6. package/lib/config/type.js +0 -1
  7. package/lib/core/components/index.js +0 -1
  8. package/lib/core/index.js +0 -1
  9. package/lib/core/interfaces.js +0 -1
  10. package/lib/core/types.js +0 -1
  11. package/lib/decorators/index.js +0 -1
  12. package/lib/decorators/route.js +0 -1
  13. package/lib/decorators/router.js +0 -1
  14. package/lib/decorators/types.js +0 -1
  15. package/lib/entries/entry-client.js +0 -1
  16. package/lib/entries/entry-server.js +0 -1
  17. package/lib/hooks/index.js +0 -1
  18. package/lib/index.js +0 -1
  19. package/lib/routing/components/index.js +0 -1
  20. package/lib/routing/index.js +0 -1
  21. package/lib/routing/interfaces.js +0 -1
  22. package/lib/routing/types.js +0 -1
  23. package/lib/routing/utils/index.js +0 -1
  24. package/lib/server/functions/vercel/api/index.js +0 -1
  25. package/lib/server/utils/createFetchRequest.js +0 -1
  26. package/lib/server/utils/getIp.js +0 -1
  27. package/lib/server/utils/handleError.js +0 -1
  28. package/lib/server/utils/index.js +0 -1
  29. package/lib/server/utils/log.js +0 -1
  30. package/package.json +3 -4
  31. package/tsconfig.lib.json +1 -1
  32. package/vite.config.ts +10 -1
  33. package/src/cli/dirname.ts +0 -7
  34. package/src/cli/index.ts +0 -134
  35. package/src/config/index.ts +0 -67
  36. package/src/config/type.ts +0 -76
  37. package/src/core/components/index.tsx +0 -95
  38. package/src/core/index.ts +0 -14
  39. package/src/core/interfaces.tsx +0 -129
  40. package/src/core/types.ts +0 -43
  41. package/src/decorators/index.ts +0 -2
  42. package/src/decorators/route.ts +0 -32
  43. package/src/decorators/router.ts +0 -30
  44. package/src/decorators/types.ts +0 -54
  45. package/src/entries/entry-client.tsx +0 -33
  46. package/src/entries/entry-server.tsx +0 -50
  47. package/src/hooks/index.ts +0 -0
  48. package/src/index.ts +0 -11
  49. package/src/routing/components/index.tsx +0 -125
  50. package/src/routing/index.ts +0 -23
  51. package/src/routing/interfaces.ts +0 -105
  52. package/src/routing/types.ts +0 -3
  53. package/src/routing/utils/index.tsx +0 -342
  54. package/src/server/functions/vercel/api/index.ts +0 -122
  55. package/src/server/functions/vercel/vercel.json +0 -12
  56. package/src/server/utils/createFetchRequest.ts +0 -40
  57. package/src/server/utils/getIp.ts +0 -37
  58. package/src/server/utils/handleError.ts +0 -36
  59. package/src/server/utils/index.ts +0 -15
  60. package/src/server/utils/log.ts +0 -115
  61. package/src/vite-env.d.ts +0 -1
@@ -3,4 +3,3 @@ import { dirname } from 'path';
3
3
  const __filename = fileURLToPath(import.meta.url);
4
4
  const __dirname = dirname(__filename);
5
5
  export default __dirname;
6
- //# sourceMappingURL=dirname.js.map
package/lib/cli/index.js CHANGED
@@ -98,4 +98,3 @@ program
98
98
  });
99
99
  });
100
100
  program.parse(process.argv);
101
- //# sourceMappingURL=index.js.map
@@ -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
@@ -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
@@ -65,4 +65,4 @@ export type AppConfig = {
65
65
  /**
66
66
  * Hosting strategy
67
67
  */
68
- export type HostingStrategy = "vercel" | "netlify" | "heroku" | "custom";
68
+ export type HostingStrategy = "vercel" | "custom";
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=type.js.map
@@ -57,4 +57,3 @@ const ErrorFallbackComponent = ({ error, info }) => {
57
57
  backgroundColor: "#f0f0f0",
58
58
  }, children: _jsx("p", { children: info.componentStack }) })] }) }));
59
59
  };
60
- //# sourceMappingURL=index.js.map
package/lib/core/index.js CHANGED
@@ -1,2 +1 @@
1
1
  export { LayoutComponent, DefaultLayout, PageComponent, } from "./interfaces.js";
2
- //# sourceMappingURL=index.js.map
@@ -88,4 +88,3 @@ export class PageComponent extends LayoutComponent {
88
88
  });
89
89
  }
90
90
  }
91
- //# sourceMappingURL=interfaces.js.map
package/lib/core/types.js CHANGED
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=types.js.map
@@ -1,3 +1,2 @@
1
1
  export { Router } from "./router.js";
2
2
  export { Route } from "./route.js";
3
- //# sourceMappingURL=index.js.map
@@ -22,4 +22,3 @@ export function Route(props) {
22
22
  Object.seal(constructor.prototype);
23
23
  };
24
24
  }
25
- //# sourceMappingURL=route.js.map
@@ -21,4 +21,3 @@ export function Router(props) {
21
21
  Object.seal(constructor.prototype);
22
22
  };
23
23
  }
24
- //# sourceMappingURL=router.js.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=types.js.map
@@ -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
@@ -17,4 +17,3 @@ export function render(router, context, helmetContext = {}) {
17
17
  return { html };
18
18
  }
19
19
  export const staticRoutes = generateStaticRoutes(AppRouter);
20
- //# sourceMappingURL=entry-server.js.map
@@ -1 +0,0 @@
1
- //# sourceMappingURL=index.js.map
package/lib/index.js CHANGED
@@ -7,4 +7,3 @@ export * from "./decorators/index.js";
7
7
  export * from "./config/index.js";
8
8
  export { createFetchRequest };
9
9
  // export * as hooks from './hooks';
10
- //# sourceMappingURL=index.js.map
@@ -66,4 +66,3 @@ export const NotFoundPageComponent = () => {
66
66
  export const NotFoundComponentContainer = ({ content, }) => {
67
67
  return _jsx(_Fragment, { children: content({}) });
68
68
  };
69
- //# sourceMappingURL=index.js.map
@@ -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
@@ -85,4 +85,3 @@ export class RouterComponent {
85
85
  this._notFoundComponent = notFoundComponent;
86
86
  }
87
87
  }
88
- //# sourceMappingURL=interfaces.js.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=types.js.map
@@ -253,4 +253,3 @@ export const defineRouter = (option) => {
253
253
  return router;
254
254
  };
255
255
  };
256
- //# sourceMappingURL=index.js.map
@@ -88,4 +88,3 @@ export default async function handler(req, res) {
88
88
  res.status(500).end(e.stack);
89
89
  }
90
90
  }
91
- //# sourceMappingURL=index.js.map
@@ -31,4 +31,3 @@ export default function createFetchRequest(req, host) {
31
31
  }
32
32
  return new Request(url.href, init);
33
33
  }
34
- //# sourceMappingURL=createFetchRequest.js.map
@@ -27,4 +27,3 @@ export default function getIP() {
27
27
  }
28
28
  return ipAddress;
29
29
  }
30
- //# sourceMappingURL=getIp.js.map
@@ -25,4 +25,3 @@ export function fix404(url, res, appPath) {
25
25
  return res.sendFile(path.resolve(join(appPath, "dist/client/manifest.json")));
26
26
  }
27
27
  }
28
- //# sourceMappingURL=handleError.js.map
@@ -5,4 +5,3 @@ import { logServerInfo } from "./log.js";
5
5
  import { fix404 } from "./handleError.js";
6
6
  // Export section
7
7
  export { createFetchRequest, getIP, logServerInfo, fix404, };
8
- //# sourceMappingURL=index.js.map
@@ -66,4 +66,3 @@ export async function logServerInfo(port, isProduction) {
66
66
  // Set a higher limit for the number of listeners
67
67
  process.stdin.setMaxListeners(100);
68
68
  }
69
- //# sourceMappingURL=log.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rasengan",
3
3
  "private": false,
4
- "version": "1.0.0-beta.2",
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.7",
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
@@ -24,7 +24,7 @@
24
24
  "noEmit": false,
25
25
  "jsx": "react-jsx",
26
26
  "declaration": true,
27
- "sourceMap": true,
27
+ "sourceMap": false,
28
28
 
29
29
  /* Plugins */
30
30
  "plugins": [{ "name": "typescript-plugin-css-modules" }],
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",
@@ -1,7 +0,0 @@
1
- import { fileURLToPath } from 'url';
2
- import { dirname } from 'path';
3
-
4
- const __filename = fileURLToPath(import.meta.url);
5
- const __dirname = dirname(__filename);
6
-
7
- export default __dirname;
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);
@@ -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
- }
@@ -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
@@ -1,14 +0,0 @@
1
- export {
2
- type ILayoutComponent,
3
- LayoutComponent,
4
- DefaultLayout,
5
- PageComponent,
6
- } from "./interfaces.js";
7
-
8
- export type {
9
- AppProps,
10
- ReactComponentProps,
11
- ComponentProps,
12
- LoaderOptions,
13
- LoaderResponse,
14
- } from "./types.js";