veryfront 0.1.743 → 0.1.745
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/cache/hash.d.ts +33 -0
- package/esm/src/cache/hash.d.ts.map +1 -0
- package/esm/src/cache/hash.js +59 -0
- 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 +3 -1
- package/esm/src/integrations/schema.d.ts +4 -4
- package/esm/src/modules/server/module-batch-handler.d.ts.map +1 -1
- package/esm/src/modules/server/module-batch-handler.js +68 -5
- package/esm/src/modules/server/module-server.d.ts.map +1 -1
- package/esm/src/modules/server/module-server.js +60 -4
- package/esm/src/modules/server/ssr-import-rewriter.d.ts +14 -2
- package/esm/src/modules/server/ssr-import-rewriter.d.ts.map +1 -1
- package/esm/src/modules/server/ssr-import-rewriter.js +134 -12
- package/esm/src/security/client/html-sanitizer.d.ts +1 -0
- package/esm/src/security/client/html-sanitizer.d.ts.map +1 -1
- package/esm/src/security/client/html-sanitizer.js +2 -2
- package/esm/src/server/services/rsc/endpoints/rsc-bundles.generated.js +1 -1
- package/esm/src/skill/executor.d.ts.map +1 -1
- package/esm/src/skill/executor.js +3 -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
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**************************
|
|
2
|
+
* Standardized Cache Hashing Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides consistent hashing for cache keys across the codebase.
|
|
5
|
+
* All cache keys should use these utilities to ensure:
|
|
6
|
+
* - Consistent format with type prefixes
|
|
7
|
+
* - Collision resistance between different cache types
|
|
8
|
+
* - Easy debugging and key parsing
|
|
9
|
+
*
|
|
10
|
+
* Key format: `{type}:{hash}` or `{type}:{version}:{hash}`
|
|
11
|
+
*
|
|
12
|
+
* @module cache/hash
|
|
13
|
+
**************************/
|
|
14
|
+
import { computeHash } from "../utils/hash-utils.js";
|
|
15
|
+
type CacheKeyType = "http" | "mod" | "esm" | "render" | "mdx" | "css" | "file" | "config";
|
|
16
|
+
export declare function fastHash(input: string): number;
|
|
17
|
+
export declare function hashToString(hash: number): string;
|
|
18
|
+
export declare function hashString(input: string): string;
|
|
19
|
+
export declare function getCacheKey(type: CacheKeyType, input: string): string;
|
|
20
|
+
export declare function getVersionedCacheKey(type: CacheKeyType, version: number | string, input: string): string;
|
|
21
|
+
export declare function getCompoundCacheKey(type: CacheKeyType, components: string[]): string;
|
|
22
|
+
export declare function parseCacheKey(key: string): {
|
|
23
|
+
type: string;
|
|
24
|
+
hash: string;
|
|
25
|
+
version?: string;
|
|
26
|
+
} | null;
|
|
27
|
+
export declare const sha256Hash: typeof computeHash;
|
|
28
|
+
export declare function sha256Short(input: string): Promise<string>;
|
|
29
|
+
export declare function getHttpBundleFilename(normalizedUrl: string): string;
|
|
30
|
+
export declare function parseHttpBundleFilename(filename: string): string | null;
|
|
31
|
+
export declare function isCacheKey(value: string): boolean;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../../src/src/cache/hash.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;4BAY4B;AAE5B,OAAO,EAAE,WAAW,EAAc,MAAM,wBAAwB,CAAC;AAEjE,KAAK,YAAY,GACb,MAAM,GACN,KAAK,GACL,KAAK,GACL,QAAQ,GACR,KAAK,GACL,KAAK,GACL,MAAM,GACN,QAAQ,CAAC;AAEb,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQ9C;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAErE;AAED,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,KAAK,EAAE,MAAM,GACZ,MAAM,CAER;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,CAEpF;AAED,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,GACV;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAWzD;AAED,eAAO,MAAM,UAAU,oBAAc,CAAC;AAEtC,wBAAsB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEhE;AAED,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAEvE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEjD"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**************************
|
|
2
|
+
* Standardized Cache Hashing Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides consistent hashing for cache keys across the codebase.
|
|
5
|
+
* All cache keys should use these utilities to ensure:
|
|
6
|
+
* - Consistent format with type prefixes
|
|
7
|
+
* - Collision resistance between different cache types
|
|
8
|
+
* - Easy debugging and key parsing
|
|
9
|
+
*
|
|
10
|
+
* Key format: `{type}:{hash}` or `{type}:{version}:{hash}`
|
|
11
|
+
*
|
|
12
|
+
* @module cache/hash
|
|
13
|
+
**************************/
|
|
14
|
+
import { computeHash, simpleHash } from "../utils/hash-utils.js";
|
|
15
|
+
export function fastHash(input) {
|
|
16
|
+
let hash = 5381;
|
|
17
|
+
for (let i = 0; i < input.length; i++) {
|
|
18
|
+
hash = ((hash << 5) + hash) ^ input.charCodeAt(i);
|
|
19
|
+
}
|
|
20
|
+
return hash >>> 0;
|
|
21
|
+
}
|
|
22
|
+
export function hashToString(hash) {
|
|
23
|
+
return hash.toString(36);
|
|
24
|
+
}
|
|
25
|
+
export function hashString(input) {
|
|
26
|
+
return hashToString(fastHash(input));
|
|
27
|
+
}
|
|
28
|
+
export function getCacheKey(type, input) {
|
|
29
|
+
return `${type}:${hashString(input)}`;
|
|
30
|
+
}
|
|
31
|
+
export function getVersionedCacheKey(type, version, input) {
|
|
32
|
+
return `${type}:v${version}:${hashString(input)}`;
|
|
33
|
+
}
|
|
34
|
+
export function getCompoundCacheKey(type, components) {
|
|
35
|
+
return getCacheKey(type, components.join(":"));
|
|
36
|
+
}
|
|
37
|
+
export function parseCacheKey(key) {
|
|
38
|
+
const [type, ...rest] = key.split(":");
|
|
39
|
+
if (!type || rest.length === 0)
|
|
40
|
+
return null;
|
|
41
|
+
const [maybeVersion, ...hashParts] = rest;
|
|
42
|
+
if (maybeVersion?.startsWith("v") && /^v\d+$/.test(maybeVersion)) {
|
|
43
|
+
return { type, version: maybeVersion.slice(1), hash: hashParts.join(":") };
|
|
44
|
+
}
|
|
45
|
+
return { type, hash: rest.join(":") };
|
|
46
|
+
}
|
|
47
|
+
export const sha256Hash = computeHash;
|
|
48
|
+
export async function sha256Short(input) {
|
|
49
|
+
return (await sha256Hash(input)).slice(0, 8);
|
|
50
|
+
}
|
|
51
|
+
export function getHttpBundleFilename(normalizedUrl) {
|
|
52
|
+
return `http-${simpleHash(normalizedUrl)}.mjs`;
|
|
53
|
+
}
|
|
54
|
+
export function parseHttpBundleFilename(filename) {
|
|
55
|
+
return filename.match(/^http-(\d+)\.mjs$/)?.[1] ?? null;
|
|
56
|
+
}
|
|
57
|
+
export function isCacheKey(value) {
|
|
58
|
+
return /^[a-z]+:[a-z0-9]+/.test(value);
|
|
59
|
+
}
|
|
@@ -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;AAK3D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AA8BzD,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,EAC9B,gBAAgB,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GACtC,MAAM,CAgDR"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { resolveRelativePath } from "../../modules/react-loader/path-resolver.js";
|
|
2
2
|
import { getExtensionName } from "../../utils/path-utils.js";
|
|
3
3
|
import { determineClientModuleStrategy } from "../../rendering/rsc/client-module-strategy.js";
|
|
4
|
+
import { jsonForInlineScript } from "../../security/client/html-sanitizer.js";
|
|
4
5
|
function toProjectRelativePath(absolutePath, projectDir) {
|
|
5
6
|
if (!absolutePath)
|
|
6
7
|
return "";
|
|
@@ -58,5 +59,6 @@ export function generateHydrationData(slug, params, props, options, serializeOpt
|
|
|
58
59
|
headings: options.headings,
|
|
59
60
|
studioEmbed: options.studioEmbed,
|
|
60
61
|
};
|
|
61
|
-
|
|
62
|
+
const pretty = serializeOptions?.pretty ?? true;
|
|
63
|
+
return jsonForInlineScript(data, pretty ? 2 : undefined);
|
|
62
64
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { InferSchema } from "../extensions/schema/index.js";
|
|
2
|
-
export declare const getIntegrationNameSchema: () => import("../internal-agents/schema.js").Schema<"github" | "anthropic" | "
|
|
2
|
+
export declare const getIntegrationNameSchema: () => import("../internal-agents/schema.js").Schema<"github" | "anthropic" | "zoom" | "twitter" | "linear" | "gmail" | "slack" | "calendar" | "jira" | "notion" | "servicenow" | "confluence" | "gitlab" | "outlook" | "teams" | "figma" | "sap" | "sheets" | "airtable" | "supabase" | "neon" | "sharepoint" | "stripe" | "salesforce" | "onedrive" | "bitbucket" | "sentry" | "posthog" | "persona" | "zendesk" | "asana" | "harvest" | "hubspot" | "monday" | "trello" | "box" | "shopify" | "clickup" | "intercom" | "pipedrive" | "mailchimp" | "webex" | "freshdesk" | "quickbooks" | "xero" | "drive" | "docs-google" | "snowflake" | "mixpanel" | "twilio" | "aws">;
|
|
3
3
|
/** Zod schema for integration name. */
|
|
4
|
-
export declare const IntegrationNameSchema: import("../internal-agents/schema.js").Schema<"github" | "anthropic" | "
|
|
4
|
+
export declare const IntegrationNameSchema: import("../internal-agents/schema.js").Schema<"github" | "anthropic" | "zoom" | "twitter" | "linear" | "gmail" | "slack" | "calendar" | "jira" | "notion" | "servicenow" | "confluence" | "gitlab" | "outlook" | "teams" | "figma" | "sap" | "sheets" | "airtable" | "supabase" | "neon" | "sharepoint" | "stripe" | "salesforce" | "onedrive" | "bitbucket" | "sentry" | "posthog" | "persona" | "zendesk" | "asana" | "harvest" | "hubspot" | "monday" | "trello" | "box" | "shopify" | "clickup" | "intercom" | "pipedrive" | "mailchimp" | "webex" | "freshdesk" | "quickbooks" | "xero" | "drive" | "docs-google" | "snowflake" | "mixpanel" | "twilio" | "aws">;
|
|
5
5
|
export declare const getEnvVarSchema: () => import("../internal-agents/schema.js").Schema<import("../extensions/schema/schema-validator.js").InferShape<{
|
|
6
6
|
name: import("../internal-agents/schema.js").Schema<string>;
|
|
7
7
|
description: import("../internal-agents/schema.js").Schema<string>;
|
|
@@ -426,7 +426,7 @@ export declare const IntegrationPromptSchema: import("../internal-agents/schema.
|
|
|
426
426
|
icon: import("../internal-agents/schema.js").Schema<string | undefined>;
|
|
427
427
|
}>>;
|
|
428
428
|
export declare const getIntegrationConfigSchema: () => import("../internal-agents/schema.js").Schema<import("../extensions/schema/schema-validator.js").InferShape<{
|
|
429
|
-
name: import("../internal-agents/schema.js").Schema<"github" | "anthropic" | "
|
|
429
|
+
name: import("../internal-agents/schema.js").Schema<"github" | "anthropic" | "zoom" | "twitter" | "linear" | "gmail" | "slack" | "calendar" | "jira" | "notion" | "servicenow" | "confluence" | "gitlab" | "outlook" | "teams" | "figma" | "sap" | "sheets" | "airtable" | "supabase" | "neon" | "sharepoint" | "stripe" | "salesforce" | "onedrive" | "bitbucket" | "sentry" | "posthog" | "persona" | "zendesk" | "asana" | "harvest" | "hubspot" | "monday" | "trello" | "box" | "shopify" | "clickup" | "intercom" | "pipedrive" | "mailchimp" | "webex" | "freshdesk" | "quickbooks" | "xero" | "drive" | "docs-google" | "snowflake" | "mixpanel" | "twilio" | "aws">;
|
|
430
430
|
displayName: import("../internal-agents/schema.js").Schema<string>;
|
|
431
431
|
icon: import("../internal-agents/schema.js").Schema<string | undefined>;
|
|
432
432
|
description: import("../internal-agents/schema.js").Schema<string>;
|
|
@@ -552,7 +552,7 @@ export declare const getIntegrationConfigSchema: () => import("../internal-agent
|
|
|
552
552
|
}>>;
|
|
553
553
|
/** Zod schema for integration config. */
|
|
554
554
|
export declare const IntegrationConfigSchema: import("../internal-agents/schema.js").Schema<import("../extensions/schema/schema-validator.js").InferShape<{
|
|
555
|
-
name: import("../internal-agents/schema.js").Schema<"github" | "anthropic" | "
|
|
555
|
+
name: import("../internal-agents/schema.js").Schema<"github" | "anthropic" | "zoom" | "twitter" | "linear" | "gmail" | "slack" | "calendar" | "jira" | "notion" | "servicenow" | "confluence" | "gitlab" | "outlook" | "teams" | "figma" | "sap" | "sheets" | "airtable" | "supabase" | "neon" | "sharepoint" | "stripe" | "salesforce" | "onedrive" | "bitbucket" | "sentry" | "posthog" | "persona" | "zendesk" | "asana" | "harvest" | "hubspot" | "monday" | "trello" | "box" | "shopify" | "clickup" | "intercom" | "pipedrive" | "mailchimp" | "webex" | "freshdesk" | "quickbooks" | "xero" | "drive" | "docs-google" | "snowflake" | "mixpanel" | "twilio" | "aws">;
|
|
556
556
|
displayName: import("../internal-agents/schema.js").Schema<string>;
|
|
557
557
|
icon: import("../internal-agents/schema.js").Schema<string | undefined>;
|
|
558
558
|
description: import("../internal-agents/schema.js").Schema<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-batch-handler.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/server/module-batch-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AASH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"module-batch-handler.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/server/module-batch-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AASH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AA2DtE,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,cAAc,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC,CA2K/F;AAkPD;;GAEG;AACH,wBAAgB,eAAe,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAY1D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAKrE"}
|
|
@@ -20,12 +20,13 @@ import { createSecureFs } from "../../security/index.js";
|
|
|
20
20
|
import { transformToESM } from "../../transforms/esm-transform.js";
|
|
21
21
|
import { createFileSystem } from "../../platform/compat/fs.js";
|
|
22
22
|
import { join } from "../../platform/compat/path/index.js";
|
|
23
|
-
import {
|
|
23
|
+
import { applySSRImportRewritesAsync, resolveSSRImportTargetModulePath, stripSSRModuleJsExtension, } from "./ssr-import-rewriter.js";
|
|
24
24
|
import { buildModuleTransformCacheKey } from "../../cache/keys.js";
|
|
25
25
|
import { withSpan } from "../../observability/tracing/otlp-setup.js";
|
|
26
26
|
import { getFrameworkRootFromMeta } from "../../platform/compat/vfs-paths.js";
|
|
27
27
|
import { LRUCache } from "../../utils/lru-wrapper.js";
|
|
28
28
|
import { registerLRUCache } from "../../cache/index.js";
|
|
29
|
+
import { sha256Short } from "../../cache/hash.js";
|
|
29
30
|
const logger = serverLogger.component("module-batch");
|
|
30
31
|
/** Slow request threshold in milliseconds */
|
|
31
32
|
const SLOW_REQUEST_THRESHOLD_MS = 500;
|
|
@@ -202,7 +203,7 @@ async function loadAndTransformModule(modulePath, projectDir, adapter, secureFs,
|
|
|
202
203
|
if (!stat.isFile)
|
|
203
204
|
continue;
|
|
204
205
|
const source = await secureFs.readFile(fullPath);
|
|
205
|
-
return transformModule(source, fullPath, projectDir, adapter, options);
|
|
206
|
+
return transformModule(source, fullPath, modulePath, projectDir, adapter, secureFs, options);
|
|
206
207
|
}
|
|
207
208
|
catch (_) {
|
|
208
209
|
/* expected: file may not exist at this extension */
|
|
@@ -224,7 +225,7 @@ async function loadAndTransformModule(modulePath, projectDir, adapter, secureFs,
|
|
|
224
225
|
if (!stat.isFile)
|
|
225
226
|
continue;
|
|
226
227
|
const source = await platformFs.readTextFile(frameworkPath);
|
|
227
|
-
return transformModule(source, frameworkPath, projectDir, adapter, options);
|
|
228
|
+
return transformModule(source, frameworkPath, modulePath, projectDir, adapter, secureFs, options);
|
|
228
229
|
}
|
|
229
230
|
catch (_) {
|
|
230
231
|
/* expected: framework file may not exist at this extension */
|
|
@@ -233,7 +234,7 @@ async function loadAndTransformModule(modulePath, projectDir, adapter, secureFs,
|
|
|
233
234
|
}
|
|
234
235
|
return null;
|
|
235
236
|
}
|
|
236
|
-
async function transformModule(source, sourceFile, projectDir, adapter, options) {
|
|
237
|
+
async function transformModule(source, sourceFile, modulePath, projectDir, adapter, secureFs, options) {
|
|
237
238
|
let code = await transformToESM(source, sourceFile, projectDir, adapter, {
|
|
238
239
|
projectId: options.projectId ?? projectDir,
|
|
239
240
|
dev: options.dev,
|
|
@@ -241,13 +242,75 @@ async function transformModule(source, sourceFile, projectDir, adapter, options)
|
|
|
241
242
|
reactVersion: options.reactVersion,
|
|
242
243
|
});
|
|
243
244
|
if (options.ssr) {
|
|
244
|
-
code =
|
|
245
|
+
code = await applySSRImportRewritesAsync(code, {
|
|
245
246
|
projectSlug: options.projectSlug,
|
|
246
247
|
branch: options.branch,
|
|
248
|
+
resolveCacheBuster: createBatchSSRTargetCacheBusterResolver({
|
|
249
|
+
projectDir,
|
|
250
|
+
secureFs,
|
|
251
|
+
currentModulePath: modulePath,
|
|
252
|
+
}),
|
|
247
253
|
});
|
|
248
254
|
}
|
|
249
255
|
return code;
|
|
250
256
|
}
|
|
257
|
+
async function readBatchTargetSource(projectDir, secureFs, modulePath) {
|
|
258
|
+
const basePath = stripSSRModuleJsExtension(modulePath);
|
|
259
|
+
for (const ext of EXTENSIONS) {
|
|
260
|
+
const fullPath = join(projectDir, basePath + ext);
|
|
261
|
+
try {
|
|
262
|
+
const stat = await secureFs.stat(fullPath);
|
|
263
|
+
if (!stat.isFile)
|
|
264
|
+
continue;
|
|
265
|
+
return {
|
|
266
|
+
path: fullPath,
|
|
267
|
+
source: await secureFs.readFile(fullPath),
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
catch (_) {
|
|
271
|
+
/* expected: file may not exist at this extension */
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
if (!basePath.startsWith("lib/"))
|
|
275
|
+
return null;
|
|
276
|
+
const frameworkLookupDirs = [EMBEDDED_SRC_DIR, join(FRAMEWORK_ROOT, "src")];
|
|
277
|
+
const platformFs = createFileSystem();
|
|
278
|
+
for (const lookupDir of frameworkLookupDirs) {
|
|
279
|
+
for (const ext of FRAMEWORK_EXTENSIONS) {
|
|
280
|
+
const frameworkPath = join(lookupDir, basePath + ext);
|
|
281
|
+
try {
|
|
282
|
+
const stat = await platformFs.stat(frameworkPath);
|
|
283
|
+
if (!stat.isFile)
|
|
284
|
+
continue;
|
|
285
|
+
return {
|
|
286
|
+
path: frameworkPath,
|
|
287
|
+
source: await platformFs.readTextFile(frameworkPath),
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
catch (_) {
|
|
291
|
+
/* expected: framework file may not exist at this extension */
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return null;
|
|
296
|
+
}
|
|
297
|
+
function createBatchSSRTargetCacheBusterResolver(options) {
|
|
298
|
+
const versions = new Map();
|
|
299
|
+
return (target) => {
|
|
300
|
+
const targetPath = resolveSSRImportTargetModulePath(target, options.currentModulePath);
|
|
301
|
+
let promise = versions.get(targetPath);
|
|
302
|
+
if (!promise) {
|
|
303
|
+
promise = (async () => {
|
|
304
|
+
const resolved = await readBatchTargetSource(options.projectDir, options.secureFs, targetPath);
|
|
305
|
+
if (!resolved)
|
|
306
|
+
return undefined;
|
|
307
|
+
return await sha256Short(`${resolved.path}\0${resolved.source}`);
|
|
308
|
+
})();
|
|
309
|
+
versions.set(targetPath, promise);
|
|
310
|
+
}
|
|
311
|
+
return promise;
|
|
312
|
+
};
|
|
313
|
+
}
|
|
251
314
|
/**
|
|
252
315
|
* Generate the batch bundle code
|
|
253
316
|
* Creates a module that exports all loaded modules by path
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-server.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/server/module-server.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAG5E,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;AAG5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AA6BtE;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAsDrD,CAAC;AAQF,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,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAkVzF;AAgTD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAGrD"}
|
|
@@ -11,11 +11,12 @@ import { getApiBaseUrlEnv } from "../../config/env.js";
|
|
|
11
11
|
import { injectContext, withSpan } from "../../observability/tracing/otlp-setup.js";
|
|
12
12
|
import { injectNodePositions } from "../../transforms/plugins/babel-node-positions.js";
|
|
13
13
|
import { parseProjectDomain } from "../../server/utils/domain-parser.js";
|
|
14
|
-
import {
|
|
14
|
+
import { applySSRImportRewritesAsync, resolveSSRImportTargetModulePath, stripSSRModuleJsExtension, } from "./ssr-import-rewriter.js";
|
|
15
15
|
import { addHMRTimestamps } from "../../transforms/esm/import-rewriter.js";
|
|
16
16
|
import { FRAMEWORK_ROOT, resolveFrameworkSourcePath, } from "../../platform/compat/framework-source-resolver.js";
|
|
17
17
|
import { getReactUrls, REACT_DEFAULT_VERSION } from "../../utils/constants/cdn.js";
|
|
18
18
|
import { readLimitedCrossProjectSource } from "./cross-project-source-limit.js";
|
|
19
|
+
import { sha256Short } from "../../cache/hash.js";
|
|
19
20
|
const logger = serverLogger.component("module-server");
|
|
20
21
|
/**
|
|
21
22
|
* Embedded polyfills for compiled Deno binaries.
|
|
@@ -153,9 +154,15 @@ export function serveModule(req, options) {
|
|
|
153
154
|
try {
|
|
154
155
|
let transformedCode = await transformToESM(snippetCode, `_snippets/${hash}.tsx`, projectDir, adapter, { projectId: effectiveProjectId, dev, ssr: isSSR, reactVersion });
|
|
155
156
|
if (isSSR) {
|
|
156
|
-
transformedCode =
|
|
157
|
+
transformedCode = await applySSRImportRewritesAsync(transformedCode, {
|
|
157
158
|
projectSlug: snippetProjectSlug,
|
|
158
159
|
branch: snippetBranch,
|
|
160
|
+
resolveCacheBuster: createSSRTargetCacheBusterResolver({
|
|
161
|
+
secureFs,
|
|
162
|
+
projectDir,
|
|
163
|
+
currentModulePath: `_snippets/${hash}.js`,
|
|
164
|
+
reactVersion,
|
|
165
|
+
}),
|
|
159
166
|
});
|
|
160
167
|
}
|
|
161
168
|
logger.debug("Snippet transformed", {
|
|
@@ -215,7 +222,16 @@ export function serveModule(req, options) {
|
|
|
215
222
|
reactVersion,
|
|
216
223
|
});
|
|
217
224
|
if (isSSR) {
|
|
218
|
-
code =
|
|
225
|
+
code = await applySSRImportRewritesAsync(code, {
|
|
226
|
+
crossProjectRef: projectRef,
|
|
227
|
+
resolveCacheBuster: createSSRTargetCacheBusterResolver({
|
|
228
|
+
secureFs,
|
|
229
|
+
projectDir,
|
|
230
|
+
currentModulePath: crossPath,
|
|
231
|
+
crossProjectRef: projectRef,
|
|
232
|
+
reactVersion,
|
|
233
|
+
}),
|
|
234
|
+
});
|
|
219
235
|
}
|
|
220
236
|
return createModuleResponse(method, code, HTTP_OK, {
|
|
221
237
|
"Content-Type": "application/javascript; charset=utf-8",
|
|
@@ -303,7 +319,16 @@ export function serveModule(req, options) {
|
|
|
303
319
|
};
|
|
304
320
|
code = await transformToESM(source, sourceFile, projectDir, adapter, transformOpts);
|
|
305
321
|
if (isSSR) {
|
|
306
|
-
code =
|
|
322
|
+
code = await applySSRImportRewritesAsync(code, {
|
|
323
|
+
projectSlug,
|
|
324
|
+
branch,
|
|
325
|
+
resolveCacheBuster: createSSRTargetCacheBusterResolver({
|
|
326
|
+
secureFs,
|
|
327
|
+
projectDir,
|
|
328
|
+
currentModulePath: modulePath,
|
|
329
|
+
reactVersion,
|
|
330
|
+
}),
|
|
331
|
+
});
|
|
307
332
|
}
|
|
308
333
|
const hmrTimestamp = url.searchParams.get("t");
|
|
309
334
|
if (hmrTimestamp) {
|
|
@@ -330,6 +355,37 @@ export function serveModule(req, options) {
|
|
|
330
355
|
}
|
|
331
356
|
}, { "modules.path": url.pathname, "modules.projectSlug": options.projectSlug || "unknown" });
|
|
332
357
|
}
|
|
358
|
+
async function readSourceFileForVersion(secureFs, findResult) {
|
|
359
|
+
if (findResult.embeddedContent !== undefined)
|
|
360
|
+
return findResult.embeddedContent;
|
|
361
|
+
const platformFs = createFileSystem();
|
|
362
|
+
return findResult.isFrameworkFile
|
|
363
|
+
? await platformFs.readTextFile(findResult.path)
|
|
364
|
+
: await secureFs.readFile(findResult.path);
|
|
365
|
+
}
|
|
366
|
+
function createSSRTargetCacheBusterResolver(options) {
|
|
367
|
+
const versions = new Map();
|
|
368
|
+
return (target) => {
|
|
369
|
+
const targetPath = resolveSSRImportTargetModulePath(target, options.currentModulePath);
|
|
370
|
+
const key = `${options.crossProjectRef ?? "local"}\0${targetPath}`;
|
|
371
|
+
let promise = versions.get(key);
|
|
372
|
+
if (!promise) {
|
|
373
|
+
promise = (async () => {
|
|
374
|
+
if (options.crossProjectRef) {
|
|
375
|
+
const source = await fetchCrossProjectSource(options.crossProjectRef, targetPath);
|
|
376
|
+
return source === null ? undefined : await sha256Short(`${targetPath}\0${source}`);
|
|
377
|
+
}
|
|
378
|
+
const findResult = await findSourceFile(options.secureFs, options.projectDir, stripSSRModuleJsExtension(targetPath), options.reactVersion);
|
|
379
|
+
if (!findResult)
|
|
380
|
+
return undefined;
|
|
381
|
+
const source = await readSourceFileForVersion(options.secureFs, findResult);
|
|
382
|
+
return await sha256Short(`${findResult.path}\0${source}`);
|
|
383
|
+
})();
|
|
384
|
+
versions.set(key, promise);
|
|
385
|
+
}
|
|
386
|
+
return promise;
|
|
387
|
+
};
|
|
388
|
+
}
|
|
333
389
|
const REACT_PACKAGE_ASSET_SPECIFIERS = {
|
|
334
390
|
"react/react": "react",
|
|
335
391
|
"react/react-dom": "react-dom",
|
|
@@ -1,15 +1,27 @@
|
|
|
1
|
+
type CacheBuster = number | string;
|
|
2
|
+
export interface SSRImportRewriteTarget {
|
|
3
|
+
specifier: string;
|
|
4
|
+
kind: "alias" | "relative";
|
|
5
|
+
modulePath: string;
|
|
6
|
+
rewrittenPath: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function stripSSRModuleJsExtension(path: string): string;
|
|
9
|
+
export declare function resolveSSRImportTargetModulePath(target: SSRImportRewriteTarget, currentModulePath: string): string;
|
|
1
10
|
interface SSRRewriteOptions {
|
|
2
11
|
/** Project slug for multi-project routing */
|
|
3
12
|
projectSlug?: string | null;
|
|
4
13
|
/** Branch name for branch-aware routing */
|
|
5
14
|
branch?: string | null;
|
|
6
|
-
/** Cache buster
|
|
7
|
-
cacheBuster?:
|
|
15
|
+
/** Cache buster token. When omitted, each rewritten target gets a stable token. */
|
|
16
|
+
cacheBuster?: CacheBuster;
|
|
17
|
+
/** Resolve a cache buster token for each rewritten target. */
|
|
18
|
+
resolveCacheBuster?: (target: SSRImportRewriteTarget) => CacheBuster | null | undefined | Promise<CacheBuster | null | undefined>;
|
|
8
19
|
/** Cross-project reference (e.g., "demo@0.0") for @/ path rewrites */
|
|
9
20
|
crossProjectRef?: string;
|
|
10
21
|
/** React version to use for import rewrites */
|
|
11
22
|
reactVersion?: string;
|
|
12
23
|
}
|
|
13
24
|
export declare function applySSRImportRewrites(code: string, options?: SSRRewriteOptions): string;
|
|
25
|
+
export declare function applySSRImportRewritesAsync(code: string, options?: SSRRewriteOptions): Promise<string>;
|
|
14
26
|
export {};
|
|
15
27
|
//# sourceMappingURL=ssr-import-rewriter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssr-import-rewriter.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/server/ssr-import-rewriter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ssr-import-rewriter.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/server/ssr-import-rewriter.ts"],"names":[],"mappings":"AAQA,KAAK,WAAW,GAAG,MAAM,GAAG,MAAM,CAAC;AAEnC,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,OAAO,GAAG,UAAU,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9D;AAWD,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,sBAAsB,EAC9B,iBAAiB,EAAE,MAAM,GACxB,MAAM,CAWR;AAED,UAAU,iBAAiB;IACzB,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,2CAA2C;IAC3C,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,mFAAmF;IACnF,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,8DAA8D;IAC9D,kBAAkB,CAAC,EAAE,CACnB,MAAM,EAAE,sBAAsB,KAC3B,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IAC9E,sEAAsE;IACtE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAwKD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,MAAM,CAK5F;AA+CD,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,MAAM,CAAC,CAKjB"}
|
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
import { DEFAULT_REACT_VERSION, getReactImportMap, } from "../../transforms/esm/package-registry.js";
|
|
2
2
|
import { isDeno, isNode } from "../../platform/compat/runtime.js";
|
|
3
3
|
import { getLocalReactPaths } from "../../platform/compat/react-paths.js";
|
|
4
|
+
import { hashString } from "../../cache/hash.js";
|
|
5
|
+
export function stripSSRModuleJsExtension(path) {
|
|
6
|
+
return path.replace(/\.(?:mjs|js)$/i, "");
|
|
7
|
+
}
|
|
8
|
+
function normalizeSSRModulePath(path) {
|
|
9
|
+
let normalized = path.replace(/^\/+/, "");
|
|
10
|
+
if (normalized.startsWith("_vf_modules/")) {
|
|
11
|
+
normalized = normalized.slice("_vf_modules/".length);
|
|
12
|
+
}
|
|
13
|
+
if (normalized.startsWith("@/"))
|
|
14
|
+
normalized = normalized.slice(2);
|
|
15
|
+
return normalized;
|
|
16
|
+
}
|
|
17
|
+
export function resolveSSRImportTargetModulePath(target, currentModulePath) {
|
|
18
|
+
if (target.kind === "alias")
|
|
19
|
+
return normalizeSSRModulePath(target.modulePath);
|
|
20
|
+
const currentPath = normalizeSSRModulePath(currentModulePath);
|
|
21
|
+
if (target.specifier.startsWith("/")) {
|
|
22
|
+
return normalizeSSRModulePath(target.specifier);
|
|
23
|
+
}
|
|
24
|
+
const basePath = currentPath.startsWith("/") ? currentPath : `/${currentPath}`;
|
|
25
|
+
const resolved = new URL(target.specifier, `http://veryfront.local${basePath}`).pathname;
|
|
26
|
+
return normalizeSSRModulePath(resolved);
|
|
27
|
+
}
|
|
4
28
|
function shouldKeepBareSpecifier(specifier) {
|
|
5
29
|
// npm: specifiers are only supported in Deno, not Node.js
|
|
6
30
|
// In Node.js, we need to convert them to esm.sh URLs (handled in rewriteBareImports)
|
|
@@ -56,24 +80,86 @@ function rewriteBareImports(code, version) {
|
|
|
56
80
|
return `from "https://esm.sh/${bareSpecifier}?external=react&target=es2022"`;
|
|
57
81
|
});
|
|
58
82
|
}
|
|
83
|
+
function getDefaultCacheBuster(target, options) {
|
|
84
|
+
return hashString([
|
|
85
|
+
target.kind,
|
|
86
|
+
target.modulePath,
|
|
87
|
+
target.rewrittenPath,
|
|
88
|
+
options.projectSlug ?? "",
|
|
89
|
+
options.branch ?? "",
|
|
90
|
+
options.crossProjectRef ?? "",
|
|
91
|
+
options.reactVersion ?? "",
|
|
92
|
+
].join("\0"));
|
|
93
|
+
}
|
|
94
|
+
function getCacheBusterSync(target, options) {
|
|
95
|
+
if (options.cacheBuster !== undefined)
|
|
96
|
+
return String(options.cacheBuster);
|
|
97
|
+
return getDefaultCacheBuster(target, options);
|
|
98
|
+
}
|
|
99
|
+
async function getCacheBusterAsync(target, options) {
|
|
100
|
+
if (options.cacheBuster !== undefined)
|
|
101
|
+
return String(options.cacheBuster);
|
|
102
|
+
const resolved = await options.resolveCacheBuster?.(target);
|
|
103
|
+
if (resolved !== undefined && resolved !== null)
|
|
104
|
+
return String(resolved);
|
|
105
|
+
return getDefaultCacheBuster(target, options);
|
|
106
|
+
}
|
|
107
|
+
function buildAliasRewrite(specifierPath, options) {
|
|
108
|
+
const { crossProjectRef } = options;
|
|
109
|
+
const jsPath = specifierPath.endsWith(".js") ? specifierPath : `${specifierPath}.js`;
|
|
110
|
+
if (crossProjectRef) {
|
|
111
|
+
const rewrittenPath = `/_vf_modules/_cross/${crossProjectRef}/@/${jsPath}`;
|
|
112
|
+
return {
|
|
113
|
+
target: {
|
|
114
|
+
specifier: `@/${specifierPath}`,
|
|
115
|
+
kind: "alias",
|
|
116
|
+
modulePath: jsPath,
|
|
117
|
+
rewrittenPath,
|
|
118
|
+
},
|
|
119
|
+
prefix: `${rewrittenPath}?ssr=true`,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
const rewrittenPath = `/_vf_modules/${jsPath}`;
|
|
123
|
+
return {
|
|
124
|
+
target: {
|
|
125
|
+
specifier: `@/${specifierPath}`,
|
|
126
|
+
kind: "alias",
|
|
127
|
+
modulePath: jsPath,
|
|
128
|
+
rewrittenPath,
|
|
129
|
+
},
|
|
130
|
+
prefix: `${rewrittenPath}?ssr=true`,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function buildRelativeRewrite(specifier) {
|
|
134
|
+
return {
|
|
135
|
+
target: {
|
|
136
|
+
specifier,
|
|
137
|
+
kind: "relative",
|
|
138
|
+
modulePath: specifier,
|
|
139
|
+
rewrittenPath: specifier,
|
|
140
|
+
},
|
|
141
|
+
prefix: `${specifier}?ssr=true`,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function buildScopedParams(options) {
|
|
145
|
+
const projectParam = options.projectSlug ? `&project=${options.projectSlug}` : "";
|
|
146
|
+
const branchParam = options.branch ? `&branch=${options.branch}` : "";
|
|
147
|
+
return `${projectParam}${branchParam}`;
|
|
148
|
+
}
|
|
59
149
|
function rewritePathAliases(code, options) {
|
|
60
|
-
const
|
|
61
|
-
const projectParam = projectSlug ? `&project=${projectSlug}` : "";
|
|
62
|
-
const branchParam = branch ? `&branch=${branch}` : "";
|
|
150
|
+
const scopedParams = buildScopedParams(options);
|
|
63
151
|
return code.replace(/from\s+["']@\/([^"']+)["']/g, (_match, path) => {
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
return `from "/_vf_modules/${jsPath}?ssr=true${projectParam}${branchParam}&v=${cacheBuster}"`;
|
|
152
|
+
const { target, prefix } = buildAliasRewrite(path, options);
|
|
153
|
+
const cacheBuster = getCacheBusterSync(target, options);
|
|
154
|
+
return `from "${prefix}${scopedParams}&v=${cacheBuster}"`;
|
|
69
155
|
});
|
|
70
156
|
}
|
|
71
157
|
function rewriteRelativeImports(code, options) {
|
|
72
|
-
const
|
|
73
|
-
const projectParam = projectSlug ? `&project=${projectSlug}` : "";
|
|
74
|
-
const branchParam = branch ? `&branch=${branch}` : "";
|
|
158
|
+
const scopedParams = buildScopedParams(options);
|
|
75
159
|
return code.replace(/from\s+["']((?:\.\.?\/|\/)[^"']+\.js)["']/g, (_match, path) => {
|
|
76
|
-
|
|
160
|
+
const { target, prefix } = buildRelativeRewrite(path);
|
|
161
|
+
const cacheBuster = getCacheBusterSync(target, options);
|
|
162
|
+
return `from "${prefix}${scopedParams}&v=${cacheBuster}"`;
|
|
77
163
|
});
|
|
78
164
|
}
|
|
79
165
|
export function applySSRImportRewrites(code, options = {}) {
|
|
@@ -82,3 +168,39 @@ export function applySSRImportRewrites(code, options = {}) {
|
|
|
82
168
|
result = rewriteRelativeImports(result, options);
|
|
83
169
|
return result;
|
|
84
170
|
}
|
|
171
|
+
async function replaceAsync(code, pattern, replacer) {
|
|
172
|
+
const chunks = [];
|
|
173
|
+
let lastIndex = 0;
|
|
174
|
+
pattern.lastIndex = 0;
|
|
175
|
+
for (let match = pattern.exec(code); match; match = pattern.exec(code)) {
|
|
176
|
+
chunks.push(code.slice(lastIndex, match.index));
|
|
177
|
+
chunks.push(await replacer(match));
|
|
178
|
+
lastIndex = match.index + match[0].length;
|
|
179
|
+
}
|
|
180
|
+
chunks.push(code.slice(lastIndex));
|
|
181
|
+
return chunks.join("");
|
|
182
|
+
}
|
|
183
|
+
async function rewritePathAliasesAsync(code, options) {
|
|
184
|
+
const scopedParams = buildScopedParams(options);
|
|
185
|
+
return await replaceAsync(code, /from\s+["']@\/([^"']+)["']/g, async (match) => {
|
|
186
|
+
const path = match[1] ?? "";
|
|
187
|
+
const { target, prefix } = buildAliasRewrite(path, options);
|
|
188
|
+
const cacheBuster = await getCacheBusterAsync(target, options);
|
|
189
|
+
return `from "${prefix}${scopedParams}&v=${cacheBuster}"`;
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
async function rewriteRelativeImportsAsync(code, options) {
|
|
193
|
+
const scopedParams = buildScopedParams(options);
|
|
194
|
+
return await replaceAsync(code, /from\s+["']((?:\.\.?\/|\/)[^"']+\.js)["']/g, async (match) => {
|
|
195
|
+
const path = match[1] ?? "";
|
|
196
|
+
const { target, prefix } = buildRelativeRewrite(path);
|
|
197
|
+
const cacheBuster = await getCacheBusterAsync(target, options);
|
|
198
|
+
return `from "${prefix}${scopedParams}&v=${cacheBuster}"`;
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
export async function applySSRImportRewritesAsync(code, options = {}) {
|
|
202
|
+
let result = rewriteBareImports(code, options.reactVersion);
|
|
203
|
+
result = await rewritePathAliasesAsync(result, options);
|
|
204
|
+
result = await rewriteRelativeImportsAsync(result, options);
|
|
205
|
+
return result;
|
|
206
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { escapeHtml } from "../../html/html-escape.js";
|
|
2
2
|
export { escapeHtml };
|
|
3
|
+
export declare function jsonForInlineScript(value: unknown, space?: string | number): string;
|
|
3
4
|
export declare function buildTrustedHtmlValidatorScript(): string;
|
|
4
5
|
interface ValidateTrustedHtmlOptions {
|
|
5
6
|
/** Throw on suspicious patterns even in dev mode */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-sanitizer.d.ts","sourceRoot":"","sources":["../../../../src/src/security/client/html-sanitizer.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAGvD,OAAO,EAAE,UAAU,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"html-sanitizer.d.ts","sourceRoot":"","sources":["../../../../src/src/security/client/html-sanitizer.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAGvD,OAAO,EAAE,UAAU,EAAE,CAAC;AAoBtB,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAOnF;AAED,wBAAgB,+BAA+B,IAAI,MAAM,CAwBxD;AAiBD,UAAU,0BAA0B;IAClC,oDAAoD;IACpD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,2CAA2C;IAC3C,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,0BAA+B,GACvC,MAAM,CAcR;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACtC,GAAG,cAAc,CA+BjB"}
|
|
@@ -25,8 +25,8 @@ function createSuspiciousPatterns() {
|
|
|
25
25
|
name,
|
|
26
26
|
}));
|
|
27
27
|
}
|
|
28
|
-
function jsonForInlineScript(value) {
|
|
29
|
-
return JSON.stringify(value)
|
|
28
|
+
export function jsonForInlineScript(value, space) {
|
|
29
|
+
return JSON.stringify(value, null, space)
|
|
30
30
|
.replace(/</g, "\\u003c")
|
|
31
31
|
.replace(/>/g, "\\u003e")
|
|
32
32
|
.replace(/&/g, "\\u0026")
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* Do not edit manually — run `deno task generate` to regenerate.
|
|
6
6
|
* @module
|
|
7
7
|
*/
|
|
8
|
-
export const CLIENT_BOOT_BUNDLE = 'var ot=Object.defineProperty;var nt=(t,e,o)=>e in t?ot(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var m=(t,e,o)=>nt(t,typeof e!="symbol"?e+"":e,o);var st="3.2.3";function it(t,e,o,n){let s=[];if(n?.external?.length&&s.push(`external=${n.external.join(",")}`),s.push(`target=${n?.target??"es2022"}`),n?.deps){let d=Object.entries(n.deps).map(([l,p])=>`${l}@${p}`).join(",");s.push(`deps=${d}`)}let u=e?`@${e}`:"",c=o??"",i=s.length?`?${s.join("&")}`:"";return`https://esm.sh/${t}${u}${c}${i}`}function R(t,e,o,n=!1){return it(t,e,o,{external:n?["react"]:void 0,deps:{csstype:st}})}var ct="19.2.4",E=ct;function w(t=E){return{react:R("react",t),"react-dom":R("react-dom",t,void 0,!0),"react-dom/client":R("react-dom",t,"/client",!0),"react-dom/server":R("react-dom",t,"/server",!0),"react/jsx-runtime":R("react",t,"/jsx-runtime",!0),"react/jsx-dev-runtime":R("react",t,"/jsx-dev-runtime",!0)}}function V(t=E){return w(t).react}function H(t=E){return w(t)["react-dom/client"]}function lt(t){return t.replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}function D(t){return lt(btoa(t))}var xr=Object.freeze({react:"","react-dom":"","react-dom/client":"","react-dom/server":"","react/jsx-runtime":"","react/jsx-dev-runtime":""});function v(t,e){if(!e)return!1;if(Object.prototype.hasOwnProperty.call(e,t))return!0;for(let o of Object.keys(e))if(o.endsWith("/")&&t.startsWith(o))return!0;return!1}function ut(t){try{return JSON.parse(t)?.imports??{}}catch{return{}}}function F(t=document){let e=t.querySelector(\'script[type="importmap"]\');return e?.textContent?ut(e.textContent):{}}var a="/_veryfront",b={RSC:`${a}/rsc/`,FS:`${a}/fs/`,MODULES:`${a}/modules/`,PAGES:`${a}/pages/`,DATA:`${a}/data/`,LIB:`${a}/lib/`,CHUNKS:`${a}/chunks/`,CLIENT:`${a}/client/`},G={HMR_RUNTIME:`${a}/hmr-runtime.js`,HMR:`${a}/hmr.js`,ERROR_OVERLAY:`${a}/error-overlay.js`,DEV_LOADER:`${a}/dev-loader.js`,CLIENT_LOG:`${a}/log`,CLIENT_JS:`${a}/client.js`,ROUTER_JS:`${a}/router.js`,PREFETCH_JS:`${a}/prefetch.js`,MANIFEST_JSON:`${a}/manifest.json`,APP_JS:`${a}/app.js`,RSC_CLIENT:`${a}/rsc/client.js`,RSC_MANIFEST:`${a}/rsc/manifest`,RSC_STREAM:`${a}/rsc/stream`,RSC_PAYLOAD:`${a}/rsc/payload`,RSC_RENDER:`${a}/rsc/render`,RSC_PAGE:`${a}/rsc/page`,RSC_MODULE:`${a}/rsc/module`,RSC_DOM:`${a}/rsc/dom.js`,LIB_CHAT_REACT:`${a}/lib/chat/react.js`,LIB_CHAT_COMPONENTS:`${a}/lib/chat/components.js`,LIB_CHAT_PRIMITIVES:`${a}/lib/chat/primitives.js`};var dt={ROOT:".veryfront",CACHE:".veryfront/cache",KV:".veryfront/kv",LOGS:".veryfront/logs",TMP:".veryfront/tmp"},Nr=dt.CACHE;var Dr={HMR_RUNTIME:G.HMR_RUNTIME,ERROR_OVERLAY:G.ERROR_OVERLAY};var y=b.RSC,k=b.FS,$="veryfront-hydration-data",_="rsc-root";function x(t=document){try{let e=t.getElementById($);return e?JSON.parse(e.textContent||"{}"):null}catch(e){return console.debug?.("[RSC] hydration data parse failed",e),null}}function C(t){return t?.clientModuleStrategy?t.clientModuleStrategy:t?.dev?"fs":"rsc-module"}function pt(t){return`${k}${D(t)}.js`}function mt(t,e){let o=e?`&v=${encodeURIComponent(e)}`:"";return`${y}module?rel=${encodeURIComponent(t)}${o}`}function I(t){if(t.strategy==="fs"){let e=t.absPath??t.rel;return e?pt(e):null}return mt(t.rel,t.version)}function O(t=document,e=E){let o=F(t);return{react:v("react",o)?"react":V(e),reactDomClient:v("react-dom/client",o)?"react-dom/client":H(e)}}function r(t){return{...t,create(e){return new M(e?.message||e?.detail||t.title,{slug:t.slug,category:t.category,status:e?.status??t.status,title:t.title,suggestion:t.suggestion,detail:e?.detail,cause:e?.cause,instance:e?.instance,context:e?.context})}}}var M=class extends Error{constructor(o,n){super(o);m(this,"slug");m(this,"category");m(this,"status");m(this,"title");m(this,"suggestion");m(this,"detail");m(this,"cause");m(this,"instance");m(this,"context");this.name="VeryfrontError",this.slug=n.slug,this.category=n.category,this.status=n.status,this.title=n.title,this.suggestion=n.suggestion,this.detail=n.detail,this.cause=n.cause,this.instance=n.instance,this.context=n.context}toRFC9457(){return{type:`https://veryfront.com/docs/errors/${this.slug}`,title:this.title,status:this.status,detail:this.detail,instance:this.instance,category:this.category,suggestion:this.suggestion,cause:typeof this.cause=="string"?this.cause:void 0}}getDocsUrl(){return`https://veryfront.com/docs/errors/${this.slug}`}};var Rt=r({slug:"config-not-found",category:"CONFIG",status:404,title:"Configuration file not found",suggestion:"Run \'vf init\' to create a configuration file"}),ft=r({slug:"config-invalid",category:"CONFIG",status:400,title:"Invalid configuration format",suggestion:"Check your veryfront.config.ts for syntax errors"}),Et=r({slug:"config-parse-error",category:"CONFIG",status:400,title:"Failed to parse configuration",suggestion:"Ensure your configuration file is valid TypeScript/JSON"}),yt=r({slug:"config-validation-error",category:"CONFIG",status:422,title:"Configuration validation failed",suggestion:"Check the configuration against the schema requirements"}),_t=r({slug:"config-type-error",category:"CONFIG",status:400,title:"Configuration type mismatch",suggestion:"Ensure configuration values match expected types"}),ht=r({slug:"import-map-invalid",category:"CONFIG",status:400,title:"Invalid import map configuration",suggestion:"Check your import map syntax and paths"}),St=r({slug:"cors-config-invalid",category:"CONFIG",status:400,title:"Invalid CORS configuration",suggestion:"Review CORS settings in your configuration"}),Tt=r({slug:"config-validation-failed",category:"CONFIG",status:400,title:"Configuration validation failed",suggestion:"Check configuration values against requirements"}),Y={"config-not-found":Rt,"config-invalid":ft,"config-parse-error":Et,"config-validation-error":yt,"config-type-error":_t,"import-map-invalid":ht,"cors-config-invalid":St,"config-validation-failed":Tt};var xt=r({slug:"build-failed",category:"BUILD",status:500,title:"Build process failed",suggestion:"Check the build output for specific errors"}),Ct=r({slug:"bundle-error",category:"BUILD",status:500,title:"Bundle generation failed",suggestion:"Review bundler output for details"}),It=r({slug:"typescript-error",category:"BUILD",status:500,title:"TypeScript compilation error",suggestion:"Fix TypeScript errors shown in the output"}),Ot=r({slug:"mdx-compile-error",category:"BUILD",status:500,title:"MDX compilation failed",suggestion:"Check your MDX file syntax"}),At=r({slug:"asset-optimization-error",category:"BUILD",status:500,title:"Asset optimization failed",suggestion:"Check asset file formats and paths"}),Nt=r({slug:"ssg-generation-error",category:"BUILD",status:500,title:"Static site generation failed",suggestion:"Review SSG configuration and data fetching"}),Dt=r({slug:"sourcemap-error",category:"BUILD",status:500,title:"Source map generation failed",suggestion:"Check source map configuration"}),vt=r({slug:"compilation-error",category:"BUILD",status:500,title:"Compilation failed",suggestion:"Review compiler output for specific errors"}),B={"build-failed":xt,"bundle-error":Ct,"typescript-error":It,"mdx-compile-error":Ot,"asset-optimization-error":At,"ssg-generation-error":Nt,"sourcemap-error":Dt,"compilation-error":vt};var bt=r({slug:"hydration-mismatch",category:"RUNTIME",status:500,title:"Client/server hydration mismatch",suggestion:"Ensure server and client render the same content"}),Mt=r({slug:"render-error",category:"RUNTIME",status:500,title:"Component render failed",suggestion:"Check component for runtime errors"}),Lt=r({slug:"component-error",category:"RUNTIME",status:500,title:"Component execution error",suggestion:"Review component logic and props"}),Ut=r({slug:"layout-not-found",category:"RUNTIME",status:404,title:"Layout component not found",suggestion:"Ensure layout file exists at the expected path"}),Pt=r({slug:"page-not-found",category:"RUNTIME",status:404,title:"Page component not found",suggestion:"Check that the page file exists in the routes directory"}),wt=r({slug:"api-error",category:"RUNTIME",status:500,title:"API route handler error",suggestion:"Review API route handler for errors"}),Vt=r({slug:"middleware-error",category:"RUNTIME",status:500,title:"Middleware execution error",suggestion:"Check middleware function for errors"}),j={"hydration-mismatch":bt,"render-error":Mt,"component-error":Lt,"layout-not-found":Ut,"page-not-found":Pt,"api-error":wt,"middleware-error":Vt};var Ht=r({slug:"route-conflict",category:"ROUTE",status:409,title:"Conflicting route definitions",suggestion:"Rename or reorganize conflicting route files"}),Ft=r({slug:"invalid-route-file",category:"ROUTE",status:400,title:"Invalid route file structure",suggestion:"Ensure route file exports required functions"}),Gt=r({slug:"route-handler-invalid",category:"ROUTE",status:400,title:"Invalid route handler export",suggestion:"Export a valid handler function from the route file"}),kt=r({slug:"dynamic-route-error",category:"ROUTE",status:500,title:"Dynamic route parsing failed",suggestion:"Check dynamic route segment syntax"}),$t=r({slug:"route-params-error",category:"ROUTE",status:400,title:"Route parameters invalid",suggestion:"Validate route parameter values"}),Yt=r({slug:"api-route-error",category:"ROUTE",status:500,title:"API route definition error",suggestion:"Review API route configuration"}),W={"route-conflict":Ht,"invalid-route-file":Ft,"route-handler-invalid":Gt,"dynamic-route-error":kt,"route-params-error":$t,"api-route-error":Yt};var Bt=r({slug:"module-not-found",category:"MODULE",status:404,title:"Module could not be resolved",suggestion:"Check the import path and ensure the module is installed"}),jt=r({slug:"import-resolution-error",category:"MODULE",status:500,title:"Import path resolution failed",suggestion:"Verify import paths and module configuration"}),Wt=r({slug:"circular-dependency",category:"MODULE",status:500,title:"Circular dependency detected",suggestion:"Refactor imports to break the circular dependency"}),qt=r({slug:"invalid-import",category:"MODULE",status:400,title:"Invalid import statement",suggestion:"Fix import syntax or path"}),zt=r({slug:"dependency-missing",category:"MODULE",status:404,title:"Required dependency not installed",suggestion:"Install the missing dependency with your package manager"}),Xt=r({slug:"version-mismatch",category:"MODULE",status:409,title:"Dependency version mismatch",suggestion:"Update dependencies to compatible versions"}),q={"module-not-found":Bt,"import-resolution-error":jt,"circular-dependency":Wt,"invalid-import":qt,"dependency-missing":zt,"version-mismatch":Xt};var Jt=r({slug:"port-in-use",category:"SERVER",status:409,title:"Server port already in use",suggestion:"Use a different port or stop the process using this port"}),Kt=r({slug:"server-start-error",category:"SERVER",status:500,title:"Server failed to start",suggestion:"Check server configuration and port availability"}),Zt=r({slug:"cache-error",category:"SERVER",status:500,title:"Cache operation failed",suggestion:"Clear the cache and try again"}),Qt=r({slug:"file-watch-error",category:"SERVER",status:500,title:"File watcher error",suggestion:"Restart the development server"}),te=r({slug:"request-error",category:"SERVER",status:500,title:"HTTP request handling error",suggestion:"Check request handler and middleware"}),ee=r({slug:"service-overloaded",category:"SERVER",status:503,title:"Service overloaded",suggestion:"Reduce load or scale up resources"}),re=r({slug:"semaphore-timeout",category:"SERVER",status:503,title:"Semaphore acquire timeout",suggestion:"Reduce concurrency or increase the semaphore acquire timeout"}),oe=r({slug:"circuit-breaker-open",category:"SERVER",status:503,title:"Circuit breaker is open",suggestion:"Wait for the breaker reset timeout before retrying"}),ne=r({slug:"cache-path-mismatch",category:"SERVER",status:500,title:"Cache path mismatch",suggestion:"Clear the cache directory and rebuild"}),se=r({slug:"network-error",category:"SERVER",status:502,title:"Network operation failed",suggestion:"Check network connectivity and retry"}),ie=r({slug:"api-client-error",category:"SERVER",status:500,title:"API client request failed",suggestion:"Check API connectivity and authentication"}),ae=r({slug:"token-storage-error",category:"SERVER",status:500,title:"Token storage operation failed",suggestion:"Check token storage backend and credentials"}),ce=r({slug:"cache-invariant-violation",category:"SERVER",status:500,title:"Cache path invariant violated",suggestion:"Clear the cache and rebuild"}),le=r({slug:"release-not-found",category:"SERVER",status:404,title:"No active release found",suggestion:"Deploy the project to create a release for this environment"}),ue=r({slug:"fallback-exhausted",category:"SERVER",status:500,title:"Primary and fallback operations both failed",suggestion:"Check service availability and connectivity"}),z={"port-in-use":Jt,"server-start-error":Kt,"cache-error":Zt,"file-watch-error":Qt,"request-error":te,"service-overloaded":ee,"semaphore-timeout":re,"circuit-breaker-open":oe,"cache-path-mismatch":ne,"network-error":se,"api-client-error":ie,"token-storage-error":ae,"cache-invariant-violation":ce,"release-not-found":le,"fallback-exhausted":ue};var ge=r({slug:"client-boundary-violation",category:"BOUNDARY",status:400,title:"Client boundary rule violation",suggestion:"Add \'use client\' directive or move code to a client component"}),de=r({slug:"server-only-in-client",category:"BOUNDARY",status:400,title:"Server-only code in client component",suggestion:"Move server-only code to a server component"}),pe=r({slug:"client-only-in-server",category:"BOUNDARY",status:400,title:"Client-only code in server component",suggestion:"Move client-only code to a client component"}),me=r({slug:"invalid-use-client",category:"BOUNDARY",status:400,title:"Invalid \'use client\' directive",suggestion:"Place \'use client\' at the top of the file"}),Re=r({slug:"invalid-use-server",category:"BOUNDARY",status:400,title:"Invalid \'use server\' directive",suggestion:"Place \'use server\' at the top of the file or function"}),fe=r({slug:"rsc-payload-error",category:"BOUNDARY",status:500,title:"RSC payload serialization error",suggestion:"Ensure props are serializable (no functions, symbols, etc.)"}),X={"client-boundary-violation":ge,"server-only-in-client":de,"client-only-in-server":pe,"invalid-use-client":me,"invalid-use-server":Re,"rsc-payload-error":fe};var Ee=r({slug:"hmr-error",category:"DEV",status:500,title:"Hot module replacement error",suggestion:"Restart the development server"}),ye=r({slug:"dev-server-error",category:"DEV",status:500,title:"Development server error",suggestion:"Check the dev server logs and restart"}),_e=r({slug:"fast-refresh-error",category:"DEV",status:500,title:"Fast refresh failed",suggestion:"Save the file again or restart the dev server"}),he=r({slug:"error-overlay-error",category:"DEV",status:500,title:"Error overlay failed",suggestion:"Check browser console for details"}),Se=r({slug:"source-map-error",category:"DEV",status:500,title:"Source map loading error",suggestion:"Rebuild or clear cache"}),J={"hmr-error":Ee,"dev-server-error":ye,"fast-refresh-error":_e,"error-overlay-error":he,"source-map-error":Se};var Te=r({slug:"deployment-error",category:"DEPLOY",status:500,title:"Deployment process failed",suggestion:"Check deployment logs for details"}),xe=r({slug:"platform-error",category:"DEPLOY",status:500,title:"Platform-specific error",suggestion:"Check platform documentation and requirements"}),Ce=r({slug:"env-var-missing",category:"DEPLOY",status:500,title:"Required environment variable missing",suggestion:"Set the required environment variable"}),Ie=r({slug:"production-build-required",category:"DEPLOY",status:400,title:"Production build required",suggestion:"Run \'vf build\' before deploying"}),K={"deployment-error":Te,"platform-error":xe,"env-var-missing":Ce,"production-build-required":Ie};var Oe=r({slug:"agent-error",category:"AGENT",status:500,title:"Agent operation error",suggestion:"Check agent configuration and logs"}),Ae=r({slug:"agent-not-found",category:"AGENT",status:404,title:"Agent not found",suggestion:"Verify the agent ID exists"}),Ne=r({slug:"agent-timeout",category:"AGENT",status:408,title:"Agent operation timed out",suggestion:"Increase timeout or simplify the request"}),De=r({slug:"agent-intent-error",category:"AGENT",status:400,title:"Agent intent parsing error",suggestion:"Rephrase the request more clearly"}),ve=r({slug:"orchestration-error",category:"AGENT",status:500,title:"Multi-agent orchestration error",suggestion:"Check agent coordination logic"}),be=r({slug:"cost-limit-exceeded",category:"AGENT",status:429,title:"Cost limit exceeded",suggestion:"Wait for the budget period to reset or increase the limit"}),Z={"agent-error":Oe,"agent-not-found":Ae,"agent-timeout":Ne,"agent-intent-error":De,"orchestration-error":ve,"cost-limit-exceeded":be};var Me=r({slug:"unknown-error",category:"GENERAL",status:500,title:"Unknown/unclassified error",suggestion:"Check logs for more details"}),Le=r({slug:"permission-denied",category:"GENERAL",status:403,title:"File/resource permission denied",suggestion:"Check file permissions and access rights"}),Ue=r({slug:"file-not-found",category:"GENERAL",status:404,title:"File not found",suggestion:"Verify the file path exists"}),Pe=r({slug:"resource-not-found",category:"GENERAL",status:404,title:"Requested resource not found",suggestion:"Verify the referenced resource ID or name exists"}),we=r({slug:"invalid-argument",category:"GENERAL",status:400,title:"Invalid function argument",suggestion:"Check argument types and values"}),Ve=r({slug:"timeout-error",category:"GENERAL",status:408,title:"Operation timed out",suggestion:"Increase timeout or optimize the operation"}),He=r({slug:"initialization-error",category:"GENERAL",status:500,title:"Initialization failed",suggestion:"Check initialization requirements and dependencies"}),Fe=r({slug:"not-supported",category:"GENERAL",status:501,title:"Feature not supported",suggestion:"Check documentation for supported features"}),L=r({slug:"security-violation",category:"GENERAL",status:403,title:"Security violation detected",suggestion:"Check for path traversal or unauthorized access attempts"}),Ge=r({slug:"input-validation-failed",category:"GENERAL",status:400,title:"Input validation failed",suggestion:"Check request input against validation rules"}),Q={"unknown-error":Me,"permission-denied":Le,"file-not-found":Ue,"resource-not-found":Pe,"invalid-argument":we,"timeout-error":Ve,"initialization-error":He,"not-supported":Fe,"security-violation":L,"input-validation-failed":Ge};var Ao={...Y,...B,...j,...W,...q,...z,...X,...J,...K,...Z,...Q};var ke=[{source:String.raw`<script[^>]*>[\\s\\S]*?<\\/script>`,flags:"gi",name:"inline script"},{source:String.raw`javascript:`,flags:"gi",name:"javascript: URL"},{source:String.raw`\\bon\\w+\\s*=`,flags:"gi",name:"event handler attribute"},{source:String.raw`data:\\s*text\\/html`,flags:"gi",name:"data: HTML URL"}];function $e(){return ke.map(({source:t,flags:e,name:o})=>({pattern:new RegExp(t,e),name:o}))}function Ye(){let t=globalThis;return t.__VERYFRONT_DEV__===!0||t.Deno?.env?.get?.("VERYFRONT_ENV")==="development"}function h(t,e={}){let{strict:o=!1,warn:n=!0}=e;for(let{pattern:s,name:u}of $e())if(s.lastIndex=0,!!s.test(t)&&(n&&console.warn(`[Security] Suspicious ${u} detected in server HTML`),o||!Ye()))throw L.create({detail:`Potentially unsafe HTML: ${u} detected`});return t}var f=class{constructor(e,o){this.prefix=e;this.level=o}log(e,o,n,...s){this.level>e||o?.(n,...s)}debug(e,...o){this.log(0,console.debug,`[${this.prefix}] DEBUG: ${e}`,...o)}info(e,...o){this.log(1,console.log,`[${this.prefix}] ${e}`,...o)}warn(e,...o){this.log(2,console.warn,`[${this.prefix}] WARN: ${e}`,...o)}error(e,...o){this.log(3,console.error,`[${this.prefix}] ERROR: ${e}`,...o)}};function Be(){if(typeof window>"u")return 2;let t=globalThis;return t.__VERYFRONT_DEV__||t.__RSC_DEV__?t.__VERYFRONT_DEBUG__||t.__RSC_DEBUG__?0:1:2}var A=Be(),g=new f("RSC",A),Bo=new f("PREFETCH",A),jo=new f("HYDRATE",A),Wo=new f("VERYFRONT",A);function S(t,e){let o=e==="root"?_:`rsc-slot-${e}`,n=t.getElementById(o);if(n)return n;let s=t.createElement("div");return s.id=o,t.body.appendChild(s),s}function je(t,e){if(e.type!=="slot")return;let o=S(t,e.id);o.innerHTML=h(String(e.html??""))}function tt(t,e){let o=e.split(`\n`),n=o.pop()??"";for(let s of o){let u=s.trim();if(!u)continue;let c;try{c=JSON.parse(u)}catch(d){g.debug("[client-dom] malformed NDJSON line",{line:u,error:d instanceof Error?d.message:String(d)});continue}if(!c||typeof c!="object")continue;let i=c;if(i.type==="slot"){je(t,i);try{ze(t,i.id||"root")}catch(d){g.debug("[client-dom] hydration optional failed",d)}}}return n}function We(t){return new Promise((e,o)=>{let n=()=>o(new DOMException("aborted","AbortError"));if(t.aborted){n();return}t.addEventListener("abort",n,{once:!0})})}async function et(t,e=document,o){let n="body"in t?t:null,s=n?.body??t;if(!s)return;let u=s.getReader(),c=new TextDecoder,i="",d=!1;try{for(;;){if(o?.aborted)throw new DOMException("aborted","AbortError");let l=u.read(),{done:p,value:T}=o?await Promise.race([l,We(o)]):await l;if(p){d=!0;break}i+=c.decode(T,{stream:!0}),i=tt(e,i)}i&&tt(e,`${i}\n`)}catch(l){throw l instanceof Error&&l.name==="AbortError"||g.debug("[client-dom] consumeNdjsonStream error",l),l}finally{try{await u.cancel()}catch(l){d||g.debug("[client-dom] reader.cancel failed",l)}try{u.releaseLock()}catch(l){g.debug("[client-dom] reader.releaseLock failed",l)}if(typeof s.cancel=="function")try{await s.cancel()}catch(l){g.debug("[client-dom] stream.cancel failed",l)}if(typeof n?.body?.cancel=="function")try{await n.body.cancel()}catch(l){g.debug("[client-dom] response.body.cancel failed",l)}}}function qe(t,e){let o=S(t,e),n=[],s=u=>{let c=u;c.dataset?.clientRef&&n.push(c);for(let i of u.children)s(i)};return s(o),n}function ze(t,e){let o=qe(t,e);for(let n of o){let s=n.dataset?.clientRef;s&&(n.dataset.hydrated="true",g.debug("[client-dom] marked for hydration",s))}}var Xe=100;function Je(t,e){if(globalThis.__VF_CLIENT_MOD_CACHE??(globalThis.__VF_CLIENT_MOD_CACHE=new Map),globalThis.__VF_CLIENT_MOD_CACHE.size>=Xe){let o=globalThis.__VF_CLIENT_MOD_CACHE.keys().next().value;o&&globalThis.__VF_CLIENT_MOD_CACHE.delete(o)}globalThis.__VF_CLIENT_MOD_CACHE.set(t,e)}function Ke(t){let e=t.match(/^\\/app\\/(.+)#([A-Za-z0-9_]+)$/);return e?{rel:`/${e[1]||""}`,exportName:e[2]||"default"}:null}async function Ze(){try{let t=await fetch("/_veryfront/rsc/manifest");return t.ok?await t.json():null}catch{return null}}async function Qe(t,e,o){let n=t.graphIds?.client.find(c=>c.rel===e)?.path,s=`${e}#${t.hash??""}`;try{let c=globalThis.__VF_CLIENT_MOD_CACHE?.get(s);if(c)return c}catch(c){g.debug("hydrate: cache get failed",c)}let u=I({strategy:o,rel:e,absPath:n,version:t.hash});if(!u)return null;try{let c=await import(u);try{Je(s,c)}catch(i){g.debug("hydrate: cache set failed",i)}return c}catch(c){return g.debug("hydrate: failed to import module",{moduleUrl:u,error:c}),null}}async function rt(t=document){let e=null;try{e=await Ze()}catch(i){g.debug("hydrate: fetch manifest failed",i)}if(!e){g.debug("hydrate: no manifest");return}let o=Array.from(t.querySelectorAll("[data-client-ref]"));try{let i=globalThis.__VF_MANIFEST_HASH;if(!o.some(l=>l.dataset?.hydrated!=="true")&&i&&e.hash&&i===e.hash)return}catch(i){g.debug("hydrate: hmr hash read failed",i)}if(o.length===0){try{globalThis.__VF_MANIFEST_HASH=e.hash??""}catch(i){g.debug("hydrate: set hash failed",i)}return}let n=C(x(t));try{if(globalThis.__VF_TEST_MODE__){globalThis.__VF_HYDRATE_CALLED=!0,globalThis.__VF_MANIFEST_HASH=e.hash??"";return}}catch(i){g.debug("hydrate: test mode flags failed",i)}let s=O(t),[{default:u},{createRoot:c}]=await Promise.all([import(s.react),import(s.reactDomClient)]);for(let i of o){let d=i.dataset?.clientRef??"";if(!d||i.dataset?.hydrated==="true")continue;let l=Ke(d);if(!l)continue;let p=await Qe(e,l.rel,n);if(!p)continue;let T=p[l.exportName]??p.default;if(typeof T=="function")try{c(i).render(u.createElement(T,{})),i.dataset.hydrated="true"}catch(P){g.warn("hydrate: render failed",P)}}try{globalThis.__VF_MANIFEST_HASH=e.hash??""}catch(i){g.debug("hydrate: set hash failed (post)",i)}}async function tr(){let t=O(document),[e,o]=await Promise.all([import(t.react),import(t.reactDomClient)]);return{React:e,ReactDOM:o}}var er=new Set(["SCRIPT","STYLE","NOSCRIPT","TEMPLATE"]);function U(t){let e=t.getAttribute("style")??"";return t.hasAttribute("data-veryfront-head")||t.hasAttribute("hidden")||/(?:^|;)\\s*display\\s*:\\s*none(?:\\s*;|$)/i.test(e)||er.has(t.tagName.toUpperCase())}function rr(t,e){return t.find(o=>o.tagName.toUpperCase()==="DIV"&&!!o.getAttribute("class")?.trim()&&!U(o))??e}function or(t,e){return t===e}function nr(t,e){let o=document.createElement("div");o.setAttribute("data-veryfront-hydration-root","page");let n=t.find(s=>!U(s));n?.parentNode===e?e.insertBefore(o,n):e.appendChild(o);for(let s of t)!U(s)&&s.parentNode===e&&o.appendChild(s);return o}function sr(t,e,o=document){return!!e?.pagePath&&typeof t?.__veryfrontRenderPage=="function"&&!!o.getElementById("root")}function ir(t,e){return e?.pagePath?!1:!!t.getElementById(_)}function ar(t=import.meta.url){try{return new URL(t,"http://veryfront.local").searchParams.get("hydrate")==="1"}catch{return!1}}function cr(t){return t==="rsc-module"}async function lr(t){try{let e=await fetch(y+"stream"+t);if(!e.ok||!e.body)return!1;let o=new AbortController;return addEventListener("pagehide",()=>o.abort(),{once:!0}),await et(e,document,o.signal),!0}catch(e){return console.debug?.("[RSC] tryStream failed",e),!1}}async function N(){try{await rt(document)}catch(t){console.debug?.("[RSC] hydration failed",t)}}async function ur(t,e){try{let{React:o,ReactDOM:n}=await tr(),s=I({strategy:e,rel:t});if(!s)return!1;console.debug?.("[RSC] Loading component from:",s);let c=(await import(s)).default;if(typeof c!="function")return console.debug?.("[RSC] Page component is not a function"),!1;let i=Array.from(document.body.children),d=rr(i,document.body),l=or(d,document.body)?nr(i,document.body):d,p=o.createElement(c,{});return cr(e)?n.createRoot(l).render(p):n.hydrateRoot(l,p,{identifierPrefix:"vf",onRecoverableError:()=>{}}),console.debug?.("[RSC] Page component hydrated successfully"),!0}catch(o){return console.error("[RSC] Page hydration failed",o),!1}}async function gr(t){try{let e=await fetch(y+"payload"+t);if(!e.ok)return!1;let o=await e.json();if(o?.slots){for(let[n,s]of Object.entries(o.slots))S(document,n).innerHTML=h(String(s||""));return!0}return S(document,_).innerHTML=h(String(o?.html||"")),!0}catch(e){return console.debug?.("[RSC] payload fetch failed",e),!1}}async function dr(){try{let t=globalThis.window?.location.search??"",e=x(document);if(ar()){await N();return}let o=e?.pagePath,n=C(e);if(o){if(sr(globalThis.window,e,document)){console.debug?.("[RSC] Page renderer owns hydration");return}console.debug?.("[RSC] Found page component in hydration data:",o),await ur(o,n)&&console.debug?.("[RSC] Client component hydrated successfully");return}if(!ir(document,e))return;if(await lr(t)){await N();return}if(await gr(t)){await N();return}await N()}catch(t){console.error("[RSC] boot failed",t)}}if(typeof document<"u"){let t=()=>{dr()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}export{dr as boot,rr as selectHydrationRoot,ir as shouldAttemptRSCTransport,ar as shouldHydrateOnly,cr as shouldRenderPageComponent,sr as shouldUsePageRendererHydration,or as shouldWrapPageHydrationRoot};\n';
|
|
8
|
+
export const CLIENT_BOOT_BUNDLE = 'var ot=Object.defineProperty;var nt=(t,e,o)=>e in t?ot(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var m=(t,e,o)=>nt(t,typeof e!="symbol"?e+"":e,o);var st="3.2.3";function it(t,e,o,n){let s=[];if(n?.external?.length&&s.push(`external=${n.external.join(",")}`),s.push(`target=${n?.target??"es2022"}`),n?.deps){let d=Object.entries(n.deps).map(([l,p])=>`${l}@${p}`).join(",");s.push(`deps=${d}`)}let u=e?`@${e}`:"",c=o??"",i=s.length?`?${s.join("&")}`:"";return`https://esm.sh/${t}${u}${c}${i}`}function R(t,e,o,n=!1){return it(t,e,o,{external:n?["react"]:void 0,deps:{csstype:st}})}var ct="19.2.4",E=ct;function w(t=E){return{react:R("react",t),"react-dom":R("react-dom",t,void 0,!0),"react-dom/client":R("react-dom",t,"/client",!0),"react-dom/server":R("react-dom",t,"/server",!0),"react/jsx-runtime":R("react",t,"/jsx-runtime",!0),"react/jsx-dev-runtime":R("react",t,"/jsx-dev-runtime",!0)}}function V(t=E){return w(t).react}function H(t=E){return w(t)["react-dom/client"]}function lt(t){return t.replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}function D(t){return lt(btoa(t))}var Tr=Object.freeze({react:"","react-dom":"","react-dom/client":"","react-dom/server":"","react/jsx-runtime":"","react/jsx-dev-runtime":""});function v(t,e){if(!e)return!1;if(Object.prototype.hasOwnProperty.call(e,t))return!0;for(let o of Object.keys(e))if(o.endsWith("/")&&t.startsWith(o))return!0;return!1}function ut(t){try{return JSON.parse(t)?.imports??{}}catch{return{}}}function F(t=document){let e=t.querySelector(\'script[type="importmap"]\');return e?.textContent?ut(e.textContent):{}}var a="/_veryfront",b={RSC:`${a}/rsc/`,FS:`${a}/fs/`,MODULES:`${a}/modules/`,PAGES:`${a}/pages/`,DATA:`${a}/data/`,LIB:`${a}/lib/`,CHUNKS:`${a}/chunks/`,CLIENT:`${a}/client/`},G={HMR_RUNTIME:`${a}/hmr-runtime.js`,HMR:`${a}/hmr.js`,ERROR_OVERLAY:`${a}/error-overlay.js`,DEV_LOADER:`${a}/dev-loader.js`,CLIENT_LOG:`${a}/log`,CLIENT_JS:`${a}/client.js`,ROUTER_JS:`${a}/router.js`,PREFETCH_JS:`${a}/prefetch.js`,MANIFEST_JSON:`${a}/manifest.json`,APP_JS:`${a}/app.js`,RSC_CLIENT:`${a}/rsc/client.js`,RSC_MANIFEST:`${a}/rsc/manifest`,RSC_STREAM:`${a}/rsc/stream`,RSC_PAYLOAD:`${a}/rsc/payload`,RSC_RENDER:`${a}/rsc/render`,RSC_PAGE:`${a}/rsc/page`,RSC_MODULE:`${a}/rsc/module`,RSC_DOM:`${a}/rsc/dom.js`,LIB_CHAT_REACT:`${a}/lib/chat/react.js`,LIB_CHAT_COMPONENTS:`${a}/lib/chat/components.js`,LIB_CHAT_PRIMITIVES:`${a}/lib/chat/primitives.js`};var dt={ROOT:".veryfront",CACHE:".veryfront/cache",KV:".veryfront/kv",LOGS:".veryfront/logs",TMP:".veryfront/tmp"},Nr=dt.CACHE;var Dr={HMR_RUNTIME:G.HMR_RUNTIME,ERROR_OVERLAY:G.ERROR_OVERLAY};var y=b.RSC,k=b.FS,$="veryfront-hydration-data",_="rsc-root";function T(t=document){try{let e=t.getElementById($);return e?JSON.parse(e.textContent||"{}"):null}catch(e){return console.debug?.("[RSC] hydration data parse failed",e),null}}function C(t){return t?.clientModuleStrategy?t.clientModuleStrategy:t?.dev?"fs":"rsc-module"}function pt(t){return`${k}${D(t)}.js`}function mt(t,e){let o=e?`&v=${encodeURIComponent(e)}`:"";return`${y}module?rel=${encodeURIComponent(t)}${o}`}function I(t){if(t.strategy==="fs"){let e=t.absPath??t.rel;return e?pt(e):null}return mt(t.rel,t.version)}function O(t=document,e=E){let o=F(t);return{react:v("react",o)?"react":V(e),reactDomClient:v("react-dom/client",o)?"react-dom/client":H(e)}}function r(t){return{...t,create(e){return new M(e?.message||e?.detail||t.title,{slug:t.slug,category:t.category,status:e?.status??t.status,title:t.title,suggestion:t.suggestion,detail:e?.detail,cause:e?.cause,instance:e?.instance,context:e?.context})}}}var M=class extends Error{constructor(o,n){super(o);m(this,"slug");m(this,"category");m(this,"status");m(this,"title");m(this,"suggestion");m(this,"detail");m(this,"cause");m(this,"instance");m(this,"context");this.name="VeryfrontError",this.slug=n.slug,this.category=n.category,this.status=n.status,this.title=n.title,this.suggestion=n.suggestion,this.detail=n.detail,this.cause=n.cause,this.instance=n.instance,this.context=n.context}toRFC9457(){return{type:`https://veryfront.com/docs/errors/${this.slug}`,title:this.title,status:this.status,detail:this.detail,instance:this.instance,category:this.category,suggestion:this.suggestion,cause:typeof this.cause=="string"?this.cause:void 0}}getDocsUrl(){return`https://veryfront.com/docs/errors/${this.slug}`}};var Rt=r({slug:"config-not-found",category:"CONFIG",status:404,title:"Configuration file not found",suggestion:"Run \'vf init\' to create a configuration file"}),ft=r({slug:"config-invalid",category:"CONFIG",status:400,title:"Invalid configuration format",suggestion:"Check your veryfront.config.ts for syntax errors"}),Et=r({slug:"config-parse-error",category:"CONFIG",status:400,title:"Failed to parse configuration",suggestion:"Ensure your configuration file is valid TypeScript/JSON"}),yt=r({slug:"config-validation-error",category:"CONFIG",status:422,title:"Configuration validation failed",suggestion:"Check the configuration against the schema requirements"}),_t=r({slug:"config-type-error",category:"CONFIG",status:400,title:"Configuration type mismatch",suggestion:"Ensure configuration values match expected types"}),ht=r({slug:"import-map-invalid",category:"CONFIG",status:400,title:"Invalid import map configuration",suggestion:"Check your import map syntax and paths"}),St=r({slug:"cors-config-invalid",category:"CONFIG",status:400,title:"Invalid CORS configuration",suggestion:"Review CORS settings in your configuration"}),xt=r({slug:"config-validation-failed",category:"CONFIG",status:400,title:"Configuration validation failed",suggestion:"Check configuration values against requirements"}),Y={"config-not-found":Rt,"config-invalid":ft,"config-parse-error":Et,"config-validation-error":yt,"config-type-error":_t,"import-map-invalid":ht,"cors-config-invalid":St,"config-validation-failed":xt};var Tt=r({slug:"build-failed",category:"BUILD",status:500,title:"Build process failed",suggestion:"Check the build output for specific errors"}),Ct=r({slug:"bundle-error",category:"BUILD",status:500,title:"Bundle generation failed",suggestion:"Review bundler output for details"}),It=r({slug:"typescript-error",category:"BUILD",status:500,title:"TypeScript compilation error",suggestion:"Fix TypeScript errors shown in the output"}),Ot=r({slug:"mdx-compile-error",category:"BUILD",status:500,title:"MDX compilation failed",suggestion:"Check your MDX file syntax"}),At=r({slug:"asset-optimization-error",category:"BUILD",status:500,title:"Asset optimization failed",suggestion:"Check asset file formats and paths"}),Nt=r({slug:"ssg-generation-error",category:"BUILD",status:500,title:"Static site generation failed",suggestion:"Review SSG configuration and data fetching"}),Dt=r({slug:"sourcemap-error",category:"BUILD",status:500,title:"Source map generation failed",suggestion:"Check source map configuration"}),vt=r({slug:"compilation-error",category:"BUILD",status:500,title:"Compilation failed",suggestion:"Review compiler output for specific errors"}),B={"build-failed":Tt,"bundle-error":Ct,"typescript-error":It,"mdx-compile-error":Ot,"asset-optimization-error":At,"ssg-generation-error":Nt,"sourcemap-error":Dt,"compilation-error":vt};var bt=r({slug:"hydration-mismatch",category:"RUNTIME",status:500,title:"Client/server hydration mismatch",suggestion:"Ensure server and client render the same content"}),Mt=r({slug:"render-error",category:"RUNTIME",status:500,title:"Component render failed",suggestion:"Check component for runtime errors"}),Lt=r({slug:"component-error",category:"RUNTIME",status:500,title:"Component execution error",suggestion:"Review component logic and props"}),Ut=r({slug:"layout-not-found",category:"RUNTIME",status:404,title:"Layout component not found",suggestion:"Ensure layout file exists at the expected path"}),Pt=r({slug:"page-not-found",category:"RUNTIME",status:404,title:"Page component not found",suggestion:"Check that the page file exists in the routes directory"}),wt=r({slug:"api-error",category:"RUNTIME",status:500,title:"API route handler error",suggestion:"Review API route handler for errors"}),Vt=r({slug:"middleware-error",category:"RUNTIME",status:500,title:"Middleware execution error",suggestion:"Check middleware function for errors"}),j={"hydration-mismatch":bt,"render-error":Mt,"component-error":Lt,"layout-not-found":Ut,"page-not-found":Pt,"api-error":wt,"middleware-error":Vt};var Ht=r({slug:"route-conflict",category:"ROUTE",status:409,title:"Conflicting route definitions",suggestion:"Rename or reorganize conflicting route files"}),Ft=r({slug:"invalid-route-file",category:"ROUTE",status:400,title:"Invalid route file structure",suggestion:"Ensure route file exports required functions"}),Gt=r({slug:"route-handler-invalid",category:"ROUTE",status:400,title:"Invalid route handler export",suggestion:"Export a valid handler function from the route file"}),kt=r({slug:"dynamic-route-error",category:"ROUTE",status:500,title:"Dynamic route parsing failed",suggestion:"Check dynamic route segment syntax"}),$t=r({slug:"route-params-error",category:"ROUTE",status:400,title:"Route parameters invalid",suggestion:"Validate route parameter values"}),Yt=r({slug:"api-route-error",category:"ROUTE",status:500,title:"API route definition error",suggestion:"Review API route configuration"}),W={"route-conflict":Ht,"invalid-route-file":Ft,"route-handler-invalid":Gt,"dynamic-route-error":kt,"route-params-error":$t,"api-route-error":Yt};var Bt=r({slug:"module-not-found",category:"MODULE",status:404,title:"Module could not be resolved",suggestion:"Check the import path and ensure the module is installed"}),jt=r({slug:"import-resolution-error",category:"MODULE",status:500,title:"Import path resolution failed",suggestion:"Verify import paths and module configuration"}),Wt=r({slug:"circular-dependency",category:"MODULE",status:500,title:"Circular dependency detected",suggestion:"Refactor imports to break the circular dependency"}),qt=r({slug:"invalid-import",category:"MODULE",status:400,title:"Invalid import statement",suggestion:"Fix import syntax or path"}),zt=r({slug:"dependency-missing",category:"MODULE",status:404,title:"Required dependency not installed",suggestion:"Install the missing dependency with your package manager"}),Xt=r({slug:"version-mismatch",category:"MODULE",status:409,title:"Dependency version mismatch",suggestion:"Update dependencies to compatible versions"}),q={"module-not-found":Bt,"import-resolution-error":jt,"circular-dependency":Wt,"invalid-import":qt,"dependency-missing":zt,"version-mismatch":Xt};var Jt=r({slug:"port-in-use",category:"SERVER",status:409,title:"Server port already in use",suggestion:"Use a different port or stop the process using this port"}),Kt=r({slug:"server-start-error",category:"SERVER",status:500,title:"Server failed to start",suggestion:"Check server configuration and port availability"}),Zt=r({slug:"cache-error",category:"SERVER",status:500,title:"Cache operation failed",suggestion:"Clear the cache and try again"}),Qt=r({slug:"file-watch-error",category:"SERVER",status:500,title:"File watcher error",suggestion:"Restart the development server"}),te=r({slug:"request-error",category:"SERVER",status:500,title:"HTTP request handling error",suggestion:"Check request handler and middleware"}),ee=r({slug:"service-overloaded",category:"SERVER",status:503,title:"Service overloaded",suggestion:"Reduce load or scale up resources"}),re=r({slug:"semaphore-timeout",category:"SERVER",status:503,title:"Semaphore acquire timeout",suggestion:"Reduce concurrency or increase the semaphore acquire timeout"}),oe=r({slug:"circuit-breaker-open",category:"SERVER",status:503,title:"Circuit breaker is open",suggestion:"Wait for the breaker reset timeout before retrying"}),ne=r({slug:"cache-path-mismatch",category:"SERVER",status:500,title:"Cache path mismatch",suggestion:"Clear the cache directory and rebuild"}),se=r({slug:"network-error",category:"SERVER",status:502,title:"Network operation failed",suggestion:"Check network connectivity and retry"}),ie=r({slug:"api-client-error",category:"SERVER",status:500,title:"API client request failed",suggestion:"Check API connectivity and authentication"}),ae=r({slug:"token-storage-error",category:"SERVER",status:500,title:"Token storage operation failed",suggestion:"Check token storage backend and credentials"}),ce=r({slug:"cache-invariant-violation",category:"SERVER",status:500,title:"Cache path invariant violated",suggestion:"Clear the cache and rebuild"}),le=r({slug:"release-not-found",category:"SERVER",status:404,title:"No active release found",suggestion:"Deploy the project to create a release for this environment"}),ue=r({slug:"fallback-exhausted",category:"SERVER",status:500,title:"Primary and fallback operations both failed",suggestion:"Check service availability and connectivity"}),z={"port-in-use":Jt,"server-start-error":Kt,"cache-error":Zt,"file-watch-error":Qt,"request-error":te,"service-overloaded":ee,"semaphore-timeout":re,"circuit-breaker-open":oe,"cache-path-mismatch":ne,"network-error":se,"api-client-error":ie,"token-storage-error":ae,"cache-invariant-violation":ce,"release-not-found":le,"fallback-exhausted":ue};var ge=r({slug:"client-boundary-violation",category:"BOUNDARY",status:400,title:"Client boundary rule violation",suggestion:"Add \'use client\' directive or move code to a client component"}),de=r({slug:"server-only-in-client",category:"BOUNDARY",status:400,title:"Server-only code in client component",suggestion:"Move server-only code to a server component"}),pe=r({slug:"client-only-in-server",category:"BOUNDARY",status:400,title:"Client-only code in server component",suggestion:"Move client-only code to a client component"}),me=r({slug:"invalid-use-client",category:"BOUNDARY",status:400,title:"Invalid \'use client\' directive",suggestion:"Place \'use client\' at the top of the file"}),Re=r({slug:"invalid-use-server",category:"BOUNDARY",status:400,title:"Invalid \'use server\' directive",suggestion:"Place \'use server\' at the top of the file or function"}),fe=r({slug:"rsc-payload-error",category:"BOUNDARY",status:500,title:"RSC payload serialization error",suggestion:"Ensure props are serializable (no functions, symbols, etc.)"}),X={"client-boundary-violation":ge,"server-only-in-client":de,"client-only-in-server":pe,"invalid-use-client":me,"invalid-use-server":Re,"rsc-payload-error":fe};var Ee=r({slug:"hmr-error",category:"DEV",status:500,title:"Hot module replacement error",suggestion:"Restart the development server"}),ye=r({slug:"dev-server-error",category:"DEV",status:500,title:"Development server error",suggestion:"Check the dev server logs and restart"}),_e=r({slug:"fast-refresh-error",category:"DEV",status:500,title:"Fast refresh failed",suggestion:"Save the file again or restart the dev server"}),he=r({slug:"error-overlay-error",category:"DEV",status:500,title:"Error overlay failed",suggestion:"Check browser console for details"}),Se=r({slug:"source-map-error",category:"DEV",status:500,title:"Source map loading error",suggestion:"Rebuild or clear cache"}),J={"hmr-error":Ee,"dev-server-error":ye,"fast-refresh-error":_e,"error-overlay-error":he,"source-map-error":Se};var xe=r({slug:"deployment-error",category:"DEPLOY",status:500,title:"Deployment process failed",suggestion:"Check deployment logs for details"}),Te=r({slug:"platform-error",category:"DEPLOY",status:500,title:"Platform-specific error",suggestion:"Check platform documentation and requirements"}),Ce=r({slug:"env-var-missing",category:"DEPLOY",status:500,title:"Required environment variable missing",suggestion:"Set the required environment variable"}),Ie=r({slug:"production-build-required",category:"DEPLOY",status:400,title:"Production build required",suggestion:"Run \'vf build\' before deploying"}),K={"deployment-error":xe,"platform-error":Te,"env-var-missing":Ce,"production-build-required":Ie};var Oe=r({slug:"agent-error",category:"AGENT",status:500,title:"Agent operation error",suggestion:"Check agent configuration and logs"}),Ae=r({slug:"agent-not-found",category:"AGENT",status:404,title:"Agent not found",suggestion:"Verify the agent ID exists"}),Ne=r({slug:"agent-timeout",category:"AGENT",status:408,title:"Agent operation timed out",suggestion:"Increase timeout or simplify the request"}),De=r({slug:"agent-intent-error",category:"AGENT",status:400,title:"Agent intent parsing error",suggestion:"Rephrase the request more clearly"}),ve=r({slug:"orchestration-error",category:"AGENT",status:500,title:"Multi-agent orchestration error",suggestion:"Check agent coordination logic"}),be=r({slug:"cost-limit-exceeded",category:"AGENT",status:429,title:"Cost limit exceeded",suggestion:"Wait for the budget period to reset or increase the limit"}),Z={"agent-error":Oe,"agent-not-found":Ae,"agent-timeout":Ne,"agent-intent-error":De,"orchestration-error":ve,"cost-limit-exceeded":be};var Me=r({slug:"unknown-error",category:"GENERAL",status:500,title:"Unknown/unclassified error",suggestion:"Check logs for more details"}),Le=r({slug:"permission-denied",category:"GENERAL",status:403,title:"File/resource permission denied",suggestion:"Check file permissions and access rights"}),Ue=r({slug:"file-not-found",category:"GENERAL",status:404,title:"File not found",suggestion:"Verify the file path exists"}),Pe=r({slug:"resource-not-found",category:"GENERAL",status:404,title:"Requested resource not found",suggestion:"Verify the referenced resource ID or name exists"}),we=r({slug:"invalid-argument",category:"GENERAL",status:400,title:"Invalid function argument",suggestion:"Check argument types and values"}),Ve=r({slug:"timeout-error",category:"GENERAL",status:408,title:"Operation timed out",suggestion:"Increase timeout or optimize the operation"}),He=r({slug:"initialization-error",category:"GENERAL",status:500,title:"Initialization failed",suggestion:"Check initialization requirements and dependencies"}),Fe=r({slug:"not-supported",category:"GENERAL",status:501,title:"Feature not supported",suggestion:"Check documentation for supported features"}),L=r({slug:"security-violation",category:"GENERAL",status:403,title:"Security violation detected",suggestion:"Check for path traversal or unauthorized access attempts"}),Ge=r({slug:"input-validation-failed",category:"GENERAL",status:400,title:"Input validation failed",suggestion:"Check request input against validation rules"}),Q={"unknown-error":Me,"permission-denied":Le,"file-not-found":Ue,"resource-not-found":Pe,"invalid-argument":we,"timeout-error":Ve,"initialization-error":He,"not-supported":Fe,"security-violation":L,"input-validation-failed":Ge};var Ao={...Y,...B,...j,...W,...q,...z,...X,...J,...K,...Z,...Q};var ke=[{source:String.raw`<script[^>]*>[\\s\\S]*?<\\/script>`,flags:"gi",name:"inline script"},{source:String.raw`javascript:`,flags:"gi",name:"javascript: URL"},{source:String.raw`\\bon\\w+\\s*=`,flags:"gi",name:"event handler attribute"},{source:String.raw`data:\\s*text\\/html`,flags:"gi",name:"data: HTML URL"}];function $e(){return ke.map(({source:t,flags:e,name:o})=>({pattern:new RegExp(t,e),name:o}))}function Ye(){let t=globalThis;return t.__VERYFRONT_DEV__===!0||t.Deno?.env?.get?.("VERYFRONT_ENV")==="development"}function h(t,e={}){let{strict:o=!1,warn:n=!0}=e;for(let{pattern:s,name:u}of $e())if(s.lastIndex=0,!!s.test(t)&&(n&&console.warn(`[Security] Suspicious ${u} detected in server HTML`),o||!Ye()))throw L.create({detail:`Potentially unsafe HTML: ${u} detected`});return t}var f=class{constructor(e,o){this.prefix=e;this.level=o}log(e,o,n,...s){this.level>e||o?.(n,...s)}debug(e,...o){this.log(0,console.debug,`[${this.prefix}] DEBUG: ${e}`,...o)}info(e,...o){this.log(1,console.log,`[${this.prefix}] ${e}`,...o)}warn(e,...o){this.log(2,console.warn,`[${this.prefix}] WARN: ${e}`,...o)}error(e,...o){this.log(3,console.error,`[${this.prefix}] ERROR: ${e}`,...o)}};function Be(){if(typeof window>"u")return 2;let t=globalThis;return t.__VERYFRONT_DEV__||t.__RSC_DEV__?t.__VERYFRONT_DEBUG__||t.__RSC_DEBUG__?0:1:2}var A=Be(),g=new f("RSC",A),Bo=new f("PREFETCH",A),jo=new f("HYDRATE",A),Wo=new f("VERYFRONT",A);function S(t,e){let o=e==="root"?_:`rsc-slot-${e}`,n=t.getElementById(o);if(n)return n;let s=t.createElement("div");return s.id=o,t.body.appendChild(s),s}function je(t,e){if(e.type!=="slot")return;let o=S(t,e.id);o.innerHTML=h(String(e.html??""))}function tt(t,e){let o=e.split(`\n`),n=o.pop()??"";for(let s of o){let u=s.trim();if(!u)continue;let c;try{c=JSON.parse(u)}catch(d){g.debug("[client-dom] malformed NDJSON line",{line:u,error:d instanceof Error?d.message:String(d)});continue}if(!c||typeof c!="object")continue;let i=c;if(i.type==="slot"){je(t,i);try{ze(t,i.id||"root")}catch(d){g.debug("[client-dom] hydration optional failed",d)}}}return n}function We(t){return new Promise((e,o)=>{let n=()=>o(new DOMException("aborted","AbortError"));if(t.aborted){n();return}t.addEventListener("abort",n,{once:!0})})}async function et(t,e=document,o){let n="body"in t?t:null,s=n?.body??t;if(!s)return;let u=s.getReader(),c=new TextDecoder,i="",d=!1;try{for(;;){if(o?.aborted)throw new DOMException("aborted","AbortError");let l=u.read(),{done:p,value:x}=o?await Promise.race([l,We(o)]):await l;if(p){d=!0;break}i+=c.decode(x,{stream:!0}),i=tt(e,i)}i&&tt(e,`${i}\n`)}catch(l){throw l instanceof Error&&l.name==="AbortError"||g.debug("[client-dom] consumeNdjsonStream error",l),l}finally{try{await u.cancel()}catch(l){d||g.debug("[client-dom] reader.cancel failed",l)}try{u.releaseLock()}catch(l){g.debug("[client-dom] reader.releaseLock failed",l)}if(typeof s.cancel=="function")try{await s.cancel()}catch(l){g.debug("[client-dom] stream.cancel failed",l)}if(typeof n?.body?.cancel=="function")try{await n.body.cancel()}catch(l){g.debug("[client-dom] response.body.cancel failed",l)}}}function qe(t,e){let o=S(t,e),n=[],s=u=>{let c=u;c.dataset?.clientRef&&n.push(c);for(let i of u.children)s(i)};return s(o),n}function ze(t,e){let o=qe(t,e);for(let n of o){let s=n.dataset?.clientRef;s&&(n.dataset.hydrated="true",g.debug("[client-dom] marked for hydration",s))}}var Xe=100;function Je(t,e){if(globalThis.__VF_CLIENT_MOD_CACHE??(globalThis.__VF_CLIENT_MOD_CACHE=new Map),globalThis.__VF_CLIENT_MOD_CACHE.size>=Xe){let o=globalThis.__VF_CLIENT_MOD_CACHE.keys().next().value;o&&globalThis.__VF_CLIENT_MOD_CACHE.delete(o)}globalThis.__VF_CLIENT_MOD_CACHE.set(t,e)}function Ke(t){let e=t.match(/^\\/app\\/(.+)#([A-Za-z0-9_]+)$/);return e?{rel:`/${e[1]||""}`,exportName:e[2]||"default"}:null}async function Ze(){try{let t=await fetch("/_veryfront/rsc/manifest");return t.ok?await t.json():null}catch{return null}}async function Qe(t,e,o){let n=t.graphIds?.client.find(c=>c.rel===e)?.path,s=`${e}#${t.hash??""}`;try{let c=globalThis.__VF_CLIENT_MOD_CACHE?.get(s);if(c)return c}catch(c){g.debug("hydrate: cache get failed",c)}let u=I({strategy:o,rel:e,absPath:n,version:t.hash});if(!u)return null;try{let c=await import(u);try{Je(s,c)}catch(i){g.debug("hydrate: cache set failed",i)}return c}catch(c){return g.debug("hydrate: failed to import module",{moduleUrl:u,error:c}),null}}async function rt(t=document){let e=null;try{e=await Ze()}catch(i){g.debug("hydrate: fetch manifest failed",i)}if(!e){g.debug("hydrate: no manifest");return}let o=Array.from(t.querySelectorAll("[data-client-ref]"));try{let i=globalThis.__VF_MANIFEST_HASH;if(!o.some(l=>l.dataset?.hydrated!=="true")&&i&&e.hash&&i===e.hash)return}catch(i){g.debug("hydrate: hmr hash read failed",i)}if(o.length===0){try{globalThis.__VF_MANIFEST_HASH=e.hash??""}catch(i){g.debug("hydrate: set hash failed",i)}return}let n=C(T(t));try{if(globalThis.__VF_TEST_MODE__){globalThis.__VF_HYDRATE_CALLED=!0,globalThis.__VF_MANIFEST_HASH=e.hash??"";return}}catch(i){g.debug("hydrate: test mode flags failed",i)}let s=O(t),[{default:u},{createRoot:c}]=await Promise.all([import(s.react),import(s.reactDomClient)]);for(let i of o){let d=i.dataset?.clientRef??"";if(!d||i.dataset?.hydrated==="true")continue;let l=Ke(d);if(!l)continue;let p=await Qe(e,l.rel,n);if(!p)continue;let x=p[l.exportName]??p.default;if(typeof x=="function")try{c(i).render(u.createElement(x,{})),i.dataset.hydrated="true"}catch(P){g.warn("hydrate: render failed",P)}}try{globalThis.__VF_MANIFEST_HASH=e.hash??""}catch(i){g.debug("hydrate: set hash failed (post)",i)}}async function tr(){let t=O(document),[e,o]=await Promise.all([import(t.react),import(t.reactDomClient)]);return{React:e,ReactDOM:o}}var er=new Set(["SCRIPT","STYLE","NOSCRIPT","TEMPLATE"]);function U(t){let e=t.getAttribute("style")??"";return t.hasAttribute("data-veryfront-head")||t.hasAttribute("hidden")||/(?:^|;)\\s*display\\s*:\\s*none(?:\\s*;|$)/i.test(e)||er.has(t.tagName.toUpperCase())}function rr(t,e){return t.find(o=>o.tagName.toUpperCase()==="DIV"&&!!o.getAttribute("class")?.trim()&&!U(o))??e}function or(t,e){return t===e}function nr(t,e){let o=document.createElement("div");o.setAttribute("data-veryfront-hydration-root","page");let n=t.find(s=>!U(s));n?.parentNode===e?e.insertBefore(o,n):e.appendChild(o);for(let s of t)!U(s)&&s.parentNode===e&&o.appendChild(s);return o}function sr(t,e,o=document){return!!e?.pagePath&&typeof t?.__veryfrontRenderPage=="function"&&!!o.getElementById("root")}function ir(t,e){return e?.pagePath?!1:!!t.getElementById(_)}function ar(t=import.meta.url){try{return new URL(t,"http://veryfront.local").searchParams.get("hydrate")==="1"}catch{return!1}}function cr(t){return t==="rsc-module"}async function lr(t){try{let e=await fetch(y+"stream"+t);if(!e.ok||!e.body)return!1;let o=new AbortController;return addEventListener("pagehide",()=>o.abort(),{once:!0}),await et(e,document,o.signal),!0}catch(e){return console.debug?.("[RSC] tryStream failed",e),!1}}async function N(){try{await rt(document)}catch(t){console.debug?.("[RSC] hydration failed",t)}}async function ur(t,e){try{let{React:o,ReactDOM:n}=await tr(),s=I({strategy:e,rel:t});if(!s)return!1;console.debug?.("[RSC] Loading component from:",s);let c=(await import(s)).default;if(typeof c!="function")return console.debug?.("[RSC] Page component is not a function"),!1;let i=Array.from(document.body.children),d=rr(i,document.body),l=or(d,document.body)?nr(i,document.body):d,p=o.createElement(c,{});return cr(e)?n.createRoot(l).render(p):n.hydrateRoot(l,p,{identifierPrefix:"vf",onRecoverableError:()=>{}}),console.debug?.("[RSC] Page component hydrated successfully"),!0}catch(o){return console.error("[RSC] Page hydration failed",o),!1}}async function gr(t){try{let e=await fetch(y+"payload"+t);if(!e.ok)return!1;let o=await e.json();if(o?.slots){for(let[n,s]of Object.entries(o.slots))S(document,n).innerHTML=h(String(s||""));return!0}return S(document,_).innerHTML=h(String(o?.html||"")),!0}catch(e){return console.debug?.("[RSC] payload fetch failed",e),!1}}async function dr(){try{let t=globalThis.window?.location.search??"",e=T(document);if(ar()){await N();return}let o=e?.pagePath,n=C(e);if(o){if(sr(globalThis.window,e,document)){console.debug?.("[RSC] Page renderer owns hydration");return}console.debug?.("[RSC] Found page component in hydration data:",o),await ur(o,n)&&console.debug?.("[RSC] Client component hydrated successfully");return}if(!ir(document,e))return;if(await lr(t)){await N();return}if(await gr(t)){await N();return}await N()}catch(t){console.error("[RSC] boot failed",t)}}if(typeof document<"u"){let t=()=>{dr()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}export{dr as boot,rr as selectHydrationRoot,ir as shouldAttemptRSCTransport,ar as shouldHydrateOnly,cr as shouldRenderPageComponent,sr as shouldUsePageRendererHydration,or as shouldWrapPageHydrationRoot};\n';
|
|
9
9
|
export const CLIENT_DOM_BUNDLE = 'var G=Object.defineProperty;var F=(r,t,o)=>t in r?G(r,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[t]=o;var l=(r,t,o)=>F(r,typeof t!="symbol"?t+"":t,o);function e(r){return{...r,create(t){return new f(t?.message||t?.detail||r.title,{slug:r.slug,category:r.category,status:t?.status??r.status,title:r.title,suggestion:r.suggestion,detail:t?.detail,cause:t?.cause,instance:t?.instance,context:t?.context})}}}var f=class extends Error{constructor(o,s){super(o);l(this,"slug");l(this,"category");l(this,"status");l(this,"title");l(this,"suggestion");l(this,"detail");l(this,"cause");l(this,"instance");l(this,"context");this.name="VeryfrontError",this.slug=s.slug,this.category=s.category,this.status=s.status,this.title=s.title,this.suggestion=s.suggestion,this.detail=s.detail,this.cause=s.cause,this.instance=s.instance,this.context=s.context}toRFC9457(){return{type:`https://veryfront.com/docs/errors/${this.slug}`,title:this.title,status:this.status,detail:this.detail,instance:this.instance,category:this.category,suggestion:this.suggestion,cause:typeof this.cause=="string"?this.cause:void 0}}getDocsUrl(){return`https://veryfront.com/docs/errors/${this.slug}`}};var k=e({slug:"config-not-found",category:"CONFIG",status:404,title:"Configuration file not found",suggestion:"Run \'vf init\' to create a configuration file"}),w=e({slug:"config-invalid",category:"CONFIG",status:400,title:"Invalid configuration format",suggestion:"Check your veryfront.config.ts for syntax errors"}),Y=e({slug:"config-parse-error",category:"CONFIG",status:400,title:"Failed to parse configuration",suggestion:"Ensure your configuration file is valid TypeScript/JSON"}),H=e({slug:"config-validation-error",category:"CONFIG",status:422,title:"Configuration validation failed",suggestion:"Check the configuration against the schema requirements"}),B=e({slug:"config-type-error",category:"CONFIG",status:400,title:"Configuration type mismatch",suggestion:"Ensure configuration values match expected types"}),$=e({slug:"import-map-invalid",category:"CONFIG",status:400,title:"Invalid import map configuration",suggestion:"Check your import map syntax and paths"}),j=e({slug:"cors-config-invalid",category:"CONFIG",status:400,title:"Invalid CORS configuration",suggestion:"Review CORS settings in your configuration"}),q=e({slug:"config-validation-failed",category:"CONFIG",status:400,title:"Configuration validation failed",suggestion:"Check configuration values against requirements"}),y={"config-not-found":k,"config-invalid":w,"config-parse-error":Y,"config-validation-error":H,"config-type-error":B,"import-map-invalid":$,"cors-config-invalid":j,"config-validation-failed":q};var z=e({slug:"build-failed",category:"BUILD",status:500,title:"Build process failed",suggestion:"Check the build output for specific errors"}),W=e({slug:"bundle-error",category:"BUILD",status:500,title:"Bundle generation failed",suggestion:"Review bundler output for details"}),J=e({slug:"typescript-error",category:"BUILD",status:500,title:"TypeScript compilation error",suggestion:"Fix TypeScript errors shown in the output"}),X=e({slug:"mdx-compile-error",category:"BUILD",status:500,title:"MDX compilation failed",suggestion:"Check your MDX file syntax"}),K=e({slug:"asset-optimization-error",category:"BUILD",status:500,title:"Asset optimization failed",suggestion:"Check asset file formats and paths"}),Z=e({slug:"ssg-generation-error",category:"BUILD",status:500,title:"Static site generation failed",suggestion:"Review SSG configuration and data fetching"}),Q=e({slug:"sourcemap-error",category:"BUILD",status:500,title:"Source map generation failed",suggestion:"Check source map configuration"}),ee=e({slug:"compilation-error",category:"BUILD",status:500,title:"Compilation failed",suggestion:"Review compiler output for specific errors"}),O={"build-failed":z,"bundle-error":W,"typescript-error":J,"mdx-compile-error":X,"asset-optimization-error":K,"ssg-generation-error":Z,"sourcemap-error":Q,"compilation-error":ee};var te=e({slug:"hydration-mismatch",category:"RUNTIME",status:500,title:"Client/server hydration mismatch",suggestion:"Ensure server and client render the same content"}),re=e({slug:"render-error",category:"RUNTIME",status:500,title:"Component render failed",suggestion:"Check component for runtime errors"}),oe=e({slug:"component-error",category:"RUNTIME",status:500,title:"Component execution error",suggestion:"Review component logic and props"}),se=e({slug:"layout-not-found",category:"RUNTIME",status:404,title:"Layout component not found",suggestion:"Ensure layout file exists at the expected path"}),ne=e({slug:"page-not-found",category:"RUNTIME",status:404,title:"Page component not found",suggestion:"Check that the page file exists in the routes directory"}),ie=e({slug:"api-error",category:"RUNTIME",status:500,title:"API route handler error",suggestion:"Review API route handler for errors"}),ae=e({slug:"middleware-error",category:"RUNTIME",status:500,title:"Middleware execution error",suggestion:"Check middleware function for errors"}),T={"hydration-mismatch":te,"render-error":re,"component-error":oe,"layout-not-found":se,"page-not-found":ne,"api-error":ie,"middleware-error":ae};var ce=e({slug:"route-conflict",category:"ROUTE",status:409,title:"Conflicting route definitions",suggestion:"Rename or reorganize conflicting route files"}),ue=e({slug:"invalid-route-file",category:"ROUTE",status:400,title:"Invalid route file structure",suggestion:"Ensure route file exports required functions"}),le=e({slug:"route-handler-invalid",category:"ROUTE",status:400,title:"Invalid route handler export",suggestion:"Export a valid handler function from the route file"}),ge=e({slug:"dynamic-route-error",category:"ROUTE",status:500,title:"Dynamic route parsing failed",suggestion:"Check dynamic route segment syntax"}),pe=e({slug:"route-params-error",category:"ROUTE",status:400,title:"Route parameters invalid",suggestion:"Validate route parameter values"}),Ee=e({slug:"api-route-error",category:"ROUTE",status:500,title:"API route definition error",suggestion:"Review API route configuration"}),I={"route-conflict":ce,"invalid-route-file":ue,"route-handler-invalid":le,"dynamic-route-error":ge,"route-params-error":pe,"api-route-error":Ee};var Re=e({slug:"module-not-found",category:"MODULE",status:404,title:"Module could not be resolved",suggestion:"Check the import path and ensure the module is installed"}),de=e({slug:"import-resolution-error",category:"MODULE",status:500,title:"Import path resolution failed",suggestion:"Verify import paths and module configuration"}),fe=e({slug:"circular-dependency",category:"MODULE",status:500,title:"Circular dependency detected",suggestion:"Refactor imports to break the circular dependency"}),me=e({slug:"invalid-import",category:"MODULE",status:400,title:"Invalid import statement",suggestion:"Fix import syntax or path"}),_e=e({slug:"dependency-missing",category:"MODULE",status:404,title:"Required dependency not installed",suggestion:"Install the missing dependency with your package manager"}),ye=e({slug:"version-mismatch",category:"MODULE",status:409,title:"Dependency version mismatch",suggestion:"Update dependencies to compatible versions"}),x={"module-not-found":Re,"import-resolution-error":de,"circular-dependency":fe,"invalid-import":me,"dependency-missing":_e,"version-mismatch":ye};var Oe=e({slug:"port-in-use",category:"SERVER",status:409,title:"Server port already in use",suggestion:"Use a different port or stop the process using this port"}),Te=e({slug:"server-start-error",category:"SERVER",status:500,title:"Server failed to start",suggestion:"Check server configuration and port availability"}),Ie=e({slug:"cache-error",category:"SERVER",status:500,title:"Cache operation failed",suggestion:"Clear the cache and try again"}),xe=e({slug:"file-watch-error",category:"SERVER",status:500,title:"File watcher error",suggestion:"Restart the development server"}),he=e({slug:"request-error",category:"SERVER",status:500,title:"HTTP request handling error",suggestion:"Check request handler and middleware"}),Se=e({slug:"service-overloaded",category:"SERVER",status:503,title:"Service overloaded",suggestion:"Reduce load or scale up resources"}),Ne=e({slug:"semaphore-timeout",category:"SERVER",status:503,title:"Semaphore acquire timeout",suggestion:"Reduce concurrency or increase the semaphore acquire timeout"}),ve=e({slug:"circuit-breaker-open",category:"SERVER",status:503,title:"Circuit breaker is open",suggestion:"Wait for the breaker reset timeout before retrying"}),Ae=e({slug:"cache-path-mismatch",category:"SERVER",status:500,title:"Cache path mismatch",suggestion:"Clear the cache directory and rebuild"}),Ce=e({slug:"network-error",category:"SERVER",status:502,title:"Network operation failed",suggestion:"Check network connectivity and retry"}),De=e({slug:"api-client-error",category:"SERVER",status:500,title:"API client request failed",suggestion:"Check API connectivity and authentication"}),Le=e({slug:"token-storage-error",category:"SERVER",status:500,title:"Token storage operation failed",suggestion:"Check token storage backend and credentials"}),Ue=e({slug:"cache-invariant-violation",category:"SERVER",status:500,title:"Cache path invariant violated",suggestion:"Clear the cache and rebuild"}),be=e({slug:"release-not-found",category:"SERVER",status:404,title:"No active release found",suggestion:"Deploy the project to create a release for this environment"}),Me=e({slug:"fallback-exhausted",category:"SERVER",status:500,title:"Primary and fallback operations both failed",suggestion:"Check service availability and connectivity"}),h={"port-in-use":Oe,"server-start-error":Te,"cache-error":Ie,"file-watch-error":xe,"request-error":he,"service-overloaded":Se,"semaphore-timeout":Ne,"circuit-breaker-open":ve,"cache-path-mismatch":Ae,"network-error":Ce,"api-client-error":De,"token-storage-error":Le,"cache-invariant-violation":Ue,"release-not-found":be,"fallback-exhausted":Me};var Pe=e({slug:"client-boundary-violation",category:"BOUNDARY",status:400,title:"Client boundary rule violation",suggestion:"Add \'use client\' directive or move code to a client component"}),Ve=e({slug:"server-only-in-client",category:"BOUNDARY",status:400,title:"Server-only code in client component",suggestion:"Move server-only code to a server component"}),Ge=e({slug:"client-only-in-server",category:"BOUNDARY",status:400,title:"Client-only code in server component",suggestion:"Move client-only code to a client component"}),Fe=e({slug:"invalid-use-client",category:"BOUNDARY",status:400,title:"Invalid \'use client\' directive",suggestion:"Place \'use client\' at the top of the file"}),ke=e({slug:"invalid-use-server",category:"BOUNDARY",status:400,title:"Invalid \'use server\' directive",suggestion:"Place \'use server\' at the top of the file or function"}),we=e({slug:"rsc-payload-error",category:"BOUNDARY",status:500,title:"RSC payload serialization error",suggestion:"Ensure props are serializable (no functions, symbols, etc.)"}),S={"client-boundary-violation":Pe,"server-only-in-client":Ve,"client-only-in-server":Ge,"invalid-use-client":Fe,"invalid-use-server":ke,"rsc-payload-error":we};var Ye=e({slug:"hmr-error",category:"DEV",status:500,title:"Hot module replacement error",suggestion:"Restart the development server"}),He=e({slug:"dev-server-error",category:"DEV",status:500,title:"Development server error",suggestion:"Check the dev server logs and restart"}),Be=e({slug:"fast-refresh-error",category:"DEV",status:500,title:"Fast refresh failed",suggestion:"Save the file again or restart the dev server"}),$e=e({slug:"error-overlay-error",category:"DEV",status:500,title:"Error overlay failed",suggestion:"Check browser console for details"}),je=e({slug:"source-map-error",category:"DEV",status:500,title:"Source map loading error",suggestion:"Rebuild or clear cache"}),N={"hmr-error":Ye,"dev-server-error":He,"fast-refresh-error":Be,"error-overlay-error":$e,"source-map-error":je};var qe=e({slug:"deployment-error",category:"DEPLOY",status:500,title:"Deployment process failed",suggestion:"Check deployment logs for details"}),ze=e({slug:"platform-error",category:"DEPLOY",status:500,title:"Platform-specific error",suggestion:"Check platform documentation and requirements"}),We=e({slug:"env-var-missing",category:"DEPLOY",status:500,title:"Required environment variable missing",suggestion:"Set the required environment variable"}),Je=e({slug:"production-build-required",category:"DEPLOY",status:400,title:"Production build required",suggestion:"Run \'vf build\' before deploying"}),v={"deployment-error":qe,"platform-error":ze,"env-var-missing":We,"production-build-required":Je};var Xe=e({slug:"agent-error",category:"AGENT",status:500,title:"Agent operation error",suggestion:"Check agent configuration and logs"}),Ke=e({slug:"agent-not-found",category:"AGENT",status:404,title:"Agent not found",suggestion:"Verify the agent ID exists"}),Ze=e({slug:"agent-timeout",category:"AGENT",status:408,title:"Agent operation timed out",suggestion:"Increase timeout or simplify the request"}),Qe=e({slug:"agent-intent-error",category:"AGENT",status:400,title:"Agent intent parsing error",suggestion:"Rephrase the request more clearly"}),et=e({slug:"orchestration-error",category:"AGENT",status:500,title:"Multi-agent orchestration error",suggestion:"Check agent coordination logic"}),tt=e({slug:"cost-limit-exceeded",category:"AGENT",status:429,title:"Cost limit exceeded",suggestion:"Wait for the budget period to reset or increase the limit"}),A={"agent-error":Xe,"agent-not-found":Ke,"agent-timeout":Ze,"agent-intent-error":Qe,"orchestration-error":et,"cost-limit-exceeded":tt};var rt=e({slug:"unknown-error",category:"GENERAL",status:500,title:"Unknown/unclassified error",suggestion:"Check logs for more details"}),ot=e({slug:"permission-denied",category:"GENERAL",status:403,title:"File/resource permission denied",suggestion:"Check file permissions and access rights"}),st=e({slug:"file-not-found",category:"GENERAL",status:404,title:"File not found",suggestion:"Verify the file path exists"}),nt=e({slug:"resource-not-found",category:"GENERAL",status:404,title:"Requested resource not found",suggestion:"Verify the referenced resource ID or name exists"}),it=e({slug:"invalid-argument",category:"GENERAL",status:400,title:"Invalid function argument",suggestion:"Check argument types and values"}),at=e({slug:"timeout-error",category:"GENERAL",status:408,title:"Operation timed out",suggestion:"Increase timeout or optimize the operation"}),ct=e({slug:"initialization-error",category:"GENERAL",status:500,title:"Initialization failed",suggestion:"Check initialization requirements and dependencies"}),ut=e({slug:"not-supported",category:"GENERAL",status:501,title:"Feature not supported",suggestion:"Check documentation for supported features"}),m=e({slug:"security-violation",category:"GENERAL",status:403,title:"Security violation detected",suggestion:"Check for path traversal or unauthorized access attempts"}),lt=e({slug:"input-validation-failed",category:"GENERAL",status:400,title:"Input validation failed",suggestion:"Check request input against validation rules"}),C={"unknown-error":rt,"permission-denied":ot,"file-not-found":st,"resource-not-found":nt,"invalid-argument":it,"timeout-error":at,"initialization-error":ct,"not-supported":ut,"security-violation":m,"input-validation-failed":lt};var ur={...y,...O,...T,...I,...x,...h,...S,...N,...v,...A,...C};var gt=[{source:String.raw`<script[^>]*>[\\s\\S]*?<\\/script>`,flags:"gi",name:"inline script"},{source:String.raw`javascript:`,flags:"gi",name:"javascript: URL"},{source:String.raw`\\bon\\w+\\s*=`,flags:"gi",name:"event handler attribute"},{source:String.raw`data:\\s*text\\/html`,flags:"gi",name:"data: HTML URL"}];function pt(){return gt.map(({source:r,flags:t,name:o})=>({pattern:new RegExp(r,t),name:o}))}function Et(){let r=globalThis;return r.__VERYFRONT_DEV__===!0||r.Deno?.env?.get?.("VERYFRONT_ENV")==="development"}function D(r,t={}){let{strict:o=!1,warn:s=!0}=t;for(let{pattern:i,name:c}of pt())if(i.lastIndex=0,!!i.test(r)&&(s&&console.warn(`[Security] Suspicious ${c} detected in server HTML`),o||!Et()))throw m.create({detail:`Potentially unsafe HTML: ${c} detected`});return r}var R=class{constructor(t,o){this.prefix=t;this.level=o}log(t,o,s,...i){this.level>t||o?.(s,...i)}debug(t,...o){this.log(0,console.debug,`[${this.prefix}] DEBUG: ${t}`,...o)}info(t,...o){this.log(1,console.log,`[${this.prefix}] ${t}`,...o)}warn(t,...o){this.log(2,console.warn,`[${this.prefix}] WARN: ${t}`,...o)}error(t,...o){this.log(3,console.error,`[${this.prefix}] ERROR: ${t}`,...o)}};function Rt(){if(typeof window>"u")return 2;let r=globalThis;return r.__VERYFRONT_DEV__||r.__RSC_DEV__?r.__VERYFRONT_DEBUG__||r.__RSC_DEBUG__?0:1:2}var d=Rt(),p=new R("RSC",d),Nr=new R("PREFETCH",d),vr=new R("HYDRATE",d),Ar=new R("VERYFRONT",d);var n="/_veryfront",_={RSC:`${n}/rsc/`,FS:`${n}/fs/`,MODULES:`${n}/modules/`,PAGES:`${n}/pages/`,DATA:`${n}/data/`,LIB:`${n}/lib/`,CHUNKS:`${n}/chunks/`,CLIENT:`${n}/client/`},L={HMR_RUNTIME:`${n}/hmr-runtime.js`,HMR:`${n}/hmr.js`,ERROR_OVERLAY:`${n}/error-overlay.js`,DEV_LOADER:`${n}/dev-loader.js`,CLIENT_LOG:`${n}/log`,CLIENT_JS:`${n}/client.js`,ROUTER_JS:`${n}/router.js`,PREFETCH_JS:`${n}/prefetch.js`,MANIFEST_JSON:`${n}/manifest.json`,APP_JS:`${n}/app.js`,RSC_CLIENT:`${n}/rsc/client.js`,RSC_MANIFEST:`${n}/rsc/manifest`,RSC_STREAM:`${n}/rsc/stream`,RSC_PAYLOAD:`${n}/rsc/payload`,RSC_RENDER:`${n}/rsc/render`,RSC_PAGE:`${n}/rsc/page`,RSC_MODULE:`${n}/rsc/module`,RSC_DOM:`${n}/rsc/dom.js`,LIB_CHAT_REACT:`${n}/lib/chat/react.js`,LIB_CHAT_COMPONENTS:`${n}/lib/chat/components.js`,LIB_CHAT_PRIMITIVES:`${n}/lib/chat/primitives.js`};var ft={ROOT:".veryfront",CACHE:".veryfront/cache",KV:".veryfront/kv",LOGS:".veryfront/logs",TMP:".veryfront/tmp"},br=ft.CACHE;var Mr={HMR_RUNTIME:L.HMR_RUNTIME,ERROR_OVERLAY:L.ERROR_OVERLAY};var Fr=_.RSC,kr=_.FS;var U="rsc-root";function M(r,t){let o=t==="root"?U:`rsc-slot-${t}`,s=r.getElementById(o);if(s)return s;let i=r.createElement("div");return i.id=o,r.body.appendChild(i),i}function mt(r,t){if(t.type!=="slot")return;let o=M(r,t.id);o.innerHTML=D(String(t.html??""))}function b(r,t){let o=t.split(`\n`),s=o.pop()??"";for(let i of o){let c=i.trim();if(!c)continue;let g;try{g=JSON.parse(c)}catch(E){p.debug("[client-dom] malformed NDJSON line",{line:c,error:E instanceof Error?E.message:String(E)});continue}if(!g||typeof g!="object")continue;let u=g;if(u.type==="slot"){mt(r,u);try{Ot(r,u.id||"root")}catch(E){p.debug("[client-dom] hydration optional failed",E)}}}return s}function _t(r){return new Promise((t,o)=>{let s=()=>o(new DOMException("aborted","AbortError"));if(r.aborted){s();return}r.addEventListener("abort",s,{once:!0})})}async function $r(r,t=document,o){let s="body"in r?r:null,i=s?.body??r;if(!i)return;let c=i.getReader(),g=new TextDecoder,u="",E=!1;try{for(;;){if(o?.aborted)throw new DOMException("aborted","AbortError");let a=c.read(),{done:P,value:V}=o?await Promise.race([a,_t(o)]):await a;if(P){E=!0;break}u+=g.decode(V,{stream:!0}),u=b(t,u)}u&&b(t,`${u}\n`)}catch(a){throw a instanceof Error&&a.name==="AbortError"||p.debug("[client-dom] consumeNdjsonStream error",a),a}finally{try{await c.cancel()}catch(a){E||p.debug("[client-dom] reader.cancel failed",a)}try{c.releaseLock()}catch(a){p.debug("[client-dom] reader.releaseLock failed",a)}if(typeof i.cancel=="function")try{await i.cancel()}catch(a){p.debug("[client-dom] stream.cancel failed",a)}if(typeof s?.body?.cancel=="function")try{await s.body.cancel()}catch(a){p.debug("[client-dom] response.body.cancel failed",a)}}}function yt(r,t){let o=M(r,t),s=[],i=c=>{let g=c;g.dataset?.clientRef&&s.push(g);for(let u of c.children)i(u)};return i(o),s}function Ot(r,t){let o=yt(r,t);for(let s of o){let i=s.dataset?.clientRef;i&&(s.dataset.hydrated="true",p.debug("[client-dom] marked for hydration",i))}}export{$r as consumeNdjsonStream,M as getContainer};\n';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/src/skill/executor.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AA4EnG;;GAEG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAqBrF;AAED;;GAEG;AACH,qBAAa,mBAAoB,YAAW,mBAAmB;IACvD,OAAO,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAsB3E;
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/src/skill/executor.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AA4EnG;;GAEG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAqBrF;AAED;;GAEG;AACH,qBAAa,mBAAoB,YAAW,mBAAmB;IACvD,OAAO,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAsB3E;AAgED;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,mBAAmB,CAE5D"}
|
|
@@ -149,6 +149,9 @@ class CloudScriptExecutor {
|
|
|
149
149
|
const commandPromise = sandbox.executeCommand(cmdString);
|
|
150
150
|
const result = await withTimeout(commandPromise, timeoutMs);
|
|
151
151
|
if (result === TIMEOUT_SENTINEL) {
|
|
152
|
+
commandPromise.catch(() => {
|
|
153
|
+
// The command may reject after the timeout path has already returned.
|
|
154
|
+
});
|
|
152
155
|
// Kill any running processes before returning — withTimeout only
|
|
153
156
|
// races the timer, it doesn't terminate the sandbox command.
|
|
154
157
|
try {
|