veryfront 0.1.836 → 0.1.838

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.836",
3
+ "version": "0.1.838",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "minimumDependencyAge": {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/src/html/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAK1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAejF,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,OAAO,EACjB,OAAO,CAAC,EAAE,MAAM,GACf,MAAM,CAQR;AAaD,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;CACd;AA4DD,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAGrD,CAAC;AA6JF,UAAU,qBAAqB;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,oBAAoB,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;CACpD;AAgFD,wBAAsB,cAAc,CAClC,OAAO,CAAC,EAAE,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACvD,OAAO,CAAC,cAAc,CAAC,CA+DzB;AAED,wBAAsB,kBAAkB,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GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACvD,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C;AAED,wBAAgB,mBAAmB,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAElF"}
@@ -1,6 +1,6 @@
1
1
  import { escapeHTML } from "./html-escape.js";
2
2
  import { LRUCache } from "../utils/lru-wrapper.js";
3
- import { RELEASE_ASSET_DEPENDENCY_IMPORT_MAP_ENV_FLAG, releaseAssetUrl, } from "../release-assets/constants.js";
3
+ import { RELEASE_ASSET_DEPENDENCY_IMPORT_MAP_ENV_FLAG, RELEASE_MODULE_RUNTIME_VERSION_PARAM, RELEASE_MODULE_VERSION_PARAM, releaseAssetUrl, } from "../release-assets/constants.js";
4
4
  import { getHostEnv } from "../platform/compat/process.js";
5
5
  import { VERYFRONT_VERSION } from "../utils/constants/cdn.js";
6
6
  import { DEFAULT_REACT_VERSION, esmShReact, readProjectDependencyVersions, resolveProjectReactVersion, stripSemverRange, } from "../transforms/esm/package-registry.js";
@@ -192,6 +192,8 @@ function stableManifestDependencyKey(manifest) {
192
192
  return manifest
193
193
  ? JSON.stringify({
194
194
  assetBasePath: manifest.assetBasePath,
195
+ releaseId: manifest.releaseId,
196
+ manifestVersion: manifest.manifestVersion,
195
197
  dependencies: Object.entries(manifest.dependencies)
196
198
  .map(([specifier, entry]) => [specifier, entry.contentHash])
197
199
  .sort(([a], [b]) => String(a).localeCompare(String(b))),
@@ -236,6 +238,28 @@ function applyManifestDependencies(imports, manifest) {
236
238
  return [specifier, url];
237
239
  }));
238
240
  }
241
+ function shouldVersionReleaseModuleImportMapUrl(value) {
242
+ if (!value.startsWith("/_vf_modules/"))
243
+ return false;
244
+ const pathname = value.split(/[?#]/, 1)[0] ?? "";
245
+ return pathname.endsWith(".js") || pathname.endsWith(".mjs");
246
+ }
247
+ function appendReleaseModuleVersion(value, releaseId) {
248
+ if (!shouldVersionReleaseModuleImportMapUrl(value))
249
+ return value;
250
+ const url = new URL(value, "https://veryfront.local");
251
+ url.searchParams.set(RELEASE_MODULE_VERSION_PARAM, releaseId);
252
+ url.searchParams.set(RELEASE_MODULE_RUNTIME_VERSION_PARAM, VERYFRONT_VERSION);
253
+ return `${url.pathname}${url.search}${url.hash}`;
254
+ }
255
+ function applyReleaseModuleVersions(imports, manifest) {
256
+ if (!manifest?.releaseId)
257
+ return imports;
258
+ return Object.fromEntries(Object.entries(imports).map(([specifier, url]) => [
259
+ specifier,
260
+ appendReleaseModuleVersion(url, manifest.releaseId),
261
+ ]));
262
+ }
239
263
  function isImportMapOnlyOptions(options) {
240
264
  return !("projectDir" in options) &&
241
265
  !("config" in options) &&
@@ -263,6 +287,7 @@ export async function buildImportMap(options) {
263
287
  "react/jsx-dev-runtime": reactTemplates.jsxDevRuntime(versions.react),
264
288
  };
265
289
  imports = applyManifestDependencies(imports, releaseAssetManifest);
290
+ imports = applyReleaseModuleVersions(imports, releaseAssetManifest);
266
291
  imports = { ...imports, ...customImports };
267
292
  return { imports, json: stringifyImportMap(imports, pretty) };
268
293
  }
@@ -275,6 +300,7 @@ export async function buildImportMap(options) {
275
300
  }
276
301
  imports["@/"] = "/_vf_modules/";
277
302
  imports = applyManifestDependencies(imports, releaseAssetManifest);
303
+ imports = applyReleaseModuleVersions(imports, releaseAssetManifest);
278
304
  if (customImports) {
279
305
  imports = { ...imports, ...customImports };
280
306
  }
@@ -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;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"}
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;AA0DtE;;;;;;;;;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,CA8bzF;AAwWD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAGrD"}
@@ -20,7 +20,7 @@ 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 { getReleaseDependencyRewriteManifestState, rewriteReleaseDependencyImportsForModule, } from "../../release-assets/module-consumption.js";
23
+ import { getReleaseDependencyRewriteManifestState, hasReleaseDependencyImportSpecifiers, 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
26
  import { buildReleaseModuleResponseCacheKey, getReleaseModuleResponse, rememberReleaseModuleResponse, } from "./module-response-cache.js";
@@ -337,17 +337,16 @@ export function serveModule(req, options) {
337
337
  shouldCacheReleaseVersionedModule(url, options, isSSR);
338
338
  let releaseDependencyManifest = null;
339
339
  let releaseDependencyManifestVersion = null;
340
- let releaseDependencyManifestReady = true;
340
+ let releaseDependencyManifestRequired = false;
341
341
  if (canCacheReleaseVersionedModule) {
342
342
  const manifestState = await getReleaseDependencyRewriteManifestState(options.releaseId);
343
343
  if (manifestState.enabled) {
344
344
  releaseDependencyManifest = manifestState.manifest;
345
345
  releaseDependencyManifestVersion = manifestState.manifest?.manifestVersion ?? null;
346
- releaseDependencyManifestReady = manifestState.manifest !== null;
346
+ releaseDependencyManifestRequired = manifestState.manifest === null;
347
347
  }
348
348
  }
349
- const releaseModuleResponseCacheKey = canCacheReleaseVersionedModule &&
350
- releaseDependencyManifestReady
349
+ const releaseModuleResponseCacheKey = canCacheReleaseVersionedModule
351
350
  ? buildReleaseModuleResponseCacheKey({
352
351
  projectIdentity: effectiveProjectId,
353
352
  projectDir,
@@ -363,11 +362,16 @@ export function serveModule(req, options) {
363
362
  if (releaseModuleResponseCacheKey) {
364
363
  const cachedResponse = await getReleaseModuleResponse(releaseModuleResponseCacheKey);
365
364
  if (cachedResponse?.entry) {
366
- markRequestProfilePhase("module.response_cache_hit");
367
- if (cachedResponse.source === "distributed") {
368
- markRequestProfilePhase("module.response_cache_distributed_hit");
365
+ const canUseCachedResponse = !releaseDependencyManifestRequired ||
366
+ !(await hasReleaseDependencyImportSpecifiers(cachedResponse.entry.body));
367
+ if (canUseCachedResponse) {
368
+ markRequestProfilePhase("module.response_cache_hit");
369
+ if (cachedResponse.source === "distributed") {
370
+ markRequestProfilePhase("module.response_cache_distributed_hit");
371
+ }
372
+ return createModuleResponse(method, cachedResponse.entry.body, cachedResponse.entry.status, Object.fromEntries(cachedResponse.entry.headers));
369
373
  }
370
- return createModuleResponse(method, cachedResponse.entry.body, cachedResponse.entry.status, Object.fromEntries(cachedResponse.entry.headers));
374
+ markRequestProfilePhase("module.response_cache_manifest_blocked");
371
375
  }
372
376
  markRequestProfilePhase("module.response_cache_miss");
373
377
  }
@@ -465,14 +469,17 @@ export function serveModule(req, options) {
465
469
  code = await addReleaseVersionToFallbackImports(code, modulePath, options.releaseId);
466
470
  }
467
471
  }
472
+ const canCacheModuleResponse = releaseModuleResponseCacheKey !== null &&
473
+ (!releaseDependencyManifestRequired ||
474
+ !(await hasReleaseDependencyImportSpecifiers(code)));
468
475
  const headers = getModuleHeaders(modulePath, {
469
- cacheable: releaseModuleResponseCacheKey !== null,
476
+ cacheable: canCacheModuleResponse,
470
477
  });
471
478
  logger.debug("Request complete", {
472
479
  path: modulePath,
473
480
  durationMs: (performance.now() - startTime).toFixed(1),
474
481
  });
475
- if (releaseModuleResponseCacheKey && method === "GET") {
482
+ if (canCacheModuleResponse && method === "GET") {
476
483
  void rememberReleaseModuleResponse(releaseModuleResponseCacheKey, {
477
484
  body: code,
478
485
  status: HTTP_OK,
@@ -19,6 +19,7 @@ export interface ReleaseDependencyRewriteManifestState {
19
19
  manifest: ReleaseAssetManifest | null;
20
20
  }
21
21
  export declare function isReleaseDependencyImportMapRewriteEnabled(): boolean;
22
+ export declare function hasReleaseDependencyImportSpecifiers(code: string): Promise<boolean>;
22
23
  export declare function getReleaseDependencyRewriteManifestState(releaseId: string | null | undefined): Promise<ReleaseDependencyRewriteManifestState>;
23
24
  export declare function rewriteReleaseDependencyImportsForModule(code: string, options: RewriteReleaseDependencyImportsOptions): Promise<string>;
24
25
  //# 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;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"}
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;AAWD,wBAAsB,oCAAoC,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CASzF;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"}
@@ -17,6 +17,26 @@ import { getReadyManifestForRenderAsync } from "./manifest-cache.js";
17
17
  export function isReleaseDependencyImportMapRewriteEnabled() {
18
18
  return getHostEnv(RELEASE_ASSET_DEPENDENCY_IMPORT_MAP_ENV_FLAG) === "1";
19
19
  }
20
+ function isHttpImportSpecifier(specifier) {
21
+ try {
22
+ const url = new URL(specifier);
23
+ return url.protocol === "http:" || url.protocol === "https:";
24
+ }
25
+ catch {
26
+ return false;
27
+ }
28
+ }
29
+ export async function hasReleaseDependencyImportSpecifiers(code) {
30
+ if (!code.includes("http") && !code.includes("veryfront-http-bundle"))
31
+ return false;
32
+ for (const imp of await parseImports(code)) {
33
+ if (!imp.n)
34
+ continue;
35
+ if (isHttpImportSpecifier(imp.n) || localHttpBundlePath(imp.n))
36
+ return true;
37
+ }
38
+ return false;
39
+ }
20
40
  export async function getReleaseDependencyRewriteManifestState(releaseId) {
21
41
  if (!releaseId || !isReleaseDependencyImportMapRewriteEnabled()) {
22
42
  return { enabled: false, manifest: null };
@@ -1,3 +1,3 @@
1
1
  /** Shared version value. */
2
- export declare const VERSION = "0.1.836";
2
+ export declare const VERSION = "0.1.838";
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.836";
4
+ export const VERSION = "0.1.838";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veryfront",
3
- "version": "0.1.836",
3
+ "version": "0.1.838",
4
4
  "description": "The simplest way to build AI-powered apps",
5
5
  "keywords": [
6
6
  "react",