veryfront 0.1.930 → 0.1.931
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/esm/deno.js +1 -1
- package/esm/src/server/handlers/request/css.handler.d.ts.map +1 -1
- package/esm/src/server/handlers/request/css.handler.js +16 -2
- package/esm/src/server/handlers/request/rsc/index.d.ts.map +1 -1
- package/esm/src/server/handlers/request/rsc/index.js +5 -1
- package/esm/src/server/services/rsc/endpoints/endpoint-router.d.ts.map +1 -1
- package/esm/src/server/services/rsc/endpoints/endpoint-router.js +14 -12
- package/esm/src/server/shared/browser-module-bundler.d.ts.map +1 -1
- package/esm/src/server/shared/browser-module-bundler.js +16 -0
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +1 -1
package/esm/deno.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css.handler.d.ts","sourceRoot":"","sources":["../../../../../src/src/server/handlers/request/css.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAmB,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"css.handler.d.ts","sourceRoot":"","sources":["../../../../../src/src/server/handlers/request/css.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAmB,aAAa,EAAE,MAAM,aAAa,CAAC;AAyCnG,qBAAa,UAAW,SAAQ,WAAW;IACzC,QAAQ,EAAE,eAAe,CAOvB;IAEI,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;CAsExE"}
|
|
@@ -4,6 +4,7 @@ import { HTTP_OK, PRIORITY_HIGH } from "../../../utils/constants/index.js";
|
|
|
4
4
|
import { extractCacheKeyContext, runWithCacheKeyContext, } from "../../../cache/cache-key-builder.js";
|
|
5
5
|
import { getHostEnv } from "../../../platform/compat/process.js";
|
|
6
6
|
import { runWithRequestContext } from "../../../platform/adapters/fs/veryfront/multi-project-adapter.js";
|
|
7
|
+
import { join } from "../../../platform/compat/path/index.js";
|
|
7
8
|
/** Pattern to match hashed CSS URLs: /_vf/css/[8-char-hash].css */
|
|
8
9
|
const CSS_URL_PATTERN = /^\/_vf\/css\/([a-z0-9-]{1,16})\.css$/;
|
|
9
10
|
async function getCSSWithJITFallback(cssHash, projectSlug) {
|
|
@@ -12,6 +13,18 @@ async function getCSSWithJITFallback(cssHash, projectSlug) {
|
|
|
12
13
|
return cached;
|
|
13
14
|
return regenerateCSSByHash(cssHash, projectSlug);
|
|
14
15
|
}
|
|
16
|
+
async function getBuiltCSSFallback(cssHash, ctx) {
|
|
17
|
+
const builtCSSPath = join(ctx.projectDir, "dist", "_vf", "css", `${cssHash}.css`);
|
|
18
|
+
try {
|
|
19
|
+
const exists = await ctx.adapter.fs.exists(builtCSSPath);
|
|
20
|
+
if (!exists)
|
|
21
|
+
return undefined;
|
|
22
|
+
return await ctx.adapter.fs.readFile(builtCSSPath);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
15
28
|
export class CSSHandler extends BaseHandler {
|
|
16
29
|
metadata = {
|
|
17
30
|
name: "CSSHandler",
|
|
@@ -47,7 +60,8 @@ export class CSSHandler extends BaseHandler {
|
|
|
47
60
|
releaseId: ctx.releaseId,
|
|
48
61
|
}, lookup)
|
|
49
62
|
: await lookup();
|
|
50
|
-
|
|
63
|
+
const resolvedCSS = css ?? await getBuiltCSSFallback(cssHash, ctx);
|
|
64
|
+
if (!resolvedCSS) {
|
|
51
65
|
this.logInfo(`CSS not found and JIT regeneration failed: ${cssHash}. ` +
|
|
52
66
|
`Server restart or cache expiry. Reload page to regenerate.`, {}, ctx);
|
|
53
67
|
// Return 404 instead of 200 with comment - this is more honest
|
|
@@ -58,7 +72,7 @@ export class CSSHandler extends BaseHandler {
|
|
|
58
72
|
.withContentType("text/css; charset=utf-8", `/* CSS ${cssHash} not found - reload page to regenerate */`, 404);
|
|
59
73
|
return this.respond(response);
|
|
60
74
|
}
|
|
61
|
-
const body = method === "HEAD" ? null :
|
|
75
|
+
const body = method === "HEAD" ? null : resolvedCSS;
|
|
62
76
|
const response = this.createResponseBuilder(ctx)
|
|
63
77
|
.withCORS(req, ctx.securityConfig?.cors)
|
|
64
78
|
.withCache("immutable")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/src/server/handlers/request/rsc/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EAEf,aAAa,EACd,MAAM,gBAAgB,CAAC;AASxB,qBAAa,UAAW,SAAQ,WAAW;IACzC,QAAQ,EAAE,eAAe,CAIvB;IAEF,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/src/server/handlers/request/rsc/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EAEf,aAAa,EACd,MAAM,gBAAgB,CAAC;AASxB,qBAAa,UAAW,SAAQ,WAAW;IACzC,QAAQ,EAAE,eAAe,CAIvB;IAEF,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;CA2DlE"}
|
|
@@ -25,8 +25,12 @@ export class RSCHandler extends BaseHandler {
|
|
|
25
25
|
const endpoint = pathname.slice("/_veryfront/rsc/".length);
|
|
26
26
|
return withSpan("rsc.handle", async () => {
|
|
27
27
|
const isHydrationScript = endpoint === "client.js" || endpoint === "dom.js";
|
|
28
|
+
const isClientModuleEndpoint = endpoint === "module";
|
|
28
29
|
const isDeprecatedEndpoint = endpoint === "flight_page";
|
|
29
|
-
if (!isRSCEnabled(ctx.config) &&
|
|
30
|
+
if (!isRSCEnabled(ctx.config) &&
|
|
31
|
+
!isHydrationScript &&
|
|
32
|
+
!isClientModuleEndpoint &&
|
|
33
|
+
!isDeprecatedEndpoint) {
|
|
30
34
|
return this.respond(new Response("Not Found", { status: HTTP_NOT_FOUND }));
|
|
31
35
|
}
|
|
32
36
|
const nonce = generateNonce();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint-router.d.ts","sourceRoot":"","sources":["../../../../../../src/src/server/services/rsc/endpoints/endpoint-router.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAcH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAKpD;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,iBAAiB,GAClF,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"endpoint-router.d.ts","sourceRoot":"","sources":["../../../../../../src/src/server/services/rsc/endpoints/endpoint-router.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAcH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAKpD;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,iBAAiB,GAClF,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CA4H1B"}
|
|
@@ -40,12 +40,22 @@ export async function handleRSCEndpoint({ req, pathname, projectDir, projectId,
|
|
|
40
40
|
if (sub === "flight_page") {
|
|
41
41
|
return new Response("Flight endpoint removed. Use custom RSC endpoints.", { status: 410 });
|
|
42
42
|
}
|
|
43
|
-
if (!isRSCEnabled(config)) {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
43
|
const url = new URL(req.url);
|
|
47
|
-
const handler = getRSCHandler(projectDir, projectId);
|
|
48
44
|
try {
|
|
45
|
+
// App-router client-page hydration imports browser-safe page modules from
|
|
46
|
+
// this endpoint even when the broader RSC transport is not enabled.
|
|
47
|
+
if (sub === "module") {
|
|
48
|
+
return await handleModuleEndpoint({
|
|
49
|
+
searchParams: url.searchParams,
|
|
50
|
+
projectDir,
|
|
51
|
+
adapter,
|
|
52
|
+
config,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (!isRSCEnabled(config)) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
const handler = getRSCHandler(projectDir, projectId);
|
|
49
59
|
if (sub.startsWith("render/")) {
|
|
50
60
|
return handler.handleRender(sub.replace("render/", ""), url.searchParams, req);
|
|
51
61
|
}
|
|
@@ -87,14 +97,6 @@ export async function handleRSCEndpoint({ req, pathname, projectDir, projectId,
|
|
|
87
97
|
metrics.recordRSC("page");
|
|
88
98
|
return handlePayloadEndpoint({ handler, searchParams: url.searchParams });
|
|
89
99
|
}
|
|
90
|
-
if (sub === "module") {
|
|
91
|
-
return await handleModuleEndpoint({
|
|
92
|
-
searchParams: url.searchParams,
|
|
93
|
-
projectDir,
|
|
94
|
-
adapter,
|
|
95
|
-
config,
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
100
|
if (sub === "page") {
|
|
99
101
|
metrics.recordRSC("page");
|
|
100
102
|
return handler.handlePage("/", url.searchParams, nonce);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-module-bundler.d.ts","sourceRoot":"","sources":["../../../../src/src/server/shared/browser-module-bundler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"browser-module-bundler.d.ts","sourceRoot":"","sources":["../../../../src/src/server/shared/browser-module-bundler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AA2B7D,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,cAAc,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,MAAM,CAAC,CA4CjB"}
|
|
@@ -2,6 +2,21 @@ import { buildImportMapJson } from "../../html/index.js";
|
|
|
2
2
|
import { withSpan } from "../../observability/tracing/otlp-setup.js";
|
|
3
3
|
import { getDirectory, getEsbuildLoader } from "../../utils/path-utils.js";
|
|
4
4
|
import { createBareExternalPlugin, createHttpExternalPlugin, createRelativeFsPlugin, } from "../handlers/dev/files/esbuild-plugins.js";
|
|
5
|
+
function createIgnoreCSSImportsPlugin() {
|
|
6
|
+
return {
|
|
7
|
+
name: "veryfront-ignore-css-imports",
|
|
8
|
+
setup(build) {
|
|
9
|
+
build.onResolve({ filter: /\.css(?:\?.*)?$/ }, (args) => ({
|
|
10
|
+
path: args.path,
|
|
11
|
+
namespace: "veryfront-empty-css",
|
|
12
|
+
}));
|
|
13
|
+
build.onLoad({ filter: /.*/, namespace: "veryfront-empty-css" }, (_args) => ({
|
|
14
|
+
contents: "",
|
|
15
|
+
loader: "js",
|
|
16
|
+
}));
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
}
|
|
5
20
|
export function bundleBrowserModule(absPath, options) {
|
|
6
21
|
return withSpan("server.browser-module.bundle", async () => {
|
|
7
22
|
const { build } = await import("../../extensions/bundler/index.js");
|
|
@@ -27,6 +42,7 @@ export function bundleBrowserModule(absPath, options) {
|
|
|
27
42
|
sourcefile: absPath,
|
|
28
43
|
},
|
|
29
44
|
plugins: [
|
|
45
|
+
createIgnoreCSSImportsPlugin(),
|
|
30
46
|
createRelativeFsPlugin(options.projectDir, options.adapter),
|
|
31
47
|
createBareExternalPlugin({
|
|
32
48
|
importMapImports: importMap.imports,
|