rasengan 1.0.0-beta.9 → 1.1.0-beta.2
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 +44 -0
- package/README.md +36 -0
- package/bin.js +13 -0
- package/lib/esm/cli/index.js +30 -139
- 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 +92 -0
- package/lib/esm/core/dynamic/index.js +21 -0
- package/lib/esm/core/index.js +2 -1
- 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 +205 -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 +3 -6
- package/lib/esm/plugin.js +2 -0
- package/lib/esm/routing/components/index.js +72 -73
- package/lib/esm/routing/components/template.js +64 -0
- package/lib/esm/routing/index.js +4 -7
- package/lib/esm/routing/interfaces.js +100 -87
- package/lib/esm/routing/providers/metadata.js +42 -0
- package/lib/esm/routing/utils/define-router.js +80 -0
- package/lib/esm/routing/utils/define-routes-group.js +44 -0
- package/lib/esm/routing/utils/flat-routes.js +316 -0
- package/lib/esm/routing/utils/generate-metadata.js +83 -0
- package/lib/esm/routing/utils/generate-routes.js +368 -0
- package/lib/esm/routing/utils/index.js +5 -404
- package/lib/esm/scripts/build-command.js +17 -0
- package/lib/esm/scripts/generate-package-json.js +5 -5
- 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 +20 -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 +75 -0
- package/lib/esm/server/node/rendering.js +47 -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 +6 -0
- package/lib/tsconfig.esm.tsbuildinfo +1 -0
- package/lib/tsconfig.types.tsbuildinfo +1 -0
- package/lib/types/cli/index.d.ts +0 -1
- 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 +72 -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 -3
- 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 +6 -125
- 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 -6
- package/lib/types/plugin.d.ts +3 -0
- package/lib/types/routing/components/index.d.ts +7 -23
- package/lib/types/routing/components/template.d.ts +41 -0
- package/lib/types/routing/index.d.ts +5 -5
- package/lib/types/routing/interfaces.d.ts +18 -6
- package/lib/types/routing/providers/metadata.d.ts +5 -0
- package/lib/types/routing/types.d.ts +160 -5
- package/lib/types/routing/utils/define-router.d.ts +10 -0
- package/lib/types/routing/utils/define-routes-group.d.ts +7 -0
- package/lib/types/routing/utils/flat-routes.d.ts +7 -0
- package/lib/types/routing/utils/generate-metadata.d.ts +7 -0
- package/lib/types/routing/utils/generate-routes.d.ts +19 -0
- package/lib/types/routing/utils/index.d.ts +5 -39
- 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/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 +6 -0
- package/package.json +72 -46
- package/tsconfig.base.json +1 -5
- package/tsconfig.esm.json +2 -2
- package/tsconfig.types.json +3 -2
- package/types/client.d.ts +51 -0
- package/vite.config.ts +28 -76
- package/lib/cjs/cli/dirname.js +0 -16
- package/lib/cjs/cli/index.js +0 -154
- package/lib/cjs/config/index.js +0 -140
- package/lib/cjs/config/type.js +0 -2
- package/lib/cjs/core/components/index.js +0 -178
- package/lib/cjs/core/index.js +0 -6
- package/lib/cjs/core/interfaces.js +0 -189
- package/lib/cjs/core/types.js +0 -2
- package/lib/cjs/decorators/index.js +0 -1
- package/lib/cjs/decorators/route.js +0 -24
- package/lib/cjs/decorators/router.js +0 -38
- package/lib/cjs/decorators/types.js +0 -2
- package/lib/cjs/entries/entry-client.js +0 -40
- package/lib/cjs/entries/entry-server.js +0 -80
- package/lib/cjs/hooks/index.js +0 -0
- package/lib/cjs/index.js +0 -28
- package/lib/cjs/routing/components/index.js +0 -114
- package/lib/cjs/routing/index.js +0 -26
- package/lib/cjs/routing/interfaces.js +0 -94
- package/lib/cjs/routing/types.js +0 -2
- package/lib/cjs/routing/utils/index.js +0 -413
- package/lib/cjs/scripts/generate-package-json.js +0 -28
- package/lib/cjs/scripts/refresh-hack.js +0 -24
- package/lib/cjs/server/functions/vercel/api/index.js +0 -156
- package/lib/cjs/server/functions/vercel/vercel.json +0 -16
- package/lib/cjs/server/utils/createFetchRequest.js +0 -38
- package/lib/cjs/server/utils/getIp.js +0 -35
- package/lib/cjs/server/utils/handleError.js +0 -46
- package/lib/cjs/server/utils/index.js +0 -15
- package/lib/cjs/server/utils/log.js +0 -126
- package/lib/esm/cli/dirname.js +0 -14
- package/lib/esm/config/index.js +0 -135
- package/lib/esm/core/components/index.js +0 -144
- package/lib/esm/core/interfaces.js +0 -183
- package/lib/esm/decorators/index.js +0 -1
- package/lib/esm/decorators/route.js +0 -20
- package/lib/esm/decorators/router.js +0 -34
- package/lib/esm/entries/entry-client.js +0 -12
- package/lib/esm/entries/entry-server.js +0 -49
- package/lib/esm/hooks/index.js +0 -0
- package/lib/esm/scripts/refresh-hack.js +0 -22
- package/lib/esm/server/functions/vercel/api/index.js +0 -127
- package/lib/esm/server/functions/vercel/vercel.json +0 -16
- package/lib/esm/server/utils/createFetchRequest.js +0 -35
- package/lib/esm/server/utils/getIp.js +0 -29
- package/lib/esm/server/utils/handleError.js +0 -19
- package/lib/esm/server/utils/index.js +0 -7
- package/lib/esm/server/utils/log.js +0 -119
- package/lib/types/cli/dirname.d.ts +0 -2
- package/lib/types/config/index.d.ts +0 -60
- package/lib/types/config/type.d.ts +0 -92
- package/lib/types/core/components/index.d.ts +0 -50
- package/lib/types/core/interfaces.d.ts +0 -93
- package/lib/types/decorators/index.d.ts +0 -0
- package/lib/types/decorators/route.d.ts +0 -8
- package/lib/types/decorators/router.d.ts +0 -8
- package/lib/types/decorators/types.d.ts +0 -52
- package/lib/types/entries/entry-client.d.ts +0 -1
- package/lib/types/entries/entry-server.d.ts +0 -14
- package/lib/types/hooks/index.d.ts +0 -0
- package/lib/types/scripts/refresh-hack.d.ts +0 -1
- package/lib/types/server/functions/vercel/api/index.d.ts +0 -2
- package/lib/types/server/utils/createFetchRequest.d.ts +0 -5
- package/lib/types/server/utils/getIp.d.ts +0 -1
- package/lib/types/server/utils/handleError.d.ts +0 -2
- package/lib/types/server/utils/index.d.ts +0 -5
- package/lib/types/server/utils/log.d.ts +0 -7
- package/server.js +0 -234
- package/tsconfig.cjs.json +0 -8
- package/tsconfig.json +0 -33
- /package/lib/{esm/config/type.js → types/scripts/build-command.d.ts} +0 -0
- /package/lib/{esm/decorators/types.js → types/server/dev/server.d.ts} +0 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
## Unreleased
|
|
2
|
+
|
|
3
|
+
## 1.1.0-beta.2 (2025-07-09)
|
|
4
|
+
|
|
5
|
+
## 1.1.0-beta.1 (2025-07-09)
|
|
6
|
+
|
|
7
|
+
## 1.1.0-beta.0 (2025-07-09)
|
|
8
|
+
|
|
9
|
+
## 1.0.0 (2025-04-26)
|
|
10
|
+
|
|
11
|
+
- fix: handling metadata on client when navigating between pages [5fbbaca](https://github.com/rasengan-dev/rasenganjs/5fbbaca5ce206d693b5a5d394827a3804838ba5c)
|
|
12
|
+
- feat(rasengan): update metadata on client while navigating [1c373ff](https://github.com/rasengan-dev/rasenganjs/1c373ff3e7dacee52dde81f8bb0689856ffe0393)
|
|
13
|
+
- fix: fix build issue in ssr mode [6dfde61](https://github.com/rasengan-dev/rasenganjs/6dfde618f4f0e43d801b67afc4f4235e98a3976c)
|
|
14
|
+
- feat: generate output inside the ./dist folder in spa mode instead of ./dist/client [cf2b7b2](https://github.com/rasengan-dev/rasenganjs/cf2b7b29133ff4f3256c131fa895fcde4d590e93)
|
|
15
|
+
- feat: handling proxy in spa mode [7616f67](https://github.com/rasengan-dev/rasenganjs/7616f670d8f7ae0a02d494b13bbe03efc25cc26e)
|
|
16
|
+
- feat: generate template.js, config.json and index.html during build for spa [ed345f2](https://github.com/rasengan-dev/rasenganjs/ed345f2abda7c508a384a16409fc28799085476c)
|
|
17
|
+
- feat: Handling client rendering for spa mode [980eefc](https://github.com/rasengan-dev/rasenganjs/980eefc65a17016544c94b323d69a92d24ac149d)
|
|
18
|
+
- feat: adding handleSpaModeHandle to render blank html in dev server mode [fe6b79b](https://github.com/rasengan-dev/rasenganjs/fe6b79b370e8626ddc65a6f4142225fd71880a5a)
|
|
19
|
+
- feat: adding option 'ssr' into defineConfig to enable spa mode [d2da64d](https://github.com/rasengan-dev/rasenganjs/d2da64d8a372f5ad71ff26196c37658e78e71cc7)
|
|
20
|
+
- feat: merge static metadata and dynamic metadata [c979609](https://github.com/rasengan-dev/rasenganjs/c979609e5b45b45f9965a81c34fa73284dce3e09)
|
|
21
|
+
- feat: Enabling keypress event capture by using readline built in nodejs package [72422fd](https://github.com/rasengan-dev/rasenganjs/72422fd8f5eee401f0ba0468a51d09097dc3ae8d)
|
|
22
|
+
- feat: implement the mergeMetadata function to merge static and dynamic metadata together [29a88dd](https://github.com/rasengan-dev/rasenganjs/29a88ddc727f523d6fedb28b5166501fe48ee275)
|
|
23
|
+
|
|
24
|
+
## 1.0.0-beta.62 (2025-04-26)
|
|
25
|
+
|
|
26
|
+
## 1.0.0-beta.61 (2025-03-22)
|
|
27
|
+
|
|
28
|
+
## 1.0.0-beta.60 (2025-03-16)
|
|
29
|
+
|
|
30
|
+
## 1.0.0-beta.59 (2025-03-16)
|
|
31
|
+
|
|
32
|
+
## 1.0.0-beta.58 (2025-03-12)
|
|
33
|
+
|
|
34
|
+
## 1.0.0-beta.57 (2025-03-04)
|
|
35
|
+
|
|
36
|
+
## 1.0.0-beta.56 (2025-03-03)
|
|
37
|
+
|
|
38
|
+
## 1.0.0-beta.55 (2025-02-28)
|
|
39
|
+
|
|
40
|
+
## 1.0.0-beta.54 (2025-02-28)
|
|
41
|
+
|
|
42
|
+
## 1.0.0-beta.53 (2025-02-28)
|
|
43
|
+
|
|
44
|
+
## 1.0.0-beta.53 (2025-02-28)
|
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[](https://rasengan.dev)
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/rasengan)
|
|
4
|
+
[](https://www.npmjs.com/package/rasengan)
|
|
5
|
+
[](https://github.com/rasengan-dev/rasenganjs/blob/main/LICENSE)
|
|
6
|
+
|
|
7
|
+
## Getting Started
|
|
8
|
+
|
|
9
|
+
Based on modern tools, Rasengan.js will help you to create **high-quality web applications** with the benefit of React Components. It's a simple and easy-to-use framework that will help you to create a **beautiful and responsive web application**.
|
|
10
|
+
|
|
11
|
+
- Visit the [Rasengan.js Showcase](https://rasengan.dev/showcase) to see more sites built with Rasengan.js.
|
|
12
|
+
- Visit the [Rasengan.js Blog](https://rasengan.dev/blog) to get all news related to Rasengan.js.
|
|
13
|
+
|
|
14
|
+
## Documentation
|
|
15
|
+
|
|
16
|
+
Visit [https://rasengan.dev/docs](https://rasengan.dev/docs) to view the full documentation.
|
|
17
|
+
|
|
18
|
+
## Community
|
|
19
|
+
|
|
20
|
+
The Rasengan.js community can be found on [GitHub Discussions](https://github.com/rasengan-dev/rasenganjs/discussions) where you can ask questions, voice ideas, and share your projects with other people.
|
|
21
|
+
|
|
22
|
+
We also have a [Twitter](https://twitter.com/rasenganjs) account where you can follow us to get the latest news about Rasengan.js.
|
|
23
|
+
|
|
24
|
+
## License
|
|
25
|
+
|
|
26
|
+
Rasengan.js is [MIT licensed](https://github.com/rasengan-dev/rasenganjs/blob/main/LICENSE).
|
|
27
|
+
|
|
28
|
+
## Contributing
|
|
29
|
+
|
|
30
|
+
We are open to all contributions. If you want to contribute to Rasengan.js, please read the [Contributing Guide](https://github.com/rasengan-dev/rasenganjs/blob/main/CONTRIBUTING.md) to get started.
|
|
31
|
+
|
|
32
|
+
## Authors
|
|
33
|
+
|
|
34
|
+
Here are the authors of Rasengan.js, the people who are at the origin of this great framework:
|
|
35
|
+
|
|
36
|
+
- Dilane Kombou ([**@dilanekombou**](https://twitter.com/dilanekombou))
|
package/bin.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Import `process` explicitly if needed (e.g., in certain runtime environments).
|
|
4
|
+
import process from 'process';
|
|
5
|
+
|
|
6
|
+
// If not already set, default `NODE_ENV=development`
|
|
7
|
+
process.env.NODE_ENV = process.env.NODE_ENV ?? 'development';
|
|
8
|
+
|
|
9
|
+
// Import and execute the CLI script
|
|
10
|
+
import('./lib/esm/cli/index.js').catch((err) => {
|
|
11
|
+
console.error('Failed to start the Rasengan CLI:', err);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
});
|
package/lib/esm/cli/index.js
CHANGED
|
@@ -1,149 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
import chalk from "chalk";
|
|
50
|
-
import { Command } from "commander";
|
|
51
|
-
import { execa } from "execa";
|
|
52
|
-
// Config
|
|
53
|
-
// @ts-ignore
|
|
54
|
-
import config from "../../../../../rasengan.config.js";
|
|
55
|
-
var program = new Command();
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { execa } from 'execa';
|
|
4
|
+
const program = new Command();
|
|
56
5
|
program
|
|
57
|
-
.name(chalk.blue(
|
|
58
|
-
.version(
|
|
6
|
+
.name(chalk.blue('rasengan'))
|
|
7
|
+
.version('1.0.0', '-v, --version', 'Output the current version number');
|
|
59
8
|
// Handle the dev command
|
|
60
9
|
program
|
|
61
|
-
.command(
|
|
62
|
-
.option(
|
|
63
|
-
.description(
|
|
64
|
-
.action(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
env: __assign(__assign({}, process.env), { PORT: convertedPort ? convertedPort.toString() : undefined }),
|
|
81
|
-
});
|
|
82
|
-
return [2 /*return*/];
|
|
83
|
-
});
|
|
10
|
+
.command('dev')
|
|
11
|
+
.option('-p <port>')
|
|
12
|
+
.description('Start development server')
|
|
13
|
+
.action(async ({ p: port }) => {
|
|
14
|
+
const convertedPort = Number(port);
|
|
15
|
+
// Checking port
|
|
16
|
+
if (port &&
|
|
17
|
+
(isNaN(convertedPort) || convertedPort < 0 || convertedPort > 65535)) {
|
|
18
|
+
console.log('');
|
|
19
|
+
console.log(chalk.red('Please provide a valid port number between 0-65535'));
|
|
20
|
+
console.log('');
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
execa('node', ['node_modules/rasengan/lib/esm/server/dev/server'], {
|
|
24
|
+
stdio: 'inherit',
|
|
25
|
+
env: {
|
|
26
|
+
...process.env,
|
|
27
|
+
PORT: convertedPort ? convertedPort.toString() : undefined,
|
|
28
|
+
},
|
|
84
29
|
});
|
|
85
30
|
});
|
|
86
31
|
// Handle the build command
|
|
87
32
|
program
|
|
88
|
-
.command(
|
|
89
|
-
.description(
|
|
90
|
-
.action(
|
|
91
|
-
execa(
|
|
92
|
-
|
|
93
|
-
stdio: "inherit", // Pipe child process output to the parent process
|
|
33
|
+
.command('build')
|
|
34
|
+
.description('Build the project')
|
|
35
|
+
.action(async () => {
|
|
36
|
+
execa('node', ['node_modules/rasengan/lib/esm/scripts/build-command'], {
|
|
37
|
+
stdio: 'inherit',
|
|
94
38
|
});
|
|
95
39
|
});
|
|
96
|
-
// Handle the prebuild command
|
|
97
|
-
program
|
|
98
|
-
.command("prepare")
|
|
99
|
-
.description("Prepare the project")
|
|
100
|
-
.action(function () {
|
|
101
|
-
var _a, _b;
|
|
102
|
-
// Displaying the message
|
|
103
|
-
console.log("");
|
|
104
|
-
console.log(chalk.blue("Preparing your project for production..."));
|
|
105
|
-
console.log("");
|
|
106
|
-
// Checking the config file in order to know about hosting strategy
|
|
107
|
-
var server = config.server;
|
|
108
|
-
var hostingStrategy = (_b = (_a = server === null || server === void 0 ? void 0 : server.production) === null || _a === void 0 ? void 0 : _a.hosting) !== null && _b !== void 0 ? _b : "custom";
|
|
109
|
-
if (hostingStrategy === "vercel") {
|
|
110
|
-
// Displaying the message
|
|
111
|
-
console.log("Your project is configured to be hosted on ".concat(chalk.bold.blue(hostingStrategy), "\n"));
|
|
112
|
-
// Copying the api folder to the root directory
|
|
113
|
-
execa("cp", ["-r", "node_modules/rasengan/lib/server/functions/vercel/api", "."], {
|
|
114
|
-
stdio: "inherit",
|
|
115
|
-
});
|
|
116
|
-
// Copying the vercel.json file to the root directory
|
|
117
|
-
execa("cp", ["node_modules/rasengan/lib/server/functions/vercel/vercel.json", "."], {
|
|
118
|
-
stdio: "inherit",
|
|
119
|
-
});
|
|
120
|
-
// Removing index.d.ts and index.js.map files from the api folder
|
|
121
|
-
execa("rm", ["api/index.d.ts"], {
|
|
122
|
-
stdio: "inherit",
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
else if (hostingStrategy === "netlify") {
|
|
126
|
-
// Copying the netlify.toml file to the root directory
|
|
127
|
-
// execa(
|
|
128
|
-
// "cp",
|
|
129
|
-
// ["node_modules/rasengan/src/server/functions/netlify/netlify.toml", "."],
|
|
130
|
-
// {
|
|
131
|
-
// stdio: "inherit",
|
|
132
|
-
// }
|
|
133
|
-
// );
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
// Handle the start command
|
|
137
|
-
program
|
|
138
|
-
.command("start")
|
|
139
|
-
.description("Start the project in production mode")
|
|
140
|
-
.action(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
141
|
-
return __generator(this, function (_a) {
|
|
142
|
-
execa("npm", ["run", "preview"], {
|
|
143
|
-
cwd: "node_modules/rasengan",
|
|
144
|
-
stdio: "inherit", // Pipe child process output to the parent process
|
|
145
|
-
});
|
|
146
|
-
return [2 /*return*/];
|
|
147
|
-
});
|
|
148
|
-
}); });
|
|
149
40
|
program.parse(process.argv);
|
|
@@ -0,0 +1,80 @@
|
|
|
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 | AppConfigFunction | AppConfigFunctionAsync} loadedConfig
|
|
5
|
+
*/
|
|
6
|
+
export const defineConfig = async (loadedConfig) => {
|
|
7
|
+
return async () => {
|
|
8
|
+
let config;
|
|
9
|
+
// Check if the loadedConfig is a function
|
|
10
|
+
if (typeof loadedConfig === 'function') {
|
|
11
|
+
// Call the function to get the config
|
|
12
|
+
const result = loadedConfig();
|
|
13
|
+
// Check if it's a promise (asynchronous function)
|
|
14
|
+
if (result instanceof Promise) {
|
|
15
|
+
config = await result; // Await the promise result (AppConfigFunctionAsync)
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
config = result; // Synchronous function result (AppConfigFunction)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
config = loadedConfig;
|
|
23
|
+
}
|
|
24
|
+
const { ssr, server, vite, redirects } = config;
|
|
25
|
+
// Define default values for vite config coming from loadedConfig.vite
|
|
26
|
+
const defaultViteConfig = {
|
|
27
|
+
...vite,
|
|
28
|
+
resolve: {
|
|
29
|
+
symbole: vite?.resolve?.symbole || '@',
|
|
30
|
+
alias: vite?.resolve?.alias || [],
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
// Define default values for server config coming from loadedConfig.server
|
|
34
|
+
const defaultServerConfig = {
|
|
35
|
+
development: {
|
|
36
|
+
port: server?.development?.port || undefined,
|
|
37
|
+
open: server?.development?.open || false,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
// Define default values for redirects config coming from loadedConfig.redirects
|
|
41
|
+
const defaultRedirectsConfig = redirects || (() => new Promise((resolve) => resolve([])));
|
|
42
|
+
try {
|
|
43
|
+
const config = {
|
|
44
|
+
ssr: ssr ?? true,
|
|
45
|
+
server: defaultServerConfig,
|
|
46
|
+
vite: {
|
|
47
|
+
...defaultViteConfig,
|
|
48
|
+
resolve: {
|
|
49
|
+
alias: [
|
|
50
|
+
{
|
|
51
|
+
find: defaultViteConfig.resolve.symbole,
|
|
52
|
+
replacement: './src',
|
|
53
|
+
},
|
|
54
|
+
...defaultViteConfig.resolve.alias,
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
redirects: defaultRedirectsConfig,
|
|
59
|
+
};
|
|
60
|
+
return config;
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
return {
|
|
64
|
+
ssr: true,
|
|
65
|
+
vite: {
|
|
66
|
+
appType: 'custom',
|
|
67
|
+
resolve: {
|
|
68
|
+
alias: [
|
|
69
|
+
{
|
|
70
|
+
find: '@',
|
|
71
|
+
replacement: './src',
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
redirects: () => new Promise((resolve) => resolve([])),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { resolvePath } from './path.js';
|
|
2
|
+
import fs from 'fs/promises';
|
|
3
|
+
export const extensions = [
|
|
4
|
+
'.mjs',
|
|
5
|
+
'.js',
|
|
6
|
+
'.mts',
|
|
7
|
+
'.ts',
|
|
8
|
+
'.jsx',
|
|
9
|
+
'.tsx',
|
|
10
|
+
'.json',
|
|
11
|
+
];
|
|
12
|
+
/**
|
|
13
|
+
* Asynchronously loads a module from a file path only in the server-side environment.
|
|
14
|
+
*
|
|
15
|
+
* @param path - The path to the module.
|
|
16
|
+
* @returns The loaded module.
|
|
17
|
+
*/
|
|
18
|
+
export const loadModuleSSR = async (path) => {
|
|
19
|
+
try {
|
|
20
|
+
let modulePath = path;
|
|
21
|
+
// Check if the module path has an extension
|
|
22
|
+
const moduleExtension = path.split('.').pop(); // eg: js or ts
|
|
23
|
+
if (!moduleExtension || !extensions.includes(`.${moduleExtension}`)) {
|
|
24
|
+
const { path: newPath } = await findModulePath(path);
|
|
25
|
+
modulePath = newPath;
|
|
26
|
+
}
|
|
27
|
+
const module = await import(/* @vite-ignore */ resolvePath(modulePath));
|
|
28
|
+
return module;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
throw new Error(error);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Finds the module path with the right extension.
|
|
36
|
+
*
|
|
37
|
+
* @param path - The path to the module.
|
|
38
|
+
* @returns The module path and extension.
|
|
39
|
+
*/
|
|
40
|
+
export const findModulePath = async (path) => {
|
|
41
|
+
try {
|
|
42
|
+
let modulePath = path;
|
|
43
|
+
let rightExtension = '';
|
|
44
|
+
// Check if the module path has an extension
|
|
45
|
+
const moduleExtension = path.split('.').pop(); // eg: js or ts
|
|
46
|
+
if (!moduleExtension || !extensions.includes(`.${moduleExtension}`)) {
|
|
47
|
+
for (let ext of extensions) {
|
|
48
|
+
const newModulePath = `${modulePath}${ext}`;
|
|
49
|
+
try {
|
|
50
|
+
await fs.access(newModulePath);
|
|
51
|
+
modulePath = newModulePath;
|
|
52
|
+
rightExtension = ext;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (modulePath === path) {
|
|
60
|
+
throw new Error(`Module "${path}" not found`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
path: modulePath,
|
|
65
|
+
extension: rightExtension,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
throw new Error(error);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
export const getDirname = async (url) => {
|
|
73
|
+
// Load the dirname function from the path module
|
|
74
|
+
// and return the dirname of the file URL
|
|
75
|
+
const { dirname } = await import('node:path');
|
|
76
|
+
const { fileURLToPath } = await import('node:url');
|
|
77
|
+
return dirname(fileURLToPath(url));
|
|
78
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
/**
|
|
3
|
+
* Adapts the provided file path to a valid URL format based on the operating system.
|
|
4
|
+
*
|
|
5
|
+
* @param path - The file path to be adapted.
|
|
6
|
+
* @returns The adapted file path in a valid URL format.
|
|
7
|
+
*/
|
|
8
|
+
export const resolvePath = (pathValue) => {
|
|
9
|
+
// Check the OS
|
|
10
|
+
const isWindows = process.platform === 'win32';
|
|
11
|
+
// Adapt the path
|
|
12
|
+
if (isWindows) {
|
|
13
|
+
return `file:///${path.normalize(pathValue)}`;
|
|
14
|
+
}
|
|
15
|
+
return path.normalize(pathValue);
|
|
16
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// core/config/defaults.ts
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
// Define core external packages
|
|
4
|
+
const CORE_EXTERNALS = [
|
|
5
|
+
// '@rasenganjs/mdx',
|
|
6
|
+
// '@rasenganjs/vercel',
|
|
7
|
+
// '@rasenganjs/netlify',
|
|
8
|
+
];
|
|
9
|
+
export const createDefaultViteConfig = (rootPath, __dirname, mode, config) => {
|
|
10
|
+
// Combine core externals with user-defined externals
|
|
11
|
+
const externals = [
|
|
12
|
+
...CORE_EXTERNALS,
|
|
13
|
+
...(Array.isArray(config.vite?.build?.external)
|
|
14
|
+
? config.vite.build.external
|
|
15
|
+
: []),
|
|
16
|
+
];
|
|
17
|
+
return {
|
|
18
|
+
...config.vite,
|
|
19
|
+
root: rootPath,
|
|
20
|
+
build: {
|
|
21
|
+
sourcemap: mode === 'development',
|
|
22
|
+
rollupOptions: {
|
|
23
|
+
external: externals,
|
|
24
|
+
input: './src/index',
|
|
25
|
+
output: {
|
|
26
|
+
manualChunks(id) {
|
|
27
|
+
if (id.includes('node_modules'))
|
|
28
|
+
return 'vendor';
|
|
29
|
+
if (id.includes('src/components'))
|
|
30
|
+
return 'shared-components';
|
|
31
|
+
if (config.ssr) {
|
|
32
|
+
if (id.includes('src/app') && id.includes('.page.')) {
|
|
33
|
+
const parts = id.split('src/app')[1]?.split('/');
|
|
34
|
+
if (parts?.length) {
|
|
35
|
+
const pageName = parts.pop()?.split('.')[0];
|
|
36
|
+
return pageName ? `page-${pageName}` : undefined;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return undefined;
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
outDir: 'dist',
|
|
45
|
+
chunkSizeWarningLimit: 1000,
|
|
46
|
+
},
|
|
47
|
+
environments: {
|
|
48
|
+
client: {
|
|
49
|
+
build: {
|
|
50
|
+
manifest: true,
|
|
51
|
+
outDir: config.ssr ? 'dist/client' : 'dist',
|
|
52
|
+
rollupOptions: {
|
|
53
|
+
input: './src/index',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
ssr: {
|
|
58
|
+
build: {
|
|
59
|
+
outDir: 'dist/server',
|
|
60
|
+
rollupOptions: {
|
|
61
|
+
input: {
|
|
62
|
+
'entry.server': join(__dirname, './lib/esm/entries/server/entry.server.js'),
|
|
63
|
+
'app.router': './src/app/app.router',
|
|
64
|
+
main: './src/main',
|
|
65
|
+
template: './src/template',
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
ssrEmitAssets: false,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
resolve: {
|
|
73
|
+
alias: Array.isArray(config.vite?.resolve?.alias)
|
|
74
|
+
? config.vite.resolve.alias.map(({ find, replacement }) => ({
|
|
75
|
+
find,
|
|
76
|
+
replacement: join(rootPath, replacement),
|
|
77
|
+
}))
|
|
78
|
+
: [],
|
|
79
|
+
},
|
|
80
|
+
builder: {
|
|
81
|
+
buildApp: async (builder) => {
|
|
82
|
+
if (config.ssr) {
|
|
83
|
+
await builder.build(builder.environments.ssr);
|
|
84
|
+
}
|
|
85
|
+
await builder.build(builder.environments.client);
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
cacheDir: '.rasengan/',
|
|
89
|
+
envPrefix: 'RASENGAN_',
|
|
90
|
+
appType: 'custom',
|
|
91
|
+
};
|
|
92
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Suspense, lazy } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* It allows you to defer loading of Client Components,
|
|
5
|
+
* and only include them in the client bundle when they're needed
|
|
6
|
+
* @param load
|
|
7
|
+
* @param fallback
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export function dynamicLoad(load, fallback = _jsx(_Fragment, {}) // Default pending UI element
|
|
11
|
+
) {
|
|
12
|
+
try {
|
|
13
|
+
const LazyComponent = lazy(load);
|
|
14
|
+
// Return a functional component preserving the exact props type
|
|
15
|
+
const WrappedComponent = (props) => (_jsx(Suspense, { fallback: fallback, children: _jsx(LazyComponent, { ...props }) }));
|
|
16
|
+
return WrappedComponent;
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
throw new Error(error);
|
|
20
|
+
}
|
|
21
|
+
}
|
package/lib/esm/core/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
// export { defineConfig, resolvePath } from "./config/index.js";
|
|
2
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './logger.js';
|