rasengan 1.0.0-beta.56 → 1.0.0-beta.58

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 CHANGED
@@ -1,5 +1,9 @@
1
1
  ## Unreleased
2
2
 
3
+ ## 1.0.0-beta.58 (2025-03-12)
4
+
5
+ ## 1.0.0-beta.57 (2025-03-04)
6
+
3
7
  ## 1.0.0-beta.56 (2025-03-03)
4
8
 
5
9
  ## 1.0.0-beta.55 (2025-02-28)
@@ -1,15 +1,16 @@
1
+ import path from 'node:path';
1
2
  /**
2
3
  * Adapts the provided file path to a valid URL format based on the operating system.
3
4
  *
4
5
  * @param path - The file path to be adapted.
5
6
  * @returns The adapted file path in a valid URL format.
6
7
  */
7
- export const resolvePath = (path) => {
8
+ export const resolvePath = (pathValue) => {
8
9
  // Check the OS
9
10
  const isWindows = process.platform === 'win32';
10
11
  // Adapt the path
11
12
  if (isWindows) {
12
- return `file:///${path}`;
13
+ return `file:///${path.normalize(pathValue)}`;
13
14
  }
14
- return path;
15
+ return path.normalize(pathValue);
15
16
  };
@@ -1,30 +1,32 @@
1
1
  import { resolve } from 'path';
2
2
  import fs from 'fs';
3
3
  import { loadModuleSSR } from '../config/utils/load-modules.js';
4
- function loadRasenganConfig() {
4
+ function loadRasenganGlobal() {
5
5
  return {
6
6
  name: 'vite-plugin-rasengan-config',
7
7
  async config(_, { command }) {
8
8
  if (command !== 'build')
9
9
  return;
10
- const configPath = resolve(process.cwd(), 'rasengan.config.js');
11
- if (!fs.existsSync(configPath)) {
12
- throw new Error(`Configuration file not found at: ${configPath}`);
10
+ const packageJsonPath = resolve(process.cwd(), 'package.json');
11
+ if (!fs.existsSync(packageJsonPath)) {
12
+ throw new Error(`Package.json file not found at: ${packageJsonPath}`);
13
13
  }
14
- const rasenganConfig = await (await loadModuleSSR(configPath)).default;
15
- const partialConfig = {
16
- server: rasenganConfig.server ?? {},
17
- redirects: rasenganConfig.redirects
18
- ? await rasenganConfig.redirects()
19
- : [],
14
+ const packageJsonRaw = fs.readFileSync(packageJsonPath, {
15
+ encoding: 'utf-8',
16
+ });
17
+ const packageJson = JSON.parse(packageJsonRaw);
18
+ const rasenganConfig = {
19
+ version: packageJson.version,
20
+ ssr: true,
20
21
  };
21
22
  // Inject the configuration as a global constant
22
23
  return {
23
24
  define: {
24
- ['__RASENGAN_CONFIG__']: JSON.stringify(partialConfig),
25
+ ['Rasengan']: JSON.stringify(rasenganConfig),
25
26
  },
26
27
  };
27
28
  },
29
+ apply: 'build',
28
30
  };
29
31
  }
30
32
  function rasenganConfigPlugin() {
@@ -113,4 +115,4 @@ export function rasengan({ adapter = { name: Adapters.DEFAULT, prepare: async ()
113
115
  },
114
116
  };
115
117
  }
116
- export const plugins = [];
118
+ export const plugins = [loadRasenganGlobal()];
@@ -34,7 +34,7 @@ export const HeadComponent = ({ metadata, assets = [], children = undefined, })
34
34
  const description = metadata.page.description;
35
35
  return { title, description };
36
36
  }, [metadata]);
37
- return (_jsxs("head", { children: [metaTags, assets, _jsx("title", { children: title }), _jsx("meta", { name: "description", content: description, "data-rg": "true" }), children] }));
37
+ return (_jsxs("head", { children: [_jsx("meta", { name: "generator", content: "Rasengan.js" }), metaTags, assets, _jsx("title", { children: title }), _jsx("meta", { name: "description", content: description, "data-rg": "true" }), children] }));
38
38
  };
39
39
  /**
40
40
  * Body component
@@ -24,7 +24,7 @@ const generateRoutesGroup = (path, children) => {
24
24
  pages.push(...childrenPages);
25
25
  }
26
26
  else {
27
- const routePath = path[0] === '/' ? path : `/${path}`;
27
+ const routePath = path === '/' ? '' : path[0] === '/' ? path : `/${path}`;
28
28
  // Check if the page is a PageComponent
29
29
  if (page['path']) {
30
30
  const pagePath = page['path'][0] === '/' ? page['path'].slice(1) : page['path'];
@@ -27,7 +27,6 @@ async function devRequestHandler(req, res, viteDevServer, options) {
27
27
  const AppRouter = await (await runner.import(join(`${options.rootPath}/src/app/app.router`))).default;
28
28
  // Get static routes
29
29
  const staticRoutes = generateRoutes(AppRouter);
30
- console.log({ staticRoutes: JSON.stringify(staticRoutes) });
31
30
  // Create static handler
32
31
  let handler = createStaticHandler(staticRoutes);
33
32
  if (isDataRequest(req)) {
@@ -7,15 +7,16 @@ import createRasenganRequest from './utils.js';
7
7
  import { extractHeadersFromRRContext, extractMetaFromRRContext, isRedirectResponse, isStaticRedirectFromConfig, } from '../dev/utils.js';
8
8
  import { handleRedirectRequest } from '../dev/handlers.js';
9
9
  import { loadModuleSSR } from '../../core/config/utils/load-modules.js';
10
+ import { resolvePath } from '../../core/config/utils/path.js';
10
11
  export function createRequestHandler(options) {
11
12
  const { build: buildOptions } = options;
12
13
  const manifest = new ManifestManager(path.posix.join(buildOptions.buildDirectory, buildOptions.clientPathDirectory, buildOptions.manifestPathDirectory, 'manifest.json'));
13
14
  return async function requestHandler(req, res) {
14
15
  try {
15
16
  // Get server entry
16
- const entry = await import(path.posix.join(buildOptions.buildDirectory, buildOptions.serverPathDirectory, buildOptions.entryServerPath));
17
+ const entry = await import(resolvePath(path.posix.join(buildOptions.buildDirectory, buildOptions.serverPathDirectory, buildOptions.entryServerPath)));
17
18
  // Get AppRouter
18
- const AppRouter = await (await import(path.posix.join(buildOptions.buildDirectory, buildOptions.serverPathDirectory, 'app.router.js'))).default;
19
+ const AppRouter = await (await import(resolvePath(path.posix.join(buildOptions.buildDirectory, buildOptions.serverPathDirectory, 'app.router.js')))).default;
19
20
  // Get Config
20
21
  const configHandler = await (await loadModuleSSR(path.posix.join(buildOptions.buildDirectory, buildOptions.serverPathDirectory, 'config.js'))).default;
21
22
  const config = await configHandler();
@@ -0,0 +1,5 @@
1
+ import os from 'node:os';
2
+ /**
3
+ * Check if the current OS is the provided one
4
+ */
5
+ export const checkOsPlateform = (osname) => osname === os.platform();
@@ -1 +1 @@
1
- {"root":["../src/client.ts","../src/index.ts","../src/plugin.ts","../src/server.ts","../src/cli/index.ts","../src/core/index.ts","../src/core/types.ts","../src/core/config/index.ts","../src/core/config/type.ts","../src/core/config/utils/define-config.ts","../src/core/config/utils/load-modules.ts","../src/core/config/utils/path.ts","../src/core/config/vite/defaults.ts","../src/core/dynamic/index.tsx","../src/core/middlewares/index.ts","../src/core/middlewares/logger.ts","../src/core/plugins/index.ts","../src/core/utils/log.ts","../src/entries/client/render.tsx","../src/entries/server/entry.server.tsx","../src/entries/server/index.tsx","../src/routing/index.ts","../src/routing/interfaces.tsx","../src/routing/types.ts","../src/routing/components/index.tsx","../src/routing/components/template.tsx","../src/routing/utils/define-router.tsx","../src/routing/utils/define-routes-group.tsx","../src/routing/utils/generate-metadata.tsx","../src/routing/utils/generate-routes.tsx","../src/routing/utils/index.tsx","../src/scripts/build-command.js","../src/scripts/generate-package-json.js","../src/scripts/utils/check-os.js","../src/scripts/utils/copy.js","../src/server/build/index.ts","../src/server/build/manifest.tsx","../src/server/dev/handlers.tsx","../src/server/dev/server.ts","../src/server/dev/utils.ts","../src/server/node/index.tsx","../src/server/node/rendering.ts","../src/server/node/stream.ts","../src/server/node/utils.ts","../src/server/runtime/mode.ts","../src/server/virtual/index.ts","../types/client.d.ts"],"version":"5.7.2"}
1
+ {"root":["../src/client.ts","../src/index.ts","../src/plugin.ts","../src/server.ts","../src/cli/index.ts","../src/core/index.ts","../src/core/types.ts","../src/core/config/index.ts","../src/core/config/type.ts","../src/core/config/utils/define-config.ts","../src/core/config/utils/load-modules.ts","../src/core/config/utils/path.ts","../src/core/config/vite/defaults.ts","../src/core/dynamic/index.tsx","../src/core/middlewares/index.ts","../src/core/middlewares/logger.ts","../src/core/plugins/index.ts","../src/core/utils/log.ts","../src/entries/client/render.tsx","../src/entries/server/entry.server.tsx","../src/entries/server/index.tsx","../src/routing/index.ts","../src/routing/interfaces.tsx","../src/routing/types.ts","../src/routing/components/index.tsx","../src/routing/components/template.tsx","../src/routing/utils/define-router.tsx","../src/routing/utils/define-routes-group.tsx","../src/routing/utils/generate-metadata.tsx","../src/routing/utils/generate-routes.tsx","../src/routing/utils/index.tsx","../src/scripts/build-command.js","../src/scripts/generate-package-json.js","../src/scripts/utils/check-os.js","../src/scripts/utils/copy.js","../src/server/build/index.ts","../src/server/build/manifest.tsx","../src/server/dev/handlers.tsx","../src/server/dev/server.ts","../src/server/dev/utils.ts","../src/server/node/index.tsx","../src/server/node/rendering.ts","../src/server/node/stream.ts","../src/server/node/utils.ts","../src/server/runtime/mode.ts","../src/server/runtime/utils.ts","../src/server/virtual/index.ts","../types/client.d.ts"],"version":"5.8.2"}
@@ -1 +1 @@
1
- {"root":["../src/client.ts","../src/index.ts","../src/plugin.ts","../src/server.ts","../src/cli/index.ts","../src/core/index.ts","../src/core/types.ts","../src/core/config/index.ts","../src/core/config/type.ts","../src/core/config/utils/define-config.ts","../src/core/config/utils/load-modules.ts","../src/core/config/utils/path.ts","../src/core/config/vite/defaults.ts","../src/core/dynamic/index.tsx","../src/core/middlewares/index.ts","../src/core/middlewares/logger.ts","../src/core/plugins/index.ts","../src/core/utils/log.ts","../src/entries/client/render.tsx","../src/entries/server/entry.server.tsx","../src/entries/server/index.tsx","../src/routing/index.ts","../src/routing/interfaces.tsx","../src/routing/types.ts","../src/routing/components/index.tsx","../src/routing/components/template.tsx","../src/routing/utils/define-router.tsx","../src/routing/utils/define-routes-group.tsx","../src/routing/utils/generate-metadata.tsx","../src/routing/utils/generate-routes.tsx","../src/routing/utils/index.tsx","../src/scripts/build-command.js","../src/scripts/generate-package-json.js","../src/scripts/utils/check-os.js","../src/scripts/utils/copy.js","../src/server/build/index.ts","../src/server/build/manifest.tsx","../src/server/dev/handlers.tsx","../src/server/dev/server.ts","../src/server/dev/utils.ts","../src/server/node/index.tsx","../src/server/node/rendering.ts","../src/server/node/stream.ts","../src/server/node/utils.ts","../src/server/runtime/mode.ts","../src/server/virtual/index.ts","../types/client.d.ts"],"version":"5.7.2"}
1
+ {"root":["../src/client.ts","../src/index.ts","../src/plugin.ts","../src/server.ts","../src/cli/index.ts","../src/core/index.ts","../src/core/types.ts","../src/core/config/index.ts","../src/core/config/type.ts","../src/core/config/utils/define-config.ts","../src/core/config/utils/load-modules.ts","../src/core/config/utils/path.ts","../src/core/config/vite/defaults.ts","../src/core/dynamic/index.tsx","../src/core/middlewares/index.ts","../src/core/middlewares/logger.ts","../src/core/plugins/index.ts","../src/core/utils/log.ts","../src/entries/client/render.tsx","../src/entries/server/entry.server.tsx","../src/entries/server/index.tsx","../src/routing/index.ts","../src/routing/interfaces.tsx","../src/routing/types.ts","../src/routing/components/index.tsx","../src/routing/components/template.tsx","../src/routing/utils/define-router.tsx","../src/routing/utils/define-routes-group.tsx","../src/routing/utils/generate-metadata.tsx","../src/routing/utils/generate-routes.tsx","../src/routing/utils/index.tsx","../src/scripts/build-command.js","../src/scripts/generate-package-json.js","../src/scripts/utils/check-os.js","../src/scripts/utils/copy.js","../src/server/build/index.ts","../src/server/build/manifest.tsx","../src/server/dev/handlers.tsx","../src/server/dev/server.ts","../src/server/dev/utils.ts","../src/server/node/index.tsx","../src/server/node/rendering.ts","../src/server/node/stream.ts","../src/server/node/utils.ts","../src/server/runtime/mode.ts","../src/server/runtime/utils.ts","../src/server/virtual/index.ts","../types/client.d.ts"],"version":"5.8.2"}
@@ -4,4 +4,4 @@
4
4
  * @param path - The file path to be adapted.
5
5
  * @returns The adapted file path in a valid URL format.
6
6
  */
7
- export declare const resolvePath: (path: string) => string;
7
+ export declare const resolvePath: (pathValue: string) => string;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Check if the current OS is the provided one
3
+ */
4
+ export declare const checkOsPlateform: (osname: "aix" | "darwin" | "freebsd" | "linux" | "openbsd" | "sunos" | "win32") => boolean;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rasengan",
3
3
  "private": false,
4
- "version": "1.0.0-beta.56",
4
+ "version": "1.0.0-beta.58",
5
5
  "description": "The modern React Framework",
6
6
  "type": "module",
7
7
  "main": "lib/esm/index.js",
@@ -79,7 +79,7 @@
79
79
  "sass": "*",
80
80
  "stylus": "*",
81
81
  "vite": "^6.0.0",
82
- "@rasenganjs/mdx": "^1.0.6"
82
+ "@rasenganjs/mdx": "^1.1.0-beta.0"
83
83
  },
84
84
  "peerDependenciesMeta": {
85
85
  "@types/node": {
@@ -135,7 +135,7 @@
135
135
  ],
136
136
  "scripts": {
137
137
  "build:compile": "tsc -b ./tsconfig.esm.json ./tsconfig.types.json",
138
- "build:clean": "rm -rf ./lib",
138
+ "build:clean": "rimraf ./lib",
139
139
  "build": "pnpm run build:clean & pnpm run build:compile",
140
140
  "deploy": "pnpm publish --access public",
141
141
  "deploy:beta": "pnpm run deploy --tag beta",