@swiftbrowser/web 0.11.0 → 0.13.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/main.ts +7 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swiftbrowser/web",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "type": "module",
5
5
  "description": "SwiftBrowser web renderer and dev server: applies render ops from a Swift/Wasm app to the DOM inside an iPhone frame.",
6
6
  "repository": {
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
- const response = await fetch(catalogPath(app), { cache: 'no-cache' });
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
- return isAssetCatalog(json) ? json : EMPTY_CATALOG;
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
  }