@swiftbrowser/web 0.11.0 → 0.12.0
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/package.json +1 -1
- package/src/main.ts +7 -2
package/package.json
CHANGED
package/src/main.ts
CHANGED
|
@@ -484,10 +484,15 @@ async function loadBundle(app: string): Promise<Map<string, Uint8Array>> {
|
|
|
484
484
|
|
|
485
485
|
async function loadAssetCatalog(app: string): Promise<AssetCatalog> {
|
|
486
486
|
try {
|
|
487
|
-
|
|
487
|
+
// The manifest and its files are written at the site's root paths; a site
|
|
488
|
+
// served under a base path (`/native/`) has them under it.
|
|
489
|
+
const base = import.meta.env.BASE_URL;
|
|
490
|
+
const under = (path: string): string => (base !== '/' && path.startsWith('/') ? `${base.replace(/\/$/, '')}${path}` : path);
|
|
491
|
+
const response = await fetch(under(catalogPath(app)), { cache: 'no-cache' });
|
|
488
492
|
if (!response.ok) return EMPTY_CATALOG;
|
|
489
493
|
const json: unknown = await response.json();
|
|
490
|
-
|
|
494
|
+
if (!isAssetCatalog(json)) return EMPTY_CATALOG;
|
|
495
|
+
return { ...json, images: Object.fromEntries(Object.entries(json.images).map(([name, image]) => [name, { ...image, src: under(image.src) }])) };
|
|
491
496
|
} catch {
|
|
492
497
|
return EMPTY_CATALOG;
|
|
493
498
|
}
|