veryfront 0.1.1114 → 0.1.1115
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/cli/commands/deploy/command.d.ts +3 -0
- package/esm/cli/commands/deploy/command.d.ts.map +1 -1
- package/esm/cli/commands/deploy/command.js +4 -4
- package/esm/cli/commands/up/command.d.ts +3 -0
- package/esm/cli/commands/up/command.d.ts.map +1 -1
- package/esm/cli/commands/up/command.js +4 -2
- package/esm/cli/skills/loader.d.ts +4 -4
- package/esm/cli/skills/loader.d.ts.map +1 -1
- package/esm/cli/skills/loader.js +6 -6
- package/esm/deno.js +1 -1
- package/esm/src/agent/runtime/index.d.ts.map +1 -1
- package/esm/src/agent/runtime/index.js +4 -8
- package/esm/src/data/server-data-fetcher.d.ts.map +1 -1
- package/esm/src/data/server-data-fetcher.js +5 -1
- package/esm/src/html/hydration-script-builder/templates/router.d.ts.map +1 -1
- package/esm/src/html/hydration-script-builder/templates/router.js +87 -24
- package/esm/src/rendering/orchestrator/pipeline.d.ts.map +1 -1
- package/esm/src/rendering/orchestrator/pipeline.js +26 -8
- package/esm/src/rendering/script-page-handling.js +1 -1
- package/esm/src/routing/api/module-loader/external-import-rewriter.js +1 -1
- package/esm/src/sandbox/lazy-sandbox.d.ts +1 -0
- package/esm/src/sandbox/lazy-sandbox.d.ts.map +1 -1
- package/esm/src/sandbox/lazy-sandbox.js +21 -5
- package/esm/src/server/handlers/request/module/page-data-endpoint-handler.d.ts.map +1 -1
- package/esm/src/server/handlers/request/module/page-data-endpoint-handler.js +6 -3
- package/esm/src/transforms/npm-import-rewrites.d.ts +3 -3
- package/esm/src/transforms/npm-import-rewrites.d.ts.map +1 -1
- package/esm/src/transforms/npm-import-rewrites.js +29 -14
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +5 -5
|
@@ -12,6 +12,7 @@ import { type ApiClient } from "../../shared/config.js";
|
|
|
12
12
|
* Schema factory for deploy command arguments
|
|
13
13
|
*/
|
|
14
14
|
export declare const getDeployArgsSchema: () => import("../../../src/internal-agents/schema.js").Schema<import("../../../src/extensions/schema/schema-validator.js").InferShape<{
|
|
15
|
+
projectDir: import("../../../src/internal-agents/schema.js").Schema<string | undefined>;
|
|
15
16
|
branch: import("../../../src/internal-agents/schema.js").Schema<string>;
|
|
16
17
|
env: import("../../../src/internal-agents/schema.js").Schema<string>;
|
|
17
18
|
releaseName: import("../../../src/internal-agents/schema.js").Schema<string | undefined>;
|
|
@@ -21,6 +22,7 @@ export declare const getDeployArgsSchema: () => import("../../../src/internal-ag
|
|
|
21
22
|
quiet: import("../../../src/internal-agents/schema.js").Schema<boolean>;
|
|
22
23
|
}>>;
|
|
23
24
|
export declare const DeployArgsSchema: import("../../../src/internal-agents/schema.js").Schema<import("../../../src/extensions/schema/schema-validator.js").InferShape<{
|
|
25
|
+
projectDir: import("../../../src/internal-agents/schema.js").Schema<string | undefined>;
|
|
24
26
|
branch: import("../../../src/internal-agents/schema.js").Schema<string>;
|
|
25
27
|
env: import("../../../src/internal-agents/schema.js").Schema<string>;
|
|
26
28
|
releaseName: import("../../../src/internal-agents/schema.js").Schema<string | undefined>;
|
|
@@ -37,6 +39,7 @@ export type DeployOptions = InferSchema<ReturnType<typeof getDeployArgsSchema>>;
|
|
|
37
39
|
* Parse CLI arguments into validated DeployOptions
|
|
38
40
|
*/
|
|
39
41
|
export declare const parseDeployArgs: (args: import("../../shared/types.js").ParsedArgs) => import("../../shared/args.js").SafeParseResult<import("../../../src/extensions/schema/schema-validator.js").InferShape<{
|
|
42
|
+
projectDir: import("../../../src/internal-agents/schema.js").Schema<string | undefined>;
|
|
40
43
|
branch: import("../../../src/internal-agents/schema.js").Schema<string>;
|
|
41
44
|
env: import("../../../src/internal-agents/schema.js").Schema<string>;
|
|
42
45
|
releaseName: import("../../../src/internal-agents/schema.js").Schema<string | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/deploy/command.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAE3E,OAAO,EAAE,KAAK,SAAS,EAA0C,MAAM,wBAAwB,CAAC;AAehG;;GAEG;AACH,eAAO,MAAM,mBAAmB
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/deploy/command.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAE3E,OAAO,EAAE,KAAK,SAAS,EAA0C,MAAM,wBAAwB,CAAC;AAehG;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;;IAQ5B,oDAAoD;;GAGvD,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;;;;IALzB,oDAAoD;;GAKO,CAAC;AAEhE;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;IAfxB,oDAAoD;;GAuBtD,CAAC;AAEH,wBAAgB,kCAAkC,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE1E;AAED;;GAEG;AACH,UAAU,qBAAqB;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE;QACP,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;KACrB,GAAG,IAAI,CAAC;CACV;AAED,UAAU,WAAW;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,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AClB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,OAAO,CAAC;CACvB,GAAG,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC,CAmBvD;AAED;;GAEG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CA2HzE"}
|
|
@@ -19,6 +19,7 @@ import { computeSourceDigest, getProjectTarget, normalizeControlPlane, readPushR
|
|
|
19
19
|
* Schema factory for deploy command arguments
|
|
20
20
|
*/
|
|
21
21
|
export const getDeployArgsSchema = defineSchema((v) => v.object({
|
|
22
|
+
projectDir: v.string().optional(),
|
|
22
23
|
branch: v.string().min(1).default("main"),
|
|
23
24
|
env: v.string().min(1).default("production"),
|
|
24
25
|
releaseName: v.string().min(1).optional(),
|
|
@@ -32,6 +33,7 @@ export const DeployArgsSchema = lazySchema(getDeployArgsSchema);
|
|
|
32
33
|
* Parse CLI arguments into validated DeployOptions
|
|
33
34
|
*/
|
|
34
35
|
export const parseDeployArgs = createArgParser(DeployArgsSchema, {
|
|
36
|
+
projectDir: CommonArgs.projectDir,
|
|
35
37
|
branch: CommonArgs.branch,
|
|
36
38
|
env: CommonArgs.env,
|
|
37
39
|
releaseName: CommonArgs.releaseName,
|
|
@@ -270,11 +272,10 @@ export async function resolvePushedSource(input) {
|
|
|
270
272
|
* Create a release and deploy to an environment
|
|
271
273
|
*/
|
|
272
274
|
export async function deployCommand(options) {
|
|
273
|
-
const { branch, env, releaseName, dryRun, force, quiet } = options;
|
|
275
|
+
const { projectDir = cwd(), branch, env, releaseName, dryRun, force, quiet } = options;
|
|
274
276
|
if (isJsonMode()) {
|
|
275
277
|
return deployCommandJson(options);
|
|
276
278
|
}
|
|
277
|
-
const projectDir = cwd();
|
|
278
279
|
let spinner = quiet ? createNoopSpinner() : createSpinner("Resolving configuration...");
|
|
279
280
|
const config = await resolveConfigWithAuth(projectDir);
|
|
280
281
|
const client = createApiClient(config);
|
|
@@ -377,7 +378,7 @@ export async function deployCommand(options) {
|
|
|
377
378
|
console.log(getPostDeployTips());
|
|
378
379
|
}
|
|
379
380
|
async function deployCommandJson(options) {
|
|
380
|
-
const { branch, env, releaseName, dryRun, force } = options;
|
|
381
|
+
const { projectDir = cwd(), branch, env, releaseName, dryRun, force } = options;
|
|
381
382
|
try {
|
|
382
383
|
// JSON mode requires --force or --yes to prevent accidental deploys
|
|
383
384
|
if (requiresExplicitDeployConfirmation(force)) {
|
|
@@ -391,7 +392,6 @@ async function deployCommandJson(options) {
|
|
|
391
392
|
return;
|
|
392
393
|
}
|
|
393
394
|
streamJsonLine({ type: "step", name: "resolve-config", status: "started" });
|
|
394
|
-
const projectDir = cwd();
|
|
395
395
|
const config = await resolveConfigWithAuth(projectDir);
|
|
396
396
|
const client = createApiClient(config);
|
|
397
397
|
streamJsonLine({ type: "step", name: "resolve-config", status: "completed" });
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import type { InferSchema } from "../../../src/extensions/schema/index.js";
|
|
2
2
|
import { type EnvironmentConfig } from "../../../src/config/index.js";
|
|
3
3
|
export declare const getUpArgsSchema: () => import("../../../src/internal-agents/schema.js").Schema<import("../../../src/extensions/schema/schema-validator.js").InferShape<{
|
|
4
|
+
projectDir: import("../../../src/internal-agents/schema.js").Schema<string | undefined>;
|
|
4
5
|
force: import("../../../src/internal-agents/schema.js").Schema<boolean>;
|
|
5
6
|
dryRun: import("../../../src/internal-agents/schema.js").Schema<boolean>;
|
|
6
7
|
}>>;
|
|
7
8
|
export declare const UpArgsSchema: import("../../../src/internal-agents/schema.js").Schema<import("../../../src/extensions/schema/schema-validator.js").InferShape<{
|
|
9
|
+
projectDir: import("../../../src/internal-agents/schema.js").Schema<string | undefined>;
|
|
8
10
|
force: import("../../../src/internal-agents/schema.js").Schema<boolean>;
|
|
9
11
|
dryRun: import("../../../src/internal-agents/schema.js").Schema<boolean>;
|
|
10
12
|
}>>;
|
|
11
13
|
export type UpOptions = InferSchema<ReturnType<typeof getUpArgsSchema>>;
|
|
12
14
|
export declare const parseUpArgs: (args: import("../../shared/types.js").ParsedArgs) => import("../../shared/args.js").SafeParseResult<import("../../../src/extensions/schema/schema-validator.js").InferShape<{
|
|
15
|
+
projectDir: import("../../../src/internal-agents/schema.js").Schema<string | undefined>;
|
|
13
16
|
force: import("../../../src/internal-agents/schema.js").Schema<boolean>;
|
|
14
17
|
dryRun: import("../../../src/internal-agents/schema.js").Schema<boolean>;
|
|
15
18
|
}>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/up/command.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAO3E,OAAO,EAAE,KAAK,iBAAiB,EAAwB,MAAM,8BAA8B,CAAC;AAS5F,eAAO,MAAM,eAAe
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/up/command.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAO3E,OAAO,EAAE,KAAK,iBAAiB,EAAwB,MAAM,8BAA8B,CAAC;AAS5F,eAAO,MAAM,eAAe;;;;GAM3B,CAAC;AAEF,eAAO,MAAM,YAAY;;;;GAA8B,CAAC;AAExD,MAAM,MAAM,SAAS,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC;AAExE,eAAO,MAAM,WAAW;;;;GAItB,CAAC;AAyEH,wBAAsB,SAAS,CAC7B,OAAO,GAAE,OAAO,CAAC,SAAS,CAAM,EAChC,GAAG,GAAE,iBAA0C,GAC9C,OAAO,CAAC,IAAI,CAAC,CA8Gf"}
|
|
@@ -14,11 +14,13 @@ import { resolveCliApiUrl } from "../../shared/constants.js";
|
|
|
14
14
|
import { pushCommand } from "../push/index.js";
|
|
15
15
|
import { deployCommand } from "../deploy/index.js";
|
|
16
16
|
export const getUpArgsSchema = defineSchema((v) => v.object({
|
|
17
|
+
projectDir: v.string().optional(),
|
|
17
18
|
force: v.boolean().default(false),
|
|
18
19
|
dryRun: v.boolean().default(false),
|
|
19
20
|
}));
|
|
20
21
|
export const UpArgsSchema = lazySchema(getUpArgsSchema);
|
|
21
22
|
export const parseUpArgs = createArgParser(UpArgsSchema, {
|
|
23
|
+
projectDir: CommonArgs.projectDir,
|
|
22
24
|
force: CommonArgs.force,
|
|
23
25
|
dryRun: CommonArgs.dryRun,
|
|
24
26
|
});
|
|
@@ -74,10 +76,9 @@ async function saveConfig(projectDir, config) {
|
|
|
74
76
|
await fs.writeTextFile(join(projectDir, "veryfront.json"), `${JSON.stringify(config, null, 2)}\n`);
|
|
75
77
|
}
|
|
76
78
|
export async function upCommand(options = {}, env = getEnvironmentConfig()) {
|
|
77
|
-
const { force = false, dryRun = false } = options;
|
|
79
|
+
const { projectDir = cwd(), force = false, dryRun = false } = options;
|
|
78
80
|
const useColor = shouldUseColor();
|
|
79
81
|
const c = (fn, s) => (useColor ? fn(s) : s);
|
|
80
|
-
const projectDir = cwd();
|
|
81
82
|
const userInfo = await ensureAuthenticated(env);
|
|
82
83
|
if (!userInfo)
|
|
83
84
|
return;
|
|
@@ -154,6 +155,7 @@ export async function upCommand(options = {}, env = getEnvironmentConfig()) {
|
|
|
154
155
|
cliLogger.info("");
|
|
155
156
|
try {
|
|
156
157
|
await deployCommand({
|
|
158
|
+
projectDir,
|
|
157
159
|
branch: "main",
|
|
158
160
|
env: "preview",
|
|
159
161
|
force: true,
|
|
@@ -2,12 +2,12 @@ import type { LoadedSkill } from "./types.js";
|
|
|
2
2
|
export declare function loadSkill(directory: string): Promise<LoadedSkill | null>;
|
|
3
3
|
export declare function listCoreSkills(): Promise<LoadedSkill[]>;
|
|
4
4
|
/**
|
|
5
|
-
* Scan the
|
|
5
|
+
* Scan the provided project directory for local skill directories.
|
|
6
6
|
* A local skill is any skills/<id>/ directory containing a SKILL.md file.
|
|
7
7
|
*/
|
|
8
|
-
export declare function listLocalSkills(): Promise<LoadedSkill[]>;
|
|
8
|
+
export declare function listLocalSkills(baseDir?: string): Promise<LoadedSkill[]>;
|
|
9
9
|
/**
|
|
10
|
-
* List all skills: core (built-in) + local (
|
|
10
|
+
* List all skills: core (built-in) + local (under baseDir).
|
|
11
11
|
*/
|
|
12
|
-
export declare function listAllSkills(): Promise<LoadedSkill[]>;
|
|
12
|
+
export declare function listAllSkills(baseDir?: string): Promise<LoadedSkill[]>;
|
|
13
13
|
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/cli/skills/loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAO9C,wBAAsB,SAAS,CAC7B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAW7B;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,CAqB7D;AAED;;;GAGG;AACH,wBAAsB,eAAe,
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/cli/skills/loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAO9C,wBAAsB,SAAS,CAC7B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAW7B;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,CAqB7D;AAED;;;GAGG;AACH,wBAAsB,eAAe,CAAC,OAAO,GAAE,MAAc,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAgBrF;AAED;;GAEG;AACH,wBAAsB,aAAa,CAAC,OAAO,GAAE,MAAc,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAqBnF"}
|
package/esm/cli/skills/loader.js
CHANGED
|
@@ -41,13 +41,13 @@ export async function listCoreSkills() {
|
|
|
41
41
|
return skills;
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
|
-
* Scan the
|
|
44
|
+
* Scan the provided project directory for local skill directories.
|
|
45
45
|
* A local skill is any skills/<id>/ directory containing a SKILL.md file.
|
|
46
46
|
*/
|
|
47
|
-
export async function listLocalSkills() {
|
|
47
|
+
export async function listLocalSkills(baseDir = cwd()) {
|
|
48
48
|
const fs = createFileSystem();
|
|
49
49
|
const skills = [];
|
|
50
|
-
const skillsDir = `${
|
|
50
|
+
const skillsDir = `${baseDir}/skills`;
|
|
51
51
|
try {
|
|
52
52
|
for await (const entry of fs.readDir(skillsDir)) {
|
|
53
53
|
if (!entry.isDirectory)
|
|
@@ -63,12 +63,12 @@ export async function listLocalSkills() {
|
|
|
63
63
|
return skills;
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
|
-
* List all skills: core (built-in) + local (
|
|
66
|
+
* List all skills: core (built-in) + local (under baseDir).
|
|
67
67
|
*/
|
|
68
|
-
export async function listAllSkills() {
|
|
68
|
+
export async function listAllSkills(baseDir = cwd()) {
|
|
69
69
|
const [core, local] = await Promise.all([
|
|
70
70
|
listCoreSkills(),
|
|
71
|
-
listLocalSkills(),
|
|
71
|
+
listLocalSkills(baseDir),
|
|
72
72
|
]);
|
|
73
73
|
// Deduplicate by name, local skills override core
|
|
74
74
|
const seen = new Set();
|
package/esm/deno.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,6BAA6B,EAClC,KAAK,aAAa,EAGlB,KAAK,OAAO,EAIZ,KAAK,QAAQ,EAGd,MAAM,aAAa,CAAC;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AAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,IAAI,CAAC;KAC9C,EACD,aAAa,CAAC,EAAE,MAAM,EACtB,uBAAuB,CAAC,EAAE,MAAM,EAChC,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IA0JtC;;OAEG;YACW,gBAAgB;IAugB9B;;;;OAIG;YACW,yBAAyB;IAuiBvC;;OAEG;YACW,eAAe;IAgC7B;;OAEG;YACW,mBAAmB;IAOjC;;OAEG;IACH,OAAO,CAAC,eAAe;IAKvB,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,sBAAsB;IAoB9B;;OAEG;IACH,SAAS,IAAI,MAAM,CAAC,OAAO,CAAC;IAI5B;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC;QAC9B,aAAa,EAAE,MAAM,CAAC;QACtB,eAAe,EAAE,MAAM,CAAC;QACxB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IAIF;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;CAGnC"}
|
|
@@ -761,7 +761,7 @@ export class AgentRuntime {
|
|
|
761
761
|
}
|
|
762
762
|
this.status = "tool_execution";
|
|
763
763
|
addSpanEvent(loopSpan, "tool_execution_start", { count: response.toolCalls.length });
|
|
764
|
-
|
|
764
|
+
const mustLoadSkillFirstForStep = !activeSkillPolicy &&
|
|
765
765
|
response.toolCalls.some((tc) => tc.toolName === LOAD_SKILL_TOOL_ID);
|
|
766
766
|
for (const tc of response.toolCalls) {
|
|
767
767
|
throwIfAborted(abortSignal);
|
|
@@ -830,7 +830,7 @@ export class AgentRuntime {
|
|
|
830
830
|
toolCalls.push(toolCall);
|
|
831
831
|
return;
|
|
832
832
|
}
|
|
833
|
-
const policyCheck = enforceSkillPolicy(tc.toolName, activeSkillPolicy,
|
|
833
|
+
const policyCheck = enforceSkillPolicy(tc.toolName, activeSkillPolicy, mustLoadSkillFirstForStep, {
|
|
834
834
|
hasSubmittedFormInput: hasSubmittedFormInputInLoop,
|
|
835
835
|
skillToolAvailability: activeSkillToolAvailability,
|
|
836
836
|
});
|
|
@@ -923,7 +923,6 @@ export class AgentRuntime {
|
|
|
923
923
|
activeSkillToolAvailability = extractSkillToolAvailability(result) ??
|
|
924
924
|
INACTIVE_SKILL_TOOL_AVAILABILITY;
|
|
925
925
|
activeSkillDelegationOverrides = extractSkillDelegationOverrides(result);
|
|
926
|
-
mustLoadSkillFirst = false;
|
|
927
926
|
}
|
|
928
927
|
activeSkillPolicy = removeFormInputAfterSubmission(tc.toolName, result, activeSkillId, activeSkillPolicy);
|
|
929
928
|
if (isSubmittedFormInputExecutionResult(tc.toolName, result)) {
|
|
@@ -1163,7 +1162,7 @@ export class AgentRuntime {
|
|
|
1163
1162
|
}
|
|
1164
1163
|
this.status = "tool_execution";
|
|
1165
1164
|
const streamedToolCalls = Array.from(state.toolCalls.values());
|
|
1166
|
-
|
|
1165
|
+
const mustLoadSkillFirstForStep = !activeSkillPolicy &&
|
|
1167
1166
|
streamedToolCalls.some((tc) => tc.name === LOAD_SKILL_TOOL_ID);
|
|
1168
1167
|
for (const tc of streamedToolCalls) {
|
|
1169
1168
|
throwIfAborted(abortSignal);
|
|
@@ -1220,7 +1219,6 @@ export class AgentRuntime {
|
|
|
1220
1219
|
activeSkillToolAvailability = extractSkillToolAvailability(matchingResult.output) ??
|
|
1221
1220
|
INACTIVE_SKILL_TOOL_AVAILABILITY;
|
|
1222
1221
|
activeSkillDelegationOverrides = extractSkillDelegationOverrides(matchingResult.output);
|
|
1223
|
-
mustLoadSkillFirst = false;
|
|
1224
1222
|
}
|
|
1225
1223
|
activeSkillPolicy = removeFormInputAfterSubmission(tc.name, matchingResult.output, activeSkillId, activeSkillPolicy);
|
|
1226
1224
|
if (isSubmittedFormInputExecutionResult(tc.name, matchingResult.output)) {
|
|
@@ -1246,7 +1244,6 @@ export class AgentRuntime {
|
|
|
1246
1244
|
activeSkillToolAvailability = extractSkillToolAvailability(persistedResult.result) ??
|
|
1247
1245
|
INACTIVE_SKILL_TOOL_AVAILABILITY;
|
|
1248
1246
|
activeSkillDelegationOverrides = extractSkillDelegationOverrides(persistedResult.result);
|
|
1249
|
-
mustLoadSkillFirst = false;
|
|
1250
1247
|
}
|
|
1251
1248
|
activeSkillPolicy = removeFormInputAfterSubmission(tc.name, persistedResult.result, activeSkillId, activeSkillPolicy);
|
|
1252
1249
|
if (isSubmittedFormInputExecutionResult(tc.name, persistedResult.result)) {
|
|
@@ -1288,7 +1285,7 @@ export class AgentRuntime {
|
|
|
1288
1285
|
await this.recordToolError(toolCall, `Invalid tool arguments: ${capturedInput.parseError}`, controller, encoder, currentMessages, toolCalls);
|
|
1289
1286
|
continue;
|
|
1290
1287
|
}
|
|
1291
|
-
const policyCheck = enforceSkillPolicy(tc.name, activeSkillPolicy,
|
|
1288
|
+
const policyCheck = enforceSkillPolicy(tc.name, activeSkillPolicy, mustLoadSkillFirstForStep, {
|
|
1292
1289
|
hasSubmittedFormInput: hasSubmittedFormInputInLoop,
|
|
1293
1290
|
skillToolAvailability: activeSkillToolAvailability,
|
|
1294
1291
|
});
|
|
@@ -1343,7 +1340,6 @@ export class AgentRuntime {
|
|
|
1343
1340
|
activeSkillToolAvailability = extractSkillToolAvailability(result) ??
|
|
1344
1341
|
INACTIVE_SKILL_TOOL_AVAILABILITY;
|
|
1345
1342
|
activeSkillDelegationOverrides = extractSkillDelegationOverrides(result);
|
|
1346
|
-
mustLoadSkillFirst = false;
|
|
1347
1343
|
}
|
|
1348
1344
|
activeSkillPolicy = removeFormInputAfterSubmission(tc.name, result, activeSkillId, activeSkillPolicy);
|
|
1349
1345
|
if (isSubmittedFormInputExecutionResult(tc.name, result)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-data-fetcher.d.ts","sourceRoot":"","sources":["../../../src/src/data/server-data-fetcher.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAcxE;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,2DAA2D;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,iBAAiB;IAC5B,KAAK,CACH,UAAU,EAAE,YAAY,EACxB,OAAO,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"server-data-fetcher.d.ts","sourceRoot":"","sources":["../../../src/src/data/server-data-fetcher.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAcxE;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,2DAA2D;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,iBAAiB;IAC5B,KAAK,CACH,UAAU,EAAE,YAAY,EACxB,OAAO,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,UAAU,CAAC;IA2FtB;;OAEG;YACW,aAAa;IAqE3B;;;OAGG;IACH,OAAO,CAAC,QAAQ;CAGjB"}
|
|
@@ -15,7 +15,9 @@ export class ServerDataFetcher {
|
|
|
15
15
|
}
|
|
16
16
|
const pathname = context.url?.pathname ?? "unknown";
|
|
17
17
|
const projectId = context.request?.headers?.get("x-project-id") ?? "default";
|
|
18
|
-
const
|
|
18
|
+
const isPrefetch = context.request?.headers?.get("x-veryfront-prefetch") === "1";
|
|
19
|
+
const breakerNamespace = isPrefetch ? "data-prefetch" : "data-fetch";
|
|
20
|
+
const circuitBreaker = getCircuitBreaker(`${breakerNamespace}:${projectId}`, {
|
|
19
21
|
failureThreshold: 5,
|
|
20
22
|
resetTimeoutMs: 30_000,
|
|
21
23
|
successThreshold: 2,
|
|
@@ -55,6 +57,7 @@ export class ServerDataFetcher {
|
|
|
55
57
|
serverLogger.warn("DATA_FETCH_CIRCUIT_OPEN circuit breaker open, failing fast", {
|
|
56
58
|
pathname,
|
|
57
59
|
projectId,
|
|
60
|
+
breakerNamespace,
|
|
58
61
|
retryAfterMs: error.nextAttemptMs,
|
|
59
62
|
});
|
|
60
63
|
throw error;
|
|
@@ -79,6 +82,7 @@ export class ServerDataFetcher {
|
|
|
79
82
|
"data.pathname": pathname,
|
|
80
83
|
"data.timeout_ms": DATA_FETCH_TIMEOUT_MS,
|
|
81
84
|
"data.project_id": projectId,
|
|
85
|
+
"data.prefetch": isPrefetch,
|
|
82
86
|
"data.isolated": useIsolation,
|
|
83
87
|
});
|
|
84
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../../../src/src/html/hydration-script-builder/templates/router.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../../../src/src/html/hydration-script-builder/templates/router.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,cA4sC3B,CAAC"}
|
|
@@ -39,6 +39,7 @@ export const getRouterScript = () => `
|
|
|
39
39
|
const IDLE_PREFETCH_DELAY_MS = 1200;
|
|
40
40
|
const IDLE_PREFETCH_MAX_LINKS = 4;
|
|
41
41
|
const VIEWPORT_PREFETCH_MAX_LINKS = 8;
|
|
42
|
+
const PAGE_DATA_PREFETCH_CONCURRENCY = 2;
|
|
42
43
|
const VIEWPORT_PREFETCH_ROOT_MARGIN = '200px';
|
|
43
44
|
const MAX_ROUTE_TIMINGS = 100;
|
|
44
45
|
const MAX_SERVER_TIMING_LENGTH = 1024;
|
|
@@ -54,6 +55,10 @@ export const getRouterScript = () => `
|
|
|
54
55
|
log(reason + ' failed:', path, message);
|
|
55
56
|
}
|
|
56
57
|
|
|
58
|
+
function isAbortError(error) {
|
|
59
|
+
return error?.name === 'AbortError';
|
|
60
|
+
}
|
|
61
|
+
|
|
57
62
|
function getDocumentNonce() {
|
|
58
63
|
const element = document.querySelector('script[nonce], style[nonce], link[nonce]');
|
|
59
64
|
if (!element) return undefined;
|
|
@@ -407,11 +412,16 @@ export const getRouterScript = () => `
|
|
|
407
412
|
async function fetchWithRetry(url, options, maxRetries = MAX_RETRIES) {
|
|
408
413
|
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
409
414
|
const controller = new AbortController();
|
|
415
|
+
const callerSignal = options.signal;
|
|
416
|
+
const abortFromCaller = () => controller.abort();
|
|
417
|
+
if (callerSignal?.aborted) controller.abort();
|
|
418
|
+
callerSignal?.addEventListener('abort', abortFromCaller, { once: true });
|
|
410
419
|
const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
|
411
420
|
|
|
412
421
|
try {
|
|
413
422
|
const response = await fetch(url, { ...options, signal: controller.signal });
|
|
414
423
|
clearTimeout(timeout);
|
|
424
|
+
callerSignal?.removeEventListener('abort', abortFromCaller);
|
|
415
425
|
|
|
416
426
|
if (response.ok) return response;
|
|
417
427
|
|
|
@@ -424,8 +434,9 @@ export const getRouterScript = () => `
|
|
|
424
434
|
return response;
|
|
425
435
|
} catch (error) {
|
|
426
436
|
clearTimeout(timeout);
|
|
437
|
+
callerSignal?.removeEventListener('abort', abortFromCaller);
|
|
427
438
|
|
|
428
|
-
if (error.name === 'AbortError' &&
|
|
439
|
+
if (error.name === 'AbortError' && callerSignal?.aborted) throw error;
|
|
429
440
|
if (attempt === maxRetries) throw error;
|
|
430
441
|
|
|
431
442
|
log('Fetch failed, retrying...', error.message);
|
|
@@ -450,10 +461,13 @@ export const getRouterScript = () => `
|
|
|
450
461
|
log('Fetching page data:', path);
|
|
451
462
|
perfStart('fetch:' + path);
|
|
452
463
|
|
|
464
|
+
const headers = options.prefetch
|
|
465
|
+
? { 'X-Veryfront-Prefetch': '1' }
|
|
466
|
+
: { 'X-Veryfront-Navigation': 'spa' };
|
|
453
467
|
const response = await fetchWithRetry(endpoint, {
|
|
454
|
-
headers
|
|
468
|
+
headers,
|
|
455
469
|
signal
|
|
456
|
-
});
|
|
470
|
+
}, options.prefetch ? 0 : MAX_RETRIES);
|
|
457
471
|
|
|
458
472
|
if (!response.ok) {
|
|
459
473
|
perfEnd('fetch:' + path);
|
|
@@ -504,11 +518,13 @@ export const getRouterScript = () => `
|
|
|
504
518
|
|
|
505
519
|
function startPageDataFetch(path, signal, options = {}) {
|
|
506
520
|
const request = fetchPageDataFresh(path, signal, options).finally(() => {
|
|
507
|
-
if (pendingPageDataFetches.get(path) === request) {
|
|
521
|
+
if (options.trackPending !== false && pendingPageDataFetches.get(path) === request) {
|
|
508
522
|
pendingPageDataFetches.delete(path);
|
|
509
523
|
}
|
|
510
524
|
});
|
|
511
|
-
|
|
525
|
+
if (options.trackPending !== false) {
|
|
526
|
+
pendingPageDataFetches.set(path, request);
|
|
527
|
+
}
|
|
512
528
|
return request;
|
|
513
529
|
}
|
|
514
530
|
|
|
@@ -555,12 +571,15 @@ export const getRouterScript = () => `
|
|
|
555
571
|
});
|
|
556
572
|
}
|
|
557
573
|
|
|
558
|
-
async function fetchPageDataForPrefetch(path) {
|
|
574
|
+
async function fetchPageDataForPrefetch(path, signal) {
|
|
559
575
|
if (getCachedPageData(path)) return;
|
|
560
|
-
return
|
|
576
|
+
return startPageDataFetch(path, signal, { prefetch: true, trackPending: false })
|
|
561
577
|
.then((data) => preloadModulesForPageData(data, path))
|
|
562
578
|
.catch((error) => {
|
|
563
|
-
|
|
579
|
+
if (!isAbortError(error)) {
|
|
580
|
+
logBackgroundFetchFailure('Page data prefetch', path, error);
|
|
581
|
+
}
|
|
582
|
+
throw error;
|
|
564
583
|
});
|
|
565
584
|
}
|
|
566
585
|
|
|
@@ -578,6 +597,9 @@ export const getRouterScript = () => `
|
|
|
578
597
|
|
|
579
598
|
if (isNavigating) return;
|
|
580
599
|
isNavigating = true;
|
|
600
|
+
const [navigationPath] = href.split('#');
|
|
601
|
+
removeQueuedPrefetch(navigationPath || href);
|
|
602
|
+
abortActiveSpeculativePrefetches();
|
|
581
603
|
|
|
582
604
|
currentAbortController = new AbortController();
|
|
583
605
|
const signal = currentAbortController.signal;
|
|
@@ -654,6 +676,7 @@ export const getRouterScript = () => `
|
|
|
654
676
|
} finally {
|
|
655
677
|
isNavigating = false;
|
|
656
678
|
currentAbortController = null;
|
|
679
|
+
processPageDataPrefetchQueue();
|
|
657
680
|
}
|
|
658
681
|
}
|
|
659
682
|
|
|
@@ -810,6 +833,9 @@ export const getRouterScript = () => `
|
|
|
810
833
|
const observedPrefetchLinks = new WeakSet();
|
|
811
834
|
const prefetchedPaths = new Set();
|
|
812
835
|
const inFlightPrefetches = new Set();
|
|
836
|
+
const queuedPrefetchPaths = new Set();
|
|
837
|
+
const pageDataPrefetchQueue = [];
|
|
838
|
+
const activePageDataPrefetchControllers = new Map();
|
|
813
839
|
|
|
814
840
|
function cancelScheduledPrefetch() {
|
|
815
841
|
if (prefetchTimeout) {
|
|
@@ -895,9 +921,58 @@ export const getRouterScript = () => `
|
|
|
895
921
|
}
|
|
896
922
|
}
|
|
897
923
|
|
|
924
|
+
function removeQueuedPrefetch(path) {
|
|
925
|
+
queuedPrefetchPaths.delete(path);
|
|
926
|
+
for (let i = pageDataPrefetchQueue.length - 1; i >= 0; i--) {
|
|
927
|
+
if (pageDataPrefetchQueue[i] === path) pageDataPrefetchQueue.splice(i, 1);
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
function abortActiveSpeculativePrefetches() {
|
|
932
|
+
for (const controller of activePageDataPrefetchControllers.values()) {
|
|
933
|
+
controller.abort();
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
function processPageDataPrefetchQueue() {
|
|
938
|
+
if (isNavigating) return;
|
|
939
|
+
|
|
940
|
+
while (
|
|
941
|
+
activePageDataPrefetchControllers.size < PAGE_DATA_PREFETCH_CONCURRENCY &&
|
|
942
|
+
pageDataPrefetchQueue.length > 0
|
|
943
|
+
) {
|
|
944
|
+
const href = pageDataPrefetchQueue.shift();
|
|
945
|
+
queuedPrefetchPaths.delete(href);
|
|
946
|
+
|
|
947
|
+
if (prefetchedPaths.has(href) || inFlightPrefetches.has(href) || getCachedPageData(href)) {
|
|
948
|
+
continue;
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
if (prefetchedPaths.size >= MAX_PREFETCH_PATHS) {
|
|
952
|
+
const oldest = prefetchedPaths.values().next().value;
|
|
953
|
+
if (oldest) prefetchedPaths.delete(oldest);
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
const controller = new AbortController();
|
|
957
|
+
prefetchedPaths.add(href);
|
|
958
|
+
inFlightPrefetches.add(href);
|
|
959
|
+
activePageDataPrefetchControllers.set(href, controller);
|
|
960
|
+
|
|
961
|
+
fetchPageDataForPrefetch(href, controller.signal)
|
|
962
|
+
.catch(() => {
|
|
963
|
+
prefetchedPaths.delete(href);
|
|
964
|
+
})
|
|
965
|
+
.finally(() => {
|
|
966
|
+
inFlightPrefetches.delete(href);
|
|
967
|
+
activePageDataPrefetchControllers.delete(href);
|
|
968
|
+
processPageDataPrefetchQueue();
|
|
969
|
+
});
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
|
|
898
973
|
function prefetchPage(href) {
|
|
899
974
|
if (isNavigating) return;
|
|
900
|
-
if (prefetchedPaths.has(href) || inFlightPrefetches.has(href)) return;
|
|
975
|
+
if (prefetchedPaths.has(href) || inFlightPrefetches.has(href) || queuedPrefetchPaths.has(href)) return;
|
|
901
976
|
|
|
902
977
|
const cachedPageData = getCachedPageData(href);
|
|
903
978
|
if (cachedPageData) {
|
|
@@ -907,21 +982,9 @@ export const getRouterScript = () => `
|
|
|
907
982
|
return;
|
|
908
983
|
}
|
|
909
984
|
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
}
|
|
914
|
-
|
|
915
|
-
prefetchedPaths.add(href);
|
|
916
|
-
inFlightPrefetches.add(href);
|
|
917
|
-
|
|
918
|
-
fetchPageDataForPrefetch(href)
|
|
919
|
-
.catch(() => {
|
|
920
|
-
prefetchedPaths.delete(href);
|
|
921
|
-
})
|
|
922
|
-
.finally(() => {
|
|
923
|
-
inFlightPrefetches.delete(href);
|
|
924
|
-
});
|
|
985
|
+
queuedPrefetchPaths.add(href);
|
|
986
|
+
pageDataPrefetchQueue.push(href);
|
|
987
|
+
processPageDataPrefetchQueue();
|
|
925
988
|
}
|
|
926
989
|
|
|
927
990
|
function prefetchEligibleRouteLinks(limit) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../../../src/src/rendering/orchestrator/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAUH,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,iCAAiC,CAAC;AASzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AA4DhF,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAE1D;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,UAAU,CAA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,EAAE,sBAAsB,CAAC;CAC1E;AAqCD,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,kBAAkB,CAAqB;IAC/C,OAAO,CAAC,mBAAmB,CAAgC;gBAE/C,MAAM,EAAE,oBAAoB;IAcxC,OAAO,CAAC,eAAe;IAQvB,OAAO,CAAC,oBAAoB;IA0B5B;;;;OAIG;YACW,yBAAyB;IAWvC;;;OAGG;IACH,gBAAgB,IAAI,IAAI;IAKxB,OAAO,CAAC,UAAU;YAOJ,0BAA0B;IAaxC;;;;;;;;;OASG;YACW,qBAAqB;IA6EnC;;;OAGG;YACW,mBAAmB;IAoHjC,OAAO,CAAC,uBAAuB;IAkCzB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IAqU9E,+EAA+E;IACzE,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC;YAsHzE,kBAAkB;YA2ClB,cAAc;IAW5B,OAAO,CAAC,uBAAuB;YAYjB,kBAAkB;IA6FhC,OAAO,CAAC,kBAAkB;YAQZ,uBAAuB;IAmBrC;;;;;;OAMG;IACH,OAAO,CAAC,aAAa;CAStB"}
|
|
@@ -51,6 +51,11 @@ const renderPipelineLog = logger.component("render-pipeline");
|
|
|
51
51
|
const resolvePageDataLog = logger.component("resolve-page-data");
|
|
52
52
|
// Re-export test helper for backward compatibility
|
|
53
53
|
export { __injectCssCacheForTests } from "./css-cache.js";
|
|
54
|
+
const PRE_RESOLVED_DATA = Symbol("veryfront.preResolvedData");
|
|
55
|
+
function stripInternalRenderOptions(options) {
|
|
56
|
+
const { [PRE_RESOLVED_DATA]: _preResolvedData, ...publicOptions } = options;
|
|
57
|
+
return publicOptions;
|
|
58
|
+
}
|
|
54
59
|
export class RenderPipeline {
|
|
55
60
|
config;
|
|
56
61
|
dataFetcher;
|
|
@@ -336,7 +341,18 @@ export class RenderPipeline {
|
|
|
336
341
|
: {};
|
|
337
342
|
let layoutDataMap = new Map();
|
|
338
343
|
const dataFetchStart = performance.now();
|
|
339
|
-
|
|
344
|
+
const internalPreResolvedData = options?.[PRE_RESOLVED_DATA];
|
|
345
|
+
const renderInputOptions = internalPreResolvedData && options
|
|
346
|
+
? stripInternalRenderOptions(options)
|
|
347
|
+
: options;
|
|
348
|
+
if (internalPreResolvedData) {
|
|
349
|
+
resolvedParams = internalPreResolvedData.params;
|
|
350
|
+
dataFetchingProps = Object.keys(internalPreResolvedData.pageProps).length > 0
|
|
351
|
+
? internalPreResolvedData.pageProps
|
|
352
|
+
: undefined;
|
|
353
|
+
layoutDataMap = internalPreResolvedData.layoutProps;
|
|
354
|
+
}
|
|
355
|
+
else if (options?.url && (options.request || options.staticDataOnly)) {
|
|
340
356
|
await profilePhase("render.data_fetching", () => withSpan("render.data_fetching", async () => {
|
|
341
357
|
try {
|
|
342
358
|
const dataResolution = await this.resolveDataFetching(slug, pageInfo.entity.path, layoutResult.nestedLayouts, options);
|
|
@@ -361,13 +377,13 @@ export class RenderPipeline {
|
|
|
361
377
|
const hasResolvedParams = Object.keys(resolvedParams).length > 0;
|
|
362
378
|
const mergedOptions = (dataFetchingProps || hasResolvedParams)
|
|
363
379
|
? {
|
|
364
|
-
...
|
|
380
|
+
...renderInputOptions,
|
|
365
381
|
...(hasResolvedParams ? { params: resolvedParams } : {}),
|
|
366
382
|
...(dataFetchingProps
|
|
367
|
-
? { props: { ...
|
|
383
|
+
? { props: { ...renderInputOptions?.props, ...dataFetchingProps } }
|
|
368
384
|
: {}),
|
|
369
385
|
}
|
|
370
|
-
:
|
|
386
|
+
: renderInputOptions;
|
|
371
387
|
const bundlePrepStart = performance.now();
|
|
372
388
|
const pageBundleResult = await profilePhase("render.prepare_bundles", () => withSpan("render.prepare_bundles", () => this.config.pageRenderer.preparePageBundles(pageInfo, slug, cacheResult?.cachedModule, mergedOptions), { "render.slug": slug }));
|
|
373
389
|
timing.bundlePrep = Math.round(performance.now() - bundlePrepStart);
|
|
@@ -512,7 +528,7 @@ export class RenderPipeline {
|
|
|
512
528
|
const appPath = pageIslandPlan
|
|
513
529
|
? undefined
|
|
514
530
|
: await profilePhase("page_data.resolve_app_path", () => this.resolveAppPath());
|
|
515
|
-
const { css, cssAction, cssError } = await profilePhase("page_data.resolve_css", () => this.resolvePageDataCss(slug, options, projectUpdatedAt));
|
|
531
|
+
const { css, cssAction, cssError } = await profilePhase("page_data.resolve_css", () => this.resolvePageDataCss(slug, options, projectUpdatedAt, dataResolution));
|
|
516
532
|
resolvePageDataLog.debug("Resolved page data", {
|
|
517
533
|
slug,
|
|
518
534
|
pagePath,
|
|
@@ -593,7 +609,7 @@ export class RenderPipeline {
|
|
|
593
609
|
const wrappedAdapter = fs.getUnderlyingAdapter();
|
|
594
610
|
return wrappedAdapter.getProjectData?.()?.updated_at;
|
|
595
611
|
}
|
|
596
|
-
async resolvePageDataCss(slug, options, projectUpdatedAt) {
|
|
612
|
+
async resolvePageDataCss(slug, options, projectUpdatedAt, dataResolution) {
|
|
597
613
|
if (this.hasReadyReleaseCss(options)) {
|
|
598
614
|
return { css: undefined, cssAction: "clear", cssError: undefined };
|
|
599
615
|
}
|
|
@@ -604,12 +620,14 @@ export class RenderPipeline {
|
|
|
604
620
|
return { css: cachedCss, cssAction: undefined, cssError: undefined };
|
|
605
621
|
}
|
|
606
622
|
try {
|
|
607
|
-
const
|
|
623
|
+
const cssRenderOptions = {
|
|
608
624
|
...options,
|
|
609
625
|
delivery: "string",
|
|
610
626
|
skipCacheCheck: true,
|
|
611
627
|
skipCachePersist: true,
|
|
612
|
-
|
|
628
|
+
[PRE_RESOLVED_DATA]: dataResolution,
|
|
629
|
+
};
|
|
630
|
+
const renderResult = await profilePhase("page_data.css.render_html", () => withTimeout(this.renderPage(slug, cssRenderOptions), CSS_SSR_TIMEOUT_MS, `CSS SSR for ${slug}`));
|
|
613
631
|
if (!renderResult?.html) {
|
|
614
632
|
return { css: undefined, cssAction: undefined, cssError: undefined };
|
|
615
633
|
}
|
|
@@ -261,5 +261,5 @@ async function loadScriptModule(modulePath, projectDir, adapter) {
|
|
|
261
261
|
const resolveDir = dirname(normalizedPath) || projectDir;
|
|
262
262
|
const transpiled = await transpileWithEsbuild(source, modulePath, resolveDir);
|
|
263
263
|
logger.debug(`Transpiled ${modulePath}`);
|
|
264
|
-
return importFromTempFile(fs, rewriteNpmImports(transpiled));
|
|
264
|
+
return importFromTempFile(fs, rewriteNpmImports(transpiled, projectDir));
|
|
265
265
|
}
|
|
@@ -419,7 +419,7 @@ export async function rewriteExternalImports(code, projectDir, fs, userDeps = ne
|
|
|
419
419
|
}
|
|
420
420
|
}
|
|
421
421
|
if (isDeno) {
|
|
422
|
-
transformed = rewriteNpmImports(transformed);
|
|
422
|
+
transformed = rewriteNpmImports(transformed, projectDir);
|
|
423
423
|
transformed = rewriteDenoNodeBuiltinImports(transformed);
|
|
424
424
|
// Rewrite user-installed npm dependencies.
|
|
425
425
|
// In non-compiled Deno: use npm: specifiers (resolved by Deno's npm support).
|
|
@@ -99,6 +99,7 @@ export declare class LazySandbox {
|
|
|
99
99
|
private waitForExecStartRetry;
|
|
100
100
|
private reprovisionAfterExecStartFailure;
|
|
101
101
|
private resolveRuntimeEndpointFor;
|
|
102
|
+
private shouldUseInternalDataPlane;
|
|
102
103
|
private resolveDataPlaneRoute;
|
|
103
104
|
private requireSessionId;
|
|
104
105
|
private authHeaders;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazy-sandbox.d.ts","sourceRoot":"","sources":["../../../src/src/sandbox/lazy-sandbox.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAE5B,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;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AI,GAAG,IAAI,MAAM,GAAG,IAAI,CAEvB;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;YAEa,gBAAgB;YAqBhB,uBAAuB;YAiCvB,oBAAoB;YAWpB,qBAAqB;YAkBrB,UAAU;YAiBV,mBAAmB;YA+BnB,4BAA4B;YAiC5B,YAAY;IAc1B,OAAO,CAAC,qBAAqB,CAAK;IAClC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,6BAA6B,CAAK;IAE1D,OAAO,CAAC,kBAAkB;IAqB1B,OAAO,CAAC,iBAAiB;YAMX,aAAa;IAU3B,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,iBAAiB;IAYzB,OAAO,CAAC,kBAAkB;YAKZ,6BAA6B;IAgB3C,OAAO,CAAC,8BAA8B;IAqBtC,OAAO,CAAC,kCAAkC;YAS5B,SAAS;YAkCT,cAAc;YAId,YAAY;IAI1B,OAAO,CAAC,qBAAqB;YAIf,gCAAgC;IAU9C,OAAO,CAAC,yBAAyB;IAKjC,OAAO,CAAC,0BAA0B;IASlC,OAAO,CAAC,qBAAqB;IAwB7B,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,WAAW;CAMpB"}
|
|
@@ -422,7 +422,9 @@ export class LazySandbox {
|
|
|
422
422
|
const readySession = session.status === "running"
|
|
423
423
|
? session
|
|
424
424
|
: await this.waitForReadySession(session.id);
|
|
425
|
-
|
|
425
|
+
if (this.shouldUseInternalDataPlane(readySession.endpoint, readySession.id)) {
|
|
426
|
+
await this.waitForRuntimeDataPlaneReady(readySession);
|
|
427
|
+
}
|
|
426
428
|
return readySession.endpoint;
|
|
427
429
|
}
|
|
428
430
|
async attachExistingSession(sessionId) {
|
|
@@ -653,14 +655,28 @@ export class LazySandbox {
|
|
|
653
655
|
return this.resolveRuntimeEndpointOption?.({ endpoint, sessionId }) ??
|
|
654
656
|
resolveDefaultSandboxRuntimeEndpoint({ endpoint });
|
|
655
657
|
}
|
|
658
|
+
shouldUseInternalDataPlane(endpoint, sessionId) {
|
|
659
|
+
if (!this.resolveRuntimeEndpointOption) {
|
|
660
|
+
return false;
|
|
661
|
+
}
|
|
662
|
+
const runtimeEndpoint = this.resolveRuntimeEndpointFor(endpoint, sessionId);
|
|
663
|
+
return normalizeDataPlaneBaseUrl(runtimeEndpoint) !== normalizeDataPlaneBaseUrl(endpoint);
|
|
664
|
+
}
|
|
656
665
|
resolveDataPlaneRoute() {
|
|
657
666
|
const endpoint = this.requireEndpoint();
|
|
658
667
|
const sessionId = this.requireSessionId();
|
|
668
|
+
if (!this.resolveRuntimeEndpointOption) {
|
|
669
|
+
return {
|
|
670
|
+
baseUrl: sandboxSessionRoute(this.apiUrl, sessionId),
|
|
671
|
+
kind: "proxy",
|
|
672
|
+
};
|
|
673
|
+
}
|
|
659
674
|
const runtimeEndpoint = this.resolveRuntimeEndpointFor(endpoint, sessionId);
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
675
|
+
if (normalizeDataPlaneBaseUrl(runtimeEndpoint) !== normalizeDataPlaneBaseUrl(endpoint)) {
|
|
676
|
+
return {
|
|
677
|
+
baseUrl: normalizeDataPlaneBaseUrl(runtimeEndpoint),
|
|
678
|
+
kind: "internal",
|
|
679
|
+
};
|
|
664
680
|
}
|
|
665
681
|
return {
|
|
666
682
|
baseUrl: sandboxSessionRoute(this.apiUrl, sessionId),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-data-endpoint-handler.d.ts","sourceRoot":"","sources":["../../../../../../src/src/server/handlers/request/module/page-data-endpoint-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AA8EhE,wBAAgB,oCAAoC,IAAI,IAAI,CAE3D;AAED,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,OAAO,EACZ,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,cAAc,EACnB,qBAAqB,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,eAAe,EAC/D,OAAO,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,aAAa,EAC9C,eAAe,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,GAC1C,OAAO,CAAC,aAAa,CAAC,
|
|
1
|
+
{"version":3,"file":"page-data-endpoint-handler.d.ts","sourceRoot":"","sources":["../../../../../../src/src/server/handlers/request/module/page-data-endpoint-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AA8EhE,wBAAgB,oCAAoC,IAAI,IAAI,CAE3D;AAED,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,OAAO,EACZ,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,cAAc,EACnB,qBAAqB,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,eAAe,EAC/D,OAAO,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,aAAa,EAC9C,eAAe,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,GAC1C,OAAO,CAAC,aAAa,CAAC,CAgHxB"}
|
|
@@ -58,9 +58,12 @@ export function handlePageDataEndpoint(req, pathname, ctx, createResponseBuilder
|
|
|
58
58
|
.replace(/\.json$/, "") || "";
|
|
59
59
|
const url = new URL(req.url);
|
|
60
60
|
const renderer = await getRendererForProject(ctx);
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
const isSpeculativePrefetch = req.headers.get("x-veryfront-prefetch") === "1";
|
|
62
|
+
// The request reaches server-data hooks, so prefetch work cannot safely
|
|
63
|
+
// populate or join the foreground response cache/singleflight.
|
|
64
|
+
const canUsePageDataCache = isPageDataCacheEnabled() &&
|
|
65
|
+
!requestHasCacheSensitiveState(req) && !isSpeculativePrefetch;
|
|
66
|
+
const cacheKey = canUsePageDataCache ? buildPageDataCacheKey(ctx, slug, url) : null;
|
|
64
67
|
const cachePolicy = cacheKey ? getPageDataCachePolicy(ctx) : null;
|
|
65
68
|
const payload = cacheKey
|
|
66
69
|
? await resolveCachedPageData(cacheKey, () => withTimeoutThrow(renderer.resolvePageData(slug, { request: req, url }), PAGE_DATA_TIMEOUT_MS, `resolvePageData for ${slug}`), cachePolicy)
|
|
@@ -10,15 +10,15 @@ interface RewriteRule {
|
|
|
10
10
|
declare function buildRules(importMap: Record<string, string>): RewriteRule[];
|
|
11
11
|
/**
|
|
12
12
|
* Returns rewrite rules derived from deno.json's import map.
|
|
13
|
-
* Rules are cached
|
|
13
|
+
* Rules are cached per resolved project directory.
|
|
14
14
|
*/
|
|
15
|
-
export declare function getNpmRewriteRules(): RewriteRule[];
|
|
15
|
+
export declare function getNpmRewriteRules(baseDir?: string): RewriteRule[];
|
|
16
16
|
/**
|
|
17
17
|
* Apply npm import rewrites to source code.
|
|
18
18
|
* Rewrites bare specifiers to pinned npm: versions from deno.json.
|
|
19
19
|
* No-op on Node.js where bare specifiers resolve via node_modules.
|
|
20
20
|
*/
|
|
21
|
-
export declare function rewriteNpmImports(source: string): string;
|
|
21
|
+
export declare function rewriteNpmImports(source: string, baseDir?: string): string;
|
|
22
22
|
/** Exported for testing */
|
|
23
23
|
export { buildRules, REWRITABLE_PACKAGES };
|
|
24
24
|
/** @internal Reset cached rules — only for testing */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"npm-import-rewrites.d.ts","sourceRoot":"","sources":["../../../src/src/transforms/npm-import-rewrites.ts"],"names":[],"mappings":"AAgBA;;;GAGG;AACH,QAAA,MAAM,mBAAmB,aAAc,CAAC;AAExC,UAAU,WAAW;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB;AAQD,iBAAS,UAAU,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,WAAW,EAAE,CA6BpE;
|
|
1
|
+
{"version":3,"file":"npm-import-rewrites.d.ts","sourceRoot":"","sources":["../../../src/src/transforms/npm-import-rewrites.ts"],"names":[],"mappings":"AAgBA;;;GAGG;AACH,QAAA,MAAM,mBAAmB,aAAc,CAAC;AAExC,UAAU,WAAW;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB;AAQD,iBAAS,UAAU,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,WAAW,EAAE,CA6BpE;AAyBD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,MAAc,GAAG,WAAW,EAAE,CASzE;AAID;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,MAAc,GAAG,MAAM,CAOjF;AAED,2BAA2B;AAC3B,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,CAAC;AAE3C,sDAAsD;AACtD,wBAAgB,WAAW,IAAI,IAAI,CAElC"}
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import * as dntShim from "../../_dnt.shims.js";
|
|
12
12
|
import { cwd } from "../platform/compat/process.js";
|
|
13
|
-
import { join } from "../platform/compat/path/index.js";
|
|
13
|
+
import { join, resolve } from "../platform/compat/path/index.js";
|
|
14
14
|
/**
|
|
15
15
|
* Bare specifiers that should be rewritten to their pinned npm: versions.
|
|
16
16
|
* Each must have a corresponding entry in deno.json's import map.
|
|
17
17
|
*/
|
|
18
18
|
const REWRITABLE_PACKAGES = [];
|
|
19
|
-
let cachedRules;
|
|
19
|
+
let cachedRules = new Map();
|
|
20
20
|
function escapeForRegex(pkg) {
|
|
21
21
|
return pkg.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
22
22
|
}
|
|
@@ -46,9 +46,9 @@ function buildRules(importMap) {
|
|
|
46
46
|
}
|
|
47
47
|
return rules;
|
|
48
48
|
}
|
|
49
|
-
function loadImportMapSync() {
|
|
49
|
+
function loadImportMapSync(baseDir = cwd()) {
|
|
50
50
|
try {
|
|
51
|
-
const denoJsonPath = join(
|
|
51
|
+
const denoJsonPath = join(baseDir, "deno.json");
|
|
52
52
|
const content = dntShim.Deno.readTextFileSync(denoJsonPath);
|
|
53
53
|
const config = JSON.parse(content);
|
|
54
54
|
return config.imports ?? {};
|
|
@@ -58,16 +58,31 @@ function loadImportMapSync() {
|
|
|
58
58
|
return {};
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
+
function resolveProjectDir(baseDir) {
|
|
62
|
+
const resolvedBaseDir = resolve(baseDir);
|
|
63
|
+
let canonicalBaseDir = resolvedBaseDir;
|
|
64
|
+
try {
|
|
65
|
+
canonicalBaseDir = dntShim.Deno.realPathSync(resolvedBaseDir);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// expected: user projects may not exist yet in some compiled-binary paths
|
|
69
|
+
}
|
|
70
|
+
return canonicalBaseDir;
|
|
71
|
+
}
|
|
61
72
|
/**
|
|
62
73
|
* Returns rewrite rules derived from deno.json's import map.
|
|
63
|
-
* Rules are cached
|
|
74
|
+
* Rules are cached per resolved project directory.
|
|
64
75
|
*/
|
|
65
|
-
export function getNpmRewriteRules() {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
76
|
+
export function getNpmRewriteRules(baseDir = cwd()) {
|
|
77
|
+
const projectDir = resolveProjectDir(baseDir);
|
|
78
|
+
const cacheKey = projectDir;
|
|
79
|
+
const cached = cachedRules.get(cacheKey);
|
|
80
|
+
if (cached)
|
|
81
|
+
return cached;
|
|
82
|
+
const importMap = loadImportMapSync(projectDir);
|
|
83
|
+
const rules = buildRules(importMap);
|
|
84
|
+
cachedRules.set(cacheKey, rules);
|
|
85
|
+
return rules;
|
|
71
86
|
}
|
|
72
87
|
const isDeno = typeof dntShim.dntGlobalThis.Deno !== "undefined";
|
|
73
88
|
/**
|
|
@@ -75,11 +90,11 @@ const isDeno = typeof dntShim.dntGlobalThis.Deno !== "undefined";
|
|
|
75
90
|
* Rewrites bare specifiers to pinned npm: versions from deno.json.
|
|
76
91
|
* No-op on Node.js where bare specifiers resolve via node_modules.
|
|
77
92
|
*/
|
|
78
|
-
export function rewriteNpmImports(source) {
|
|
93
|
+
export function rewriteNpmImports(source, baseDir = cwd()) {
|
|
79
94
|
if (!isDeno)
|
|
80
95
|
return source;
|
|
81
96
|
let result = source;
|
|
82
|
-
for (const { pattern, replacement } of getNpmRewriteRules()) {
|
|
97
|
+
for (const { pattern, replacement } of getNpmRewriteRules(baseDir)) {
|
|
83
98
|
result = result.replace(pattern, replacement);
|
|
84
99
|
}
|
|
85
100
|
return result;
|
|
@@ -88,5 +103,5 @@ export function rewriteNpmImports(source) {
|
|
|
88
103
|
export { buildRules, REWRITABLE_PACKAGES };
|
|
89
104
|
/** @internal Reset cached rules — only for testing */
|
|
90
105
|
export function _resetCache() {
|
|
91
|
-
cachedRules =
|
|
106
|
+
cachedRules = new Map();
|
|
92
107
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "veryfront",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1115",
|
|
4
4
|
"description": "The simplest way to build AI-powered apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -332,10 +332,10 @@
|
|
|
332
332
|
"@types/react": "19.2.14",
|
|
333
333
|
"@types/react-dom": "19.2.3",
|
|
334
334
|
"ws": "8.21.0",
|
|
335
|
-
"@veryfront/ext-bundler-esbuild": "0.1.
|
|
336
|
-
"@veryfront/ext-content-mdx": "0.1.
|
|
337
|
-
"@veryfront/ext-css-tailwind": "0.1.
|
|
338
|
-
"@veryfront/ext-parser-babel": "0.1.
|
|
335
|
+
"@veryfront/ext-bundler-esbuild": "0.1.1115",
|
|
336
|
+
"@veryfront/ext-content-mdx": "0.1.1115",
|
|
337
|
+
"@veryfront/ext-css-tailwind": "0.1.1115",
|
|
338
|
+
"@veryfront/ext-parser-babel": "0.1.1115"
|
|
339
339
|
},
|
|
340
340
|
"devDependencies": {
|
|
341
341
|
"@types/node": "20.9.0"
|