@jay-framework/dev-server 0.15.1 → 0.15.3
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 +5 -0
- package/dist/index.js +40 -17
- package/package.json +14 -14
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { JayRoute } from '@jay-framework/stack-route-scanner';
|
|
|
3
3
|
import { RequestHandler } from 'express-serve-static-core';
|
|
4
4
|
import { JayRollupConfig } from '@jay-framework/rollup-plugin';
|
|
5
5
|
import { LogLevel } from '@jay-framework/logger';
|
|
6
|
+
import { Server } from 'node:http';
|
|
6
7
|
import { ProjectClientInitInfo, PluginWithInit, ActionRegistry } from '@jay-framework/stack-server-runtime';
|
|
7
8
|
import { RequestHandler as RequestHandler$1 } from 'express';
|
|
8
9
|
import { JayRollupConfig as JayRollupConfig$1 } from '@jay-framework/compiler-jay-stack';
|
|
@@ -34,6 +35,8 @@ interface DevServerOptions {
|
|
|
34
35
|
* Controls both Jay logging and Vite logging.
|
|
35
36
|
*/
|
|
36
37
|
logLevel?: LogLevel;
|
|
38
|
+
/** HTTP server for HMR WebSocket attachment (avoids default port 24678 collision) */
|
|
39
|
+
httpServer?: Server;
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
/**
|
|
@@ -182,6 +185,8 @@ interface CreateViteServerOptions {
|
|
|
182
185
|
logLevel?: 'info' | 'warn' | 'error' | 'silent';
|
|
183
186
|
/** Whether to clear screen on rebuild */
|
|
184
187
|
clearScreen?: boolean;
|
|
188
|
+
/** HTTP server for HMR WebSocket (avoids default port 24678 collision) */
|
|
189
|
+
httpServer?: Server;
|
|
185
190
|
}
|
|
186
191
|
/**
|
|
187
192
|
* Creates a Vite server configured for Jay Stack.
|
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ import { createRequire as createRequire$1 } from "node:module";
|
|
|
16
16
|
import * as fs from "node:fs";
|
|
17
17
|
import crypto from "node:crypto";
|
|
18
18
|
import { scanRoutes, routeToExpressRoute } from "@jay-framework/stack-route-scanner";
|
|
19
|
-
import { discoverPluginsWithInit, sortPluginsByDependencies, executePluginServerInits, runInitCallbacks, actionRegistry, discoverAndRegisterActions, discoverAllPluginActions, runShutdownCallbacks, clearLifecycleCallbacks, clearServiceRegistry, clearClientInitData, DevSlowlyChangingPhase, SlowRenderCache, preparePluginClientInits,
|
|
19
|
+
import { discoverPluginsWithInit, sortPluginsByDependencies, executePluginServerInits, runInitCallbacks, actionRegistry, discoverAndRegisterActions, discoverAllPluginActions, runShutdownCallbacks, clearLifecycleCallbacks, clearServiceRegistry, clearClientInitData, DevSlowlyChangingPhase, SlowRenderCache, preparePluginClientInits, clearServerElementCache, getServiceRegistry, materializeContracts, loadPageParts, renderFastChangingData, generateClientScript, getClientInitData, generateSSRPageHtml, validateForEachInstances, slowRenderInstances } from "@jay-framework/stack-server-runtime";
|
|
20
20
|
import fs$1 from "node:fs/promises";
|
|
21
21
|
import { pathToFileURL } from "node:url";
|
|
22
22
|
const s$1 = createRequire(import.meta.url), e$1 = s$1("typescript"), c$1 = new Proxy(e$1, {
|
|
@@ -1152,8 +1152,8 @@ function extractPackageName(source) {
|
|
|
1152
1152
|
function isSubpathImport(source, packageName) {
|
|
1153
1153
|
return source.length > packageName.length && source[packageName.length] === "/";
|
|
1154
1154
|
}
|
|
1155
|
-
const IMPORT_REGEX = /import\s+(
|
|
1156
|
-
const EXPORT_FROM_REGEX = /export\s+(
|
|
1155
|
+
const IMPORT_REGEX = /import\s+([\s\S]+?)\s+from\s+(['"])([^'"]+)\2/g;
|
|
1156
|
+
const EXPORT_FROM_REGEX = /export\s+([\s\S]+?)\s+from\s+(['"])([^'"]+)\2/g;
|
|
1157
1157
|
function transformImports(options) {
|
|
1158
1158
|
const { code, projectRoot, filePath, pluginDetector, verbose = false } = options;
|
|
1159
1159
|
let hasChanges = false;
|
|
@@ -1363,13 +1363,18 @@ async function createViteServer(options) {
|
|
|
1363
1363
|
base,
|
|
1364
1364
|
jayRollupConfig = { tsConfigFilePath: path__default.join(projectRoot, "tsconfig.json") },
|
|
1365
1365
|
logLevel = "info",
|
|
1366
|
-
clearScreen = true
|
|
1366
|
+
clearScreen = true,
|
|
1367
|
+
httpServer
|
|
1367
1368
|
} = options;
|
|
1368
1369
|
const instanceId = crypto.randomBytes(4).toString("hex");
|
|
1369
1370
|
const cacheDir = path__default.join(projectRoot, "node_modules", `.vite-${instanceId}`);
|
|
1370
1371
|
const vite = await createServer({
|
|
1371
1372
|
// Don't start HTTP server - we use middleware mode
|
|
1372
|
-
server: {
|
|
1373
|
+
server: {
|
|
1374
|
+
middlewareMode: true,
|
|
1375
|
+
hmr: httpServer ? { server: httpServer } : void 0,
|
|
1376
|
+
watch: { ignored: ["**/build/**"] }
|
|
1377
|
+
},
|
|
1373
1378
|
// Use Jay Stack compiler for .jay-html and other custom transforms
|
|
1374
1379
|
plugins: [...jayStackCompiler(jayRollupConfig)],
|
|
1375
1380
|
// Custom app type (no default middleware)
|
|
@@ -1857,7 +1862,8 @@ function defaults(options) {
|
|
|
1857
1862
|
jayRollupConfig: {
|
|
1858
1863
|
...options.jayRollupConfig || {},
|
|
1859
1864
|
tsConfigFilePath
|
|
1860
|
-
}
|
|
1865
|
+
},
|
|
1866
|
+
httpServer: options.httpServer
|
|
1861
1867
|
};
|
|
1862
1868
|
}
|
|
1863
1869
|
function handleOtherResponseCodes(res, renderedResult) {
|
|
@@ -1908,6 +1914,11 @@ function mkRoute(route, vite, slowlyPhase, options, slowRenderCache, projectInit
|
|
|
1908
1914
|
language: "en",
|
|
1909
1915
|
url
|
|
1910
1916
|
};
|
|
1917
|
+
const query = {};
|
|
1918
|
+
const urlObj = new URL(req.originalUrl, `http://${req.headers.host}`);
|
|
1919
|
+
for (const [key, value] of urlObj.searchParams) {
|
|
1920
|
+
query[key] = value;
|
|
1921
|
+
}
|
|
1911
1922
|
if (options.disableSSR) {
|
|
1912
1923
|
await handleClientOnlyRequest(
|
|
1913
1924
|
vite,
|
|
@@ -1921,7 +1932,8 @@ function mkRoute(route, vite, slowlyPhase, options, slowRenderCache, projectInit
|
|
|
1921
1932
|
projectInit,
|
|
1922
1933
|
res,
|
|
1923
1934
|
url,
|
|
1924
|
-
timing
|
|
1935
|
+
timing,
|
|
1936
|
+
query
|
|
1925
1937
|
);
|
|
1926
1938
|
} else {
|
|
1927
1939
|
const cachedEntry = await slowRenderCache.get(route.jayHtmlPath, pageParams);
|
|
@@ -1938,7 +1950,8 @@ function mkRoute(route, vite, slowlyPhase, options, slowRenderCache, projectInit
|
|
|
1938
1950
|
projectInit,
|
|
1939
1951
|
res,
|
|
1940
1952
|
url,
|
|
1941
|
-
timing
|
|
1953
|
+
timing,
|
|
1954
|
+
query
|
|
1942
1955
|
);
|
|
1943
1956
|
} else {
|
|
1944
1957
|
await handlePreRenderRequest(
|
|
@@ -1954,7 +1967,8 @@ function mkRoute(route, vite, slowlyPhase, options, slowRenderCache, projectInit
|
|
|
1954
1967
|
projectInit,
|
|
1955
1968
|
res,
|
|
1956
1969
|
url,
|
|
1957
|
-
timing
|
|
1970
|
+
timing,
|
|
1971
|
+
query
|
|
1958
1972
|
);
|
|
1959
1973
|
}
|
|
1960
1974
|
}
|
|
@@ -1967,7 +1981,7 @@ function mkRoute(route, vite, slowlyPhase, options, slowRenderCache, projectInit
|
|
|
1967
1981
|
};
|
|
1968
1982
|
return { path: routePath, handler, fsRoute: route };
|
|
1969
1983
|
}
|
|
1970
|
-
async function handleCachedRequest(vite, route, options, cachedEntry, pageParams, pageProps, allPluginClientInits, allPluginsWithInit, projectInit, res, url, timing) {
|
|
1984
|
+
async function handleCachedRequest(vite, route, options, cachedEntry, pageParams, pageProps, allPluginClientInits, allPluginsWithInit, projectInit, res, url, timing, query = {}) {
|
|
1971
1985
|
const loadStart = Date.now();
|
|
1972
1986
|
const pagePartsResult = await loadPageParts(
|
|
1973
1987
|
vite,
|
|
@@ -2005,7 +2019,8 @@ async function handleCachedRequest(vite, route, options, cachedEntry, pageParams
|
|
|
2005
2019
|
instancePhaseData,
|
|
2006
2020
|
forEachInstances,
|
|
2007
2021
|
headlessComps,
|
|
2008
|
-
cachedEntry.slowViewState
|
|
2022
|
+
cachedEntry.slowViewState,
|
|
2023
|
+
query
|
|
2009
2024
|
);
|
|
2010
2025
|
timing?.recordFastRender(Date.now() - fastStart);
|
|
2011
2026
|
if (renderedFast.kind !== "PhaseOutput") {
|
|
@@ -2033,7 +2048,7 @@ async function handleCachedRequest(vite, route, options, cachedEntry, pageParams
|
|
|
2033
2048
|
cachedEntry.preRenderedContent
|
|
2034
2049
|
);
|
|
2035
2050
|
}
|
|
2036
|
-
async function handlePreRenderRequest(vite, route, options, slowlyPhase, slowRenderCache, pageParams, pageProps, allPluginClientInits, allPluginsWithInit, projectInit, res, url, timing) {
|
|
2051
|
+
async function handlePreRenderRequest(vite, route, options, slowlyPhase, slowRenderCache, pageParams, pageProps, allPluginClientInits, allPluginsWithInit, projectInit, res, url, timing, query = {}) {
|
|
2037
2052
|
const loadStart = Date.now();
|
|
2038
2053
|
const initialPartsResult = await loadPageParts(
|
|
2039
2054
|
vite,
|
|
@@ -2112,10 +2127,11 @@ async function handlePreRenderRequest(vite, route, options, slowlyPhase, slowRen
|
|
|
2112
2127
|
projectInit,
|
|
2113
2128
|
res,
|
|
2114
2129
|
url,
|
|
2115
|
-
timing
|
|
2130
|
+
timing,
|
|
2131
|
+
query
|
|
2116
2132
|
);
|
|
2117
2133
|
}
|
|
2118
|
-
async function handleClientOnlyRequest(vite, route, options, slowlyPhase, pageParams, pageProps, allPluginClientInits, allPluginsWithInit, projectInit, res, url, timing) {
|
|
2134
|
+
async function handleClientOnlyRequest(vite, route, options, slowlyPhase, pageParams, pageProps, allPluginClientInits, allPluginsWithInit, projectInit, res, url, timing, query = {}) {
|
|
2119
2135
|
const loadStart = Date.now();
|
|
2120
2136
|
const pagePartsResult = await loadPageParts(
|
|
2121
2137
|
vite,
|
|
@@ -2173,7 +2189,8 @@ async function handleClientOnlyRequest(vite, route, options, slowlyPhase, pagePa
|
|
|
2173
2189
|
instancePhaseData,
|
|
2174
2190
|
forEachInstances,
|
|
2175
2191
|
headlessInstanceComponents,
|
|
2176
|
-
renderedSlowly.rendered
|
|
2192
|
+
renderedSlowly.rendered,
|
|
2193
|
+
query
|
|
2177
2194
|
);
|
|
2178
2195
|
timing?.recordFastRender(Date.now() - fastStart);
|
|
2179
2196
|
if (renderedFast.kind !== "PhaseOutput") {
|
|
@@ -2432,7 +2449,8 @@ async function mkDevServer(rawOptions) {
|
|
|
2432
2449
|
pagesRoot: pagesRootFolder,
|
|
2433
2450
|
base: publicBaseUrlPath,
|
|
2434
2451
|
jayRollupConfig,
|
|
2435
|
-
logLevel: viteLogLevel
|
|
2452
|
+
logLevel: viteLogLevel,
|
|
2453
|
+
httpServer: options.httpServer
|
|
2436
2454
|
});
|
|
2437
2455
|
lifecycleManager.setViteServer(vite);
|
|
2438
2456
|
await lifecycleManager.initialize();
|
|
@@ -2509,28 +2527,33 @@ function setupSlowRenderCacheInvalidation(vite, cache, pagesRootFolder) {
|
|
|
2509
2527
|
return;
|
|
2510
2528
|
}
|
|
2511
2529
|
if (changedPath.endsWith(".jay-html")) {
|
|
2512
|
-
|
|
2530
|
+
clearServerElementCache();
|
|
2513
2531
|
cache.invalidate(changedPath).then(() => {
|
|
2514
2532
|
getLogger().info(`[SlowRender] Cache invalidated for ${changedPath}`);
|
|
2533
|
+
vite.ws.send({ type: "full-reload" });
|
|
2515
2534
|
});
|
|
2516
2535
|
return;
|
|
2517
2536
|
}
|
|
2518
2537
|
if (changedPath.endsWith("page.ts")) {
|
|
2519
2538
|
const dir = path__default.dirname(changedPath);
|
|
2520
2539
|
const jayHtmlPath = path__default.join(dir, "page.jay-html");
|
|
2540
|
+
clearServerElementCache();
|
|
2521
2541
|
cache.invalidate(jayHtmlPath).then(() => {
|
|
2522
2542
|
getLogger().info(
|
|
2523
2543
|
`[SlowRender] Cache invalidated for ${jayHtmlPath} (page.ts changed)`
|
|
2524
2544
|
);
|
|
2545
|
+
vite.ws.send({ type: "full-reload" });
|
|
2525
2546
|
});
|
|
2526
2547
|
return;
|
|
2527
2548
|
}
|
|
2528
2549
|
if (changedPath.endsWith(".jay-contract")) {
|
|
2529
2550
|
const jayHtmlPath = changedPath.replace(".jay-contract", ".jay-html");
|
|
2551
|
+
clearServerElementCache();
|
|
2530
2552
|
cache.invalidate(jayHtmlPath).then(() => {
|
|
2531
2553
|
getLogger().info(
|
|
2532
2554
|
`[SlowRender] Cache invalidated for ${jayHtmlPath} (contract changed)`
|
|
2533
2555
|
);
|
|
2556
|
+
vite.ws.send({ type: "full-reload" });
|
|
2534
2557
|
});
|
|
2535
2558
|
return;
|
|
2536
2559
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jay-framework/dev-server",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -23,22 +23,22 @@
|
|
|
23
23
|
"test:watch": "vitest"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@jay-framework/compiler-jay-stack": "^0.15.
|
|
27
|
-
"@jay-framework/compiler-shared": "^0.15.
|
|
28
|
-
"@jay-framework/component": "^0.15.
|
|
29
|
-
"@jay-framework/fullstack-component": "^0.15.
|
|
30
|
-
"@jay-framework/logger": "^0.15.
|
|
31
|
-
"@jay-framework/runtime": "^0.15.
|
|
32
|
-
"@jay-framework/stack-client-runtime": "^0.15.
|
|
33
|
-
"@jay-framework/stack-route-scanner": "^0.15.
|
|
34
|
-
"@jay-framework/stack-server-runtime": "^0.15.
|
|
35
|
-
"@jay-framework/view-state-merge": "^0.15.
|
|
26
|
+
"@jay-framework/compiler-jay-stack": "^0.15.3",
|
|
27
|
+
"@jay-framework/compiler-shared": "^0.15.3",
|
|
28
|
+
"@jay-framework/component": "^0.15.3",
|
|
29
|
+
"@jay-framework/fullstack-component": "^0.15.3",
|
|
30
|
+
"@jay-framework/logger": "^0.15.3",
|
|
31
|
+
"@jay-framework/runtime": "^0.15.3",
|
|
32
|
+
"@jay-framework/stack-client-runtime": "^0.15.3",
|
|
33
|
+
"@jay-framework/stack-route-scanner": "^0.15.3",
|
|
34
|
+
"@jay-framework/stack-server-runtime": "^0.15.3",
|
|
35
|
+
"@jay-framework/view-state-merge": "^0.15.3",
|
|
36
36
|
"vite": "^5.0.11"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@jay-framework/dev-environment": "^0.15.
|
|
40
|
-
"@jay-framework/jay-cli": "^0.15.
|
|
41
|
-
"@jay-framework/stack-client-runtime": "^0.15.
|
|
39
|
+
"@jay-framework/dev-environment": "^0.15.3",
|
|
40
|
+
"@jay-framework/jay-cli": "^0.15.3",
|
|
41
|
+
"@jay-framework/stack-client-runtime": "^0.15.3",
|
|
42
42
|
"@playwright/test": "^1.58.2",
|
|
43
43
|
"@types/express": "^5.0.2",
|
|
44
44
|
"@types/node": "^22.15.21",
|