veryfront 0.1.174 → 0.1.177
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/platform/adapters/fs/veryfront/read-operations.d.ts +2 -0
- package/esm/src/platform/adapters/fs/veryfront/read-operations.d.ts.map +1 -1
- package/esm/src/platform/adapters/fs/veryfront/read-operations.js +30 -16
- package/esm/src/platform/adapters/fs/veryfront/stat-operations.d.ts +1 -0
- package/esm/src/platform/adapters/fs/veryfront/stat-operations.d.ts.map +1 -1
- package/esm/src/platform/adapters/fs/veryfront/stat-operations.js +48 -41
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +1 -1
- package/src/deno.js +1 -1
- package/src/src/platform/adapters/fs/veryfront/read-operations.ts +62 -36
- package/src/src/platform/adapters/fs/veryfront/stat-operations.ts +70 -49
- package/src/src/utils/version-constant.ts +1 -1
package/esm/deno.js
CHANGED
|
@@ -28,8 +28,10 @@ export declare class ReadOperations {
|
|
|
28
28
|
private setupInFlightFetch;
|
|
29
29
|
private tryResolveExtensionlessPath;
|
|
30
30
|
private tryResolveExtensionlessPathFromFileList;
|
|
31
|
+
private finalizeResolvedExtension;
|
|
31
32
|
private cacheResolvedContent;
|
|
32
33
|
private storeFetchedContent;
|
|
34
|
+
private fetchPublishedVariant;
|
|
33
35
|
private fetchContent;
|
|
34
36
|
private fetchPublishedContent;
|
|
35
37
|
private tryFallbackExtensions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-operations.d.ts","sourceRoot":"","sources":["../../../../../../src/src/platform/adapters/fs/veryfront/read-operations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAKnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;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uBAAuB,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAIrD,kBAAkB,IAAI,IAAI;IAK1B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAY3C,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAY3C,OAAO,CAAC,mBAAmB;YAsBb,+BAA+B;YA0C/B,mBAAmB;IA0CjC,OAAO,CAAC,kBAAkB;YAoFZ,2BAA2B;YAmD3B,uCAAuC;IAiCrD,OAAO,CAAC,yBAAyB;IAmCjC,OAAO,CAAC,oBAAoB;IAgB5B,OAAO,CAAC,mBAAmB;IAU3B,OAAO,CAAC,qBAAqB;YAYf,YAAY;YA6JZ,qBAAqB;YAwDrB,qBAAqB;YA8CrB,+BAA+B;YAwD/B,iBAAiB;CAuBhC"}
|
|
@@ -219,17 +219,15 @@ export class ReadOperations {
|
|
|
219
219
|
if (!resolved)
|
|
220
220
|
return null;
|
|
221
221
|
const resolvedPath = this.normalizer.normalize(resolved.path);
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
this.extensionResolutionCache.set(apiPath, resolvedPath);
|
|
225
|
-
logger.debug("Resolved extension for base path", {
|
|
226
|
-
basePath: apiPath,
|
|
222
|
+
return this.finalizeResolvedExtension({
|
|
223
|
+
requestedPath: apiPath,
|
|
227
224
|
resolvedPath,
|
|
225
|
+
cacheKeyPrefix,
|
|
228
226
|
cacheKey,
|
|
229
|
-
|
|
227
|
+
content: resolved.content,
|
|
228
|
+
persistToCache: isProduction && !skipPersistentCaches,
|
|
229
|
+
logMessage: "Resolved extension for base path",
|
|
230
230
|
});
|
|
231
|
-
this.cacheResolvedContent(cacheKey, resolvedCacheKey, resolved.content, isProduction && !skipPersistentCaches);
|
|
232
|
-
return resolved.content;
|
|
233
231
|
}
|
|
234
232
|
catch (error) {
|
|
235
233
|
logger.debug("resolveFileWithExtension failed", {
|
|
@@ -244,8 +242,6 @@ export class ReadOperations {
|
|
|
244
242
|
const resolved = await this.fileListIndex.findFirstMatch(candidatePaths);
|
|
245
243
|
if (resolved.status !== "hit" || !resolved.path || !resolved.content)
|
|
246
244
|
return resolved;
|
|
247
|
-
const resolvedCacheKey = getResolvedCacheKey(cacheKeyPrefix, resolved.path);
|
|
248
|
-
this.extensionResolutionCache.set(normalizedPath, resolved.path);
|
|
249
245
|
logContentMetric("FILE_LIST_HIT", {
|
|
250
246
|
path: normalizedPath,
|
|
251
247
|
resolvedPath: resolved.path,
|
|
@@ -253,15 +249,30 @@ export class ReadOperations {
|
|
|
253
249
|
cacheKey,
|
|
254
250
|
isPreviewMode,
|
|
255
251
|
});
|
|
256
|
-
|
|
257
|
-
|
|
252
|
+
this.finalizeResolvedExtension({
|
|
253
|
+
requestedPath: normalizedPath,
|
|
258
254
|
resolvedPath: resolved.path,
|
|
255
|
+
cacheKeyPrefix,
|
|
259
256
|
cacheKey,
|
|
260
|
-
|
|
257
|
+
content: resolved.content,
|
|
258
|
+
persistToCache: isProduction,
|
|
259
|
+
logMessage: "Resolved extension from file list index",
|
|
261
260
|
});
|
|
262
|
-
this.cacheResolvedContent(cacheKey, resolvedCacheKey, resolved.content, isProduction);
|
|
263
261
|
return resolved;
|
|
264
262
|
}
|
|
263
|
+
finalizeResolvedExtension({ requestedPath, resolvedPath, cacheKeyPrefix, cacheKey, content, persistToCache, logMessage, }) {
|
|
264
|
+
const resolvedCacheKey = getResolvedCacheKey(cacheKeyPrefix, resolvedPath);
|
|
265
|
+
// Cache the path mapping to avoid future API resolution calls.
|
|
266
|
+
this.extensionResolutionCache.set(requestedPath, resolvedPath);
|
|
267
|
+
logger.debug(logMessage, {
|
|
268
|
+
basePath: requestedPath,
|
|
269
|
+
resolvedPath,
|
|
270
|
+
cacheKey,
|
|
271
|
+
resolvedCacheKey: resolvedCacheKey === cacheKey ? undefined : resolvedCacheKey,
|
|
272
|
+
});
|
|
273
|
+
this.cacheResolvedContent(cacheKey, resolvedCacheKey, content, persistToCache);
|
|
274
|
+
return content;
|
|
275
|
+
}
|
|
265
276
|
cacheResolvedContent(cacheKey, resolvedCacheKey, content, persistToCache) {
|
|
266
277
|
if (persistToCache) {
|
|
267
278
|
this.cache.set(cacheKey, content);
|
|
@@ -279,6 +290,9 @@ export class ReadOperations {
|
|
|
279
290
|
setRequestScopedFile(cacheKey, content);
|
|
280
291
|
return content;
|
|
281
292
|
}
|
|
293
|
+
fetchPublishedVariant(apiPath, releaseId, environmentName) {
|
|
294
|
+
return this.client.getPublishedFileContent(apiPath, releaseId ?? undefined, environmentName ?? undefined);
|
|
295
|
+
}
|
|
282
296
|
async fetchContent(normalizedPath) {
|
|
283
297
|
// Framework paths should NEVER be fetched from API - they must be read from local filesystem.
|
|
284
298
|
// If we reach here for a framework path, the module server's local resolution failed.
|
|
@@ -357,7 +371,7 @@ export class ReadOperations {
|
|
|
357
371
|
environmentName: environmentName ?? undefined,
|
|
358
372
|
});
|
|
359
373
|
try {
|
|
360
|
-
const content = await this.
|
|
374
|
+
const content = await this.fetchPublishedVariant(apiPath, releaseId, environmentName);
|
|
361
375
|
logger.debug("Fetched published content", {
|
|
362
376
|
path: normalizedPath,
|
|
363
377
|
contentLength: content.length,
|
|
@@ -423,7 +437,7 @@ export class ReadOperations {
|
|
|
423
437
|
const candidates = EXTENSION_PRIORITY.filter((ext) => ext !== originalExt);
|
|
424
438
|
const startTime = performance.now();
|
|
425
439
|
const promises = candidates.map(async (ext) => {
|
|
426
|
-
const content = await this.
|
|
440
|
+
const content = await this.fetchPublishedVariant(basePath + ext, releaseId, environmentName);
|
|
427
441
|
return { ext, content };
|
|
428
442
|
});
|
|
429
443
|
// Mark all promises as handled to prevent unhandled rejection errors
|
|
@@ -18,6 +18,7 @@ export declare class StatOperations extends VeryfrontOperationsBase {
|
|
|
18
18
|
private normalizeMatchedPaths;
|
|
19
19
|
private tryResolveViaApiSearch;
|
|
20
20
|
private hasCachedFileList;
|
|
21
|
+
private resolveFromIndex;
|
|
21
22
|
exists(path: string): Promise<boolean>;
|
|
22
23
|
resolveFile(basePath: string, options?: ResolveFileOptions): Promise<string | null>;
|
|
23
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stat-operations.d.ts","sourceRoot":"","sources":["../../../../../../src/src/platform/adapters/fs/veryfront/stat-operations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAElE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAuB/D,qBAAa,cAAe,SAAQ,uBAAuB;IACzD,OAAO,CAAC,SAAS,CAAyC;IAC1D,OAAO,CAAC,cAAc,CAA4B;IAClD,OAAO,CAAC,aAAa,CAA8B;IAEnD,OAAO,CAAC,sBAAsB,CAA6B;IAC3D,OAAO,CAAC,qBAAqB,CAA8B;IAE3D,OAAO,CAAC,WAAW,CAAkC;IAErD,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAGrC;IAEH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;YAiHvB,gBAAgB;YAwChB,UAAU;IAkDxB,UAAU,IAAI,IAAI;IAMlB,kBAAkB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM;YAIpC,cAAc;IAU5B,OAAO,CAAC,0BAA0B;IAgClC,OAAO,CAAC,qBAAqB;YAQf,sBAAsB;YA8EtB,iBAAiB;
|
|
1
|
+
{"version":3,"file":"stat-operations.d.ts","sourceRoot":"","sources":["../../../../../../src/src/platform/adapters/fs/veryfront/stat-operations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAElE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAuB/D,qBAAa,cAAe,SAAQ,uBAAuB;IACzD,OAAO,CAAC,SAAS,CAAyC;IAC1D,OAAO,CAAC,cAAc,CAA4B;IAClD,OAAO,CAAC,aAAa,CAA8B;IAEnD,OAAO,CAAC,sBAAsB,CAA6B;IAC3D,OAAO,CAAC,qBAAqB,CAA8B;IAE3D,OAAO,CAAC,WAAW,CAAkC;IAErD,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAGrC;IAEH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;YAiHvB,gBAAgB;YAwChB,UAAU;IAkDxB,UAAU,IAAI,IAAI;IAMlB,kBAAkB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM;YAIpC,cAAc;IAU5B,OAAO,CAAC,0BAA0B;IAgClC,OAAO,CAAC,qBAAqB;YAQf,sBAAsB;YA8EtB,iBAAiB;IAS/B,OAAO,CAAC,gBAAgB;IA6DlB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAWtC,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CA0F1F"}
|
|
@@ -310,6 +310,51 @@ export class StatOperations extends VeryfrontOperationsBase {
|
|
|
310
310
|
const files = await this.contextProvider?.getFileList?.();
|
|
311
311
|
return Array.isArray(files) && files.length > 0;
|
|
312
312
|
}
|
|
313
|
+
resolveFromIndex(fileIdx, normalizedPath, options, indexMs, resolveStart) {
|
|
314
|
+
if (fileIdx.has(normalizedPath)) {
|
|
315
|
+
const totalMs = Math.round(performance.now() - resolveStart);
|
|
316
|
+
logger.debug("resolveFile exact match found", {
|
|
317
|
+
normalizedPath,
|
|
318
|
+
indexMs,
|
|
319
|
+
totalMs,
|
|
320
|
+
});
|
|
321
|
+
return normalizedPath;
|
|
322
|
+
}
|
|
323
|
+
const pathWithoutExt = stripKnownExtension(normalizedPath, EXTENSION_PRIORITY);
|
|
324
|
+
const resolvedDirect = resolveByExtensionPriority(fileIdx, pathWithoutExt, EXTENSION_PRIORITY);
|
|
325
|
+
if (resolvedDirect) {
|
|
326
|
+
const totalMs = Math.round(performance.now() - resolveStart);
|
|
327
|
+
logger.debug("resolveFile found with extension", {
|
|
328
|
+
pathWithExt: resolvedDirect,
|
|
329
|
+
indexMs,
|
|
330
|
+
totalMs,
|
|
331
|
+
});
|
|
332
|
+
return resolvedDirect;
|
|
333
|
+
}
|
|
334
|
+
if (options?.allowPagesPrefix !== false && !pathWithoutExt.startsWith("pages/")) {
|
|
335
|
+
const resolvedPages = resolveByExtensionPriority(fileIdx, `pages/${pathWithoutExt}`, EXTENSION_PRIORITY);
|
|
336
|
+
if (resolvedPages) {
|
|
337
|
+
const totalMs = Math.round(performance.now() - resolveStart);
|
|
338
|
+
logger.debug("resolveFile found with pages prefix", {
|
|
339
|
+
pathWithExt: resolvedPages,
|
|
340
|
+
indexMs,
|
|
341
|
+
totalMs,
|
|
342
|
+
});
|
|
343
|
+
return resolvedPages;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
const indexPath = resolveIndexByExtensionPriority(fileIdx, pathWithoutExt, EXTENSION_PRIORITY);
|
|
347
|
+
if (indexPath) {
|
|
348
|
+
const totalMs = Math.round(performance.now() - resolveStart);
|
|
349
|
+
logger.debug("resolveFile found index file", {
|
|
350
|
+
indexPath,
|
|
351
|
+
indexMs,
|
|
352
|
+
totalMs,
|
|
353
|
+
});
|
|
354
|
+
return indexPath;
|
|
355
|
+
}
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
313
358
|
async exists(path) {
|
|
314
359
|
const normalizedPath = this.normalizer.normalize(path);
|
|
315
360
|
try {
|
|
@@ -364,47 +409,9 @@ export class StatOperations extends VeryfrontOperationsBase {
|
|
|
364
409
|
logger.debug("resolveFile - no file index", { indexMs });
|
|
365
410
|
return null;
|
|
366
411
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
normalizedPath,
|
|
371
|
-
indexMs,
|
|
372
|
-
totalMs,
|
|
373
|
-
});
|
|
374
|
-
return normalizedPath;
|
|
375
|
-
}
|
|
376
|
-
const pathWithoutExt = stripKnownExtension(normalizedPath, EXTENSION_PRIORITY);
|
|
377
|
-
const resolvedDirect = resolveByExtensionPriority(fileIdx, pathWithoutExt, EXTENSION_PRIORITY);
|
|
378
|
-
if (resolvedDirect) {
|
|
379
|
-
const totalMs = Math.round(performance.now() - resolveStart);
|
|
380
|
-
logger.debug("resolveFile found with extension", {
|
|
381
|
-
pathWithExt: resolvedDirect,
|
|
382
|
-
indexMs,
|
|
383
|
-
totalMs,
|
|
384
|
-
});
|
|
385
|
-
return resolvedDirect;
|
|
386
|
-
}
|
|
387
|
-
if (options?.allowPagesPrefix !== false && !pathWithoutExt.startsWith("pages/")) {
|
|
388
|
-
const resolvedPages = resolveByExtensionPriority(fileIdx, `pages/${pathWithoutExt}`, EXTENSION_PRIORITY);
|
|
389
|
-
if (resolvedPages) {
|
|
390
|
-
const totalMs = Math.round(performance.now() - resolveStart);
|
|
391
|
-
logger.debug("resolveFile found with pages prefix", {
|
|
392
|
-
pathWithExt: resolvedPages,
|
|
393
|
-
indexMs,
|
|
394
|
-
totalMs,
|
|
395
|
-
});
|
|
396
|
-
return resolvedPages;
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
const indexPath = resolveIndexByExtensionPriority(fileIdx, pathWithoutExt, EXTENSION_PRIORITY);
|
|
400
|
-
if (indexPath) {
|
|
401
|
-
const totalMs = Math.round(performance.now() - resolveStart);
|
|
402
|
-
logger.debug("resolveFile found index file", {
|
|
403
|
-
indexPath,
|
|
404
|
-
indexMs,
|
|
405
|
-
totalMs,
|
|
406
|
-
});
|
|
407
|
-
return indexPath;
|
|
412
|
+
const indexedResolution = this.resolveFromIndex(fileIdx, normalizedPath, options, indexMs, resolveStart);
|
|
413
|
+
if (indexedResolution) {
|
|
414
|
+
return indexedResolution;
|
|
408
415
|
}
|
|
409
416
|
if (attemptedApiResolve) {
|
|
410
417
|
logger.debug("resolveFile not found after pre-index API search", {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.
|
|
1
|
+
export declare const VERSION = "0.1.177";
|
|
2
2
|
//# sourceMappingURL=version-constant.d.ts.map
|
package/package.json
CHANGED
package/src/deno.js
CHANGED
|
@@ -316,26 +316,15 @@ export class ReadOperations {
|
|
|
316
316
|
if (!resolved) return null;
|
|
317
317
|
|
|
318
318
|
const resolvedPath = this.normalizer.normalize(resolved.path);
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
// Cache the path mapping to avoid future API resolution calls
|
|
322
|
-
this.extensionResolutionCache.set(apiPath, resolvedPath);
|
|
323
|
-
|
|
324
|
-
logger.debug("Resolved extension for base path", {
|
|
325
|
-
basePath: apiPath,
|
|
319
|
+
return this.finalizeResolvedExtension({
|
|
320
|
+
requestedPath: apiPath,
|
|
326
321
|
resolvedPath,
|
|
322
|
+
cacheKeyPrefix,
|
|
327
323
|
cacheKey,
|
|
328
|
-
|
|
324
|
+
content: resolved.content,
|
|
325
|
+
persistToCache: isProduction && !skipPersistentCaches,
|
|
326
|
+
logMessage: "Resolved extension for base path",
|
|
329
327
|
});
|
|
330
|
-
|
|
331
|
-
this.cacheResolvedContent(
|
|
332
|
-
cacheKey,
|
|
333
|
-
resolvedCacheKey,
|
|
334
|
-
resolved.content,
|
|
335
|
-
isProduction && !skipPersistentCaches,
|
|
336
|
-
);
|
|
337
|
-
|
|
338
|
-
return resolved.content;
|
|
339
328
|
} catch (error) {
|
|
340
329
|
logger.debug("resolveFileWithExtension failed", {
|
|
341
330
|
basePath: apiPath,
|
|
@@ -357,10 +346,6 @@ export class ReadOperations {
|
|
|
357
346
|
const resolved = await this.fileListIndex.findFirstMatch(candidatePaths);
|
|
358
347
|
if (resolved.status !== "hit" || !resolved.path || !resolved.content) return resolved;
|
|
359
348
|
|
|
360
|
-
const resolvedCacheKey = getResolvedCacheKey(cacheKeyPrefix, resolved.path);
|
|
361
|
-
|
|
362
|
-
this.extensionResolutionCache.set(normalizedPath, resolved.path);
|
|
363
|
-
|
|
364
349
|
logContentMetric("FILE_LIST_HIT", {
|
|
365
350
|
path: normalizedPath,
|
|
366
351
|
resolvedPath: resolved.path,
|
|
@@ -368,18 +353,55 @@ export class ReadOperations {
|
|
|
368
353
|
cacheKey,
|
|
369
354
|
isPreviewMode,
|
|
370
355
|
});
|
|
371
|
-
|
|
372
|
-
|
|
356
|
+
|
|
357
|
+
this.finalizeResolvedExtension({
|
|
358
|
+
requestedPath: normalizedPath,
|
|
373
359
|
resolvedPath: resolved.path,
|
|
360
|
+
cacheKeyPrefix,
|
|
374
361
|
cacheKey,
|
|
375
|
-
|
|
362
|
+
content: resolved.content,
|
|
363
|
+
persistToCache: isProduction,
|
|
364
|
+
logMessage: "Resolved extension from file list index",
|
|
376
365
|
});
|
|
377
366
|
|
|
378
|
-
this.cacheResolvedContent(cacheKey, resolvedCacheKey, resolved.content, isProduction);
|
|
379
|
-
|
|
380
367
|
return resolved;
|
|
381
368
|
}
|
|
382
369
|
|
|
370
|
+
private finalizeResolvedExtension(
|
|
371
|
+
{
|
|
372
|
+
requestedPath,
|
|
373
|
+
resolvedPath,
|
|
374
|
+
cacheKeyPrefix,
|
|
375
|
+
cacheKey,
|
|
376
|
+
content,
|
|
377
|
+
persistToCache,
|
|
378
|
+
logMessage,
|
|
379
|
+
}: {
|
|
380
|
+
requestedPath: string;
|
|
381
|
+
resolvedPath: string;
|
|
382
|
+
cacheKeyPrefix: string;
|
|
383
|
+
cacheKey: string;
|
|
384
|
+
content: string;
|
|
385
|
+
persistToCache: boolean;
|
|
386
|
+
logMessage: string;
|
|
387
|
+
},
|
|
388
|
+
): string {
|
|
389
|
+
const resolvedCacheKey = getResolvedCacheKey(cacheKeyPrefix, resolvedPath);
|
|
390
|
+
|
|
391
|
+
// Cache the path mapping to avoid future API resolution calls.
|
|
392
|
+
this.extensionResolutionCache.set(requestedPath, resolvedPath);
|
|
393
|
+
|
|
394
|
+
logger.debug(logMessage, {
|
|
395
|
+
basePath: requestedPath,
|
|
396
|
+
resolvedPath,
|
|
397
|
+
cacheKey,
|
|
398
|
+
resolvedCacheKey: resolvedCacheKey === cacheKey ? undefined : resolvedCacheKey,
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
this.cacheResolvedContent(cacheKey, resolvedCacheKey, content, persistToCache);
|
|
402
|
+
return content;
|
|
403
|
+
}
|
|
404
|
+
|
|
383
405
|
private cacheResolvedContent(
|
|
384
406
|
cacheKey: string,
|
|
385
407
|
resolvedCacheKey: string,
|
|
@@ -406,6 +428,18 @@ export class ReadOperations {
|
|
|
406
428
|
return content;
|
|
407
429
|
}
|
|
408
430
|
|
|
431
|
+
private fetchPublishedVariant(
|
|
432
|
+
apiPath: string,
|
|
433
|
+
releaseId: string | null,
|
|
434
|
+
environmentName?: string | null,
|
|
435
|
+
): Promise<string> {
|
|
436
|
+
return this.client.getPublishedFileContent(
|
|
437
|
+
apiPath,
|
|
438
|
+
releaseId ?? undefined,
|
|
439
|
+
environmentName ?? undefined,
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
|
|
409
443
|
private async fetchContent(normalizedPath: string): Promise<string> {
|
|
410
444
|
// Framework paths should NEVER be fetched from API - they must be read from local filesystem.
|
|
411
445
|
// If we reach here for a framework path, the module server's local resolution failed.
|
|
@@ -579,11 +613,7 @@ export class ReadOperations {
|
|
|
579
613
|
});
|
|
580
614
|
|
|
581
615
|
try {
|
|
582
|
-
const content = await this.
|
|
583
|
-
apiPath,
|
|
584
|
-
releaseId ?? undefined,
|
|
585
|
-
environmentName ?? undefined,
|
|
586
|
-
);
|
|
616
|
+
const content = await this.fetchPublishedVariant(apiPath, releaseId, environmentName);
|
|
587
617
|
|
|
588
618
|
logger.debug("Fetched published content", {
|
|
589
619
|
path: normalizedPath,
|
|
@@ -686,11 +716,7 @@ export class ReadOperations {
|
|
|
686
716
|
const startTime = performance.now();
|
|
687
717
|
|
|
688
718
|
const promises = candidates.map(async (ext) => {
|
|
689
|
-
const content = await this.
|
|
690
|
-
basePath + ext,
|
|
691
|
-
releaseId ?? undefined,
|
|
692
|
-
environmentName ?? undefined,
|
|
693
|
-
);
|
|
719
|
+
const content = await this.fetchPublishedVariant(basePath + ext, releaseId, environmentName);
|
|
694
720
|
return { ext, content };
|
|
695
721
|
});
|
|
696
722
|
|
|
@@ -390,6 +390,67 @@ export class StatOperations extends VeryfrontOperationsBase {
|
|
|
390
390
|
return Array.isArray(files) && files.length > 0;
|
|
391
391
|
}
|
|
392
392
|
|
|
393
|
+
private resolveFromIndex(
|
|
394
|
+
fileIdx: Map<string, ProjectFile>,
|
|
395
|
+
normalizedPath: string,
|
|
396
|
+
options: ResolveFileOptions | undefined,
|
|
397
|
+
indexMs: number,
|
|
398
|
+
resolveStart: number,
|
|
399
|
+
): string | null {
|
|
400
|
+
if (fileIdx.has(normalizedPath)) {
|
|
401
|
+
const totalMs = Math.round(performance.now() - resolveStart);
|
|
402
|
+
logger.debug("resolveFile exact match found", {
|
|
403
|
+
normalizedPath,
|
|
404
|
+
indexMs,
|
|
405
|
+
totalMs,
|
|
406
|
+
});
|
|
407
|
+
return normalizedPath;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
const pathWithoutExt = stripKnownExtension(normalizedPath, EXTENSION_PRIORITY);
|
|
411
|
+
|
|
412
|
+
const resolvedDirect = resolveByExtensionPriority(fileIdx, pathWithoutExt, EXTENSION_PRIORITY);
|
|
413
|
+
if (resolvedDirect) {
|
|
414
|
+
const totalMs = Math.round(performance.now() - resolveStart);
|
|
415
|
+
logger.debug("resolveFile found with extension", {
|
|
416
|
+
pathWithExt: resolvedDirect,
|
|
417
|
+
indexMs,
|
|
418
|
+
totalMs,
|
|
419
|
+
});
|
|
420
|
+
return resolvedDirect;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
if (options?.allowPagesPrefix !== false && !pathWithoutExt.startsWith("pages/")) {
|
|
424
|
+
const resolvedPages = resolveByExtensionPriority(
|
|
425
|
+
fileIdx,
|
|
426
|
+
`pages/${pathWithoutExt}`,
|
|
427
|
+
EXTENSION_PRIORITY,
|
|
428
|
+
);
|
|
429
|
+
if (resolvedPages) {
|
|
430
|
+
const totalMs = Math.round(performance.now() - resolveStart);
|
|
431
|
+
logger.debug("resolveFile found with pages prefix", {
|
|
432
|
+
pathWithExt: resolvedPages,
|
|
433
|
+
indexMs,
|
|
434
|
+
totalMs,
|
|
435
|
+
});
|
|
436
|
+
return resolvedPages;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
const indexPath = resolveIndexByExtensionPriority(fileIdx, pathWithoutExt, EXTENSION_PRIORITY);
|
|
441
|
+
if (indexPath) {
|
|
442
|
+
const totalMs = Math.round(performance.now() - resolveStart);
|
|
443
|
+
logger.debug("resolveFile found index file", {
|
|
444
|
+
indexPath,
|
|
445
|
+
indexMs,
|
|
446
|
+
totalMs,
|
|
447
|
+
});
|
|
448
|
+
return indexPath;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
return null;
|
|
452
|
+
}
|
|
453
|
+
|
|
393
454
|
async exists(path: string): Promise<boolean> {
|
|
394
455
|
const normalizedPath = this.normalizer.normalize(path);
|
|
395
456
|
try {
|
|
@@ -453,55 +514,15 @@ export class StatOperations extends VeryfrontOperationsBase {
|
|
|
453
514
|
return null;
|
|
454
515
|
}
|
|
455
516
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
const pathWithoutExt = stripKnownExtension(normalizedPath, EXTENSION_PRIORITY);
|
|
467
|
-
|
|
468
|
-
const resolvedDirect = resolveByExtensionPriority(fileIdx, pathWithoutExt, EXTENSION_PRIORITY);
|
|
469
|
-
if (resolvedDirect) {
|
|
470
|
-
const totalMs = Math.round(performance.now() - resolveStart);
|
|
471
|
-
logger.debug("resolveFile found with extension", {
|
|
472
|
-
pathWithExt: resolvedDirect,
|
|
473
|
-
indexMs,
|
|
474
|
-
totalMs,
|
|
475
|
-
});
|
|
476
|
-
return resolvedDirect;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
if (options?.allowPagesPrefix !== false && !pathWithoutExt.startsWith("pages/")) {
|
|
480
|
-
const resolvedPages = resolveByExtensionPriority(
|
|
481
|
-
fileIdx,
|
|
482
|
-
`pages/${pathWithoutExt}`,
|
|
483
|
-
EXTENSION_PRIORITY,
|
|
484
|
-
);
|
|
485
|
-
if (resolvedPages) {
|
|
486
|
-
const totalMs = Math.round(performance.now() - resolveStart);
|
|
487
|
-
logger.debug("resolveFile found with pages prefix", {
|
|
488
|
-
pathWithExt: resolvedPages,
|
|
489
|
-
indexMs,
|
|
490
|
-
totalMs,
|
|
491
|
-
});
|
|
492
|
-
return resolvedPages;
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
const indexPath = resolveIndexByExtensionPriority(fileIdx, pathWithoutExt, EXTENSION_PRIORITY);
|
|
497
|
-
if (indexPath) {
|
|
498
|
-
const totalMs = Math.round(performance.now() - resolveStart);
|
|
499
|
-
logger.debug("resolveFile found index file", {
|
|
500
|
-
indexPath,
|
|
501
|
-
indexMs,
|
|
502
|
-
totalMs,
|
|
503
|
-
});
|
|
504
|
-
return indexPath;
|
|
517
|
+
const indexedResolution = this.resolveFromIndex(
|
|
518
|
+
fileIdx,
|
|
519
|
+
normalizedPath,
|
|
520
|
+
options,
|
|
521
|
+
indexMs,
|
|
522
|
+
resolveStart,
|
|
523
|
+
);
|
|
524
|
+
if (indexedResolution) {
|
|
525
|
+
return indexedResolution;
|
|
505
526
|
}
|
|
506
527
|
|
|
507
528
|
if (attemptedApiResolve) {
|