@jay-framework/stack-server-runtime 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.js +23 -43
- package/package.json +10 -9
- /package/dist/{index.d.mts → index.d.ts} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,31 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
}
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
25
|
-
const fullstackComponent = require("@jay-framework/fullstack-component");
|
|
26
|
-
const fs = require("node:fs/promises");
|
|
27
|
-
const path = require("node:path");
|
|
28
|
-
const compilerJayHtml = require("@jay-framework/compiler-jay-html");
|
|
1
|
+
import { notFound, partialRender } from "@jay-framework/fullstack-component";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { parseJayFile } from "@jay-framework/compiler-jay-html";
|
|
5
|
+
import { createRequire } from "module";
|
|
29
6
|
function isLeftSideParamsSubsetOfRightSideParams(left, right) {
|
|
30
7
|
return Object.keys(left).reduce((prev, curr) => prev && left[curr] === right[curr], true);
|
|
31
8
|
}
|
|
@@ -46,7 +23,7 @@ class DevSlowlyChangingPhase {
|
|
|
46
23
|
if (compDefinition.loadParams) {
|
|
47
24
|
const compParams = compDefinition.loadParams([]);
|
|
48
25
|
if (!await findMatchingParams(pageParams, compParams))
|
|
49
|
-
return
|
|
26
|
+
return notFound();
|
|
50
27
|
}
|
|
51
28
|
}
|
|
52
29
|
let slowlyViewState = {};
|
|
@@ -70,7 +47,7 @@ class DevSlowlyChangingPhase {
|
|
|
70
47
|
return slowlyRenderedPart;
|
|
71
48
|
}
|
|
72
49
|
}
|
|
73
|
-
return
|
|
50
|
+
return partialRender(slowlyViewState, carryForward);
|
|
74
51
|
}
|
|
75
52
|
}
|
|
76
53
|
async function runLoadParams(compDefinition, serverContexts) {
|
|
@@ -101,7 +78,7 @@ async function renderFastChangingData(pageParams, pageProps, carryForward, parts
|
|
|
101
78
|
return fastRenderedPart;
|
|
102
79
|
}
|
|
103
80
|
}
|
|
104
|
-
return Promise.resolve(
|
|
81
|
+
return Promise.resolve(partialRender(fastViewState, fastCarryForward));
|
|
105
82
|
}
|
|
106
83
|
function generateClientScript(defaultViewState, fastCarryForward, parts, jayHtmlPath) {
|
|
107
84
|
const imports = parts.length > 0 ? parts.map((part) => part.clientImport).join("\n") + "\n" : "";
|
|
@@ -133,6 +110,7 @@ ${parts.map((part) => " " + part.clientPart).join(",\n")}
|
|
|
133
110
|
</body>
|
|
134
111
|
</html>`;
|
|
135
112
|
}
|
|
113
|
+
const require2 = createRequire(import.meta.url);
|
|
136
114
|
async function loadPageParts(vite, route, pagesBase, jayRollupConfig) {
|
|
137
115
|
const exists = await fs.access(route.compPath, fs.constants.F_OK).then(() => true).catch(() => false);
|
|
138
116
|
const parts = [];
|
|
@@ -148,9 +126,9 @@ async function loadPageParts(vite, route, pagesBase, jayRollupConfig) {
|
|
|
148
126
|
const jayHtmlSource = (await fs.readFile(route.jayHtmlPath)).toString();
|
|
149
127
|
const fileName = path.basename(route.jayHtmlPath);
|
|
150
128
|
const dirName = path.dirname(route.jayHtmlPath);
|
|
151
|
-
const
|
|
152
|
-
const JAY_IMPORT_RESOLVER =
|
|
153
|
-
const jayHtmlWithValidations = await
|
|
129
|
+
const module = await import("@jay-framework/compiler-jay-html");
|
|
130
|
+
const JAY_IMPORT_RESOLVER = module.JAY_IMPORT_RESOLVER;
|
|
131
|
+
const jayHtmlWithValidations = await parseJayFile(
|
|
154
132
|
jayHtmlSource,
|
|
155
133
|
fileName,
|
|
156
134
|
dirName,
|
|
@@ -161,11 +139,11 @@ async function loadPageParts(vite, route, pagesBase, jayRollupConfig) {
|
|
|
161
139
|
);
|
|
162
140
|
return jayHtmlWithValidations.mapAsync(async (jayHtml) => {
|
|
163
141
|
for await (const headlessImport of jayHtml.headlessImports) {
|
|
164
|
-
const
|
|
142
|
+
const module2 = headlessImport.codeLink.module;
|
|
165
143
|
const name = headlessImport.codeLink.names[0].name;
|
|
166
|
-
const modulePath =
|
|
144
|
+
const modulePath = module2[0] === "." ? path.resolve(dirName, module2) : require2.resolve(module2, { paths: require2.resolve.paths(dirName) });
|
|
167
145
|
const compDefinition = (await vite.ssrLoadModule(modulePath))[name];
|
|
168
|
-
const moduleImport =
|
|
146
|
+
const moduleImport = module2.startsWith("./") ? path.resolve(pagesBase, module2) : module2;
|
|
169
147
|
const key = headlessImport.key;
|
|
170
148
|
const part = {
|
|
171
149
|
key,
|
|
@@ -178,9 +156,11 @@ async function loadPageParts(vite, route, pagesBase, jayRollupConfig) {
|
|
|
178
156
|
return parts;
|
|
179
157
|
});
|
|
180
158
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
159
|
+
export {
|
|
160
|
+
DevSlowlyChangingPhase,
|
|
161
|
+
generateClientScript,
|
|
162
|
+
loadPageParts,
|
|
163
|
+
renderFastChangingData,
|
|
164
|
+
runLoadParams,
|
|
165
|
+
runSlowlyChangingRender
|
|
166
|
+
};
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jay-framework/stack-server-runtime",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.8",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.mts",
|
|
7
|
+
"type": "module",
|
|
7
8
|
"directories": {
|
|
8
9
|
"lib": "lib"
|
|
9
10
|
},
|
|
@@ -25,16 +26,16 @@
|
|
|
25
26
|
"test:watch": "vitest"
|
|
26
27
|
},
|
|
27
28
|
"dependencies": {
|
|
28
|
-
"@jay-framework/compiler-jay-html": "^0.6.
|
|
29
|
-
"@jay-framework/component": "^0.6.
|
|
30
|
-
"@jay-framework/fullstack-component": "^0.6.
|
|
31
|
-
"@jay-framework/runtime": "^0.6.
|
|
32
|
-
"@jay-framework/stack-route-scanner": "^0.6.
|
|
29
|
+
"@jay-framework/compiler-jay-html": "^0.6.8",
|
|
30
|
+
"@jay-framework/component": "^0.6.8",
|
|
31
|
+
"@jay-framework/fullstack-component": "^0.6.8",
|
|
32
|
+
"@jay-framework/runtime": "^0.6.8",
|
|
33
|
+
"@jay-framework/stack-route-scanner": "^0.6.8"
|
|
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",
|
|
File without changes
|