veryfront 0.1.834 → 0.1.836

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.834",
3
+ "version": "0.1.836",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "minimumDependencyAge": {
@@ -0,0 +1,27 @@
1
+ import type { CacheBackend } from "../../cache/types.js";
2
+ export interface ReleaseModuleResponseCacheEntry {
3
+ body: string;
4
+ status: number;
5
+ headers: Array<[string, string]>;
6
+ }
7
+ export interface ReleaseModuleResponseCacheKeyOptions {
8
+ projectIdentity: string;
9
+ projectDir: string;
10
+ projectSlug?: string | null;
11
+ branch?: string | null;
12
+ releaseId: string;
13
+ runtimeVersion: string;
14
+ reactVersion?: string;
15
+ releaseDependencyManifestVersion?: number | null;
16
+ modulePath: string;
17
+ }
18
+ export interface ReleaseModuleResponseCacheHit {
19
+ entry: ReleaseModuleResponseCacheEntry;
20
+ source: "memory" | "distributed";
21
+ }
22
+ export declare function buildReleaseModuleResponseCacheKey(options: ReleaseModuleResponseCacheKeyOptions): string;
23
+ export declare function getReleaseModuleResponse(cacheKey: string): Promise<ReleaseModuleResponseCacheHit | undefined>;
24
+ export declare function rememberReleaseModuleResponse(cacheKey: string, entry: ReleaseModuleResponseCacheEntry): Promise<void>;
25
+ export declare function clearReleaseModuleResponseCache(): void;
26
+ export declare function __setReleaseModuleResponseDistributedCacheForTests(cache: CacheBackend | null | undefined): void;
27
+ //# sourceMappingURL=module-response-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-response-cache.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/server/module-response-cache.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAQzD,MAAM,WAAW,+BAA+B;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,oCAAoC;IACnD,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gCAAgC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjD,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,6BAA6B;IAC5C,KAAK,EAAE,+BAA+B,CAAC;IACvC,MAAM,EAAE,QAAQ,GAAG,aAAa,CAAC;CAClC;AAiDD,wBAAgB,kCAAkC,CAChD,OAAO,EAAE,oCAAoC,GAC5C,MAAM,CAmBR;AAED,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,6BAA6B,GAAG,SAAS,CAAC,CAqBpD;AAED,wBAAsB,6BAA6B,CACjD,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,+BAA+B,GACrC,OAAO,CAAC,IAAI,CAAC,CAef;AAED,wBAAgB,+BAA+B,IAAI,IAAI,CAEtD;AAED,wBAAgB,kDAAkD,CAChE,KAAK,EAAE,YAAY,GAAG,IAAI,GAAG,SAAS,GACrC,IAAI,CAEN"}
@@ -0,0 +1,105 @@
1
+ import { registerLRUCache } from "../../cache/index.js";
2
+ import { CacheBackends, createDistributedCacheAccessor } from "../../cache/backend.js";
3
+ import { hashString } from "../../cache/hash.js";
4
+ import { LRUCache } from "../../utils/lru-wrapper.js";
5
+ import { TRANSFORM_DISTRIBUTED_TTL_SEC } from "../../utils/constants/cache.js";
6
+ const RELEASE_MODULE_RESPONSE_CACHE_MAX_ENTRIES = 10_000;
7
+ const RELEASE_MODULE_RESPONSE_CACHE_MAX_BYTES = 64 * 1024 * 1024;
8
+ const RELEASE_MODULE_RESPONSE_DISTRIBUTED_TTL_SEC = TRANSFORM_DISTRIBUTED_TTL_SEC;
9
+ const releaseModuleResponseCache = new LRUCache({
10
+ maxEntries: RELEASE_MODULE_RESPONSE_CACHE_MAX_ENTRIES,
11
+ maxSizeBytes: RELEASE_MODULE_RESPONSE_CACHE_MAX_BYTES,
12
+ });
13
+ registerLRUCache("module-server-release-response-cache", releaseModuleResponseCache);
14
+ const getDistributedModuleResponseCache = createDistributedCacheAccessor(() => CacheBackends.module(), "MODULE-RESPONSE-CACHE");
15
+ let injectedDistributedCache;
16
+ function parseDistributedEntry(raw) {
17
+ try {
18
+ const parsed = JSON.parse(raw);
19
+ if (typeof parsed.body !== "string")
20
+ return null;
21
+ if (typeof parsed.status !== "number")
22
+ return null;
23
+ if (!Array.isArray(parsed.headers) ||
24
+ !parsed.headers.every((entry) => Array.isArray(entry) &&
25
+ entry.length === 2 &&
26
+ typeof entry[0] === "string" &&
27
+ typeof entry[1] === "string"))
28
+ return null;
29
+ return {
30
+ body: parsed.body,
31
+ status: parsed.status,
32
+ headers: parsed.headers,
33
+ };
34
+ }
35
+ catch {
36
+ return null;
37
+ }
38
+ }
39
+ async function getDistributedCache() {
40
+ const cache = injectedDistributedCache !== undefined
41
+ ? injectedDistributedCache
42
+ : await getDistributedModuleResponseCache();
43
+ if (!cache)
44
+ return null;
45
+ return cache.type === "api" || cache.type === "redis" ? cache : null;
46
+ }
47
+ export function buildReleaseModuleResponseCacheKey(options) {
48
+ const projectScope = [
49
+ options.projectIdentity,
50
+ options.projectDir,
51
+ options.projectSlug ?? "",
52
+ options.branch ?? "",
53
+ ].join("\0");
54
+ return [
55
+ "module-server-release-response",
56
+ hashString(projectScope),
57
+ options.releaseId,
58
+ options.runtimeVersion,
59
+ options.reactVersion ?? "",
60
+ options.releaseDependencyManifestVersion == null
61
+ ? ""
62
+ : `release-dependency-manifest:${options.releaseDependencyManifestVersion}`,
63
+ options.modulePath,
64
+ ].join("\0");
65
+ }
66
+ export async function getReleaseModuleResponse(cacheKey) {
67
+ const localEntry = releaseModuleResponseCache.get(cacheKey);
68
+ if (localEntry) {
69
+ return { entry: localEntry, source: "memory" };
70
+ }
71
+ const distributedCache = await getDistributedCache();
72
+ if (!distributedCache)
73
+ return undefined;
74
+ try {
75
+ const raw = await distributedCache.get(cacheKey);
76
+ if (!raw)
77
+ return undefined;
78
+ const entry = parseDistributedEntry(raw);
79
+ if (!entry)
80
+ return undefined;
81
+ releaseModuleResponseCache.set(cacheKey, entry);
82
+ return { entry, source: "distributed" };
83
+ }
84
+ catch {
85
+ return undefined;
86
+ }
87
+ }
88
+ export async function rememberReleaseModuleResponse(cacheKey, entry) {
89
+ releaseModuleResponseCache.set(cacheKey, entry);
90
+ const distributedCache = await getDistributedCache();
91
+ if (!distributedCache)
92
+ return;
93
+ try {
94
+ await distributedCache.set(cacheKey, JSON.stringify(entry), RELEASE_MODULE_RESPONSE_DISTRIBUTED_TTL_SEC);
95
+ }
96
+ catch {
97
+ /* best-effort shared cache */
98
+ }
99
+ }
100
+ export function clearReleaseModuleResponseCache() {
101
+ releaseModuleResponseCache.clear();
102
+ }
103
+ export function __setReleaseModuleResponseDistributedCacheForTests(cache) {
104
+ injectedDistributedCache = cache;
105
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"module-server.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/server/module-server.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAG5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AA6CtE;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAwDrD,CAAC;AA4DF,MAAM,WAAW,mBAAmB;IAClC,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,6BAA6B;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,sBAAsB;IACtB,OAAO,EAAE,cAAc,CAAC;IACxB,uBAAuB;IACvB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sFAAsF;IACtF,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,sDAAsD;AACtD,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC,CA+XzF;AAwWD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAGrD"}
1
+ {"version":3,"file":"module-server.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/server/module-server.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAG5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAyDtE;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAwDrD,CAAC;AAyEF,MAAM,WAAW,mBAAmB;IAClC,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,6BAA6B;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,sBAAsB;IACtB,OAAO,EAAE,cAAc,CAAC;IACxB,uBAAuB;IACvB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sFAAsF;IACtF,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,sDAAsD;AACtD,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAubzF;AAwWD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAGrD"}
@@ -8,7 +8,7 @@ import { getContentTypeForPath } from "../../server/handlers/utils/content-types
8
8
  import { createSecureFs } from "../../security/index.js";
9
9
  import { getErrorMessage } from "../../errors/veryfront-error.js";
10
10
  import { getApiBaseUrlEnv } from "../../config/env.js";
11
- import { profilePhase } from "../../observability/request-profiler.js";
11
+ import { markRequestProfilePhase, profilePhase, } from "../../observability/request-profiler.js";
12
12
  import { metrics } from "../../observability/simple-metrics/index.js";
13
13
  import { injectContext, withSpan } from "../../observability/tracing/otlp-setup.js";
14
14
  import { injectNodePositions } from "../../transforms/plugins/babel-node-positions.js";
@@ -20,9 +20,10 @@ import { FRAMEWORK_ROOT, resolveFrameworkSourcePath, } from "../../platform/comp
20
20
  import { getReactUrls, REACT_DEFAULT_VERSION } from "../../utils/constants/cdn.js";
21
21
  import { readLimitedCrossProjectSource } from "./cross-project-source-limit.js";
22
22
  import { sha256Short } from "../../cache/hash.js";
23
- import { rewriteReleaseDependencyImportsForModule } from "../../release-assets/module-consumption.js";
23
+ import { getReleaseDependencyRewriteManifestState, rewriteReleaseDependencyImportsForModule, } from "../../release-assets/module-consumption.js";
24
24
  import { RELEASE_ASSET_IMMUTABLE_MAX_AGE_SECONDS, RELEASE_MODULE_RUNTIME_VERSION_PARAM, RELEASE_MODULE_VERSION_PARAM, } from "../../release-assets/constants.js";
25
25
  import { buildSourceMissCacheKey, hasSourceMiss, rememberSourceMiss, } from "./module-source-resolution-cache.js";
26
+ import { buildReleaseModuleResponseCacheKey, getReleaseModuleResponse, rememberReleaseModuleResponse, } from "./module-response-cache.js";
26
27
  import { ensureFilenameDefaultExport } from "../loader-shared/filename-default-export.js";
27
28
  const logger = serverLogger.component("module-server");
28
29
  const PROJECT_FALLBACK_EMBEDDED_POLYFILLS = new Set(["deno"]);
@@ -111,7 +112,9 @@ function appendReleaseModuleVersion(url, releaseId) {
111
112
  return `${url}${separator}${params.toString()}`;
112
113
  }
113
114
  function shouldCacheReleaseVersionedModule(url, options, isSSR) {
114
- if (options.dev || isSSR || !options.releaseId)
115
+ if (options.dev || options.mode === "preview" || isSSR || !options.releaseId)
116
+ return false;
117
+ if (url.searchParams.get("studio_embed") === "true" || url.searchParams.has("t"))
115
118
  return false;
116
119
  return url.searchParams.get(RELEASE_MODULE_VERSION_PARAM) === options.releaseId &&
117
120
  url.searchParams.get(RELEASE_MODULE_RUNTIME_VERSION_PARAM) === VERSION;
@@ -120,13 +123,22 @@ function isSSRModuleRequest(req, url) {
120
123
  const userAgent = req.headers.get("user-agent") ?? "";
121
124
  return url.searchParams.get("ssr") === "true" || userAgent.startsWith("Deno/");
122
125
  }
123
- async function addReleaseVersionToFallbackImports(code, releaseId) {
124
- if (!releaseId || !code.includes("/_vf_modules/"))
126
+ async function addReleaseVersionToFallbackImports(code, modulePath, releaseId) {
127
+ if (!releaseId)
125
128
  return code;
129
+ const moduleBaseUrl = `https://veryfront.local/_vf_modules/${modulePath}`;
126
130
  return await replaceSpecifiers(code, (specifier) => {
127
- if (!specifier.startsWith("/_vf_modules/"))
131
+ if (specifier.startsWith("/_vf_modules/")) {
132
+ return appendReleaseModuleVersion(specifier, releaseId);
133
+ }
134
+ if (!specifier.startsWith("./") && !specifier.startsWith("../"))
135
+ return null;
136
+ const resolved = new URL(specifier, moduleBaseUrl);
137
+ if (resolved.origin !== "https://veryfront.local")
138
+ return null;
139
+ if (!resolved.pathname.startsWith("/_vf_modules/"))
128
140
  return null;
129
- return appendReleaseModuleVersion(specifier, releaseId);
141
+ return appendReleaseModuleVersion(`${resolved.pathname}${resolved.search}${resolved.hash}`, releaseId);
130
142
  });
131
143
  }
132
144
  /** Serve transformed module at /_vf_modules/* path */
@@ -319,6 +331,46 @@ export function serveModule(req, options) {
319
331
  projectSlug = parsedHost.slug;
320
332
  branch ??= parsedHost.branch;
321
333
  }
334
+ const isSSR = isSSRModuleRequest(req, url);
335
+ const canUseReleaseModuleResponseCache = method === "GET" || method === "HEAD";
336
+ const canCacheReleaseVersionedModule = canUseReleaseModuleResponseCache &&
337
+ shouldCacheReleaseVersionedModule(url, options, isSSR);
338
+ let releaseDependencyManifest = null;
339
+ let releaseDependencyManifestVersion = null;
340
+ let releaseDependencyManifestReady = true;
341
+ if (canCacheReleaseVersionedModule) {
342
+ const manifestState = await getReleaseDependencyRewriteManifestState(options.releaseId);
343
+ if (manifestState.enabled) {
344
+ releaseDependencyManifest = manifestState.manifest;
345
+ releaseDependencyManifestVersion = manifestState.manifest?.manifestVersion ?? null;
346
+ releaseDependencyManifestReady = manifestState.manifest !== null;
347
+ }
348
+ }
349
+ const releaseModuleResponseCacheKey = canCacheReleaseVersionedModule &&
350
+ releaseDependencyManifestReady
351
+ ? buildReleaseModuleResponseCacheKey({
352
+ projectIdentity: effectiveProjectId,
353
+ projectDir,
354
+ projectSlug,
355
+ branch,
356
+ releaseId: options.releaseId,
357
+ runtimeVersion: VERSION,
358
+ reactVersion,
359
+ releaseDependencyManifestVersion,
360
+ modulePath,
361
+ })
362
+ : null;
363
+ if (releaseModuleResponseCacheKey) {
364
+ const cachedResponse = await getReleaseModuleResponse(releaseModuleResponseCacheKey);
365
+ if (cachedResponse?.entry) {
366
+ markRequestProfilePhase("module.response_cache_hit");
367
+ if (cachedResponse.source === "distributed") {
368
+ markRequestProfilePhase("module.response_cache_distributed_hit");
369
+ }
370
+ return createModuleResponse(method, cachedResponse.entry.body, cachedResponse.entry.status, Object.fromEntries(cachedResponse.entry.headers));
371
+ }
372
+ markRequestProfilePhase("module.response_cache_miss");
373
+ }
322
374
  try {
323
375
  const findResult = await profilePhase("module.source_lookup", () => findSourceFile(secureFs, projectDir, filePathWithoutExt, {
324
376
  projectId: effectiveProjectId,
@@ -356,7 +408,6 @@ export function serveModule(req, options) {
356
408
  : await secureFs.readFile(sourceFile);
357
409
  }
358
410
  const userAgent = req.headers.get("user-agent") ?? "";
359
- const isSSR = isSSRModuleRequest(req, url);
360
411
  const studioEmbed = url.searchParams.get("studio_embed") === "true";
361
412
  const shouldInjectPositions = dev || options.mode === "preview";
362
413
  const isJsxFile = /\.(tsx|jsx)$/i.test(sourceFile);
@@ -408,18 +459,27 @@ export function serveModule(req, options) {
408
459
  if (!isSSR) {
409
460
  code = await rewriteReleaseDependencyImportsForModule(code, {
410
461
  releaseId: options.releaseId,
462
+ manifest: releaseDependencyManifest ?? undefined,
411
463
  readDependencySource: (path) => platformFs.readTextFile(path),
412
464
  });
413
- code = await addReleaseVersionToFallbackImports(code, options.releaseId);
465
+ code = await addReleaseVersionToFallbackImports(code, modulePath, options.releaseId);
414
466
  }
415
467
  }
416
468
  const headers = getModuleHeaders(modulePath, {
417
- cacheable: shouldCacheReleaseVersionedModule(url, options, isSSRModuleRequest(req, url)),
469
+ cacheable: releaseModuleResponseCacheKey !== null,
418
470
  });
419
471
  logger.debug("Request complete", {
420
472
  path: modulePath,
421
473
  durationMs: (performance.now() - startTime).toFixed(1),
422
474
  });
475
+ if (releaseModuleResponseCacheKey && method === "GET") {
476
+ void rememberReleaseModuleResponse(releaseModuleResponseCacheKey, {
477
+ body: code,
478
+ status: HTTP_OK,
479
+ headers: Object.entries(headers),
480
+ });
481
+ markRequestProfilePhase("module.response_cache_store");
482
+ }
423
483
  return createModuleResponse(method, code, HTTP_OK, headers);
424
484
  }
425
485
  catch (error) {
@@ -8,9 +8,17 @@
8
8
  *
9
9
  * @module release-assets/module-consumption
10
10
  */
11
+ import type { ReleaseAssetManifest } from "./manifest-schema.js";
11
12
  export interface RewriteReleaseDependencyImportsOptions {
12
13
  releaseId?: string | null;
13
14
  readDependencySource: (path: string) => Promise<string>;
15
+ manifest?: ReleaseAssetManifest | null;
14
16
  }
17
+ export interface ReleaseDependencyRewriteManifestState {
18
+ enabled: boolean;
19
+ manifest: ReleaseAssetManifest | null;
20
+ }
21
+ export declare function isReleaseDependencyImportMapRewriteEnabled(): boolean;
22
+ export declare function getReleaseDependencyRewriteManifestState(releaseId: string | null | undefined): Promise<ReleaseDependencyRewriteManifestState>;
15
23
  export declare function rewriteReleaseDependencyImportsForModule(code: string, options: RewriteReleaseDependencyImportsOptions): Promise<string>;
16
24
  //# sourceMappingURL=module-consumption.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"module-consumption.d.ts","sourceRoot":"","sources":["../../../src/src/release-assets/module-consumption.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAUH,MAAM,WAAW,sCAAsC;IACrD,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,oBAAoB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CACzD;AAmDD,wBAAsB,wCAAwC,CAC5D,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,sCAAsC,GAC9C,OAAO,CAAC,MAAM,CAAC,CA2BjB"}
1
+ {"version":3,"file":"module-consumption.d.ts","sourceRoot":"","sources":["../../../src/src/release-assets/module-consumption.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAQH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,MAAM,WAAW,sCAAsC;IACrD,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,oBAAoB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACxD,QAAQ,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;CACxC;AAED,MAAM,WAAW,qCAAqC;IACpD,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,oBAAoB,GAAG,IAAI,CAAC;CACvC;AAED,wBAAgB,0CAA0C,IAAI,OAAO,CAEpE;AAED,wBAAsB,wCAAwC,CAC5D,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACnC,OAAO,CAAC,qCAAqC,CAAC,CAShD;AAmDD,wBAAsB,wCAAwC,CAC5D,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,sCAAsC,GAC9C,OAAO,CAAC,MAAM,CAAC,CA6BjB"}
@@ -14,6 +14,18 @@ import { parseImports, replaceSpecifiers } from "../transforms/esm/lexer.js";
14
14
  import { extractSourceUrl } from "../transforms/esm/source-url-embed.js";
15
15
  import { RELEASE_ASSET_DEPENDENCY_IMPORT_MAP_ENV_FLAG, releaseAssetUrl } from "./constants.js";
16
16
  import { getReadyManifestForRenderAsync } from "./manifest-cache.js";
17
+ export function isReleaseDependencyImportMapRewriteEnabled() {
18
+ return getHostEnv(RELEASE_ASSET_DEPENDENCY_IMPORT_MAP_ENV_FLAG) === "1";
19
+ }
20
+ export async function getReleaseDependencyRewriteManifestState(releaseId) {
21
+ if (!releaseId || !isReleaseDependencyImportMapRewriteEnabled()) {
22
+ return { enabled: false, manifest: null };
23
+ }
24
+ return {
25
+ enabled: true,
26
+ manifest: await getReadyManifestForRenderAsync(releaseId),
27
+ };
28
+ }
17
29
  function dependencyAssetUrl(manifest, specifier) {
18
30
  const direct = manifest.dependencies[specifier] ??
19
31
  manifest.dependencies[specifier.replace(/[?#].*$/, "")];
@@ -63,11 +75,13 @@ async function sourceUrlForLocalHttpBundle(specifier, readDependencySource) {
63
75
  export async function rewriteReleaseDependencyImportsForModule(code, options) {
64
76
  if (!options.releaseId)
65
77
  return code;
66
- if (getHostEnv(RELEASE_ASSET_DEPENDENCY_IMPORT_MAP_ENV_FLAG) !== "1")
78
+ if (!isReleaseDependencyImportMapRewriteEnabled())
67
79
  return code;
68
80
  if (!code.includes("http") && !code.includes("veryfront-http-bundle"))
69
81
  return code;
70
- const manifest = await getReadyManifestForRenderAsync(options.releaseId);
82
+ const manifest = options.manifest !== undefined
83
+ ? options.manifest
84
+ : await getReadyManifestForRenderAsync(options.releaseId);
71
85
  if (!manifest || Object.keys(manifest.dependencies).length === 0)
72
86
  return code;
73
87
  const replacements = new Map();
@@ -1,3 +1,3 @@
1
1
  /** Shared version value. */
2
- export declare const VERSION = "0.1.834";
2
+ export declare const VERSION = "0.1.836";
3
3
  //# sourceMappingURL=version-constant.d.ts.map
@@ -1,4 +1,4 @@
1
1
  // Keep in sync with deno.json version.
2
2
  // scripts/release.ts updates this constant during releases.
3
3
  /** Shared version value. */
4
- export const VERSION = "0.1.834";
4
+ export const VERSION = "0.1.836";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veryfront",
3
- "version": "0.1.834",
3
+ "version": "0.1.836",
4
4
  "description": "The simplest way to build AI-powered apps",
5
5
  "keywords": [
6
6
  "react",