veryfront 0.1.630 → 0.1.631
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/agent/ag-ui/handler.d.ts.map +1 -1
- package/esm/src/agent/ag-ui/handler.js +36 -3
- package/esm/src/agent/ag-ui/runtime-chat-stream-encoder.d.ts.map +1 -1
- package/esm/src/agent/ag-ui/runtime-chat-stream-encoder.js +9 -1
- package/esm/src/agent/hosted/child-fork-execution-runner.d.ts.map +1 -1
- package/esm/src/agent/hosted/child-fork-execution-runner.js +1 -0
- package/esm/src/agent/hosted/child-fork-step-message-preparation.d.ts.map +1 -1
- package/esm/src/agent/hosted/child-requested-tools.d.ts +1 -0
- package/esm/src/agent/hosted/child-requested-tools.d.ts.map +1 -1
- package/esm/src/agent/hosted/child-requested-tools.js +15 -5
- package/esm/src/agent/react/use-chat/streaming/handler.d.ts.map +1 -1
- package/esm/src/agent/react/use-chat/streaming/handler.js +32 -3
- package/esm/src/agent/react/use-chat/streaming/parts-builder.d.ts +2 -2
- package/esm/src/agent/react/use-chat/streaming/parts-builder.d.ts.map +1 -1
- package/esm/src/agent/react/use-chat/streaming/parts-builder.js +8 -1
- package/esm/src/agent/react/use-chat/streaming/types.d.ts +4 -0
- package/esm/src/agent/react/use-chat/streaming/types.d.ts.map +1 -1
- package/esm/src/agent/react/use-chat/types.d.ts +2 -2
- package/esm/src/agent/react/use-chat/types.d.ts.map +1 -1
- package/esm/src/agent/runtime/chat-stream-handler.d.ts +2 -0
- package/esm/src/agent/runtime/chat-stream-handler.d.ts.map +1 -1
- package/esm/src/agent/runtime/chat-stream-handler.js +151 -15
- package/esm/src/agent/runtime/index.d.ts +15 -0
- package/esm/src/agent/runtime/index.d.ts.map +1 -1
- package/esm/src/agent/runtime/index.js +55 -1
- package/esm/src/agent/runtime/provider-native-tool-inventory.d.ts +1 -1
- package/esm/src/agent/runtime/provider-native-tool-inventory.d.ts.map +1 -1
- package/esm/src/agent/runtime/provider-native-tool-inventory.js +2 -7
- package/esm/src/agent/runtime/runtime-tool-types.d.ts +11 -0
- package/esm/src/agent/runtime/runtime-tool-types.d.ts.map +1 -1
- package/esm/src/agent/streaming/fork-runtime-stream.d.ts +1 -0
- package/esm/src/agent/streaming/fork-runtime-stream.d.ts.map +1 -1
- package/esm/src/agent/streaming/fork-runtime-stream.js +7 -5
- package/esm/src/agent/streaming/tool-execution-data-event-bridge.d.ts.map +1 -1
- package/esm/src/agent/streaming/tool-execution-data-event-bridge.js +4 -0
- package/esm/src/cache/registry.d.ts +13 -2
- package/esm/src/cache/registry.d.ts.map +1 -1
- package/esm/src/channels/control-plane.d.ts +9 -7
- package/esm/src/channels/control-plane.d.ts.map +1 -1
- package/esm/src/channels/control-plane.js +3 -1
- package/esm/src/channels/invoke.d.ts +2 -2
- package/esm/src/chat/protocol.d.ts +6 -1
- package/esm/src/chat/protocol.d.ts.map +1 -1
- package/esm/src/discovery/import-rewriter.d.ts.map +1 -1
- package/esm/src/discovery/import-rewriter.js +8 -1
- package/esm/src/embedding/veryfront-cloud/rag-store.d.ts.map +1 -1
- package/esm/src/embedding/veryfront-cloud/rag-store.js +4 -1
- package/esm/src/html/hydration-script-builder/hydration-data-generator.d.ts.map +1 -1
- package/esm/src/html/hydration-script-builder/hydration-data-generator.js +5 -1
- package/esm/src/html/utils.d.ts.map +1 -1
- package/esm/src/html/utils.js +11 -1
- package/esm/src/internal-agents/control-plane-auth.d.ts +3 -2
- package/esm/src/internal-agents/control-plane-auth.d.ts.map +1 -1
- package/esm/src/internal-agents/control-plane-auth.js +1 -1
- package/esm/src/mcp/server.d.ts.map +1 -1
- package/esm/src/mcp/server.js +8 -2
- package/esm/src/modules/react-loader/ssr-module-loader/cache/memory.d.ts.map +1 -1
- package/esm/src/modules/react-loader/ssr-module-loader/cache/memory.js +1 -0
- package/esm/src/platform/adapters/fs/veryfront/proxy-manager.d.ts.map +1 -1
- package/esm/src/platform/adapters/fs/veryfront/proxy-manager.js +2 -1
- package/esm/src/platform/compat/fs.d.ts.map +1 -1
- package/esm/src/platform/compat/fs.js +27 -27
- package/esm/src/provider/local/local-embedding-engine.d.ts.map +1 -1
- package/esm/src/provider/local/local-embedding-engine.js +18 -32
- package/esm/src/provider/local/local-engine.d.ts.map +1 -1
- package/esm/src/provider/local/local-engine.js +14 -26
- package/esm/src/provider/local/pipeline-cache.d.ts +27 -0
- package/esm/src/provider/local/pipeline-cache.d.ts.map +1 -0
- package/esm/src/provider/local/pipeline-cache.js +61 -0
- package/esm/src/server/handlers/dev/framework-candidates.generated.d.ts.map +1 -1
- package/esm/src/server/handlers/dev/framework-candidates.generated.js +1 -0
- package/esm/src/server/handlers/request/internal-agents-list.handler.d.ts.map +1 -1
- package/esm/src/server/handlers/request/internal-agents-list.handler.js +1 -0
- package/esm/src/transforms/mdx/esm-module-loader/module-writer.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/module-writer.js +8 -2
- package/esm/src/transforms/pipeline/stages/ssr-vf-modules/transform.d.ts.map +1 -1
- package/esm/src/transforms/pipeline/stages/ssr-vf-modules/transform.js +8 -1
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +1 -1
|
@@ -15,6 +15,7 @@ import { createError, toError } from "../../errors/veryfront-error.js";
|
|
|
15
15
|
import { importTransformers } from "../../platform/compat/opaque-deps.js";
|
|
16
16
|
import { DEFAULT_LOCAL_MODEL, resolveLocalModel } from "./model-catalog.js";
|
|
17
17
|
import { throwIfLocalAIDisabled } from "./env.js";
|
|
18
|
+
import { createPipelineCache } from "./pipeline-cache.js";
|
|
18
19
|
const logger = serverLogger.component("local-llm");
|
|
19
20
|
/** Default maximum new tokens for local model generation */
|
|
20
21
|
const DEFAULT_MAX_NEW_TOKENS = 512;
|
|
@@ -82,10 +83,6 @@ export function buildPipeOptions(options, transformers, tokenizer, streamer) {
|
|
|
82
83
|
}
|
|
83
84
|
return pipeOptions;
|
|
84
85
|
}
|
|
85
|
-
/** Cached pipeline instances keyed by HuggingFace model ID */
|
|
86
|
-
const pipelineCache = new Map();
|
|
87
|
-
/** Whether a model is currently being loaded (prevents concurrent loads) */
|
|
88
|
-
const loadingLocks = new Map();
|
|
89
86
|
let transformersModule = null;
|
|
90
87
|
/**
|
|
91
88
|
* Lazily import @huggingface/transformers.
|
|
@@ -117,21 +114,12 @@ export async function getTransformers() {
|
|
|
117
114
|
return mod;
|
|
118
115
|
}
|
|
119
116
|
/**
|
|
120
|
-
*
|
|
121
|
-
*
|
|
117
|
+
* Bounded, dedup-aware cache of text-generation pipelines keyed by HuggingFace
|
|
118
|
+
* model id. Only loads a model on a cold cache miss; concurrent loads of the
|
|
119
|
+
* same model share a single promise.
|
|
122
120
|
*/
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
// Return cached pipeline
|
|
126
|
-
const cached = pipelineCache.get(cacheKey);
|
|
127
|
-
if (cached)
|
|
128
|
-
return cached;
|
|
129
|
-
// Wait for existing load if in progress
|
|
130
|
-
const existingLock = loadingLocks.get(cacheKey);
|
|
131
|
-
if (existingLock)
|
|
132
|
-
return existingLock;
|
|
133
|
-
// Start loading
|
|
134
|
-
const loadPromise = (async () => {
|
|
121
|
+
const textGenerationPipelines = createPipelineCache(async (modelInfo) => {
|
|
122
|
+
try {
|
|
135
123
|
const transformers = await getTransformers();
|
|
136
124
|
logger.info(`Loading local model: ${modelInfo.hfId} (${modelInfo.dtype}, ~${modelInfo.sizeMB}MB)...`);
|
|
137
125
|
const pipe = (await transformers.pipeline("text-generation", modelInfo.hfId, {
|
|
@@ -139,16 +127,9 @@ async function loadPipeline(modelInfo) {
|
|
|
139
127
|
device: "cpu",
|
|
140
128
|
}));
|
|
141
129
|
logger.info(`Model loaded: ${modelInfo.hfId}`);
|
|
142
|
-
pipelineCache.set(cacheKey, pipe);
|
|
143
|
-
loadingLocks.delete(cacheKey);
|
|
144
130
|
return pipe;
|
|
145
|
-
})();
|
|
146
|
-
loadingLocks.set(cacheKey, loadPromise);
|
|
147
|
-
try {
|
|
148
|
-
return await loadPromise;
|
|
149
131
|
}
|
|
150
132
|
catch (error) {
|
|
151
|
-
loadingLocks.delete(cacheKey);
|
|
152
133
|
// Convert ONNX / native-addon errors to no_ai_available so they propagate
|
|
153
134
|
// correctly through the chat handler (503) instead of being swallowed as
|
|
154
135
|
// in-band SSE errors inside a 200 response stream.
|
|
@@ -166,6 +147,13 @@ async function loadPipeline(modelInfo) {
|
|
|
166
147
|
}
|
|
167
148
|
throw error;
|
|
168
149
|
}
|
|
150
|
+
});
|
|
151
|
+
/**
|
|
152
|
+
* Load a text-generation pipeline for the given model.
|
|
153
|
+
* Returns a cached pipeline if already loaded.
|
|
154
|
+
*/
|
|
155
|
+
function loadPipeline(modelInfo) {
|
|
156
|
+
return textGenerationPipelines.load(modelInfo.hfId, modelInfo);
|
|
169
157
|
}
|
|
170
158
|
/**
|
|
171
159
|
* Eagerly verify that the local AI runtime (@huggingface/transformers + ONNX)
|
|
@@ -262,5 +250,5 @@ export async function preloadModel(modelId) {
|
|
|
262
250
|
*/
|
|
263
251
|
export function isModelLoaded(modelId) {
|
|
264
252
|
const modelInfo = resolveLocalModel(modelId);
|
|
265
|
-
return
|
|
253
|
+
return textGenerationPipelines.has(modelInfo.hfId);
|
|
266
254
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared pipeline cache for local Transformers.js engines.
|
|
3
|
+
*
|
|
4
|
+
* Both the text-generation engine (`local-engine.ts`) and the embedding engine
|
|
5
|
+
* (`local-embedding-engine.ts`) need to lazily load a pipeline per HuggingFace
|
|
6
|
+
* model id, cache it, and deduplicate concurrent loads of the same model. This
|
|
7
|
+
* helper captures that shared behavior and bounds the cache with an LRU so a
|
|
8
|
+
* long-running process that touches many models cannot grow memory without
|
|
9
|
+
* limit (loaded models are large).
|
|
10
|
+
*
|
|
11
|
+
* @module provider/local
|
|
12
|
+
*/
|
|
13
|
+
/** A loaded pipeline cache with concurrency-safe, deduplicated loading. */
|
|
14
|
+
export interface PipelineCache<P, M> {
|
|
15
|
+
/** Load (or return cached) pipeline for the given model id. */
|
|
16
|
+
load(cacheKey: string, modelInfo: M): Promise<P>;
|
|
17
|
+
/** Whether a pipeline for the given model id is currently loaded. */
|
|
18
|
+
has(cacheKey: string): boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Create a bounded, dedup-aware pipeline cache.
|
|
22
|
+
*
|
|
23
|
+
* @param loadFn Loads the underlying pipeline for a model. Only invoked on a
|
|
24
|
+
* cold cache miss; concurrent loads of the same key share a single promise.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createPipelineCache<P, M>(loadFn: (modelInfo: M) => Promise<P>): PipelineCache<P, M>;
|
|
27
|
+
//# sourceMappingURL=pipeline-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline-cache.d.ts","sourceRoot":"","sources":["../../../../src/src/provider/local/pipeline-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAUH,2EAA2E;AAC3E,MAAM,WAAW,aAAa,CAAC,CAAC,EAAE,CAAC;IACjC,+DAA+D;IAC/D,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACjD,qEAAqE;IACrE,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAChC;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,CAAC,EACtC,MAAM,EAAE,CAAC,SAAS,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,GACnC,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAwCrB"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared pipeline cache for local Transformers.js engines.
|
|
3
|
+
*
|
|
4
|
+
* Both the text-generation engine (`local-engine.ts`) and the embedding engine
|
|
5
|
+
* (`local-embedding-engine.ts`) need to lazily load a pipeline per HuggingFace
|
|
6
|
+
* model id, cache it, and deduplicate concurrent loads of the same model. This
|
|
7
|
+
* helper captures that shared behavior and bounds the cache with an LRU so a
|
|
8
|
+
* long-running process that touches many models cannot grow memory without
|
|
9
|
+
* limit (loaded models are large).
|
|
10
|
+
*
|
|
11
|
+
* @module provider/local
|
|
12
|
+
*/
|
|
13
|
+
import { LRUCache } from "../../utils/lru-wrapper.js";
|
|
14
|
+
/**
|
|
15
|
+
* Maximum number of loaded pipelines kept in memory at once. Loaded models are
|
|
16
|
+
* large (hundreds of MB each), so the cap is intentionally small.
|
|
17
|
+
*/
|
|
18
|
+
const PIPELINE_CACHE_MAX_ENTRIES = 4;
|
|
19
|
+
/**
|
|
20
|
+
* Create a bounded, dedup-aware pipeline cache.
|
|
21
|
+
*
|
|
22
|
+
* @param loadFn Loads the underlying pipeline for a model. Only invoked on a
|
|
23
|
+
* cold cache miss; concurrent loads of the same key share a single promise.
|
|
24
|
+
*/
|
|
25
|
+
export function createPipelineCache(loadFn) {
|
|
26
|
+
const pipelineCache = new LRUCache({
|
|
27
|
+
maxEntries: PIPELINE_CACHE_MAX_ENTRIES,
|
|
28
|
+
});
|
|
29
|
+
// Whether a model is currently being loaded (prevents concurrent loads).
|
|
30
|
+
const loadingLocks = new Map();
|
|
31
|
+
return {
|
|
32
|
+
async load(cacheKey, modelInfo) {
|
|
33
|
+
// Return cached pipeline.
|
|
34
|
+
const cached = pipelineCache.get(cacheKey);
|
|
35
|
+
if (cached)
|
|
36
|
+
return cached;
|
|
37
|
+
// Wait for existing load if in progress.
|
|
38
|
+
const existingLock = loadingLocks.get(cacheKey);
|
|
39
|
+
if (existingLock)
|
|
40
|
+
return existingLock;
|
|
41
|
+
// Start loading.
|
|
42
|
+
const loadPromise = (async () => {
|
|
43
|
+
const pipe = await loadFn(modelInfo);
|
|
44
|
+
pipelineCache.set(cacheKey, pipe);
|
|
45
|
+
loadingLocks.delete(cacheKey);
|
|
46
|
+
return pipe;
|
|
47
|
+
})();
|
|
48
|
+
loadingLocks.set(cacheKey, loadPromise);
|
|
49
|
+
try {
|
|
50
|
+
return await loadPromise;
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
loadingLocks.delete(cacheKey);
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
has(cacheKey) {
|
|
58
|
+
return pipelineCache.has(cacheKey);
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framework-candidates.generated.d.ts","sourceRoot":"","sources":["../../../../../src/src/server/handlers/dev/framework-candidates.generated.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"framework-candidates.generated.d.ts","sourceRoot":"","sources":["../../../../../src/src/server/handlers/dev/framework-candidates.generated.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EAi/KjD,CAAC"}
|
|
@@ -5516,6 +5516,7 @@ export const FRAMEWORK_CANDIDATES = [
|
|
|
5516
5516
|
"veryfront/chat",
|
|
5517
5517
|
"veryfront/errors/error-registry.ts",
|
|
5518
5518
|
"veryfront/platform/compat/runtime.ts",
|
|
5519
|
+
"veryfront/react/primitives/index.ts",
|
|
5519
5520
|
"veryfront/schemas/_test-setup.ts",
|
|
5520
5521
|
"veryfront/security/client/html-sanitizer.ts",
|
|
5521
5522
|
"veryfront/testing/assert",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal-agents-list.handler.d.ts","sourceRoot":"","sources":["../../../../../src/src/server/handlers/request/internal-agents-list.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAmB,aAAa,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,
|
|
1
|
+
{"version":3,"file":"internal-agents-list.handler.d.ts","sourceRoot":"","sources":["../../../../../src/src/server/handlers/request/internal-agents-list.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAmB,aAAa,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EAML,KAAK,yBAAyB,EAC/B,MAAM,oCAAoC,CAAC;AAa5C,qBAAa,yBAA0B,SAAQ,WAAW;IAS5C,OAAO,CAAC,QAAQ,CAAC,IAAI;IARjC,QAAQ,EAAE,eAAe,CAMvB;gBAE2B,IAAI,GAAE,yBAAoD;IAIjF,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;CAmExE"}
|
|
@@ -30,6 +30,7 @@ export class InternalAgentsListHandler extends BaseHandler {
|
|
|
30
30
|
const payload = ControlPlaneAgentsListRequestSchema.parse(JSON.parse(rawBody));
|
|
31
31
|
const claims = await verifyControlPlaneRequest(req, ctx, rawBody, {
|
|
32
32
|
expectedSubject: payload.requestId,
|
|
33
|
+
// Validated by `.parse()` above; narrow back to the union (object inference widens it to `string`).
|
|
33
34
|
expectedSurface: payload.surface,
|
|
34
35
|
});
|
|
35
36
|
if (payload.projectId !== claims.project_id ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-writer.d.ts","sourceRoot":"","sources":["../../../../../src/src/transforms/mdx/esm-module-loader/module-writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAyBH,OAAO,KAAK,EAAkB,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAiDnD,wBAAsB,eAAe,CACnC,mBAAmB,EAAE,MAAM,EAC3B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"module-writer.d.ts","sourceRoot":"","sources":["../../../../../src/src/transforms/mdx/esm-module-loader/module-writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAyBH,OAAO,KAAK,EAAkB,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAiDnD,wBAAsB,eAAe,CACnC,mBAAmB,EAAE,MAAM,EAC3B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,SAAS,CAAC,CA4VpB"}
|
|
@@ -184,7 +184,10 @@ export async function doLoadModuleESM(compiledProgramCode, context) {
|
|
|
184
184
|
compositeKey = `${namespaceKey}:${codeHash}`;
|
|
185
185
|
// Clean up orphaned module file if path changed
|
|
186
186
|
if (refreshedPath !== originalFilePath) {
|
|
187
|
-
getLocalFs().remove(originalFilePath).catch(() => {
|
|
187
|
+
getLocalFs().remove(originalFilePath).catch((error) => logger.debug(`${LOG_PREFIX_MDX_LOADER} orphaned module file cleanup failed`, {
|
|
188
|
+
originalFilePath,
|
|
189
|
+
error,
|
|
190
|
+
}));
|
|
188
191
|
}
|
|
189
192
|
// Verify bundles exist after re-fetch
|
|
190
193
|
const refreshedBundles = extractHttpBundlePaths(rewritten);
|
|
@@ -241,7 +244,10 @@ export async function doLoadModuleESM(compiledProgramCode, context) {
|
|
|
241
244
|
compositeKey = `${namespaceKey}:${codeHash}`;
|
|
242
245
|
// Clean up orphaned module file if path changed
|
|
243
246
|
if (refreshedPath !== originalFilePath) {
|
|
244
|
-
getLocalFs().remove(originalFilePath).catch(() => {
|
|
247
|
+
getLocalFs().remove(originalFilePath).catch((error) => logger.debug(`${LOG_PREFIX_MDX_LOADER} orphaned module file cleanup failed`, {
|
|
248
|
+
originalFilePath,
|
|
249
|
+
error,
|
|
250
|
+
}));
|
|
245
251
|
}
|
|
246
252
|
// Verify bundles now exist
|
|
247
253
|
const stillMissing = await findMissingFrameworkBundles(extractFrameworkBundlePaths(rewritten));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/pipeline/stages/ssr-vf-modules/transform.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/pipeline/stages/ssr-vf-modules/transform.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAcrE,OAAO,EAOL,KAAK,gBAAgB,EAGtB,MAAM,gBAAgB,CAAC;AAKxB;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAExD;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,oBAAoB,CACxC,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,EAAE,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,GACtC,OAAO,CAAC,MAAM,CAAC,CA2BjB;AA8ED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACtC,MAAM,GAAG,IAAI,CAKf;AAwMD;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,gBAAgB,EACrB,oBAAoB,UAAQ,EAC5B,KAAK,SAAI,GACR,OAAO,CAAC,MAAM,CAAC,CAsPjB;AAED;;;GAGG;AACH,wBAAsB,kCAAkC,CACtD,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,gBAAgB,GACpB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA4CxB;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,GACtC,OAAO,CAAC,MAAM,CAAC,CAEjB"}
|
|
@@ -10,6 +10,7 @@ import { rendererLogger as logger } from "../../../../utils/index.js";
|
|
|
10
10
|
import { IMPORT_RESOLUTION_ERROR } from "../../../../errors/index.js";
|
|
11
11
|
import { replaceSpecifiers } from "../../../esm/lexer.js";
|
|
12
12
|
import { hashCodeHex } from "../../../../utils/hash-utils.js";
|
|
13
|
+
import { LRUCache } from "../../../../utils/lru-wrapper.js";
|
|
13
14
|
import { getHttpBundleCacheDir, getMdxEsmCacheDir } from "../../../../utils/cache-dir.js";
|
|
14
15
|
import { cacheHttpImportsToLocal } from "../../../esm/http-cache.js";
|
|
15
16
|
import { loadImportMap } from "../../../../modules/import-map/index.js";
|
|
@@ -69,7 +70,13 @@ export async function cacheTransformedCode(transformed, vfModulePath, fs) {
|
|
|
69
70
|
// React, HTTP imports all rewritten). The fallback still reads
|
|
70
71
|
// `frameworkFileCache` first, so when the main path has already produced
|
|
71
72
|
// a high-quality entry the fallback prefers it.
|
|
72
|
-
|
|
73
|
+
// Bounded so the fallback's per-path output cannot grow memory without limit
|
|
74
|
+
// in a long-running dev server. Entries are deterministic per resolved path and
|
|
75
|
+
// safe to evict/recompute.
|
|
76
|
+
const FALLBACK_TRANSFORM_CACHE_MAX_ENTRIES = 2000;
|
|
77
|
+
const fallbackTransformCache = new LRUCache({
|
|
78
|
+
maxEntries: FALLBACK_TRANSFORM_CACHE_MAX_ENTRIES,
|
|
79
|
+
});
|
|
73
80
|
/**
|
|
74
81
|
* Resolve a bare `react` / `react-dom` (or subpath) specifier to its esm.sh
|
|
75
82
|
* URL for the given React version. Returns `null` for anything that is not a
|