veryfront 0.1.117 → 0.1.119
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.d.ts +2 -0
- package/esm/deno.js +4 -2
- package/esm/src/agent/runtime/input-utils.js +1 -1
- package/esm/src/agent/types.js +1 -1
- package/esm/src/html/html-injection.d.ts +6 -0
- package/esm/src/html/html-injection.d.ts.map +1 -1
- package/esm/src/html/html-injection.js +13 -1
- package/esm/src/html/hydration-script-builder/hydration-data-generator.d.ts.map +1 -1
- package/esm/src/html/hydration-script-builder/hydration-data-generator.js +5 -0
- package/esm/src/html/hydration-script-builder/types.d.ts +2 -0
- package/esm/src/html/hydration-script-builder/types.d.ts.map +1 -1
- package/esm/src/html/schemas/html.schema.d.ts +8 -0
- package/esm/src/html/schemas/html.schema.d.ts.map +1 -1
- package/esm/src/html/schemas/html.schema.js +2 -0
- package/esm/src/modules/react-loader/component-loader.d.ts +1 -0
- package/esm/src/modules/react-loader/component-loader.d.ts.map +1 -1
- package/esm/src/modules/react-loader/component-loader.js +8 -5
- package/esm/src/modules/react-loader/index.d.ts +1 -1
- package/esm/src/modules/react-loader/index.d.ts.map +1 -1
- package/esm/src/modules/react-loader/index.js +1 -1
- package/esm/src/modules/react-loader/ssr-module-loader/loader.d.ts +1 -0
- package/esm/src/modules/react-loader/ssr-module-loader/loader.d.ts.map +1 -1
- package/esm/src/modules/react-loader/ssr-module-loader/loader.js +6 -2
- package/esm/src/modules/server/module-server.d.ts.map +1 -1
- package/esm/src/modules/server/module-server.js +11 -45
- package/esm/src/platform/compat/framework-source-resolver.d.ts +20 -0
- package/esm/src/platform/compat/framework-source-resolver.d.ts.map +1 -0
- package/esm/src/platform/compat/framework-source-resolver.js +62 -0
- package/esm/src/react/compat/ssr-adapter/server-loader.d.ts +1 -0
- package/esm/src/react/compat/ssr-adapter/server-loader.d.ts.map +1 -1
- package/esm/src/react/compat/ssr-adapter/server-loader.js +4 -1
- package/esm/src/react/compat/ssr-adapter/stream-renderer.d.ts +2 -0
- package/esm/src/react/compat/ssr-adapter/stream-renderer.d.ts.map +1 -1
- package/esm/src/react/compat/ssr-adapter/stream-renderer.js +14 -7
- package/esm/src/react/components/ai/chat/contexts/chat-context.js +1 -1
- package/esm/src/react/components/ai/chat/contexts/composer-context.js +1 -1
- package/esm/src/react/components/ai/chat/contexts/message-context.js +1 -1
- package/esm/src/react/components/ai/chat/contexts/thread-list-context.js +1 -1
- package/esm/src/react/context/index.d.ts.map +1 -1
- package/esm/src/react/context/index.js +5 -1
- package/esm/src/react/router/index.d.ts.map +1 -1
- package/esm/src/react/router/index.js +5 -1
- package/esm/src/rendering/layouts/layout-applicator.d.ts +5 -0
- package/esm/src/rendering/layouts/layout-applicator.d.ts.map +1 -1
- package/esm/src/rendering/layouts/layout-applicator.js +58 -6
- package/esm/src/rendering/orchestrator/html.d.ts.map +1 -1
- package/esm/src/rendering/orchestrator/html.js +3 -0
- package/esm/src/rendering/orchestrator/layout.d.ts +1 -1
- package/esm/src/rendering/orchestrator/layout.d.ts.map +1 -1
- package/esm/src/rendering/orchestrator/layout.js +2 -1
- package/esm/src/rendering/orchestrator/pipeline.d.ts.map +1 -1
- package/esm/src/rendering/orchestrator/pipeline.js +5 -2
- package/esm/src/rendering/page-renderer.d.ts +1 -0
- package/esm/src/rendering/page-renderer.d.ts.map +1 -1
- package/esm/src/rendering/page-renderer.js +2 -0
- package/esm/src/rendering/page-rendering.d.ts +1 -0
- package/esm/src/rendering/page-rendering.d.ts.map +1 -1
- package/esm/src/rendering/page-rendering.js +2 -0
- package/esm/src/rendering/rsc/client-boot.ts +30 -57
- package/esm/src/rendering/rsc/client-hydrator.ts +2 -2
- package/esm/src/rendering/rsc/client-module-strategy.d.ts +27 -0
- package/esm/src/rendering/rsc/client-module-strategy.d.ts.map +1 -0
- package/esm/src/rendering/rsc/client-module-strategy.js +48 -0
- package/esm/src/rendering/rsc/constants.d.ts +5 -0
- package/esm/src/rendering/rsc/constants.d.ts.map +1 -0
- package/esm/src/rendering/rsc/constants.js +5 -0
- package/esm/src/rendering/rsc/hydrate-client.ts +30 -31
- package/esm/src/rendering/script-page-handling.d.ts +1 -0
- package/esm/src/rendering/script-page-handling.d.ts.map +1 -1
- package/esm/src/rendering/script-page-handling.js +3 -2
- package/esm/src/rendering/ssr-renderer.d.ts.map +1 -1
- package/esm/src/rendering/ssr-renderer.js +34 -7
- package/esm/src/routing/client/page-loader.js +1 -1
- package/esm/src/server/handlers/dev/files/esbuild-bundler.d.ts.map +1 -1
- package/esm/src/server/handlers/dev/files/esbuild-bundler.js +7 -36
- package/esm/src/server/handlers/dev/files/esbuild-plugins.d.ts +1 -0
- package/esm/src/server/handlers/dev/files/esbuild-plugins.d.ts.map +1 -1
- package/esm/src/server/handlers/dev/files/esbuild-plugins.js +15 -26
- package/esm/src/server/handlers/dev/framework-candidates.generated.js +1 -1
- package/esm/src/server/handlers/request/ssr/ssr.handler.d.ts +1 -0
- package/esm/src/server/handlers/request/ssr/ssr.handler.d.ts.map +1 -1
- package/esm/src/server/handlers/request/ssr/ssr.handler.js +12 -0
- package/esm/src/server/services/rendering/ssr.service.d.ts +2 -1
- package/esm/src/server/services/rendering/ssr.service.d.ts.map +1 -1
- package/esm/src/server/services/rendering/ssr.service.js +30 -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 +35 -12
- package/esm/src/server/services/rsc/endpoints/rsc-bundles.generated.d.ts.map +1 -1
- package/esm/src/server/services/rsc/endpoints/rsc-bundles.generated.js +1 -1
- package/esm/src/server/shared/browser-module-bundler.d.ts +10 -0
- package/esm/src/server/shared/browser-module-bundler.d.ts.map +1 -0
- package/esm/src/server/shared/browser-module-bundler.js +42 -0
- package/esm/src/transforms/mdx/esm-module-loader/resolution/file-finder.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/resolution/file-finder.js +19 -44
- package/esm/src/utils/import-map.d.ts +11 -0
- package/esm/src/utils/import-map.d.ts.map +1 -0
- package/esm/src/utils/import-map.js +44 -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/src/deno.js +4 -2
- package/src/src/agent/runtime/input-utils.ts +1 -1
- package/src/src/agent/types.ts +1 -1
- package/src/src/html/html-injection.ts +21 -1
- package/src/src/html/hydration-script-builder/hydration-data-generator.ts +5 -0
- package/src/src/html/hydration-script-builder/types.ts +3 -0
- package/src/src/html/schemas/html.schema.ts +2 -0
- package/src/src/modules/react-loader/component-loader.ts +16 -6
- package/src/src/modules/react-loader/index.ts +1 -1
- package/src/src/modules/react-loader/ssr-module-loader/loader.ts +11 -3
- package/src/src/modules/server/module-server.ts +17 -51
- package/src/src/platform/compat/framework-source-resolver.ts +89 -0
- package/src/src/react/compat/ssr-adapter/server-loader.ts +5 -1
- package/src/src/react/compat/ssr-adapter/stream-renderer.ts +17 -7
- package/src/src/react/components/ai/chat/contexts/chat-context.tsx +1 -1
- package/src/src/react/components/ai/chat/contexts/composer-context.tsx +1 -1
- package/src/src/react/components/ai/chat/contexts/message-context.tsx +1 -1
- package/src/src/react/components/ai/chat/contexts/thread-list-context.tsx +1 -1
- package/src/src/react/context/index.tsx +9 -1
- package/src/src/react/router/index.tsx +9 -1
- package/src/src/rendering/layouts/layout-applicator.ts +95 -6
- package/src/src/rendering/orchestrator/html.ts +3 -0
- package/src/src/rendering/orchestrator/layout.ts +2 -0
- package/src/src/rendering/orchestrator/pipeline.ts +5 -1
- package/src/src/rendering/page-renderer.ts +3 -0
- package/src/src/rendering/page-rendering.ts +3 -0
- package/src/src/rendering/rsc/client-module-strategy.ts +92 -0
- package/src/src/rendering/rsc/constants.ts +6 -0
- package/src/src/rendering/script-page-handling.ts +4 -1
- package/src/src/rendering/ssr-renderer.ts +32 -6
- package/src/src/routing/client/page-loader.ts +1 -1
- package/src/src/server/handlers/dev/files/esbuild-bundler.ts +7 -42
- package/src/src/server/handlers/dev/files/esbuild-plugins.ts +18 -31
- package/src/src/server/handlers/dev/framework-candidates.generated.ts +1 -1
- package/src/src/server/handlers/request/ssr/ssr.handler.ts +20 -0
- package/src/src/server/services/rendering/ssr.service.ts +43 -1
- package/src/src/server/services/rsc/endpoints/endpoint-router.ts +43 -12
- package/src/src/server/services/rsc/endpoints/rsc-bundles.generated.ts +1 -1
- package/src/src/server/shared/browser-module-bundler.ts +65 -0
- package/src/src/transforms/mdx/esm-module-loader/resolution/file-finder.ts +21 -50
- package/src/src/utils/import-map.ts +53 -0
- package/src/src/utils/version-constant.ts +1 -1
package/esm/deno.d.ts
CHANGED
|
@@ -333,6 +333,8 @@ declare namespace _default {
|
|
|
333
333
|
"test:bun": string;
|
|
334
334
|
"test:all-runtimes": string;
|
|
335
335
|
"test:e2e": string;
|
|
336
|
+
"test:e2e:playwright": string;
|
|
337
|
+
"test:e2e:rsc-browser": string;
|
|
336
338
|
"test:e2e:binary": string;
|
|
337
339
|
"test:e2e:binary:fresh": string;
|
|
338
340
|
"check:circular": string;
|
package/esm/deno.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
"name": "veryfront",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.119",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"nodeModulesDir": "auto",
|
|
6
6
|
"exclude": [
|
|
@@ -350,7 +350,9 @@ export default {
|
|
|
350
350
|
"test:node": "node ./tests/node/run-tests.mjs 'src/**/*.test.ts'",
|
|
351
351
|
"test:bun": "node ./tests/bun/run-tests.mjs src/",
|
|
352
352
|
"test:all-runtimes": "deno task test:unit && deno task test:node && deno task test:bun",
|
|
353
|
-
"test:e2e": "
|
|
353
|
+
"test:e2e": "deno task test:e2e:playwright",
|
|
354
|
+
"test:e2e:playwright": "npx playwright test --config=tests/e2e/playwright.config.ts",
|
|
355
|
+
"test:e2e:rsc-browser": "deno task generate && VF_DISABLE_LRU_INTERVAL=1 SSR_TRANSFORM_PER_PROJECT_LIMIT=0 REVALIDATION_PER_PROJECT_LIMIT=0 NODE_ENV=production LOG_FORMAT=text deno test --no-check --allow-all tests/e2e/regressions/rsc-proxy-hydration.test.ts --unstable-worker-options --unstable-net",
|
|
354
356
|
"test:e2e:binary": "deno task generate && deno test --allow-all tests/integration/compiled-binary-e2e.test.ts",
|
|
355
357
|
"test:e2e:binary:fresh": "deno task generate && VERYFRONT_BINARY_FRESH=1 deno test --allow-all tests/integration/compiled-binary-e2e.test.ts",
|
|
356
358
|
"check:circular": "deno run -A jsr:@cunarist/deno-circular-deps src/index.ts",
|
package/esm/src/agent/types.js
CHANGED
|
@@ -5,6 +5,8 @@ export interface InjectHTMLContentOptions {
|
|
|
5
5
|
devPort?: number;
|
|
6
6
|
/** Absolute path to the page file, used for 'use client' hydration */
|
|
7
7
|
pagePath?: string;
|
|
8
|
+
/** Project root used to normalize absolute page paths in hydration data */
|
|
9
|
+
projectDir?: string;
|
|
8
10
|
/** Whether the page has 'use client' directive */
|
|
9
11
|
isClientPage?: boolean;
|
|
10
12
|
/** Whether page is embedded in Studio iframe */
|
|
@@ -15,6 +17,10 @@ export interface InjectHTMLContentOptions {
|
|
|
15
17
|
pageId?: string;
|
|
16
18
|
/** CSP nonce */
|
|
17
19
|
nonce?: string;
|
|
20
|
+
/** Deployment environment for hydration module selection */
|
|
21
|
+
environment?: "preview" | "production";
|
|
22
|
+
/** Whether the request is being served from a local project */
|
|
23
|
+
isLocalProject?: boolean;
|
|
18
24
|
/** WebSocket URL for direct Yjs connection from the bridge */
|
|
19
25
|
wsUrl?: string;
|
|
20
26
|
/** Yjs document GUID for the bridge to join the same room */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-injection.d.ts","sourceRoot":"","sources":["../../../src/src/html/html-injection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"html-injection.d.ts","sourceRoot":"","sources":["../../../src/src/html/html-injection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAY/D,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gDAAgD;IAChD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gBAAgB;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,WAAW,CAAC,EAAE,SAAS,GAAG,YAAY,CAAC;IACvC,+DAA+D;IAC/D,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iFAAiF;IACjF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAUD,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,wBAAwB,GAChC,MAAM,CAwFR"}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
import { resolveRelativePath } from "../modules/react-loader/path-resolver.js";
|
|
2
|
+
import { determineClientModuleStrategy } from "../rendering/rsc/client-module-strategy.js";
|
|
1
3
|
import { generateLinkTags, generateMetaTags, generateScriptTags, generateStyleTags, } from "./tag-generators.js";
|
|
2
4
|
import { escapeHtml } from "./html-escape.js";
|
|
3
5
|
import { getDevScripts, getDevStyles, getProdScripts, getStudioScripts } from "./dev-scripts.js";
|
|
6
|
+
function toProjectRelativePath(absolutePath, projectDir) {
|
|
7
|
+
const normalizedPath = absolutePath.replace(/\\/g, "/");
|
|
8
|
+
if (!projectDir)
|
|
9
|
+
return normalizedPath.replace(/^\//, "");
|
|
10
|
+
return resolveRelativePath(normalizedPath, projectDir);
|
|
11
|
+
}
|
|
4
12
|
export function injectHTMLContent(template, content, metadata, options) {
|
|
5
13
|
let html = template;
|
|
6
14
|
html = html.replace(/{{\s*content\s*}}/gi, content);
|
|
@@ -28,9 +36,13 @@ export function injectHTMLContent(template, content, metadata, options) {
|
|
|
28
36
|
// Inject hydration data for 'use client' pages (before scripts, so client.js can find it)
|
|
29
37
|
if (options.pagePath && options.isClientPage && hasBodyClose) {
|
|
30
38
|
const hydrationData = JSON.stringify({
|
|
31
|
-
pagePath: options.pagePath,
|
|
39
|
+
pagePath: toProjectRelativePath(options.pagePath, options.projectDir),
|
|
32
40
|
slug: options.slug,
|
|
33
41
|
isClientPage: true,
|
|
42
|
+
clientModuleStrategy: determineClientModuleStrategy({
|
|
43
|
+
isLocalProject: options.isLocalProject ?? options.mode === "development",
|
|
44
|
+
environment: options.environment,
|
|
45
|
+
}),
|
|
34
46
|
});
|
|
35
47
|
const hydrationScript = `<script id="veryfront-hydration-data" type="application/json">${hydrationData}</script>`;
|
|
36
48
|
html = html.replace(/<\/body>/i, `${hydrationScript}</body>`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hydration-data-generator.d.ts","sourceRoot":"","sources":["../../../../src/src/html/hydration-script-builder/hydration-data-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"hydration-data-generator.d.ts","sourceRoot":"","sources":["../../../../src/src/html/hydration-script-builder/hydration-data-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAI3D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAyBzD,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EACzC,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,qBAAqB,GAC7B,MAAM,CA2CR"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resolveRelativePath } from "../../modules/react-loader/path-resolver.js";
|
|
2
2
|
import { getExtensionName } from "../../utils/path-utils.js";
|
|
3
|
+
import { determineClientModuleStrategy } from "../../rendering/rsc/client-module-strategy.js";
|
|
3
4
|
function toProjectRelativePath(absolutePath, projectDir) {
|
|
4
5
|
if (!absolutePath)
|
|
5
6
|
return "";
|
|
@@ -41,6 +42,10 @@ export function generateHydrationData(slug, params, props, options) {
|
|
|
41
42
|
? toProjectRelativePath(options.pagePath, options.projectDir)
|
|
42
43
|
: undefined,
|
|
43
44
|
pageType: options.pageType || inferPageType(options.pagePath),
|
|
45
|
+
clientModuleStrategy: determineClientModuleStrategy({
|
|
46
|
+
isLocalProject: options.isLocalProject,
|
|
47
|
+
environment: options.environment,
|
|
48
|
+
}),
|
|
44
49
|
frontmatter: options.frontmatter,
|
|
45
50
|
layoutProps: options.layoutProps,
|
|
46
51
|
// In dev mode, client uses createRoot instead of hydrateRoot to avoid
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ClientModuleStrategy } from "../../rendering/rsc/client-module-strategy.js";
|
|
1
2
|
export interface HydrationLayout {
|
|
2
3
|
kind: "mdx" | "tsx";
|
|
3
4
|
path: string;
|
|
@@ -10,6 +11,7 @@ export interface HydrationDataStructure {
|
|
|
10
11
|
appPath?: string;
|
|
11
12
|
pagePath?: string;
|
|
12
13
|
pageType?: "mdx" | "md" | "tsx" | "jsx" | "ts" | "js";
|
|
14
|
+
clientModuleStrategy?: ClientModuleStrategy;
|
|
13
15
|
frontmatter?: Record<string, unknown>;
|
|
14
16
|
layoutProps?: Record<string, Record<string, unknown>>;
|
|
15
17
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/src/html/hydration-script-builder/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,KAAK,GAAG,KAAK,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IAC1C,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI,CAAC;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACtD;;;;OAIG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC9D,6EAA6E;IAC7E,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/src/html/hydration-script-builder/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAC;AAE1F,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,KAAK,GAAG,KAAK,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IAC1C,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI,CAAC;IACtD,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACtD;;;;OAIG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC9D,6EAA6E;IAC7E,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB"}
|
|
@@ -15,6 +15,10 @@ export declare const pageTypeSchema: z.ZodEnum<{
|
|
|
15
15
|
js: "js";
|
|
16
16
|
md: "md";
|
|
17
17
|
}>;
|
|
18
|
+
export declare const clientModuleStrategySchema: z.ZodEnum<{
|
|
19
|
+
fs: "fs";
|
|
20
|
+
"rsc-module": "rsc-module";
|
|
21
|
+
}>;
|
|
18
22
|
export declare const HTMLGenerationOptionsSchema: z.ZodObject<{
|
|
19
23
|
mode: z.ZodEnum<{
|
|
20
24
|
production: "production";
|
|
@@ -75,6 +79,10 @@ export declare const HydrationDataSchema: z.ZodObject<{
|
|
|
75
79
|
}, z.core.$strip>>;
|
|
76
80
|
appPath: z.ZodOptional<z.ZodString>;
|
|
77
81
|
pagePath: z.ZodOptional<z.ZodString>;
|
|
82
|
+
clientModuleStrategy: z.ZodOptional<z.ZodEnum<{
|
|
83
|
+
fs: "fs";
|
|
84
|
+
"rsc-module": "rsc-module";
|
|
85
|
+
}>>;
|
|
78
86
|
}, z.core.$strip>;
|
|
79
87
|
export type HTMLGenerationOptions = z.infer<typeof HTMLGenerationOptionsSchema>;
|
|
80
88
|
export type HydrationData = z.infer<typeof HydrationDataSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.schema.d.ts","sourceRoot":"","sources":["../../../../src/src/html/schemas/html.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,iBAAiB;;;EAA4B,CAAC;AAE3D,eAAO,MAAM,iBAAiB;;;EAAoC,CAAC;AAEnE,eAAO,MAAM,cAAc;;;;;;;EAAkD,CAAC;
|
|
1
|
+
{"version":3,"file":"html.schema.d.ts","sourceRoot":"","sources":["../../../../src/src/html/schemas/html.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,iBAAiB;;;EAA4B,CAAC;AAE3D,eAAO,MAAM,iBAAiB;;;EAAoC,CAAC;AAEnE,eAAO,MAAM,cAAc;;;;;;;EAAkD,CAAC;AAC9E,eAAO,MAAM,0BAA0B;;;EAA+B,CAAC;AAEvE,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyCtC,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;iBAa9B,CAAC;AAGH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAChF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
|
|
@@ -2,6 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
export const colorSchemeSchema = z.enum(["light", "dark"]);
|
|
3
3
|
export const environmentSchema = z.enum(["preview", "production"]);
|
|
4
4
|
export const pageTypeSchema = z.enum(["mdx", "md", "tsx", "jsx", "ts", "js"]);
|
|
5
|
+
export const clientModuleStrategySchema = z.enum(["fs", "rsc-module"]);
|
|
5
6
|
export const HTMLGenerationOptionsSchema = z.object({
|
|
6
7
|
mode: z.enum(["development", "production"]),
|
|
7
8
|
config: z.any(), // VeryfrontConfig is complex, use any
|
|
@@ -50,4 +51,5 @@ export const HydrationDataSchema = z.object({
|
|
|
50
51
|
})),
|
|
51
52
|
appPath: z.string().optional(),
|
|
52
53
|
pagePath: z.string().optional(),
|
|
54
|
+
clientModuleStrategy: clientModuleStrategySchema.optional(),
|
|
53
55
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type * as React from "react";
|
|
2
2
|
import type { RuntimeAdapter } from "../../platform/adapters/base.js";
|
|
3
3
|
import type { LoadComponentOptions } from "./types.js";
|
|
4
|
+
export declare function loadModuleFromSource(source: string, filePath: string, projectDir: string, adapter: RuntimeAdapter, options?: LoadComponentOptions): Promise<Record<string, unknown>>;
|
|
4
5
|
export declare function loadComponentFromSource(source: string, filePath: string, projectDir: string, adapter: RuntimeAdapter, options?: LoadComponentOptions): Promise<React.ComponentType<Record<string, unknown>>>;
|
|
5
6
|
//# sourceMappingURL=component-loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-loader.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/react-loader/component-loader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAKtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAMvD,
|
|
1
|
+
{"version":3,"file":"component-loader.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/react-loader/component-loader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAKtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAMvD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA2DlC;AAED,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAGvD"}
|
|
@@ -6,12 +6,12 @@ import { createFileSystem } from "../../platform/compat/fs.js";
|
|
|
6
6
|
import { SSRModuleLoader } from "./ssr-module-loader/index.js";
|
|
7
7
|
import { extractComponent } from "./extract-component.js";
|
|
8
8
|
import { withSpan } from "../../observability/tracing/otlp-setup.js";
|
|
9
|
-
export function
|
|
9
|
+
export async function loadModuleFromSource(source, filePath, projectDir, adapter, options) {
|
|
10
10
|
const fileName = filePath.split("/").pop() ?? filePath;
|
|
11
11
|
const projectId = options?.projectId ?? projectDir;
|
|
12
12
|
const dev = options?.dev ?? true;
|
|
13
13
|
const ssr = options?.ssr ?? true;
|
|
14
|
-
return withSpan("modules.react.loadComponentFromSource", async () => {
|
|
14
|
+
return await withSpan("modules.react.loadComponentFromSource", async () => {
|
|
15
15
|
if (ssr) {
|
|
16
16
|
const loader = new SSRModuleLoader({
|
|
17
17
|
projectDir,
|
|
@@ -23,7 +23,7 @@ export function loadComponentFromSource(source, filePath, projectDir, adapter, o
|
|
|
23
23
|
reactVersion: options?.reactVersion,
|
|
24
24
|
mode: options?.mode,
|
|
25
25
|
});
|
|
26
|
-
return loader.
|
|
26
|
+
return await loader.loadRawModule(filePath, source);
|
|
27
27
|
}
|
|
28
28
|
const transformOpts = {
|
|
29
29
|
projectId,
|
|
@@ -41,8 +41,7 @@ export function loadComponentFromSource(source, filePath, projectDir, adapter, o
|
|
|
41
41
|
const fs = createFileSystem();
|
|
42
42
|
await fs.mkdir(componentDir, { recursive: true });
|
|
43
43
|
await fs.writeTextFile(componentFile, transformedCode);
|
|
44
|
-
|
|
45
|
-
return extractComponent(mod, filePath);
|
|
44
|
+
return await import(`file://${componentFile}?t=${Date.now()}`);
|
|
46
45
|
}, {
|
|
47
46
|
"react.file": fileName,
|
|
48
47
|
"react.projectDir": projectDir,
|
|
@@ -50,3 +49,7 @@ export function loadComponentFromSource(source, filePath, projectDir, adapter, o
|
|
|
50
49
|
"react.sourceLength": source.length,
|
|
51
50
|
});
|
|
52
51
|
}
|
|
52
|
+
export async function loadComponentFromSource(source, filePath, projectDir, adapter, options) {
|
|
53
|
+
const mod = await loadModuleFromSource(source, filePath, projectDir, adapter, options);
|
|
54
|
+
return extractComponent(mod, filePath);
|
|
55
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module modules/react-loader
|
|
5
5
|
*/
|
|
6
|
-
export { loadComponentFromSource } from "./component-loader.js";
|
|
6
|
+
export { loadComponentFromSource, loadModuleFromSource } from "./component-loader.js";
|
|
7
7
|
export { loadComponentsUnified } from "./unified-loader.js";
|
|
8
8
|
export { clearSSRModuleCache, clearSSRModuleCacheForProject } from "./ssr-module-loader/index.js";
|
|
9
9
|
export { getGlobalTmpDir, getProjectTmpDir, resetGlobalTmpDir } from "./temp-directory.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/react-loader/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/react-loader/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAElG,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC3F,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9E,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module modules/react-loader
|
|
5
5
|
*/
|
|
6
|
-
export { loadComponentFromSource } from "./component-loader.js";
|
|
6
|
+
export { loadComponentFromSource, loadModuleFromSource } from "./component-loader.js";
|
|
7
7
|
export { loadComponentsUnified } from "./unified-loader.js";
|
|
8
8
|
export { clearSSRModuleCache, clearSSRModuleCacheForProject } from "./ssr-module-loader/index.js";
|
|
9
9
|
export { getGlobalTmpDir, getProjectTmpDir, resetGlobalTmpDir } from "./temp-directory.js";
|
|
@@ -23,6 +23,7 @@ export declare class SSRModuleLoader {
|
|
|
23
23
|
private createTransformCapacityError;
|
|
24
24
|
private withTransformCapacity;
|
|
25
25
|
private importModuleFromCacheEntry;
|
|
26
|
+
loadRawModule(filePath: string, source: string): Promise<Record<string, unknown>>;
|
|
26
27
|
loadModule(filePath: string, source: string): Promise<React.ComponentType<Record<string, unknown>>>;
|
|
27
28
|
private transformCrossProjectImport;
|
|
28
29
|
private transformWithDependencies;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../../src/src/modules/react-loader/ssr-module-loader/loader.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAiCpC,OAAO,KAAK,EAAoB,sBAAsB,EAAE,MAAM,YAAY,CAAC;AA2B3E;;;;;GAKG;AACH,qBAAa,eAAe;IAKd,OAAO,CAAC,OAAO;IAJ3B,OAAO,CAAC,KAAK,CAAkB;IAC/B,OAAO,CAAC,cAAc,CAA2B;IACjD,OAAO,CAAC,YAAY,CAAyB;gBAEzB,OAAO,EAAE,sBAAsB;IAWnD,OAAO,CAAC,mBAAmB;IAY3B,OAAO,CAAC,4BAA4B;YAetB,qBAAqB;YAuCrB,0BAA0B;IAwHxC,UAAU,
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../../src/src/modules/react-loader/ssr-module-loader/loader.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAiCpC,OAAO,KAAK,EAAoB,sBAAsB,EAAE,MAAM,YAAY,CAAC;AA2B3E;;;;;GAKG;AACH,qBAAa,eAAe;IAKd,OAAO,CAAC,OAAO;IAJ3B,OAAO,CAAC,KAAK,CAAkB;IAC/B,OAAO,CAAC,cAAc,CAA2B;IACjD,OAAO,CAAC,YAAY,CAAyB;gBAEzB,OAAO,EAAE,sBAAsB;IAWnD,OAAO,CAAC,mBAAmB;IAY3B,OAAO,CAAC,4BAA4B;YAetB,qBAAqB;YAuCrB,0BAA0B;IAwHxC,aAAa,CACX,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IA+C7B,UAAU,CACd,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;YAK1C,2BAA2B;IAYzC,OAAO,CAAC,yBAAyB;YAiBnB,2BAA2B;CA+V1C"}
|
|
@@ -183,7 +183,7 @@ export class SSRModuleLoader {
|
|
|
183
183
|
throw importError;
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
|
-
|
|
186
|
+
loadRawModule(filePath, source) {
|
|
187
187
|
const fileName = filePath.split("/").pop() || filePath;
|
|
188
188
|
return withSpan(SpanNames.SSR_LOAD_MODULE, async () => {
|
|
189
189
|
const circuitKey = this.cache.getCacheKey(filePath);
|
|
@@ -205,7 +205,7 @@ export class SSRModuleLoader {
|
|
|
205
205
|
}
|
|
206
206
|
const mod = await this.importModuleFromCacheEntry(filePath, fileName, cacheEntry);
|
|
207
207
|
this.circuitBreaker.recordSuccess(circuitKey);
|
|
208
|
-
return
|
|
208
|
+
return mod;
|
|
209
209
|
}
|
|
210
210
|
catch (error) {
|
|
211
211
|
this.circuitBreaker.recordFailure(circuitKey);
|
|
@@ -217,6 +217,10 @@ export class SSRModuleLoader {
|
|
|
217
217
|
"ssr.source_length": source.length,
|
|
218
218
|
});
|
|
219
219
|
}
|
|
220
|
+
async loadModule(filePath, source) {
|
|
221
|
+
const mod = await this.loadRawModule(filePath, source);
|
|
222
|
+
return extractComponent(mod, filePath);
|
|
223
|
+
}
|
|
220
224
|
async transformCrossProjectImport(crossProjectImport) {
|
|
221
225
|
return transformCrossProjectImportFlow({
|
|
222
226
|
crossProjectImport,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-server.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/server/module-server.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;AAIlD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"module-server.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/server/module-server.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;AAIlD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAqBtE;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAsDrD,CAAC;AASF,MAAM,WAAW,mBAAmB;IAClC,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,6BAA6B;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,sBAAsB;IACtB,OAAO,EAAE,cAAc,CAAC;IACxB,uBAAuB;IACvB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sFAAsF;IACtF,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,sDAAsD;AACtD,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAqTzG;AAmLD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,GAAG,OAAO,CAG7D"}
|
|
@@ -14,7 +14,7 @@ import { injectNodePositions } from "../../transforms/plugins/babel-node-positio
|
|
|
14
14
|
import { parseProjectDomain } from "../../server/utils/domain-parser.js";
|
|
15
15
|
import { applySSRImportRewrites } from "./ssr-import-rewriter.js";
|
|
16
16
|
import { addHMRTimestamps } from "../../transforms/esm/import-rewriter.js";
|
|
17
|
-
import {
|
|
17
|
+
import { FRAMEWORK_ROOT, resolveFrameworkSourcePath, } from "../../platform/compat/framework-source-resolver.js";
|
|
18
18
|
const logger = serverLogger.component("module-server");
|
|
19
19
|
/**
|
|
20
20
|
* Embedded polyfills for compiled Deno binaries.
|
|
@@ -329,9 +329,6 @@ export function serveModule(req, options) {
|
|
|
329
329
|
}
|
|
330
330
|
}, { "modules.path": url.pathname, "modules.projectSlug": options.projectSlug || "unknown" });
|
|
331
331
|
}
|
|
332
|
-
const FRAMEWORK_ROOT = getFrameworkRootFromMeta(globalThis[Symbol.for("import-meta-ponyfill-esmodule")](import.meta).url);
|
|
333
|
-
// Embedded source directory for compiled binaries (created by prepare-framework-sources.ts)
|
|
334
|
-
const EMBEDDED_SRC_DIR = join(FRAMEWORK_ROOT, "dist", "framework-src");
|
|
335
332
|
async function findSourceFile(secureFs, projectDir, basePath) {
|
|
336
333
|
// Extensions including .src for compiled binary embedded sources
|
|
337
334
|
const extensions = [
|
|
@@ -358,13 +355,6 @@ async function findSourceFile(secureFs, projectDir, basePath) {
|
|
|
358
355
|
if (basePathWithoutExt.startsWith("_vf_modules/")) {
|
|
359
356
|
basePathWithoutExt = basePathWithoutExt.slice("_vf_modules/".length);
|
|
360
357
|
}
|
|
361
|
-
const frameworkLookups = [
|
|
362
|
-
["_veryfront/", join(FRAMEWORK_ROOT, "src"), "_veryfront", true],
|
|
363
|
-
// Embedded sources are a fallback for compiled binaries when src/ is unavailable.
|
|
364
|
-
["_veryfront/", EMBEDDED_SRC_DIR, "_veryfront-embedded", true],
|
|
365
|
-
// Fallback to projectDir for local dev/proxy setups where FRAMEWORK_ROOT may differ.
|
|
366
|
-
["_veryfront/", join(projectDir, "src"), "_veryfront-project", true],
|
|
367
|
-
];
|
|
368
358
|
const isFrameworkPath = basePathWithoutExt.startsWith("_veryfront/");
|
|
369
359
|
// Check embedded polyfills first (no filesystem access needed).
|
|
370
360
|
// These cover both compiled-binary polyfills (node:async_hooks etc.)
|
|
@@ -384,42 +374,18 @@ async function findSourceFile(secureFs, projectDir, basePath) {
|
|
|
384
374
|
embeddedContent,
|
|
385
375
|
};
|
|
386
376
|
}
|
|
387
|
-
async function resolveFrameworkFile(lookups) {
|
|
388
|
-
// Look for framework files using native filesystem (not secureFs which goes to API)
|
|
389
|
-
const platformFs = createFileSystem();
|
|
390
|
-
for (const [prefix, frameworkDir, label, stripPrefix] of lookups) {
|
|
391
|
-
if (!basePathWithoutExt.startsWith(prefix))
|
|
392
|
-
continue;
|
|
393
|
-
const pathWithinFramework = stripPrefix
|
|
394
|
-
? basePathWithoutExt.slice(prefix.length)
|
|
395
|
-
: basePathWithoutExt;
|
|
396
|
-
// Try direct file match first, then index file fallback
|
|
397
|
-
const candidates = [pathWithinFramework, `${pathWithinFramework}/index`];
|
|
398
|
-
for (const candidate of candidates) {
|
|
399
|
-
for (const ext of extensions) {
|
|
400
|
-
const frameworkPath = join(frameworkDir, candidate + ext);
|
|
401
|
-
try {
|
|
402
|
-
const stat = await platformFs.stat(frameworkPath);
|
|
403
|
-
if (stat.isFile) {
|
|
404
|
-
logger.debug(`Found framework ${label} file`, {
|
|
405
|
-
basePath: basePathWithoutExt,
|
|
406
|
-
resolvedPath: frameworkPath,
|
|
407
|
-
});
|
|
408
|
-
return { path: frameworkPath, isFrameworkFile: true };
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
catch (_) {
|
|
412
|
-
/* expected: file may not exist at this extension */
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
return null;
|
|
418
|
-
}
|
|
419
377
|
if (isFrameworkPath) {
|
|
420
|
-
const frameworkResult = await
|
|
378
|
+
const frameworkResult = await resolveFrameworkSourcePath(basePathWithoutExt.slice("_veryfront/".length), {
|
|
379
|
+
extraLookupDirs: [join(projectDir, "src")],
|
|
380
|
+
extensions,
|
|
381
|
+
});
|
|
421
382
|
if (frameworkResult) {
|
|
422
|
-
|
|
383
|
+
logger.debug("Found framework source file", {
|
|
384
|
+
basePath: basePathWithoutExt,
|
|
385
|
+
resolvedPath: frameworkResult.path,
|
|
386
|
+
lookupDir: frameworkResult.lookupDir,
|
|
387
|
+
});
|
|
388
|
+
return { path: frameworkResult.path, isFrameworkFile: true };
|
|
423
389
|
}
|
|
424
390
|
// Framework path not found locally - log warning and fall back to project lookups
|
|
425
391
|
logger.warn("Framework file not found locally", {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { FileInfo } from "../adapters/base.js";
|
|
2
|
+
export declare const FRAMEWORK_ROOT: string;
|
|
3
|
+
export declare const FRAMEWORK_EMBEDDED_SRC_DIR: string;
|
|
4
|
+
export declare const DEFAULT_FRAMEWORK_SOURCE_EXTENSIONS: readonly [".tsx.src", ".ts.src", ".jsx.src", ".js.src", ".mdx.src", ".md.src", ".tsx", ".ts", ".jsx", ".js", ".mdx", ".md"];
|
|
5
|
+
export interface FrameworkSourceFileSystem {
|
|
6
|
+
stat(path: string): Promise<FileInfo>;
|
|
7
|
+
}
|
|
8
|
+
export interface FrameworkSourceLookupResult {
|
|
9
|
+
path: string;
|
|
10
|
+
lookupDir: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ResolveFrameworkSourcePathOptions {
|
|
13
|
+
fileSystem?: FrameworkSourceFileSystem;
|
|
14
|
+
extraLookupDirs?: string[];
|
|
15
|
+
extensions?: readonly string[];
|
|
16
|
+
includeIndexFallback?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function getFrameworkSourceLookupDirs(extraLookupDirs?: string[]): string[];
|
|
19
|
+
export declare function resolveFrameworkSourcePath(relativePathWithoutExt: string, options?: ResolveFrameworkSourcePathOptions): Promise<FrameworkSourceLookupResult | null>;
|
|
20
|
+
//# sourceMappingURL=framework-source-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework-source-resolver.d.ts","sourceRoot":"","sources":["../../../../src/src/platform/compat/framework-source-resolver.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAIpD,eAAO,MAAM,cAAc,QAA4C,CAAC;AACxE,eAAO,MAAM,0BAA0B,QAAgD,CAAC;AAExF,eAAO,MAAM,mCAAmC,6HAatC,CAAC;AAEX,MAAM,WAAW,yBAAyB;IACxC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iCAAiC;IAChD,UAAU,CAAC,EAAE,yBAAyB,CAAC;IACvC,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,wBAAgB,4BAA4B,CAAC,eAAe,GAAE,MAAM,EAAO,GAAG,MAAM,EAAE,CAarF;AAED,wBAAsB,0BAA0B,CAC9C,sBAAsB,EAAE,MAAM,EAC9B,OAAO,GAAE,iCAAsC,GAC9C,OAAO,CAAC,2BAA2B,GAAG,IAAI,CAAC,CA+B7C"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { join } from "./path/index.js";
|
|
2
|
+
import { createFileSystem } from "./fs.js";
|
|
3
|
+
import { getFrameworkRootFromMeta } from "./vfs-paths.js";
|
|
4
|
+
export const FRAMEWORK_ROOT = getFrameworkRootFromMeta(globalThis[Symbol.for("import-meta-ponyfill-esmodule")](import.meta).url);
|
|
5
|
+
export const FRAMEWORK_EMBEDDED_SRC_DIR = join(FRAMEWORK_ROOT, "dist", "framework-src");
|
|
6
|
+
export const DEFAULT_FRAMEWORK_SOURCE_EXTENSIONS = [
|
|
7
|
+
".tsx.src",
|
|
8
|
+
".ts.src",
|
|
9
|
+
".jsx.src",
|
|
10
|
+
".js.src",
|
|
11
|
+
".mdx.src",
|
|
12
|
+
".md.src",
|
|
13
|
+
".tsx",
|
|
14
|
+
".ts",
|
|
15
|
+
".jsx",
|
|
16
|
+
".js",
|
|
17
|
+
".mdx",
|
|
18
|
+
".md",
|
|
19
|
+
];
|
|
20
|
+
export function getFrameworkSourceLookupDirs(extraLookupDirs = []) {
|
|
21
|
+
const seen = new Set();
|
|
22
|
+
const ordered = [
|
|
23
|
+
join(FRAMEWORK_ROOT, "src"),
|
|
24
|
+
FRAMEWORK_EMBEDDED_SRC_DIR,
|
|
25
|
+
...extraLookupDirs,
|
|
26
|
+
];
|
|
27
|
+
return ordered.filter((dir) => {
|
|
28
|
+
if (seen.has(dir))
|
|
29
|
+
return false;
|
|
30
|
+
seen.add(dir);
|
|
31
|
+
return true;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export async function resolveFrameworkSourcePath(relativePathWithoutExt, options = {}) {
|
|
35
|
+
const fs = options.fileSystem ?? createFileSystem();
|
|
36
|
+
const lookupDirs = getFrameworkSourceLookupDirs(options.extraLookupDirs);
|
|
37
|
+
const extensions = options.extensions ?? DEFAULT_FRAMEWORK_SOURCE_EXTENSIONS;
|
|
38
|
+
const candidates = [relativePathWithoutExt];
|
|
39
|
+
if (options.includeIndexFallback !== false) {
|
|
40
|
+
candidates.push(`${relativePathWithoutExt}/index`);
|
|
41
|
+
}
|
|
42
|
+
for (const lookupDir of lookupDirs) {
|
|
43
|
+
for (const candidate of candidates) {
|
|
44
|
+
for (const ext of extensions) {
|
|
45
|
+
const candidatePath = join(lookupDir, candidate + ext);
|
|
46
|
+
try {
|
|
47
|
+
const stat = await fs.stat(candidatePath);
|
|
48
|
+
if (stat.isFile) {
|
|
49
|
+
return {
|
|
50
|
+
path: candidatePath,
|
|
51
|
+
lookupDir,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
/* expected: candidate may not exist */
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
@@ -5,6 +5,7 @@ export interface ReactDOMServer {
|
|
|
5
5
|
renderToReadableStream?: typeof import("react-dom/server").renderToReadableStream;
|
|
6
6
|
}
|
|
7
7
|
export declare function resetReactCache(): void;
|
|
8
|
+
export declare function __injectReactDOMServerForTests(server: ReactDOMServer | null): void;
|
|
8
9
|
export declare function getProjectReact(): Promise<typeof import("react")>;
|
|
9
10
|
export declare function getReactDOMServer(): Promise<ReactDOMServer>;
|
|
10
11
|
//# sourceMappingURL=server-loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-loader.d.ts","sourceRoot":"","sources":["../../../../../src/src/react/compat/ssr-adapter/server-loader.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,cAAc;IAC7B,cAAc,EAAE,cAAc,kBAAkB,EAAE,cAAc,CAAC;IACjE,oBAAoB,EAAE,cAAc,kBAAkB,EAAE,oBAAoB,CAAC;IAC7E,sBAAsB,CAAC,EAAE,cAAc,kBAAkB,EAAE,sBAAsB,CAAC;IAClF,sBAAsB,CAAC,EAAE,cAAc,kBAAkB,EAAE,sBAAsB,CAAC;CACnF;AAQD,wBAAgB,eAAe,IAAI,IAAI,CAGtC;AASD,wBAAgB,eAAe,IAAI,OAAO,CAAC,cAAc,OAAO,CAAC,CAAC,CAuBjE;AAED,wBAAgB,iBAAiB,IAAI,OAAO,CAAC,cAAc,CAAC,CAiC3D"}
|
|
1
|
+
{"version":3,"file":"server-loader.d.ts","sourceRoot":"","sources":["../../../../../src/src/react/compat/ssr-adapter/server-loader.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,cAAc;IAC7B,cAAc,EAAE,cAAc,kBAAkB,EAAE,cAAc,CAAC;IACjE,oBAAoB,EAAE,cAAc,kBAAkB,EAAE,oBAAoB,CAAC;IAC7E,sBAAsB,CAAC,EAAE,cAAc,kBAAkB,EAAE,sBAAsB,CAAC;IAClF,sBAAsB,CAAC,EAAE,cAAc,kBAAkB,EAAE,sBAAsB,CAAC;CACnF;AAQD,wBAAgB,eAAe,IAAI,IAAI,CAGtC;AAED,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,GAAG,IAAI,CAElF;AASD,wBAAgB,eAAe,IAAI,OAAO,CAAC,cAAc,OAAO,CAAC,CAAC,CAuBjE;AAED,wBAAgB,iBAAiB,IAAI,OAAO,CAAC,cAAc,CAAC,CAiC3D"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getReactVersionInfo } from "../version-detector/index.js";
|
|
2
|
-
import { INITIALIZATION_ERROR } from "../../../errors/
|
|
2
|
+
import { INITIALIZATION_ERROR } from "../../../errors/error-registry.js";
|
|
3
3
|
import { Singleflight } from "../../../utils/singleflight.js";
|
|
4
4
|
import { cacheModuleToLocal } from "../../../transforms/esm/http-cache.js";
|
|
5
5
|
import { getReactUrls } from "../../../transforms/esm/package-registry.js";
|
|
@@ -14,6 +14,9 @@ export function resetReactCache() {
|
|
|
14
14
|
projectReactCache = null;
|
|
15
15
|
reactDOMServerCache = null;
|
|
16
16
|
}
|
|
17
|
+
export function __injectReactDOMServerForTests(server) {
|
|
18
|
+
reactDOMServerCache = server;
|
|
19
|
+
}
|
|
17
20
|
async function loadFromCachedHttpModule(url, label) {
|
|
18
21
|
const cacheDir = getHttpBundleCacheDir();
|
|
19
22
|
const cachedPath = await cacheModuleToLocal(url, cacheDir);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { SSROptions, SSRResult } from "./types.js";
|
|
3
|
+
export declare function __setSSRStreamTimeoutForTests(timeoutMs: number): void;
|
|
4
|
+
export declare function __resetSSRStreamRendererForTests(): void;
|
|
3
5
|
export declare function renderToStreamAdapter(element: React.ReactNode, options?: SSROptions): Promise<SSRResult>;
|
|
4
6
|
//# sourceMappingURL=stream-renderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-renderer.d.ts","sourceRoot":"","sources":["../../../../../src/src/react/compat/ssr-adapter/stream-renderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"stream-renderer.d.ts","sourceRoot":"","sources":["../../../../../src/src/react/compat/ssr-adapter/stream-renderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAexD,wBAAgB,6BAA6B,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAErE;AAED,wBAAgB,gCAAgC,IAAI,IAAI,CAEvD;AAiMD,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,KAAK,CAAC,SAAS,EACxB,OAAO,GAAE,UAAe,GACvB,OAAO,CAAC,SAAS,CAAC,CAwBpB"}
|
|
@@ -6,9 +6,16 @@ import { renderToStringAdapter } from "./string-renderer.js";
|
|
|
6
6
|
import { createError, toError } from "../../../errors/veryfront-error.js";
|
|
7
7
|
import { isDebugEnvEnabled } from "../../../config/env.js";
|
|
8
8
|
import { SSR_TIMEOUT_MS } from "../../../config/defaults.js";
|
|
9
|
+
let ssrTimeoutMs = SSR_TIMEOUT_MS;
|
|
9
10
|
function isDebugMode() {
|
|
10
11
|
return Boolean(dntShim.dntGlobalThis.__VERYFRONT_DEBUG__ || isDebugEnvEnabled());
|
|
11
12
|
}
|
|
13
|
+
export function __setSSRStreamTimeoutForTests(timeoutMs) {
|
|
14
|
+
ssrTimeoutMs = timeoutMs;
|
|
15
|
+
}
|
|
16
|
+
export function __resetSSRStreamRendererForTests() {
|
|
17
|
+
ssrTimeoutMs = SSR_TIMEOUT_MS;
|
|
18
|
+
}
|
|
12
19
|
async function renderToReadableStreamImpl(element, options, server) {
|
|
13
20
|
if (!server.renderToReadableStream) {
|
|
14
21
|
throw toError(createError({
|
|
@@ -21,9 +28,9 @@ async function renderToReadableStreamImpl(element, options, server) {
|
|
|
21
28
|
const start = performance.now();
|
|
22
29
|
const controller = new AbortController();
|
|
23
30
|
const timeoutId = dntShim.setTimeout(() => {
|
|
24
|
-
logger.error("SSR_TIMEOUT aborting React render", { timeoutMs:
|
|
25
|
-
controller.abort(new Error(`SSR timeout: React render exceeded ${
|
|
26
|
-
},
|
|
31
|
+
logger.error("SSR_TIMEOUT aborting React render", { timeoutMs: ssrTimeoutMs });
|
|
32
|
+
controller.abort(new Error(`SSR timeout: React render exceeded ${ssrTimeoutMs}ms`));
|
|
33
|
+
}, ssrTimeoutMs);
|
|
27
34
|
try {
|
|
28
35
|
if (debug)
|
|
29
36
|
logger.info("SSR renderToReadableStream started");
|
|
@@ -61,7 +68,7 @@ async function renderToReadableStreamImpl(element, options, server) {
|
|
|
61
68
|
if (isAbort) {
|
|
62
69
|
logger.error("SSR_TIMEOUT React render was aborted", {
|
|
63
70
|
durationMs,
|
|
64
|
-
timeoutMs:
|
|
71
|
+
timeoutMs: ssrTimeoutMs,
|
|
65
72
|
});
|
|
66
73
|
throw error;
|
|
67
74
|
}
|
|
@@ -98,7 +105,7 @@ function renderToPipeableStreamImpl(element, options, server) {
|
|
|
98
105
|
if (settled)
|
|
99
106
|
return;
|
|
100
107
|
settled = true;
|
|
101
|
-
logger.error("SSR_TIMEOUT aborting pipeable React render", { timeoutMs:
|
|
108
|
+
logger.error("SSR_TIMEOUT aborting pipeable React render", { timeoutMs: ssrTimeoutMs });
|
|
102
109
|
if (abortFn) {
|
|
103
110
|
try {
|
|
104
111
|
abortFn();
|
|
@@ -107,8 +114,8 @@ function renderToPipeableStreamImpl(element, options, server) {
|
|
|
107
114
|
logger.warn("SSR_ABORT error calling abort", e);
|
|
108
115
|
}
|
|
109
116
|
}
|
|
110
|
-
reject(new Error(`SSR timeout: React render exceeded ${
|
|
111
|
-
},
|
|
117
|
+
reject(new Error(`SSR timeout: React render exceeded ${ssrTimeoutMs}ms - likely a hanging data fetch`));
|
|
118
|
+
}, ssrTimeoutMs);
|
|
112
119
|
try {
|
|
113
120
|
const { pipe, abort } = renderToPipeableStream(element, {
|
|
114
121
|
bootstrapScripts: options.bootstrapScripts,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module ai/react/components/chat/contexts/chat-context
|
|
7
7
|
*/
|
|
8
8
|
import * as React from "react";
|
|
9
|
-
import { COMPONENT_ERROR } from "../../../../../errors/
|
|
9
|
+
import { COMPONENT_ERROR } from "../../../../../errors/error-registry.js";
|
|
10
10
|
const ChatContext = React.createContext(null);
|
|
11
11
|
export function useChatContext() {
|
|
12
12
|
const context = React.useContext(ChatContext);
|