@jay-framework/production-server 0.19.7 → 0.19.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.d.ts +2 -2
- package/dist/index.js +48 -16
- package/dist/{init-services-mT6H6d4z.js → init-services-J5GZMNJT.js} +9 -9
- package/dist/{serve-index-HC05uvRi.d.ts → serve-index-oMDgTHRv.d.ts} +0 -2
- package/dist/serve-index.d.ts +1 -1
- package/dist/serve-index.js +1 -1
- package/package.json +12 -12
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as BuildOptions, R as RouteManifest, a as RouteEntry } from './serve-index-
|
|
2
|
-
export { A as ActionEntry, e as ArtifactStore, c as BuildMetadata, C as CacheEntry, F as FilesystemArtifactStore, I as InstanceEntry, M as MatchResult, d as PageModule, P as PluginEntry, n as PreImportedPlugin, b as RouteSegment, S as ServerElementModule, g as fetchActionRequest, f as fetchPageRequest, j as fetchStaticFile, k as initializeServices, l as initializeServicesFromModules, i as isActionRequest, m as matchRequest, r as registerActionsFromManifest, h as registerActionsFromModules } from './serve-index-
|
|
1
|
+
import { B as BuildOptions, R as RouteManifest, a as RouteEntry } from './serve-index-oMDgTHRv.js';
|
|
2
|
+
export { A as ActionEntry, e as ArtifactStore, c as BuildMetadata, C as CacheEntry, F as FilesystemArtifactStore, I as InstanceEntry, M as MatchResult, d as PageModule, P as PluginEntry, n as PreImportedPlugin, b as RouteSegment, S as ServerElementModule, g as fetchActionRequest, f as fetchPageRequest, j as fetchStaticFile, k as initializeServices, l as initializeServicesFromModules, i as isActionRequest, m as matchRequest, r as registerActionsFromManifest, h as registerActionsFromModules } from './serve-index-oMDgTHRv.js';
|
|
3
3
|
import '@jay-framework/ssr-runtime';
|
|
4
4
|
import '@jay-framework/compiler-shared';
|
|
5
5
|
import '@jay-framework/stack-server-runtime';
|
package/dist/index.js
CHANGED
|
@@ -6,9 +6,9 @@ import path from "node:path";
|
|
|
6
6
|
import fs from "node:fs/promises";
|
|
7
7
|
import { createRequire } from "node:module";
|
|
8
8
|
import { DevSlowlyChangingPhase, slowRenderInstances, scanPlugins, runLoadParams, parseCookies } from "@jay-framework/stack-server-runtime";
|
|
9
|
-
import { l as loadProductionPageParts, g as buildPagePartsConfig, d as initializeServices, r as registerActionsFromManifest, i as isActionRequest, a as fetchActionRequest, c as fetchStaticFile, m as matchRequest, f as fetchPageRequest, F as FilesystemArtifactStore } from "./init-services-
|
|
10
|
-
import { e, b } from "./init-services-
|
|
11
|
-
import crypto from "node:crypto";
|
|
9
|
+
import { l as loadProductionPageParts, g as buildPagePartsConfig, d as initializeServices, r as registerActionsFromManifest, i as isActionRequest, a as fetchActionRequest, c as fetchStaticFile, m as matchRequest, f as fetchPageRequest, F as FilesystemArtifactStore } from "./init-services-J5GZMNJT.js";
|
|
10
|
+
import { e, b } from "./init-services-J5GZMNJT.js";
|
|
11
|
+
import crypto, { createHash } from "node:crypto";
|
|
12
12
|
import fs$1 from "node:fs";
|
|
13
13
|
import { jayRuntime } from "@jay-framework/vite-plugin";
|
|
14
14
|
import { injectHeadfullFSTemplates, JAY_IMPORT_RESOLVER, parseJayFile, generateElementHydrateFile, generateServerElementFile } from "@jay-framework/compiler-jay-html";
|
|
@@ -103,6 +103,7 @@ async function buildServerCode(entries, jayOptions, outputDir, projectRoot) {
|
|
|
103
103
|
}
|
|
104
104
|
await build({
|
|
105
105
|
root: projectRoot,
|
|
106
|
+
publicDir: false,
|
|
106
107
|
plugins: [...jayStackCompiler(jayOptions)],
|
|
107
108
|
build: {
|
|
108
109
|
ssr: true,
|
|
@@ -152,6 +153,7 @@ async function buildSharedChunks(outputDir, _projectRoot, minify = true, pluginC
|
|
|
152
153
|
}
|
|
153
154
|
const dedupePackages = [...allPackages, "@jay-framework/list-compare"];
|
|
154
155
|
await build({
|
|
156
|
+
publicDir: false,
|
|
155
157
|
build: {
|
|
156
158
|
outDir: outputDir,
|
|
157
159
|
emptyOutDir: true,
|
|
@@ -527,6 +529,7 @@ async function compileServerElement(jayHtmlContent, jayHtmlFilename, jayHtmlDir,
|
|
|
527
529
|
const jayOptions = { tsConfigFilePath };
|
|
528
530
|
await build({
|
|
529
531
|
root: projectRoot,
|
|
532
|
+
publicDir: false,
|
|
530
533
|
plugins: [jayRuntime(jayOptions)],
|
|
531
534
|
build: {
|
|
532
535
|
outDir: outputDir,
|
|
@@ -604,6 +607,7 @@ async function compileRouteHydrateScript(jayHtmlPath, outputDir, projectRoot, ts
|
|
|
604
607
|
const jayOptions = { tsConfigFilePath };
|
|
605
608
|
await build({
|
|
606
609
|
root: projectRoot,
|
|
610
|
+
publicDir: false,
|
|
607
611
|
plugins: [...jayStackCompiler(jayOptions)],
|
|
608
612
|
build: {
|
|
609
613
|
outDir: outputDir,
|
|
@@ -738,6 +742,7 @@ async function buildInstanceClient(hydrateEntryPath, instanceId, outputDir, proj
|
|
|
738
742
|
};
|
|
739
743
|
await build({
|
|
740
744
|
root: projectRoot,
|
|
745
|
+
publicDir: false,
|
|
741
746
|
plugins: [...jayStackCompiler(fullJayOptions)],
|
|
742
747
|
build: {
|
|
743
748
|
outDir: outputDir,
|
|
@@ -920,6 +925,29 @@ async function discoverPluginClientPackages(projectRoot) {
|
|
|
920
925
|
}
|
|
921
926
|
return result;
|
|
922
927
|
}
|
|
928
|
+
async function collectFiles(dir, base = "") {
|
|
929
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
930
|
+
const paths = [];
|
|
931
|
+
for (const entry of entries) {
|
|
932
|
+
const rel = base ? `${base}/${entry.name}` : entry.name;
|
|
933
|
+
if (entry.isDirectory()) {
|
|
934
|
+
paths.push(...await collectFiles(path.join(dir, entry.name), rel));
|
|
935
|
+
} else {
|
|
936
|
+
paths.push(rel);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
return paths;
|
|
940
|
+
}
|
|
941
|
+
async function computeBuildHash(buildDir) {
|
|
942
|
+
const files = (await collectFiles(buildDir)).filter((f) => f !== "backend/build-metadata.json");
|
|
943
|
+
files.sort();
|
|
944
|
+
const hash = createHash("sha256");
|
|
945
|
+
for (const file of files) {
|
|
946
|
+
hash.update(file);
|
|
947
|
+
hash.update(await fs.readFile(path.join(buildDir, file)));
|
|
948
|
+
}
|
|
949
|
+
return hash.digest("hex").slice(0, 12);
|
|
950
|
+
}
|
|
923
951
|
async function buildVersion(options) {
|
|
924
952
|
const logger = getLogger();
|
|
925
953
|
const buildDir = path.join(options.buildRoot, `v${options.version}`);
|
|
@@ -1288,8 +1316,6 @@ async function buildVersion(options) {
|
|
|
1288
1316
|
}
|
|
1289
1317
|
const manifest = {
|
|
1290
1318
|
version: options.version,
|
|
1291
|
-
buildTimestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1292
|
-
sourceHash: "",
|
|
1293
1319
|
projectRoot: options.projectRoot,
|
|
1294
1320
|
sharedManifest,
|
|
1295
1321
|
routes: routeEntries.map((r) => r.entry),
|
|
@@ -1297,10 +1323,18 @@ async function buildVersion(options) {
|
|
|
1297
1323
|
plugins
|
|
1298
1324
|
};
|
|
1299
1325
|
await writeRouteManifest(manifest, backendDir);
|
|
1326
|
+
const publicFolder = path.join(options.projectRoot, "public");
|
|
1327
|
+
try {
|
|
1328
|
+
await fs.access(publicFolder);
|
|
1329
|
+
await fs.cp(publicFolder, path.join(frontendDir, "public"), { recursive: true });
|
|
1330
|
+
logger.info("[Build] Copied public/ to frontend/public/");
|
|
1331
|
+
} catch {
|
|
1332
|
+
}
|
|
1333
|
+
const sourceHash = await computeBuildHash(buildDir);
|
|
1300
1334
|
const metadata = {
|
|
1301
1335
|
version: options.version,
|
|
1302
|
-
sourceHash
|
|
1303
|
-
buildTimestamp:
|
|
1336
|
+
sourceHash,
|
|
1337
|
+
buildTimestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1304
1338
|
nodeVersion: process.version,
|
|
1305
1339
|
instanceCount
|
|
1306
1340
|
};
|
|
@@ -1308,14 +1342,9 @@ async function buildVersion(options) {
|
|
|
1308
1342
|
path.join(backendDir, "build-metadata.json"),
|
|
1309
1343
|
JSON.stringify(metadata, null, 2)
|
|
1310
1344
|
);
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
await fs.cp(publicFolder, path.join(frontendDir, "public"), { recursive: true });
|
|
1315
|
-
logger.info("[Build] Copied public/ to frontend/public/");
|
|
1316
|
-
} catch {
|
|
1317
|
-
}
|
|
1318
|
-
logger.important(`[Build] Done! ${instanceCount} instances built in ${buildDir}`);
|
|
1345
|
+
logger.important(
|
|
1346
|
+
`[Build] Done! ${instanceCount} instances built in ${buildDir} (hash: ${sourceHash})`
|
|
1347
|
+
);
|
|
1319
1348
|
return manifest;
|
|
1320
1349
|
}
|
|
1321
1350
|
function toFetchRequest(req) {
|
|
@@ -1880,9 +1909,12 @@ async function startRendererServer(options) {
|
|
|
1880
1909
|
const manifest = JSON.parse(
|
|
1881
1910
|
await fs.readFile(path.join(buildDir, "route-manifest.json"), "utf-8")
|
|
1882
1911
|
);
|
|
1912
|
+
const metadata = JSON.parse(
|
|
1913
|
+
await fs.readFile(path.join(buildDir, "build-metadata.json"), "utf-8")
|
|
1914
|
+
);
|
|
1883
1915
|
const status = {
|
|
1884
1916
|
version: options.version,
|
|
1885
|
-
buildTimestamp:
|
|
1917
|
+
buildTimestamp: metadata.buildTimestamp,
|
|
1886
1918
|
instanceCount: manifest.routes.reduce((n, r) => n + r.instances.length, 0),
|
|
1887
1919
|
uptime: Math.floor((Date.now() - startTime) / 1e3),
|
|
1888
1920
|
webhooks: [...webhookMap.keys()],
|
|
@@ -386,12 +386,13 @@ async function fetchPageRequest(match, manifest, requestUrl, artifacts, staticBa
|
|
|
386
386
|
]);
|
|
387
387
|
const tData = Date.now();
|
|
388
388
|
const query = Object.fromEntries(requestUrl.searchParams.entries());
|
|
389
|
+
const cf = cached.carryForward;
|
|
389
390
|
const fastResult = await renderFastChangingData(
|
|
390
391
|
match.params,
|
|
391
392
|
{ params: match.params, query },
|
|
392
393
|
cached.carryForward,
|
|
393
394
|
pageParts.parts,
|
|
394
|
-
|
|
395
|
+
cf.__instances,
|
|
395
396
|
pageParts.forEachInstances,
|
|
396
397
|
pageParts.headlessInstanceComponents,
|
|
397
398
|
cached.slowViewState,
|
|
@@ -399,20 +400,20 @@ async function fetchPageRequest(match, manifest, requestUrl, artifacts, staticBa
|
|
|
399
400
|
cookies
|
|
400
401
|
);
|
|
401
402
|
const tFast = Date.now();
|
|
402
|
-
if (fastResult.kind === "
|
|
403
|
+
if (fastResult.kind === "Redirect") {
|
|
403
404
|
return new Response(null, {
|
|
404
405
|
status: fastResult.status,
|
|
405
406
|
headers: { Location: fastResult.location }
|
|
406
407
|
});
|
|
407
408
|
}
|
|
408
|
-
if (fastResult.kind === "
|
|
409
|
+
if (fastResult.kind === "ServerError" || fastResult.kind === "ClientError") {
|
|
409
410
|
return new Response(fastResult.message || "Error", {
|
|
410
411
|
status: fastResult.status
|
|
411
412
|
});
|
|
412
413
|
}
|
|
413
414
|
const fastViewState = fastResult.rendered || {};
|
|
414
415
|
const fastCarryForward = fastResult.carryForward || {};
|
|
415
|
-
const instanceSlowVS =
|
|
416
|
+
const instanceSlowVS = cf.__instances?.slowViewStates;
|
|
416
417
|
const fullSlowViewState = instanceSlowVS && Object.keys(instanceSlowVS).length > 0 ? { ...cached.slowViewState, __headlessInstances: instanceSlowVS } : cached.slowViewState;
|
|
417
418
|
const fullViewState = deepMergeViewStates(
|
|
418
419
|
fullSlowViewState,
|
|
@@ -420,12 +421,11 @@ async function fetchPageRequest(match, manifest, requestUrl, artifacts, staticBa
|
|
|
420
421
|
route.trackByMap || {}
|
|
421
422
|
);
|
|
422
423
|
const headTagSources = [];
|
|
423
|
-
const slowHeadTags =
|
|
424
|
+
const slowHeadTags = cf.__slowHeadTags;
|
|
424
425
|
if (slowHeadTags)
|
|
425
426
|
headTagSources.push(...slowHeadTags);
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
headTagSources.push(fastHeadTags);
|
|
427
|
+
if (fastResult.headTags)
|
|
428
|
+
headTagSources.push(fastResult.headTags);
|
|
429
429
|
const templateHeadTags = headMetaToHeadTags(route.headMeta, fullViewState);
|
|
430
430
|
if (templateHeadTags.length > 0)
|
|
431
431
|
headTagSources.push(templateHeadTags);
|
|
@@ -484,7 +484,7 @@ ${headParts}
|
|
|
484
484
|
if (asyncScripts)
|
|
485
485
|
write(asyncScripts);
|
|
486
486
|
const clientInitData = getClientInitData();
|
|
487
|
-
const initArgs = route.routeClientBundlePath ? `${JSON.stringify(
|
|
487
|
+
const initArgs = route.routeClientBundlePath ? `${JSON.stringify(fullSlowViewState)}, ${JSON.stringify(fastViewState)}, ${JSON.stringify(fastCarryForward)}, ${JSON.stringify(clientInitData)}` : `${JSON.stringify(fastViewState)}, ${JSON.stringify(fastCarryForward)}, ${JSON.stringify(clientInitData)}`;
|
|
488
488
|
const tTotal = Date.now() - t0;
|
|
489
489
|
const tLoadMs = tLoad - tLoadStart;
|
|
490
490
|
const serverTiming = {
|
package/dist/serve-index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { e as ArtifactStore, C as CacheEntry, F as FilesystemArtifactStore, I as InstanceEntry, M as MatchResult, n as PreImportedPlugin, a as RouteEntry, R as RouteManifest, S as ServerElementModule, g as fetchActionRequest, f as fetchPageRequest, j as fetchStaticFile, k as initializeServices, l as initializeServicesFromModules, i as isActionRequest, m as matchRequest, r as registerActionsFromManifest, h as registerActionsFromModules } from './serve-index-
|
|
1
|
+
export { e as ArtifactStore, C as CacheEntry, F as FilesystemArtifactStore, I as InstanceEntry, M as MatchResult, n as PreImportedPlugin, a as RouteEntry, R as RouteManifest, S as ServerElementModule, g as fetchActionRequest, f as fetchPageRequest, j as fetchStaticFile, k as initializeServices, l as initializeServicesFromModules, i as isActionRequest, m as matchRequest, r as registerActionsFromManifest, h as registerActionsFromModules } from './serve-index-oMDgTHRv.js';
|
|
2
2
|
import '@jay-framework/ssr-runtime';
|
|
3
3
|
import '@jay-framework/compiler-shared';
|
|
4
4
|
import '@jay-framework/stack-server-runtime';
|
package/dist/serve-index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jay-framework/production-server",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.8",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -30,20 +30,20 @@
|
|
|
30
30
|
"test:watch": "vitest"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@jay-framework/compiler-jay-html": "^0.19.
|
|
34
|
-
"@jay-framework/compiler-jay-stack": "^0.19.
|
|
35
|
-
"@jay-framework/compiler-shared": "^0.19.
|
|
36
|
-
"@jay-framework/fullstack-component": "^0.19.
|
|
37
|
-
"@jay-framework/logger": "^0.19.
|
|
38
|
-
"@jay-framework/ssr-runtime": "^0.19.
|
|
39
|
-
"@jay-framework/stack-route-scanner": "^0.19.
|
|
40
|
-
"@jay-framework/stack-server-runtime": "^0.19.
|
|
41
|
-
"@jay-framework/view-state-merge": "^0.19.
|
|
42
|
-
"@jay-framework/vite-plugin": "^0.19.
|
|
33
|
+
"@jay-framework/compiler-jay-html": "^0.19.8",
|
|
34
|
+
"@jay-framework/compiler-jay-stack": "^0.19.8",
|
|
35
|
+
"@jay-framework/compiler-shared": "^0.19.8",
|
|
36
|
+
"@jay-framework/fullstack-component": "^0.19.8",
|
|
37
|
+
"@jay-framework/logger": "^0.19.8",
|
|
38
|
+
"@jay-framework/ssr-runtime": "^0.19.8",
|
|
39
|
+
"@jay-framework/stack-route-scanner": "^0.19.8",
|
|
40
|
+
"@jay-framework/stack-server-runtime": "^0.19.8",
|
|
41
|
+
"@jay-framework/view-state-merge": "^0.19.8",
|
|
42
|
+
"@jay-framework/vite-plugin": "^0.19.8",
|
|
43
43
|
"vite": "^5.0.11"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@jay-framework/dev-environment": "^0.19.
|
|
46
|
+
"@jay-framework/dev-environment": "^0.19.8",
|
|
47
47
|
"@types/node": "^22.15.21",
|
|
48
48
|
"rimraf": "^5.0.5",
|
|
49
49
|
"tsup": "^8.0.1",
|