rasengan 1.0.0-beta.43 → 1.0.0-beta.44
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/lib/esm/config/index.js +38 -8
- package/lib/esm/core/components/index.js +3 -3
- package/lib/esm/entries/entry-server-stream.js +4 -12
- package/lib/esm/entries/entry-server.js +7 -10
- package/lib/esm/scripts/prepare-prod.js +9 -20
- package/lib/esm/scripts/utils/check-os.js +7 -0
- package/lib/esm/scripts/utils/copy.js +16 -0
- package/lib/esm/server/functions/vercel/api/index.js +23 -37
- package/lib/types/config/index.d.ts +8 -6
- package/lib/types/core/components/index.d.ts +2 -1
- package/lib/types/core/types.d.ts +0 -1
- package/lib/types/scripts/utils/check-os.d.ts +1 -0
- package/lib/types/scripts/utils/copy.d.ts +1 -0
- package/package.json +1 -1
- package/server.js +32 -34
- package/vite.config.ts +9 -7
- /package/lib/esm/server/functions/netlify/{functions → netlify/functions}/api.js +0 -0
- /package/lib/types/server/functions/netlify/{functions → netlify/functions}/api.d.ts +0 -0
package/lib/esm/config/index.js
CHANGED
|
@@ -7,6 +7,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
7
7
|
}
|
|
8
8
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
9
|
};
|
|
10
|
+
// import { fileURLToPath } from "node:url";
|
|
10
11
|
/**
|
|
11
12
|
* Function to define the config for the app
|
|
12
13
|
* It will be used by vite.config.ts and other files in other to configure the app
|
|
@@ -44,9 +45,9 @@ export var defineConfig = function (loadedConfig) {
|
|
|
44
45
|
},
|
|
45
46
|
};
|
|
46
47
|
// Define default values for experimentals features coming from loadedConfig.experimentals
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
48
|
+
// const defaultExperimentalFeaturesConfig = {
|
|
49
|
+
// stream: experimental?.stream || true
|
|
50
|
+
// }
|
|
50
51
|
try {
|
|
51
52
|
var config = {
|
|
52
53
|
reactStrictMode: reactStrictMode === undefined ? true : reactStrictMode,
|
|
@@ -90,13 +91,12 @@ export var defineConfig = function (loadedConfig) {
|
|
|
90
91
|
},
|
|
91
92
|
appType: "custom",
|
|
92
93
|
},
|
|
93
|
-
experimental: defaultExperimentalFeaturesConfig,
|
|
94
|
+
// experimental: defaultExperimentalFeaturesConfig,
|
|
94
95
|
// More config options...
|
|
95
96
|
};
|
|
96
97
|
return config;
|
|
97
98
|
}
|
|
98
99
|
catch (error) {
|
|
99
|
-
console.error(error);
|
|
100
100
|
return {
|
|
101
101
|
reactStrictMode: true,
|
|
102
102
|
vite: {
|
|
@@ -127,9 +127,9 @@ export var defineConfig = function (loadedConfig) {
|
|
|
127
127
|
],
|
|
128
128
|
},
|
|
129
129
|
},
|
|
130
|
-
experimental: {
|
|
131
|
-
|
|
132
|
-
},
|
|
130
|
+
// experimental: {
|
|
131
|
+
// stream: true
|
|
132
|
+
// },
|
|
133
133
|
};
|
|
134
134
|
}
|
|
135
135
|
};
|
|
@@ -165,3 +165,33 @@ export var resolvePath = function (path) {
|
|
|
165
165
|
}
|
|
166
166
|
return path;
|
|
167
167
|
};
|
|
168
|
+
/**
|
|
169
|
+
* Asynchronously loads a module from a file path relative to the project root directory.
|
|
170
|
+
*
|
|
171
|
+
* This function checks the current environment (production or development) and adjusts the file path accordingly. It then resolves the file path to a valid URL format based on the operating system.
|
|
172
|
+
*
|
|
173
|
+
* @param filename - The name of the file to be loaded.
|
|
174
|
+
* @returns The loaded module.
|
|
175
|
+
*/
|
|
176
|
+
// export const loadAsyncFromRoot = async (filename: string) => {
|
|
177
|
+
// try {
|
|
178
|
+
// const isProduction = process.env.NODE_ENV === "production";
|
|
179
|
+
// let __pathToRoot = "";
|
|
180
|
+
// if (!isProduction) {
|
|
181
|
+
// __pathToRoot = process.cwd();
|
|
182
|
+
// } else {
|
|
183
|
+
// __pathToRoot = path.join(process.cwd(), "./../../");
|
|
184
|
+
// }
|
|
185
|
+
// const filePath = resolvePath(path.join(__pathToRoot, filename));
|
|
186
|
+
// const file = await import(`./${filePath}`);
|
|
187
|
+
// return file;
|
|
188
|
+
// } catch (error) {
|
|
189
|
+
// console.error(error);
|
|
190
|
+
// return {};
|
|
191
|
+
// }
|
|
192
|
+
// }
|
|
193
|
+
// export const getDirname = (url: string) => {
|
|
194
|
+
// // Get directory name
|
|
195
|
+
// const __dirname = dirname(fileURLToPath(url));
|
|
196
|
+
// return __dirname;
|
|
197
|
+
// }
|
|
@@ -24,7 +24,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
24
24
|
};
|
|
25
25
|
return __assign.apply(this, arguments);
|
|
26
26
|
};
|
|
27
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
27
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
28
|
import React from "react";
|
|
29
29
|
import { generateMetadata, getRouter } from "../../routing/utils/index.js";
|
|
30
30
|
import { Outlet, useParams } from "react-router-dom";
|
|
@@ -124,10 +124,10 @@ export var Heads = function (_a) {
|
|
|
124
124
|
* Body component
|
|
125
125
|
*/
|
|
126
126
|
export var Body = function (_a) {
|
|
127
|
-
var _b = _a.children, children = _b === void 0 ? undefined : _b, _c = _a.asChild, asChild = _c === void 0 ? false : _c;
|
|
127
|
+
var _b = _a.children, children = _b === void 0 ? undefined : _b, _c = _a.asChild, asChild = _c === void 0 ? false : _c, _d = _a.AppContent, AppContent = _d === void 0 ? undefined : _d;
|
|
128
128
|
return (_jsxs("body", { children: [_jsx("noscript", { dangerouslySetInnerHTML: {
|
|
129
129
|
__html: "<b>Enable JavaScript to run this app.</b>",
|
|
130
|
-
} }), asChild ? (_jsx("div", { id: 'root', children:
|
|
130
|
+
} }), asChild ? (_jsx("div", { id: 'root', children: AppContent })) : (_jsx("div", { id: "root", children: "rasengan-body-app" })), children] }));
|
|
131
131
|
};
|
|
132
132
|
/**
|
|
133
133
|
* Scripts component
|
|
@@ -60,11 +60,11 @@ var RenderApp = function (_a) {
|
|
|
60
60
|
return (_jsxs(Heads, { data: helmetContext, styles: styles, bootstrap: bootstrap, children: [viteScripts, children] }));
|
|
61
61
|
}, Body: function (_a) {
|
|
62
62
|
var children = _a.children;
|
|
63
|
-
return _jsx(Body, { asChild: true, children: children });
|
|
63
|
+
return (_jsx(Body, { asChild: true, AppContent: _jsx(App, { Component: Component, children: _jsx(StaticRouterProvider, { router: router, context: context }) }), children: children }));
|
|
64
64
|
}, Script: function (_a) {
|
|
65
65
|
var children = _a.children;
|
|
66
|
-
return _jsx(Scripts, { bootstrap: bootstrap, children: children });
|
|
67
|
-
}
|
|
66
|
+
return (_jsx(Scripts, { bootstrap: bootstrap, children: children }));
|
|
67
|
+
} }) }) }));
|
|
68
68
|
};
|
|
69
69
|
export default function renderStream(router_1, context_1) {
|
|
70
70
|
return __awaiter(this, arguments, void 0, function (router, context, helmetContext, bootstrap, styles, res) {
|
|
@@ -74,17 +74,9 @@ export default function renderStream(router_1, context_1) {
|
|
|
74
74
|
var shellRendered = false;
|
|
75
75
|
var responseStatusCode = 200;
|
|
76
76
|
var _a = renderToPipeableStream(_jsx(RenderApp, { router: router, context: context, helmetContext: helmetContext, bootstrap: bootstrap, styles: styles }), {
|
|
77
|
-
// bootstrapModules: [bootstrap],
|
|
78
77
|
onShellReady: function () {
|
|
79
|
-
// console.log("hummm")
|
|
80
78
|
shellRendered = true;
|
|
81
|
-
|
|
82
|
-
// const stream = createReadableStreamFromReadable(body);
|
|
83
|
-
// console.log({
|
|
84
|
-
// body,
|
|
85
|
-
// stream
|
|
86
|
-
// })
|
|
87
|
-
res.status(200).set({
|
|
79
|
+
res.status(responseStatusCode).set({
|
|
88
80
|
"Content-Type": "text/html",
|
|
89
81
|
"Cache-Control": "max-age=31536000",
|
|
90
82
|
});
|
|
@@ -35,20 +35,22 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
38
|
-
import React from "react";
|
|
38
|
+
// import React from "react";
|
|
39
39
|
import ReactDOMServer from "react-dom/server";
|
|
40
40
|
// @ts-ignore
|
|
41
41
|
import AppRouter from "./../../../../../src/app/app.router";
|
|
42
42
|
// @ts-ignore
|
|
43
|
-
import App from "./../../../../../src/main";
|
|
43
|
+
// import App from "./../../../../../src/main";
|
|
44
44
|
// @ts-ignore
|
|
45
45
|
import Template from "./../../../../../src/template";
|
|
46
46
|
// @ts-ignore
|
|
47
47
|
import { generateStaticRoutes } from "../routing/utils/index.js";
|
|
48
|
-
import { StaticRouterProvider, } from "react-router-dom/server.js";
|
|
49
48
|
// @ts-ignore
|
|
50
|
-
import config from "./../../../../../rasengan.config.js";
|
|
51
|
-
import {
|
|
49
|
+
// import config from "./../../../../../rasengan.config.js";
|
|
50
|
+
import {
|
|
51
|
+
// Component,
|
|
52
|
+
// ErrorBoundary,
|
|
53
|
+
Heads, Body, Scripts, } from "../core/components/index.js";
|
|
52
54
|
import * as HelmetAsync from "react-helmet-async";
|
|
53
55
|
import renderStream from "./entry-server-stream.js";
|
|
54
56
|
// @ts-ignore
|
|
@@ -76,21 +78,16 @@ var TemplateHtml = function (_a) {
|
|
|
76
78
|
*/
|
|
77
79
|
export function render(router_1, context_1) {
|
|
78
80
|
return __awaiter(this, arguments, void 0, function (router, context, helmetContext, bootstrap, styles, res) {
|
|
79
|
-
var html;
|
|
80
81
|
if (helmetContext === void 0) { helmetContext = {}; }
|
|
81
82
|
if (bootstrap === void 0) { bootstrap = ""; }
|
|
82
83
|
if (styles === void 0) { styles = ""; }
|
|
83
84
|
return __generator(this, function (_a) {
|
|
84
85
|
switch (_a.label) {
|
|
85
86
|
case 0:
|
|
86
|
-
if (!config.experimental.stream) return [3 /*break*/, 2];
|
|
87
87
|
if (!res)
|
|
88
88
|
return [2 /*return*/];
|
|
89
89
|
return [4 /*yield*/, renderStream(router, context, helmetContext, bootstrap, styles, res)];
|
|
90
90
|
case 1: return [2 /*return*/, _a.sent()];
|
|
91
|
-
case 2:
|
|
92
|
-
html = ReactDOMServer.renderToString(config.reactStrictMode ? (_jsx(React.StrictMode, { children: _jsx(H.HelmetProvider, { context: helmetContext, children: _jsx(ErrorBoundary, { children: _jsx(App, { Component: Component, children: _jsx(StaticRouterProvider, { router: router, context: context }) }) }) }) })) : (_jsx(H.HelmetProvider, { context: helmetContext, children: _jsx(ErrorBoundary, { children: _jsx(App, { Component: Component, children: _jsx(StaticRouterProvider, { router: router, context: context }) }) }) })));
|
|
93
|
-
return [2 /*return*/, { html: html }];
|
|
94
91
|
}
|
|
95
92
|
});
|
|
96
93
|
});
|
|
@@ -1,37 +1,26 @@
|
|
|
1
1
|
import { execa } from "execa";
|
|
2
2
|
import chalk from "chalk";
|
|
3
|
+
import { checkOsPlateform } from "./utils/check-os.js";
|
|
4
|
+
import { generateCopyExecaArray } from "./utils/copy.js";
|
|
3
5
|
var hostingStrategy = process.env.HOSTING_STRATEGY || "custom";
|
|
4
6
|
(function () {
|
|
7
|
+
var copyCommand = checkOsPlateform("win32") ? "xcopy" : "cp";
|
|
5
8
|
if (hostingStrategy === "vercel") {
|
|
6
9
|
// Displaying the message
|
|
7
10
|
console.log("Your project is configured to be hosted on ".concat(chalk.bold.blue(hostingStrategy), "\n"));
|
|
8
|
-
// Copying the
|
|
9
|
-
execa(
|
|
10
|
-
stdio: "inherit",
|
|
11
|
-
});
|
|
12
|
-
// Copying the vercel.json file to the root directory
|
|
13
|
-
execa("cp", ["node_modules/rasengan/lib/esm/server/functions/vercel/vercel.json", "."], {
|
|
11
|
+
// Copying the vercel folder content to the root directory
|
|
12
|
+
execa(copyCommand, generateCopyExecaArray("node_modules/rasengan/lib/esm/server/functions/vercel", "."), {
|
|
14
13
|
stdio: "inherit",
|
|
14
|
+
shell: true,
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
else if (hostingStrategy === "netlify") {
|
|
18
18
|
// Displaying the message
|
|
19
19
|
console.log("Your project is configured to be hosted on ".concat(chalk.bold.blue(hostingStrategy), "\n"));
|
|
20
|
-
//
|
|
21
|
-
execa(
|
|
22
|
-
stdio: "inherit",
|
|
23
|
-
});
|
|
24
|
-
// Copying the netlify folder to the root directory
|
|
25
|
-
execa("cp", [
|
|
26
|
-
"-r",
|
|
27
|
-
"node_modules/rasengan/lib/esm/server/functions/netlify/functions",
|
|
28
|
-
"./netlify",
|
|
29
|
-
], {
|
|
30
|
-
stdio: "inherit",
|
|
31
|
-
});
|
|
32
|
-
// Copying the netlify.toml file to the root directory
|
|
33
|
-
execa("cp", ["node_modules/rasengan/lib/esm/server/functions/netlify/netlify.toml", "."], {
|
|
20
|
+
// Copying the netlify folder content to the root directory
|
|
21
|
+
execa(copyCommand, generateCopyExecaArray("node_modules/rasengan/lib/esm/server/functions/netlify", "."), {
|
|
34
22
|
stdio: "inherit",
|
|
23
|
+
shell: true,
|
|
35
24
|
});
|
|
36
25
|
}
|
|
37
26
|
})();
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import os from "node:os";
|
|
2
|
+
/**
|
|
3
|
+
* Check if the current OS is the provided one
|
|
4
|
+
* @param {"aix"| "darwin"| "freebsd"| "linux"| "openbsd"| "sunos"| "win32"} osname
|
|
5
|
+
* @returns {boolean}
|
|
6
|
+
*/
|
|
7
|
+
export var checkOsPlateform = function (osname) { return osname === os.platform(); };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { checkOsPlateform } from "./check-os.js";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* Generates an array of command-line arguments for the `execa` function to copy files from one location to another.
|
|
5
|
+
*
|
|
6
|
+
* @param {string} from - The source directory or file path.
|
|
7
|
+
* @param {string} to - The destination directory or file path.
|
|
8
|
+
* @return {Array<string>} - An array of command-line arguments for the `execa` function.
|
|
9
|
+
*/
|
|
10
|
+
export var generateCopyExecaArray = function (from, to) {
|
|
11
|
+
var fromPath = path.normalize(from);
|
|
12
|
+
var toPath = path.normalize(to);
|
|
13
|
+
var copyCommand = ["-r", path.join(fromPath, "/*"), toPath];
|
|
14
|
+
var copyCommandWindows = ["\"".concat(fromPath, "\""), "\"".concat(toPath, "\""), "/s /e /i"];
|
|
15
|
+
return checkOsPlateform("win32") ? copyCommandWindows : copyCommand;
|
|
16
|
+
};
|
|
@@ -54,12 +54,11 @@ var RASENGAN_VERCEL_CONFIG = process.env.RASENGAN_VERCEL_CONFIG;
|
|
|
54
54
|
// Create server for production only
|
|
55
55
|
export default function handler(req, res) {
|
|
56
56
|
return __awaiter(this, void 0, void 0, function () {
|
|
57
|
-
var url, host, appPath, config_1, configPath, config, filePath, file, err_1, segments, segmentsWithoutOrigin, _i, segments_1, segment, filePath, file, otherFile, result, mimeType, file, templateHtml, serverFilePath, bootstrapDirPath, entry, bootstrap, styles, render, staticRoutes, loadTemplateHtml, handler_1, fetchRequest, context, status_1, redirect, helmetContext, router,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
switch (_b.label) {
|
|
57
|
+
var url, host, appPath, config_1, configPath, config, filePath, file, err_1, segments, segmentsWithoutOrigin, _i, segments_1, segment, filePath, file, otherFile, result, mimeType, file, templateHtml, serverFilePath, bootstrapDirPath, entry, bootstrap, styles, render, staticRoutes, loadTemplateHtml, handler_1, fetchRequest, context, status_1, redirect, helmetContext, router, e_1;
|
|
58
|
+
return __generator(this, function (_a) {
|
|
59
|
+
switch (_a.label) {
|
|
61
60
|
case 0:
|
|
62
|
-
|
|
61
|
+
_a.trys.push([0, 16, , 17]);
|
|
63
62
|
url = req.url;
|
|
64
63
|
host = req.headers.host;
|
|
65
64
|
appPath = process.cwd();
|
|
@@ -72,21 +71,21 @@ export default function handler(req, res) {
|
|
|
72
71
|
configPath = path.resolve(join(appPath, "rasengan.config.js"));
|
|
73
72
|
return [4 /*yield*/, import(configPath)];
|
|
74
73
|
case 1:
|
|
75
|
-
config = (
|
|
74
|
+
config = (_a.sent()).default;
|
|
76
75
|
if (!(url === "/robots.txt")) return [3 /*break*/, 6];
|
|
77
|
-
|
|
76
|
+
_a.label = 2;
|
|
78
77
|
case 2:
|
|
79
|
-
|
|
78
|
+
_a.trys.push([2, 5, , 6]);
|
|
80
79
|
filePath = join(appPath, "dist/client/robots.txt");
|
|
81
80
|
return [4 /*yield*/, fs.access(path.resolve(filePath))];
|
|
82
81
|
case 3:
|
|
83
|
-
|
|
82
|
+
_a.sent();
|
|
84
83
|
return [4 /*yield*/, fs.readFile(filePath, "utf-8")];
|
|
85
84
|
case 4:
|
|
86
|
-
file =
|
|
85
|
+
file = _a.sent();
|
|
87
86
|
return [2 /*return*/, res.send(file)];
|
|
88
87
|
case 5:
|
|
89
|
-
err_1 =
|
|
88
|
+
err_1 = _a.sent();
|
|
90
89
|
return [2 /*return*/, res.send("\n user-agent: *\n disallow: /downloads/\n disallow: /private/\n allow: /\n \n user-agent: magicsearchbot\n disallow: /uploads/\n ")];
|
|
91
90
|
case 6:
|
|
92
91
|
// ! Sitemap Fix
|
|
@@ -110,7 +109,7 @@ export default function handler(req, res) {
|
|
|
110
109
|
filePath = join(appPath, "dist/client", segmentsWithoutOrigin.join("/"));
|
|
111
110
|
return [4 /*yield*/, fs.readFile(filePath, "utf-8")];
|
|
112
111
|
case 7:
|
|
113
|
-
file =
|
|
112
|
+
file = _a.sent();
|
|
114
113
|
if (url.endsWith(".js") || url.endsWith(".css")) {
|
|
115
114
|
return [2 /*return*/, new Response(file, {
|
|
116
115
|
headers: {
|
|
@@ -123,10 +122,10 @@ export default function handler(req, res) {
|
|
|
123
122
|
}
|
|
124
123
|
return [4 /*yield*/, fs.readFile(filePath)];
|
|
125
124
|
case 8:
|
|
126
|
-
otherFile =
|
|
125
|
+
otherFile = _a.sent();
|
|
127
126
|
return [4 /*yield*/, fileTypeFromBuffer(otherFile)];
|
|
128
127
|
case 9:
|
|
129
|
-
result =
|
|
128
|
+
result = _a.sent();
|
|
130
129
|
mimeType = result
|
|
131
130
|
? result.mime
|
|
132
131
|
: url.endsWith(".svg")
|
|
@@ -142,7 +141,7 @@ export default function handler(req, res) {
|
|
|
142
141
|
if (!(url.endsWith(".js") || url.endsWith(".css"))) return [3 /*break*/, 12];
|
|
143
142
|
return [4 /*yield*/, fs.readFile(url, "utf-8")];
|
|
144
143
|
case 11:
|
|
145
|
-
file =
|
|
144
|
+
file = _a.sent();
|
|
146
145
|
return [2 /*return*/, res
|
|
147
146
|
.status(200)
|
|
148
147
|
.setHeader("Content-Type", url.endsWith(".js") ? "text/javascript" : "text/css")
|
|
@@ -154,7 +153,7 @@ export default function handler(req, res) {
|
|
|
154
153
|
bootstrapDirPath = join(appPath, "dist/client/assets");
|
|
155
154
|
return [4 /*yield*/, import(serverFilePath)];
|
|
156
155
|
case 13:
|
|
157
|
-
entry =
|
|
156
|
+
entry = _a.sent();
|
|
158
157
|
bootstrap = "/assets/" +
|
|
159
158
|
fsSync
|
|
160
159
|
.readdirSync(bootstrapDirPath)
|
|
@@ -168,7 +167,7 @@ export default function handler(req, res) {
|
|
|
168
167
|
fetchRequest = createFetchRequest(req, host);
|
|
169
168
|
return [4 /*yield*/, handler_1.query(fetchRequest)];
|
|
170
169
|
case 14:
|
|
171
|
-
context =
|
|
170
|
+
context = _a.sent();
|
|
172
171
|
status_1 = context.status;
|
|
173
172
|
if (status_1 === 302) {
|
|
174
173
|
redirect = context.headers.get("Location");
|
|
@@ -177,29 +176,16 @@ export default function handler(req, res) {
|
|
|
177
176
|
}
|
|
178
177
|
helmetContext = {};
|
|
179
178
|
router = createStaticRouter(handler_1.dataRoutes, context);
|
|
180
|
-
if (!config.experimental.stream) return [3 /*break*/, 16];
|
|
181
179
|
return [4 /*yield*/, render(router, context, helmetContext, bootstrap, styles, res)];
|
|
182
|
-
case 15:
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
if (!templateHtml) {
|
|
188
|
-
templateHtml = loadTemplateHtml(helmetContext, bootstrap, styles);
|
|
189
|
-
}
|
|
190
|
-
html = templateHtml.replace("rasengan-body-app", (_a = rendered.html) !== null && _a !== void 0 ? _a : "");
|
|
191
|
-
// Send the rendered html page
|
|
192
|
-
return [2 /*return*/, res
|
|
193
|
-
.status(200)
|
|
194
|
-
.setHeader("Content-Type", "text/html")
|
|
195
|
-
.setHeader("Cache-Control", "max-age=31536000")
|
|
196
|
-
.end(html)];
|
|
197
|
-
case 18:
|
|
198
|
-
e_1 = _b.sent();
|
|
180
|
+
case 15:
|
|
181
|
+
// If stream mode enabled, render the page as a plain text
|
|
182
|
+
return [2 /*return*/, _a.sent()];
|
|
183
|
+
case 16:
|
|
184
|
+
e_1 = _a.sent();
|
|
199
185
|
console.log(e_1.stack);
|
|
200
186
|
res.status(500).end(e_1.stack);
|
|
201
|
-
return [3 /*break*/,
|
|
202
|
-
case
|
|
187
|
+
return [3 /*break*/, 17];
|
|
188
|
+
case 17: return [2 /*return*/];
|
|
203
189
|
}
|
|
204
190
|
});
|
|
205
191
|
});
|
|
@@ -37,9 +37,6 @@ export declare const defineConfig: (loadedConfig: AppConfig) => {
|
|
|
37
37
|
};
|
|
38
38
|
appType: string;
|
|
39
39
|
};
|
|
40
|
-
experimental: {
|
|
41
|
-
stream: boolean;
|
|
42
|
-
};
|
|
43
40
|
} | {
|
|
44
41
|
reactStrictMode: boolean;
|
|
45
42
|
vite: {
|
|
@@ -55,9 +52,6 @@ export declare const defineConfig: (loadedConfig: AppConfig) => {
|
|
|
55
52
|
}[];
|
|
56
53
|
};
|
|
57
54
|
};
|
|
58
|
-
experimental: {
|
|
59
|
-
stream: boolean;
|
|
60
|
-
};
|
|
61
55
|
};
|
|
62
56
|
/**
|
|
63
57
|
* Function to adapt the path for dev and prod
|
|
@@ -71,3 +65,11 @@ export declare const adaptPath: (paths: string | Array<string>) => string | stri
|
|
|
71
65
|
* @returns The adapted file path in a valid URL format.
|
|
72
66
|
*/
|
|
73
67
|
export declare const resolvePath: (path: string) => string;
|
|
68
|
+
/**
|
|
69
|
+
* Asynchronously loads a module from a file path relative to the project root directory.
|
|
70
|
+
*
|
|
71
|
+
* This function checks the current environment (production or development) and adjusts the file path accordingly. It then resolves the file path to a valid URL format based on the operating system.
|
|
72
|
+
*
|
|
73
|
+
* @param filename - The name of the file to be loaded.
|
|
74
|
+
* @returns The loaded module.
|
|
75
|
+
*/
|
|
@@ -34,9 +34,10 @@ export declare const Heads: ({ data, children, bootstrap, styles, }: {
|
|
|
34
34
|
/**
|
|
35
35
|
* Body component
|
|
36
36
|
*/
|
|
37
|
-
export declare const Body: ({ children, asChild, }: {
|
|
37
|
+
export declare const Body: ({ children, asChild, AppContent, }: {
|
|
38
38
|
children?: React.ReactNode;
|
|
39
39
|
asChild?: boolean;
|
|
40
|
+
AppContent?: React.ReactNode;
|
|
40
41
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
41
42
|
/**
|
|
42
43
|
* Scripts component
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function checkOsPlateform(osname: "aix" | "darwin" | "freebsd" | "linux" | "openbsd" | "sunos" | "win32"): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function generateCopyExecaArray(from: string, to: string): Array<string>;
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -133,46 +133,44 @@ async function createServer({
|
|
|
133
133
|
let router = createStaticRouter(handler.dataRoutes, context);
|
|
134
134
|
|
|
135
135
|
// If stream mode enabled, render the page as a plain text
|
|
136
|
-
|
|
137
|
-
return await render(
|
|
138
|
-
router,
|
|
139
|
-
context,
|
|
140
|
-
helmetContext,
|
|
141
|
-
bootstrap,
|
|
142
|
-
styles,
|
|
143
|
-
res
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// Render the html page on the server
|
|
148
|
-
const rendered = await render(
|
|
136
|
+
return await render(
|
|
149
137
|
router,
|
|
150
138
|
context,
|
|
151
139
|
helmetContext,
|
|
152
140
|
bootstrap,
|
|
153
|
-
styles
|
|
141
|
+
styles,
|
|
142
|
+
res
|
|
154
143
|
);
|
|
155
144
|
|
|
156
|
-
//
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
//
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
145
|
+
// Render the html page on the server
|
|
146
|
+
// const rendered = await render(
|
|
147
|
+
// router,
|
|
148
|
+
// context,
|
|
149
|
+
// helmetContext,
|
|
150
|
+
// bootstrap,
|
|
151
|
+
// styles
|
|
152
|
+
// );
|
|
153
|
+
|
|
154
|
+
// // Load template html
|
|
155
|
+
// if (!templateHtml) {
|
|
156
|
+
// templateHtml = loadTemplateHtml(helmetContext, bootstrap, styles);
|
|
157
|
+
|
|
158
|
+
// if (!isProduction) {
|
|
159
|
+
// templateHtml = await vite.transformIndexHtml(url, templateHtml);
|
|
160
|
+
// }
|
|
161
|
+
// }
|
|
162
|
+
|
|
163
|
+
// // Replacing the app-html placeholder with the rendered html
|
|
164
|
+
// let html = templateHtml.replace(`rasengan-body-app`, rendered.html ?? "");
|
|
165
|
+
|
|
166
|
+
// // Send the rendered html page
|
|
167
|
+
// return res
|
|
168
|
+
// .status(200)
|
|
169
|
+
// .set({
|
|
170
|
+
// "Content-Type": "text/html",
|
|
171
|
+
// "Cache-Control": "max-age=31536000",
|
|
172
|
+
// })
|
|
173
|
+
// .end(html);
|
|
176
174
|
} catch (e) {
|
|
177
175
|
vite?.ssrFixStacktrace(e);
|
|
178
176
|
|
package/vite.config.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { defineConfig } from "vite";
|
|
2
2
|
import react from "@vitejs/plugin-react";
|
|
3
3
|
|
|
4
|
-
// Load rasengan config file
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
import config from "./../../rasengan.config.js";
|
|
7
|
-
|
|
8
4
|
import path from "node:path";
|
|
9
5
|
|
|
10
|
-
//
|
|
11
|
-
|
|
6
|
+
// Load config
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
import config from "./../../rasengan.config.js";
|
|
9
|
+
// import { config } from "./AppEntry";
|
|
12
10
|
|
|
13
11
|
// Getting root path
|
|
14
12
|
let __pathToRoot = "";
|
|
@@ -41,6 +39,9 @@ export default defineConfig(async ({ command, mode }: any) => {
|
|
|
41
39
|
__pathToRoot = path.join(process.cwd(), "./../../");
|
|
42
40
|
}
|
|
43
41
|
|
|
42
|
+
// Extract vite config
|
|
43
|
+
const { vite } = config;
|
|
44
|
+
|
|
44
45
|
return {
|
|
45
46
|
// Define env
|
|
46
47
|
define: {
|
|
@@ -59,7 +60,8 @@ export default defineConfig(async ({ command, mode }: any) => {
|
|
|
59
60
|
|
|
60
61
|
// Build options
|
|
61
62
|
build: {
|
|
62
|
-
sourcemap: true,
|
|
63
|
+
sourcemap: mode === "development" ? true : false,
|
|
64
|
+
minify: "esbuild",
|
|
63
65
|
rollupOptions: {
|
|
64
66
|
input: "./lib/esm/entries/entry-client.js",
|
|
65
67
|
output: {
|
|
File without changes
|
|
File without changes
|