veryfront 0.1.836 → 0.1.837
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 +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;
|
|
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;AAO1D,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;AA+GD,wBAAsB,cAAc,CAClC,OAAO,CAAC,EAAE,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACvD,OAAO,CAAC,cAAc,CAAC,CAiEzB;AAED,wBAAsB,kBAAkB,CACtC,OAAO,CAAC,EAAE,qBAAqB,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"}
|
package/esm/src/html/utils.js
CHANGED
|
@@ -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
|
}
|