@jay-framework/dev-server 0.6.6 → 0.6.8
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/dist/{index.cjs → index.js} +23 -23
- package/package.json +13 -12
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const vitePlugin = require("@jay-framework/vite-plugin");
|
|
7
|
-
const path = require("node:path");
|
|
1
|
+
import { createServer } from "vite";
|
|
2
|
+
import { scanRoutes, routeToExpressRoute } from "@jay-framework/stack-route-scanner";
|
|
3
|
+
import { DevSlowlyChangingPhase, loadPageParts, renderFastChangingData, generateClientScript } from "@jay-framework/stack-server-runtime";
|
|
4
|
+
import { jayRuntime } from "@jay-framework/vite-plugin";
|
|
5
|
+
import path from "node:path";
|
|
8
6
|
async function initRoutes(pagesBaseFolder) {
|
|
9
|
-
return await
|
|
7
|
+
return await scanRoutes(pagesBaseFolder, {
|
|
10
8
|
jayHtmlFilename: "page.jay-html",
|
|
11
9
|
compFilename: "page.ts"
|
|
12
10
|
});
|
|
@@ -33,8 +31,8 @@ function handleOtherResponseCodes(res, renderedResult) {
|
|
|
33
31
|
else
|
|
34
32
|
res.status(renderedResult.status).end("redirect to " + renderedResult.location);
|
|
35
33
|
}
|
|
36
|
-
function mkRoute(route,
|
|
37
|
-
const path2 =
|
|
34
|
+
function mkRoute(route, vite, slowlyPhase, options) {
|
|
35
|
+
const path2 = routeToExpressRoute(route);
|
|
38
36
|
const handler = async (req, res) => {
|
|
39
37
|
try {
|
|
40
38
|
const url = req.originalUrl.replace(options.serverBase, "");
|
|
@@ -44,8 +42,8 @@ function mkRoute(route, vite2, slowlyPhase, options) {
|
|
|
44
42
|
url
|
|
45
43
|
};
|
|
46
44
|
let viewState, carryForward;
|
|
47
|
-
const pageParts = await
|
|
48
|
-
|
|
45
|
+
const pageParts = await loadPageParts(
|
|
46
|
+
vite,
|
|
49
47
|
route,
|
|
50
48
|
options.pagesBase,
|
|
51
49
|
options.jayRollupConfig
|
|
@@ -57,7 +55,7 @@ function mkRoute(route, vite2, slowlyPhase, options) {
|
|
|
57
55
|
pageParts.val
|
|
58
56
|
);
|
|
59
57
|
if (renderedSlowly.kind === "PartialRender") {
|
|
60
|
-
const renderedFast = await
|
|
58
|
+
const renderedFast = await renderFastChangingData(
|
|
61
59
|
pageParams,
|
|
62
60
|
pageProps,
|
|
63
61
|
renderedSlowly.carryForward,
|
|
@@ -66,13 +64,13 @@ function mkRoute(route, vite2, slowlyPhase, options) {
|
|
|
66
64
|
if (renderedFast.kind === "PartialRender") {
|
|
67
65
|
viewState = { ...renderedSlowly.rendered, ...renderedFast.rendered };
|
|
68
66
|
carryForward = renderedFast.carryForward;
|
|
69
|
-
const pageHtml =
|
|
67
|
+
const pageHtml = generateClientScript(
|
|
70
68
|
viewState,
|
|
71
69
|
carryForward,
|
|
72
70
|
pageParts.val,
|
|
73
71
|
route.jayHtmlPath
|
|
74
72
|
);
|
|
75
|
-
const compiledPageHtml = await
|
|
73
|
+
const compiledPageHtml = await vite.transformIndexHtml(
|
|
76
74
|
!!url ? url : "/",
|
|
77
75
|
pageHtml
|
|
78
76
|
);
|
|
@@ -88,7 +86,7 @@ function mkRoute(route, vite2, slowlyPhase, options) {
|
|
|
88
86
|
res.status(500).end(pageParts.validations.join("\n"));
|
|
89
87
|
}
|
|
90
88
|
} catch (e) {
|
|
91
|
-
|
|
89
|
+
vite?.ssrFixStacktrace(e);
|
|
92
90
|
console.log(e.stack);
|
|
93
91
|
res.status(500).end(e.stack);
|
|
94
92
|
}
|
|
@@ -97,22 +95,24 @@ function mkRoute(route, vite2, slowlyPhase, options) {
|
|
|
97
95
|
}
|
|
98
96
|
async function mkDevServer(options) {
|
|
99
97
|
const { serverBase, pagesBase, jayRollupConfig, dontCacheSlowly } = defaults(options);
|
|
100
|
-
const vite
|
|
98
|
+
const vite = await createServer({
|
|
101
99
|
server: { middlewareMode: true },
|
|
102
|
-
plugins: [
|
|
100
|
+
plugins: [jayRuntime(jayRollupConfig)],
|
|
103
101
|
appType: "custom",
|
|
104
102
|
base: serverBase,
|
|
105
103
|
root: pagesBase
|
|
106
104
|
});
|
|
107
105
|
const routes = await initRoutes(pagesBase);
|
|
108
|
-
const slowlyPhase = new
|
|
106
|
+
const slowlyPhase = new DevSlowlyChangingPhase(dontCacheSlowly);
|
|
109
107
|
const devServerRoutes = routes.map(
|
|
110
|
-
(route) => mkRoute(route, vite
|
|
108
|
+
(route) => mkRoute(route, vite, slowlyPhase, options)
|
|
111
109
|
);
|
|
112
110
|
return {
|
|
113
|
-
server: vite
|
|
114
|
-
viteServer: vite
|
|
111
|
+
server: vite.middlewares,
|
|
112
|
+
viteServer: vite,
|
|
115
113
|
routes: devServerRoutes
|
|
116
114
|
};
|
|
117
115
|
}
|
|
118
|
-
|
|
116
|
+
export {
|
|
117
|
+
mkDevServer
|
|
118
|
+
};
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jay-framework/dev-server",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
-
"main": "dist/index.
|
|
6
|
+
"main": "dist/index.js",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist",
|
|
9
9
|
"readme.md"
|
|
@@ -22,19 +22,20 @@
|
|
|
22
22
|
"test:watch": "vitest"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@jay-framework/
|
|
26
|
-
"@jay-framework/
|
|
27
|
-
"@jay-framework/
|
|
28
|
-
"@jay-framework/
|
|
29
|
-
"@jay-framework/stack-
|
|
30
|
-
"@jay-framework/stack-
|
|
31
|
-
"@jay-framework/
|
|
25
|
+
"@jay-framework/compiler-shared": "^0.6.8",
|
|
26
|
+
"@jay-framework/component": "^0.6.8",
|
|
27
|
+
"@jay-framework/fullstack-component": "^0.6.8",
|
|
28
|
+
"@jay-framework/runtime": "^0.6.8",
|
|
29
|
+
"@jay-framework/stack-client-runtime": "^0.6.8",
|
|
30
|
+
"@jay-framework/stack-route-scanner": "^0.6.8",
|
|
31
|
+
"@jay-framework/stack-server-runtime": "^0.6.8",
|
|
32
|
+
"@jay-framework/vite-plugin": "^0.6.8",
|
|
32
33
|
"vite": "^5.0.11"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
|
-
"@jay-framework/dev-environment": "^0.6.
|
|
36
|
-
"@jay-framework/jay-cli": "^0.6.
|
|
37
|
-
"@jay-framework/stack-client-runtime": "^0.6.
|
|
36
|
+
"@jay-framework/dev-environment": "^0.6.8",
|
|
37
|
+
"@jay-framework/jay-cli": "^0.6.8",
|
|
38
|
+
"@jay-framework/stack-client-runtime": "^0.6.8",
|
|
38
39
|
"@types/express": "^5.0.2",
|
|
39
40
|
"@types/node": "^22.15.21",
|
|
40
41
|
"nodemon": "^3.0.3",
|